Skip to content

Commit 402cfc6

Browse files
committed
More C90 fixes
Signed-off-by: Brendan Moran <[email protected]>
1 parent 042369c commit 402cfc6

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/test_unit.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ static int test_shake128x4_api(void)
499499

500500
for (ai = 0; ai < absorb_count; ai++)
501501
{
502+
test_priv_shake128x4ctx ref_ctx;
503+
mld_shake128x4ctx dut_ctx;
502504
inlen = absorb_lens[ai];
503505
for (ch = 0; ch < MLD_KECCAK_WAY; ch++)
504506
{
@@ -508,8 +510,6 @@ static int test_shake128x4_api(void)
508510
}
509511
}
510512

511-
test_priv_shake128x4ctx ref_ctx;
512-
mld_shake128x4ctx dut_ctx;
513513
test_priv_shake128x4_absorb_once(&ref_ctx, in[0], in[1], in[2], in[3],
514514
inlen);
515515
mld_shake128x4_absorb_once(&dut_ctx, in[0], in[1], in[2], in[3], inlen);
@@ -570,6 +570,8 @@ static int test_shake256x4_api(void)
570570

571571
for (ai = 0; ai < absorb_count; ai++)
572572
{
573+
test_priv_shake256x4ctx ref_ctx;
574+
mld_shake256x4ctx dut_ctx;
573575
inlen = absorb_lens[ai];
574576
for (ch = 0; ch < MLD_KECCAK_WAY; ch++)
575577
{
@@ -579,8 +581,6 @@ static int test_shake256x4_api(void)
579581
}
580582
}
581583

582-
test_priv_shake256x4ctx ref_ctx;
583-
mld_shake256x4ctx dut_ctx;
584584
test_priv_shake256x4_absorb_once(&ref_ctx, in[0], in[1], in[2], in[3],
585585
inlen);
586586
mld_shake256x4_absorb_once(&dut_ctx, in[0], in[1], in[2], in[3], inlen);
@@ -794,12 +794,19 @@ static int test_x4_permute(void)
794794
/* Testcase 2: randomized per-channel states */
795795
{
796796
uint64_t init[4][MLD_KECCAK_LANES];
797+
uint64_t ref[4][MLD_KECCAK_LANES];
798+
799+
#if defined(MLD_USE_FIPS202_X4_XOR_NATIVE)
800+
uint64_t x4buf[MLD_KECCAK_LANES * MLD_KECCAK_WAY];
801+
uint64_t inter[4][MLD_KECCAK_LANES];
802+
uint64_t inter_out[4][MLD_KECCAK_LANES];
803+
#endif
804+
797805
randombytes((uint8_t *)init[0], sizeof init[0]);
798806
randombytes((uint8_t *)init[1], sizeof init[1]);
799807
randombytes((uint8_t *)init[2], sizeof init[2]);
800808
randombytes((uint8_t *)init[3], sizeof init[3]);
801809

802-
uint64_t ref[4][MLD_KECCAK_LANES];
803810
memcpy(ref[0], init[0], sizeof ref[0]);
804811
memcpy(ref[1], init[1], sizeof ref[1]);
805812
memcpy(ref[2], init[2], sizeof ref[2]);
@@ -809,16 +816,13 @@ static int test_x4_permute(void)
809816
test_priv_keccakf1600_permute(ref[2]);
810817
test_priv_keccakf1600_permute(ref[3]);
811818

812-
uint64_t x4buf[MLD_KECCAK_LANES * MLD_KECCAK_WAY];
813819
#if defined(MLD_USE_FIPS202_X4_XOR_NATIVE)
814-
uint64_t inter[4][MLD_KECCAK_LANES];
815820
for (ch = 0; ch < 4; ch++)
816821
{
817822
interleave_state(inter[ch], init[ch]);
818823
}
819824
pack_x4_native(x4buf, inter);
820825
mld_keccakf1600x4_permute(x4buf);
821-
uint64_t inter_out[4][MLD_KECCAK_LANES];
822826
unpack_x4_native(inter_out, x4buf);
823827
for (ch = 0; ch < 4; ch++)
824828
{
@@ -870,10 +874,12 @@ static int test_xor_bytes(void)
870874
{
871875
uint64_t ref_s[MLD_KECCAK_LANES] = {0};
872876
uint64_t nat_s[MLD_KECCAK_LANES] = {0};
877+
#if defined(MLD_USE_FIPS202_X1_XOR_NATIVE)
878+
uint64_t nat_s_norm[MLD_KECCAK_LANES];
879+
#endif
873880
test_priv_keccakf1600_xor_bytes(ref_s, data, off, len);
874881
mld_keccakf1600_xor_bytes(nat_s, data, off, len);
875882
#if defined(MLD_USE_FIPS202_X1_XOR_NATIVE)
876-
uint64_t nat_s_norm[MLD_KECCAK_LANES];
877883
deinterleave_state(nat_s_norm, nat_s);
878884
CHECK(memcmp(ref_s, nat_s_norm, sizeof ref_s) == 0);
879885
#else

0 commit comments

Comments
 (0)