summaryrefslogtreecommitdiff
path: root/lib/nettle/mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nettle/mac.c')
-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 = {