diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2016-11-30 01:32:30 +0300 |
---|---|---|
committer | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2019-06-24 03:08:23 +0300 |
commit | 92daa9548dfd53490e6e463e4ce5185cdd766be0 (patch) | |
tree | 14f3e6caac7ce8a9fe4279c1b476050ceec7732e /lib/hash_int.c | |
parent | 7d8fd3aee4d71e1cd79ab5c980d137b363283a33 (diff) | |
download | gnutls-92daa9548dfd53490e6e463e4ce5185cdd766be0.tar.gz |
Add MAC api to support copying of instances
GOST ciphersuites requires continuously computing MAC of all the
previously sent or received data. The easies way to support that is to
add support for copy function, that creates MAC instance with the same
internal state.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'lib/hash_int.c')
-rw-r--r-- | lib/hash_int.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/hash_int.c b/lib/hash_int.c index fbc56b4333..61e24d5375 100644 --- a/lib/hash_int.c +++ b/lib/hash_int.c @@ -225,6 +225,7 @@ _gnutls_mac_init(mac_hd_st * mac, const mac_entry_st * e, mac->setnonce = cc->setnonce; mac->output = cc->output; mac->deinit = cc->deinit; + mac->copy = cc->copy; return 0; } @@ -239,6 +240,7 @@ _gnutls_mac_init(mac_hd_st * mac, const mac_entry_st * e, mac->setnonce = _gnutls_mac_ops.setnonce; mac->output = _gnutls_mac_ops.output; mac->deinit = _gnutls_mac_ops.deinit; + mac->copy = _gnutls_mac_ops.copy; if (_gnutls_mac_ops.setkey(mac->handle, key, keylen) < 0) { gnutls_assert(); @@ -249,6 +251,20 @@ _gnutls_mac_init(mac_hd_st * mac, const mac_entry_st * e, return 0; } +int _gnutls_mac_copy(const mac_hd_st * handle, mac_hd_st * dst) +{ + if (handle->copy == NULL) + return gnutls_assert_val(GNUTLS_E_HASH_FAILED); + + *dst = *handle; /* copy data */ + dst->handle = handle->copy(handle->handle); + + if (dst->handle == NULL) + return GNUTLS_E_HASH_FAILED; + + return 0; +} + void _gnutls_mac_deinit(mac_hd_st * handle, void *digest) { if (handle->handle == NULL) { |