]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
groups: add function to return group by curve
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Sat, 9 Feb 2019 23:38:43 +0000 (02:38 +0300)
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Thu, 7 Nov 2019 15:41:29 +0000 (18:41 +0300)
Two GOST groups will have two curves attached. Add function to retrieve
group by curve, rather than by group id.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
lib/algorithms.h
lib/algorithms/ecc.c

index d0191312f78fa89a24f5709652ab4979a767e6e6..0d143311540fa6f35ff3671943c74ad94bb8ef1e 100644 (file)
@@ -437,6 +437,7 @@ const gnutls_ecc_curve_entry_st
 
 unsigned _gnutls_ecc_curve_is_supported(gnutls_ecc_curve_t);
 
+gnutls_group_t _gnutls_ecc_curve_get_group(gnutls_ecc_curve_t);
 const gnutls_group_entry_st *_gnutls_tls_id_to_group(unsigned num);
 const gnutls_group_entry_st * _gnutls_id_to_group(unsigned id);
 
index 935bfb8672bd673ce01384e2dc99d227e59a689c..8b4b78f67d03f138a3537d9947d303a8582e80eb 100644 (file)
@@ -510,3 +510,24 @@ gnutls_pk_algorithm_t gnutls_ecc_curve_get_pk(gnutls_ecc_curve_t curve)
        return ret;
 }
 
+/**
+ * _gnutls_ecc_curve_get_group:
+ * @curve: is an ECC curve
+ *
+ * Returns: the group associated with the named curve or %GNUTLS_GROUP_INVALID.
+ *
+ * Since: 3.6.11
+ */
+gnutls_group_t _gnutls_ecc_curve_get_group(gnutls_ecc_curve_t curve)
+{
+       gnutls_group_t ret = GNUTLS_GROUP_INVALID;
+
+       GNUTLS_ECC_CURVE_LOOP(
+               if (p->id == curve && p->supported && _gnutls_pk_curve_exists(p->id)) {
+                       ret = p->group;
+                       break;
+               }
+       );
+
+       return ret;
+}