diff --git a/hasher.c b/hasher.c index 35f27ea81f..6430ee95a2 100644 --- a/hasher.c +++ b/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) { diff --git a/hasher.h b/hasher.h index b4cc5426c5..0cde1df8b2 100644 --- a/hasher.h +++ b/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]);