Skip to content

Commit 245b2eb

Browse files
urutvaPatater
authored andcommitted
psa: Replace Mbed PSA with TF-M
These changes switch to TF-M as the sole PSA implementation for v8-M and dual core targets, with TF-M running on the secure side and Mbed OS running on the non-secure side. Single core v7-M targets will continue to have PSA implemented via PSA emulation, implemented by Mbed OS. Move or remove many PSA-implementing files, as PSA will be provided by TF-M on non-single-v7-M targets. Delete any files that are not relevant for PSA emulation mode. - Remove imported TF-M SPM - Remove Mbed SPM and tests - Remove Mbed-implemented PSA services and tests - Remove PSA_SRV_IMPL, PSA_SRV_IPC, PSA_SRV_EMUL and NSPE. - Replace PSA_SRV_EMUL and PSA_SRV_IMPL with MBED_PSA_SRV - Remove any files autogenerated by "tools/psa/generate_partition_code.py", which no longer exists. Add new feature `PSA` to support PSA in Mbed OS. Add the document supporting_psa_in_mbed-os.md which describes how to add PSA support for a target in Mbed 6. Move the Mbed OS implementation of PSA services for v7-M targets (which employ PSA emulation, and don't yet use TF-M) to features/FEATURE_PSA/TARGET_MBED_PSA_SRV. Update the `requires` attribute in TESTS/configs/baremetal.json to avoid breaking baremetal testing builds. Update .astyleignore to match new directory structure Create the following generic PSA targets: * `PSA_Target` (Root level PSA target) * `PSA_V7_M_NSPE` (Single v7-M NSPE generic target) * `PSA_V7_M_SPE` (Single v7-M SPE generic target) * `PSA_DUAL_V7_M_NSPE` (Dual v7-M NSPE generic target) * `PSA_DUAL_V7_M_SPE` (Dual v7-M SPE generic target) * `PSA_V8_M_NSPE` (v8-M NSPE generic target) * `PSA_V8_M_SPE` (v8-M SPE generic target) Flatten MUSCA_NS and private MUSCA targets into public MUSCA targets. Move mcuboot.bin to flat location (removing prebuilt folder) Signed-off-by: Devaraj Ranganna <[email protected]> Signed-off-by: Jaeden Amero <[email protected]>
1 parent a19afcf commit 245b2eb

File tree

312 files changed

+27083
-4146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+27083
-4146
lines changed

.astyleignore

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
^BUILD
22
^cmsis
3-
^components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation/attestation.h
4-
^components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation/COMPONENT_PSA_SRV_IMPL/tfm_impl
5-
^components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation/qcbor
6-
^components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h
7-
^components/TARGET_PSA/TARGET_TFM
8-
^components/TARGET_PSA/TARGET_MBED_PSA_SRV/TESTS
3+
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation/attestation.h
4+
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation/tfm_impl
5+
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation/qcbor
6+
^features/FEATURE_PSA/TARGET_TFM
7+
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS
98
^features/cryptocell
109
^features/FEATURE_BLE
1110
^features/frameworks

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ test_suite.json
9797

9898
# default delivery dir
9999
DELIVERY/
100+
101+
# Directory used to clone and build TF-M
102+
features/FEATURE_PSA/TARGET_TFM/TARGET_IGNORE/

LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Folders containing files under different permissive license than Apache 2.0 are
55

66
- [cmsis](./cmsis) - MIT, BSD-3-Clause
77
- [components/802.15.4_RF/mcr20a-rf-driver](./components/802.15.4_RF/mcr20a-rf-driver) - BSD-3-Clause
8-
- [components/TARGET_PSA/TARGET_TFM](./components/TARGET_PSA/TARGET_TFM) - BSD-3-Clause
9-
- [components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation](./components/TARGET_PSA/TARGET_MBED_PSA_SRV/services/attestation) - BSD-3-Clause
108
- [features/cryptocell/FEATURE_CRYPTOCELL310](./features/cryptocell/FEATURE_CRYPTOCELL310) - ARM Object Code and Header Files License
119
- [features/FEATURE_BOOTLOADER](./features/FEATURE_BOOTLOADER) - PBL
1210
- [features/FEATURE_BLE/targets](./features/FEATURE_BLE/targets) - BSD-style, PBL, MIT-style
11+
- [features/FEATURE_PSA/FEATURE_TFM](./features/FEATURE_PSA/FEATURE_TFM) - BSD-3-Clause
12+
- [features/FEATURE_PSA/FEATURE_MBED_PSA_SRV/services/attestation](./features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation) - BSD-3-Clause
1313
- [features/lorawan](./features/lorawan) - Revised BSD
1414
- [features/lwipstack](./features/lwipstack) - BSD-style, MIT-style
1515
- [features/nanostack/sal-stack-nanostack](./features/nanostack/sal-stack-nanostack) - BSD-3-Clause

TESTS/configs/baremetal.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"utest",
66
"unity",
77
"psa",
8+
"psa-services",
89
"mbedtls",
910
"psa-compliance-framework",
1011
"filesystem",

TESTS/mbed_hal/trng/main.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,6 @@
6969

7070
using namespace utest::v1;
7171

72-
#if (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
73-
#include "entropy.h"
74-
#include "entropy_poll.h"
75-
#include "crypto.h"
76-
#if !defined(MAX)
77-
#define MAX(a,b) (((a)>(b))?(a):(b))
78-
#endif
79-
80-
/* Calculating the minimum allowed entropy size in bytes */
81-
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \
82-
MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)
83-
84-
void inject_entropy_for_psa()
85-
{
86-
if (psa_crypto_init() == PSA_ERROR_INSUFFICIENT_ENTROPY) {
87-
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
88-
/* inject some a seed for test*/
89-
for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
90-
seed[i] = i;
91-
}
92-
93-
/* don't really care if this succeed this is just to make crypto init pass*/
94-
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
95-
}
96-
}
97-
#endif // (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
98-
9972
static int fill_buffer_trng(uint8_t *buffer, trng_t *trng_obj, size_t trng_len)
10073
{
10174
size_t temp_size = 0, output_length = 0;
@@ -275,9 +248,6 @@ int main()
275248
#if defined(MBEDTLS_PLATFORM_C)
276249
ret = mbedtls_platform_setup(NULL);
277250
#endif /* MBEDTLS_PLATFORM_C */
278-
#if (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
279-
inject_entropy_for_psa();
280-
#endif
281251
ret = !Harness::run(specification);
282252
#if defined(MBEDTLS_PLATFORM_C)
283253
mbedtls_platform_teardown(NULL);

TESTS/mbedtls/sanity/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "psa/crypto.h"
19-
20-
#if ((!defined(TARGET_PSA)) || (!defined(MBEDTLS_PSA_CRYPTO_C)))
18+
#if ((!defined(FEATURE_PSA)) || (!defined(MBEDTLS_PSA_CRYPTO_C)))
2119
#error [NOT_SUPPORTED] Mbed Crypto is OFF - skipping.
2220
#else
2321

22+
#include "psa/crypto.h"
2423
#include <stdio.h>
2524
#include "mbed.h"
2625
#include "greentea-client/test_env.h"
@@ -31,7 +30,7 @@
3130

3231
using namespace utest::v1;
3332

34-
#if defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
33+
#if defined(MBEDTLS_ENTROPY_NV_SEED)
3534

3635
#if !defined(MAX)
3736
#define MAX(a,b) (((a)>(b))?(a):(b))
@@ -48,7 +47,7 @@ void inject_entropy()
4847
}
4948
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
5049
}
51-
#endif // defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
50+
#endif // defined(MBEDTLS_ENTROPY_NV_SEED)
5251

5352
void test_crypto_random(void)
5453
{
@@ -431,12 +430,12 @@ void test_crypto_hash_clone(void)
431430
utest::v1::status_t case_setup_handler(const Case *const source, const size_t index_of_case)
432431
{
433432
psa_status_t status = psa_crypto_init();
434-
#if defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
433+
#if defined(MBEDTLS_ENTROPY_NV_SEED)
435434
if (status == PSA_ERROR_INSUFFICIENT_ENTROPY) {
436435
inject_entropy();
437436
status = psa_crypto_init();
438437
}
439-
#endif /* defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC) */
438+
#endif /* defined(MBEDTLS_ENTROPY_NV_SEED) */
440439
TEST_ASSERT_EQUAL(PSA_SUCCESS, status);
441440
return greentea_case_setup_handler(source, index_of_case);
442441
}

TESTS/mbedtls/selftest/main.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,6 @@ Case cases[] = {
8787
#endif /* MBEDTLS_SELF_TEST */
8888
};
8989

90-
#if (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
91-
#include "crypto.h"
92-
#if !defined(MAX)
93-
#define MAX(a,b) (((a)>(b))?(a):(b))
94-
#endif
95-
96-
/* Calculating the minimum allowed entropy size in bytes */
97-
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \
98-
MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)
99-
100-
void inject_entropy_for_psa()
101-
{
102-
if (psa_crypto_init() == PSA_ERROR_INSUFFICIENT_ENTROPY) {
103-
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
104-
/* inject some a seed for test*/
105-
for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
106-
seed[i] = i;
107-
}
108-
109-
/* don't really care if this succeed this is just to make crypto init pass*/
110-
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
111-
}
112-
}
113-
#endif // (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
114-
115-
11690
utest::v1::status_t test_setup(const size_t num_cases)
11791
{
11892
GREENTEA_SETUP(120, "default_auto");
@@ -131,10 +105,6 @@ int main()
131105
}
132106
#endif
133107

134-
#if (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
135-
inject_entropy_for_psa();
136-
#endif
137-
138108
ret = (Harness::run(specification) ? 0 : 1);
139109
#if defined(MBEDTLS_PLATFORM_C)
140110
mbedtls_platform_teardown(NULL);

cmsis/TARGET_CORTEX_M/mbed_tz_context.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* limitations under the License.
2323
*/
2424

25-
#if !TARGET_TFM
25+
#if !FEATURE_TFM
2626

2727
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
2828

@@ -204,4 +204,4 @@ uint32_t TZ_StoreContext_S (TZ_MemoryId_t id) {
204204
}
205205
#endif
206206

207-
#endif // !TARGET_TFM
207+
#endif // !FEATURE_TFM

components/TARGET_PSA/TARGET_MBED_PSA_SRV/TARGET_TFM/COMPONENT_NSPE/interface/src/tfm_ns_lock_rtx.c

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

0 commit comments

Comments
 (0)