From: Dmitry Eremin-Solenikov Date: Sat, 9 Feb 2019 23:38:43 +0000 (+0300) Subject: groups: add function to return group by curve X-Git-Tag: gnutls_3_6_11~14^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1412ef059395e2b404eb4e3c018d9cca4e790a98;p=thirdparty%2Fgnutls.git groups: add function to return group by curve 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 --- diff --git a/lib/algorithms.h b/lib/algorithms.h index d0191312f7..0d14331154 100644 --- a/lib/algorithms.h +++ b/lib/algorithms.h @@ -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); diff --git a/lib/algorithms/ecc.c b/lib/algorithms/ecc.c index 935bfb8672..8b4b78f67d 100644 --- a/lib/algorithms/ecc.c +++ b/lib/algorithms/ecc.c @@ -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; +}