mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-13 09:05:08 -04:00
Add missing state test coverage
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
481be341ef
commit
374a2be588
@ -3938,6 +3938,28 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
|||||||
|
|
||||||
psa_aead_abort( &operation );
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
|
/* ------------------------------------------------------- */
|
||||||
|
|
||||||
|
operation = psa_aead_operation_init( );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_aead_decrypt_setup( &operation, key, alg ),
|
||||||
|
PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
|
/* ------------------------------------------------------- */
|
||||||
|
|
||||||
|
operation = psa_aead_operation_init( );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_decrypt_setup( &operation, key, alg ) );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_aead_encrypt_setup( &operation, key, alg ),
|
||||||
|
PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
/* Test for not setting a nonce. */
|
/* Test for not setting a nonce. */
|
||||||
|
|
||||||
operation = psa_aead_operation_init( );
|
operation = psa_aead_operation_init( );
|
||||||
@ -3963,6 +3985,54 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
|||||||
|
|
||||||
psa_aead_abort( &operation );
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
|
/* Test for double generating nonce. */
|
||||||
|
|
||||||
|
operation = psa_aead_operation_init( );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer,
|
||||||
|
PSA_AEAD_NONCE_MAX_SIZE,
|
||||||
|
&nonce_length ) );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer,
|
||||||
|
PSA_AEAD_NONCE_MAX_SIZE,
|
||||||
|
&nonce_length ),
|
||||||
|
PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
|
|
||||||
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
|
/* Test for generate nonce then set and vice versa */
|
||||||
|
|
||||||
|
operation = psa_aead_operation_init( );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||||
|
|
||||||
|
PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer,
|
||||||
|
PSA_AEAD_NONCE_MAX_SIZE,
|
||||||
|
&nonce_length ) );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_aead_set_nonce( &operation, nonce->x, nonce->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 ) );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_aead_generate_nonce( &operation, nonce_buffer,
|
||||||
|
PSA_AEAD_NONCE_MAX_SIZE,
|
||||||
|
&nonce_length ),
|
||||||
|
PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
|
psa_aead_abort( &operation );
|
||||||
|
|
||||||
/* Test for generating nonce in decrypt setup. */
|
/* Test for generating nonce in decrypt setup. */
|
||||||
|
|
||||||
operation = psa_aead_operation_init( );
|
operation = psa_aead_operation_init( );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user