summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2016-11-30 01:34:14 +0300
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2019-06-24 03:08:50 +0300
commit4591181a6c06465393425e51c4c68a2a1126b8e8 (patch)
treea0b213b0f4e6ec37c8f49fbafc34225275627b0a
parent92daa9548dfd53490e6e463e4ce5185cdd766be0 (diff)
downloadgnutls-4591181a6c06465393425e51c4c68a2a1126b8e8.tar.gz
Add MAC copying support to nettle backend
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
-rw-r--r--lib/nettle/mac.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/nettle/mac.c b/lib/nettle/mac.c
index 249ff2e2d7..90789d876f 100644
--- a/lib/nettle/mac.c
+++ b/lib/nettle/mac.c
@@ -324,6 +324,22 @@ static int wrap_nettle_mac_init(gnutls_mac_algorithm_t algo, void **_ctx)
return 0;
}
+static void *wrap_nettle_mac_copy(const void *_ctx)
+{
+ const struct nettle_mac_ctx *ctx = _ctx;
+ struct nettle_mac_ctx *new_ctx;
+ ptrdiff_t off = (uint8_t *)ctx->ctx_ptr - (uint8_t *)(&ctx->ctx);
+
+ new_ctx = gnutls_calloc(1, sizeof(struct nettle_mac_ctx));
+ if (new_ctx == NULL)
+ return NULL;
+
+ memcpy(new_ctx, ctx, sizeof(*ctx));
+ new_ctx->ctx_ptr = (uint8_t *)&new_ctx->ctx + off;
+
+ return new_ctx;
+}
+
static int
wrap_nettle_mac_set_key(void *_ctx, const void *key, size_t keylen)
{
@@ -641,6 +657,7 @@ gnutls_crypto_mac_st _gnutls_mac_ops = {
.deinit = wrap_nettle_mac_deinit,
.fast = wrap_nettle_mac_fast,
.exists = wrap_nettle_mac_exists,
+ .copy = wrap_nettle_mac_copy,
};
gnutls_crypto_digest_st _gnutls_digest_ops = {