Fixing trng_get_bytes return status

pull/6642/head
Yossi Levy 2018-05-14 20:01:47 +03:00
parent 789eb04617
commit 1cb43fa020
2 changed files with 2 additions and 3 deletions

View File

@ -49,7 +49,6 @@ int inject_dummy_rot_key()
#if !defined(DEVICE_TRNG)
uint32_t key[DEVICE_KEY_16BYTE / sizeof(uint32_t)];
memset(key, 0, DEVICE_KEY_16BYTE);
memcpy(key, "1234567812345678", DEVICE_KEY_16BYTE);
int size = DEVICE_KEY_16BYTE;
DeviceKey& devkey = DeviceKey::get_instance();

View File

@ -253,12 +253,12 @@ int DeviceKey::generate_key_by_trng(uint32_t *output, size_t& size)
final_size = 0;
in_size = size;
while (DEVICEKEY_SUCCESS == ret && final_size < size) {
while (final_size < size) {
ongoing_size = 0;
ret = trng_get_bytes(&trng_obj, (unsigned char *)pBuffer, in_size, &ongoing_size);
final_size += ongoing_size;
if (DEVICEKEY_SUCCESS != ret) {
if (0 != ret) {
ret = DEVICEKEY_TRNG_ERROR;
goto finish;
}