File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -165,4 +165,32 @@ int exec_revoke(void)
165
165
return ret ;
166
166
}
167
167
#endif /* CONFIG_BOOT_KMU_KEYS_REVOCATION */
168
+
169
+ void nrf_crypto_keys_housekeeping (void )
170
+ {
171
+ psa_status_t status ;
172
+
173
+ /* We will continue through all keys, even if we have error while
174
+ * processing any of it. Only doing BOOT_LOG_DBG, as we do not
175
+ * really want to inform on failures to lock.
176
+ */
177
+ for (int i = 0 ; i < CONFIG_BOOT_SIGNATURE_KMU_SLOTS ; ++ i ) {
178
+ psa_key_attributes_t attr ;
179
+
180
+ status = psa_get_key_attributes (kmu_key_ids [i ], & attr );
181
+ BOOT_LOG_DBG ("KMU key 0x%x(%d) attr query status == %d" ,
182
+ kmu_key_ids [i ], i , status );
183
+
184
+ if (status == PSA_SUCCESS ) {
185
+ status = cracen_kmu_block (& attr );
186
+ BOOT_LOG_DBG ("KMU key lock status == %d" , status );
187
+ }
188
+
189
+ status = psa_purge_key (kmu_key_ids [i ]);
190
+ BOOT_LOG_DBG ("KMU key 0x%x(%d) purge status == %d" ,
191
+ kmu_key_ids [i ], i , status );
192
+
193
+ }
194
+ }
195
+
168
196
#endif
Original file line number Diff line number Diff line change @@ -21,4 +21,15 @@ void nrf_cleanup_peripheral(void);
21
21
*/
22
22
void nrf_cleanup_ns_ram (void );
23
23
24
+ /**
25
+ * Crypto key storage housekeeping. Intended to clean up key objects from
26
+ * crypto backend and apply key policies that should take effect after
27
+ * MCUboot no longer needs access to keys.
28
+ */
29
+ #if defined(CONFIG_BOOT_SIGNATURE_USING_KMU )
30
+ extern void nrf_crypto_keys_housekeeping (void );
31
+ #else
32
+ #define nrf_crypto_keys_housekeeping () do {} while (0)
33
+ #endif
34
+
24
35
#endif
Original file line number Diff line number Diff line change @@ -651,6 +651,13 @@ int main(void)
651
651
652
652
mcuboot_status_change (MCUBOOT_STATUS_BOOTABLE_IMAGE_FOUND );
653
653
654
+ /* From this point MCUboot does not need access to crypto keys.
655
+ * Clean up backend key objects and apply key access policies that
656
+ * will take effect from now through entire boot session and application
657
+ * run.
658
+ */
659
+ nrf_crypto_keys_housekeeping ();
660
+
654
661
#if USE_PARTITION_MANAGER && CONFIG_FPROTECT
655
662
656
663
#ifdef PM_S1_ADDRESS
You can’t perform that action at this time.
0 commit comments