Skip to content

Commit 9645782

Browse files
nordicjmde-nordic
authored andcommitted
[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 <jamie.mccrae@nordicsemi.no> (cherry picked from commit 12e5ee1) (cherry picked from commit 2ca0efe)
1 parent a86b4e0 commit 9645782

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

boot/bootutil/src/ed25519_psa.c

+5-2
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)
@@ -103,7 +106,7 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
103106

104107
status = PSA_ERROR_BAD_STATE;
105108

106-
for (int i = 0; i < KMU_KEY_COUNT; ++i) {
109+
for (int i = 0; i < CONFIG_BOOT_SIGNATURE_KMU_SLOTS; ++i) {
107110
psa_key_id_t kid = kmu_key_ids[i];
108111

109112
status = psa_verify_message(kid, PSA_ALG_PURE_EDDSA, message,

boot/zephyr/Kconfig

+12
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ config BOOT_SIGNATURE_USING_KMU
338338
MCUboot will use keys provisioned to the device key management unit for signature
339339
verification instead of compiling in key data from a file.
340340

341+
if BOOT_SIGNATURE_USING_KMU
342+
343+
config BOOT_SIGNATURE_KMU_SLOTS
344+
int "KMU key slots"
345+
range 1 3
346+
default 1
347+
help
348+
Selects the number of KMU key slots (also known as generations) to use when verifying
349+
an image.
350+
351+
endif
352+
341353
if !BOOT_SIGNATURE_USING_KMU
342354

343355
config BOOT_SIGNATURE_KEY_FILE

0 commit comments

Comments
 (0)