mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 13:20:21 +00:00
test_suite_psa_crypto_driver_wrappers: add counter for failing psa_cipher_update()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
83e0de8481
commit
7ef35a9b3c
@ -26,7 +26,7 @@ typedef struct {
|
|||||||
/* Count the amount of times one of the cipher driver functions is called. */
|
/* Count the amount of times one of the cipher driver functions is called. */
|
||||||
unsigned long hits;
|
unsigned long hits;
|
||||||
unsigned long cipher_encrypt_hits;
|
unsigned long cipher_encrypt_hits;
|
||||||
unsigned long cipher_update_hits;
|
unsigned long cipher_update_forced_status_hits;
|
||||||
} mbedtls_test_driver_cipher_hooks_t;
|
} mbedtls_test_driver_cipher_hooks_t;
|
||||||
|
|
||||||
#define MBEDTLS_TEST_DRIVER_CIPHER_INIT { NULL, 0, PSA_SUCCESS, 0, 0, 0 }
|
#define MBEDTLS_TEST_DRIVER_CIPHER_INIT { NULL, 0, PSA_SUCCESS, 0, 0, 0 }
|
||||||
|
@ -234,7 +234,6 @@ psa_status_t mbedtls_test_transparent_cipher_update(
|
|||||||
size_t *output_length)
|
size_t *output_length)
|
||||||
{
|
{
|
||||||
mbedtls_test_driver_cipher_hooks.hits++;
|
mbedtls_test_driver_cipher_hooks.hits++;
|
||||||
mbedtls_test_driver_cipher_hooks.cipher_update_hits++;
|
|
||||||
|
|
||||||
if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
|
if (mbedtls_test_driver_cipher_hooks.forced_output != NULL) {
|
||||||
if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
|
if (output_size < mbedtls_test_driver_cipher_hooks.forced_output_length) {
|
||||||
@ -250,6 +249,7 @@ psa_status_t mbedtls_test_transparent_cipher_update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
|
if (mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS) {
|
||||||
|
++mbedtls_test_driver_cipher_hooks.cipher_update_forced_status_hits;
|
||||||
return mbedtls_test_driver_cipher_hooks.forced_status;
|
return mbedtls_test_driver_cipher_hooks.forced_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1489,7 +1489,7 @@ void cipher_entry_points(int alg_arg, int key_type_arg,
|
|||||||
output[i] = 0xa5;
|
output[i] = 0xa5;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_test_driver_cipher_hooks.cipher_update_hits = 0;
|
mbedtls_test_driver_cipher_hooks.cipher_update_forced_status_hits = 0;
|
||||||
mbedtls_test_driver_cipher_hooks.cipher_encrypt_hits = 0;
|
mbedtls_test_driver_cipher_hooks.cipher_encrypt_hits = 0;
|
||||||
status = psa_cipher_encrypt(
|
status = psa_cipher_encrypt(
|
||||||
key, alg, input->x, input->len,
|
key, alg, input->x, input->len,
|
||||||
@ -1501,7 +1501,7 @@ void cipher_entry_points(int alg_arg, int key_type_arg,
|
|||||||
* 1st access to the driver since "forced_status" is set. However this
|
* 1st access to the driver since "forced_status" is set. However this
|
||||||
* initial access happens in psa_cipher_update() (random number generation
|
* initial access happens in psa_cipher_update() (random number generation
|
||||||
* for IV) so psa_cipher_encrypt() never gets called. */
|
* for IV) so psa_cipher_encrypt() never gets called. */
|
||||||
TEST_EQUAL(mbedtls_test_driver_cipher_hooks.cipher_update_hits, 1);
|
TEST_EQUAL(mbedtls_test_driver_cipher_hooks.cipher_update_forced_status_hits, 1);
|
||||||
#endif
|
#endif
|
||||||
TEST_EQUAL(status, PSA_ERROR_GENERIC_ERROR);
|
TEST_EQUAL(status, PSA_ERROR_GENERIC_ERROR);
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user