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

mbedtls: some enhancement for PSA crypto core #80136

Merged
merged 3 commits into from
Nov 20, 2024
Merged
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
6 changes: 6 additions & 0 deletions doc/releases/migration-guide-4.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ Modules
Mbed TLS
========

* If a platform has a CSPRNG source available (i.e. :kconfig:option:`CONFIG_CSPRNG_ENABLED`
is set), then the Kconfig option :kconfig:option:`CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG`
is the default choice for random number source instead of
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
is the default choice for random number source instead of
is now the default choice for random number source instead of

:kconfig:option:`CONFIG_MBEDTLS_PSA_CRYPTO_LEGACY_RNG`. This helps in reducing
ROM/RAM footprint of the Mbed TLS library.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ROM/RAM footprint of the Mbed TLS library.
the ROM/RAM footprint of the Mbed TLS library.


Trusted Firmware-M
==================

Expand Down
1 change: 0 additions & 1 deletion drivers/bluetooth/hci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ config BT_SILABS_EFR32
select MBEDTLS
select MBEDTLS_PSA_CRYPTO_C
select MBEDTLS_ENTROPY_C
select MBEDTLS_ENTROPY_POLL_ZEPHYR
help
Use Silicon Labs binary Bluetooth library to connect to the
controller.
Expand Down
1 change: 0 additions & 1 deletion drivers/wifi/esp32/Kconfig.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ config ESP32_WIFI_MBEDTLS_CRYPTO
select MBEDTLS_CIPHER_MODE_CTR_ENABLED
select MBEDTLS_CMAC
select MBEDTLS_ENTROPY_C
select MBEDTLS_ENTROPY_POLL_ZEPHYR
help
Select this option to use MbedTLS crypto APIs which utilize hardware acceleration.

Expand Down
3 changes: 3 additions & 0 deletions modules/mbedtls/Kconfig.tls-generic
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ config MBEDTLS_SOME_CIPHER_ENABLED

config MBEDTLS_CIPHER_AES_ENABLED
bool "AES block cipher"
default y if PSA_WANT_KEY_TYPE_AES && MBEDTLS_PSA_CRYPTO_C

if MBEDTLS_CIPHER_AES_ENABLED

Expand Down Expand Up @@ -397,6 +398,7 @@ config MBEDTLS_ENTROPY_C

config MBEDTLS_ENTROPY_POLL_ZEPHYR
bool "Provide entropy data to Mbed TLS through entropy driver or random generator"
default y
depends on MBEDTLS_ENTROPY_C
help
Provide entropy data to the Mbed TLS's entropy module through either
Expand Down Expand Up @@ -480,6 +482,7 @@ config MBEDTLS_SSL_EXTENDED_MASTER_SECRET
choice MBEDTLS_PSA_CRYPTO_RNG_SOURCE
prompt "Select random source for built-in PSA crypto"
depends on MBEDTLS_PSA_CRYPTO_C
default MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG if CSPRNG_ENABLED
default MBEDTLS_PSA_CRYPTO_LEGACY_RNG

config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Expand Down
1 change: 0 additions & 1 deletion samples/net/wifi/shell/boards/frdm_rw612.conf
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ CONFIG_MBEDTLS_USER_CONFIG_FILE="wpa_supp_els_pkc_mbedtls_config.h"
CONFIG_ENTROPY_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_ENTROPY_C=y
CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR=y
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192

# power management
Expand Down
1 change: 0 additions & 1 deletion samples/net/wifi/shell/boards/rd_rw612_bga.conf
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ CONFIG_MBEDTLS_USER_CONFIG_FILE="wpa_supp_els_pkc_mbedtls_config.h"
CONFIG_ENTROPY_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_ENTROPY_C=y
CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR=y
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192

# power management
Expand Down
1 change: 0 additions & 1 deletion samples/psa/its/overlay-entropy_driver.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_ENTROPY_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
1 change: 0 additions & 1 deletion samples/psa/its/overlay-entropy_not_secure.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR=y
1 change: 0 additions & 1 deletion samples/psa/persistent_key/overlay-entropy_driver.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_ENTROPY_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
1 change: 0 additions & 1 deletion samples/psa/persistent_key/overlay-entropy_not_secure.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR=y
1 change: 0 additions & 1 deletion subsys/bluetooth/mesh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,6 @@ config BT_MESH_USES_MBEDTLS_PSA
select EXPERIMENTAL
select MBEDTLS
select MBEDTLS_ENTROPY_C
select MBEDTLS_ENTROPY_POLL_ZEPHYR
select MBEDTLS_PSA_CRYPTO_C
select MBEDTLS_USE_PSA_CRYPTO
select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT
Expand Down
1 change: 0 additions & 1 deletion tests/bsim/bluetooth/host/gatt/caching/psa_overlay.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_PSA_CRYPTO_ENABLE_ALL=y

CONFIG_ENTROPY_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
1 change: 0 additions & 1 deletion tests/bsim/bluetooth/ll/conn/psa_overlay.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_PSA_CRYPTO_ENABLE_ALL=y

CONFIG_ENTROPY_GENERATOR=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
1 change: 0 additions & 1 deletion tests/crypto/mbedtls_psa/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ CONFIG_ZTEST=y

CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
5 changes: 3 additions & 2 deletions tests/crypto/mbedtls_psa/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# - no TF-M enabled devices because we assume that the TF-M implementation
# of PSA crypto is working fine on the platforms that support TF-M.
# - platform should be testable by the CI.
# - enable CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG in order to reduce as much
# as possible usage of legacy modules in Mbed TLS.
# - pick 1 platform which supports entropy driver and 1 which does not. The
# latter case will allow to test
# CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG.
Expand All @@ -34,8 +32,11 @@ tests:
# Pick a platform which does not have an entropy driver. In this case we
# enable the timer random generator because it's always available on all
# platforms.
# Explicitly select CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG because this is
# not "automatically selected" when there is no CSPRNG available.
integration_platforms:
- qemu_x86
extra_configs:
- CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
- CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y
- CONFIG_TEST_RANDOM_GENERATOR=y
1 change: 0 additions & 1 deletion tests/crypto/secp256r1/mbedtls.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_PSA_P256M_DRIVER_ENABLED=y

Expand Down
1 change: 0 additions & 1 deletion tests/crypto/secp256r1/p256-m_raw.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_PSA_P256M_DRIVER_ENABLED=y
CONFIG_MBEDTLS_PSA_P256M_DRIVER_RAW=y
1 change: 0 additions & 1 deletion tests/modules/uoscore/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=2048
CONFIG_MBEDTLS_ENTROPY_C=y
CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR=y

# PSA Crypto options

Expand Down
1 change: 0 additions & 1 deletion tests/net/socket/tls_configurations/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
# Build the PSA Crypto core so that the TLS stack uses the PSA crypto API.
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
CONFIG_ENTROPY_GENERATOR=y

# Disable some Kconfigs that are implied by CONFIG_NET_SOCKETS_SOCKOPT_TLS.
Expand Down
6 changes: 6 additions & 0 deletions tests/subsys/jwt/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ tests:
libraries.encoding.jwt.ecdsa.psa:
extra_configs:
- CONFIG_JWT_SIGN_ECDSA_PSA=y
# Explicitly select CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG because this
# is not automatically selected on platforms that do not have a CSPRNG
# source.
- CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
- CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y
libraries.encoding.jwt.rsa.legacy:
Expand All @@ -21,5 +24,8 @@ tests:
libraries.encoding.jwt.rsa.psa:
extra_configs:
- CONFIG_JWT_SIGN_RSA_PSA=y
# Explicitly select CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG because this
# is not automatically selected on platforms that do not have a CSPRNG
# source.
- CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG=y
- CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG=y
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CONFIG_MAIN_STACK_SIZE=2048
CONFIG_MBEDTLS=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y

CONFIG_SECURE_STORAGE=y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
CONFIG_MBEDTLS=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y

# SETTINGS_MAX_VAL_LEN (256) - flags (1) - CONFIG_SECURE_STORAGE_ITS_TRANSFORM_OUTPUT_OVERHEAD (28)
Expand Down
1 change: 1 addition & 0 deletions tests/subsys/storage/flash_map/overlay-psa.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONFIG_FLASH_AREA_CHECK_INTEGRITY_PSA=y
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_TEST_RANDOM_GENERATOR=y
Loading