Skip to content

Commit e211d92

Browse files
committed
[nrf noup] boot: bootutil: Allow configuring number of KMU keys
Adds a new Kconfig CONFIG_BOOT_SIGNATURE_KMU_SLOTS which allows specifying how many KMU key IDs are supported, the default is set to 1 instead of 3 which was set before NCSDK-30743 Signed-off-by: Jamie McCrae <[email protected]> Signed-off-by: Dominik Ermel <[email protected]> (cherry picked from commit 8a366a3) (cherry picked from commit 36c1fdf)
1 parent e28f5e9 commit e211d92

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

boot/bootutil/src/ed25519_psa.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <psa/crypto.h>
1414
#include <psa/crypto_types.h>
15+
#include <zephyr/sys/util.h>
1516
#if defined(CONFIG_BOOT_SIGNATURE_USING_KMU)
1617
#include <cracen_psa_kmu.h>
1718
#endif
@@ -30,7 +31,9 @@ static psa_key_id_t kmu_key_ids[3] = {
3031
MAKE_PSA_KMU_KEY_ID(228),
3132
MAKE_PSA_KMU_KEY_ID(230)
3233
};
33-
#define KMU_KEY_COUNT (sizeof(kmu_key_ids)/sizeof(kmu_key_ids[0]))
34+
35+
BUILD_ASSERT(CONFIG_BOOT_SIGNATURE_KMU_SLOTS <= ARRAY_SIZE(kmu_key_ids),
36+
"Invalid number of KMU slots, up to 3 are supported on nRF54L15");
3437
#endif
3538

3639
#if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU)
@@ -105,7 +108,7 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
105108

106109
status = PSA_ERROR_BAD_STATE;
107110

108-
for (int i = 0; i < KMU_KEY_COUNT; ++i) {
111+
for (int i = 0; i < CONFIG_BOOT_SIGNATURE_KMU_SLOTS; ++i) {
109112
psa_key_id_t kid = kmu_key_ids[i];
110113

111114
status = psa_verify_message(kid, PSA_ALG_PURE_EDDSA, message,

boot/zephyr/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,18 @@ config BOOT_SIGNATURE_USING_KMU
346346
MCUboot will use keys provisioned to the device key management unit for signature
347347
verification instead of compiling in key data from a file.
348348

349+
if BOOT_SIGNATURE_USING_KMU
350+
351+
config BOOT_SIGNATURE_KMU_SLOTS
352+
int "KMU key slots"
353+
range 1 3
354+
default 1
355+
help
356+
Selects the number of KMU key slots (also known as generations) to use when verifying
357+
an image.
358+
359+
endif
360+
349361
if !BOOT_SIGNATURE_USING_KMU
350362

351363
config BOOT_SIGNATURE_KEY_FILE

0 commit comments

Comments
 (0)