@@ -178,6 +178,41 @@ static psa_status_t ram_allocate( psa_drv_se_context_t *context,
178
178
/* Other test helper functions */
179
179
/****************************************************************/
180
180
181
+ /* Check that the attributes of a key reported by psa_get_key_attributes()
182
+ * are consistent with the attributes used when creating the key. */
183
+ static int check_key_attributes(
184
+ psa_key_handle_t handle,
185
+ const psa_key_attributes_t *reference_attributes )
186
+ {
187
+ int ok = 0;
188
+ psa_key_attributes_t actual_attributes = PSA_KEY_ATTRIBUTES_INIT;
189
+
190
+ PSA_ASSERT( psa_get_key_attributes( handle, &actual_attributes ) );
191
+
192
+ TEST_EQUAL( psa_get_key_id( &actual_attributes ),
193
+ psa_get_key_id( reference_attributes ) );
194
+ TEST_EQUAL( psa_get_key_lifetime( &actual_attributes ),
195
+ psa_get_key_lifetime( reference_attributes ) );
196
+ TEST_EQUAL( psa_get_key_type( &actual_attributes ),
197
+ psa_get_key_type( reference_attributes ) );
198
+ TEST_EQUAL( psa_get_key_usage_flags( &actual_attributes ),
199
+ psa_get_key_usage_flags( reference_attributes ) );
200
+ TEST_EQUAL( psa_get_key_algorithm( &actual_attributes ),
201
+ psa_get_key_algorithm( reference_attributes ) );
202
+ TEST_EQUAL( psa_get_key_enrollment_algorithm( &actual_attributes ),
203
+ psa_get_key_enrollment_algorithm( reference_attributes ) );
204
+ if( psa_get_key_bits( reference_attributes ) != 0 )
205
+ {
206
+ TEST_EQUAL( psa_get_key_bits( &actual_attributes ),
207
+ psa_get_key_bits( reference_attributes ) );
208
+ }
209
+
210
+ ok = 1;
211
+
212
+ exit:
213
+ return( ok );
214
+ }
215
+
181
216
/* Check that a function's return status is "smoke-free", i.e. that
182
217
* it's an acceptable error code when calling an API function that operates
183
218
* on a key with potentially bogus parameters. */
@@ -445,6 +480,9 @@ void key_creation_import_export( int min_slot, int restart )
445
480
/* Test that the key was created in the expected slot. */
446
481
TEST_ASSERT( ram_slots[min_slot].type == PSA_KEY_TYPE_RAW_DATA );
447
482
483
+ /* Test the key attributes and the key data. */
484
+ if( ! check_key_attributes( handle, &attributes ) )
485
+ goto exit;
448
486
PSA_ASSERT( psa_export_key( handle,
449
487
exported, sizeof( exported ),
450
488
&exported_length ) );
0 commit comments