From 3b7e084077c923dea45afc28d80758d039676ea6 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 19 Feb 2019 19:22:51 +0100 Subject: [PATCH] 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. --- tests/suites/test_suite_psa_crypto.function | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 9c5dae94a9..6bb19602d3 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -2475,7 +2475,7 @@ void cipher_encrypt_multipart( int alg_arg, int key_type_arg, PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) ); 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, output, output_buffer_size, &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 ) ); 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, output, output_buffer_size, @@ -2772,7 +2772,7 @@ void cipher_verify_output_multipart( int alg_arg, PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) ); 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, output1, output1_buffer_size,