psa_export_public_key
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index de388db..f4dbf1e 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -526,3 +526,62 @@
mbedtls_psa_crypto_free( );
}
/* END_CASE */
+
+
+/* BEGIN_CASE */
+void import_export_public_key( char *hex,
+ int type_arg,
+ int expected_bits,
+ int expected_export_status )
+{
+ int slot = 1;
+ psa_key_type_t type = type_arg;
+ psa_status_t status;
+ unsigned char *data = NULL;
+ unsigned char *exported = NULL;
+ size_t data_size;
+ size_t export_size;
+ size_t exported_length;
+ psa_key_type_t got_type;
+ size_t got_bits;
+
+ data = unhexify_alloc( hex, &data_size );
+ TEST_ASSERT( data != NULL );
+ export_size = (ssize_t) data_size ;
+ exported = mbedtls_calloc( 1, export_size );
+ TEST_ASSERT( exported != NULL );
+
+ TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
+
+ /* Import the key */
+ TEST_ASSERT( psa_import_key( slot, type,
+ data, data_size ) == PSA_SUCCESS );
+
+ /* Test the key information */
+ TEST_ASSERT( psa_get_key_information( slot,
+ &got_type, &got_bits ) == PSA_SUCCESS );
+ TEST_ASSERT( got_type == type );
+ TEST_ASSERT( got_bits == (size_t) expected_bits );
+
+ /* Export the key */
+ status = psa_export_public_key( slot,
+ exported, export_size,
+ &exported_length );
+ TEST_ASSERT( status == (psa_status_t) expected_export_status );
+ if( status != PSA_SUCCESS )
+ goto destroy;
+
+
+ TEST_ASSERT( exported_length == data_size );
+
+destroy:
+ /* Destroy the key */
+ TEST_ASSERT( psa_destroy_key( slot ) == PSA_SUCCESS );
+ TEST_ASSERT( psa_get_key_information(
+ slot, NULL, NULL ) == PSA_ERROR_EMPTY_SLOT );
+
+exit:
+ mbedtls_free( data );
+ mbedtls_psa_crypto_free( );
+}
+/* END_CASE */
\ No newline at end of file