diff --git a/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c b/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c index d7f74a6d..910eb10f 100644 --- a/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +++ b/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c @@ -132,9 +132,11 @@ static inline int blake2s_param_set_personal( blake2s_param *P, const uint8_t pe static inline int blake2s_init0( blake2s_state *S ) { + int i; + memset( S, 0, sizeof( blake2s_state ) ); - for( int i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i]; + for( i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i]; return 0; } @@ -301,6 +303,7 @@ int blake2s_update( blake2s_state *S, const uint8_t *in, uint64_t inlen ) int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen ) { uint8_t buffer[BLAKE2S_OUTBYTES]; + int i; if( S->buflen > BLAKE2S_BLOCKBYTES ) { @@ -315,7 +318,7 @@ int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen ) memset( S->buf + S->buflen, 0, 2 * BLAKE2S_BLOCKBYTES - S->buflen ); /* Padding */ blake2s_compress( S, S->buf ); - for( int i = 0; i < 8; ++i ) /* Output full hash to temp buffer */ + 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 );