Skip to content

Commit

Permalink
nrf_security: drivers: cracen: Add Cracen key export for SPAKE2P keys
Browse files Browse the repository at this point in the history
Add support for export of SPAKE2P keys to Cracen.
It currently only supports SECP256R1 keys.

Signed-off-by: Dag Erik Gjørvad <dag.erik.gjorvad@nordicsemi.no>
  • Loading branch information
degjorva committed Feb 10, 2025
1 parent 78004d0 commit 8e48b11
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ psa_status_t cracen_export_public_key(const psa_key_attributes_t *attributes,

psa_key_type_t key_type = psa_get_key_type(attributes);
*data_length = 0;

int test = IS_ENABLED(PSA_NEED_CRACEN_KEY_TYPE_SPAKE2P_KEY_PAIR_EXPORT_SECP_R1_256);
if (data_size == 0) {
return PSA_ERROR_INVALID_ARGUMENT;
}
Expand All @@ -896,6 +896,17 @@ psa_status_t cracen_export_public_key(const psa_key_attributes_t *attributes,
}
}

if (IS_ENABLED(PSA_NEED_CRACEN_KEY_TYPE_SPAKE2P_KEY_PAIR_EXPORT_SECP_R1_256)) {
if (PSA_KEY_TYPE_IS_SPAKE2P_KEY_PAIR(key_type)) {
return export_ecc_public_key_from_keypair(attributes, key_buffer,
key_buffer_size, data, data_size,
data_length);
} else if (PSA_KEY_TYPE_IS_SPAKE2P_PUBLIC_KEY(key_type)) {
return ecc_export_key(attributes, key_buffer, key_buffer_size, data,
data_size, data_length);
}
}

if (key_type == PSA_KEY_TYPE_RSA_KEY_PAIR &&
IS_ENABLED(PSA_NEED_CRACEN_KEY_TYPE_RSA_KEY_PAIR_EXPORT)) {
return export_rsa_public_key_from_keypair(attributes, key_buffer, key_buffer_size,
Expand All @@ -906,7 +917,7 @@ psa_status_t cracen_export_public_key(const psa_key_attributes_t *attributes,
data_size, data_length);
}

return PSA_ERROR_NOT_SUPPORTED;
return test;
}

psa_status_t cracen_import_key(const psa_key_attributes_t *attributes, const uint8_t *data,
Expand Down

0 comments on commit 8e48b11

Please sign in to comment.