Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf noup] boot: bootutil: Allow configuring number of KMU keys #383

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions boot/bootutil/src/ed25519_psa.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
* Copyright (c) 2020-2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
Expand All @@ -12,6 +12,7 @@

#include <psa/crypto.h>
#include <psa/crypto_types.h>
#include <zephyr/sys/util.h>
#if defined(CONFIG_BOOT_SIGNATURE_USING_KMU)
#include <cracen_psa_kmu.h>
#endif
Expand All @@ -30,7 +31,9 @@ static psa_key_id_t kmu_key_ids[3] = {
MAKE_PSA_KMU_KEY_ID(228),
MAKE_PSA_KMU_KEY_ID(230)
};
#define KMU_KEY_COUNT (sizeof(kmu_key_ids)/sizeof(kmu_key_ids[0]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have assertion on limit CONFIG_BOOT_SIGNATURE_KMU_SLOTS value to KMU_KEY_COUNT as max?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The limit is enforced by Kconfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a build assert


BUILD_ASSERT(CONFIG_BOOT_SIGNATURE_KMU_SLOTS <= ARRAY_SIZE(kmu_key_ids),
"Invalid number of KMU slots, up to 3 are supported on nRF54L15");
#endif

#if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU)
Expand Down Expand Up @@ -103,7 +106,7 @@ int ED25519_verify(const uint8_t *message, size_t message_len,

status = PSA_ERROR_BAD_STATE;

for (int i = 0; i < KMU_KEY_COUNT; ++i) {
for (int i = 0; i < CONFIG_BOOT_SIGNATURE_KMU_SLOTS; ++i) {
psa_key_id_t kid = kmu_key_ids[i];

status = psa_verify_message(kid, PSA_ALG_PURE_EDDSA, message,
Expand Down
12 changes: 12 additions & 0 deletions boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,18 @@ config BOOT_SIGNATURE_USING_KMU
MCUboot will use keys provisioned to the device key management unit for signature
verification instead of compiling in key data from a file.

if BOOT_SIGNATURE_USING_KMU

config BOOT_SIGNATURE_KMU_SLOTS
int "KMU key slots"
range 1 3
default 1
help
Selects the number of KMU key slots (also known as generations) to use when verifying
an image.

endif

if !BOOT_SIGNATURE_USING_KMU

config BOOT_SIGNATURE_KEY_FILE
Expand Down
Loading