mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-10-30 10:45:34 +03:00 
			
		
		
		
	Add tests to oversend data/ad when lengths set
Previous tests only tested when the expected lengths were set to zero. New test sends all data/ad then goes over by one byte. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
		| @@ -4467,6 +4467,24 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, | ||||
|  | ||||
|     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_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_update_ad( &operation, additional_data->x, | ||||
|                                     1 ), | ||||
|                 PSA_ERROR_INVALID_ARGUMENT ); | ||||
|  | ||||
|     psa_aead_abort( &operation ); | ||||
|  | ||||
|     /* Test for sending too much data after setting lengths. */ | ||||
|  | ||||
|     operation = psa_aead_operation_init( ); | ||||
| @@ -4484,6 +4502,29 @@ void aead_multipart_state_test( int key_type_arg, data_t *key_data, | ||||
|  | ||||
|     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_set_lengths( &operation, additional_data->len, | ||||
|                                       input_data->len ) ); | ||||
|  | ||||
|     PSA_ASSERT( psa_aead_update_ad( &operation, additional_data->x, | ||||
|                                     additional_data->len ) ); | ||||
|  | ||||
|     PSA_ASSERT( psa_aead_update( &operation, input_data->x, | ||||
|                                  input_data->len, output_data, | ||||
|                                  output_size, &output_length ) ); | ||||
|  | ||||
|     TEST_EQUAL( psa_aead_update( &operation, input_data->x, | ||||
|                                  1, output_data, | ||||
|                                  output_size, &output_length ), | ||||
|                 PSA_ERROR_INVALID_ARGUMENT ); | ||||
|  | ||||
|     psa_aead_abort( &operation ); | ||||
|  | ||||
|     /* Test sending additional data after data. */ | ||||
|  | ||||
|     operation = psa_aead_operation_init( ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user