mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 22:20:30 +00:00
Aligh finish_buffer_test vars with PSA standard
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
4023ffd275
commit
e58cb1e0cf
@ -3976,7 +3976,7 @@ exit:
|
||||
/* BEGIN_CASE */
|
||||
void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data,
|
||||
int alg_arg,
|
||||
int buffer_size,
|
||||
int finish_ciphertext_size_arg,
|
||||
data_t *nonce,
|
||||
data_t *additional_data,
|
||||
data_t *input_data,
|
||||
@ -3990,10 +3990,11 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data,
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
|
||||
psa_status_t expected_status = expected_status_arg;
|
||||
unsigned char *output_data = NULL;
|
||||
unsigned char *final_data = NULL;
|
||||
size_t output_size = 0;
|
||||
size_t output_length = 0;
|
||||
unsigned char *ciphertext = NULL;
|
||||
unsigned char *finish_ciphertext = NULL;
|
||||
size_t ciphertext_size = 0;
|
||||
size_t ciphertext_length = 0;
|
||||
size_t finish_ciphertext_size = ( size_t ) finish_ciphertext_size_arg;
|
||||
size_t tag_length = 0;
|
||||
uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE];
|
||||
|
||||
@ -4008,13 +4009,13 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data,
|
||||
|
||||
PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
|
||||
|
||||
output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len );
|
||||
ciphertext_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len );
|
||||
|
||||
ASSERT_ALLOC( output_data, output_size );
|
||||
ASSERT_ALLOC( ciphertext, ciphertext_size );
|
||||
|
||||
TEST_ASSERT( buffer_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE );
|
||||
TEST_ASSERT( finish_ciphertext_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE );
|
||||
|
||||
ASSERT_ALLOC( final_data, buffer_size );
|
||||
ASSERT_ALLOC( finish_ciphertext, finish_ciphertext_size );
|
||||
|
||||
operation = psa_aead_operation_init( );
|
||||
|
||||
@ -4037,19 +4038,20 @@ void aead_multipart_finish_buffer_test( int key_type_arg, data_t *key_data,
|
||||
additional_data->len ) );
|
||||
|
||||
PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len,
|
||||
output_data, output_size, &output_length ) );
|
||||
ciphertext, ciphertext_size, &ciphertext_length ) );
|
||||
|
||||
/* Ensure we can still complete operation. */
|
||||
status = psa_aead_finish( &operation, final_data, buffer_size,
|
||||
&output_length, tag_buffer,
|
||||
status = psa_aead_finish( &operation, finish_ciphertext,
|
||||
finish_ciphertext_size,
|
||||
&ciphertext_length, tag_buffer,
|
||||
PSA_AEAD_TAG_MAX_SIZE, &tag_length );
|
||||
|
||||
TEST_EQUAL( status, expected_status );
|
||||
|
||||
exit:
|
||||
psa_destroy_key( key );
|
||||
mbedtls_free( output_data );
|
||||
mbedtls_free( final_data );
|
||||
mbedtls_free( ciphertext );
|
||||
mbedtls_free( finish_ciphertext );
|
||||
psa_aead_abort( &operation );
|
||||
PSA_DONE( );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user