Skip to content

Commit 0692684

Browse files
SebastianBoerlubos
authored andcommitted
nrf_security: Don't enable RSA code by default
Follow good practice by not enabling features by default. The RSA code is particularly large. This patch reduces the code and read-only data from 113kB to 80kB in the sha256 sample using 53_ns. Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 5a04e98 commit 0692684

File tree

7 files changed

+14
-4
lines changed

7 files changed

+14
-4
lines changed

applications/serial_lte_modem/overlay-native_tls.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ CONFIG_MBEDTLS_ECDSA_C=y
4444
CONFIG_PSA_WANT_ALG_ECDSA=y
4545
CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
4646
CONFIG_PSA_WANT_ALG_DETERMINISTIC_ECDSA=y
47+
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR=y # dep for DETERMINISTIC_ECDSA
48+
CONFIG_PSA_WANT_ALG_HMAC=y # dep for DETERMINISTIC_ECDSA
4749
# Enable ECDH
4850
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED=y
4951
CONFIG_MBEDTLS_ECDH_C=y

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,11 @@ Libraries for NFC
859859
nRF Security
860860
------------
861861

862-
|no_changes_yet_note|
862+
* Updated the library to no longer enable RSA keys by default.
863+
This reduces the code size by 30 kB for those that are not using RSA keys.
864+
This will also break the configuration for those using the RSA keys without explicitly enabling an RSA key size.
865+
Enable the required key size to fix the configuration, for example by setting the Kconfig option :kconfig:option:`CONFIG_PSA_WANT_RSA_KEY_SIZE_2048` if 2048-bit RSA keys are required.
866+
863867

864868
Other libraries
865869
---------------

samples/crypto/rsa/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ CONFIG_MBEDTLS_HEAP_SIZE=16384
1616
CONFIG_PSA_WANT_ALG_RSA_PKCS1V15_SIGN=y
1717
CONFIG_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR=y
1818
CONFIG_PSA_WANT_ALG_SHA_256=y
19+
20+
CONFIG_PSA_WANT_RSA_KEY_SIZE_1024=y

subsys/nrf_security/src/core/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ config PSA_CORE_OBERON
1313
select PSA_WANT_AES_KEY_SIZE_128
1414
select PSA_WANT_AES_KEY_SIZE_192
1515
select PSA_WANT_AES_KEY_SIZE_256
16-
select PSA_WANT_RSA_KEY_SIZE_2048
17-
select PSA_WANT_RSA_KEY_SIZE_3072
1816

1917
endchoice

subsys/nrf_security/src/drivers/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ menu "RSA key size configuration"
160160
config PSA_WANT_RSA_KEY_SIZE_1024
161161
prompt "RSA 1024 bits key (weak)"
162162
bool
163-
default y
164163
help
165164
RSA with 1024 bit keys are not recommended for new designs.
166165
Please see https://www.keylength.com/

tests/tfm/tfm_psa_test/prj.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ CONFIG_PSA_WANT_ALG_RSA_PKCS1V15_CRYPT=y
6161
CONFIG_PSA_WANT_ALG_RSA_PKCS1V15_SIGN=y
6262
CONFIG_PSA_WANT_ALG_RSA_PSS=y
6363

64+
# RSA requires at least one key size to be enabled
65+
CONFIG_PSA_WANT_RSA_KEY_SIZE_1024=y
66+
6467
# HASH
6568
CONFIG_PSA_WANT_ALG_SHA_1=n # This is used to test not supported return code
6669
CONFIG_PSA_WANT_ALG_SHA_224=y

tests/tfm/tfm_regression_test/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ CONFIG_PSA_WANT_ALG_RSA_PKCS1V15_CRYPT=y
6363
CONFIG_PSA_WANT_ALG_RSA_PKCS1V15_SIGN=y
6464
CONFIG_PSA_WANT_ALG_RSA_PSS=y
6565

66+
CONFIG_PSA_WANT_RSA_KEY_SIZE_1024=y
67+
6668
# HASH
6769
CONFIG_PSA_WANT_ALG_SHA_1=n # This is used to test not supported return code
6870
CONFIG_PSA_WANT_ALG_SHA_224=y

0 commit comments

Comments
 (0)