From c6f004f0e2ec4ff25d8e3f6101b081118073415c Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Tue, 12 Dec 2023 11:27:36 +0100 Subject: [PATCH] psa_crypto: add internal helper to signal that cipher driver is ready Signed-off-by: Valerio Setti --- library/psa_crypto.c | 8 ++++++++ library/psa_crypto_core.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index d61e118b5..a9ba787d0 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -115,6 +115,14 @@ int psa_can_do_hash(psa_algorithm_t hash_alg) (void) hash_alg; return global_data.drivers_initialized; } + +int psa_can_do_cipher(psa_algorithm_t cipher_alg) +{ + (void) cipher_alg; + return global_data.drivers_initialized; +} + + #if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_IMPORT) || \ defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_PUBLIC_KEY) || \ defined(PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE) diff --git a/library/psa_crypto_core.h b/library/psa_crypto_core.h index 46c57755e..43b1c2377 100644 --- a/library/psa_crypto_core.h +++ b/library/psa_crypto_core.h @@ -33,6 +33,18 @@ */ int psa_can_do_hash(psa_algorithm_t hash_alg); +/** + * Tell if PSA is ready for this cipher. + * + * \note For now, only checks the state of the driver subsystem, + * not the algorithm. Might do more in the future. + * + * \param cipher_alg The cipher algorithm (ignored for now). + * + * \return 1 if the driver subsytem is ready, 0 otherwise. + */ +int psa_can_do_cipher(psa_algorithm_t cipher_alg); + typedef enum { PSA_SLOT_EMPTY = 0, PSA_SLOT_OCCUPIED,