test: psa cipher: Add unexpected IV setting/generation negative tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
f2d1199edc
commit
6c9bb0f71e
1 changed files with 11 additions and 0 deletions
|
@ -2526,6 +2526,9 @@ void cipher_encrypt_alg_without_iv( int alg_arg,
|
|||
mbedtls_svc_key_id_t key = MBEDTLS_SVC_KEY_ID_INIT;
|
||||
psa_key_type_t key_type = key_type_arg;
|
||||
psa_algorithm_t alg = alg_arg;
|
||||
psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT;
|
||||
uint8_t iv[1] = { 0x5a };
|
||||
size_t iv_length;
|
||||
unsigned char *output = NULL;
|
||||
size_t output_buffer_size = 0;
|
||||
size_t output_length = 0;
|
||||
|
@ -2543,6 +2546,14 @@ void cipher_encrypt_alg_without_iv( int alg_arg,
|
|||
PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
|
||||
&key ) );
|
||||
|
||||
PSA_ASSERT( psa_cipher_encrypt_setup( &operation, key, alg ) );
|
||||
TEST_EQUAL( psa_cipher_set_iv( &operation, iv, sizeof( iv ) ),
|
||||
PSA_ERROR_BAD_STATE );
|
||||
PSA_ASSERT( psa_cipher_encrypt_setup( &operation, key, alg ) );
|
||||
TEST_EQUAL( psa_cipher_generate_iv( &operation, iv, sizeof( iv ),
|
||||
&iv_length ),
|
||||
PSA_ERROR_BAD_STATE );
|
||||
|
||||
PSA_ASSERT( psa_cipher_encrypt( key, alg, input->x, input->len, output,
|
||||
output_buffer_size, &output_length ) );
|
||||
TEST_ASSERT( output_length <=
|
||||
|
|
Loading…
Reference in a new issue