summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2004-04-17 09:25:39 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2004-04-17 09:25:39 +0000
commit3a8ea8b0000c994080c8ea262ac5d6b846bfb0f9 (patch)
tree49a757e8cb2a292f04b48c0e2fa508de081e4bc6 /lib
parent04f22137403191c24b5fc3f3947a62eb72a2a702 (diff)
downloadgnutls-3a8ea8b0000c994080c8ea262ac5d6b846bfb0f9.tar.gz
Added gnutls_sign_algorithm_get_name() and gnutls_pk_algorithm_get_name().
Diffstat (limited to 'lib')
-rw-r--r--lib/gnutls.h.in.in4
-rw-r--r--lib/gnutls_algorithms.c84
2 files changed, 88 insertions, 0 deletions
diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in
index c5682ea772..a961f262bd 100644
--- a/lib/gnutls.h.in.in
+++ b/lib/gnutls.h.in.in
@@ -164,11 +164,15 @@ typedef enum gnutls_pk_algorithm { GNUTLS_PK_RSA = 1, GNUTLS_PK_DSA,
GNUTLS_PK_UNKNOWN = 0xff
} gnutls_pk_algorithm;
+const char *gnutls_pk_algorithm_get_name( gnutls_pk_algorithm algorithm);
+
typedef enum gnutls_sign_algorithm { GNUTLS_SIGN_RSA_SHA = 1, GNUTLS_SIGN_DSA_SHA,
GNUTLS_SIGN_RSA_MD5, GNUTLS_SIGN_RSA_MD2,
GNUTLS_SIGN_UNKNOWN = 0xff
} gnutls_sign_algorithm;
+const char *gnutls_sign_algorithm_get_name( gnutls_sign_algorithm algorithm);
+
/* If you want to change this, then also change the
* define in gnutls_int.h, and recompile.
*/
diff --git a/lib/gnutls_algorithms.c b/lib/gnutls_algorithms.c
index 57b9c6e78f..7d9937aa40 100644
--- a/lib/gnutls_algorithms.c
+++ b/lib/gnutls_algorithms.c
@@ -1366,3 +1366,87 @@ enum encipher_type _gnutls_kx_encipher_type(gnutls_kx_algorithm kx_algorithm)
return ret;
}
+
+/* signature algorithms;
+ */
+struct gnutls_sign_entry {
+ const char *name;
+ gnutls_sign_algorithm id;
+};
+typedef struct gnutls_sign_entry gnutls_sign_entry;
+
+static const gnutls_sign_entry sign_algorithms[] = {
+ {"RSA-SHA", GNUTLS_SIGN_RSA_SHA},
+ {"DSA-SHA", GNUTLS_SIGN_DSA_SHA},
+ {"RSA-MD5", GNUTLS_SIGN_RSA_MD5},
+ {"RSA-MD2", GNUTLS_SIGN_RSA_MD2},
+ {0, 0}
+};
+
+#define GNUTLS_SIGN_LOOP(b) \
+ const gnutls_sign_entry *p; \
+ for(p = sign_algorithms; p->name != NULL; p++) { b ; }
+
+#define GNUTLS_SIGN_ALG_LOOP(a) \
+ GNUTLS_SIGN_LOOP( if(p->id == algorithm) { a; break; } )
+
+
+
+/**
+ * gnutls_sign_algorithm_get_name - Returns a string with the name of the specified sign algorithm
+ * @algorithm: is a sign algorithm
+ *
+ * Returns a string that contains the name
+ * of the specified sign algorithm or NULL.
+ **/
+const char *gnutls_sign_algorithm_get_name( gnutls_sign_algorithm algorithm)
+{
+ const char *ret = NULL;
+
+ /* avoid prefix */
+ GNUTLS_SIGN_ALG_LOOP(ret =
+ p->name);
+
+ return ret;
+}
+
+/* pk algorithms;
+ */
+struct gnutls_pk_entry {
+ const char *name;
+ gnutls_pk_algorithm id;
+};
+typedef struct gnutls_pk_entry gnutls_pk_entry;
+
+static const gnutls_pk_entry pk_algorithms[] = {
+ {"RSA", GNUTLS_PK_RSA},
+ {"DSA", GNUTLS_PK_DSA},
+ {0, 0}
+};
+
+#define GNUTLS_PK_LOOP(b) \
+ const gnutls_pk_entry *p; \
+ for(p = pk_algorithms; p->name != NULL; p++) { b ; }
+
+#define GNUTLS_PK_ALG_LOOP(a) \
+ GNUTLS_PK_LOOP( if(p->id == algorithm) { a; break; } )
+
+
+
+/**
+ * gnutls_pk_algorithm_get_name - Returns a string with the name of the specified public key algorithm
+ * @algorithm: is a pk algorithm
+ *
+ * Returns a string that contains the name
+ * of the specified public key algorithm or NULL.
+ **/
+const char *gnutls_pk_algorithm_get_name( gnutls_pk_algorithm algorithm)
+{
+ const char *ret = NULL;
+
+ /* avoid prefix */
+ GNUTLS_PK_ALG_LOOP(ret =
+ p->name);
+
+ return ret;
+}