Skip to content

Commit

Permalink
nrf_security: cracen_kmu: small KMU DEST and METADATA improvement
Browse files Browse the repository at this point in the history
Define the KMU DEST field as uint32_t, and use UINT32_MAX everywhere
for to refer to the metadata of secondary slots.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
  • Loading branch information
tomi-font committed Oct 8, 2024
1 parent 933a189 commit 4639a26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct kmu_src_t {
/** 32-bit destination address. Cannot point to SICR and must be on a
* 128-bit boundary.
*/
uint8_t *dest;
uint32_t dest;
/** 32 bits of any clear-text metadata that belongs with the key slot.
*/
uint32_t metadata;
Expand Down
9 changes: 5 additions & 4 deletions subsys/nrf_security/src/drivers/cracen/cracenpsa/src/kmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ int cracen_kmu_clean_key(const uint8_t *user_data)
*/
bool is_secondary_slot(kmu_metadata *metadata)
{
uint32_t value = 0xffffffff;
uint32_t value = UINT32_MAX;

return memcmp(&value, metadata, sizeof(value)) == 0;
}
Expand Down Expand Up @@ -759,10 +759,11 @@ psa_status_t cracen_kmu_provision(const psa_key_attributes_t *key_attr, int slot
struct kmu_src_t kmu_desc = {};

for (size_t i = 0; i < num_slots; i++) {
kmu_desc.dest = push_address + (CRACEN_KMU_SLOT_KEY_SIZE * i);
kmu_desc.metadata = UINT32_MAX;
kmu_desc.dest = (uint32_t)push_address + (CRACEN_KMU_SLOT_KEY_SIZE * i);
if (i == 0) {
memcpy(&kmu_desc.metadata, &metadata, sizeof(metadata));
memcpy(&kmu_desc.metadata, &metadata, sizeof(kmu_desc.metadata));
} else {
kmu_desc.metadata = UINT32_MAX;
}
kmu_desc.rpolicy = metadata.rpolicy;
memcpy(kmu_desc.value, key_buffer + CRACEN_KMU_SLOT_KEY_SIZE * i,
Expand Down

0 comments on commit 4639a26

Please sign in to comment.