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:
parent
ade23d57b1
commit
f234260334
1 changed files with 5 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue