Fixed compilation with MSVC 2012.

This commit is contained in:
LoRd_MuldeR 2014-04-18 21:21:34 +02:00
parent 7e439a0043
commit 21032e0268

View File

@ -258,9 +258,11 @@ static inline int blake2b_param_set_personal( blake2b_param *P, const uint8_t pe
static inline int blake2b_init0( blake2b_state *S ) static inline int blake2b_init0( blake2b_state *S )
{ {
int i;
memset( S, 0, sizeof( blake2b_state ) ); memset( S, 0, sizeof( blake2b_state ) );
for( int i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i]; for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
return 0; return 0;
} }
@ -268,11 +270,14 @@ static inline int blake2b_init0( blake2b_state *S )
/* init xors IV with input parameter block */ /* init xors IV with input parameter block */
int blake2b_init_param( blake2b_state *S, const blake2b_param *P ) int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
{ {
uint8_t *p;
size_t i;
blake2b_init0( S ); blake2b_init0( S );
uint8_t *p = ( uint8_t * )( P ); p = ( uint8_t * )( P );
/* IV XOR ParamBlock */ /* IV XOR ParamBlock */
for( size_t i = 0; i < 8; ++i ) for( i = 0; i < 8; ++i )
S->h[i] ^= load64( p + sizeof( S->h[i] ) * i ); S->h[i] ^= load64( p + sizeof( S->h[i] ) * i );
return 0; return 0;
@ -430,6 +435,8 @@ int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen )
/* Is this correct? */ /* Is this correct? */
int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen ) int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
{ {
int i;
uint8_t buffer[BLAKE2B_OUTBYTES]; uint8_t buffer[BLAKE2B_OUTBYTES];
if( S->buflen > BLAKE2B_BLOCKBYTES ) if( S->buflen > BLAKE2B_BLOCKBYTES )
@ -445,7 +452,7 @@ int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen )
memset( S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */ memset( S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
blake2b_compress( S, S->buf ); blake2b_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 */
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] ); store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
memcpy( out, buffer, outlen ); memcpy( out, buffer, outlen );