Skip to content

Commit 7db4414

Browse files
committed
M2354: Support TRNG as entropy source on TF-M
1. Update TF-M Secure bin enabling TRNG as entropy source 2. Replaced with above, remove TRNG HAL stuff on Mbed, including platform extra secure functions, cmake, etc.
1 parent 2c3fb3d commit 7db4414

File tree

5 files changed

+0
-193
lines changed

5 files changed

+0
-193
lines changed

targets/TARGET_NUVOTON/TARGET_M2354/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ target_sources(mbed-m2354
7272
serial_api.c
7373
sleep.c
7474
spi_api.c
75-
trng_api.cpp
7675
us_ticker.c
7776
)
7877

targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/platform_extra_secure.c

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -894,80 +894,3 @@ NU_PLAT_XTRA_SEC_HDLR(nu_rtc_isenabled_s)
894894
return TFM_PLATFORM_ERR_SUCCESS;
895895
}
896896
#endif
897-
898-
#ifdef __MBED__
899-
void nu_trng_init_s(void)
900-
{
901-
/* Invoke NSC function */
902-
PLAT_NSC_CALL(nu_trng_init_s, NULL, 0, NULL, 0);
903-
}
904-
#else
905-
NU_PLAT_XTRA_SEC_HDLR(nu_trng_init_s)
906-
{
907-
/* Check parameter validity */
908-
NU_CHK_PARAM_VAL(0, 0);
909-
910-
CLK_EnableModuleClock(TRNG_MODULE);
911-
SYS_ResetModule(TRNG_RST);
912-
TRNG_S->ACT |= TRNG_ACT_ACT_Msk;
913-
while (!(TRNG_S->CTL & TRNG_CTL_READY_Msk));
914-
915-
return TFM_PLATFORM_ERR_SUCCESS;
916-
}
917-
#endif
918-
919-
#ifdef __MBED__
920-
void nu_trng_free_s(void)
921-
{
922-
/* Invoke NSC function */
923-
PLAT_NSC_CALL(nu_trng_free_s, NULL, 0, NULL, 0);
924-
}
925-
#else
926-
NU_PLAT_XTRA_SEC_HDLR(nu_trng_free_s)
927-
{
928-
/* Check parameter validity */
929-
NU_CHK_PARAM_VAL(0, 0);
930-
931-
TRNG_S->ACT &= ~TRNG_ACT_ACT_Msk;
932-
CLK_DisableModuleClock(TRNG_MODULE);
933-
934-
return TFM_PLATFORM_ERR_SUCCESS;
935-
}
936-
#endif
937-
938-
#ifdef __MBED__
939-
int32_t nu_trng_get_bytes_s(uint8_t *output, uint32_t length, uint32_t *output_length)
940-
{
941-
/* Check argument validity */
942-
if (!output && length) {
943-
return -1;
944-
}
945-
946-
/* Invoke NSC function */
947-
PLAT_NSC_CALL(nu_trng_get_bytes_s, NULL, 0, output, length);
948-
949-
/* Finalize output */
950-
if (output_length) {
951-
*output_length = outvec.len;
952-
}
953-
954-
return 0;
955-
}
956-
#else
957-
NU_PLAT_XTRA_SEC_HDLR(nu_trng_get_bytes_s)
958-
{
959-
/* Check parameter validity */
960-
NU_CHK_PARAM_VAL(0, INT_MAX);
961-
962-
uint8_t *output_ind = out_vec->base;
963-
uint8_t *output_end = output_ind + out_vec->len;
964-
965-
for (; output_ind != output_end; output_ind ++) {
966-
TRNG_S->CTL |= TRNG_CTL_TRNGEN_Msk;
967-
while (!(TRNG_S->CTL & TRNG_CTL_DVIF_Msk));
968-
*output_ind = TRNG_S->DATA & 0xff;
969-
}
970-
971-
return TFM_PLATFORM_ERR_SUCCESS;
972-
}
973-
#endif

targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/platform_extra_secure.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ typedef enum {
7777
NU_PLAT_XTRA_SEC_REQ(nu_rtc_read_spare_register_s),
7878
NU_PLAT_XTRA_SEC_REQ(nu_rtc_write_spare_register_s),
7979
NU_PLAT_XTRA_SEC_REQ(nu_rtc_isenabled_s),
80-
NU_PLAT_XTRA_SEC_REQ(nu_trng_init_s),
81-
NU_PLAT_XTRA_SEC_REQ(nu_trng_free_s),
82-
NU_PLAT_XTRA_SEC_REQ(nu_trng_get_bytes_s),
8380

8481
/* Max request code, plays as number of valid request code */
8582
NU_PLAT_XTRA_SEC_REQ(MAX),
@@ -346,39 +343,6 @@ int32_t nu_rtc_isenabled_s(void);
346343
NU_PLAT_XTRA_SEC_HDLR(nu_rtc_isenabled_s);
347344
#endif
348345

349-
/* Secure trng_init
350-
*
351-
* Its synopsis is the same as normal version except change of return/argument type for
352-
* binary-compatible across compilers.
353-
*/
354-
#ifdef __MBED__
355-
void nu_trng_init_s(void);
356-
#else
357-
NU_PLAT_XTRA_SEC_HDLR(nu_trng_init_s);
358-
#endif
359-
360-
/* Secure trng_free
361-
*
362-
* Its synopsis is the same as normal version except change of return/argument type for
363-
* binary-compatible across compilers.
364-
*/
365-
#ifdef __MBED__
366-
void nu_trng_free_s(void);
367-
#else
368-
NU_PLAT_XTRA_SEC_HDLR(nu_trng_free_s);
369-
#endif
370-
371-
/* Secure trng_get_bytes
372-
*
373-
* Its synopsis is the same as normal version except change of return/argument type for
374-
* binary-compatible across compilers.
375-
*/
376-
#ifdef __MBED__
377-
int32_t nu_trng_get_bytes_s(uint8_t *output, uint32_t length, uint32_t *output_length);
378-
#else
379-
NU_PLAT_XTRA_SEC_HDLR(nu_trng_get_bytes_s);
380-
#endif
381-
382346
#ifdef __cplusplus
383347
}
384348
#endif

targets/TARGET_NUVOTON/TARGET_M2354/trng_api.cpp

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)