]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Add gnutls_pk_list and gnutls_pk_get_id.
authorSimon Josefsson <simon@josefsson.org>
Mon, 1 Sep 2008 14:18:31 +0000 (16:18 +0200)
committerSimon Josefsson <simon@josefsson.org>
Mon, 1 Sep 2008 14:18:31 +0000 (16:18 +0200)
Suggested by Sam Varshavchik <mrsam@courier-mta.com>.

NEWS
includes/gnutls/gnutls.h.in
lib/gnutls_algorithms.c

diff --git a/NEWS b/NEWS
index a06cfdf9fdb173d8ce2db93035eae0a8d819a432..709e36829ab82cd0dcc515efdd67dbaa49359433 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,14 @@ See the end for copying conditions.
 
 * Version 2.5.6 (unreleased)
 
+** Add interface to deal with public key algorithms.
+The functions are called gnutls_pk_list and gnutls_pk_get_id.
+Suggested by Sam Varshavchik <mrsam@courier-mta.com>.
+
+** API and ABI modifications:
+gnutls_pk_list: ADDED
+gnutls_pk_get_id: ADDED
+
 * Version 2.5.5 (released 2008-08-29)
 
 ** libgnutls: New API to get a string corresponding to a error symbol.
index 7141c8b064c5e3e3511eff46b42ea0700b7217a1..54310378ecc77275c6607928f46855fc4246185d 100644 (file)
@@ -415,7 +415,7 @@ extern "C"
   gnutls_kx_algorithm_t gnutls_kx_get_id (const char* name);
   gnutls_protocol_t gnutls_protocol_get_id (const char* name);
   gnutls_certificate_type_t gnutls_certificate_type_get_id (const char* name);
-
+  gnutls_pk_algorithm_t gnutls_pk_get_id (const char *name);
 
   /* list supported algorithms */
   const gnutls_cipher_algorithm_t *gnutls_cipher_list (void);
@@ -424,6 +424,7 @@ extern "C"
   const gnutls_protocol_t *gnutls_protocol_list (void);
   const gnutls_certificate_type_t *gnutls_certificate_type_list (void);
   const gnutls_kx_algorithm_t *gnutls_kx_list (void);
+  const gnutls_pk_algorithm_t *gnutls_pk_list (void);
   const char *gnutls_cipher_suite_info (size_t i,
                                        char *id,
                                        gnutls_kx_algorithm_t *kx,
index 835cc2242e27743cc1a323a6669112a8c20b4ce1..67b3549f9edc7fcad553c61e9b427b64989401f6 100644 (file)
@@ -2091,6 +2091,51 @@ gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t algorithm)
   return ret;
 }
 
+/**
+ * gnutls_pk_list - Get a list of supported public key algorithms
+ *
+ * Get a list of supported public key algorithms.
+ *
+ * Returns: a zero-terminated list of #gnutls_pk_algorithm_t integers
+ *   indicating the available ciphers.
+ *
+ * Since: 2.6.0
+ **/
+const gnutls_pk_algorithm_t *
+gnutls_pk_list (void)
+{
+  const static supported_pks[] = {
+    GNUTLS_PK_RSA,
+    GNUTLS_PK_DSA
+  };
+
+  return supported_pks;
+}
+
+/**
+ * gnutls_pk_get_id - Get #gnutls_pk_algorithm_t from a string
+ * @name: is a string containing a public key algorithm name.
+ *
+ * Convert a string to a #gnutls_pk_algorithm_t value.  The names are
+ * compared in a case insensitive way.  For example,
+ * gnutls_pk_get_id("RSA") will return %GNUTLS_PK_RSA.
+ *
+ * Returns: an #gnutls_pk_algorithm_tid of the specified in a string
+ *   public key algorithm, or %GNUTLS_PK_UNKNOWN on failures.
+ *
+ * Since: 2.6.0
+ **/
+gnutls_pk_algorithm_t
+gnutls_pk_get_id (const char *name)
+{
+  if (strcasecmp (name, "RSA") == 0)
+    return GNUTLS_PK_RSA;
+  else if  (strcasecmp (name, "DSA") == 0)
+    return GNUTLS_PK_DSA;
+
+  return GNUTLS_PK_UNKNOWN;
+}
+
 gnutls_pk_algorithm_t
 _gnutls_x509_oid2pk_algorithm (const char *oid)
 {