random: rand32_ctr_drbg: Handle error in initialize function

Initialize function has to fail when a call to get entropy fails.
TinyCrypt prng_init relies on a proper entropy data, so we need to
check if the driver return it properly.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2020-01-26 22:23:34 -08:00 committed by Andrew Boie
commit f234260334

View file

@ -82,7 +82,11 @@ static int ctr_drbg_initialize(void)
u8_t entropy[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE];
entropy_get_entropy(entropy_driver, (void *)&entropy, sizeof(entropy));
ret = entropy_get_entropy(entropy_driver, (void *)&entropy,
sizeof(entropy));
if (ret != 0) {
return -EIO;
}
ret = tc_ctr_prng_init(&ctr_ctx,
(uint8_t *)&entropy,