summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-08-17 15:34:28 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-08-17 15:34:28 +0000
commitdd494d951bb079759c37d460a2905ca423ba9f77 (patch)
treefaafb0408535747f08d9c75d4f4da61a9348a8c4
parent1ff341f855f3fd019d1c6e2d9c2b63b12c27a679 (diff)
downloadgnutls-dd494d951bb079759c37d460a2905ca423ba9f77.tar.gz
Added gnutls_cipher_suite_get_name(). This functions constructs the name of a cipher suite using the given algorithms.
-rw-r--r--lib/gnutls.h.in.in4
-rw-r--r--lib/gnutls_algorithms.c26
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in
index f2473bfaf1..52d6875edd 100644
--- a/lib/gnutls.h.in.in
+++ b/lib/gnutls.h.in.in
@@ -177,6 +177,10 @@ int gnutls_kx_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
int gnutls_protocol_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
int gnutls_cert_type_set_priority( GNUTLS_STATE state, GNUTLS_LIST);
+/* Returns the name of a cipher suite */
+const char *gnutls_cipher_suite_get_name(GNUTLS_KXAlgorithm kx_algorithm,
+ GNUTLS_BulkCipherAlgorithm cipher_algorithm, GNUTLS_MACAlgorithm mac_algorithm);
+
/* get the currently used protocol version */
GNUTLS_Version gnutls_protocol_get_version(GNUTLS_STATE state);
diff --git a/lib/gnutls_algorithms.c b/lib/gnutls_algorithms.c
index 17d7e64e39..849284ccd9 100644
--- a/lib/gnutls_algorithms.c
+++ b/lib/gnutls_algorithms.c
@@ -835,12 +835,36 @@ const char *_gnutls_cipher_suite_get_name(GNUTLS_CipherSuite suite)
/* avoid prefix */
GNUTLS_CIPHER_SUITE_ALG_LOOP(ret =
- p->name + sizeof("GNUTLS_") -
+ p->name + sizeof("GNU") -
1);
return ret;
}
+/**
+ * gnutls_cipher_suite_get_name - Returns a string with the name of the specified cipher suite
+ * @kx_algorithm: is a Key exchange algorithm
+ * @cipher_algorithm: is a cipher algorithm
+ * @mac_algorithm: is a MAC algorithm
+ *
+ * Returns a string that contains the name
+ * of the specified MAC algorithm.
+ **/
+const char *gnutls_cipher_suite_get_name(GNUTLS_KXAlgorithm kx_algorithm,
+ GNUTLS_BulkCipherAlgorithm cipher_algorithm, GNUTLS_MACAlgorithm mac_algorithm)
+{
+ const char *ret = NULL;
+
+ /* avoid prefix */
+ GNUTLS_CIPHER_SUITE_LOOP(
+ if (kx_algorithm == p->kx_algorithm &&
+ cipher_algorithm == p->block_algorithm &&
+ mac_algorithm == p->mac_algorithm)
+ ret = p->name + sizeof("GNU") - 1);
+
+ return ret;
+}
+
inline
static int _gnutls_cipher_suite_is_ok(GNUTLS_CipherSuite suite)
{