diff --git a/ripemd160.c b/ripemd160.c index 031f42202b..6a62279c46 100644 --- a/ripemd160.c +++ b/ripemd160.c @@ -25,9 +25,11 @@ * http://ehash.iaik.tugraz.at/wiki/RIPEMD-160 */ -#include "ripemd160.h" #include +#include "ripemd160.h" +#include "macros.h" + /* * 32-bit integer manipulation macros (little endian) */ @@ -325,6 +327,8 @@ void ripemd160_Final( RIPEMD160_CTX *ctx, uint8_t output[RIPEMD160_DIGEST_LENGTH PUT_UINT32_LE( ctx->state[2], output, 8 ); PUT_UINT32_LE( ctx->state[3], output, 12 ); PUT_UINT32_LE( ctx->state[4], output, 16 ); + + MEMSET_BZERO(ctx, sizeof(RIPEMD160_CTX)); } /* diff --git a/sha3.c b/sha3.c index a3496e20f4..9da744d4da 100644 --- a/sha3.c +++ b/sha3.c @@ -19,7 +19,9 @@ #include #include + #include "sha3.h" +#include "macros.h" #define I64(x) x##LL #define ROTL64(qword, n) ((qword) << (n) ^ ((qword) >> (64 - (n)))) @@ -329,6 +331,7 @@ void sha3_Final(SHA3_CTX *ctx, unsigned char* result) assert(block_size > digest_length); if (result) me64_to_le_str(result, ctx->hash, digest_length); + MEMSET_BZERO(ctx, sizeof(SHA3_CTX)); } #if USE_KECCAK @@ -357,6 +360,7 @@ void keccak_Final(SHA3_CTX *ctx, unsigned char* result) assert(block_size > digest_length); if (result) me64_to_le_str(result, ctx->hash, digest_length); + MEMSET_BZERO(ctx, sizeof(SHA3_CTX)); } void keccak_256(const unsigned char* data, size_t len, unsigned char* digest)