Change names rsa->asymmetric_encryption
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
diff --git a/tests/include/test/drivers/asym.h b/tests/include/test/drivers/asymmetric_encryption.h
similarity index 74%
rename from tests/include/test/drivers/asym.h
rename to tests/include/test/drivers/asymmetric_encryption.h
index 82a9d8c..2babfea 100644
--- a/tests/include/test/drivers/asym.h
+++ b/tests/include/test/drivers/asymmetric_encryption.h
@@ -1,5 +1,5 @@
/*
- * Test driver for hash driver entry points.
+ * Test driver for asymmetric encryption.
*/
/* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
@@ -17,8 +17,8 @@
* limitations under the License.
*/
-#ifndef PSA_CRYPTO_TEST_DRIVERS_ASYM_H
-#define PSA_CRYPTO_TEST_DRIVERS_ASYM_H
+#ifndef PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H
+#define PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H
#include "mbedtls/build_info.h"
@@ -33,20 +33,23 @@
/* If not PSA_SUCCESS, return this error code instead of processing the
* function call. */
psa_status_t forced_status;
- /* Count the amount of times one of the rsa driver functions is called. */
+ /* Count the amount of times one of the asymmetric_encryption driver
+ functions is called. */
unsigned long hits;
-} mbedtls_test_driver_rsa_hooks_t;
+} mbedtls_test_driver_asymmetric_encryption_hooks_t;
-#define MBEDTLS_TEST_DRIVER_RSA_INIT { NULL, 0, PSA_SUCCESS, 0 }
+#define MBEDTLS_TEST_DRIVER_ASYMMETRIC_ENCRYPTION_INIT { NULL, 0, PSA_SUCCESS, 0 }
-static inline mbedtls_test_driver_rsa_hooks_t
- mbedtls_test_driver_rsa_hooks_init( void )
+static inline mbedtls_test_driver_asymmetric_encryption_hooks_t
+ mbedtls_test_driver_asymmetric_encryption_hooks_init( void )
{
- const mbedtls_test_driver_rsa_hooks_t v = MBEDTLS_TEST_DRIVER_RSA_INIT;
+ const mbedtls_test_driver_asymmetric_encryption_hooks_t v =
+ MBEDTLS_TEST_DRIVER_ASYMMETRIC_ENCRYPTION_INIT;
return( v );
}
-extern mbedtls_test_driver_rsa_hooks_t mbedtls_test_driver_rsa_hooks;
+extern mbedtls_test_driver_asymmetric_encryption_hooks_t
+ mbedtls_test_driver_asymmetric_encryption_hooks;
psa_status_t mbedtls_test_transparent_asymmetric_encrypt(
const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
@@ -73,4 +76,4 @@
uint8_t *output, size_t output_size, size_t *output_length );
#endif /* PSA_CRYPTO_DRIVER_TEST */
-#endif /* PSA_CRYPTO_TEST_DRIVERS_ASYM_H */
+#endif /* PSA_CRYPTO_TEST_DRIVERS_ASYMMETRIC_ENCRYPTION_H */
diff --git a/tests/include/test/drivers/test_driver.h b/tests/include/test/drivers/test_driver.h
index af19e42..098b21a 100644
--- a/tests/include/test/drivers/test_driver.h
+++ b/tests/include/test/drivers/test_driver.h
@@ -28,6 +28,6 @@
#include "test/drivers/mac.h"
#include "test/drivers/key_management.h"
#include "test/drivers/signature.h"
-#include "test/drivers/asym.h"
+#include "test/drivers/asymmetric_encryption.h"
#endif /* PSA_CRYPTO_TEST_DRIVER_H */
diff --git a/tests/src/drivers/test_driver_rsa.c b/tests/src/drivers/test_driver_asymmetric_encryption.c
similarity index 71%
rename from tests/src/drivers/test_driver_rsa.c
rename to tests/src/drivers/test_driver_asymmetric_encryption.c
index 234613e..506c29b 100644
--- a/tests/src/drivers/test_driver_rsa.c
+++ b/tests/src/drivers/test_driver_asymmetric_encryption.c
@@ -1,5 +1,5 @@
/*
- * Test driver for rsa functions.
+ * Test driver for asymmetric encryption.
*/
/* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
@@ -24,14 +24,14 @@
#include "mbedtls/rsa.h"
#include "psa_crypto_rsa.h"
#include "string.h"
-#include "test/drivers/asym.h"
+#include "test/drivers/asymmetric_encryption.h"
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
#include "libtestdriver1/library/psa_crypto_rsa.h"
#endif
-mbedtls_test_driver_rsa_hooks_t mbedtls_test_driver_rsa_hooks =
- MBEDTLS_TEST_DRIVER_RSA_INIT;
+mbedtls_test_driver_asymmetric_encryption_hooks_t mbedtls_test_driver_asymmetric_encryption_hooks =
+ MBEDTLS_TEST_DRIVER_ASYMMETRIC_ENCRYPTION_INIT;
psa_status_t mbedtls_test_transparent_asymmetric_encrypt(
const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
@@ -39,23 +39,23 @@
size_t input_length, const uint8_t *salt, size_t salt_length,
uint8_t *output, size_t output_size, size_t *output_length )
{
- mbedtls_test_driver_rsa_hooks.hits++;
+ mbedtls_test_driver_asymmetric_encryption_hooks.hits++;
- if( mbedtls_test_driver_rsa_hooks.forced_output != NULL )
+ if( mbedtls_test_driver_asymmetric_encryption_hooks.forced_output != NULL )
{
- if( output_size < mbedtls_test_driver_rsa_hooks.forced_output_length )
+ if( output_size < mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length )
return( PSA_ERROR_BUFFER_TOO_SMALL );
memcpy( output,
- mbedtls_test_driver_rsa_hooks.forced_output,
- mbedtls_test_driver_rsa_hooks.forced_output_length );
- *output_length = mbedtls_test_driver_rsa_hooks.forced_output_length;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output,
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length );
+ *output_length = mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length;
- return( mbedtls_test_driver_rsa_hooks.forced_status );
+ return( mbedtls_test_driver_asymmetric_encryption_hooks.forced_status );
}
- if( mbedtls_test_driver_rsa_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_rsa_hooks.forced_status );
+ if( mbedtls_test_driver_asymmetric_encryption_hooks.forced_status != PSA_SUCCESS )
+ return( mbedtls_test_driver_asymmetric_encryption_hooks.forced_status );
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
@@ -80,23 +80,23 @@
size_t input_length, const uint8_t *salt, size_t salt_length,
uint8_t *output, size_t output_size, size_t *output_length )
{
- mbedtls_test_driver_rsa_hooks.hits++;
+ mbedtls_test_driver_asymmetric_encryption_hooks.hits++;
- if( mbedtls_test_driver_rsa_hooks.forced_output != NULL )
+ if( mbedtls_test_driver_asymmetric_encryption_hooks.forced_output != NULL )
{
- if( output_size < mbedtls_test_driver_rsa_hooks.forced_output_length )
+ if( output_size < mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length )
return( PSA_ERROR_BUFFER_TOO_SMALL );
memcpy( output,
- mbedtls_test_driver_rsa_hooks.forced_output,
- mbedtls_test_driver_rsa_hooks.forced_output_length );
- *output_length = mbedtls_test_driver_rsa_hooks.forced_output_length;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output,
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length );
+ *output_length = mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length;
- return( mbedtls_test_driver_rsa_hooks.forced_status );
+ return( mbedtls_test_driver_asymmetric_encryption_hooks.forced_status );
}
- if( mbedtls_test_driver_rsa_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_rsa_hooks.forced_status );
+ if( mbedtls_test_driver_asymmetric_encryption_hooks.forced_status != PSA_SUCCESS )
+ return( mbedtls_test_driver_asymmetric_encryption_hooks.forced_status );
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
diff --git a/tests/suites/test_suite_psa_crypto_driver_wrappers.function b/tests/suites/test_suite_psa_crypto_driver_wrappers.function
index 438caa5..3bded34 100644
--- a/tests/suites/test_suite_psa_crypto_driver_wrappers.function
+++ b/tests/suites/test_suite_psa_crypto_driver_wrappers.function
@@ -1851,7 +1851,8 @@
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
PSA_ASSERT( psa_crypto_init( ) );
- mbedtls_test_driver_rsa_hooks = mbedtls_test_driver_rsa_hooks_init();
+ mbedtls_test_driver_asymmetric_encryption_hooks =
+ mbedtls_test_driver_asymmetric_encryption_hooks_init();
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
psa_set_key_algorithm( &attributes, alg );
@@ -1864,11 +1865,14 @@
PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
key_bits = psa_get_key_bits( &attributes );
- mbedtls_test_driver_rsa_hooks.forced_status = forced_status_encrypt;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_status =
+ forced_status_encrypt;
if ( fake_output_encrypt->len > 0 )
{
- mbedtls_test_driver_rsa_hooks.forced_output = fake_output_encrypt->x;
- mbedtls_test_driver_rsa_hooks.forced_output_length = fake_output_encrypt->len;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output =
+ fake_output_encrypt->x;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length =
+ fake_output_encrypt->len;
output_size = fake_output_encrypt->len;
ASSERT_ALLOC( output, output_size );
}
@@ -1895,14 +1899,17 @@
{
if ( fake_output_encrypt->len > 0 )
ASSERT_COMPARE( fake_output_encrypt->x, fake_output_encrypt->len,
- output, output_length );
+ output, output_length );
else
{
- mbedtls_test_driver_rsa_hooks.forced_status = forced_status_decrypt;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_status =
+ forced_status_decrypt;
if ( fake_output_decrypt->len > 0 )
{
- mbedtls_test_driver_rsa_hooks.forced_output = fake_output_decrypt->x;
- mbedtls_test_driver_rsa_hooks.forced_output_length = fake_output_decrypt->len;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output =
+ fake_output_decrypt->x;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length =
+ fake_output_decrypt->len;
output2_size = fake_output_decrypt->len;
ASSERT_ALLOC( output2, output2_size );
}
@@ -1924,10 +1931,10 @@
{
if ( fake_output_decrypt->len > 0 )
ASSERT_COMPARE( fake_output_decrypt->x, fake_output_decrypt->len,
- output2, output2_length );
+ output2, output2_length );
else
ASSERT_COMPARE( input_data->x, input_data->len,
- output2, output2_length );
+ output2, output2_length );
}
}
}
@@ -1967,7 +1974,8 @@
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
PSA_ASSERT( psa_crypto_init( ) );
- mbedtls_test_driver_rsa_hooks = mbedtls_test_driver_rsa_hooks_init();
+ mbedtls_test_driver_asymmetric_encryption_hooks =
+ mbedtls_test_driver_asymmetric_encryption_hooks_init();
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
psa_set_key_algorithm( &attributes, alg );
@@ -1976,11 +1984,15 @@
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
&key ) );
- mbedtls_test_driver_rsa_hooks.forced_status = forced_status_decrypt;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_status =
+ forced_status_decrypt;
+
if ( fake_output_decrypt->len > 0 )
{
- mbedtls_test_driver_rsa_hooks.forced_output = fake_output_decrypt->x;
- mbedtls_test_driver_rsa_hooks.forced_output_length = fake_output_decrypt->len;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output =
+ fake_output_decrypt->x;
+ mbedtls_test_driver_asymmetric_encryption_hooks.forced_output_length =
+ fake_output_decrypt->len;
output_size = fake_output_decrypt->len;
ASSERT_ALLOC( output, output_size );
}
@@ -1999,7 +2011,7 @@
{
TEST_EQUAL( output_length, expected_output_data->len );
ASSERT_COMPARE( expected_output_data->x, expected_output_data->len,
- output, output_length );
+ output, output_length );
}
exit:
/*