mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 00:05:35 +00:00
Add RSA key generation support to the transparent test driver
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
9e18fc1cf9
commit
3a9c46b184
|
@ -286,7 +286,7 @@ static psa_status_t psa_read_rsa_exponent( const uint8_t *domain_parameters,
|
|||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
||||
psa_status_t mbedtls_psa_rsa_generate_key(
|
||||
static psa_status_t rsa_generate_key(
|
||||
const psa_key_attributes_t *attributes,
|
||||
uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ psa_status_t mbedtls_psa_rsa_generate_key(
|
|||
|
||||
return( status );
|
||||
}
|
||||
#endif /* defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) */
|
||||
#endif /* defined(BUILTIN_KEY_TYPE_RSA_KEY_PAIR) */
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY)
|
||||
|
@ -345,6 +345,16 @@ psa_status_t mbedtls_psa_rsa_export_public_key(
|
|||
#endif /* defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) ||
|
||||
* defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY) */
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR)
|
||||
psa_status_t mbedtls_psa_rsa_generate_key(
|
||||
const psa_key_attributes_t *attributes,
|
||||
uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
|
||||
{
|
||||
return( rsa_generate_key( attributes, key_buffer, key_buffer_size,
|
||||
key_buffer_length ) );
|
||||
}
|
||||
#endif /* defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) */
|
||||
|
||||
/*
|
||||
* BEYOND THIS POINT, TEST DRIVER ENTRY POINTS ONLY.
|
||||
*/
|
||||
|
@ -377,6 +387,16 @@ psa_status_t mbedtls_transparent_test_driver_rsa_export_public_key(
|
|||
#endif /* defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) ||
|
||||
defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY) */
|
||||
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR)
|
||||
psa_status_t mbedtls_transparent_test_driver_rsa_generate_key(
|
||||
const psa_key_attributes_t *attributes,
|
||||
uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
|
||||
{
|
||||
return( rsa_generate_key( attributes, key_buffer, key_buffer_size,
|
||||
key_buffer_length ) );
|
||||
}
|
||||
#endif /* defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR) */
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
|
|
|
@ -154,6 +154,10 @@ psa_status_t mbedtls_transparent_test_driver_rsa_export_public_key(
|
|||
const uint8_t *key_buffer, size_t key_buffer_size,
|
||||
uint8_t *data, size_t data_size, size_t *data_length );
|
||||
|
||||
psa_status_t mbedtls_transparent_test_driver_rsa_generate_key(
|
||||
const psa_key_attributes_t *attributes,
|
||||
uint8_t *key, size_t key_size, size_t *key_length );
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* PSA_CRYPTO_RSA_H */
|
||||
|
|
|
@ -45,11 +45,6 @@ psa_status_t test_transparent_generate_key(
|
|||
const psa_key_attributes_t *attributes,
|
||||
uint8_t *key, size_t key_size, size_t *key_length )
|
||||
{
|
||||
#if !defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR) && \
|
||||
!defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY)
|
||||
(void)attributes;
|
||||
#endif /* !MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR &&
|
||||
* !MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY */
|
||||
++test_driver_key_management_hooks.hits;
|
||||
|
||||
if( test_driver_key_management_hooks.forced_status != PSA_SUCCESS )
|
||||
|
@ -125,7 +120,17 @@ psa_status_t test_transparent_generate_key(
|
|||
else
|
||||
#endif /* MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR ||
|
||||
* MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY */
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
|
||||
#if defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR)
|
||||
if ( psa_get_key_type( attributes ) == PSA_KEY_TYPE_RSA_KEY_PAIR )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
psa_status_t test_opaque_generate_key(
|
||||
|
|
Loading…
Reference in a new issue