psa: cipher: Add transparent driver test specific entry points
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c
index 147ce81..f47df9e 100644
--- a/library/psa_crypto_cipher.c
+++ b/library/psa_crypto_cipher.c
@@ -418,4 +418,66 @@
return( cipher_abort( operation ) );
}
+/*
+ * BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
+ */
+
+#if defined(PSA_CRYPTO_DRIVER_TEST)
+psa_status_t mbedtls_transparent_test_driver_cipher_encrypt_setup(
+ mbedtls_psa_cipher_operation_t *operation,
+ const psa_key_attributes_t *attributes,
+ const uint8_t *key_buffer, size_t key_buffer_size,
+ psa_algorithm_t alg )
+{
+ return( cipher_encrypt_setup(
+ operation, attributes, key_buffer, key_buffer_size, alg ) );
+}
+
+psa_status_t mbedtls_transparent_test_driver_cipher_decrypt_setup(
+ mbedtls_psa_cipher_operation_t *operation,
+ const psa_key_attributes_t *attributes,
+ const uint8_t *key_buffer, size_t key_buffer_size,
+ psa_algorithm_t alg )
+{
+ return( cipher_decrypt_setup(
+ operation, attributes, key_buffer, key_buffer_size, alg ) );
+}
+
+psa_status_t mbedtls_transparent_test_driver_cipher_generate_iv(
+ mbedtls_psa_cipher_operation_t *operation,
+ uint8_t *iv, size_t iv_size, size_t *iv_length )
+{
+ return( cipher_generate_iv( operation, iv, iv_size, iv_length ) );
+}
+
+psa_status_t mbedtls_transparent_test_driver_cipher_set_iv(
+ mbedtls_psa_cipher_operation_t *operation,
+ const uint8_t *iv, size_t iv_length )
+{
+ return( cipher_set_iv( operation, iv, iv_length ) );
+}
+
+psa_status_t mbedtls_transparent_test_driver_cipher_update(
+ mbedtls_psa_cipher_operation_t *operation,
+ const uint8_t *input, size_t input_length,
+ uint8_t *output, size_t output_size, size_t *output_length )
+{
+ return( cipher_update( operation, input, input_length,
+ output, output_size, output_length ) );
+}
+
+psa_status_t mbedtls_transparent_test_driver_cipher_finish(
+ mbedtls_psa_cipher_operation_t *operation,
+ uint8_t *output, size_t output_size, size_t *output_length )
+{
+ return( cipher_finish( operation, output, output_size, output_length ) );
+}
+
+psa_status_t mbedtls_transparent_test_driver_cipher_abort(
+ mbedtls_psa_cipher_operation_t *operation )
+{
+ return( cipher_abort( operation ) );
+}
+#endif /* PSA_CRYPTO_DRIVER_TEST */
+
#endif /* MBEDTLS_PSA_CRYPTO_C */
diff --git a/library/psa_crypto_cipher.h b/library/psa_crypto_cipher.h
index 127f18c..cb85ee1 100644
--- a/library/psa_crypto_cipher.h
+++ b/library/psa_crypto_cipher.h
@@ -206,4 +206,42 @@
*/
psa_status_t mbedtls_psa_cipher_abort( mbedtls_psa_cipher_operation_t *operation );
+/*
+ * BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
+ */
+
+#if defined(PSA_CRYPTO_DRIVER_TEST)
+psa_status_t mbedtls_transparent_test_driver_cipher_encrypt_setup(
+ mbedtls_psa_cipher_operation_t *operation,
+ const psa_key_attributes_t *attributes,
+ const uint8_t *key_buffer, size_t key_buffer_size,
+ psa_algorithm_t alg );
+
+psa_status_t mbedtls_transparent_test_driver_cipher_decrypt_setup(
+ mbedtls_psa_cipher_operation_t *operation,
+ const psa_key_attributes_t *attributes,
+ const uint8_t *key_buffer, size_t key_buffer_size,
+ psa_algorithm_t alg );
+
+psa_status_t mbedtls_transparent_test_driver_cipher_generate_iv(
+ mbedtls_psa_cipher_operation_t *operation,
+ uint8_t *iv, size_t iv_size, size_t *iv_length );
+
+psa_status_t mbedtls_transparent_test_driver_cipher_set_iv(
+ mbedtls_psa_cipher_operation_t *operation,
+ const uint8_t *iv, size_t iv_length );
+
+psa_status_t mbedtls_transparent_test_driver_cipher_update(
+ mbedtls_psa_cipher_operation_t *operation,
+ const uint8_t *input, size_t input_length,
+ uint8_t *output, size_t output_size, size_t *output_length );
+
+psa_status_t mbedtls_transparent_test_driver_cipher_finish(
+ mbedtls_psa_cipher_operation_t *operation,
+ uint8_t *output, size_t output_size, size_t *output_length );
+
+psa_status_t mbedtls_transparent_test_driver_cipher_abort(
+ mbedtls_psa_cipher_operation_t *operation );
+#endif /* PSA_CRYPTO_DRIVER_TEST */
+
#endif /* PSA_CRYPTO_CIPHER_H */
diff --git a/tests/src/drivers/cipher.c b/tests/src/drivers/cipher.c
index 607cd94..295d47a 100644
--- a/tests/src/drivers/cipher.c
+++ b/tests/src/drivers/cipher.c
@@ -222,11 +222,8 @@
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
- return ( mbedtls_psa_cipher_encrypt_setup( operation,
- attributes,
- key,
- key_length,
- alg ) );
+ return ( mbedtls_transparent_test_driver_cipher_encrypt_setup(
+ operation, attributes, key, key_length, alg ) );
}
psa_status_t test_transparent_cipher_decrypt_setup(
@@ -240,11 +237,8 @@
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
- return ( mbedtls_psa_cipher_decrypt_setup( operation,
- attributes,
- key,
- key_length,
- alg ) );
+ return ( mbedtls_transparent_test_driver_cipher_decrypt_setup(
+ operation, attributes, key, key_length, alg ) );
}
psa_status_t test_transparent_cipher_abort(
@@ -255,7 +249,7 @@
if( operation->alg == 0 )
return( PSA_SUCCESS );
- mbedtls_psa_cipher_abort( operation );
+ mbedtls_transparent_test_driver_cipher_abort( operation );
/* Wiping the entire struct here, instead of member-by-member. This is
* useful for the test suite, since it gives a chance of catching memory
@@ -277,10 +271,8 @@
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
- return( mbedtls_psa_cipher_generate_iv( operation,
- iv,
- iv_size,
- iv_length ) );
+ return( mbedtls_transparent_test_driver_cipher_generate_iv(
+ operation, iv, iv_size, iv_length ) );
}
psa_status_t test_transparent_cipher_set_iv(
@@ -293,9 +285,8 @@
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
- return( mbedtls_psa_cipher_set_iv( operation,
- iv,
- iv_length ) );
+ return( mbedtls_transparent_test_driver_cipher_set_iv(
+ operation, iv, iv_length ) );
}
psa_status_t test_transparent_cipher_update(
@@ -324,10 +315,9 @@
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
- return( mbedtls_psa_cipher_update( operation,
- input, input_length,
- output, output_size,
- output_length ) );
+ return( mbedtls_transparent_test_driver_cipher_update(
+ operation, input, input_length,
+ output, output_size, output_length ) );
}
psa_status_t test_transparent_cipher_finish(
@@ -354,9 +344,8 @@
if( test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
return( test_driver_cipher_hooks.forced_status );
- return( mbedtls_psa_cipher_finish( operation,
- output, output_size,
- output_length ) );
+ return( mbedtls_transparent_test_driver_cipher_finish(
+ operation, output, output_size, output_length ) );
}
/*