Skip to content

Commit b47cdc3

Browse files
committed
wolfcrypt/test/test.c: in random_bank_test(), accommodate WOLFSSL_DRBG_SHA512 in the WC_RNG_BANK_FLAG_NO_VECTOR_OPS test;
linuxkm/lkcapi_sha_glue.c: in wc_mix_pool_bytes(), accommodate WOLFSSL_DRBG_SHA512.
1 parent 97795c1 commit b47cdc3

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

linuxkm/lkcapi_sha_glue.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,10 +1510,22 @@ static int wc_mix_pool_bytes(const void *buf, size_t len) {
15101510
if (wc_rng_bank_checkout(ctx, &drbg, n, 0, WC_RNG_BANK_FLAG_NONE) != 0)
15111511
continue;
15121512

1513-
for (i = 0, V_offset = 0; i < len; ++i) {
1514-
((struct DRBG_internal *)WC_RNG_BANK_INST_TO_RNG(drbg)->drbg)->V[V_offset++] += ((byte *)buf)[i];
1515-
if (V_offset == (int)sizeof ((struct DRBG_internal *)WC_RNG_BANK_INST_TO_RNG(drbg)->drbg)->V)
1516-
V_offset = 0;
1513+
#ifdef WOLFSSL_DRBG_SHA512
1514+
if (WC_RNG_BANK_INST_TO_RNG(drbg)->drbgType == WC_DRBG_SHA512) {
1515+
for (i = 0, V_offset = 0; i < len; ++i) {
1516+
((struct DRBG_SHA512_internal *)WC_RNG_BANK_INST_TO_RNG(drbg)->drbg512)->V[V_offset++] += ((byte *)buf)[i];
1517+
if (V_offset == (int)sizeof ((struct DRBG_SHA512_internal *)WC_RNG_BANK_INST_TO_RNG(drbg)->drbg512)->V)
1518+
V_offset = 0;
1519+
}
1520+
}
1521+
else
1522+
#endif /* WOLFSSL_DRBG_SHA512 */
1523+
{
1524+
for (i = 0, V_offset = 0; i < len; ++i) {
1525+
((struct DRBG_internal *)WC_RNG_BANK_INST_TO_RNG(drbg)->drbg)->V[V_offset++] += ((byte *)buf)[i];
1526+
if (V_offset == (int)sizeof ((struct DRBG_internal *)WC_RNG_BANK_INST_TO_RNG(drbg)->drbg)->V)
1527+
V_offset = 0;
1528+
}
15171529
}
15181530

15191531
wc_rng_bank_checkin(ctx, &drbg);

wolfcrypt/test/test.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21883,8 +21883,17 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t random_bank_test(void)
2188321883
defined(WC_C_DYNAMIC_FALLBACK) && \
2188421884
defined(HAVE_HASHDRBG) && \
2188521885
defined(WC_NO_INTERNAL_FUNCTION_POINTERS)
21886-
if (((struct DRBG_internal *)rng_inst->rng.drbg)->sha256.sha_method != 7 /* SHA256_C */)
21887-
ERROR_OUT(WC_TEST_RET_ENC_I(((struct DRBG_internal *)rng_inst->rng.drbg)->sha256.sha_method), out);
21886+
#ifdef WOLFSSL_DRBG_SHA512
21887+
if (rng_inst->rng.drbgType == WC_DRBG_SHA512) {
21888+
if (((struct DRBG_SHA512_internal *)rng_inst->rng.drbg512)->sha512.sha_method != 5 /* SHA512_C */)
21889+
ERROR_OUT(WC_TEST_RET_ENC_I(((struct DRBG_SHA512_internal *)rng_inst->rng.drbg512)->sha512.sha_method), out);
21890+
}
21891+
else
21892+
#endif /* WOLFSSL_DRBG_SHA512 */
21893+
{
21894+
if (((struct DRBG_internal *)rng_inst->rng.drbg)->sha256.sha_method != 7 /* SHA256_C */)
21895+
ERROR_OUT(WC_TEST_RET_ENC_I(((struct DRBG_internal *)rng_inst->rng.drbg)->sha256.sha_method), out);
21896+
}
2188821897
#endif
2188921898

2189021899
ret = wc_RNG_GenerateBlock(WC_RNG_BANK_INST_TO_RNG(rng_inst), outbuf1, sizeof(outbuf1));

0 commit comments

Comments
 (0)