diff options
author | NIIBE Yutaka <[email protected]> | 2020-06-19 04:58:13 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2020-06-19 04:58:13 +0000 |
commit | d2e4aa5ee4c5128547cc45c2e1ac35fdc5c00f45 (patch) | |
tree | 0e4fe7cc81e885bbd86a0c48f4f41c71fc15bb06 /agent/findkey.c | |
parent | agent: A little clean up. (diff) | |
download | gnupg-d2e4aa5ee4c5128547cc45c2e1ac35fdc5c00f45.tar.gz gnupg-d2e4aa5ee4c5128547cc45c2e1ac35fdc5c00f45.zip |
agent: Clean up for getting info from SEXP.
* agent/agent.h (agent_is_dsa_key, agent_is_eddsa_key): Remove.
(agent_pk_get_algo): New.
* agent/findkey.c (agent_pk_get_algo): New.
* agent/pksign.c (do_encode_dsa): Use generic GCRY_PK_ECC.
(agent_pksign_do): Use agent_pk_get_algo.
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'agent/findkey.c')
-rw-r--r-- | agent/findkey.c | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/agent/findkey.c b/agent/findkey.c index 53a08b89f..d1b688888 100644 --- a/agent/findkey.c +++ b/agent/findkey.c @@ -1258,10 +1258,10 @@ is_eddsa (gcry_sexp_t keyparms) } -/* Return the public key algorithm number if S_KEY is a DSA style key. - If it is not a DSA style key, return 0. */ +/* Return the public key algorithm number of S_KEY. For ECC, returns + GCRY_PK_ECC (generic), even if it is known specifically for ECDSA. */ int -agent_is_dsa_key (gcry_sexp_t s_key) +agent_pk_get_algo (gcry_sexp_t s_key) { int result; gcry_sexp_t list; @@ -1271,43 +1271,21 @@ agent_is_dsa_key (gcry_sexp_t s_key) return 0; if (key_parms_from_sexp (s_key, &list, algoname, sizeof algoname, NULL, 0)) - return 0; /* Error - assume it is not an DSA key. */ + return 0; - if (!strcmp (algoname, "dsa")) + if (!strcmp (algoname, "rsa")) + result = GCRY_PK_RSA; + else if (!strcmp (algoname, "dsa")) result = GCRY_PK_DSA; else if (!strcmp (algoname, "ecc")) { if (is_eddsa (list)) - result = 0; + result = GCRY_PK_EDDSA; else - result = GCRY_PK_ECDSA; + result = GCRY_PK_ECC; } else if (!strcmp (algoname, "ecdsa")) - result = GCRY_PK_ECDSA; - else - result = 0; - - gcry_sexp_release (list); - return result; -} - - -/* Return true if S_KEY is an EdDSA key as used with curve Ed25519. */ -int -agent_is_eddsa_key (gcry_sexp_t s_key) -{ - int result; - gcry_sexp_t list; - char algoname[6]; - - if (!s_key) - return 0; - - if (key_parms_from_sexp (s_key, &list, algoname, sizeof algoname, NULL, 0)) - return 0; /* Error - assume it is not an EdDSA key. */ - - if (!strcmp (algoname, "ecc") && is_eddsa (list)) - result = 1; + result = GCRY_PK_ECC; else result = 0; |