mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-23 13:43:44 +08:00
Do not clean ctx in <digest>_finish
This commit is contained in:
@@ -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.
|
||||
@@ -85,7 +85,6 @@ void sha512_finish(SHA512_CTX *ctx, unsigned char dgst[SHA512_DIGEST_SIZE])
|
||||
PUTU64(dgst, ctx->state[i]);
|
||||
dgst += sizeof(uint64_t);
|
||||
}
|
||||
memset(ctx, 0, sizeof(SHA512_CTX));
|
||||
}
|
||||
|
||||
#define Ch(X, Y, Z) (((X) & (Y)) ^ ((~(X)) & (Z)))
|
||||
@@ -188,6 +187,7 @@ void sha512_digest(const unsigned char *data, size_t datalen,
|
||||
sha512_init(&ctx);
|
||||
sha512_update(&ctx, data, datalen);
|
||||
sha512_finish(&ctx, dgst);
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
}
|
||||
|
||||
|
||||
@@ -229,5 +229,6 @@ void sha384_digest(const unsigned char *data, size_t datalen,
|
||||
sha384_init(&ctx);
|
||||
sha384_update(&ctx, data, datalen);
|
||||
sha384_finish(&ctx, dgst);
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user