Skip to content

Commit ae5d3bb

Browse files
57300rlubos
authored andcommitted
nrf_security: cracen: Fix identity key personalization
This fixes an old regression introduced by this commit: (1) 166d9eb which managed to undo some changes from here: (2) a013ce7 This seems to be unintentional, likely a result of a rebasing mistake, because the PR containing (1) was opened before the PR containing (2), but the second one was merged first. The fix entails changing the `identity_key_index` argument to existing function calls from `ikg_signature.c`. Note: this argument only has an effect when CONFIG_CRACEN_IKG_PERSONALIZED_KEYS=y. The argument value will now be `owner_id`, from the second byte of the opaque key buffer, rather than the first byte, which is `slot_number`. It doesn't make sense to use `slot_number` anymore, because this field is not populated for CRACEN_BUILTIN_IDENTITY_KEY_ID in the first place (see `cracen_set_ikg_key_buffer()`), which means that its value is a constant zero. It used to be an explicit zero prior to this refactor: (3) a8918df Ref: NRFX-8427 Signed-off-by: Grzegorz Swiderski <[email protected]>
1 parent 8317cb3 commit ae5d3bb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/key_management.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,8 @@ static psa_status_t handle_identity_key(const uint8_t *key_buffer, size_t key_bu
671671

672672
if (IS_ENABLED(PSA_NEED_CRACEN_ECDSA_SECP_R1_256)) {
673673
data[0] = CRACEN_ECC_PUBKEY_UNCOMPRESSED;
674-
return silex_statuscodes_to_psa(cracen_ikg_create_pub_key(key_buffer[0], data + 1));
674+
return silex_statuscodes_to_psa(cracen_ikg_create_pub_key(
675+
((const ikg_opaque_key *)key_buffer)->owner_id, data + 1));
675676
}
676677
return PSA_ERROR_NOT_SUPPORTED;
677678
}

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/sign.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ cracen_signature_prepare_ec_pubkey(const uint8_t *key_buffer, size_t key_buffer_
105105
if (key_buffer_size != sizeof(ikg_opaque_key)) {
106106
return PSA_ERROR_INVALID_ARGUMENT;
107107
}
108-
sx_status = cracen_ikg_create_pub_key(key_buffer[0], pubkey_buffer);
108+
sx_status = cracen_ikg_create_pub_key(
109+
((const ikg_opaque_key *)key_buffer)->owner_id, pubkey_buffer);
109110
}
110111
return silex_statuscodes_to_psa(sx_status);
111112
}
@@ -226,11 +227,13 @@ static psa_status_t handle_ikg_sign(bool is_message, const uint8_t *key_buffer,
226227
status = hash_get_algo(alg, &hashalgpointer);
227228
*signature_length = 2 * ecurve->sz;
228229
if (is_message) {
229-
status = cracen_ikg_sign_message(key_buffer[0], hashalgpointer, ecurve, input,
230-
input_length, signature);
230+
status = cracen_ikg_sign_message(((const ikg_opaque_key *)key_buffer)->owner_id,
231+
hashalgpointer, ecurve, input, input_length,
232+
signature);
231233
} else {
232-
status = cracen_ikg_sign_digest(key_buffer[0], hashalgpointer, ecurve, input,
233-
input_length, signature);
234+
status = cracen_ikg_sign_digest(((const ikg_opaque_key *)key_buffer)->owner_id,
235+
hashalgpointer, ecurve, input, input_length,
236+
signature);
234237
}
235238
return silex_statuscodes_to_psa(status);
236239
}

0 commit comments

Comments
 (0)