If the RNG seeding callback is missing or returns an error, the RNG instantiate fails.

This commit is contained in:
John Safranek
2021-03-17 12:18:21 -07:00
parent ff64584f34
commit 1c064dd957

View File

@ -813,18 +813,19 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
rng->drbg = (struct DRBG*)&rng->drbg_data;
#endif
if (ret == 0) {
ret = -1;
#ifdef WC_RNG_SEED_CB
if (seedCb != NULL) {
if (seedCb == NULL) {
ret = DRBG_FAILURE;
}
else {
ret = seedCb(seed, seedSz);
if (ret != 0) {
ret = DRBG_FAILURE;
}
}
#else
ret = wc_GenerateSeed(&rng->seed, seed, seedSz);
#endif
if (ret < 0) {
ret = wc_GenerateSeed(&rng->seed, seed, seedSz);
}
if (ret == 0)
ret = wc_RNG_TestSeed(seed, seedSz);
else {