From 6eec0fb9b408fc98f91b0f1db66ac5d42a5864a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Fri, 11 Aug 2023 15:15:39 +0200 Subject: [PATCH] nrf_security: Check for existence of RNG driver at build time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check for existence of an RNG driver at build time. This moves input validation from runtime to build time. We take psa_driver_wrapper_get_random functions that just return "not supported" out of the build as this should be detected at build time, not runtime. Signed-off-by: Sebastian Bøe --- subsys/nrf_security/src/psa_crypto_driver_wrappers.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subsys/nrf_security/src/psa_crypto_driver_wrappers.c b/subsys/nrf_security/src/psa_crypto_driver_wrappers.c index 1751b33a800..a620b7be9a8 100644 --- a/subsys/nrf_security/src/psa_crypto_driver_wrappers.c +++ b/subsys/nrf_security/src/psa_crypto_driver_wrappers.c @@ -2432,6 +2432,9 @@ psa_status_t psa_driver_wrapper_init_random(psa_driver_random_context_t *context return PSA_SUCCESS; } +#if defined(PSA_CRYPTO_DRIVER_ALG_PRNG_TEST) || \ + defined(PSA_CRYPTO_DRIVER_ALG_PRNG_CC3XX_PLATFORM) || \ + defined(PSA_CRYPTO_DRIVER_ALG_PRNG_OBERON) psa_status_t psa_driver_wrapper_get_random(psa_driver_random_context_t *context, uint8_t *output, size_t output_size) { @@ -2483,6 +2486,7 @@ psa_status_t psa_driver_wrapper_get_random(psa_driver_random_context_t *context, (void)output_size; return PSA_ERROR_NOT_SUPPORTED; } +#endif psa_status_t psa_driver_wrapper_free_random(psa_driver_random_context_t *context) {