psa: add key_type as input parameter of psa_can_do_cipher()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
diff --git a/library/block_cipher.c b/library/block_cipher.c
index e21541e..04cd7fb 100644
--- a/library/block_cipher.c
+++ b/library/block_cipher.c
@@ -88,8 +88,9 @@
MBEDTLS_BLOCK_CIPHER_ID_NONE;
#if defined(MBEDTLS_BLOCK_CIPHER_SOME_PSA)
- if (psa_can_do_cipher(cipher_id) &&
- (psa_key_type_from_block_cipher_id(ctx->id) != PSA_KEY_TYPE_NONE)) {
+ psa_key_type_t psa_key_type = psa_key_type_from_block_cipher_id(ctx->id);
+ if (psa_key_type != PSA_KEY_TYPE_NONE &&
+ psa_can_do_cipher(psa_key_type, PSA_ALG_ECB_NO_PADDING)) {
ctx->engine = MBEDTLS_BLOCK_CIPHER_ENGINE_PSA;
return 0;
}
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index a9ba787..dd5b446 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -116,8 +116,9 @@
return global_data.drivers_initialized;
}
-int psa_can_do_cipher(psa_algorithm_t cipher_alg)
+int psa_can_do_cipher(psa_key_type_t key_type, psa_algorithm_t cipher_alg)
{
+ (void) key_type;
(void) cipher_alg;
return global_data.drivers_initialized;
}
diff --git a/library/psa_crypto_core.h b/library/psa_crypto_core.h
index 43b1c23..ff01add 100644
--- a/library/psa_crypto_core.h
+++ b/library/psa_crypto_core.h
@@ -43,7 +43,7 @@
*
* \return 1 if the driver subsytem is ready, 0 otherwise.
*/
-int psa_can_do_cipher(psa_algorithm_t cipher_alg);
+int psa_can_do_cipher(psa_key_type_t key_type, psa_algorithm_t cipher_alg);
typedef enum {
PSA_SLOT_EMPTY = 0,