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>2014-08-06 14:33:19 +0400
committerSamuel Neves <sneves@dei.uc.pt>2014-08-06 14:42:44 +0400
commitb8024d53e77374d4a5b7868aa17cac3f11c33581 (patch)
tree03bfa9de153d0a5ff3688c00cb038a37bb3a875b /ref/blake2b-ref.c
parent77ede9e4db21892f1c5bebc4def2c8c1c569f5cd (diff)
Check for overflow of outlen in blake2{s,b}_final
Fix warnings with -Wcast-qual Fix blake2{sp,bp}_final's return value
Diffstat (limited to 'ref/blake2b-ref.c')
-rw-r--r--ref/blake2b-ref.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ref/blake2b-ref.c b/ref/blake2b-ref.c
index a840bb8..fe27f85 100644
--- a/ref/blake2b-ref.c
+++ b/ref/blake2b-ref.c
@@ -149,7 +149,7 @@ static inline int blake2b_init0( blake2b_state *S )
int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
{
blake2b_init0( S );
- uint8_t *p = ( uint8_t * )( P );
+ const uint8_t *p = ( const uint8_t * )( P );
/* IV XOR ParamBlock */
for( size_t i = 0; i < 8; ++i )
@@ -310,7 +310,10 @@ int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
/* Is this correct? */
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
{
- uint8_t buffer[BLAKE2B_OUTBYTES];
+ uint8_t buffer[BLAKE2B_OUTBYTES] = {0};
+
+ if( outlen > BLAKE2B_OUTBYTES )
+ return -1;
if( S->buflen > BLAKE2B_BLOCKBYTES )
{
@@ -353,7 +356,7 @@ int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen
if( blake2b_init( S, outlen ) < 0 ) return -1;
}
- blake2b_update( S, ( uint8_t * )in, inlen );
+ blake2b_update( S, ( const uint8_t * )in, inlen );
blake2b_final( S, out, outlen );
return 0;
}