diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2014-03-04 03:54:59 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2014-03-11 08:03:01 +0100 |
commit | ac5a1a3ccb7c3e6393bc83d73b545dec9b70e7d1 (patch) | |
tree | 66bfee42a5e19cad0c50651844b9bf7670a54ec9 /agent/pksign.c | |
parent | Backport useful code from fixes for bug 1447. (diff) | |
download | gnupg2-ac5a1a3ccb7c3e6393bc83d73b545dec9b70e7d1.tar.xz gnupg2-ac5a1a3ccb7c3e6393bc83d73b545dec9b70e7d1.zip |
agent: API change of agent_key_from_file.
* agent/findkey.c (agent_key_from_file): Always return S-expression.
* agent/command.c (cmd_passwd): Distinguish by SHADOW_INFO.
(cmd_export_key): Likewise. Free SHADOW_INFO.
(cmd_keytocard): Likewise. Release S_SKEY.
* agent/pkdecrypt.c (agent_pkdecrypt): Likewise.
* agent/pksign.c (agent_pksign_do): Likewise. Use the S-expression to
know the key type.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to '')
-rw-r--r-- | agent/pksign.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/agent/pksign.c b/agent/pksign.c index 4d0a240e9..088615011 100644 --- a/agent/pksign.c +++ b/agent/pksign.c @@ -299,31 +299,20 @@ agent_pksign_do (ctrl_t ctrl, const char *cache_nonce, goto leave; } - if (!s_skey) + if (shadow_info) { /* Divert operation to the smartcard */ - gcry_sexp_t s_pkey, l; - const char *name; size_t len; unsigned char *buf = NULL; + int key_type; int is_RSA = 0; int is_ECDSA = 0; - /* Check keytype by public key */ - rc = agent_public_key_from_file (ctrl, ctrl->keygrip, &s_pkey); - if (rc) - { - log_error ("failed to read the public key\n"); - goto leave; - } - l = gcry_sexp_cadr (s_pkey); - name = gcry_sexp_nth_data (l, 0, &len); - if (len == 3 && !memcmp (name, "rsa", 3)) + key_type = agent_is_dsa_key (s_skey); + if (key_type == 0) is_RSA = 1; - else if (len == 5 && !memcmp (name, "ecdsa", 5)) + else if (key_type == GCRY_PK_ECDSA) is_ECDSA = 1; - gcry_sexp_release (l); - gcry_sexp_release (s_pkey); rc = divert_pksign (ctrl, ctrl->digest.value, |