From 9d8835741b1298bf820dd8cfaa19b71d3dc27f03 Mon Sep 17 00:00:00 2001 From: Stephan Brunner Date: Mon, 7 Jan 2019 18:04:33 +0100 Subject: [PATCH] Fix security bug in DeviceKey --- 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 d2125c6805..016b28c135 100644 --- a/features/device_key/source/DeviceKey.cpp +++ b/features/device_key/source/DeviceKey.cpp @@ -267,11 +267,12 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size) ret = mbedtls_entropy_func(entropy, (unsigned char *)output, size); if (ret != MBED_SUCCESS) { ret = DEVICEKEY_GENERATE_RANDOM_ERROR; + } else { + ret = DEVICEKEY_SUCCESS; } mbedtls_entropy_free(entropy); delete entropy; - ret = DEVICEKEY_SUCCESS; #endif return ret;