Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/BLAKE2/BLAKE2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Neves <sneves@dei.uc.pt>2016-06-11 14:42:46 +0300
committerSamuel Neves <sneves@dei.uc.pt>2016-06-11 14:42:46 +0300
commit932be4e9f5c973a2aa49656447683fbfae4cfb39 (patch)
tree791d07b1bebe41b9567e73fed3d4cc4c6fef44a0 /sse/blake2s.c
parent64cafcff1620ab778d23057e1c7559087d7bd4e6 (diff)
outlen in blake2xx_final should be the output buffer size, not the hash length
Diffstat (limited to 'sse/blake2s.c')
-rw-r--r--sse/blake2s.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sse/blake2s.c b/sse/blake2s.c
index 05d4c99..f423d58 100644
--- a/sse/blake2s.c
+++ b/sse/blake2s.c
@@ -119,6 +119,7 @@ int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
for( i = 0; i < BLAKE2S_OUTBYTES; ++i ) h[i] = v[i] ^ p[i];
+ S->outlen = P->digest_length;
return 0;
}
@@ -268,7 +269,7 @@ int blake2s_final( blake2s_state *S, void *out, size_t outlen )
uint8_t buffer[BLAKE2S_OUTBYTES] = {0};
size_t i;
- if( outlen > BLAKE2S_OUTBYTES )
+ if( out == NULL || outlen < S->outlen )
return -1;
if( blake2s_is_lastblock( S ) )
@@ -282,7 +283,7 @@ int blake2s_final( blake2s_state *S, void *out, size_t outlen )
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
- memcpy( out, buffer, outlen );
+ memcpy( out, buffer, S->outlen );
secure_zero_memory( buffer, sizeof(buffer) );
return 0;
}