Skip to content

WIP Replace Mbed PSA with TF-M PSA #12954

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

Closed
wants to merge 11 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 5 additions & 6 deletions .astyleignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
^BUILD
^cmsis
^components/TARGET_PSA/services/attestation/attestation.h
^components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/tfm_impl
^components/TARGET_PSA/services/attestation/qcbor
^components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h
^components/TARGET_PSA/TARGET_TFM
^components/TARGET_PSA/TESTS
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation/attestation.h
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation/implementation/tfm_impl
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation/qcbor
^features/FEATURE_PSA/TARGET_TFM
^features/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS
^features/cryptocell
^features/FEATURE_BLE
^features/frameworks
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ test_suite.json

# default delivery dir
DELIVERY/

# Directory used to clone and build TF-M
features/FEATURE_PSA/TARGET_TFM/TARGET_IGNORE/
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Folders containing files under different permissive license than Apache 2.0 are

- [cmsis](./cmsis) - MIT, BSD-3-Clause
- [components/802.15.4_RF/mcr20a-rf-driver](./components/802.15.4_RF/mcr20a-rf-driver) - BSD-3-Clause
- [components/TARGET_PSA/TARGET_TFM](./components/TARGET_PSA/TARGET_TFM) - BSD-3-Clause
- [components/TARGET_PSA/TARGET_PSA/services/attestation](./components/TARGET_PSA/services/attestation) - BSD-3-Clause
- [features/cryptocell/FEATURE_CRYPTOCELL310](./features/cryptocell/FEATURE_CRYPTOCELL310) - ARM Object Code and Header Files License
- [features/FEATURE_BOOTLOADER](./features/FEATURE_BOOTLOADER) - PBL
- [features/FEATURE_BLE/targets](./features/FEATURE_BLE/targets) - BSD-style, PBL, MIT-style
- [features/FEATURE_PSA/FEATURE_TFM](./features/FEATURE_PSA/FEATURE_TFM) - BSD-3-Clause
- [features/FEATURE_PSA/FEATURE_MBED_PSA_SRV/services/attestation](./features/FEATURE_PSA/TARGET_MBED_PSA_SRV/services/attestation) - BSD-3-Clause
- [features/lorawan](./features/lorawan) - Revised BSD
- [features/lwipstack](./features/lwipstack) - BSD-style, MIT-style
- [features/nanostack/sal-stack-nanostack](./features/nanostack/sal-stack-nanostack) - BSD-3-Clause
Expand Down
1 change: 1 addition & 0 deletions TESTS/configs/baremetal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"utest",
"unity",
"psa",
"psa-services",
"mbedtls",
"psa-compliance-framework",
"filesystem",
Expand Down
30 changes: 0 additions & 30 deletions TESTS/mbed_hal/trng/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,6 @@

using namespace utest::v1;

#if (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
#include "entropy.h"
#include "entropy_poll.h"
#include "crypto.h"
#if !defined(MAX)
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif

/* Calculating the minimum allowed entropy size in bytes */
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \
MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)

void inject_entropy_for_psa()
{
if (psa_crypto_init() == PSA_ERROR_INSUFFICIENT_ENTROPY) {
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
/* inject some a seed for test*/
for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
seed[i] = i;
}

/* don't really care if this succeed this is just to make crypto init pass*/
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
}
}
#endif // (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))

static int fill_buffer_trng(uint8_t *buffer, trng_t *trng_obj, size_t trng_len)
{
size_t temp_size = 0, output_length = 0;
Expand Down Expand Up @@ -275,9 +248,6 @@ int main()
#if defined(MBEDTLS_PLATFORM_C)
ret = mbedtls_platform_setup(NULL);
#endif /* MBEDTLS_PLATFORM_C */
#if (defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
inject_entropy_for_psa();
#endif
ret = !Harness::run(specification);
#if defined(MBEDTLS_PLATFORM_C)
mbedtls_platform_teardown(NULL);
Expand Down
13 changes: 6 additions & 7 deletions TESTS/mbedtls/sanity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
* limitations under the License.
*/

#include "psa/crypto.h"

#if ((!defined(TARGET_PSA)) || (!defined(MBEDTLS_PSA_CRYPTO_C)))
#if ((!defined(FEATURE_PSA)) || (!defined(MBEDTLS_PSA_CRYPTO_C)))
#error [NOT_SUPPORTED] Mbed Crypto is OFF - skipping.
#else

#include "psa/crypto.h"
#include <stdio.h>
#include "mbed.h"
#include "greentea-client/test_env.h"
Expand All @@ -31,7 +30,7 @@

using namespace utest::v1;

#if defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
#if defined(MBEDTLS_ENTROPY_NV_SEED)

#if !defined(MAX)
#define MAX(a,b) (((a)>(b))?(a):(b))
Expand All @@ -48,7 +47,7 @@ void inject_entropy()
}
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
}
#endif // defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
#endif // defined(MBEDTLS_ENTROPY_NV_SEED)

void test_crypto_random(void)
{
Expand Down Expand Up @@ -431,12 +430,12 @@ void test_crypto_hash_clone(void)
utest::v1::status_t case_setup_handler(const Case *const source, const size_t index_of_case)
{
psa_status_t status = psa_crypto_init();
#if defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC)
#if defined(MBEDTLS_ENTROPY_NV_SEED)
if (status == PSA_ERROR_INSUFFICIENT_ENTROPY) {
inject_entropy();
status = psa_crypto_init();
}
#endif /* defined(MBEDTLS_ENTROPY_NV_SEED) || defined(COMPONENT_PSA_SRV_IPC) */
#endif /* defined(MBEDTLS_ENTROPY_NV_SEED) */
TEST_ASSERT_EQUAL(PSA_SUCCESS, status);
return greentea_case_setup_handler(source, index_of_case);
}
Expand Down
30 changes: 0 additions & 30 deletions TESTS/mbedtls/selftest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,6 @@ Case cases[] = {
#endif /* MBEDTLS_SELF_TEST */
};

#if (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
#include "crypto.h"
#if !defined(MAX)
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif

/* Calculating the minimum allowed entropy size in bytes */
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \
MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)

void inject_entropy_for_psa()
{
if (psa_crypto_init() == PSA_ERROR_INSUFFICIENT_ENTROPY) {
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
/* inject some a seed for test*/
for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
seed[i] = i;
}

/* don't really care if this succeed this is just to make crypto init pass*/
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
}
}
#endif // (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))


utest::v1::status_t test_setup(const size_t num_cases)
{
GREENTEA_SETUP(120, "default_auto");
Expand All @@ -131,10 +105,6 @@ int main()
}
#endif

#if (defined(MBEDTLS_ENTROPY_C) && defined(TARGET_PSA) && defined(COMPONENT_PSA_SRV_IPC) && defined(MBEDTLS_PSA_CRYPTO_C))
inject_entropy_for_psa();
#endif

ret = (Harness::run(specification) ? 0 : 1);
#if defined(MBEDTLS_PLATFORM_C)
mbedtls_platform_teardown(NULL);
Expand Down
4 changes: 2 additions & 2 deletions cmsis/TARGET_CORTEX_M/mbed_tz_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* limitations under the License.
*/

#if !TARGET_TFM
#if !FEATURE_TFM

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

Expand Down Expand Up @@ -204,4 +204,4 @@ uint32_t TZ_StoreContext_S (TZ_MemoryId_t id) {
}
#endif

#endif // !TARGET_TFM
#endif // !FEATURE_TFM

This file was deleted.

Loading