Normalize whitespace
Normalize whitespace to Mbed TLS standards. There are only whitespace
changes in this commit.
diff --git a/include/psa/crypto.h b/include/psa/crypto.h
index 94060c1..c513b24 100644
--- a/include/psa/crypto.h
+++ b/include/psa/crypto.h
@@ -1304,8 +1304,8 @@
psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
const uint8_t *input,
size_t input_length,
- unsigned char *output,
- size_t output_size,
+ unsigned char *output,
+ size_t output_size,
size_t *output_length);
psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h
index f554b6e..4b0f979 100644
--- a/include/psa/crypto_struct.h
+++ b/include/psa/crypto_struct.h
@@ -48,7 +48,7 @@
#if defined(MBEDTLS_SHA512_C)
#define PSA_CRYPTO_MD_MAX_SIZE 64
#define PSA_CRYPTO_MD_BLOCK_SIZE 128
-#else
+#else
#define PSA_CRYPTO_MD_MAX_SIZE 32
#define PSA_CRYPTO_MD_BLOCK_SIZE 64
#endif
@@ -84,7 +84,8 @@
};
-typedef struct {
+typedef struct
+{
/** The hash context. */
struct psa_hash_operation_s hash_ctx;
/** The HMAC part of the context. */
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 4a25698..9548959 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -94,12 +94,15 @@
* The value is a compile-time constant for now, for simplicity. */
#define MBEDTLS_PSA_KEY_SLOT_COUNT 32
-typedef struct {
+typedef struct
+{
psa_key_type_t type;
psa_key_policy_t policy;
psa_key_lifetime_t lifetime;
- union {
- struct raw_data {
+ union
+ {
+ struct raw_data
+ {
uint8_t *data;
size_t bytes;
} raw;
@@ -112,7 +115,8 @@
} data;
} key_slot_t;
-typedef struct {
+typedef struct
+{
int initialized;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
@@ -305,10 +309,10 @@
/* Key management */
/****************************************************************/
-psa_status_t psa_import_key(psa_key_slot_t key,
- psa_key_type_t type,
- const uint8_t *data,
- size_t data_length)
+psa_status_t psa_import_key( psa_key_slot_t key,
+ psa_key_type_t type,
+ const uint8_t *data,
+ size_t data_length )
{
key_slot_t *slot;
@@ -380,7 +384,7 @@
return( PSA_SUCCESS );
}
-psa_status_t psa_destroy_key(psa_key_slot_t key)
+psa_status_t psa_destroy_key( psa_key_slot_t key )
{
key_slot_t *slot;
@@ -424,9 +428,9 @@
return( PSA_SUCCESS );
}
-psa_status_t psa_get_key_information(psa_key_slot_t key,
- psa_key_type_t *type,
- size_t *bits)
+psa_status_t psa_get_key_information( psa_key_slot_t key,
+ psa_key_type_t *type,
+ size_t *bits )
{
key_slot_t *slot;
@@ -472,11 +476,11 @@
return( PSA_SUCCESS );
}
-static psa_status_t psa_internal_export_key(psa_key_slot_t key,
- uint8_t *data,
- size_t data_size,
- size_t *data_length,
- int export_public_key)
+static psa_status_t psa_internal_export_key( psa_key_slot_t key,
+ uint8_t *data,
+ size_t data_size,
+ size_t *data_length,
+ int export_public_key )
{
key_slot_t *slot;
@@ -492,7 +496,7 @@
if( ( !export_public_key ) && ( !( PSA_KEY_TYPE_IS_PUBLIC_KEY( slot->type ) ) ) &&
( !( slot->policy.usage & PSA_KEY_USAGE_EXPORT ) ) )
return( PSA_ERROR_NOT_PERMITTED );
-
+
if( PSA_KEY_TYPE_IS_RAW_BYTES( slot->type ) )
{
if( slot->data.raw.bytes > data_size )
@@ -542,23 +546,23 @@
}
}
-psa_status_t psa_export_key(psa_key_slot_t key,
- uint8_t *data,
- size_t data_size,
- size_t *data_length)
+psa_status_t psa_export_key( psa_key_slot_t key,
+ uint8_t *data,
+ size_t data_size,
+ size_t *data_length )
{
return psa_internal_export_key( key, data, data_size,
- data_length, 0 );
+ data_length, 0 );
}
-psa_status_t psa_export_public_key(psa_key_slot_t key,
- uint8_t *data,
- size_t data_size,
- size_t *data_length)
+psa_status_t psa_export_public_key( psa_key_slot_t key,
+ uint8_t *data,
+ size_t data_size,
+ size_t *data_length )
{
return psa_internal_export_key( key, data, data_size,
- data_length, 1 );
+ data_length, 1 );
}
/****************************************************************/
@@ -884,9 +888,9 @@
}
}
-psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
- const uint8_t *hash,
- size_t hash_length)
+psa_status_t psa_hash_verify( psa_hash_operation_t *operation,
+ const uint8_t *hash,
+ size_t hash_length )
{
uint8_t actual_hash[MBEDTLS_MD_MAX_SIZE];
size_t actual_hash_length;
@@ -912,7 +916,7 @@
static const mbedtls_cipher_info_t *mbedtls_cipher_info_from_psa(
psa_algorithm_t alg,
psa_key_type_t key_type,
- size_t key_bits,
+ size_t key_bits,
mbedtls_cipher_id_t* cipher_id )
{
mbedtls_cipher_mode_t mode;
@@ -987,7 +991,7 @@
static size_t psa_get_hash_block_size( psa_algorithm_t alg )
{
- switch(alg)
+ switch( alg )
{
case PSA_ALG_MD2:
return( 16 );
@@ -1006,9 +1010,9 @@
case PSA_ALG_SHA_384:
return( 128 );
case PSA_ALG_SHA_512:
- return ( 128 );
- default:
- return ( 0 );
+ return( 128 );
+ default:
+ return( 0 );
}
}
@@ -1032,8 +1036,7 @@
return( PSA_ERROR_NOT_SUPPORTED );
psa_hash_abort( &operation->ctx.hmac.hash_ctx );
- mbedtls_zeroize( operation->ctx.hmac.opad,
- block_size);
+ mbedtls_zeroize( operation->ctx.hmac.opad, block_size );
}
else
#endif /* MBEDTLS_MD_C */
@@ -1241,7 +1244,7 @@
if( PSA_ALG_IS_HMAC( operation->alg ) )
{
status = psa_hash_update( &operation->ctx.hmac.hash_ctx, input,
- input_length );
+ input_length );
}
else
#endif /* MBEDTLS_MD_C */
@@ -1250,10 +1253,10 @@
}
break;
}
- if ( ( ret != 0 ) || ( status != PSA_SUCCESS ) )
+ if( ( ret != 0 ) || ( status != PSA_SUCCESS ) )
{
psa_mac_abort( operation );
- if ( ret != 0 )
+ if( ret != 0 )
status = mbedtls_to_psa_error( ret );
}
@@ -1261,9 +1264,9 @@
}
static psa_status_t psa_mac_finish_internal( psa_mac_operation_t *operation,
- uint8_t *mac,
- size_t mac_size,
- size_t *mac_length )
+ uint8_t *mac,
+ size_t mac_size,
+ size_t *mac_length )
{
int ret = 0;
psa_status_t status = PSA_SUCCESS;
@@ -1296,7 +1299,7 @@
unsigned char *opad = operation->ctx.hmac.opad;
size_t hash_size = 0;
size_t block_size =
- psa_get_hash_block_size( ( PSA_ALG_HMAC_HASH( operation->alg ) ) );
+ psa_get_hash_block_size( ( PSA_ALG_HMAC_HASH( operation->alg ) ) );
if( block_size == 0 )
return( PSA_ERROR_NOT_SUPPORTED );
@@ -1318,7 +1321,7 @@
goto hmac_cleanup;
status = psa_hash_update( &operation->ctx.hmac.hash_ctx, tmp,
- hash_size);
+ hash_size );
if( status != PSA_SUCCESS )
goto hmac_cleanup;
@@ -1336,7 +1339,7 @@
}
cleanup:
- if( ( ret == 0 ) && (status == PSA_SUCCESS) )
+ if( ( ret == 0 ) && ( status == PSA_SUCCESS ) )
{
return( psa_mac_abort( operation ) );
}
@@ -1344,7 +1347,7 @@
{
psa_mac_abort( operation );
if( ret != 0 )
- status = mbedtls_to_psa_error(ret);
+ status = mbedtls_to_psa_error( ret );
return status;
}
@@ -1362,9 +1365,9 @@
mac_size, mac_length ) );
}
-#define MBEDTLS_PSA_MAC_MAX_SIZE \
- ( MBEDTLS_MD_MAX_SIZE > MBEDTLS_MAX_BLOCK_LENGTH ? \
- MBEDTLS_MD_MAX_SIZE : \
+#define MBEDTLS_PSA_MAC_MAX_SIZE \
+ ( MBEDTLS_MD_MAX_SIZE > MBEDTLS_MAX_BLOCK_LENGTH ? \
+ MBEDTLS_MD_MAX_SIZE : \
MBEDTLS_MAX_BLOCK_LENGTH )
psa_status_t psa_mac_verify( psa_mac_operation_t *operation,
const uint8_t *mac,
@@ -1598,7 +1601,7 @@
{
mbedtls_ecp_keypair *ecdsa = slot->data.ecp;
int ret;
- (void)alg;
+ (void) alg;
ret = mbedtls_ecdsa_read_signature( ecdsa, hash, hash_length,
signature, signature_size );
return( mbedtls_to_psa_error( ret ) );
@@ -2015,31 +2018,31 @@
/* Key Policy */
/****************************************************************/
-void psa_key_policy_init(psa_key_policy_t *policy)
+void psa_key_policy_init( psa_key_policy_t *policy )
{
memset( policy, 0, sizeof( psa_key_policy_t ) );
}
-void psa_key_policy_set_usage(psa_key_policy_t *policy,
- psa_key_usage_t usage,
- psa_algorithm_t alg)
+void psa_key_policy_set_usage( psa_key_policy_t *policy,
+ psa_key_usage_t usage,
+ psa_algorithm_t alg )
{
policy->usage = usage;
policy->alg = alg;
}
-psa_key_usage_t psa_key_policy_get_usage(psa_key_policy_t *policy)
+psa_key_usage_t psa_key_policy_get_usage( psa_key_policy_t *policy )
{
return( policy->usage );
}
-psa_algorithm_t psa_key_policy_get_algorithm(psa_key_policy_t *policy)
+psa_algorithm_t psa_key_policy_get_algorithm( psa_key_policy_t *policy )
{
return( policy->alg );
}
-psa_status_t psa_set_key_policy(psa_key_slot_t key,
- const psa_key_policy_t *policy)
+psa_status_t psa_set_key_policy( psa_key_slot_t key,
+ const psa_key_policy_t *policy )
{
key_slot_t *slot;
@@ -2051,8 +2054,8 @@
return( PSA_ERROR_OCCUPIED_SLOT );
if( ( policy->usage & ~( PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_ENCRYPT
- | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_SIGN
- | PSA_KEY_USAGE_VERIFY ) ) != 0 )
+ | PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_SIGN
+ | PSA_KEY_USAGE_VERIFY ) ) != 0 )
return( PSA_ERROR_INVALID_ARGUMENT );
slot->policy = *policy;
@@ -2060,8 +2063,8 @@
return( PSA_SUCCESS );
}
-psa_status_t psa_get_key_policy(psa_key_slot_t key,
- psa_key_policy_t *policy)
+psa_status_t psa_get_key_policy( psa_key_slot_t key,
+ psa_key_policy_t *policy )
{
key_slot_t *slot;
@@ -2081,8 +2084,8 @@
/* Key Lifetime */
/****************************************************************/
-psa_status_t psa_get_key_lifetime(psa_key_slot_t key,
- psa_key_lifetime_t *lifetime)
+psa_status_t psa_get_key_lifetime( psa_key_slot_t key,
+ psa_key_lifetime_t *lifetime )
{
key_slot_t *slot;
@@ -2096,8 +2099,8 @@
return( PSA_SUCCESS );
}
-psa_status_t psa_set_key_lifetime(psa_key_slot_t key,
- const psa_key_lifetime_t lifetime)
+psa_status_t psa_set_key_lifetime( psa_key_slot_t key,
+ const psa_key_lifetime_t lifetime )
{
key_slot_t *slot;
@@ -2146,7 +2149,7 @@
size_t tag_length;
mbedtls_cipher_id_t cipher_id;
const mbedtls_cipher_info_t *cipher_info = NULL;
-
+
*ciphertext_length = 0;
status = psa_get_key_information( key, &key_type, &key_bits );
@@ -2154,18 +2157,18 @@
return( status );
slot = &global_data.key_slots[key];
if( slot->type == PSA_KEY_TYPE_NONE )
- return( PSA_ERROR_EMPTY_SLOT );
+ return( PSA_ERROR_EMPTY_SLOT );
cipher_info = mbedtls_cipher_info_from_psa( alg, key_type,
key_bits, &cipher_id );
if( cipher_info == NULL )
- return( PSA_ERROR_NOT_SUPPORTED );
+ return( PSA_ERROR_NOT_SUPPORTED );
if( !( slot->policy.usage & PSA_KEY_USAGE_ENCRYPT ) )
return( PSA_ERROR_NOT_PERMITTED );
- if ( ( key_type & PSA_KEY_TYPE_CATEGORY_MASK ) !=
- PSA_KEY_TYPE_CATEGORY_SYMMETRIC )
+ if( ( key_type & PSA_KEY_TYPE_CATEGORY_MASK ) !=
+ PSA_KEY_TYPE_CATEGORY_SYMMETRIC )
return( PSA_ERROR_INVALID_ARGUMENT );
if( alg == PSA_ALG_GCM )
@@ -2238,13 +2241,13 @@
{
return( PSA_ERROR_NOT_SUPPORTED );
}
-
+
if( ret != 0 )
{
memset( ciphertext, 0, ciphertext_size );
return( mbedtls_to_psa_error( ret ) );
}
-
+
*ciphertext_length = plaintext_length + tag_length;
return( PSA_SUCCESS );
}
@@ -2291,7 +2294,7 @@
size_t tag_length;
mbedtls_cipher_id_t cipher_id;
const mbedtls_cipher_info_t *cipher_info = NULL;
-
+
*plaintext_length = 0;
status = psa_get_key_information( key, &key_type, &key_bits );
@@ -2299,18 +2302,18 @@
return( status );
slot = &global_data.key_slots[key];
if( slot->type == PSA_KEY_TYPE_NONE )
- return( PSA_ERROR_EMPTY_SLOT );
+ return( PSA_ERROR_EMPTY_SLOT );
cipher_info = mbedtls_cipher_info_from_psa( alg, key_type,
key_bits, &cipher_id );
if( cipher_info == NULL )
- return( PSA_ERROR_NOT_SUPPORTED );
-
+ return( PSA_ERROR_NOT_SUPPORTED );
+
if( !( slot->policy.usage & PSA_KEY_USAGE_DECRYPT ) )
return( PSA_ERROR_NOT_PERMITTED );
- if ( ( key_type & PSA_KEY_TYPE_CATEGORY_MASK ) !=
- PSA_KEY_TYPE_CATEGORY_SYMMETRIC )
+ if( ( key_type & PSA_KEY_TYPE_CATEGORY_MASK ) !=
+ PSA_KEY_TYPE_CATEGORY_SYMMETRIC )
return( PSA_ERROR_INVALID_ARGUMENT );
if( alg == PSA_ALG_GCM )
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index cb9301a..5a68074 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -4,9 +4,9 @@
#include "mbedtls/md.h"
#if(UINT32_MAX > SIZE_MAX)
-#define PSA_CRYPTO_TEST_SIZE_T_RANGE(x) ((x) <= SIZE_MAX)
+#define PSA_CRYPTO_TEST_SIZE_T_RANGE( x ) ( ( x ) <= SIZE_MAX )
#else
-#define PSA_CRYPTO_TEST_SIZE_T_RANGE(x) 1
+#define PSA_CRYPTO_TEST_SIZE_T_RANGE( x ) 1
#endif
/* END_HEADER */
@@ -16,7 +16,7 @@
*/
/* BEGIN_CASE */
-void init_deinit()
+void init_deinit( )
{
psa_status_t status;
int i;
@@ -148,11 +148,11 @@
/* BEGIN_CASE */
void import_export_public_key( data_t *data,
- int type_arg,
- int alg_arg,
- int expected_bits,
- int public_key_expected_length,
- int expected_export_status )
+ int type_arg,
+ int alg_arg,
+ int expected_bits,
+ int public_key_expected_length,
+ int expected_export_status )
{
int slot = 1;
psa_key_type_t type = type_arg;
@@ -182,18 +182,18 @@
/* Import the key */
TEST_ASSERT( psa_import_key( slot, type,
data->x, (size_t) data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
/* Test the key information */
TEST_ASSERT( psa_get_key_information( slot,
- &got_type, &got_bits ) == PSA_SUCCESS );
+ &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 );
+ exported, export_size,
+ &exported_length );
TEST_ASSERT( status == (psa_status_t) expected_export_status );
if( status != PSA_SUCCESS )
goto destroy;
@@ -230,7 +230,7 @@
TEST_ASSERT( psa_hash_start( &operation, alg ) == PSA_SUCCESS );
TEST_ASSERT( psa_hash_update( &operation,
input->x, (size_t) input->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
TEST_ASSERT( psa_hash_finish( &operation,
actual_hash, sizeof( actual_hash ),
&actual_hash_length ) == PSA_SUCCESS );
@@ -259,11 +259,11 @@
TEST_ASSERT( psa_hash_start( &operation, alg ) == PSA_SUCCESS );
TEST_ASSERT( psa_hash_update( &operation,
input->x, (size_t) input->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
TEST_ASSERT( psa_hash_verify( &operation,
expected_hash->x,
(size_t) expected_hash->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
exit:
mbedtls_psa_crypto_free( );
@@ -305,7 +305,7 @@
TEST_ASSERT( psa_destroy_key( key_slot ) == PSA_SUCCESS );
TEST_ASSERT( psa_mac_update( &operation,
input->x, (size_t) input->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
TEST_ASSERT( psa_mac_verify( &operation,
expected_mac->x,
(size_t) expected_mac->len ) == PSA_SUCCESS );
@@ -441,7 +441,7 @@
TEST_ASSERT( total_output_length == (size_t) expected_output->len );
TEST_ASSERT( memcmp( expected_output->x, output,
- (size_t) expected_output->len ) == 0 );
+ (size_t) expected_output->len ) == 0 );
exit:
mbedtls_free( output );
@@ -510,8 +510,8 @@
TEST_ASSERT( psa_cipher_abort( &operation ) == PSA_SUCCESS );
TEST_ASSERT( total_output_length == (size_t) expected_output->len );
- TEST_ASSERT( memcmp( expected_output->x, output,
- (size_t) expected_output->len ) == 0 );
+ TEST_ASSERT( memcmp( expected_output->x, output,
+ (size_t) expected_output->len ) == 0 );
exit:
mbedtls_free( output );
@@ -776,8 +776,8 @@
/* BEGIN_CASE */
void aead_encrypt_decrypt( int key_type_arg, data_t * key_data,
- int alg_arg, data_t * input_data, data_t * nonce,
- data_t * additional_data, int expected_result_arg )
+ int alg_arg, data_t * input_data, data_t * nonce,
+ data_t * additional_data, int expected_result_arg )
{
int slot = 1;
psa_key_type_t key_type = key_type_arg;
@@ -816,13 +816,13 @@
key_data->x, (size_t) key_data->len ) == PSA_SUCCESS );
TEST_ASSERT( psa_aead_encrypt( slot, alg,
- nonce->x, (size_t) nonce->len,
- additional_data->x,
- (size_t) additional_data->len,
- input_data->x, (size_t) input_data->len,
- output_data,
- output_size, &output_length ) ==
- expected_result );
+ nonce->x, (size_t) nonce->len,
+ additional_data->x,
+ (size_t) additional_data->len,
+ input_data->x, (size_t) input_data->len,
+ output_data,
+ output_size, &output_length ) ==
+ expected_result );
if( PSA_SUCCESS == expected_result )
{
@@ -830,18 +830,18 @@
TEST_ASSERT( output_data2 != NULL );
TEST_ASSERT( psa_aead_decrypt( slot, alg,
- nonce->x, (size_t) nonce->len,
- additional_data->x,
- (size_t) additional_data->len,
- output_data, output_length, output_data2,
- output_length, &output_length2 ) ==
- expected_result );
-
+ nonce->x, (size_t) nonce->len,
+ additional_data->x,
+ (size_t) additional_data->len,
+ output_data, output_length, output_data2,
+ output_length, &output_length2 ) ==
+ expected_result );
+
TEST_ASSERT( memcmp( input_data->x, output_data2,
- (size_t) input_data->len ) == 0 );
+ (size_t) input_data->len ) == 0 );
}
-
+
exit:
psa_destroy_key( slot );
@@ -853,9 +853,9 @@
/* BEGIN_CASE */
void aead_encrypt( int key_type_arg, data_t * key_data,
- int alg_arg, data_t * input_data,
- data_t * additional_data, data_t * nonce,
- data_t * expected_result )
+ int alg_arg, data_t * input_data,
+ data_t * additional_data, data_t * nonce,
+ data_t * expected_result )
{
int slot = 1;
psa_key_type_t key_type = key_type_arg;
@@ -880,7 +880,7 @@
output_size = (size_t) input_data->len + tag_length;
output_data = mbedtls_calloc( 1, output_size );
TEST_ASSERT( output_data != NULL );
-
+
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
psa_key_policy_init( &policy );
@@ -891,20 +891,20 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
TEST_ASSERT( psa_aead_encrypt( slot, alg,
- nonce->x, (size_t) nonce->len,
- additional_data->x,
- (size_t) additional_data->len,
- input_data->x, (size_t) input_data->len,
- output_data,
- output_size, &output_length ) == PSA_SUCCESS );
+ nonce->x, (size_t) nonce->len,
+ additional_data->x,
+ (size_t) additional_data->len,
+ input_data->x, (size_t) input_data->len,
+ output_data,
+ output_size, &output_length ) == PSA_SUCCESS );
TEST_ASSERT( memcmp( output_data, expected_result->x,
- output_length ) == 0 );
-
+ output_length ) == 0 );
+
exit:
psa_destroy_key( slot );
@@ -915,9 +915,9 @@
/* BEGIN_CASE */
void aead_decrypt( int key_type_arg, data_t * key_data,
- int alg_arg, data_t * input_data,
- data_t * additional_data, data_t * nonce,
- data_t * expected_data, int expected_result_arg )
+ int alg_arg, data_t * input_data,
+ data_t * additional_data, data_t * nonce,
+ data_t * expected_data, int expected_result_arg )
{
int slot = 1;
psa_key_type_t key_type = key_type_arg;
@@ -944,7 +944,7 @@
output_size = (size_t) input_data->len + tag_length;
output_data = mbedtls_calloc( 1, output_size );
TEST_ASSERT( output_data != NULL );
-
+
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
psa_key_policy_init( &policy );
@@ -955,24 +955,24 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
TEST_ASSERT( psa_aead_decrypt( slot, alg,
- nonce->x, (size_t) nonce->len,
- additional_data->x, (size_t) additional_data->len,
- input_data->x, (size_t) input_data->len,
- output_data,
- output_size, &output_length ) ==
- expected_result );
+ nonce->x, (size_t) nonce->len,
+ additional_data->x, (size_t) additional_data->len,
+ input_data->x, (size_t) input_data->len,
+ output_data,
+ output_size, &output_length ) ==
+ expected_result );
- if ( expected_result == PSA_SUCCESS )
+ if( expected_result == PSA_SUCCESS )
{
TEST_ASSERT( memcmp( output_data, expected_data->x,
- output_length ) == 0 );
+ output_length ) == 0 );
}
-
+
exit:
psa_destroy_key( slot );
@@ -986,7 +986,7 @@
{
psa_key_type_t type = type_arg;
psa_algorithm_t alg = alg_arg;
- size_t actual_size = PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE(type, bits, alg);
+ size_t actual_size = PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE( type, bits, alg );
TEST_ASSERT( actual_size == (size_t) expected_size_arg );
exit:
;
@@ -1039,8 +1039,8 @@
signature, signature_size,
&signature_length ) == PSA_SUCCESS );
TEST_ASSERT( signature_length == (size_t) output_data->len );
- TEST_ASSERT( memcmp( signature, output_data->x, (size_t) output_data->len )
- == 0 );
+ TEST_ASSERT( memcmp( signature, output_data->x,
+ (size_t) output_data->len ) == 0 );
exit:
psa_destroy_key( slot );
@@ -1081,7 +1081,7 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
actual_status = psa_asymmetric_sign( slot, alg,
input_data->x,
@@ -1112,14 +1112,14 @@
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
- psa_key_policy_init(& policy_set );
- psa_key_policy_init(& policy_get );
+ psa_key_policy_init( &policy_set );
+ psa_key_policy_init( &policy_get );
psa_key_policy_set_usage( &policy_set, usage_arg, alg_arg );
- TEST_ASSERT( psa_key_policy_get_usage( &policy_set ) == ( psa_key_usage_t )usage_arg );
+ TEST_ASSERT( psa_key_policy_get_usage( &policy_set ) == (psa_key_usage_t) usage_arg );
- TEST_ASSERT( psa_key_policy_get_algorithm( &policy_set) == ( psa_algorithm_t )alg_arg );
+ TEST_ASSERT( psa_key_policy_get_algorithm( &policy_set ) == (psa_algorithm_t) alg_arg );
TEST_ASSERT( psa_set_key_policy( key_slot, &policy_set ) == PSA_SUCCESS );
@@ -1159,11 +1159,13 @@
TEST_ASSERT( keypair != NULL );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( keypair->len ) );
TEST_ASSERT( psa_import_key( key_slot, PSA_KEY_TYPE_RSA_KEYPAIR,
- keypair->x, (size_t) keypair->len ) ==
- PSA_SUCCESS );
- actual_status = psa_asymmetric_sign( key_slot,
- ( psa_algorithm_t )alg_arg, NULL, 0, NULL, 0,
- NULL, 0, &signature_length );
+ keypair->x, (size_t) keypair->len ) ==
+ PSA_SUCCESS );
+ actual_status = psa_asymmetric_sign( key_slot,
+ (psa_algorithm_t) alg_arg,
+ NULL, 0,
+ NULL, 0,
+ NULL, 0, &signature_length );
}
if( usage_arg & PSA_KEY_USAGE_SIGN )
@@ -1171,8 +1173,8 @@
TEST_ASSERT( keypair != NULL );
TEST_ASSERT( PSA_CRYPTO_TEST_SIZE_T_RANGE( keypair->len ) );
TEST_ASSERT( psa_import_key( key_slot, PSA_KEY_TYPE_RSA_KEYPAIR,
- keypair->x, (size_t) keypair->len ) ==
- PSA_SUCCESS );
+ keypair->x, (size_t) keypair->len ) ==
+ PSA_SUCCESS );
actual_status = psa_export_key( key_slot, NULL, 0, NULL );
}
@@ -1198,13 +1200,13 @@
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
TEST_ASSERT( psa_set_key_lifetime( key_slot,
- lifetime_set ) == PSA_SUCCESS );
+ lifetime_set ) == PSA_SUCCESS );
TEST_ASSERT( psa_import_key( key_slot, key_type,
key, sizeof( key ) ) == PSA_SUCCESS );
TEST_ASSERT( psa_get_key_lifetime( key_slot,
- &lifetime_get ) == PSA_SUCCESS );
+ &lifetime_get ) == PSA_SUCCESS );
TEST_ASSERT( lifetime_get == lifetime_set );
@@ -1265,14 +1267,14 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
TEST_ASSERT( psa_asymmetric_verify( slot, alg,
hash_data->x, (size_t) hash_data->len,
NULL, 0,
signature_data->x,
(size_t) signature_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
exit:
psa_destroy_key( slot );
mbedtls_psa_crypto_free( );
@@ -1310,13 +1312,13 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
actual_status = psa_asymmetric_verify( slot, alg,
- hash_data->x, (size_t) hash_data->len,
- NULL, 0,
- signature_data->x,
- (size_t) signature_data->len );
+ hash_data->x, (size_t) hash_data->len,
+ NULL, 0,
+ signature_data->x,
+ (size_t) signature_data->len );
TEST_ASSERT( actual_status == expected_status );
@@ -1363,28 +1365,28 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
/* We test encryption by checking that encrypt-then-decrypt gives back
* the original plaintext because of the non-optional random
* part of encryption process which prevents using fixed vectors. */
- TEST_ASSERT( psa_asymmetric_encrypt(slot, alg,
- input_data->x,
- (size_t) input_data->len,
- NULL, 0,
- output,
- output_size,
- &output_length) == PSA_SUCCESS );
+ TEST_ASSERT( psa_asymmetric_encrypt( slot, alg,
+ input_data->x,
+ (size_t) input_data->len,
+ NULL, 0,
+ output,
+ output_size,
+ &output_length ) == PSA_SUCCESS );
- TEST_ASSERT( psa_asymmetric_decrypt(slot, alg,
- output,
- output_length,
- NULL, 0,
- output2,
- output2_size,
- &output2_length) == PSA_SUCCESS );
+ TEST_ASSERT( psa_asymmetric_decrypt( slot, alg,
+ output,
+ output_length,
+ NULL, 0,
+ output2,
+ output2_size,
+ &output2_length ) == PSA_SUCCESS );
TEST_ASSERT( memcmp( input_data->x, output2, (size_t) input_data->len )
- == 0 );
+ == 0 );
exit:
psa_destroy_key( slot );
@@ -1398,8 +1400,8 @@
/* BEGIN_CASE */
void asymmetric_encrypt_fail( int key_type_arg, data_t *key_data,
- int alg_arg, data_t *input_data,
- int expected_status_arg )
+ int alg_arg, data_t *input_data,
+ int expected_status_arg )
{
@@ -1430,15 +1432,15 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
- actual_status = psa_asymmetric_encrypt(slot, alg,
- input_data->x,
- (size_t) input_data->len,
- NULL, 0,
- output,
- output_size,
- &output_length);
+ actual_status = psa_asymmetric_encrypt( slot, alg,
+ input_data->x,
+ (size_t) input_data->len,
+ NULL, 0,
+ output,
+ output_size,
+ &output_length );
TEST_ASSERT( actual_status == expected_status );
exit:
@@ -1481,17 +1483,17 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
TEST_ASSERT( psa_asymmetric_decrypt( slot, alg,
- input_data->x,
- (size_t) input_data->len,
- NULL, 0,
- output,
- output_size,
- &output_length) == PSA_SUCCESS );
- TEST_ASSERT( ((size_t)expected_size) == output_length );
- TEST_ASSERT( memcmp( expected_data->x, output, (output_length) ) == 0 );
+ input_data->x,
+ (size_t) input_data->len,
+ NULL, 0,
+ output,
+ output_size,
+ &output_length ) == PSA_SUCCESS );
+ TEST_ASSERT( ( (size_t) expected_size ) == output_length );
+ TEST_ASSERT( memcmp( expected_data->x, output, ( output_length ) ) == 0 );
exit:
psa_destroy_key( slot );
@@ -1505,8 +1507,8 @@
/* BEGIN_CASE */
void asymmetric_decrypt_fail( int key_type_arg, data_t *key_data,
- int alg_arg, data_t *input_data,
- int expected_status_arg )
+ int alg_arg, data_t *input_data,
+ int expected_status_arg )
{
int slot = 1;
@@ -1536,20 +1538,20 @@
TEST_ASSERT( psa_import_key( slot, key_type,
key_data->x, (size_t) key_data->len ) ==
- PSA_SUCCESS );
+ PSA_SUCCESS );
- actual_status = psa_asymmetric_decrypt(slot, alg,
- input_data->x,
- (size_t) input_data->len,
- NULL, 0,
- output,
- output_size,
- &output_length);
+ actual_status = psa_asymmetric_decrypt( slot, alg,
+ input_data->x,
+ (size_t) input_data->len,
+ NULL, 0,
+ output,
+ output_size,
+ &output_length );
TEST_ASSERT( actual_status == expected_status );
exit:
psa_destroy_key( slot );
- mbedtls_free( output);
+ mbedtls_free( output );
mbedtls_psa_crypto_free( );
}
/* END_CASE */