mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-05-12 23:04:31 +02:00
psa: driver: Reduce the scope of test driver entry points
Define test driver entry points that provide an alternative to Mbed TLS driver entry points only when the PSA configuration is used. Their purpose is only to test the PSA configuration thus there is no good reason to use them out of this scope. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
@@ -45,10 +45,25 @@ psa_status_t mbedtls_test_transparent_hash_compute(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_hash_compute(
|
||||
alg, input, input_length,
|
||||
hash, hash_size, hash_length );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_psa_hash_compute(
|
||||
alg, input, input_length,
|
||||
hash, hash_size, hash_length );
|
||||
#else
|
||||
(void) alg;
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
(void) hash;
|
||||
(void) hash_size;
|
||||
(void) hash_length;
|
||||
mbedtls_test_driver_hash_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_hash_hooks.driver_status );
|
||||
@@ -67,8 +82,17 @@ psa_status_t mbedtls_test_transparent_hash_setup(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_hash_setup( operation, alg );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_psa_hash_setup( operation, alg );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) alg;
|
||||
mbedtls_test_driver_hash_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_hash_hooks.driver_status );
|
||||
@@ -87,9 +111,18 @@ psa_status_t mbedtls_test_transparent_hash_clone(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_hash_clone( source_operation,
|
||||
target_operation );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_psa_hash_clone( source_operation, target_operation );
|
||||
#else
|
||||
(void) source_operation;
|
||||
(void) target_operation;
|
||||
mbedtls_test_driver_hash_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_hash_hooks.driver_status );
|
||||
@@ -109,9 +142,19 @@ psa_status_t mbedtls_test_transparent_hash_update(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_hash_update(
|
||||
operation, input, input_length );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_psa_hash_update( operation, input, input_length );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
mbedtls_test_driver_hash_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_hash_hooks.driver_status );
|
||||
@@ -132,9 +175,20 @@ psa_status_t mbedtls_test_transparent_hash_finish(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_hash_finish(
|
||||
operation, hash, hash_size, hash_length );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_psa_hash_finish( operation, hash, hash_size, hash_length );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) hash;
|
||||
(void) hash_size;
|
||||
(void) hash_length;
|
||||
mbedtls_test_driver_hash_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_hash_hooks.driver_status );
|
||||
@@ -152,8 +206,16 @@ psa_status_t mbedtls_test_transparent_hash_abort(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_hash_abort( operation );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
mbedtls_test_driver_hash_hooks.driver_status =
|
||||
mbedtls_psa_hash_abort( operation );
|
||||
#else
|
||||
(void) operation;
|
||||
mbedtls_test_driver_hash_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_hash_hooks.driver_status );
|
||||
|
||||
@@ -70,10 +70,19 @@ psa_status_t mbedtls_test_transparent_cipher_encrypt(
|
||||
|
||||
psa_generate_random( output, PSA_CIPHER_IV_LENGTH( attributes->core.type, alg ) );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_encrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_encrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_decrypt(
|
||||
@@ -105,10 +114,19 @@ psa_status_t mbedtls_test_transparent_cipher_decrypt(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_decrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_decrypt(
|
||||
attributes, key_buffer, key_buffer_size,
|
||||
alg, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
|
||||
@@ -128,8 +146,15 @@ psa_status_t mbedtls_test_transparent_cipher_encrypt_setup(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
return ( mbedtls_transparent_test_driver_cipher_encrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_encrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_encrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
|
||||
@@ -143,8 +168,15 @@ psa_status_t mbedtls_test_transparent_cipher_decrypt_setup(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
return ( mbedtls_transparent_test_driver_cipher_decrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_decrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_decrypt_setup(
|
||||
operation, attributes, key, key_length, alg ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_abort(
|
||||
@@ -155,7 +187,11 @@ psa_status_t mbedtls_test_transparent_cipher_abort(
|
||||
if( operation->alg == 0 )
|
||||
return( PSA_SUCCESS );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_transparent_test_driver_cipher_abort( operation );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
mbedtls_psa_cipher_abort( operation );
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
@@ -176,8 +212,14 @@ psa_status_t mbedtls_test_transparent_cipher_set_iv(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_set_iv(
|
||||
operation, iv, iv_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_set_iv( operation, iv, iv_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_update(
|
||||
@@ -206,9 +248,17 @@ psa_status_t mbedtls_test_transparent_cipher_update(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_update(
|
||||
operation, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_update(
|
||||
operation, input, input_length,
|
||||
output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_transparent_cipher_finish(
|
||||
@@ -235,8 +285,15 @@ psa_status_t mbedtls_test_transparent_cipher_finish(
|
||||
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_cipher_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_cipher_finish(
|
||||
operation, output, output_size, output_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
return( mbedtls_psa_cipher_finish(
|
||||
operation, output, output_size, output_length ) );
|
||||
#endif
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -80,27 +80,32 @@ psa_status_t mbedtls_test_transparent_generate_key(
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
||||
/* Copied from psa_crypto.c */
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR)
|
||||
if ( PSA_KEY_TYPE_IS_ECC( psa_get_key_type( attributes ) )
|
||||
&& PSA_KEY_TYPE_IS_KEY_PAIR( psa_get_key_type( attributes ) ) )
|
||||
if( PSA_KEY_TYPE_IS_ECC( psa_get_key_type( attributes ) )
|
||||
&& PSA_KEY_TYPE_IS_KEY_PAIR( psa_get_key_type( attributes ) ) )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_ecp_generate_key(
|
||||
attributes, key, key_size, key_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR)
|
||||
return( mbedtls_psa_ecp_generate_key(
|
||||
attributes, key, key_size, key_length ) );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#endif /* defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) */
|
||||
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR)
|
||||
if ( psa_get_key_type( attributes ) == PSA_KEY_TYPE_RSA_KEY_PAIR )
|
||||
else if( psa_get_key_type( attributes ) == PSA_KEY_TYPE_RSA_KEY_PAIR )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_rsa_generate_key(
|
||||
attributes, key, key_size, key_length ) );
|
||||
else
|
||||
#endif /* defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) */
|
||||
{
|
||||
(void)attributes;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR)
|
||||
return( mbedtls_psa_rsa_generate_key(
|
||||
attributes, key, key_size, key_length ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
(void)attributes;
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_opaque_generate_key(
|
||||
@@ -128,45 +133,56 @@ psa_status_t mbedtls_test_transparent_import_key(
|
||||
if( mbedtls_test_driver_key_management_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_key_management_hooks.forced_status );
|
||||
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
psa_key_type_t type = psa_get_key_type( attributes );
|
||||
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY)
|
||||
if( PSA_KEY_TYPE_IS_ECC( type ) )
|
||||
{
|
||||
status = mbedtls_transparent_test_driver_ecp_import_key(
|
||||
attributes,
|
||||
data, data_length,
|
||||
key_buffer, key_buffer_size,
|
||||
key_buffer_length, bits );
|
||||
}
|
||||
else
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_ecp_import_key(
|
||||
attributes,
|
||||
data, data_length,
|
||||
key_buffer, key_buffer_size,
|
||||
key_buffer_length, bits ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY)
|
||||
return( mbedtls_psa_ecp_import_key(
|
||||
attributes,
|
||||
data, data_length,
|
||||
key_buffer, key_buffer_size,
|
||||
key_buffer_length, bits ) );
|
||||
#endif
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY)
|
||||
if( PSA_KEY_TYPE_IS_RSA( type ) )
|
||||
{
|
||||
status = mbedtls_transparent_test_driver_rsa_import_key(
|
||||
attributes,
|
||||
data, data_length,
|
||||
key_buffer, key_buffer_size,
|
||||
key_buffer_length, bits );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
else if( PSA_KEY_TYPE_IS_RSA( type ) )
|
||||
{
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
(void)data;
|
||||
(void)data_length;
|
||||
(void)key_buffer;
|
||||
(void)key_buffer_size;
|
||||
(void)key_buffer_length;
|
||||
(void)bits;
|
||||
(void)type;
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_rsa_import_key(
|
||||
attributes,
|
||||
data, data_length,
|
||||
key_buffer, key_buffer_size,
|
||||
key_buffer_length, bits ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY)
|
||||
return( mbedtls_psa_rsa_import_key(
|
||||
attributes,
|
||||
data, data_length,
|
||||
key_buffer, key_buffer_size,
|
||||
key_buffer_length, bits ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
return( status );
|
||||
(void)data;
|
||||
(void)data_length;
|
||||
(void)key_buffer;
|
||||
(void)key_buffer_size;
|
||||
(void)key_buffer_length;
|
||||
(void)bits;
|
||||
(void)type;
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_opaque_export_key(
|
||||
@@ -255,39 +271,48 @@ psa_status_t mbedtls_test_transparent_export_public_key(
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
psa_key_type_t key_type = psa_get_key_type( attributes );
|
||||
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY)
|
||||
if( PSA_KEY_TYPE_IS_ECC( key_type ) )
|
||||
{
|
||||
status = mbedtls_transparent_test_driver_ecp_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length );
|
||||
}
|
||||
else
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_ecp_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY)
|
||||
return( mbedtls_psa_ecp_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length ) );
|
||||
#endif
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY)
|
||||
if( PSA_KEY_TYPE_IS_RSA( key_type ) )
|
||||
{
|
||||
status = mbedtls_transparent_test_driver_rsa_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
else if( PSA_KEY_TYPE_IS_RSA( key_type ) )
|
||||
{
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
(void)key_buffer;
|
||||
(void)key_buffer_size;
|
||||
(void)key_type;
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_rsa_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length ) );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY)
|
||||
return( mbedtls_psa_rsa_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
return( status );
|
||||
(void)key_buffer;
|
||||
(void)key_buffer_size;
|
||||
(void)key_type;
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_opaque_export_public_key(
|
||||
|
||||
@@ -51,11 +51,30 @@ psa_status_t mbedtls_test_transparent_mac_compute(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_mac_compute(
|
||||
attributes, key_buffer, key_buffer_size, alg,
|
||||
input, input_length,
|
||||
mac, mac_size, mac_length );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_psa_mac_compute(
|
||||
attributes, key_buffer, key_buffer_size, alg,
|
||||
input, input_length,
|
||||
mac, mac_size, mac_length );
|
||||
#else
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
(void) mac;
|
||||
(void) mac_size;
|
||||
(void) mac_length;
|
||||
mbedtls_test_driver_mac_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||
@@ -77,9 +96,22 @@ psa_status_t mbedtls_test_transparent_mac_sign_setup(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_mac_sign_setup(
|
||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_psa_mac_sign_setup(
|
||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
mbedtls_test_driver_mac_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||
@@ -101,9 +133,22 @@ psa_status_t mbedtls_test_transparent_mac_verify_setup(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_mac_verify_setup(
|
||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_psa_mac_verify_setup(
|
||||
operation, attributes, key_buffer, key_buffer_size, alg );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) attributes;
|
||||
(void) key_buffer;
|
||||
(void) key_buffer_size;
|
||||
(void) alg;
|
||||
mbedtls_test_driver_mac_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||
@@ -123,9 +168,20 @@ psa_status_t mbedtls_test_transparent_mac_update(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_mac_update(
|
||||
operation, input, input_length );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_psa_mac_update(
|
||||
operation, input, input_length );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
mbedtls_test_driver_mac_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||
@@ -146,9 +202,21 @@ psa_status_t mbedtls_test_transparent_mac_sign_finish(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_mac_sign_finish(
|
||||
operation, mac, mac_size, mac_length );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_psa_mac_sign_finish(
|
||||
operation, mac, mac_size, mac_length );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) mac;
|
||||
(void) mac_size;
|
||||
(void) mac_length;
|
||||
mbedtls_test_driver_mac_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||
@@ -168,9 +236,20 @@ psa_status_t mbedtls_test_transparent_mac_verify_finish(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_mac_verify_finish(
|
||||
operation, mac, mac_length );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_psa_mac_verify_finish(
|
||||
operation, mac, mac_length );
|
||||
#else
|
||||
(void) operation;
|
||||
(void) mac;
|
||||
(void) mac_length;
|
||||
mbedtls_test_driver_mac_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||
@@ -188,8 +267,16 @@ psa_status_t mbedtls_test_transparent_mac_abort(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_transparent_test_driver_mac_abort( operation );
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_MAC)
|
||||
mbedtls_test_driver_mac_hooks.driver_status =
|
||||
mbedtls_psa_mac_abort( operation );
|
||||
#else
|
||||
(void) operation;
|
||||
mbedtls_test_driver_mac_hooks.driver_status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
return( mbedtls_test_driver_mac_hooks.driver_status );
|
||||
|
||||
@@ -63,15 +63,22 @@ psa_status_t sign_hash(
|
||||
if( PSA_ALG_IS_RSA_PKCS1V15_SIGN( alg ) ||
|
||||
PSA_ALG_IS_RSA_PSS( alg) )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PSS)
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PSS) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_rsa_sign_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_size, signature_length ) );
|
||||
#endif /* defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN) ||
|
||||
* defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PSS) */
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS)
|
||||
return( mbedtls_psa_rsa_sign_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_size, signature_length ) );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -82,15 +89,22 @@ psa_status_t sign_hash(
|
||||
{
|
||||
if( PSA_ALG_IS_ECDSA( alg ) )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA)
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_ecdsa_sign_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_size, signature_length ) );
|
||||
#endif /* defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA) ||
|
||||
* defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA) */
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)
|
||||
return( mbedtls_psa_ecdsa_sign_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_size, signature_length ) );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -125,15 +139,22 @@ psa_status_t verify_hash(
|
||||
if( PSA_ALG_IS_RSA_PKCS1V15_SIGN( alg ) ||
|
||||
PSA_ALG_IS_RSA_PSS( alg) )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PSS)
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PSS) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_rsa_verify_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_length ) );
|
||||
#endif /* defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN) ||
|
||||
* defined(MBEDTLS_PSA_ACCEL_ALG_RSA_PSS) */
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS)
|
||||
return( mbedtls_psa_rsa_verify_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_length ) );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -144,15 +165,22 @@ psa_status_t verify_hash(
|
||||
{
|
||||
if( PSA_ALG_IS_ECDSA( alg ) )
|
||||
{
|
||||
#if defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA)
|
||||
#if ( defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA) ) && \
|
||||
defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
return( mbedtls_transparent_test_driver_ecdsa_verify_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_length ) );
|
||||
#endif /* defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA) ||
|
||||
* defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA) */
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)
|
||||
return( mbedtls_psa_ecdsa_verify_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_length ) );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -168,7 +196,6 @@ psa_status_t verify_hash(
|
||||
(void)hash_length;
|
||||
(void)signature;
|
||||
(void)signature_length;
|
||||
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
@@ -204,16 +231,25 @@ psa_status_t mbedtls_test_transparent_signature_sign_message(
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
status = mbedtls_transparent_test_driver_hash_compute(
|
||||
PSA_ALG_SIGN_GET_HASH( alg ), input, input_length,
|
||||
hash, sizeof( hash ), &hash_length );
|
||||
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
status = mbedtls_psa_hash_compute(
|
||||
PSA_ALG_SIGN_GET_HASH( alg ), input, input_length,
|
||||
hash, sizeof( hash ), &hash_length );
|
||||
#else
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
if( status != PSA_SUCCESS )
|
||||
return status;
|
||||
|
||||
return sign_hash( attributes, key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_size, signature_length );
|
||||
return( sign_hash( attributes, key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_size, signature_length ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_opaque_signature_sign_message(
|
||||
@@ -259,16 +295,25 @@ psa_status_t mbedtls_test_transparent_signature_verify_message(
|
||||
if( mbedtls_test_driver_signature_verify_hooks.forced_status != PSA_SUCCESS )
|
||||
return( mbedtls_test_driver_signature_verify_hooks.forced_status );
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
|
||||
status = mbedtls_transparent_test_driver_hash_compute(
|
||||
PSA_ALG_SIGN_GET_HASH( alg ), input, input_length,
|
||||
hash, sizeof( hash ), &hash_length );
|
||||
|
||||
#elif defined(MBEDTLS_PSA_BUILTIN_HASH)
|
||||
status = mbedtls_psa_hash_compute(
|
||||
PSA_ALG_SIGN_GET_HASH( alg ), input, input_length,
|
||||
hash, sizeof( hash ), &hash_length );
|
||||
#else
|
||||
(void) input;
|
||||
(void) input_length;
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
#endif
|
||||
if( status != PSA_SUCCESS )
|
||||
return status;
|
||||
|
||||
return verify_hash( attributes, key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_length );
|
||||
return( verify_hash( attributes, key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_length ) );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_test_opaque_signature_verify_message(
|
||||
|
||||
Reference in New Issue
Block a user