1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-21 23:18:13 +00:00

hasher: add param_size to hasher_InitParam

This commit is contained in:
Pavol Rusnak 2019-01-31 19:18:06 +01:00
parent 8c2bac9594
commit 21391dc5be
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 10 additions and 4 deletions

View File

@ -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) {

View File

@ -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]);