From 1a87f249558e75928a1e8fa21697a361d5ba5770 Mon Sep 17 00:00:00 2001 From: Netanel Gonen Date: Mon, 18 Feb 2019 13:56:50 +0200 Subject: [PATCH] support in more types then just RSA_KEYPAIR if the type is not supported the psa_crypto will return the error code for unsupported --- .../crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c index a0cc6b9b39..1e124b0059 100644 --- a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c +++ b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c @@ -1125,18 +1125,13 @@ psa_status_t psa_generate_key(psa_key_handle_t key_handle, in_vec[1].base = &bits; in_vec[1].len = sizeof(size_t); - /* currently the parameter argument is used only for RSA keypair - and ignored in other cases. support for other algorithms - may be added later*/ - if (PSA_KEY_TYPE_RSA_KEYPAIR == type) { - in_vec[2].base = parameters; - /* size of parameter is unsigned integer as defined in header */ - in_vec[2].len = parameters_size; - } else { // currenty ignored for non RSA case - in_vec[2].base = NULL; - in_vec[2].len = 0; + if (((parameters == NULL) && (parameters_size != 0)) || ((parameters != NULL) && (parameters_size == 0))) { + return (PSA_ERROR_INVALID_ARGUMENT); } + in_vec[2].base = parameters; + in_vec[2].len = parameters_size; + handle = psa_connect(PSA_KEY_MNG_ID, MINOR_VER); if (handle <= 0) { return (PSA_ERROR_COMMUNICATION_FAILURE);