summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2019-06-24 17:38:56 +0300
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2019-06-26 11:01:19 +0300
commitde42342c24ba0d4f745a4a4ba29176bb79b1a9da (patch)
tree69b8f84da457a19398e4d43c4639e769cdc77555
parent4591181a6c06465393425e51c4c68a2a1126b8e8 (diff)
downloadgnutls-de42342c24ba0d4f745a4a4ba29176bb79b1a9da.tar.gz
api: add gnutls_hmac_copy() function
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>
-rw-r--r--devel/libgnutls-latest-x86_64.abi1
-rw-r--r--devel/symbols.last1
-rw-r--r--doc/Makefile.am2
-rw-r--r--doc/manpages/Makefile.am1
-rw-r--r--lib/crypto-api.c32
-rw-r--r--lib/includes/gnutls/crypto.h1
-rw-r--r--lib/libgnutls.map1
7 files changed, 39 insertions, 0 deletions
diff --git a/devel/libgnutls-latest-x86_64.abi b/devel/libgnutls-latest-x86_64.abi
index 11c4174508..c63a68d94e 100644
--- a/devel/libgnutls-latest-x86_64.abi
+++ b/devel/libgnutls-latest-x86_64.abi
@@ -309,6 +309,7 @@
<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'/>
diff --git a/devel/symbols.last b/devel/symbols.last
index c2287e0f53..e3d5fa22a5 100644
--- a/devel/symbols.last
+++ b/devel/symbols.last
@@ -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
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 3ab2ad0049..f5788e7618 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -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
diff --git a/doc/manpages/Makefile.am b/doc/manpages/Makefile.am
index 063ebcb659..d4d358ea5c 100644
--- a/doc/manpages/Makefile.am
+++ b/doc/manpages/Makefile.am
@@ -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
diff --git a/lib/crypto-api.c b/lib/crypto-api.c
index 0b6be4eed2..db7a08fd92 100644
--- a/lib/crypto-api.c
+++ b/lib/crypto-api.c
@@ -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 */
/**
diff --git a/lib/includes/gnutls/crypto.h b/lib/includes/gnutls/crypto.h
index 640924bed5..1afadd8759 100644
--- a/lib/includes/gnutls/crypto.h
+++ b/lib/includes/gnutls/crypto.h
@@ -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);
diff --git a/lib/libgnutls.map b/lib/libgnutls.map
index 338cae2b1b..8f504b70f0 100644
--- a/lib/libgnutls.map
+++ b/lib/libgnutls.map
@@ -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 {