diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2019-02-10 02:38:43 +0300 |
---|---|---|
committer | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2019-11-07 18:41:29 +0300 |
commit | 1412ef059395e2b404eb4e3c018d9cca4e790a98 (patch) | |
tree | 67b0e9ca57f22cafb837b7985eab2fcd5983e969 | |
parent | 1cc1ee4f4da3ecf75b9c43eb096b413cd7375d0c (diff) | |
download | gnutls-1412ef059395e2b404eb4e3c018d9cca4e790a98.tar.gz |
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 <dbaryshkov@gmail.com>
-rw-r--r-- | lib/algorithms.h | 1 | ||||
-rw-r--r-- | lib/algorithms/ecc.c | 21 |
2 files changed, 22 insertions, 0 deletions
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; +} |