]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
api: add gnutls_hmac_copy() function
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Mon, 24 Jun 2019 14:38:56 +0000 (17:38 +0300)
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Wed, 26 Jun 2019 08:01:19 +0000 (11:01 +0300)
Add gnutls_hmac_copy() API to duplicate MAC handler state, which is
necessary for SMB3 support.

Resolves: #787

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
devel/libgnutls-latest-x86_64.abi
devel/symbols.last
doc/Makefile.am
doc/manpages/Makefile.am
lib/crypto-api.c
lib/includes/gnutls/crypto.h
lib/libgnutls.map

index 11c41745083c35f49e27ae2ae2149f97dec43268..c63a68d94e45ece90f26b0bcc5fae8fb39306041 100644 (file)
     <elf-symbol name='gnutls_hex_encode2' version='GNUTLS_3_4' is-default-version='yes' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
     <elf-symbol name='gnutls_hex_encode' version='GNUTLS_3_4' is-default-version='yes' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
     <elf-symbol name='gnutls_hmac' version='GNUTLS_3_4' is-default-version='yes' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+    <elf-symbol name='gnutls_hmac_copy' version='GNUTLS_3_6_9' is-default-version='yes' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
     <elf-symbol name='gnutls_hmac_deinit' version='GNUTLS_3_4' is-default-version='yes' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
     <elf-symbol name='gnutls_hmac_fast' version='GNUTLS_3_4' is-default-version='yes' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
     <elf-symbol name='gnutls_hmac_get_len' version='GNUTLS_3_4' is-default-version='yes' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
index c2287e0f53e5a5d1cd527b9d9677e8b62577e0af..e3d5fa22a51854691307419619da4e9c00a29588 100644 (file)
@@ -279,6 +279,7 @@ gnutls_hex_decode@GNUTLS_3_4
 gnutls_hex_encode2@GNUTLS_3_4
 gnutls_hex_encode@GNUTLS_3_4
 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_len@GNUTLS_3_4
index 3ab2ad0049d5c2b8a3348c9c08643a5221a23852..f5788e7618e0b7bb564636c55d45f0d71a8e26aa 100644 (file)
@@ -1113,6 +1113,8 @@ FUNCS += functions/gnutls_hex_encode2
 FUNCS += functions/gnutls_hex_encode2.short
 FUNCS += functions/gnutls_hmac
 FUNCS += functions/gnutls_hmac.short
+FUNCS += functions/gnutls_hmac_copy
+FUNCS += functions/gnutls_hmac_copy.short
 FUNCS += functions/gnutls_hmac_deinit
 FUNCS += functions/gnutls_hmac_deinit.short
 FUNCS += functions/gnutls_hmac_fast
index 063ebcb6597b69e2b45bb57cbd8c4b2c16dd2279..d4d358ea5cc28f88c456ba7a53cbf18254ad752d 100644 (file)
@@ -358,6 +358,7 @@ APIMANS += gnutls_hex_decode2.3
 APIMANS += gnutls_hex_encode.3
 APIMANS += gnutls_hex_encode2.3
 APIMANS += gnutls_hmac.3
+APIMANS += gnutls_hmac_copy.3
 APIMANS += gnutls_hmac_deinit.3
 APIMANS += gnutls_hmac_fast.3
 APIMANS += gnutls_hmac_get_len.3
index 0b6be4eed22d83c558faaf8ce2c5c34ea1eef531..db7a08fd92d63d4e2f14286c3b8c0c92be9d62e5 100644 (file)
@@ -482,6 +482,38 @@ gnutls_hmac_fast(gnutls_mac_algorithm_t algorithm,
                                digest);
 }
 
+/**
+ * gnutls_hmac_copy:
+ * @handle: is a #gnutls_hmac_hd_t type
+ *
+ * This function will create a copy of MAC context, containing all its current
+ * state. Copying contexts for MACs registered using
+ * gnutls_crypto_register_mac() is not supported and will always result in an
+ * error.
+ *
+ * Returns: new MAC context or NULL in case of an error.
+ *
+ * Since: 3.6.9
+ */
+gnutls_hmac_hd_t gnutls_hmac_copy(gnutls_hmac_hd_t handle)
+{
+       gnutls_hmac_hd_t dig;
+
+       dig = gnutls_malloc(sizeof(mac_hd_st));
+       if (dig == NULL) {
+               gnutls_assert();
+               return NULL;
+       }
+
+       if (_gnutls_mac_copy((const mac_hd_st *) handle, (mac_hd_st *)dig) != GNUTLS_E_SUCCESS) {
+               gnutls_assert();
+               gnutls_free(dig);
+               return NULL;
+       }
+
+       return dig;
+}
+
 /* HASH */
 
 /**
index 640924bed5f107a467003a800de95f4ee62152a1..1afadd8759050fa2f89218063bb2119060b89247 100644 (file)
@@ -112,6 +112,7 @@ unsigned gnutls_hmac_get_len(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);
+gnutls_hmac_hd_t gnutls_hmac_copy(gnutls_hmac_hd_t handle);
 
 int gnutls_hash_init(gnutls_hash_hd_t * dig,
                     gnutls_digest_algorithm_t algorithm);
index 338cae2b1bb47f6a7411ddf3af72278bec364f9b..8f504b70f0e472e51b010ce64b941cad0131b8cf 100644 (file)
@@ -1290,6 +1290,7 @@ GNUTLS_3_6_9
 {
  global:
        gnutls_get_system_config_file;
+       gnutls_hmac_copy;
 } GNUTLS_3_6_8;
 
 GNUTLS_FIPS140_3_4 {