summaryrefslogtreecommitdiff
path: root/lib/algorithms
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2015-06-18 13:59:57 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2015-06-18 13:59:57 +0200
commit83cd49383d6ab2541c3258253824c37d7fce0213 (patch)
treecc78236eaa7e327e38cca743878e57ac4a398f7f /lib/algorithms
parentb0c5ba7b3d3779060f7e6cc685bc4098e9dab680 (diff)
downloadgnutls-83cd49383d6ab2541c3258253824c37d7fce0213.tar.gz
Exported functions to convert from and to OIDs
Diffstat (limited to 'lib/algorithms')
-rw-r--r--lib/algorithms/ecc.c34
-rw-r--r--lib/algorithms/mac.c42
-rw-r--r--lib/algorithms/publickey.c26
-rw-r--r--lib/algorithms/sign.c32
4 files changed, 107 insertions, 27 deletions
diff --git a/lib/algorithms/ecc.c b/lib/algorithms/ecc.c
index 9f455a699f..cef9bf4c6a 100644
--- a/lib/algorithms/ecc.c
+++ b/lib/algorithms/ecc.c
@@ -133,14 +133,16 @@ int _gnutls_ecc_curve_get_tls_id(gnutls_ecc_curve_t supported_ecc)
return ret;
}
-/*-
- * _gnutls_oid_to_ecc_curve:
+/**
+ * gnutls_oid_to_ecc_curve:
* @oid: is a curve's OID
*
* Returns: return a #gnutls_ecc_curve_t value corresponding to
* the specified OID, or %GNUTLS_ECC_CURVE_INVALID on error.
- -*/
-gnutls_ecc_curve_t _gnutls_oid_to_ecc_curve(const char *oid)
+ *
+ * Since: 3.4.3
+ **/
+gnutls_ecc_curve_t gnutls_oid_to_ecc_curve(const char *oid)
{
gnutls_ecc_curve_t ret = GNUTLS_ECC_CURVE_INVALID;
@@ -154,16 +156,18 @@ gnutls_ecc_curve_t _gnutls_oid_to_ecc_curve(const char *oid)
return ret;
}
-/*-
- * _gnutls_ecc_curve_get_id:
+/**
+ * gnutls_ecc_curve_get_id:
* @name: is a curve name
*
* The names are compared in a case insensitive way.
*
* Returns: return a #gnutls_ecc_curve_t value corresponding to
* the specified curve, or %GNUTLS_ECC_CURVE_INVALID on error.
- -*/
-gnutls_ecc_curve_t _gnutls_ecc_curve_get_id(const char *name)
+ *
+ * Since: 3.4.3
+ **/
+gnutls_ecc_curve_t gnutls_ecc_curve_get_id(const char *name)
{
gnutls_ecc_curve_t ret = GNUTLS_ECC_CURVE_INVALID;
@@ -223,16 +227,18 @@ const char *gnutls_ecc_curve_get_name(gnutls_ecc_curve_t curve)
return ret;
}
-/*-
- * _gnutls_ecc_curve_get_oid:
+/**
+ * gnutls_ecc_curve_get_oid:
* @curve: is an ECC curve
*
- * Convert a #gnutls_ecc_curve_t value to a string.
+ * Convert a #gnutls_ecc_curve_t value to its object identifier.
*
- * Returns: a string that contains the name of the specified
+ * Returns: a string that contains the OID of the specified
* curve or %NULL.
- -*/
-const char *_gnutls_ecc_curve_get_oid(gnutls_ecc_curve_t curve)
+ *
+ * Since: 3.4.3
+ **/
+const char *gnutls_ecc_curve_get_oid(gnutls_ecc_curve_t curve)
{
const char *ret = NULL;
diff --git a/lib/algorithms/mac.c b/lib/algorithms/mac.c
index c17355a8a8..c8b2c941ec 100644
--- a/lib/algorithms/mac.c
+++ b/lib/algorithms/mac.c
@@ -124,7 +124,7 @@ const char *gnutls_digest_get_name(gnutls_digest_algorithm_t algorithm)
* compared in a case insensitive way.
*
* Returns: a #gnutls_digest_algorithm_t id of the specified MAC
- * algorithm string, or %GNUTLS_DIG_UNKNOWN on failures.
+ * algorithm string, or %GNUTLS_DIG_UNKNOWN on failure.
**/
gnutls_digest_algorithm_t gnutls_digest_get_id(const char *name)
{
@@ -149,7 +149,7 @@ gnutls_digest_algorithm_t gnutls_digest_get_id(const char *name)
* compared in a case insensitive way.
*
* Returns: a #gnutls_mac_algorithm_t id of the specified MAC
- * algorithm string, or %GNUTLS_MAC_UNKNOWN on failures.
+ * algorithm string, or %GNUTLS_MAC_UNKNOWN on failure.
**/
gnutls_mac_algorithm_t gnutls_mac_get_id(const char *name)
{
@@ -263,7 +263,18 @@ const gnutls_digest_algorithm_t *gnutls_digest_list(void)
return supported_digests;
}
-gnutls_digest_algorithm_t _gnutls_x509_oid_to_digest(const char *oid)
+/**
+ * gnutls_oid_to_digest:
+ * @oid: is an object identifier
+ *
+ * Converts a textual object identifier to a #gnutls_digest_algorithm_t value.
+ *
+ * Returns: a #gnutls_digest_algorithm_t id of the specified digest
+ * algorithm, or %GNUTLS_DIG_UNKNOWN on failure.
+ *
+ * Since: 3.4.3
+ **/
+gnutls_digest_algorithm_t gnutls_oid_to_digest(const char *oid)
{
gnutls_digest_algorithm_t ret = 0;
@@ -278,3 +289,28 @@ gnutls_digest_algorithm_t _gnutls_x509_oid_to_digest(const char *oid)
return GNUTLS_DIG_UNKNOWN;
return ret;
}
+
+/**
+ * gnutls_digest_get_oid:
+ * @algorithm: is a digest algorithm
+ *
+ * Convert a #gnutls_digest_algorithm_t value to its object identifier.
+ *
+ * Returns: a string that contains the object identifier of the specified digest
+ * algorithm, or %NULL.
+ *
+ * Since: 3.4.3
+ **/
+const char *gnutls_digest_get_oid(gnutls_digest_algorithm_t algorithm)
+{
+ const char *ret = NULL;
+
+ GNUTLS_HASH_LOOP(
+ if (algorithm == (unsigned) p->id && p->oid != NULL) {
+ ret = p->oid;
+ break;
+ }
+ );
+
+ return ret;
+}
diff --git a/lib/algorithms/publickey.c b/lib/algorithms/publickey.c
index 59738d6ccf..d921be4a63 100644
--- a/lib/algorithms/publickey.c
+++ b/lib/algorithms/publickey.c
@@ -209,7 +209,18 @@ const char *gnutls_pk_get_name(gnutls_pk_algorithm_t algorithm)
return ret;
}
-gnutls_pk_algorithm_t _gnutls_x509_oid2pk_algorithm(const char *oid)
+/**
+ * gnutls_oid_to_pk:
+ * @oid: is an object identifier
+ *
+ * Converts a textual object identifier to a #gnutls_pk_algorithm_t value.
+ *
+ * Returns: a #gnutls_pk_algorithm_t id of the specified digest
+ * algorithm, or %GNUTLS_PK_UNKNOWN on failure.
+ *
+ * Since: 3.4.3
+ **/
+gnutls_pk_algorithm_t gnutls_oid_to_pk(const char *oid)
{
gnutls_pk_algorithm_t ret = GNUTLS_PK_UNKNOWN;
const gnutls_pk_entry *p;
@@ -223,7 +234,18 @@ gnutls_pk_algorithm_t _gnutls_x509_oid2pk_algorithm(const char *oid)
return ret;
}
-const char *_gnutls_x509_pk_to_oid(gnutls_pk_algorithm_t algorithm)
+/**
+ * gnutls_pk_get_oid:
+ * @algorithm: is a public key algorithm
+ *
+ * Convert a #gnutls_pk_algorithm_t value to its object identifier string.
+ *
+ * Returns: a pointer to a string that contains the object identifier of the
+ * specified public key algorithm, or %NULL.
+ *
+ * Since: 3.4.3
+ **/
+const char *gnutls_pk_get_oid(gnutls_pk_algorithm_t algorithm)
{
const char *ret = NULL;
const gnutls_pk_entry *p;
diff --git a/lib/algorithms/sign.c b/lib/algorithms/sign.c
index e69cd0c531..f322d3cc9d 100644
--- a/lib/algorithms/sign.c
+++ b/lib/algorithms/sign.c
@@ -195,7 +195,18 @@ gnutls_sign_algorithm_t gnutls_sign_get_id(const char *name)
}
-gnutls_sign_algorithm_t _gnutls_x509_oid2sign_algorithm(const char *oid)
+/**
+ * gnutls_oid_to_sign:
+ * @oid: is an object identifier
+ *
+ * Converts a textual object identifier to a #gnutls_sign_algorithm_t value.
+ *
+ * Returns: a #gnutls_sign_algorithm_t id of the specified digest
+ * algorithm, or %GNUTLS_SIGN_UNKNOWN on failure.
+ *
+ * Since: 3.4.3
+ **/
+gnutls_sign_algorithm_t gnutls_oid_to_sign(const char *oid)
{
gnutls_sign_algorithm_t ret = 0;
@@ -238,16 +249,21 @@ gnutls_pk_to_sign(gnutls_pk_algorithm_t pk, gnutls_digest_algorithm_t hash)
return ret;
}
-const char *_gnutls_x509_sign_to_oid(gnutls_pk_algorithm_t pk,
- gnutls_digest_algorithm_t mac)
+/**
+ * gnutls_sign_get_oid:
+ * @sign: is a sign algorithm
+ *
+ * Convert a #gnutls_sign_algorithm_t value to its object identifier.
+ *
+ * Returns: a string that contains the object identifier of the specified sign
+ * algorithm, or %NULL.
+ *
+ * Since: 3.4.3
+ **/
+const char *gnutls_sign_get_oid(gnutls_sign_algorithm_t sign)
{
- gnutls_sign_algorithm_t sign;
const char *ret = NULL;
- sign = gnutls_pk_to_sign(pk, mac);
- if (sign == GNUTLS_SIGN_UNKNOWN)
- return NULL;
-
GNUTLS_SIGN_ALG_LOOP(ret = p->oid);
return ret;
}