From: Niels Möller Date: Wed, 30 Oct 2024 10:25:24 +0000 (+0100) Subject: Update hmac-sm3. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64bbcf3174736e02e664db1991bab6a81cf05e5a;p=thirdparty%2Fnettle.git Update hmac-sm3. --- diff --git a/hmac-sm3.c b/hmac-sm3.c index 67a21dde..bba2afe7 100644 --- a/hmac-sm3.c +++ b/hmac-sm3.c @@ -3,6 +3,7 @@ HMAC-SM3 message authentication code. Copyright (C) 2021 Tianjia Zhang + Copyright (C) 2024 Niels Möller This file is part of GNU Nettle. @@ -36,12 +37,14 @@ #endif #include "hmac.h" +#include "hmac-internal.h" void hmac_sm3_set_key(struct hmac_sm3_ctx *ctx, size_t key_length, const uint8_t *key) { - HMAC_SET_KEY(ctx, &nettle_sm3, key_length, key); + _nettle_hmac_set_key (sizeof(ctx->outer), ctx->outer, ctx->inner, &ctx->state, + ctx->state.block, &nettle_sm3, key_length, key); } void @@ -55,5 +58,7 @@ void hmac_sm3_digest(struct hmac_sm3_ctx *ctx, uint8_t *digest) { - HMAC_DIGEST(ctx, &nettle_sm3, digest); + sm3_digest (&ctx->state, ctx->state.block); + ctx->state.index = SM3_DIGEST_SIZE; + _NETTLE_HMAC_DIGEST (ctx->outer, ctx->inner, &ctx->state, sm3_digest, digest); } diff --git a/hmac.h b/hmac.h index 6ffe501d..4625f614 100644 --- a/hmac.h +++ b/hmac.h @@ -281,7 +281,7 @@ hmac_streebog256_digest(struct hmac_streebog256_ctx *ctx, uint8_t *digest); /* hmac-sm3 */ -struct hmac_sm3_ctx OLD_HMAC_CTX(struct sm3_ctx); +struct hmac_sm3_ctx HMAC_CTX (struct sm3_ctx, offsetof (struct sm3_ctx, index)); void hmac_sm3_set_key(struct hmac_sm3_ctx *ctx,