From a58e4f7b1f9df569085cc7c7175bf5c5f06dd1f9 Mon Sep 17 00:00:00 2001 From: Yossi Levy Date: Thu, 31 Jan 2019 17:26:26 +0200 Subject: [PATCH] Adding MBEDTLS_ENTROPY_NV_SEED macro check in device key to allow key derivation when there is no TRNG but there is DRBG --- features/device_key/source/DeviceKey.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/device_key/source/DeviceKey.cpp b/features/device_key/source/DeviceKey.cpp index 3d9b8dac07..7491add70a 100644 --- a/features/device_key/source/DeviceKey.cpp +++ b/features/device_key/source/DeviceKey.cpp @@ -260,7 +260,7 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size) 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)]; mbedtls_entropy_context *entropy = new mbedtls_entropy_context; mbedtls_entropy_init(entropy); @@ -276,6 +276,7 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size) mbedtls_entropy_free(entropy); delete entropy; + #endif return ret;