From 45337a88954105374118d8d21f8742871169e4d6 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Thu, 23 Nov 2023 14:35:02 +0100 Subject: [PATCH] test_suite_psa_crypto_driver_wrappers: add counter for cipher_update() Signed-off-by: Valerio Setti --- tests/include/test/drivers/cipher.h | 3 ++- tests/src/drivers/test_driver_cipher.c | 1 + tests/suites/test_suite_psa_crypto_driver_wrappers.function | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/include/test/drivers/cipher.h b/tests/include/test/drivers/cipher.h index 2e299da723..71682303ce 100644 --- a/tests/include/test/drivers/cipher.h +++ b/tests/include/test/drivers/cipher.h @@ -26,9 +26,10 @@ typedef struct { /* Count the amount of times one of the cipher driver functions is called. */ unsigned long hits; unsigned long cipher_encrypt_hits; + unsigned long cipher_update_hits; } mbedtls_test_driver_cipher_hooks_t; -#define MBEDTLS_TEST_DRIVER_CIPHER_INIT { NULL, 0, PSA_SUCCESS, 0, 0 } +#define MBEDTLS_TEST_DRIVER_CIPHER_INIT { NULL, 0, PSA_SUCCESS, 0, 0, 0 } static inline mbedtls_test_driver_cipher_hooks_t mbedtls_test_driver_cipher_hooks_init(void) { diff --git a/tests/src/drivers/test_driver_cipher.c b/tests/src/drivers/test_driver_cipher.c index 324590c0af..76ccdcffbe 100644 --- a/tests/src/drivers/test_driver_cipher.c +++ b/tests/src/drivers/test_driver_cipher.c @@ -234,6 +234,7 @@ psa_status_t mbedtls_test_transparent_cipher_update( size_t *output_length) { mbedtls_test_driver_cipher_hooks.hits++; + mbedtls_test_driver_cipher_hooks.cipher_update_hits++; if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) { if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) { diff --git a/tests/suites/test_suite_psa_crypto_driver_wrappers.function b/tests/suites/test_suite_psa_crypto_driver_wrappers.function index 7a41fc2f9a..4fbc5e4b96 100644 --- a/tests/suites/test_suite_psa_crypto_driver_wrappers.function +++ b/tests/suites/test_suite_psa_crypto_driver_wrappers.function @@ -1489,7 +1489,7 @@ void cipher_entry_points(int alg_arg, int key_type_arg, output[i] = 0xa5; } - mbedtls_test_driver_cipher_hooks.cipher_encrypt_hits = 0; + mbedtls_test_driver_cipher_hooks.cipher_update_hits = 0; status = psa_cipher_encrypt( key, alg, input->x, input->len, output, output_buffer_size, &function_output_length); @@ -1500,7 +1500,7 @@ void cipher_entry_points(int alg_arg, int key_type_arg, * 1st access to the driver since "forced_status" is set. However this * initial access happens in psa_cipher_update() (random number generation * for IV) so psa_cipher_encrypt() never gets called. */ - TEST_EQUAL(mbedtls_test_driver_cipher_hooks.cipher_encrypt_hits, 0); + TEST_EQUAL(mbedtls_test_driver_cipher_hooks.cipher_update_hits, 1); #endif TEST_EQUAL(status, PSA_ERROR_GENERIC_ERROR); /*