mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9532 from kjbracey-arm/trng_mutex
Mutex-protect mbedtls_hardware_pollpull/9541/head
commit
ad04edf9c1
|
@ -17,12 +17,17 @@
|
|||
#if DEVICE_TRNG
|
||||
|
||||
#include "hal/trng_api.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
|
||||
extern "C"
|
||||
int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t *olen ) {
|
||||
static PlatformMutex trng_mutex;
|
||||
trng_t trng_obj;
|
||||
trng_mutex.lock();
|
||||
trng_init(&trng_obj);
|
||||
int ret = trng_get_bytes(&trng_obj, output, len, olen);
|
||||
trng_free(&trng_obj);
|
||||
trng_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue