Skip to content

Commit f0790cd

Browse files
author
Seppo Takalo
committed
Remove usage of Mbed TLS internal function from DeviceKey.
DeviceKey was using mbedtls_ssl_safer_memcmp() to compare result against buffer of equal length, but zero content. This comparison makes no sense as the entropy function is already returning proper error, if it fails.
1 parent 4ab3c8b commit f0790cd

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

features/device_key/source/DeviceKey.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,12 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size)
270270
}
271271

272272
#if defined(DEVICE_TRNG) || defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
273-
uint32_t test_buff[DEVICE_KEY_32BYTE / sizeof(int)];
274273
mbedtls_entropy_context *entropy = new mbedtls_entropy_context;
275274
mbedtls_entropy_init(entropy);
276275
memset(output, 0, size);
277-
memset(test_buff, 0, size);
278276

279277
ret = mbedtls_entropy_func(entropy, (unsigned char *)output, size);
280-
if (ret != MBED_SUCCESS || mbedtls_ssl_safer_memcmp(test_buff, (unsigned char *)output, size) == 0) {
278+
if (ret != MBED_SUCCESS) {
281279
ret = DEVICEKEY_GENERATE_RANDOM_ERROR;
282280
} else {
283281
ret = DEVICEKEY_SUCCESS;

0 commit comments

Comments
 (0)