Skip to content

Commit ad04edf

Browse files
author
Cruz Monrreal
authored
Merge pull request #9532 from kjbracey-arm/trng_mutex
Mutex-protect mbedtls_hardware_poll
2 parents d1b367f + 983503f commit ad04edf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

features/mbedtls/platform/src/mbed_trng.c renamed to features/mbedtls/platform/src/mbed_trng.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@
1717
#if DEVICE_TRNG
1818

1919
#include "hal/trng_api.h"
20+
#include "platform/PlatformMutex.h"
2021

22+
extern "C"
2123
int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t *olen ) {
24+
static PlatformMutex trng_mutex;
2225
trng_t trng_obj;
26+
trng_mutex.lock();
2327
trng_init(&trng_obj);
2428
int ret = trng_get_bytes(&trng_obj, output, len, olen);
2529
trng_free(&trng_obj);
30+
trng_mutex.unlock();
2631
return ret;
2732
}
2833

0 commit comments

Comments
 (0)