mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
cleanup context in ripemd160/sha3
This commit is contained in:
parent
6580044196
commit
ea30ebe393
@ -25,9 +25,11 @@
|
|||||||
* http://ehash.iaik.tugraz.at/wiki/RIPEMD-160
|
* http://ehash.iaik.tugraz.at/wiki/RIPEMD-160
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ripemd160.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "ripemd160.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 32-bit integer manipulation macros (little endian)
|
* 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[2], output, 8 );
|
||||||
PUT_UINT32_LE( ctx->state[3], output, 12 );
|
PUT_UINT32_LE( ctx->state[3], output, 12 );
|
||||||
PUT_UINT32_LE( ctx->state[4], output, 16 );
|
PUT_UINT32_LE( ctx->state[4], output, 16 );
|
||||||
|
|
||||||
|
MEMSET_BZERO(ctx, sizeof(RIPEMD160_CTX));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
4
sha3.c
4
sha3.c
@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "sha3.h"
|
#include "sha3.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
#define I64(x) x##LL
|
#define I64(x) x##LL
|
||||||
#define ROTL64(qword, n) ((qword) << (n) ^ ((qword) >> (64 - (n))))
|
#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);
|
assert(block_size > digest_length);
|
||||||
if (result) me64_to_le_str(result, ctx->hash, digest_length);
|
if (result) me64_to_le_str(result, ctx->hash, digest_length);
|
||||||
|
MEMSET_BZERO(ctx, sizeof(SHA3_CTX));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_KECCAK
|
#if USE_KECCAK
|
||||||
@ -357,6 +360,7 @@ void keccak_Final(SHA3_CTX *ctx, unsigned char* result)
|
|||||||
|
|
||||||
assert(block_size > digest_length);
|
assert(block_size > digest_length);
|
||||||
if (result) me64_to_le_str(result, ctx->hash, 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)
|
void keccak_256(const unsigned char* data, size_t len, unsigned char* digest)
|
||||||
|
Loading…
Reference in New Issue
Block a user