Skip to content

Commit 4789448

Browse files
woody-applepull[bot]
authored andcommitted
Revert: "[OIS] Add PSA crypto backend support" (#27391)
This reverts commit 834663d.
1 parent 10eae84 commit 4789448

22 files changed

+57
-183
lines changed

.github/.wordlist.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,6 @@ ProxyDiscovery
10711071
ProxyValid
10721072
ProxyView
10731073
PRs
1074-
PSA
10751074
PSCAN
10761075
PSECT
10771076
PSK

.github/workflows/examples-openiotsdk.yaml

+3-8
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ env:
3131

3232
jobs:
3333
openiotsdk:
34-
strategy:
35-
fail-fast: false
36-
matrix:
37-
cryptoBackend: ["psa", "mbedtls"]
38-
3934
name: Open IoT SDK examples building
4035
timeout-minutes: 90
4136

@@ -94,7 +89,7 @@ jobs:
9489
id: build_shell
9590
timeout-minutes: 10
9691
run: |
97-
scripts/examples/openiotsdk_example.sh -b ${{ matrix.cryptoBackend }} shell
92+
scripts/examples/openiotsdk_example.sh shell
9893
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
9994
openiotsdk release shell \
10095
examples/shell/openiotsdk/build/chip-openiotsdk-shell-example.elf \
@@ -104,7 +99,7 @@ jobs:
10499
id: build_lock_app
105100
timeout-minutes: 10
106101
run: |
107-
scripts/examples/openiotsdk_example.sh -b ${{ matrix.cryptoBackend }} lock-app
102+
scripts/examples/openiotsdk_example.sh lock-app
108103
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
109104
openiotsdk release lock-app \
110105
examples/lock-app/openiotsdk/build/chip-openiotsdk-lock-app-example.elf \
@@ -114,7 +109,7 @@ jobs:
114109
id: build_unit_tests
115110
timeout-minutes: 10
116111
run: |
117-
scripts/examples/openiotsdk_example.sh -b ${{ matrix.cryptoBackend }} unit-tests
112+
scripts/examples/openiotsdk_example.sh unit-tests
118113
119114
- name: "Test: shell example"
120115
if: steps.build_shell.outcome == 'success'

.vscode/tasks.json

-9
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@
251251
"-Cbuild",
252252
"-d${input:openiotsdkDebugMode}",
253253
"-l${input:openiotsdkLwipDebug}",
254-
"-b${input:openiotsdkCryptoBackend}",
255254
"${input:openiotsdkExample}"
256255
],
257256
"group": "build",
@@ -272,7 +271,6 @@
272271
"-Cbuild",
273272
"-d${input:openiotsdkDebugMode}",
274273
"-l${input:openiotsdkLwipDebug}",
275-
"-b${input:openiotsdkCryptoBackend}",
276274
"unit-tests"
277275
],
278276
"group": "build",
@@ -482,13 +480,6 @@
482480
"options": ["false", "true"],
483481
"default": "false"
484482
},
485-
{
486-
"type": "pickString",
487-
"id": "openiotsdkCryptoBackend",
488-
"description": "Which Crypto algorithm do you wish to use?",
489-
"options": ["mbedtls", "psa"],
490-
"default": "mbedtls"
491-
},
492483
{
493484
"type": "command",
494485
"id": "openiotsdkExample",

config/openiotsdk/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ matter_add_gn_arg_bool ("chip_automation_logging" CONFIG_CHIP_AUTO
6262
matter_add_gn_arg_bool ("chip_error_logging" CONFIG_CHIP_ERROR_LOGGING)
6363
matter_add_gn_arg_bool ("chip_openiotsdk_use_tfm" TFM_SUPPORT)
6464
matter_add_gn_arg_bool ("chip_openiotsdk_use_psa_ps" CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS)
65-
matter_add_gn_arg_string("chip_crypto" "${CONFIG_CHIP_CRYPTO}")
6665
if (TARGET cmsis-rtos-api)
6766
matter_add_gn_arg_string("target_os" "cmsis-rtos")
6867
endif()

config/openiotsdk/chip-gn/args.gni

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ chip_system_config_use_lwip = true
3131
lwip_platform = "external"
3232
chip_system_config_use_sockets = false
3333

34+
chip_crypto = "mbedtls"
3435
chip_external_mbedtls = true
3536

3637
custom_toolchain = "${chip_root}/config/openiotsdk/chip-gn/toolchain:openiotsdk"

config/openiotsdk/cmake/chip.cmake

+2-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)
2323

24-
# Default CHIP build configuration
24+
# Default CHIP build configuration
2525
set(CONFIG_CHIP_PROJECT_CONFIG "main/include/CHIPProjectConfig.h" CACHE STRING "")
2626
set(CONFIG_CHIP_LIB_TESTS NO CACHE BOOL "")
2727
set(CONFIG_CHIP_LIB_SHELL NO CACHE BOOL "")
@@ -32,7 +32,6 @@ set(CONFIG_CHIP_AUTOMATION_LOGGING YES CACHE BOOL "Enable logging at automation
3232
set(CONFIG_CHIP_ERROR_LOGGING YES CACHE BOOL "Enable logging at error level")
3333

3434
set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS NO CACHE BOOL "Enable using PSA Protected Storage")
35-
set(CONFIG_CHIP_CRYPTO "mbedtls" CACHE STRING "Matter crypto backend. Mbedtls as default")
3635

3736
if(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS AND NOT TFM_SUPPORT)
3837
message( FATAL_ERROR "You can not use PSA Protected Storage without TF-M support" )
@@ -54,14 +53,8 @@ if(TFM_SUPPORT)
5453
add_dependencies(chip-gn tfm-ns-interface)
5554
endif()
5655

57-
if ("${CONFIG_CHIP_CRYPTO}" STREQUAL "psa")
58-
target_compile_definitions(chip
59-
INTERFACE
60-
CONFIG_CHIP_CRYPTO_PSA)
61-
endif()
62-
6356
function(chip_add_data_model target scope model_name)
64-
target_include_directories(${target}
57+
target_include_directories(${target}
6558
PUBLIC
6659
${GEN_DIR}/app-common
6760
${GEN_DIR}/${model_name}-app

config/openiotsdk/cmake/sdk.cmake

+17-18
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ get_filename_component(OPEN_IOT_SDK_STORAGE_SOURCE ${CHIP_ROOT}/third_party/open
2727
# Open IoT SDK targets passed to CHIP build
2828
list(APPEND CONFIG_CHIP_EXTERNAL_TARGETS)
2929

30-
# Additional Open IoT SDK build configuration
30+
# Additional Open IoT SDK build configuration
3131
set(TFM_SUPPORT NO CACHE BOOL "Add Trusted Firmware-M (TF-M) support to application")
3232
set(TFM_NS_APP_VERSION "0.0.0" CACHE STRING "TF-M non-secure application version (in the x.x.x format)")
3333
set(CONFIG_CHIP_OPEN_IOT_SDK_LWIP_DEBUG NO CACHE BOOL "Enable LwIP debug logs")
@@ -82,7 +82,7 @@ if(TFM_SUPPORT)
8282
set(TFM_PLATFORM ${OPEN_IOT_SDK_EXAMPLE_COMMON}/tf-m/targets/an552)
8383
set(TFM_PSA_FIRMWARE_UPDATE ON)
8484
set(MCUBOOT_IMAGE_VERSION_NS ${TFM_NS_APP_VERSION})
85-
set(TFM_CMAKE_ARGS "-DCONFIG_TFM_ENABLE_FP=ON;-DTFM_PROFILE=profile_medium;-DTFM_EXCEPTION_INFO_DUMP=ON;-DCONFIG_TFM_HALT_ON_CORE_PANIC=ON;-DTFM_ISOLATION_LEVEL=1;-DTFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH=${OPEN_IOT_SDK_CONFIG}/mbedtls/mbedtls_config_psa.h;-DMBEDCRYPTO_BUILD_TYPE=${CMAKE_BUILD_TYPE};-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
85+
set(TFM_CMAKE_ARGS "-DCONFIG_TFM_ENABLE_FP=ON;-DTFM_PROFILE=profile_medium;-DTFM_EXCEPTION_INFO_DUMP=ON;-DCONFIG_TFM_HALT_ON_CORE_PANIC=ON;-DTFM_ISOLATION_LEVEL=1")
8686
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
8787
set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DMCUBOOT_LOG_LEVEL=INFO;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_DEBUG;-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_INFO")
8888
else()
@@ -117,24 +117,24 @@ endif()
117117
# Add RTOS configuration headers
118118
# Link cmsis-rtos-api against a concrete implementation
119119
if(TARGET cmsis-rtos-api)
120-
target_include_directories(cmsis-core
121-
INTERFACE
120+
target_include_directories(cmsis-core
121+
INTERFACE
122122
cmsis-config
123123
)
124-
124+
125125
target_compile_definitions(cmsis-rtos-api
126126
PUBLIC
127127
DOMAIN_NS=$<IF:$<BOOL:${TFM_SUPPORT}>,1,0>
128128
)
129129

130130
if(TARGET freertos-kernel)
131-
target_include_directories(freertos-kernel
132-
PUBLIC
131+
target_include_directories(freertos-kernel
132+
PUBLIC
133133
freertos-config
134134
)
135135

136-
target_link_libraries(freertos-kernel
137-
PUBLIC
136+
target_link_libraries(freertos-kernel
137+
PUBLIC
138138
cmsis-core
139139
)
140140

@@ -250,6 +250,14 @@ if("cmsis-freertos" IN_LIST IOTSDK_FETCH_LIST)
250250
)
251251
endif()
252252

253+
if("mbedtls" IN_LIST IOTSDK_FETCH_LIST)
254+
list(APPEND CONFIG_CHIP_EXTERNAL_TARGETS
255+
mbedtls
256+
mbedtls-config
257+
mbedtls-threading-cmsis-rtos
258+
)
259+
endif()
260+
253261
if("lwip" IN_LIST IOTSDK_FETCH_LIST)
254262
list(APPEND CONFIG_CHIP_EXTERNAL_TARGETS
255263
lwipcore
@@ -274,15 +282,6 @@ if("trusted-firmware-m" IN_LIST IOTSDK_FETCH_LIST)
274282
)
275283
endif()
276284

277-
# Note: Mbed TLS must appear after TF-M otherwise psa from mbed TLS is used
278-
if("mbedtls" IN_LIST IOTSDK_FETCH_LIST)
279-
list(APPEND CONFIG_CHIP_EXTERNAL_TARGETS
280-
mbedtls
281-
mbedtls-config
282-
mbedtls-threading-cmsis-rtos
283-
)
284-
endif()
285-
286285
# Additional Open IoT SDK port components
287286

288287
# Add Open IoT SDK storage source

config/openiotsdk/lwip/user_lwipopts.h

-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@
4949
*/
5050
#define LWIP_RAW (1)
5151

52-
/**
53-
* Disable DHCP as the IP6 link local address can be used.
54-
*/
55-
#define LWIP_DHCP 0
56-
5752
#ifdef LWIP_DEBUG
5853

5954
// Debug Options

config/openiotsdk/mbedtls/mbedtls_config.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@
26922692
* or MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG.
26932693
*
26942694
*/
2695-
//#define MBEDTLS_PSA_CRYPTO_C
2695+
#define MBEDTLS_PSA_CRYPTO_C
26962696

26972697
/**
26982698
* \def MBEDTLS_PSA_CRYPTO_SE_C
@@ -3313,8 +3313,8 @@
33133313
//#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */
33143314

33153315
/* ECP options */
3316-
#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */
3317-
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */
3316+
//#define MBEDTLS_ECP_WINDOW_SIZE 4 /**< Maximum window size used */
3317+
//#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */
33183318

33193319
/* Entropy options */
33203320
//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */

config/openiotsdk/mbedtls/mbedtls_config_psa.h

-6
This file was deleted.

docs/guides/openiotsdk_examples.md

+6-46
Original file line numberDiff line numberDiff line change
@@ -374,42 +374,6 @@ For `TF-M` protected storage use:
374374
[Open IoT SDK build script](../../scripts/examples/openiotsdk_example.sh)
375375
provides the `-K,--kvsfile` option to use the persistence options listed above.
376376
377-
### Crypto backend
378-
379-
Open IoT SDK port supports two crypto backend implementations:
380-
381-
- [Mbed TLS](../guides/openiotsdk_platform_overview.md#mbed-tls) - it's the
382-
default option
383-
- [PSA crypto service](https://tf-m-user-guide.trustedfirmware.org/integration_guide/services/tfm_crypto_integration_guide.html)
384-
from the
385-
[TrustedFirmware-M (TF-M)](../guides/openiotsdk_platform_overview.md#trusted-firmware-m)
386-
component
387-
388-
The CMake variable `CONFIG_CHIP_CRYPTO` controls how cryptographic operations
389-
are implemented in Matter. It accepts two values:
390-
391-
- `mbedtls`: use Mbed TLS for crypto operations.
392-
- `psa`: use
393-
[PSA Cryptography API](https://armmbed.github.io/mbed-crypto/html/) for
394-
crypto operations.
395-
396-
This variable can be set in the main application `CMakeLists.txt`:
397-
398-
```
399-
set(CONFIG_CHIP_CRYPTO <mbedtls | psa>)
400-
```
401-
402-
The variable can also be defined with CMake CLI:
403-
404-
```
405-
cmake -G <...> -DCONFIG_CHIP_CRYPTO=<mbedtls | psa> <...>
406-
```
407-
408-
> 💡 **Notes**:
409-
>
410-
> The `TF-M PSA crypto` option requires enabling [TF-M](#trusted-firmware-m)
411-
> support.
412-
413377
## Building
414378
415379
You can build examples using the dedicated VSCode task or by calling directly
@@ -422,7 +386,6 @@ the build script from the command line.
422386
- Select `Build Open IoT SDK example`
423387
- Decide on debug mode support
424388
- Decide on LwIP debug logs support
425-
- Choose crypto algorithm
426389
- Choose example name
427390
428391
This will call the script with the selected parameters.
@@ -605,12 +568,12 @@ telnet> close
605568
606569
## Specific examples
607570
608-
### Build lock-app example with PSA crypto backend support and run it in the network namespace
571+
### Build lock-app example and run it in the network namespace
609572
610573
**Using CLI**
611574
612575
```
613-
${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -b psa lock-app
576+
${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh lock-app
614577

615578
export TEST_NETWORK_NAME=OIStest
616579

@@ -630,7 +593,6 @@ Build example:
630593
- Select `Build Open IoT SDK example`
631594
- Deny debug mode support `false`
632595
- Deny LwIP debug logs support `false`
633-
- Choose crypto algorithm `psa`
634596
- Choose example name `lock-app`
635597
636598
Setup network environment:
@@ -652,12 +614,12 @@ Run example:
652614
653615
The example output should be seen in the terminal window.
654616
655-
### Build lock-app example with mbedtls crypto backend support and execute its test in the network namespace
617+
### Build lock-app example and execute its test in the network namespace
656618
657619
**Using CLI**
658620
659621
```
660-
${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh -b mbedtls lock-app
622+
${MATTER_ROOT}/scripts/examples/openiotsdk_example.sh lock-app
661623

662624
export TEST_NETWORK_NAME=OIStest
663625

@@ -677,7 +639,6 @@ Build example:
677639
- Select `Build Open IoT SDK example`
678640
- Deny debug mode support `false`
679641
- Deny LwIP debug logs support `false`
680-
- Choose crypto algorithm `mbedtls`
681642
- Choose example name `lock-app`
682643
683644
Setup network environment:
@@ -697,7 +658,7 @@ Test example:
697658
- Enter network interface `OIStesttap`
698659
- Choose example name `lock-app`
699660
700-
### Build lock-app example with mbedtls crypto backend support in debug mode and debug it in the network namespace using the VSCode task
661+
### Build lock-app example in debug mode and debug it in the network namespace using the VSCode task
701662
702663
Build example:
703664
@@ -706,7 +667,6 @@ Build example:
706667
- Select `Build Open IoT SDK example`
707668
- Confirm debug mode support `true`
708669
- Deny LwIP debug logs support `false`
709-
- Choose crypto algorithm `mbedtls`
710670
- Choose example name `lock-app`
711671
712672
Setup network environment:
@@ -797,7 +757,7 @@ Example:
797757
id: build_new_example
798758
timeout-minutes: 10
799759
run: |
800-
scripts/examples/openiotsdk_example.sh -b ${{ matrix.cryptoBackend }} new-example
760+
scripts/examples/openiotsdk_example.sh new-example
801761
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
802762
openiotsdk release new-example \
803763
examples/new-example/openiotsdk/build/chip-openiotsdk-new-example-example.elf \

examples/platform/openiotsdk/app/openiotsdk_platform.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
#include "iotsdk/ip_network_api.h"
2828
#include "mbedtls/platform.h"
2929

30-
#ifdef CONFIG_CHIP_CRYPTO_PSA
31-
#include "psa/crypto.h"
32-
#endif
33-
3430
#include <DeviceInfoProviderImpl.h>
3531
#include <lib/support/CHIPMem.h>
3632
#include <lib/support/logging/CHIPLogging.h>
@@ -183,15 +179,6 @@ int openiotsdk_platform_init(void)
183179
return EXIT_FAILURE;
184180
}
185181

186-
#ifdef CONFIG_CHIP_CRYPTO_PSA
187-
ret = psa_crypto_init();
188-
if (ret)
189-
{
190-
ChipLogError(NotSpecified, "PSA crypto initialization failed: %d", ret);
191-
return EXIT_FAILURE;
192-
}
193-
#endif
194-
195182
#ifdef TFM_SUPPORT
196183
ret = get_psa_images_details();
197184
if (ret != 0)

0 commit comments

Comments
 (0)