Skip to content

Commit df250ac

Browse files
committed
Parametrize key bits in import mock test
1 parent 3a58913 commit df250ac

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.data

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
SE key importing mock test
2-
mock_import:PSA_SUCCESS:PSA_SUCCESS:PSA_SUCCESS
2+
mock_import:PSA_SUCCESS:PSA_SUCCESS:0:PSA_SUCCESS
3+
4+
SE key importing mock test: max key bits
5+
mock_import:PSA_SUCCESS:PSA_SUCCESS:PSA_MAX_KEY_BITS:PSA_SUCCESS
6+
7+
SE key importing mock test: more than max key bits
8+
mock_import:PSA_SUCCESS:PSA_ERROR_NOT_SUPPORTED:PSA_MAX_KEY_BITS+1:PSA_ERROR_NOT_SUPPORTED
39

410
SE key importing mock test: alloc failed
5-
mock_import:PSA_ERROR_HARDWARE_FAILURE:PSA_SUCCESS:PSA_ERROR_HARDWARE_FAILURE
11+
mock_import:PSA_ERROR_HARDWARE_FAILURE:PSA_SUCCESS:0:PSA_ERROR_HARDWARE_FAILURE
612

713
SE key importing mock test: import failed
8-
mock_import:PSA_SUCCESS:PSA_ERROR_HARDWARE_FAILURE:PSA_ERROR_HARDWARE_FAILURE
14+
mock_import:PSA_SUCCESS:PSA_ERROR_HARDWARE_FAILURE:0:PSA_ERROR_HARDWARE_FAILURE
915

1016
SE key exporting mock test
1117
mock_export:PSA_SUCCESS:PSA_SUCCESS

tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static struct
1919
uint16_t called;
2020
psa_key_slot_number_t key_slot;
2121
psa_key_attributes_t attributes;
22+
size_t bits;
2223
size_t data_length;
2324
psa_status_t return_value;
2425
} mock_import_data;
@@ -130,7 +131,8 @@ static psa_status_t mock_import( psa_drv_se_context_t *drv_context,
130131
{
131132
(void) drv_context;
132133
(void) data;
133-
(void) bits;
134+
135+
*bits = mock_import_data.bits;
134136

135137
mock_import_data.called++;
136138
mock_import_data.key_slot = key_slot;
@@ -260,6 +262,7 @@ psa_status_t mock_destroy( psa_drv_se_context_t *context,
260262
/* BEGIN_CASE */
261263
void mock_import( int mock_alloc_return_value,
262264
int mock_import_return_value,
265+
int bits,
263266
int expected_result )
264267
{
265268
psa_drv_se_t driver;
@@ -272,6 +275,7 @@ void mock_import( int mock_alloc_return_value,
272275

273276
mock_allocate_data.return_value = mock_alloc_return_value;
274277
mock_import_data.return_value = mock_import_return_value;
278+
mock_import_data.bits = bits;
275279
memset( &driver, 0, sizeof( driver ) );
276280
memset( &key_management, 0, sizeof( key_management ) );
277281
driver.hal_version = PSA_DRV_SE_HAL_VERSION;

0 commit comments

Comments
 (0)