Align generate nonce variables with psa convention
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
d9343f2f0f
commit
f127763ec9
1 changed files with 23 additions and 22 deletions
|
@ -3671,8 +3671,8 @@ void aead_multipart_decrypt( int key_type_arg, data_t *key_data,
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE */
|
||||||
void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data,
|
void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data,
|
||||||
int alg_arg,
|
int alg_arg,
|
||||||
int nonce_len,
|
int nonce_length,
|
||||||
int expected_generated_len_arg,
|
int expected_nonce_length_arg,
|
||||||
data_t *additional_data,
|
data_t *additional_data,
|
||||||
data_t *input_data,
|
data_t *input_data,
|
||||||
int expected_status_arg )
|
int expected_status_arg )
|
||||||
|
@ -3686,13 +3686,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data,
|
||||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
|
psa_status_t status = PSA_ERROR_GENERIC_ERROR;
|
||||||
psa_status_t expected_status = expected_status_arg;
|
psa_status_t expected_status = expected_status_arg;
|
||||||
size_t nonce_generated_len = 0;
|
size_t actual_nonce_length = 0;
|
||||||
size_t expected_generated_len = expected_generated_len_arg;
|
size_t expected_nonce_length = expected_nonce_length_arg;
|
||||||
unsigned char *output_data = NULL;
|
unsigned char *output = NULL;
|
||||||
unsigned char *final_data = NULL;
|
unsigned char *ciphertext = NULL;
|
||||||
size_t output_size = 0;
|
size_t output_size = 0;
|
||||||
size_t finish_output_size = 0;
|
size_t ciphertext_size = 0;
|
||||||
size_t output_length = 0;
|
size_t ciphertext_length = 0;
|
||||||
size_t tag_length = 0;
|
size_t tag_length = 0;
|
||||||
uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE];
|
uint8_t tag_buffer[PSA_AEAD_TAG_MAX_SIZE];
|
||||||
|
|
||||||
|
@ -3709,13 +3709,13 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data,
|
||||||
|
|
||||||
output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len );
|
output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, input_data->len );
|
||||||
|
|
||||||
ASSERT_ALLOC( output_data, output_size );
|
ASSERT_ALLOC( output, output_size );
|
||||||
|
|
||||||
finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg );
|
ciphertext_size = PSA_AEAD_FINISH_OUTPUT_SIZE( key_type, alg );
|
||||||
|
|
||||||
TEST_ASSERT( finish_output_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE );
|
TEST_ASSERT( ciphertext_size <= PSA_AEAD_FINISH_OUTPUT_MAX_SIZE );
|
||||||
|
|
||||||
ASSERT_ALLOC( final_data, finish_output_size );
|
ASSERT_ALLOC( ciphertext, ciphertext_size );
|
||||||
|
|
||||||
operation = psa_aead_operation_init( );
|
operation = psa_aead_operation_init( );
|
||||||
|
|
||||||
|
@ -3727,20 +3727,20 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data,
|
||||||
if( status == PSA_ERROR_NOT_SUPPORTED )
|
if( status == PSA_ERROR_NOT_SUPPORTED )
|
||||||
{
|
{
|
||||||
MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 );
|
MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192( key_type, key_data->len * 8 );
|
||||||
MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_len );
|
MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg, nonce_length );
|
||||||
}
|
}
|
||||||
|
|
||||||
PSA_ASSERT( status );
|
PSA_ASSERT( status );
|
||||||
|
|
||||||
status = psa_aead_generate_nonce( &operation, nonce_buffer,
|
status = psa_aead_generate_nonce( &operation, nonce_buffer,
|
||||||
nonce_len,
|
nonce_length,
|
||||||
&nonce_generated_len );
|
&actual_nonce_length );
|
||||||
|
|
||||||
TEST_EQUAL( status, expected_status );
|
TEST_EQUAL( status, expected_status );
|
||||||
|
|
||||||
TEST_EQUAL( nonce_generated_len, expected_generated_len );
|
TEST_EQUAL( actual_nonce_length, expected_nonce_length );
|
||||||
|
|
||||||
TEST_ASSERT( nonce_generated_len < PSA_AEAD_NONCE_MAX_SIZE );
|
TEST_ASSERT( actual_nonce_length < PSA_AEAD_NONCE_MAX_SIZE );
|
||||||
|
|
||||||
if( expected_status == PSA_SUCCESS )
|
if( expected_status == PSA_SUCCESS )
|
||||||
{
|
{
|
||||||
|
@ -3751,17 +3751,18 @@ void aead_multipart_generate_nonce( int key_type_arg, data_t *key_data,
|
||||||
additional_data->len ) );
|
additional_data->len ) );
|
||||||
|
|
||||||
PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len,
|
PSA_ASSERT( psa_aead_update( &operation, input_data->x, input_data->len,
|
||||||
output_data, output_size, &output_length ) );
|
output, output_size,
|
||||||
|
&ciphertext_length ) );
|
||||||
|
|
||||||
PSA_ASSERT( psa_aead_finish( &operation, final_data, finish_output_size,
|
PSA_ASSERT( psa_aead_finish( &operation, ciphertext, ciphertext_size,
|
||||||
&output_length, tag_buffer,
|
&ciphertext_length, tag_buffer,
|
||||||
PSA_AEAD_TAG_MAX_SIZE, &tag_length ) );
|
PSA_AEAD_TAG_MAX_SIZE, &tag_length ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
psa_destroy_key( key );
|
psa_destroy_key( key );
|
||||||
mbedtls_free( output_data );
|
mbedtls_free( output );
|
||||||
mbedtls_free( final_data );
|
mbedtls_free( ciphertext );
|
||||||
psa_aead_abort( &operation );
|
psa_aead_abort( &operation );
|
||||||
PSA_DONE( );
|
PSA_DONE( );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue