mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-01 04:20:45 +00:00
PSA AEAD: test long plaintext lengths for psa_set_lengths
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
1e8e1745a8
commit
e5f94fb556
@ -4895,7 +4895,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
||||
|
||||
psa_aead_abort( &operation );
|
||||
|
||||
/* Test for setting nonce after calling set lengths with UINT32_MAX length */
|
||||
/* Test for setting nonce after calling set lengths with UINT32_MAX ad_data length */
|
||||
|
||||
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||
|
||||
@ -4916,7 +4916,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
||||
|
||||
psa_aead_abort( &operation );
|
||||
|
||||
/* Test for setting nonce after calling set lengths with SIZE_MAX length */
|
||||
/* Test for setting nonce after calling set lengths with SIZE_MAX ad_data length */
|
||||
#if SIZE_MAX > UINT32_MAX
|
||||
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||
|
||||
@ -4938,7 +4938,7 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
||||
psa_aead_abort( &operation );
|
||||
#endif
|
||||
|
||||
/* Test for calling set lengths with a length too long, after setting nonce */
|
||||
/* Test for calling set lengths with an ad_data length too long, after setting nonce */
|
||||
|
||||
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||
|
||||
@ -4958,6 +4958,47 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data,
|
||||
|
||||
psa_aead_abort( &operation );
|
||||
|
||||
/* Test for setting nonce after calling set lengths with SIZE_MAX plaintext length */
|
||||
#if SIZE_MAX > UINT32_MAX
|
||||
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||
|
||||
if( operation.alg == PSA_ALG_GCM )
|
||||
{
|
||||
TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len,
|
||||
SIZE_MAX ),
|
||||
PSA_ERROR_INVALID_ARGUMENT );
|
||||
TEST_EQUAL( psa_aead_set_nonce( &operation, nonce->x, nonce->len ),
|
||||
PSA_ERROR_BAD_STATE );
|
||||
}
|
||||
else if ( operation.alg != PSA_ALG_CCM )
|
||||
{
|
||||
PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len,
|
||||
SIZE_MAX ) );
|
||||
PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) );
|
||||
}
|
||||
|
||||
psa_aead_abort( &operation );
|
||||
|
||||
/* Test for calling set lengths with an plaintext length too long, after setting nonce */
|
||||
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||
|
||||
PSA_ASSERT( psa_aead_set_nonce( &operation, nonce->x, nonce->len ) );
|
||||
|
||||
if( operation.alg == PSA_ALG_GCM )
|
||||
{
|
||||
TEST_EQUAL( psa_aead_set_lengths( &operation, additional_data->len,
|
||||
SIZE_MAX ),
|
||||
PSA_ERROR_INVALID_ARGUMENT );
|
||||
}
|
||||
else if ( operation.alg != PSA_ALG_CCM )
|
||||
{
|
||||
PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len,
|
||||
SIZE_MAX ) );
|
||||
}
|
||||
|
||||
psa_aead_abort( &operation );
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------- */
|
||||
|
||||
PSA_ASSERT( psa_aead_encrypt_setup( &operation, key, alg ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user