Adding MBEDTLS_ENTROPY_NV_SEED macro check in device key to allow key derivation when there is no TRNG but there is DRBG

pull/9719/head
Yossi Levy 2019-01-31 17:26:26 +02:00 committed by adbridge
parent ecb3c8c837
commit a58e4f7b1f
1 changed files with 2 additions and 1 deletions

View File

@ -260,7 +260,7 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size)
return DEVICEKEY_INVALID_PARAM; return DEVICEKEY_INVALID_PARAM;
} }
#if DEVICE_TRNG #if defined(DEVICE_TRNG) || defined(MBEDTLS_ENTROPY_NV_SEED)
uint32_t test_buff[DEVICE_KEY_32BYTE / sizeof(int)]; uint32_t test_buff[DEVICE_KEY_32BYTE / sizeof(int)];
mbedtls_entropy_context *entropy = new mbedtls_entropy_context; mbedtls_entropy_context *entropy = new mbedtls_entropy_context;
mbedtls_entropy_init(entropy); mbedtls_entropy_init(entropy);
@ -276,6 +276,7 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size)
mbedtls_entropy_free(entropy); mbedtls_entropy_free(entropy);
delete entropy; delete entropy;
#endif #endif
return ret; return ret;