Skip to content
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

nrf_security: Added support for PSA Crypto service #14923

Closed
wants to merge 1 commit 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
576 changes: 576 additions & 0 deletions include/sdfw/sdfw_services/crypto_service.h

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions subsys/nrf_security/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ set(ARM_MBEDTLS_PATH ${ZEPHYR_MBEDTLS_MODULE_DIR})
set(CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER False)

if(CONFIG_BUILD_WITH_TFM)
# TF-M is enabled and we are not inside the TF-M build system.
# Thus, do not build regular `mbedcrypto` library, instead export
# needed settings to the TF-M build system using TFM_CMAKE_OPTIONS.

# NS-build: PSA APIs are already compiled in TF-M image
set(COMPILE_PSA_APIS False)

# Execute Cmake logic to forward configurations to TF-M build
include(${NRF_SECURITY_ROOT}/cmake/config_to_tf-m.cmake)
endif()

if(CONFIG_BUILD_WITH_TFM OR CONFIG_PSA_SSF_CRYPTO_CLIENT)
# We enable either TF-M or the SSF client PSA crypto interface but we are
# not in the secure image build

# NS-build: PSA APIs are already compiled in the secure image and is
# exposed as a service
set(COMPILE_PSA_APIS False)

# Add replacement platform.c for NS build
list(APPEND src_zephyr
Expand All @@ -49,7 +51,7 @@ if(CONFIG_BUILD_WITH_TFM)

get_cmake_property(all_vars VARIABLES)

# 1. Non-secure should not build anything PSA related
# 1. Non-secure should not build the PSA core or drivers
set(CONFIG_MBEDTLS_PSA_CRYPTO_C False)

# 2. Enable OBERON_BACKEND, disable CC3XX_BACKEND
Expand Down
4 changes: 3 additions & 1 deletion subsys/nrf_security/Kconfig.psa
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG

rsource "src/core/Kconfig"

rsource "src/ssf_secdom/Kconfig"

comment "PSA Driver Support"

config MBEDTLS_PSA_CRYPTO_DRIVERS
Expand Down Expand Up @@ -58,7 +60,7 @@ config MBEDTLS_PSA_CRYPTO_STORAGE_C

config MBEDTLS_USE_PSA_CRYPTO
bool "PSA APIs for X.509 and TLS library"
default y
default y if !MBEDTLS_LEGACY_CRYPTO_C
help
Corresponds to MBEDTLS_USE_PSA_CRYPTO setting in mbed TLS config file.

Expand Down
2 changes: 2 additions & 0 deletions subsys/nrf_security/cmake/legacy_crypto_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ kconfig_check_and_set_base(MBEDTLS_MEMORY_DEBUG)
kconfig_check_and_set_base(MBEDTLS_PSA_CRYPTO_SPM)

kconfig_check_and_set_base(MBEDTLS_PSA_CRYPTO_C)
kconfig_check_and_set_base(MBEDTLS_USE_PSA_CRYPTO)
kconfig_check_and_set_base(MBEDTLS_PSA_CRYPTO_CLIENT)

kconfig_check_and_set_base_to_one(MBEDTLS_PLATFORM_EXIT_ALT)
kconfig_check_and_set_base_to_one(MBEDTLS_PLATFORM_FPRINTF_ALT)
Expand Down
4 changes: 4 additions & 0 deletions subsys/nrf_security/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ add_library(${mbedcrypto_target}
${src_crypto}
)

if(CONFIG_PSA_SSF_CRYPTO_CLIENT)
add_subdirectory(ssf_secdom)
endif()

nrf_security_add_zephyr_options(${mbedcrypto_target})

# Base mbed TLS files (not in drivers or builtin's)
Expand Down
9 changes: 7 additions & 2 deletions subsys/nrf_security/src/core/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@

choice PSA_CORE
prompt "PSA Core implementation"
default PSA_CORE_OBERON

config PSA_CORE_DISABLED
bool
prompt "PSA core-less for SSF crypto client support"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this user configurable?
wouldn't it be better to set default y with depends on PSA_SSF_CRYPTO_CLIENT

depends on SSF_CLIENT && SSF_PSA_CRYPTO_SERVICE_ENABLED

config PSA_CORE_OBERON
bool "PSA Core implementation - Oberon"
bool
prompt "PSA Core implementation - Oberon"
select PSA_WANT_AES_KEY_SIZE_128
select PSA_WANT_AES_KEY_SIZE_192
select PSA_WANT_AES_KEY_SIZE_256
Expand Down
35 changes: 35 additions & 0 deletions subsys/nrf_security/src/ssf_secdom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# NOTE that this is added as a duplication to ensure that SSF client gets
# access to the relevant include folders, without PSA core or PSA drivers
# being built.


# Add generated path first in list (order dependent)
target_include_directories(mbedcrypto_common
INTERFACE
${generated_include_path}
)

# Add regular includes
# Note, the order of include matters
target_include_directories(mbedcrypto_common
INTERFACE
# Nordic PSA headers
${NRF_SECURITY_ROOT}/include
# Oberon PSA headers
${OBERON_PSA_PATH}/include
${OBERON_PSA_PATH}/library
# Mbed TLS (mbedcrypto) PSA headers
${ARM_MBEDTLS_PATH}/include
${ARM_MBEDTLS_PATH}/library
)

target_sources(${mbedcrypto_target}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/ssf_crypto.c
)
11 changes: 11 additions & 0 deletions subsys/nrf_security/src/ssf_secdom/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config PSA_SSF_CRYPTO_CLIENT
bool
prompt "PSA crypto provided through SSF"
default y
depends on SSF_CLIENT && SSF_PSA_CRYPTO_SERVICE_ENABLED
Loading
Loading