Skip to content

Commit 8a2c213

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> Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no> (cherry picked from commit 1a2e7b520d51de49c927021639e3b9788fad2913) (cherry picked from commit 8a366a3)
1 parent 85645c7 commit 8a2c213

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
@@ -345,6 +345,18 @@ config BOOT_SIGNATURE_USING_KMU
345345
MCUboot will use keys provisioned to the device key management unit for signature
346346
verification instead of compiling in key data from a file.
347347

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

350362
config BOOT_SIGNATURE_KEY_FILE

0 commit comments

Comments
 (0)