diff options
Diffstat (limited to 'lib/nettle')
-rw-r--r-- | lib/nettle/mac.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/nettle/mac.c b/lib/nettle/mac.c index 90789d876f..8107f7cea4 100644 --- a/lib/nettle/mac.c +++ b/lib/nettle/mac.c @@ -632,6 +632,22 @@ wrap_nettle_hash_init(gnutls_digest_algorithm_t algo, void **_ctx) return 0; } +static void *wrap_nettle_hash_copy(const void *_ctx) +{ + const struct nettle_hash_ctx *ctx = _ctx; + struct nettle_hash_ctx *new_ctx; + ptrdiff_t off = (uint8_t *)ctx->ctx_ptr - (uint8_t *)(&ctx->ctx); + + new_ctx = gnutls_calloc(1, sizeof(struct nettle_hash_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_hash_output(void *src_ctx, void *digest, size_t digestsize) { @@ -667,4 +683,5 @@ gnutls_crypto_digest_st _gnutls_digest_ops = { .deinit = wrap_nettle_hash_deinit, .fast = wrap_nettle_hash_fast, .exists = wrap_nettle_hash_exists, + .copy = wrap_nettle_hash_copy, }; |