Add mock and negative testing to cipher driver
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
diff --git a/tests/src/drivers/cipher.c b/tests/src/drivers/cipher.c
index 2915fba..f9106d1 100644
--- a/tests/src/drivers/cipher.c
+++ b/tests/src/drivers/cipher.c
@@ -296,6 +296,8 @@
psa_status_t test_transparent_cipher_abort(
test_transparent_cipher_operation_t *operation)
{
+ test_driver_cipher_hooks.hits++;
+
if( operation->alg == 0 )
return( PSA_SUCCESS );
if( operation->alg != PSA_ALG_CTR )
@@ -309,7 +311,6 @@
* struct. */
memset( operation, 0, sizeof( *operation ) );
- test_driver_cipher_hooks.hits++;
return( PSA_SUCCESS );
}
@@ -325,6 +326,9 @@
test_driver_cipher_hooks.hits++;
+ if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
+ return( test_driver_cipher_hooks.forced_status );
+
if( operation->alg != PSA_ALG_CTR )
return( PSA_ERROR_BAD_STATE );
@@ -356,6 +360,9 @@
test_driver_cipher_hooks.hits++;
+ if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
+ return( test_driver_cipher_hooks.forced_status );
+
if( operation->alg != PSA_ALG_CTR )
return( PSA_ERROR_BAD_STATE );
@@ -386,6 +393,9 @@
test_driver_cipher_hooks.hits++;
+ if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
+ return( test_driver_cipher_hooks.forced_status );
+
if( operation->alg != PSA_ALG_CTR )
return( PSA_ERROR_BAD_STATE );
@@ -425,6 +435,9 @@
test_driver_cipher_hooks.hits++;
+ if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
+ return( test_driver_cipher_hooks.forced_status );
+
if( operation->alg != PSA_ALG_CTR )
return( PSA_ERROR_BAD_STATE );