Skip to content

Commit e3f0d99

Browse files
michalek-nocarlescufi
authored andcommitted
[nrf noup] boot: bootutil: encrypted*.c: fix Mbed TLS header inclusion
It's needed for MBEDTLS_OID_EC_ALG_UNRESTRICTED, which is gone from the Mbed TLS repo itself and is now in a different header in TF-PSA-Crypto. Enable MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS in PSA ECDSA and ED25519 builds otherwise we get errors because of missing types in the inclusion of this new header file. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
1 parent 70a9312 commit e3f0d99

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

boot/bootutil/src/encrypted.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#if defined(MCUBOOT_ENCRYPT_EC256) || defined(MCUBOOT_ENCRYPT_X25519)
3939
#include "bootutil/crypto/sha.h"
4040
#include "bootutil/crypto/hmac_sha256.h"
41-
#include "mbedtls/oid.h"
41+
#include "crypto_oid.h"
4242
#include "mbedtls/asn1.h"
4343
#endif
4444
#endif

boot/bootutil/src/encrypted_psa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define MBEDTLS_ASN1_PARSE_C
1515

1616
#include "bootutil/crypto/sha.h"
17-
#include "mbedtls/oid.h"
17+
#include "crypto_oid.h"
1818
#include "mbedtls/asn1.h"
1919

2020
#include "bootutil/image.h"

boot/zephyr/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ config BOOT_ED25519_PSA_DEPENDENCIES
9898
select PSA_WANT_ECC_TWISTED_EDWARDS_255
9999
select PSA_WANT_ECC_MONTGOMERY_255
100100
select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT if !PSA_CORE_LITE
101+
select MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS if BOOT_ENCRYPT_X25519
101102
help
102103
Dependencies for ed25519 signature
103104

@@ -127,6 +128,7 @@ config BOOT_ECDSA_PSA_DEPENDENCIES
127128
select PSA_WANT_ALG_ECDSA
128129
select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT if !PSA_CORE_LITE
129130
select PSA_WANT_ECC_SECP_R1_256
131+
select MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS if BOOT_ENCRYPT_EC256
130132
help
131133
Dependencies for ECDSA signature
132134

@@ -289,6 +291,10 @@ config BOOT_SIGNATURE_TYPE_ECDSA_P256
289291
bool "Elliptic curve digital signatures with curve P-256"
290292
select BOOT_ENCRYPTION_SUPPORT
291293
select BOOT_IMG_HASH_ALG_SHA256_ALLOW
294+
# Enable nrf_security for include paths to oberon-psa-crypto which has mbedtls headers
295+
# (e.g. crypto_oid.h), needed also in cases other than BOOT_ECDSA_PSA.
296+
select NRF_SECURITY
297+
imply MBEDTLS_ASN1_PARSE_C
292298

293299
if BOOT_SIGNATURE_TYPE_ECDSA_P256
294300
choice BOOT_ECDSA_IMPLEMENTATION
@@ -329,6 +335,9 @@ config BOOT_SIGNATURE_TYPE_ED25519
329335
select BOOT_IMG_HASH_ALG_SHA256_ALLOW if !BOOT_SIGNATURE_TYPE_PURE
330336
# The SHA is used only for key hashing, not for images.
331337
select BOOT_SIGNATURE_TYPE_PURE_ALLOW
338+
# Enable nrf_security for include paths to oberon-psa-crypto which has mbedtls headers
339+
# (e.g. crypto_oid.h), needed also in cases other than BOOT_ED25519_PSA.
340+
select NRF_SECURITY
332341
help
333342
This is ed25519 signature calculated over SHA512 of SHA256 of application
334343
image.
@@ -358,6 +367,14 @@ config BOOT_ED25519_TINYCRYPT
358367
select BOOT_IMG_HASH_ALG_SHA256_ALLOW
359368
select BOOT_IMG_HASH_ALG_SHA512_ALLOW
360369

370+
if BOOT_ED25519_TINYCRYPT
371+
# config-ed25519.h defines MBEDTLS_MPI_MAX_SIZE as 64, so
372+
# set the correct Kconfig value too to avoid differing definitions
373+
config MBEDTLS_MPI_MAX_SIZE
374+
range 64 2048
375+
default 64
376+
endif
377+
361378
config BOOT_ED25519_MBEDTLS
362379
bool "Use mbedTLS"
363380
select BOOT_USE_MBEDTLS

0 commit comments

Comments
 (0)