Fix incorrect length check in multipart cipher tests

The output length can be equal to the input length.

This wasn't noticed at runtime because we happened to only test with
CBC with the first chunk being a partial block.
This commit is contained in:
Gilles Peskine 2019-02-19 19:22:51 +01:00
parent ee46fe7b9b
commit 3b7e084077

View file

@ -2475,7 +2475,7 @@ void cipher_encrypt_multipart( int alg_arg, int key_type_arg,
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) ); PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output, output_buffer_size ); ASSERT_ALLOC( output, output_buffer_size );
TEST_ASSERT( (unsigned int) first_part_size < input->len ); TEST_ASSERT( (unsigned int) first_part_size <= input->len );
PSA_ASSERT( psa_cipher_update( &operation, input->x, first_part_size, PSA_ASSERT( psa_cipher_update( &operation, input->x, first_part_size,
output, output_buffer_size, output, output_buffer_size,
&function_output_length ) ); &function_output_length ) );
@ -2546,7 +2546,7 @@ void cipher_decrypt_multipart( int alg_arg, int key_type_arg,
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) ); PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output, output_buffer_size ); ASSERT_ALLOC( output, output_buffer_size );
TEST_ASSERT( (unsigned int) first_part_size < input->len ); TEST_ASSERT( (unsigned int) first_part_size <= input->len );
PSA_ASSERT( psa_cipher_update( &operation, PSA_ASSERT( psa_cipher_update( &operation,
input->x, first_part_size, input->x, first_part_size,
output, output_buffer_size, output, output_buffer_size,
@ -2772,7 +2772,7 @@ void cipher_verify_output_multipart( int alg_arg,
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) ); PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
ASSERT_ALLOC( output1, output1_buffer_size ); ASSERT_ALLOC( output1, output1_buffer_size );
TEST_ASSERT( (unsigned int) first_part_size < input->len ); TEST_ASSERT( (unsigned int) first_part_size <= input->len );
PSA_ASSERT( psa_cipher_update( &operation1, input->x, first_part_size, PSA_ASSERT( psa_cipher_update( &operation1, input->x, first_part_size,
output1, output1_buffer_size, output1, output1_buffer_size,