mirror of https://github.com/ARMmbed/mbed-os.git
Use PSA TRNG if PSA is enabled and no TRNG device defined
Signed-off-by: Charley Chu <haoc@cypress.com>pull/13358/head
parent
a1bc65a152
commit
ff74ea41c1
|
@ -54,6 +54,8 @@
|
|||
#define MBEDTLS_PSA_CRYPTO_STORAGE_C
|
||||
#define MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C
|
||||
#undef MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
|
||||
|
||||
#define MBEDTLS_ENTROPY_HARDWARE_ALT
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if DEVICE_TRNG
|
||||
#if defined(DEVICE_TRNG) || defined(FEATURE_PSA)
|
||||
|
||||
#include "hal/trng_api.h"
|
||||
#include "platform/SingletonPtr.h"
|
||||
|
@ -24,6 +24,7 @@ SingletonPtr<PlatformMutex> mbedtls_mutex;
|
|||
|
||||
extern "C"
|
||||
int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t *olen ) {
|
||||
#if defined(DEVICE_TRNG)
|
||||
trng_t trng_obj;
|
||||
mbedtls_mutex->lock();
|
||||
trng_init(&trng_obj);
|
||||
|
@ -31,6 +32,12 @@ int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t
|
|||
trng_free(&trng_obj);
|
||||
mbedtls_mutex->unlock();
|
||||
return ret;
|
||||
#else /* defined(FEATURE_PSA) */
|
||||
mbedtls_mutex->lock();
|
||||
int ret = trng_get_bytes(NULL, output, len, olen);
|
||||
mbedtls_mutex->unlock();
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <stddef.h>
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_TRNG
|
||||
#if defined(DEVICE_TRNG) || defined(FEATURE_PSA)
|
||||
|
||||
/** TRNG HAL structure. trng_s is declared in the target's HAL
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue