diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/sexputil.c | 17 | ||||
-rw-r--r-- | common/util.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/common/sexputil.c b/common/sexputil.c index 89e63a765..66cd9f60e 100644 --- a/common/sexputil.c +++ b/common/sexputil.c @@ -642,6 +642,23 @@ pubkey_algo_string (gcry_sexp_t s_pkey, enum gcry_pk_algos *r_algoid) } +/* Map a pubkey algo id from gcrypt to a string. This is the same as + * gcry_pk_algo_name but makes sure that the ECC algo identifiers are + * not all mapped to "ECC". */ +const char * +pubkey_algo_to_string (int algo) +{ + if (algo == GCRY_PK_ECDSA) + return "ECDSA"; + else if (algo == GCRY_PK_ECDH) + return "ECDH"; + else if (algo == GCRY_PK_EDDSA) + return "EdDSA"; + else + return gcry_pk_algo_name (algo); +} + + /* Map a hash algo id from gcrypt to a string. This is the same as * gcry_md_algo_name but the returned string is lower case, as * expected by libksba and it avoids some overhead. */ diff --git a/common/util.h b/common/util.h index d22a1bf60..f2b4306c3 100644 --- a/common/util.h +++ b/common/util.h @@ -202,6 +202,7 @@ int get_pk_algo_from_key (gcry_sexp_t key); int get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen); char *pubkey_algo_string (gcry_sexp_t s_pkey, enum gcry_pk_algos *r_algoid); +const char *pubkey_algo_to_string (int algo); const char *hash_algo_to_string (int algo); /*-- convert.c --*/ |