From e9efbc2aa543e00fabe4904550fec8e69cf6e166 Mon Sep 17 00:00:00 2001 From: Pengyu Lv Date: Fri, 8 Dec 2023 16:59:08 +0800 Subject: [PATCH] Error out when get domain_parameters is not supported 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 #6494. Signed-off-by: Pengyu Lv --- library/psa_crypto.c | 6 ++++++ library/psa_crypto_client.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 114994019..894167abd 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1400,6 +1400,12 @@ psa_status_t psa_get_key_attributes(mbedtls_svc_key_id_t key, mbedtls_free(rsa); } break; +#else + case PSA_KEY_TYPE_RSA_KEY_PAIR: + case PSA_KEY_TYPE_RSA_PUBLIC_KEY: + attributes->domain_parameters = NULL; + attributes->domain_parameters_size = SIZE_MAX; + break; #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) */ diff --git a/library/psa_crypto_client.c b/library/psa_crypto_client.c index 564463fed..472d3d31a 100644 --- a/library/psa_crypto_client.c +++ b/library/psa_crypto_client.c @@ -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; }