mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-01 04:20:45 +00:00
Add missing aead state tests.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
5221ef638a
commit
f94bd99368
@ -4503,6 +4503,23 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
|||||||
|
|
||||||
PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) );
|
PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x,
|
||||||
|
additional_data->len ) );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len,
|
||||||
|
input_data->len ),
|
||||||
|
PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
|
/* ------------------------------------------------------- */
|
||||||
|
|
||||||
|
operation = psa_aead_operation_init( );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) );
|
||||||
|
|
||||||
PSA_ASSERT( psa_aead_update( &operation, input_data->x,
|
PSA_ASSERT( psa_aead_update( &operation, input_data->x,
|
||||||
input_data->len, output_data,
|
input_data->len, output_data,
|
||||||
output_size, &output_length ) );
|
output_size, &output_length ) );
|
||||||
@ -4574,6 +4591,29 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
|||||||
|
|
||||||
psa_aead_abort( &operation );
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
|
/* Test for not sending any data after setting a non-zero length for it.*/
|
||||||
|
|
||||||
|
operation = psa_aead_operation_init( );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len,
|
||||||
|
input_data->len ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x,
|
||||||
|
additional_data->len ) );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_aead_finish( &operation, final_data,
|
||||||
|
finish_output_size,
|
||||||
|
&output_part_length,
|
||||||
|
tag_buffer, tag_length,
|
||||||
|
&tag_size ),
|
||||||
|
PSA_ERROR_INVALID_ARGUMENT );
|
||||||
|
|
||||||
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
/* Test for sending too much additional data after setting lengths. */
|
/* Test for sending too much additional data after setting lengths. */
|
||||||
|
|
||||||
operation = psa_aead_operation_init( );
|
operation = psa_aead_operation_init( );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user