pk: fix library code for using the new opaque key solution
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
e00954d0ed
commit
048cd44f77
5 changed files with 14 additions and 20 deletions
|
@ -188,14 +188,13 @@ int mbedtls_pk_write_pubkey(unsigned char **p, unsigned char *start,
|
|||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if (mbedtls_pk_get_type(key) == MBEDTLS_PK_OPAQUE) {
|
||||
size_t buffer_size;
|
||||
mbedtls_svc_key_id_t *key_id = (mbedtls_svc_key_id_t *) key->pk_ctx;
|
||||
|
||||
if (*p < start) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
buffer_size = (size_t) (*p - start);
|
||||
if (psa_export_public_key(*key_id, start, buffer_size, &len)
|
||||
if (psa_export_public_key(key->opaque_id, start, buffer_size, &len)
|
||||
!= PSA_SUCCESS) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
} else {
|
||||
|
@ -254,9 +253,11 @@ int mbedtls_pk_write_pubkey_der(const mbedtls_pk_context *key, unsigned char *bu
|
|||
if (pk_type == MBEDTLS_PK_OPAQUE) {
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_key_type_t key_type;
|
||||
mbedtls_svc_key_id_t key_id;
|
||||
key_id = *((mbedtls_svc_key_id_t *) key->pk_ctx);
|
||||
if (PSA_SUCCESS != psa_get_key_attributes(key_id, &attributes)) {
|
||||
psa_ecc_family_t curve;
|
||||
size_t bits;
|
||||
|
||||
if (PSA_SUCCESS != psa_get_key_attributes(key->opaque_id,
|
||||
&attributes)) {
|
||||
return MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED;
|
||||
}
|
||||
key_type = psa_get_key_type(&attributes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue