Skip to content

Nuvoton: Re-implement TRNG HAL with TRNG H/W #11650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions targets/TARGET_NUVOTON/TARGET_M2351/PeripheralNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,15 @@ typedef enum {

} CANName;

typedef enum {
#if defined(SCU_INIT_PNSSET5_VAL) && (SCU_INIT_PNSSET5_VAL & (1 << 25))
TRNG_0 = (int) NU_MODNAME(TRNG_BASE + NS_OFFSET, 0, 0)
#else
TRNG_0 = (int) NU_MODNAME(TRNG_BASE, 0, 0)
#endif

} TRNGName;

#ifdef __cplusplus
}
#endif
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The pre-built secure code has the following hardware partition:
- **TMR2/3** configured to nonsecure. TMR2 implements nonsecure `us_ticker`, and TMR3 implements nonsecure `lp_ticker`.
- **PDMA0** hardwired to secure. Implements secure asynchronous transfer.
- **PDMA1** configured to nonsecure. Implements nonsecure asynchronous transfer.
- **TRNG** configured to secure. Accessible to nonsecure through a secure gateway.

## Pre-built secure code files

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "platform/SingletonPtr.h"
#include "platform/PlatformMutex.h"

#if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT)
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)

/* Consideration for choosing proper synchronization mechanism
*
Expand Down Expand Up @@ -345,4 +345,4 @@ extern "C" void CRPT_IRQHandler()
}
}

#endif /* #if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT) */
#endif /* #if defined(MBEDTLS_CONFIG_HW_SUPPORT) */
17 changes: 8 additions & 9 deletions targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,23 @@
*
* There's only one CRYPTO/CRPT module and we have the following policy for configuring its secure attribute:
*
* 1. TRNG or mbedtls H/W support can be enabled on either secure target or non-secure target, but not both.
* 2. TRNG and mbedtls H/W supports cannot be enabled on different targets.
* 3. On secure target, if TRNG or mbedtls H/W support is enabled, CRYPTO/CRPT must configure to secure.
* 4. On non-secure target, if TRNG or mbedtls H/W support is enabled, CRYPTO/CRPT must configure to non-secure.
* 1. mbedtls H/W support can be enabled on either secure target or non-secure target, but not both.
* 2. On secure target, if mbedtls H/W support is enabled, CRYPTO/CRPT must configure to secure.
* 3. On non-secure target, if mbedtls H/W support is enabled, CRYPTO/CRPT must configure to non-secure.
*/
#if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT)
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
#if defined(SCU_INIT_PNSSET1_VAL) && (SCU_INIT_PNSSET1_VAL & (1 << 18))
#error("CRYPTO/CRPT must configure to secure for secure target which supports TRNG or mbedtls H/W")
#error("CRYPTO/CRPT must configure to secure for secure target which supports mbedtls H/W")
#endif
#else
#if (! defined(SCU_INIT_PNSSET1_VAL)) || (! (SCU_INIT_PNSSET1_VAL & (1 << 18)))
#error("CRYPTO/CRPT must configure to non-secure for non-secure target which supports TRNG or mbedtls H/W")
#error("CRYPTO/CRPT must configure to non-secure for non-secure target which supports mbedtls H/W")
#endif
#endif
#endif

#if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT)
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -132,6 +131,6 @@ bool crypto_dma_buffs_overlap(const void *in_buff, size_t in_buff_size, const vo
}
#endif

#endif /* #if DEVICE_TRNG || defined(MBEDTLS_CONFIG_HW_SUPPORT) */
#endif /* defined(MBEDTLS_CONFIG_HW_SUPPORT) */

#endif
2 changes: 1 addition & 1 deletion targets/TARGET_NUVOTON/TARGET_M2351/device/M2351.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ typedef volatile unsigned short vu16;
#include "m2351_qei.h"
#include "m2351_can.h"
#include "m2351_scu.h"
#include "m2351_bootloader.h"
#include "m2351_mkromlib.h"

#endif /* __M2351_H__ */

Expand Down
37 changes: 0 additions & 37 deletions targets/TARGET_NUVOTON/TARGET_M2351/device/M2351_funcs.S

This file was deleted.

Loading