From 6037706541616cfd2d4b49f6f5939ce6dddd1a53 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin-Solenikov Date: Tue, 24 Dec 2019 02:31:30 +0300 Subject: crypto-api: add gnutls_hmac_get_key_size() function Add gnutls_hmac_get_key_size() to retrieve MAC key size. Signed-off-by: Dmitry Eremin-Solenikov --- devel/libgnutls-latest-x86_64.abi | 1 + devel/symbols.last | 1 + doc/Makefile.am | 2 ++ doc/manpages/Makefile.am | 1 + lib/crypto-api.c | 17 +++++++++++++++++ lib/includes/gnutls/crypto.h | 1 + lib/libgnutls.map | 1 + 7 files changed, 24 insertions(+) diff --git a/devel/libgnutls-latest-x86_64.abi b/devel/libgnutls-latest-x86_64.abi index 9cc1908291..bf45d3c5b1 100644 --- a/devel/libgnutls-latest-x86_64.abi +++ b/devel/libgnutls-latest-x86_64.abi @@ -323,6 +323,7 @@ + diff --git a/devel/symbols.last b/devel/symbols.last index 4ad0268aa1..1e0e56d5c0 100644 --- a/devel/symbols.last +++ b/devel/symbols.last @@ -289,6 +289,7 @@ gnutls_hmac@GNUTLS_3_4 gnutls_hmac_copy@GNUTLS_3_6_9 gnutls_hmac_deinit@GNUTLS_3_4 gnutls_hmac_fast@GNUTLS_3_4 +gnutls_hmac_get_key_size@GNUTLS_3_6_12 gnutls_hmac_get_len@GNUTLS_3_4 gnutls_hmac_init@GNUTLS_3_4 gnutls_hmac_output@GNUTLS_3_4 diff --git a/doc/Makefile.am b/doc/Makefile.am index fc8360c73c..aa3984ffe1 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1129,6 +1129,8 @@ FUNCS += functions/gnutls_hmac_deinit FUNCS += functions/gnutls_hmac_deinit.short FUNCS += functions/gnutls_hmac_fast FUNCS += functions/gnutls_hmac_fast.short +FUNCS += functions/gnutls_hmac_get_key_size +FUNCS += functions/gnutls_hmac_get_key_size.short FUNCS += functions/gnutls_hmac_get_len FUNCS += functions/gnutls_hmac_get_len.short FUNCS += functions/gnutls_hmac_init diff --git a/doc/manpages/Makefile.am b/doc/manpages/Makefile.am index 7f8db7f943..85d0f7f0e4 100644 --- a/doc/manpages/Makefile.am +++ b/doc/manpages/Makefile.am @@ -366,6 +366,7 @@ APIMANS += gnutls_hmac.3 APIMANS += gnutls_hmac_copy.3 APIMANS += gnutls_hmac_deinit.3 APIMANS += gnutls_hmac_fast.3 +APIMANS += gnutls_hmac_get_key_size.3 APIMANS += gnutls_hmac_get_len.3 APIMANS += gnutls_hmac_init.3 APIMANS += gnutls_hmac_output.3 diff --git a/lib/crypto-api.c b/lib/crypto-api.c index d3e8094563..4db6812c29 100644 --- a/lib/crypto-api.c +++ b/lib/crypto-api.c @@ -455,6 +455,23 @@ unsigned gnutls_hmac_get_len(gnutls_mac_algorithm_t algorithm) return _gnutls_mac_get_algo_len(mac_to_entry(algorithm)); } +/** + * gnutls_hmac_get_key_size: + * @algorithm: the mac algorithm to use + * + * This function will return the size of the key to be used with this + * algorithm. On the algorithms which may accept arbitrary key sizes, + * the returned size is the MAC key size used in the TLS protocol. + * + * Returns: The key size or zero on error. + * + * Since: 3.6.12 + **/ +unsigned gnutls_hmac_get_key_size(gnutls_mac_algorithm_t algorithm) +{ + return _gnutls_mac_get_key_size(mac_to_entry(algorithm)); +} + /** * gnutls_hmac_fast: * @algorithm: the hash algorithm to use diff --git a/lib/includes/gnutls/crypto.h b/lib/includes/gnutls/crypto.h index 4d4926c86a..685d9d5d29 100644 --- a/lib/includes/gnutls/crypto.h +++ b/lib/includes/gnutls/crypto.h @@ -123,6 +123,7 @@ int gnutls_hmac(gnutls_hmac_hd_t handle, const void *text, size_t textlen); void gnutls_hmac_output(gnutls_hmac_hd_t handle, void *digest); void gnutls_hmac_deinit(gnutls_hmac_hd_t handle, void *digest); unsigned gnutls_hmac_get_len(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__; +unsigned gnutls_hmac_get_key_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__; int gnutls_hmac_fast(gnutls_mac_algorithm_t algorithm, const void *key, size_t keylen, const void *text, size_t textlen, void *digest); diff --git a/lib/libgnutls.map b/lib/libgnutls.map index ea84a1470d..e1878bb00c 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -1306,6 +1306,7 @@ GNUTLS_3_6_12 global: gnutls_certificate_verification_profile_get_name; gnutls_certificate_verification_profile_get_id; + gnutls_hmac_get_key_size; } GNUTLS_3_6_10; GNUTLS_FIPS140_3_4 { -- cgit v1.2.1