Skip to content

Commit 270ea5d

Browse files
authored
Merge pull request #14815 from LDong-Arm/test_psa_k64f_k66f
Enable PSA tests on K64F/K66F and fix missing PSA Crypto init in TLSSocketWrapper
2 parents 8902a0c + 929956d commit 270ea5d

File tree

6 files changed

+81
-18
lines changed

6 files changed

+81
-18
lines changed

connectivity/mbedtls/platform/inc/platform_mbed.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#ifndef __PLATFORM_MBED__H__
2222
#define __PLATFORM_MBED__H__
2323

24-
#if (defined(FEATURE_EXPERIMENTAL_API) && defined(FEATURE_PSA) && defined(MBEDTLS_ENTROPY_NV_SEED))
24+
#if defined(FEATURE_EXPERIMENTAL_API) && defined(FEATURE_PSA)
25+
26+
#if defined(MBEDTLS_ENTROPY_NV_SEED)
2527

2628
#include "default_random_seed.h"
2729

@@ -37,19 +39,8 @@
3739
* MBEDTLS_ENTROPY_NV_SEED is enabled. */
3840
#define MBEDTLS_PSA_INJECT_ENTROPY
3941

40-
#endif // (defined(FEATURE_PSA) && defined(MBEDTLS_ENTROPY_NV_SEED))
41-
42-
#if DEVICE_TRNG
43-
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
44-
#define MBEDTLS_ENTROPY_HARDWARE_ALT
45-
#endif
46-
#endif
47-
48-
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
49-
#include "mbedtls_device.h"
50-
#endif
42+
#endif // defined(MBEDTLS_ENTROPY_NV_SEED)
5143

52-
#if defined(FEATURE_PSA)
5344
/* The following configurations are a needed for Mbed Crypto submodule.
5445
* They are related to the persistent key storage feature.
5546
*/
@@ -58,6 +49,17 @@
5849
#undef MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
5950

6051
#define MBEDTLS_ENTROPY_HARDWARE_ALT
52+
53+
#endif // defined(FEATURE_EXPERIMENTAL_API) && defined(FEATURE_PSA)
54+
55+
#if DEVICE_TRNG
56+
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
57+
#define MBEDTLS_ENTROPY_HARDWARE_ALT
58+
#endif
59+
#endif
60+
61+
#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
62+
#include "mbedtls_device.h"
6163
#endif
6264

6365
/*

connectivity/netsocket/source/TLSSocketWrapper.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "mbed_error.h"
2929
#include "rtos/Kernel.h"
3030

31+
#if defined(MBEDTLS_USE_PSA_CRYPTO)
32+
#include "psa/crypto.h"
33+
#endif
34+
3135
// This class requires Mbed TLS SSL/TLS client code
3236
#if defined(MBEDTLS_SSL_CLI_C)
3337

@@ -41,6 +45,16 @@ TLSSocketWrapper::TLSSocketWrapper(Socket *transport, const char *hostname, cont
4145
_clicert_allocated(false),
4246
_ssl_conf_allocated(false)
4347
{
48+
#if defined(MBEDTLS_USE_PSA_CRYPTO)
49+
// It is safe to call psa_crypto_init() any number of times as
50+
// defined by the PSA Crypto API. There is no standard "deinit"
51+
// function.
52+
psa_status_t status = psa_crypto_init();
53+
if (status != PSA_SUCCESS) {
54+
tr_err("psa_crypto_init() failed (" PRIu32 ")", status);
55+
}
56+
#endif /* MBEDTLS_USE_PSA_CRYPTO */
57+
4458
#if defined(MBEDTLS_PLATFORM_C)
4559
int ret = mbedtls_platform_setup(nullptr);
4660
if (ret != 0) {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"config": {
3+
"echo-server-addr" : {
4+
"help" : "IP address of echo server",
5+
"value" : "\"echo.mbedcloudtesting.com\""
6+
},
7+
"echo-server-port" : {
8+
"help" : "Port of echo server",
9+
"value" : "7"
10+
},
11+
"echo-server-discard-port" : {
12+
"help" : "Discard port of echo server",
13+
"value" : "9"
14+
},
15+
"echo-server-port-tls" : {
16+
"help" : "Port of echo server for TLS",
17+
"value" : "2007"
18+
},
19+
"echo-server-discard-port-tls" : {
20+
"help" : "Discard port of echo server for TLS",
21+
"value" : "2009"
22+
},
23+
"sim-blockdevice": {
24+
"help": "Simulated block device, requires sufficient heap",
25+
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
26+
"value": "HeapBlockDevice"
27+
}
28+
},
29+
"target_overrides": {
30+
"*": {
31+
"target.network-default-interface-type": "ETHERNET",
32+
"target.features_add": [
33+
"EXPERIMENTAL_API"
34+
]
35+
}
36+
}
37+
}

tools/test_configs/config_paths.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"ETHERNET" : "EthernetInterface.json",
3+
"EXPERIMENTAL": "experimental.json",
34
"HEAPBLOCKDEVICE": "HeapBlockDevice.json",
45
"HEAPBLOCKDEVICE_AND_ETHERNET": "HeapBlockDeviceAndEthernetInterface.json",
6+
"HEAPBLOCKDEVICE_AND_ETHERNET_AND_EXPERIMENTAL": "HeapBlockDeviceAndEthernetAndExperimental.json",
57
"HEAPBLOCKDEVICE_AND_WIFI": "HeapBlockDeviceAndWifiInterface.json",
68
"ESP8266_WIFI" : "ESP8266Interface.json",
79
"ISM43362_WIFI" : "ISM43362Interface.json",

tools/test_configs/experimental.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"target_overrides": {
3+
"*": {
4+
"target.features_add": [
5+
"EXPERIMENTAL_API"
6+
]
7+
}
8+
}
9+
}

tools/test_configs/target_configs.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
{
22
"K64F": {
3-
"nsapi.socket-stats-enable": true,
4-
"default_test_configuration": "HEAPBLOCKDEVICE_AND_ETHERNET",
3+
"default_test_configuration": "HEAPBLOCKDEVICE_AND_ETHERNET_AND_EXPERIMENTAL",
54
"test_configurations": ["HEAPBLOCKDEVICE_AND_ETHERNET", "NANOSTACK_MAC_TESTER", "ESP8266_WIFI", "ETHERNET"]
65
},
6+
"K66F": {
7+
"default_test_configuration": "EXPERIMENTAL"
8+
},
79
"NUCLEO_F429ZI": {
8-
"nsapi.socket-stats-enable": true,
910
"default_test_configuration": "HEAPBLOCKDEVICE_AND_ETHERNET",
1011
"test_configurations": ["HEAPBLOCKDEVICE_AND_ETHERNET", "NANOSTACK_MAC_TESTER"]
1112
},
1213
"DISCO_L475VG_IOT01A": {
13-
"nsapi.socket-stats-enable": true,
1414
"default_test_configuration": "NONE",
1515
"test_configurations": ["ISM43362_WIFI"]
1616
},
1717
"DISCO_F413ZH": {
18-
"nsapi.socket-stats-enable": true,
1918
"default_test_configuration": "NONE",
2019
"test_configurations": ["ISM43362_WIFI"]
2120
},

0 commit comments

Comments
 (0)