diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-09-16 14:54:40 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-09-16 14:54:40 +0200 |
commit | f82d08eb003689ee1a40d5015e1d5c67e0a940fd (patch) | |
tree | 52034d07d4c1c1f25bfe0e51dbb773cd224799b2 /lib/gnutls_algorithms.c | |
parent | fde91b3f4543c8a70bff52bb5115e456567487cb (diff) | |
download | gnutls-f82d08eb003689ee1a40d5015e1d5c67e0a940fd.tar.gz |
Add interfaces to get PK and PK-sign algorithms. Use them.
Diffstat (limited to 'lib/gnutls_algorithms.c')
-rw-r--r-- | lib/gnutls_algorithms.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/gnutls_algorithms.c b/lib/gnutls_algorithms.c index fdca82fa31..e023a432d4 100644 --- a/lib/gnutls_algorithms.c +++ b/lib/gnutls_algorithms.c @@ -1821,6 +1821,27 @@ gnutls_sign_get_id (const char *name) } +/** + * gnutls_sign_get_name - Get name string for a #gnutls_sign_algorithm_t + * @algorithm: is a public key signature algorithm + * + * Convert a #gnutls_sign_algorithm_t value to a string. + * + * Returns: a pointer to a string that contains the name of the + * specified public key signature algorithm, or %NULL. + * + * Since: 2.6.0 + **/ +const char * +gnutls_sign_get_name (gnutls_sign_algorithm_t algorithm) +{ + const char *ret = "SIGN_UNKNOWN"; + + GNUTLS_SIGN_LOOP (if (p->id == algorithm) ret = p->name); + + return ret; +} + gnutls_sign_algorithm_t _gnutls_x509_oid2sign_algorithm (const char *oid) { @@ -1959,6 +1980,41 @@ gnutls_pk_get_id (const char *name) return GNUTLS_PK_UNKNOWN; } +/** + * gnutls_pk_get_name - Get name string with #gnutls_pk_algorithm_t algorithm + * @algorithm: is a public key algorithm + * + * Convert a #gnutls_pk_algorithm_t value to a string. + * + * Returns: a pointer to a string that contains the name of the + * specified public key algorithm, or %NULL. + * + * Since: 2.6.0 + **/ +const char * +gnutls_pk_get_name (gnutls_pk_algorithm_t algorithm) +{ + const char *p; + + switch (algorithm) + { + case GNUTLS_PK_RSA: + p = "RSA"; + break; + + case GNUTLS_PK_DSA: + p = "DSA"; + break; + + default: + case GNUTLS_PK_UNKNOWN: + p = "PK_UNKNOWN"; + break; + } + + return p; +} + gnutls_pk_algorithm_t _gnutls_x509_oid2pk_algorithm (const char *oid) { |