aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum_init_blake2s_hasher.c
diff options
context:
space:
mode:
Diffstat (limited to 'libhashsum_init_blake2s_hasher.c')
-rw-r--r--libhashsum_init_blake2s_hasher.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libhashsum_init_blake2s_hasher.c b/libhashsum_init_blake2s_hasher.c
index 0957b22..689dc64 100644
--- a/libhashsum_init_blake2s_hasher.c
+++ b/libhashsum_init_blake2s_hasher.c
@@ -69,7 +69,7 @@ finalise(struct libhashsum_hasher *this, void *data, size_t bytes, unsigned extr
size -= r;
if (!this->hash_output)
- this->hash_output = this->state.blake224.buf;
+ this->hash_output = this->state.blake2s.buf;
if (this->state.blake2s.keybytes) {
bytes = BLAKE2S_BLOCK_SIZE;
@@ -100,7 +100,7 @@ allzeroes(const uint8_t *data, size_t n)
static char *
-hex(char *buf, const uint8_t *data, size_t n)
+hex(char *restrict buf, const uint8_t *restrict data, size_t n)
{
size_t i;
for (i = 0; i < n; i++) {
@@ -150,12 +150,14 @@ libhashsum_init_blake2s_hasher(struct libhashsum_hasher *this, size_t hashbits,
.node_depth = 0U,
.inner_len = 0U
};
- if (((hashbits | keybits) & 7U) || ((hashbits | keybits) > 256U)) {
+ if (((hashbits | keybits) & 7U) || hashbits > 256U || keybits > 256U) {
errno = EINVAL;
return -1;
}
- if (!hashbits)
+ if (!hashbits) {
hashbits = 256U;
+ params.digest_len = (unsigned char)(hashbits / 8U);
+ }
libblake_init();
this->algorithm = LIBHASHSUM_BLAKE2S;
this->algorithm_string = mkalgostr(this->state.blake2s.algostr, "BLAKE2s",