mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
hasher: add param_size to hasher_InitParam
This commit is contained in:
parent
8c2bac9594
commit
21391dc5be
9
hasher.c
9
hasher.c
@ -23,9 +23,10 @@
|
||||
#include "hasher.h"
|
||||
#include "ripemd160.h"
|
||||
|
||||
void hasher_InitParam(Hasher *hasher, HasherType type, const void *param) {
|
||||
void hasher_InitParam(Hasher *hasher, HasherType type, const void *param, uint32_t param_size) {
|
||||
hasher->type = type;
|
||||
hasher->param = param;
|
||||
hasher->param_size = param_size;
|
||||
|
||||
switch (hasher->type) {
|
||||
case HASHER_SHA2:
|
||||
@ -56,8 +57,12 @@ void hasher_InitParam(Hasher *hasher, HasherType type, const void *param) {
|
||||
}
|
||||
}
|
||||
|
||||
void hasher_Init(Hasher *hasher, HasherType type) {
|
||||
hasher_InitParam(hasher, type, NULL, 0);
|
||||
}
|
||||
|
||||
void hasher_Reset(Hasher *hasher) {
|
||||
hasher_InitParam(hasher, hasher->type, hasher->param);
|
||||
hasher_InitParam(hasher, hasher->type, hasher->param, hasher->param_size);
|
||||
}
|
||||
|
||||
void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length) {
|
||||
|
5
hasher.h
5
hasher.h
@ -66,10 +66,11 @@ typedef struct {
|
||||
} ctx;
|
||||
|
||||
const void *param;
|
||||
uint32_t param_size;
|
||||
} Hasher;
|
||||
|
||||
void hasher_InitParam(Hasher *hasher, HasherType type, const void *param);
|
||||
inline void hasher_Init(Hasher *hasher, HasherType type) { hasher_InitParam(hasher, type, NULL); }
|
||||
void hasher_InitParam(Hasher *hasher, HasherType type, const void *param, uint32_t param_size);
|
||||
void hasher_Init(Hasher *hasher, HasherType type);
|
||||
void hasher_Reset(Hasher *hasher);
|
||||
void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length);
|
||||
void hasher_Final(Hasher *hasher, uint8_t hash[HASHER_DIGEST_LENGTH]);
|
||||
|
Loading…
Reference in New Issue
Block a user