diff --git a/hasher.c b/hasher.c index aa73e45d2f..edd1ac7666 100644 --- a/hasher.c +++ b/hasher.c @@ -29,6 +29,9 @@ void hasher_Init(Hasher *hasher, HasherType type) { case HASHER_SHA2: sha256_Init(&hasher->ctx.sha2); break; + case HASHER_BLAKE: + blake256_Init(&hasher->ctx.blake); + break; } } @@ -41,6 +44,9 @@ void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length) { case HASHER_SHA2: sha256_Update(&hasher->ctx.sha2, data, length); break; + case HASHER_BLAKE: + blake256_Update(&hasher->ctx.blake, data, length); + break; } } @@ -49,6 +55,9 @@ void hasher_Final(Hasher *hasher, uint8_t hash[HASHER_DIGEST_LENGTH]) { case HASHER_SHA2: sha256_Final(&hasher->ctx.sha2, hash); break; + case HASHER_BLAKE: + blake256_Final(&hasher->ctx.blake, hash); + break; } } diff --git a/hasher.h b/hasher.h index 5fa70b4087..57b70b2317 100644 --- a/hasher.h +++ b/hasher.h @@ -27,11 +27,13 @@ #include #include "sha2.h" +#include "blake256.h" #define HASHER_DIGEST_LENGTH 32 typedef enum { HASHER_SHA2, + HASHER_BLAKE, } HasherType; typedef struct { @@ -39,6 +41,7 @@ typedef struct { union { SHA256_CTX sha2; + BLAKE256_CTX blake; } ctx; } Hasher;