From 07b077d66b4f882b132517ea7c69d7ac541b84ee Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Wed, 13 Dec 2023 20:48:54 +0800 Subject: [PATCH] Update sm3_hmac.c Do not clean `ctx` in `sm3_hmac_finish` by default --- src/sm3_hmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sm3_hmac.c b/src/sm3_hmac.c index 76011a74..f8d765e2 100644 --- a/src/sm3_hmac.c +++ b/src/sm3_hmac.c @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 The GmSSL Project. All Rights Reserved. + * Copyright 2014-2023 The GmSSL Project. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. @@ -72,7 +72,6 @@ void sm3_hmac_finish(SM3_HMAC_CTX *ctx, uint8_t mac[SM3_HMAC_SIZE]) sm3_update(&ctx->sm3_ctx, ctx->key, SM3_BLOCK_SIZE); sm3_update(&ctx->sm3_ctx, mac, SM3_DIGEST_SIZE); sm3_finish(&ctx->sm3_ctx, mac); - memset(ctx, 0, sizeof(*ctx)); } void sm3_hmac(const uint8_t *key, size_t key_len, @@ -83,4 +82,5 @@ void sm3_hmac(const uint8_t *key, size_t key_len, sm3_hmac_init(&ctx, key, key_len); sm3_hmac_update(&ctx, data, data_len); sm3_hmac_finish(&ctx, mac); + memset(&ctx, 0, sizeof(ctx)); }