Do not clean ctx in <digest>_finish

This commit is contained in:
Zhi Guan
2023-10-17 23:12:43 +08:00
parent 0da7bbc22d
commit 9b5a2e6812
5 changed files with 11 additions and 10 deletions

View File

@@ -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.
@@ -364,7 +364,6 @@ void sm3_finish(SM3_CTX *ctx, uint8_t *digest)
for (i = 0; i < 8; i++) {
PUTU32(digest + i*4, ctx->digest[i]);
}
memset(ctx, 0, sizeof(SM3_CTX));
}
void sm3_digest(const uint8_t *msg, size_t msglen,
@@ -374,4 +373,5 @@ void sm3_digest(const uint8_t *msg, size_t msglen,
sm3_init(&ctx);
sm3_update(&ctx, msg, msglen);
sm3_finish(&ctx, dgst);
memset(&ctx, 0, sizeof(ctx));
}