Skip to content
Open
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
28 changes: 28 additions & 0 deletions boot/bootutil/src/ed25519_psa.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,32 @@ int exec_revoke(void)
return ret;
}
#endif /* CONFIG_BOOT_KMU_KEYS_REVOCATION */

void nrf_crypto_keys_housekeeping(void)
{
psa_status_t status;

/* We will continue through all keys, even if we have error while
* processing any of it. Only doing BOOT_LOG_DBG, as we do not
* really want to inform on failures to lock.
*/
for (int i = 0; i < CONFIG_BOOT_SIGNATURE_KMU_SLOTS; ++i) {
psa_key_attributes_t attr;

status = psa_get_key_attributes(kmu_key_ids[i], &attr);
BOOT_LOG_DBG("KMU key 0x%x(%d) attr query status == %d",
kmu_key_ids[i], i, status);

if (status == PSA_SUCCESS) {
status = cracen_kmu_block(&attr);
BOOT_LOG_DBG("KMU key lock status == %d", status);
}

status = psa_purge_key(kmu_key_ids[i]);
BOOT_LOG_DBG("KMU key 0x%x(%d) purge status == %d",
kmu_key_ids[i], i, status);

}
}

#endif
11 changes: 11 additions & 0 deletions boot/zephyr/include/nrf_cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@ void nrf_cleanup_peripheral(void);
*/
void nrf_cleanup_ns_ram(void);

/**
* Crypto key storage housekeeping. Intended to clean up key objects from
* crypto backend and apply key policies that should take effect after
* MCUboot no longer needs access to keys.
*/
#if defined(CONFIG_BOOT_SIGNATURE_USING_KMU)
extern void nrf_crypto_keys_housekeeping(void);
#else
#define nrf_crypto_keys_housekeeping() do {} while (0)
#endif

#endif
7 changes: 7 additions & 0 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,13 @@ int main(void)

mcuboot_status_change(MCUBOOT_STATUS_BOOTABLE_IMAGE_FOUND);

/* From this point MCUboot does not need access to crypto keys.
* Clean up backend key objects and apply key access policies that
* will take effect from now through entire boot session and application
* run.
*/
nrf_crypto_keys_housekeeping();

#if USE_PARTITION_MANAGER && CONFIG_FPROTECT

#ifdef PM_S1_ADDRESS
Expand Down
Loading