Introduce PSA_KEY_HANDLE_INIT macro
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function
index c6041b2..22bf0e7 100644
--- a/tests/suites/test_suite_pk.function
+++ b/tests/suites/test_suite_pk.function
@@ -151,7 +151,7 @@
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
- TEST_ASSERT( mbedtls_pk_setup_opaque( &pk, 0 ) ==
+ TEST_ASSERT( mbedtls_pk_setup_opaque( &pk, PSA_KEY_HANDLE_INIT ) ==
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
mbedtls_pk_free( &pk );
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index fc563cb..3c4d7c8 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -298,7 +298,7 @@
psa_mac_operation_t *operation,
psa_status_t *status )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
@@ -333,7 +333,7 @@
psa_cipher_operation_t *operation,
psa_status_t *status )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
@@ -1452,7 +1452,7 @@
{
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = type_arg;
psa_key_usage_t usage = usage_arg;
psa_algorithm_t alg = alg_arg;
@@ -1496,7 +1496,7 @@
{
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = type_arg;
size_t attr_bits = attr_bits_arg;
psa_status_t expected_status = expected_status_arg;
@@ -1536,7 +1536,7 @@
size_t byte_size = byte_size_arg;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t expected_status = expected_status_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status;
uint8_t *buffer = NULL;
size_t buffer_size = byte_size + 1;
@@ -1580,7 +1580,7 @@
/* BEGIN_CASE */
void import_rsa_made_up( int bits_arg, int keypair, int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
size_t bits = bits_arg;
psa_status_t expected_status = expected_status_arg;
psa_status_t status;
@@ -1624,7 +1624,7 @@
int expected_export_status_arg,
int canonical_input )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = type_arg;
psa_algorithm_t alg = alg_arg;
psa_status_t expected_export_status = expected_export_status_arg;
@@ -1717,7 +1717,7 @@
int expected_export_status_arg,
data_t *expected_public_key )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = type_arg;
psa_algorithm_t alg = alg_arg;
psa_status_t expected_export_status = expected_export_status_arg;
@@ -1768,7 +1768,7 @@
int bits_arg,
int alg_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = type_arg;
size_t bits = bits_arg;
psa_algorithm_t alg = alg_arg;
@@ -1810,7 +1810,7 @@
int usage_arg, int expected_usage_arg,
int alg_arg, int expected_alg_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = type_arg;
psa_key_type_t expected_key_type = expected_type_arg;
size_t bits = bits_arg;
@@ -1896,7 +1896,7 @@
data_t *key_data,
int exercise_alg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_mac_operation_t operation = PSA_MAC_OPERATION_INIT;
psa_status_t status;
@@ -1941,7 +1941,7 @@
data_t *key_data,
int exercise_alg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT;
psa_status_t status;
@@ -1986,7 +1986,7 @@
int tag_length_arg,
int exercise_alg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t status;
unsigned char nonce[16] = {0};
@@ -2045,7 +2045,7 @@
data_t *key_data,
int exercise_alg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t status;
size_t key_bits;
@@ -2108,7 +2108,7 @@
int exercise_alg,
int payload_length_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t status;
unsigned char payload[PSA_HASH_MAX_SIZE] = {1};
@@ -2161,7 +2161,7 @@
data_t *key_data,
int exercise_alg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_status_t status;
@@ -2211,7 +2211,7 @@
int exercise_alg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t key_type = key_type_arg;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -2243,7 +2243,7 @@
void key_policy_alg2( int key_type_arg, data_t *key_data,
int usage_arg, int alg_arg, int alg2_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -2284,7 +2284,7 @@
int exercise_alg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t key_type = key_type_arg;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -2326,8 +2326,8 @@
psa_key_usage_t expected_usage = expected_usage_arg;
psa_algorithm_t expected_alg = expected_alg_arg;
psa_algorithm_t expected_alg2 = expected_alg2_arg;
- psa_key_handle_t source_handle = 0;
- psa_key_handle_t target_handle = 0;
+ psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
uint8_t *export_buffer = NULL;
PSA_ASSERT( psa_crypto_init( ) );
@@ -2404,8 +2404,8 @@
{
psa_key_attributes_t source_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t target_attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_handle_t source_handle = 0;
- psa_key_handle_t target_handle = 0;
+ psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
PSA_ASSERT( psa_crypto_init( ) );
@@ -2909,7 +2909,7 @@
/* BEGIN_CASE */
void mac_bad_order( )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = PSA_KEY_TYPE_HMAC;
psa_algorithm_t alg = PSA_ALG_HMAC(PSA_ALG_SHA_256);
const uint8_t key[] = {
@@ -3036,7 +3036,7 @@
data_t *input,
data_t *expected_mac )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
psa_mac_operation_t operation = PSA_MAC_OPERATION_INIT;
@@ -3110,7 +3110,7 @@
data_t *input,
data_t *expected_mac )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
psa_mac_operation_t operation = PSA_MAC_OPERATION_INIT;
@@ -3264,7 +3264,7 @@
/* BEGIN_CASE */
void cipher_bad_order( )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = PSA_KEY_TYPE_AES;
psa_algorithm_t alg = PSA_ALG_CBC_PKCS7;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -3420,7 +3420,7 @@
data_t *input, data_t *expected_output,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
@@ -3487,7 +3487,7 @@
int output1_length_arg, int output2_length_arg,
data_t *expected_output )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t first_part_size = first_part_size_arg;
@@ -3560,8 +3560,7 @@
int output1_length_arg, int output2_length_arg,
data_t *expected_output )
{
- psa_key_handle_t handle = 0;
-
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t first_part_size = first_part_size_arg;
@@ -3633,7 +3632,7 @@
data_t *input, data_t *expected_output,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
@@ -3697,7 +3696,7 @@
data_t *key,
data_t *input )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
unsigned char iv[16] = {0};
@@ -3790,7 +3789,7 @@
data_t *input,
int first_part_size_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t first_part_size = first_part_size_arg;
@@ -3903,7 +3902,7 @@
data_t *input_data,
int expected_result_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
unsigned char *output_data = NULL;
@@ -3979,7 +3978,7 @@
data_t *input_data,
data_t *expected_result )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
unsigned char *output_data = NULL;
@@ -4030,7 +4029,7 @@
data_t *expected_data,
int expected_result_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
unsigned char *output_data = NULL;
@@ -4103,7 +4102,7 @@
int alg_arg, data_t *input_data,
data_t *output_data )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t key_bits;
@@ -4164,7 +4163,7 @@
int alg_arg, data_t *input_data,
int signature_size_arg, int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t signature_size = signature_size_arg;
@@ -4218,7 +4217,7 @@
void sign_verify( int key_type_arg, data_t *key_data,
int alg_arg, data_t *input_data )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t key_bits;
@@ -4285,7 +4284,7 @@
int alg_arg, data_t *hash_data,
data_t *signature_data )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -4326,7 +4325,7 @@
data_t *signature_data,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
psa_status_t actual_status;
@@ -4370,7 +4369,7 @@
int expected_output_length_arg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t expected_output_length = expected_output_length_arg;
@@ -4437,7 +4436,7 @@
data_t *input_data,
data_t *label )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t key_bits;
@@ -4503,7 +4502,7 @@
data_t *label,
data_t *expected_data )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
unsigned char *output = NULL;
@@ -4566,7 +4565,7 @@
int output_size_arg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
unsigned char *output = NULL;
@@ -4705,12 +4704,14 @@
expected_status_arg2,
expected_status_arg3};
data_t *inputs[] = {input1, input2, input3};
- psa_key_handle_t handles[] = {0, 0, 0};
+ psa_key_handle_t handles[] = { PSA_KEY_HANDLE_INIT,
+ PSA_KEY_HANDLE_INIT,
+ PSA_KEY_HANDLE_INIT};
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
size_t i;
psa_key_type_t output_key_type = output_key_type_arg;
- psa_key_handle_t output_handle = 0;
+ psa_key_handle_t output_handle = PSA_KEY_HANDLE_INIT;
psa_status_t expected_output_status = expected_output_status_arg;
psa_status_t actual_output_status;
@@ -4784,7 +4785,7 @@
void test_derive_invalid_key_derivation_state( int alg_arg )
{
psa_algorithm_t alg = alg_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
size_t key_type = PSA_KEY_TYPE_DERIVE;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
unsigned char input1[] = "Input 1";
@@ -4872,7 +4873,9 @@
psa_algorithm_t alg = alg_arg;
psa_key_derivation_step_t steps[] = {step1_arg, step2_arg, step3_arg};
data_t *inputs[] = {input1, input2, input3};
- psa_key_handle_t handles[] = {0, 0, 0};
+ psa_key_handle_t handles[] = { PSA_KEY_HANDLE_INIT,
+ PSA_KEY_HANDLE_INIT,
+ PSA_KEY_HANDLE_INIT};
size_t requested_capacity = requested_capacity_arg;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
uint8_t *expected_outputs[2] =
@@ -4982,7 +4985,7 @@
data_t *input2,
int requested_capacity_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
size_t requested_capacity = requested_capacity_arg;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -5048,8 +5051,8 @@
int derived_usage_arg,
int derived_alg_arg )
{
- psa_key_handle_t base_handle = 0;
- psa_key_handle_t derived_handle = 0;
+ psa_key_handle_t base_handle = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t derived_handle = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
psa_key_type_t derived_type = derived_type_arg;
size_t derived_bits = derived_bits_arg;
@@ -5107,8 +5110,8 @@
int bytes1_arg,
int bytes2_arg )
{
- psa_key_handle_t base_handle = 0;
- psa_key_handle_t derived_handle = 0;
+ psa_key_handle_t base_handle = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t derived_handle = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
size_t bytes1 = bytes1_arg;
size_t bytes2 = bytes2_arg;
@@ -5186,8 +5189,8 @@
int type_arg, int bits_arg,
int expected_status_arg )
{
- psa_key_handle_t base_handle = 0;
- psa_key_handle_t derived_handle = 0;
+ psa_key_handle_t base_handle = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t derived_handle = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
psa_key_type_t type = type_arg;
size_t bits = bits_arg;
@@ -5231,7 +5234,7 @@
data_t *our_key_data, data_t *peer_key_data,
int expected_status_arg )
{
- psa_key_handle_t our_key = 0;
+ psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
psa_algorithm_t our_key_alg = our_key_alg_arg;
psa_key_type_t our_key_type = our_key_type_arg;
@@ -5280,7 +5283,7 @@
data_t *peer_key_data,
data_t *expected_output )
{
- psa_key_handle_t our_key = 0;
+ psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
psa_key_type_t our_key_type = our_key_type_arg;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -5317,7 +5320,7 @@
data_t *peer_key_data,
int expected_capacity_arg )
{
- psa_key_handle_t our_key = 0;
+ psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
psa_key_type_t our_key_type = our_key_type_arg;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -5377,7 +5380,7 @@
data_t *peer_key_data,
data_t *expected_output1, data_t *expected_output2 )
{
- psa_key_handle_t our_key = 0;
+ psa_key_handle_t our_key = PSA_KEY_HANDLE_INIT;
psa_algorithm_t alg = alg_arg;
psa_key_type_t our_key_type = our_key_type_arg;
psa_key_derivation_operation_t operation = PSA_KEY_DERIVATION_OPERATION_INIT;
@@ -5491,7 +5494,7 @@
int alg_arg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = type_arg;
psa_key_usage_t usage = usage_arg;
size_t bits = bits_arg;
@@ -5533,7 +5536,7 @@
data_t *e_arg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = PSA_KEY_TYPE_RSA_KEY_PAIR;
size_t bits = bits_arg;
psa_key_usage_t usage = PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT;
@@ -5639,8 +5642,8 @@
{
mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make( 1, 1 );
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_handle_t handle = 0;
- psa_key_handle_t base_key = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t base_key = PSA_KEY_HANDLE_INIT;
psa_key_type_t type = type_arg;
size_t bits = bits_arg;
psa_key_usage_t usage_flags = usage_flags_arg;
@@ -5704,7 +5707,7 @@
&handle ) );
PSA_ASSERT( psa_key_derivation_abort( &operation ) );
PSA_ASSERT( psa_destroy_key( base_key ) );
- base_key = 0;
+ base_key = PSA_KEY_HANDLE_INIT;
}
break;
}
diff --git a/tests/suites/test_suite_psa_crypto_driver_wrappers.function b/tests/suites/test_suite_psa_crypto_driver_wrappers.function
index a0140d2..53df781 100644
--- a/tests/suites/test_suite_psa_crypto_driver_wrappers.function
+++ b/tests/suites/test_suite_psa_crypto_driver_wrappers.function
@@ -19,7 +19,7 @@
{
psa_status_t force_status = force_status_arg;
psa_status_t expected_status = expected_status_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_algorithm_t alg = PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 );
uint8_t signature[64];
@@ -73,7 +73,7 @@
{
psa_status_t force_status = force_status_arg;
psa_status_t expected_status = expected_status_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_algorithm_t alg = PSA_ALG_DETERMINISTIC_ECDSA( PSA_ALG_SHA_256 );
psa_status_t actual_status;
@@ -124,7 +124,7 @@
{
psa_status_t force_status = force_status_arg;
psa_status_t expected_status = expected_status_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_algorithm_t alg = PSA_ALG_ECDSA( PSA_ALG_SHA_256 );
const uint8_t *expected_output = NULL;
@@ -226,7 +226,7 @@
int force_status_arg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
@@ -319,7 +319,7 @@
int output1_length_arg, int output2_length_arg,
data_t *expected_output )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t first_part_size = first_part_size_arg;
@@ -404,8 +404,7 @@
int output1_length_arg, int output2_length_arg,
data_t *expected_output )
{
- psa_key_handle_t handle = 0;
-
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
size_t first_part_size = first_part_size_arg;
@@ -492,7 +491,7 @@
int force_status_arg,
int expected_status_arg )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
@@ -581,7 +580,7 @@
data_t *key, data_t *iv,
data_t *input )
{
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status;
psa_key_type_t key_type = key_type_arg;
psa_algorithm_t alg = alg_arg;
diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function
index 7ee17f9..a50eac4 100644
--- a/tests/suites/test_suite_psa_crypto_persistent_key.function
+++ b/tests/suites/test_suite_psa_crypto_persistent_key.function
@@ -117,7 +117,7 @@
void save_large_persistent_key( int data_length_arg, int expected_status )
{
mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make( 1, 42 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
uint8_t *data = NULL;
size_t data_length = data_length_arg;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -149,7 +149,7 @@
{
mbedtls_svc_key_id_t key_id =
mbedtls_svc_key_id_make( owner_id_arg, key_id_arg );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t first_type = (psa_key_type_t) first_type_arg;
psa_key_type_t second_type = (psa_key_type_t) second_type_arg;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -204,7 +204,7 @@
mbedtls_svc_key_id_t key_id =
mbedtls_svc_key_id_make( owner_id_arg, key_id_arg );
psa_key_type_t type = (psa_key_type_t) type_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
PSA_ASSERT( psa_crypto_init() );
@@ -254,7 +254,7 @@
{
mbedtls_svc_key_id_t key_id = mbedtls_svc_key_id_make( 1, 42 );
psa_key_type_t type = (psa_key_type_t) type_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
unsigned char *exported = NULL;
size_t export_size = data->len;
size_t exported_length;
diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.function b/tests/suites/test_suite_psa_crypto_se_driver_hal.function
index 8584e5e..68a803e 100644
--- a/tests/suites/test_suite_psa_crypto_se_driver_hal.function
+++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function
@@ -450,7 +450,7 @@
{
ram_slot_t *slot;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
(void) context;
@@ -483,7 +483,7 @@
{
ram_slot_t *slot;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
(void) context;
@@ -664,7 +664,7 @@
PSA_KEY_DERIVATION_OPERATION_INIT;
uint8_t buffer[80]; /* large enough for a public key for ECDH */
size_t length;
- psa_key_handle_t handle2 = 0;
+ psa_key_handle_t handle2 = PSA_KEY_HANDLE_INIT;
SMOKE_ASSERT( psa_get_key_attributes( handle, &attributes ) );
@@ -880,7 +880,7 @@
psa_key_lifetime_t lifetime = (psa_key_lifetime_t) lifetime_arg;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
uint8_t exported[sizeof( key_material )];
@@ -983,7 +983,7 @@
exported, exported_length );
PSA_ASSERT( psa_destroy_key( handle ) );
- handle = 0;
+ handle = PSA_KEY_HANDLE_INIT;
if( ! check_persistent_data( location,
&ram_shadow_slot_usage,
sizeof( ram_shadow_slot_usage ) ) )
@@ -1014,7 +1014,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -1072,7 +1072,7 @@
PSA_ASSERT( psa_get_key_attributes( handle, &attributes ) );
PSA_ASSERT( psa_destroy_key( handle ) );
- handle = 0;
+ handle = PSA_KEY_HANDLE_INIT;
if( ! check_persistent_data( location,
&ram_shadow_slot_usage,
sizeof( ram_shadow_slot_usage ) ) )
@@ -1098,7 +1098,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
TEST_USES_KEY_ID( id );
@@ -1148,7 +1148,7 @@
/* We're done. */
PSA_ASSERT( psa_destroy_key( handle ) );
- handle = 0;
+ handle = PSA_KEY_HANDLE_INIT;
if( ! check_persistent_data( location,
&shadow_counter, sizeof( shadow_counter ) ) )
goto exit;
@@ -1172,7 +1172,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
TEST_USES_KEY_ID( id );
@@ -1213,7 +1213,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
TEST_USES_KEY_ID( id );
@@ -1262,7 +1262,7 @@
/* We're done. */
PSA_ASSERT( psa_destroy_key( handle ) );
- handle = 0;
+ handle = PSA_KEY_HANDLE_INIT;
if( ! check_persistent_data( location,
&shadow_counter, sizeof( shadow_counter ) ) )
goto exit;
@@ -1295,8 +1295,8 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t drv_handle = 0; /* key managed by the driver */
- psa_key_handle_t sw_handle = 0; /* transparent key */
+ psa_key_handle_t drv_handle = PSA_KEY_HANDLE_INIT; /* key managed by the driver */
+ psa_key_handle_t sw_handle = PSA_KEY_HANDLE_INIT; /* transparent key */
psa_key_attributes_t sw_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t drv_attributes;
uint8_t signature[PSA_SIGNATURE_MAX_SIZE];
@@ -1462,7 +1462,7 @@
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( owner_id_arg, id_arg );
size_t bit_size = 48;
psa_key_slot_number_t wanted_slot = 0x123456789;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_status_t status;
TEST_USES_KEY_ID( id );
@@ -1518,7 +1518,7 @@
goto exit;
/* This time, destroy the key. */
PSA_ASSERT( psa_destroy_key( handle ) );
- handle = 0;
+ handle = PSA_KEY_HANDLE_INIT;
TEST_EQUAL( psa_open_key( id, &handle ),
PSA_ERROR_DOES_NOT_EXIST );
diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
index 7d4a591..0e2e203 100644
--- a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
+++ b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
@@ -333,7 +333,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -402,7 +402,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
uint8_t exported[sizeof( key_material )];
@@ -456,7 +456,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
mock_allocate_data.return_value = mock_alloc_return_value;
@@ -523,7 +523,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
uint8_t exported[sizeof( key_material )];
@@ -573,7 +573,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
psa_algorithm_t algorithm = PSA_ALG_ECDSA(PSA_ALG_SHA_256);
@@ -634,7 +634,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, 1 );
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
psa_algorithm_t algorithm = PSA_ALG_ECDSA(PSA_ALG_SHA_256);
diff --git a/tests/suites/test_suite_psa_crypto_slot_management.function b/tests/suites/test_suite_psa_crypto_slot_management.function
index fa3dd6e..bee5835 100644
--- a/tests/suites/test_suite_psa_crypto_slot_management.function
+++ b/tests/suites/test_suite_psa_crypto_slot_management.function
@@ -141,7 +141,7 @@
psa_key_usage_t usage_flags = usage_arg;
psa_key_type_t type = type_arg;
close_method_t close_method = close_method_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
PSA_ASSERT( psa_crypto_init( ) );
@@ -185,7 +185,7 @@
psa_key_usage_t usage_flags = usage_arg;
psa_key_type_t type = type_arg;
close_method_t close_method = close_method_arg;
- psa_key_handle_t handle = 0;
+ psa_key_handle_t handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t read_attributes = PSA_KEY_ATTRIBUTES_INIT;
uint8_t *reexported = NULL;
@@ -194,7 +194,7 @@
#if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
mbedtls_svc_key_id_t wrong_owner_id =
mbedtls_svc_key_id_make( owner_id_arg + 1, id_arg );
- psa_key_handle_t invalid_handle = 0;
+ psa_key_handle_t invalid_handle = PSA_KEY_HANDLE_INIT;
#endif
TEST_USES_KEY_ID( id );
@@ -319,7 +319,8 @@
{
psa_key_lifetime_t lifetime = lifetime_arg;
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( owner_id_arg, id_arg );
- psa_key_handle_t handle1 = 0, handle2 = 0;
+ psa_key_handle_t handle1 = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t handle2 = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t type1 = PSA_KEY_TYPE_RAW_DATA;
const uint8_t material1[5] = "a key";
@@ -447,7 +448,7 @@
mbedtls_svc_key_id_make( source_owner_id_arg, source_id_arg );
psa_key_usage_t source_usage = source_usage_arg;
psa_algorithm_t source_alg = source_alg_arg;
- psa_key_handle_t source_handle = 0;
+ psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t source_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t source_type = type_arg;
psa_key_lifetime_t target_lifetime = target_lifetime_arg;
@@ -455,7 +456,7 @@
mbedtls_svc_key_id_make( target_owner_id_arg, target_id_arg );
psa_key_usage_t target_usage = target_usage_arg;
psa_algorithm_t target_alg = target_alg_arg;
- psa_key_handle_t target_handle = 0;
+ psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
psa_key_attributes_t target_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_usage_t expected_usage = expected_usage_arg;
psa_algorithm_t expected_alg = expected_alg_arg;
@@ -573,14 +574,14 @@
mbedtls_svc_key_id_make( 1, source_id_arg );
psa_key_usage_t source_usage = source_usage_arg;
psa_algorithm_t source_alg = source_alg_arg;
- psa_key_handle_t source_handle = 0;
+ psa_key_handle_t source_handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t source_type = source_type_arg;
psa_key_lifetime_t target_lifetime = target_lifetime_arg;
mbedtls_svc_key_id_t target_id =
mbedtls_svc_key_id_make( 1, target_id_arg );
psa_key_usage_t target_usage = target_usage_arg;
psa_algorithm_t target_alg = target_alg_arg;
- psa_key_handle_t target_handle = 0;
+ psa_key_handle_t target_handle = PSA_KEY_HANDLE_INIT;
psa_key_type_t target_type = target_type_arg;
psa_key_handle_t new_handle = 0xdead;
uint8_t *export_buffer = NULL;
@@ -674,8 +675,8 @@
void invalid_handle( int handle_construction,
int close_status_arg, int usage_status_arg )
{
- psa_key_handle_t valid_handle = 0;
- psa_key_handle_t invalid_handle = 0;
+ psa_key_handle_t valid_handle = PSA_KEY_HANDLE_INIT;
+ psa_key_handle_t invalid_handle = PSA_KEY_HANDLE_INIT;
psa_status_t close_status = close_status_arg;
psa_status_t usage_status = usage_status_arg;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -696,7 +697,7 @@
switch( handle_construction )
{
case INVALID_HANDLE_0:
- invalid_handle = 0;
+ invalid_handle = PSA_KEY_HANDLE_INIT;
break;
case INVALID_HANDLE_UNOPENED:
/* We can't easily construct a handle that's never been opened
diff --git a/tests/suites/test_suite_x509write.function b/tests/suites/test_suite_x509write.function
index 31d6000..1dd2642 100644
--- a/tests/suites/test_suite_x509write.function
+++ b/tests/suites/test_suite_x509write.function
@@ -161,7 +161,7 @@
int cert_type )
{
mbedtls_pk_context key;
- psa_key_handle_t slot = 0;
+ psa_key_handle_t slot = PSA_KEY_HANDLE_INIT;
psa_algorithm_t md_alg_psa;
mbedtls_x509write_csr req;
unsigned char buf[4096];