Add export_public_key entry point to p256-m driver
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
diff --git a/3rdparty/p256-m/p256-m_driver_entrypoints.c b/3rdparty/p256-m/p256-m_driver_entrypoints.c
index e48b4e8..6131dae 100644
--- a/3rdparty/p256-m/p256-m_driver_entrypoints.c
+++ b/3rdparty/p256-m/p256-m_driver_entrypoints.c
@@ -104,6 +104,40 @@
return PSA_SUCCESS;
}
+psa_status_t p256_transparent_export_public_key(const psa_key_attributes_t *attributes,
+ const uint8_t *key_buffer,
+ size_t key_buffer_size,
+ uint8_t *data,
+ size_t data_size,
+ size_t *data_length)
+{
+ /* Is this the right curve? */
+ size_t bits = psa_get_key_bits(attributes);
+ psa_key_type_t type = psa_get_key_type(attributes);
+ if (bits != 256 || type != PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1)) {
+ return PSA_ERROR_NOT_SUPPORTED;
+ }
+
+ /* Validate input and output sizes */
+ if (key_buffer_size != 32) {
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+ if (data_size < 65) {
+ return PSA_ERROR_BUFFER_TOO_SMALL;
+ }
+
+ /* Output public key in the PSA export format */
+ data[0] = 0x04;
+ int ret = p256_public_from_private(data + 1, key_buffer);
+ if (ret != P256_SUCCESS) {
+ /* The only possible error is the private key was invalid */
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+ *data_length = 65;
+
+ return PSA_SUCCESS;
+}
+
psa_status_t p256_transparent_generate_key(
const psa_key_attributes_t *attributes,
uint8_t *key_buffer,