Skip to content

Commit

Permalink
Error out when get domain_parameters is not supported
Browse files Browse the repository at this point in the history
From time being, domain_parameters could not be extracted
from driver. We need to return error to indicate this
situation. This is temporary and would be fixed after Mbed-TLS#6494.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
  • Loading branch information
lpy4105 committed Dec 8, 2023
1 parent abeca02 commit d402c19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/psa_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,11 +1373,11 @@ psa_status_t psa_get_key_attributes(mbedtls_svc_key_id_t key,
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */

switch (slot->attr.type) {
case PSA_KEY_TYPE_RSA_KEY_PAIR:
case PSA_KEY_TYPE_RSA_PUBLIC_KEY:
#if (defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_IMPORT) && \
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_EXPORT)) || \
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY)
case PSA_KEY_TYPE_RSA_KEY_PAIR:
case PSA_KEY_TYPE_RSA_PUBLIC_KEY:
/* TODO: reporting the public exponent for opaque keys
* is not yet implemented.
* https://github.com/ARMmbed/mbed-crypto/issues/216
Expand All @@ -1400,6 +1400,9 @@ psa_status_t psa_get_key_attributes(mbedtls_svc_key_id_t key,
mbedtls_free(rsa);
}
break;
#else
attributes->domain_parameters = NULL;
attributes->domain_parameters_size = SIZE_MAX;
#endif /* (defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_IMPORT) && \
* defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR_EXPORT)) ||
* defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY) */
Expand Down
5 changes: 5 additions & 0 deletions library/psa_crypto_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ psa_status_t psa_get_key_domain_parameters(
const psa_key_attributes_t *attributes,
uint8_t *data, size_t data_size, size_t *data_length)
{
if (attributes->domain_parameters == NULL &&
attributes->domain_parameters_size == SIZE_MAX) {
return PSA_ERROR_NOT_SUPPORTED;
}

if (attributes->domain_parameters_size > data_size) {
return PSA_ERROR_BUFFER_TOO_SMALL;
}
Expand Down

0 comments on commit d402c19

Please sign in to comment.