@@ -32,8 +32,9 @@ void format_storage_data_check( data_t *key_data,
32
32
int key_lifetime, int key_type,
33
33
int key_usage, int key_alg, int key_alg2 )
34
34
{
35
- uint8_t *file_data;
36
- size_t file_data_length;
35
+ uint8_t *file_data = NULL;
36
+ size_t file_data_length =
37
+ key_data->len + sizeof( psa_persistent_key_storage_format );;
37
38
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
38
39
39
40
psa_set_key_lifetime( &attributes, key_lifetime );
@@ -42,14 +43,15 @@ void format_storage_data_check( data_t *key_data,
42
43
psa_set_key_algorithm( &attributes, key_alg );
43
44
psa_set_key_enrollment_algorithm( &attributes, key_alg2 );
44
45
45
- file_data_length = key_data->len + sizeof( psa_persistent_key_storage_format );
46
- file_data = mbedtls_calloc( 1, file_data_length );
46
+ ASSERT_ALLOC( file_data, file_data_length );
47
47
psa_format_key_data_for_storage( key_data->x, key_data->len,
48
48
&attributes.core,
49
49
file_data );
50
50
51
51
ASSERT_COMPARE( expected_file_data->x, expected_file_data->len,
52
52
file_data, file_data_length );
53
+
54
+ exit:
53
55
mbedtls_free( file_data );
54
56
}
55
57
/* END_CASE */
0 commit comments