NuMaker connection with AWS IoT thru MQTT/HTTPS (Mbed OS 6)
Dependencies: MQTT
Diff: targets/TARGET_NUVOTON/platform_entropy.cpp
- Revision:
- 41:b878d7cd7035
- Parent:
- 33:c3a985807206
- Child:
- 42:fa6f7f79a112
diff -r 5a813d7ad6d8 -r b878d7cd7035 targets/TARGET_NUVOTON/platform_entropy.cpp --- a/targets/TARGET_NUVOTON/platform_entropy.cpp Thu Nov 12 16:24:00 2020 +0800 +++ b/targets/TARGET_NUVOTON/platform_entropy.cpp Fri Mar 27 14:32:06 2020 +0800 @@ -180,7 +180,11 @@ { #if NU_CRYPTO_PRNG_PRESENT crypto_init(); +#if TARGET_NUC472 || (MBED_MAJOR_VERSION < 6) PRNG_ENABLE_INT(); +#else + PRNG_ENABLE_INT(CRPT); +#endif #endif uint32_t seed = 0; @@ -194,8 +198,12 @@ #if NU_CRYPTO_PRNG_PRESENT /* PRNG reload seed */ +#if TARGET_NUC472 || (MBED_MAJOR_VERSION < 6) PRNG_Open(PRNG_KEYSIZE_ID, 1, seed); #else + PRNG_Open(CRPT, PRNG_KEYSIZE_ID, 1, seed); +#endif +#else srand(seed); #endif /* #if NU_CRYPTO_PRNG_PRESENT */ } @@ -203,7 +211,11 @@ NuEADCSeedRandom::~NuEADCSeedRandom() { #if NU_CRYPTO_PRNG_PRESENT +#if TARGET_NUC472 || (MBED_MAJOR_VERSION < 6) PRNG_DISABLE_INT(); +#else + PRNG_DISABLE_INT(CRPT); +#endif crypto_uninit(); #endif /* #if NU_CRYPTO_PRNG_PRESENT */ } @@ -221,11 +233,18 @@ uint32_t rand_data[PRNG_KEYSIZE / sizeof(uint32_t)]; while (rmn) { crypto_prng_prestart(); +#if TARGET_NUC472 || (MBED_MAJOR_VERSION < 6) PRNG_Start(); +#else + PRNG_Start(CRPT); +#endif crypto_prng_wait(); +#if TARGET_NUC472 || (MBED_MAJOR_VERSION < 6) PRNG_Read(rand_data); - +#else + PRNG_Read(CRPT, rand_data); +#endif size_t n = (rmn >= PRNG_KEYSIZE) ? PRNG_KEYSIZE : rmn; memcpy(output_ind, rand_data, n);