Issue #26798: for loop initial declarations, take 2

This commit is contained in:
Christian Heimes 2016-09-07 00:09:22 +02:00
parent 8482ce4868
commit 9c2f304103
4 changed files with 23 additions and 17 deletions

View File

@ -157,11 +157,12 @@ BLAKE2_LOCAL_INLINE(int) blake2b_init0( blake2b_state *S )
int blake2b_init_param( blake2b_state *S, const blake2b_param *P ) int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
{ {
const uint8_t *p = ( const uint8_t * )( P ); const uint8_t *p = ( const uint8_t * )( P );
size_t i;
blake2b_init0( S ); blake2b_init0( S );
/* 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;
@ -392,14 +393,15 @@ int main( int argc, char **argv )
{ {
uint8_t key[BLAKE2B_KEYBYTES]; uint8_t key[BLAKE2B_KEYBYTES];
uint8_t buf[KAT_LENGTH]; uint8_t buf[KAT_LENGTH];
size_t i;
for( size_t i = 0; i < BLAKE2B_KEYBYTES; ++i ) for( i = 0; i < BLAKE2B_KEYBYTES; ++i )
key[i] = ( uint8_t )i; key[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
buf[i] = ( uint8_t )i; buf[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
{ {
uint8_t hash[BLAKE2B_OUTBYTES]; uint8_t hash[BLAKE2B_OUTBYTES];
blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ); blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES );

View File

@ -426,14 +426,15 @@ int main( int argc, char **argv )
{ {
uint8_t key[BLAKE2B_KEYBYTES]; uint8_t key[BLAKE2B_KEYBYTES];
uint8_t buf[KAT_LENGTH]; uint8_t buf[KAT_LENGTH];
size_t i;
for( size_t i = 0; i < BLAKE2B_KEYBYTES; ++i ) for( i = 0; i < BLAKE2B_KEYBYTES; ++i )
key[i] = ( uint8_t )i; key[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
buf[i] = ( uint8_t )i; buf[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
{ {
uint8_t hash[BLAKE2B_OUTBYTES]; uint8_t hash[BLAKE2B_OUTBYTES];
blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ); blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES );

View File

@ -154,7 +154,7 @@ int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
blake2s_init0( S ); blake2s_init0( S );
/* IV XOR ParamBlock */ /* IV XOR ParamBlock */
for( size_t i = 0; i < 8; ++i ) for( i = 0; i < 8; ++i )
S->h[i] ^= load32( &p[i] ); S->h[i] ^= load32( &p[i] );
return 0; return 0;
@ -219,11 +219,12 @@ static int blake2s_compress( blake2s_state *S, const uint8_t block[BLAKE2S_BLOCK
{ {
uint32_t m[16]; uint32_t m[16];
uint32_t v[16]; uint32_t v[16];
size_t i;
for( size_t i = 0; i < 16; ++i ) for( i = 0; i < 16; ++i )
m[i] = load32( block + i * sizeof( m[i] ) ); m[i] = load32( block + i * sizeof( m[i] ) );
for( size_t i = 0; i < 8; ++i ) for( i = 0; i < 8; ++i )
v[i] = S->h[i]; v[i] = S->h[i];
v[ 8] = blake2s_IV[0]; v[ 8] = blake2s_IV[0];
@ -267,7 +268,7 @@ static int blake2s_compress( blake2s_state *S, const uint8_t block[BLAKE2S_BLOCK
ROUND( 8 ); ROUND( 8 );
ROUND( 9 ); ROUND( 9 );
for( size_t i = 0; i < 8; ++i ) for( i = 0; i < 8; ++i )
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8]; S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
#undef G #undef G
@ -381,14 +382,15 @@ int main( int argc, char **argv )
{ {
uint8_t key[BLAKE2S_KEYBYTES]; uint8_t key[BLAKE2S_KEYBYTES];
uint8_t buf[KAT_LENGTH]; uint8_t buf[KAT_LENGTH];
size_t i;
for( size_t i = 0; i < BLAKE2S_KEYBYTES; ++i ) for( i = 0; i < BLAKE2S_KEYBYTES; ++i )
key[i] = ( uint8_t )i; key[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
buf[i] = ( uint8_t )i; buf[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
{ {
uint8_t hash[BLAKE2S_OUTBYTES]; uint8_t hash[BLAKE2S_OUTBYTES];
blake2s( hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES ); blake2s( hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES );

View File

@ -407,14 +407,15 @@ int main( int argc, char **argv )
{ {
uint8_t key[BLAKE2S_KEYBYTES]; uint8_t key[BLAKE2S_KEYBYTES];
uint8_t buf[KAT_LENGTH]; uint8_t buf[KAT_LENGTH];
size_t i;
for( size_t i = 0; i < BLAKE2S_KEYBYTES; ++i ) for( i = 0; i < BLAKE2S_KEYBYTES; ++i )
key[i] = ( uint8_t )i; key[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
buf[i] = ( uint8_t )i; buf[i] = ( uint8_t )i;
for( size_t i = 0; i < KAT_LENGTH; ++i ) for( i = 0; i < KAT_LENGTH; ++i )
{ {
uint8_t hash[BLAKE2S_OUTBYTES]; uint8_t hash[BLAKE2S_OUTBYTES];