Fix excessive line lengths
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index a6d0cdb..4ab0c63 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3309,7 +3309,8 @@
return( PSA_ERROR_BAD_STATE );
}
- required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type, operation->alg);
+ required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type,
+ operation->alg);
if( nonce_size == 0 || nonce_size < required_nonce_size )
{
@@ -3323,7 +3324,8 @@
return status;
}
- status = psa_driver_wrapper_aead_set_nonce( operation, nonce, required_nonce_size );
+ status = psa_driver_wrapper_aead_set_nonce( operation, nonce,
+ required_nonce_size );
if( status == PSA_SUCCESS )
{
@@ -3345,7 +3347,8 @@
return( PSA_ERROR_BAD_STATE );
}
- return( psa_driver_wrapper_aead_set_nonce( operation, nonce, nonce_length ) );
+ return( psa_driver_wrapper_aead_set_nonce( operation, nonce,
+ nonce_length ) );
}
/* Declare the lengths of the message and additional data for multipart AEAD. */
@@ -3358,7 +3361,8 @@
return( PSA_ERROR_BAD_STATE );
}
- return( psa_driver_wrapper_aead_set_lengths( operation, ad_length, plaintext_length ) );
+ return( psa_driver_wrapper_aead_set_lengths( operation, ad_length,
+ plaintext_length ) );
}
/* Pass additional data to an active multipart AEAD operation. */
psa_status_t psa_aead_update_ad( psa_aead_operation_t *operation,
@@ -3370,7 +3374,8 @@
return( PSA_ERROR_BAD_STATE );
}
- return( psa_driver_wrapper_aead_update_ad( operation, input, input_length ) );
+ return( psa_driver_wrapper_aead_update_ad( operation, input,
+ input_length ) );
}
/* Encrypt or decrypt a message fragment in an active multipart AEAD
@@ -3390,7 +3395,8 @@
return( PSA_ERROR_BAD_STATE );
}
- return( psa_driver_wrapper_aead_update( operation, input, input_length, output, output_size,
+ return( psa_driver_wrapper_aead_update( operation, input, input_length,
+ output, output_size,
output_length ) );
}
@@ -3412,8 +3418,10 @@
return( PSA_ERROR_BAD_STATE );
}
- return( psa_driver_wrapper_aead_finish( operation, ciphertext, ciphertext_size,
- ciphertext_length, tag, tag_size, tag_length ) );
+ return( psa_driver_wrapper_aead_finish( operation, ciphertext,
+ ciphertext_size,
+ ciphertext_length,
+ tag, tag_size, tag_length ) );
}
/* Finish authenticating and decrypting a message in a multipart AEAD
@@ -3433,8 +3441,10 @@
return( PSA_ERROR_BAD_STATE );
}
- return( psa_driver_wrapper_aead_verify( operation, plaintext, plaintext_size, plaintext_length,
- tag, tag_length ) );
+ return( psa_driver_wrapper_aead_verify( operation, plaintext,
+ plaintext_size,
+ plaintext_length,
+ tag, tag_length ) );
}
/* Abort an AEAD operation. */
diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c
index bfa271b..f5b4dc5 100644
--- a/library/psa_crypto_aead.c
+++ b/library/psa_crypto_aead.c
@@ -355,8 +355,10 @@
/* Set the key and algorithm for a multipart authenticated encryption
* operation. */
psa_status_t mbedtls_psa_aead_encrypt_setup( psa_aead_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
+ const psa_key_attributes_t
+ *attributes,
+ const uint8_t *key_buffer,
+ size_t key_buffer_size,
psa_algorithm_t alg )
{
psa_status_t status;
@@ -376,8 +378,10 @@
/* Set the key and algorithm for a multipart authenticated decryption
* operation. */
psa_status_t mbedtls_psa_aead_decrypt_setup( psa_aead_operation_t *operation,
- const psa_key_attributes_t *attributes,
- const uint8_t *key_buffer, size_t key_buffer_size,
+ const psa_key_attributes_t
+ *attributes,
+ const uint8_t *key_buffer,
+ size_t key_buffer_size,
psa_algorithm_t alg )
{
psa_status_t status;
@@ -434,11 +438,12 @@
return( PSA_ERROR_INVALID_ARGUMENT );
}
- status = mbedtls_to_psa_error(mbedtls_chachapoly_starts( &operation->ctx.chachapoly,
- nonce,
- operation->is_encrypt ?
- MBEDTLS_CHACHAPOLY_ENCRYPT :
- MBEDTLS_CHACHAPOLY_DECRYPT ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_chachapoly_starts( &operation->ctx.chachapoly,
+ nonce,
+ operation->is_encrypt ?
+ MBEDTLS_CHACHAPOLY_ENCRYPT :
+ MBEDTLS_CHACHAPOLY_DECRYPT ) );
}
else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */
@@ -540,13 +545,14 @@
return ( PSA_ERROR_INVALID_ARGUMENT );
}
- status = mbedtls_to_psa_error( mbedtls_gcm_starts( &operation->ctx.gcm,
- operation->is_encrypt ?
- MBEDTLS_GCM_ENCRYPT : MBEDTLS_GCM_DECRYPT,
- operation->nonce,
- operation->nonce_length,
- input,
- input_length ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_gcm_starts( &operation->ctx.gcm,
+ operation->is_encrypt ?
+ MBEDTLS_GCM_ENCRYPT : MBEDTLS_GCM_DECRYPT,
+ operation->nonce,
+ operation->nonce_length,
+ input,
+ input_length ) );
}
else
@@ -581,9 +587,10 @@
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
if( operation->alg == PSA_ALG_CHACHA20_POLY1305 )
{
- status = mbedtls_to_psa_error( mbedtls_chachapoly_update_aad( &operation->ctx.chachapoly,
- input,
- input_length ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_chachapoly_update_aad( &operation->ctx.chachapoly,
+ input,
+ input_length ) );
}
else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */
@@ -676,7 +683,8 @@
}
/* Need to store tag for Finish() / Verify() */
- operation->tag_buffer = ( uint8_t * ) mbedtls_calloc(1, operation->tag_length );
+ operation->tag_buffer =
+ ( uint8_t * ) mbedtls_calloc(1, operation->tag_length );
if( operation->tag_buffer )
{
@@ -685,16 +693,17 @@
{
/* Perform oneshot CCM encryption with additional data already
stored, as CCM does not support multipart yet.*/
- status = mbedtls_to_psa_error( mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm,
- input_length,
- operation->nonce,
- operation->nonce_length,
- operation->ad_buffer,
- operation->ad_length,
- input,
- output,
- operation->tag_buffer,
- operation->tag_length ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_ccm_encrypt_and_tag( &operation->ctx.ccm,
+ input_length,
+ operation->nonce,
+ operation->nonce_length,
+ operation->ad_buffer,
+ operation->ad_length,
+ input,
+ output,
+ operation->tag_buffer,
+ operation->tag_length ) );
/* Even if the above operation fails, we no longer need the
additional data.*/
@@ -706,18 +715,22 @@
{
/* Need to back up the body data so we can do this again
later.*/
- operation->body_buffer = ( uint8_t * ) mbedtls_calloc(1, input_length );
+ operation->body_buffer =
+ ( uint8_t * ) mbedtls_calloc(1, input_length );
if( operation->body_buffer )
{
memcpy( operation->body_buffer, input, input_length );
operation->body_length = input_length;
- /* this will fail, as the tag is clearly false, but will write the
- decrypted data to the output buffer. */
- ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, input_length,
- operation->nonce, operation->nonce_length,
- operation->ad_buffer, operation->ad_length,
+ /* this will fail, as the tag is clearly false, but will
+ write the decrypted data to the output buffer.*/
+ ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm,
+ input_length,
+ operation->nonce,
+ operation->nonce_length,
+ operation->ad_buffer,
+ operation->ad_length,
input, output,
operation->tag_buffer,
operation->tag_length );
@@ -747,10 +760,11 @@
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
if( operation->alg == PSA_ALG_CHACHA20_POLY1305 )
{
- status = mbedtls_to_psa_error( mbedtls_chachapoly_update( &operation->ctx.chachapoly,
- input_length,
- input,
- output ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_chachapoly_update( &operation->ctx.chachapoly,
+ input_length,
+ input,
+ output ) );
}
else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */
@@ -772,7 +786,8 @@
/* Common checks for both mbedtls_psa_aead_finish() and
mbedtls_psa_aead_verify() */
-static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t *operation,
+static psa_status_t mbedtls_psa_aead_finish_checks( psa_aead_operation_t
+ *operation,
size_t output_size,
size_t tag_size )
{
@@ -793,13 +808,15 @@
if( operation->is_encrypt )
{
- finish_output_size = PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type,
- operation->alg );
+ finish_output_size =
+ PSA_AEAD_FINISH_OUTPUT_SIZE( operation->key_type,
+ operation->alg );
}
else
{
- finish_output_size = PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type,
- operation->alg );
+ finish_output_size =
+ PSA_AEAD_VERIFY_OUTPUT_SIZE( operation->key_type,
+ operation->alg );
}
if( output_size < finish_output_size )
@@ -822,7 +839,8 @@
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
size_t finish_output_size = 0;
- status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size, tag_size );
+ status = mbedtls_psa_aead_finish_checks( operation, ciphertext_size,
+ tag_size );
if( status != PSA_SUCCESS )
{
@@ -855,8 +873,9 @@
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
if( operation->alg == PSA_ALG_CHACHA20_POLY1305 )
{
- status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly,
- tag ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_chachapoly_finish( &operation->ctx.chachapoly,
+ tag ) );
}
else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 */
@@ -902,7 +921,8 @@
int do_tag_check = 1;
uint8_t check_tag[16];
- status = mbedtls_psa_aead_finish_checks( operation, plaintext_size, tag_length );
+ status = mbedtls_psa_aead_finish_checks( operation, plaintext_size,
+ tag_length );
if( status != PSA_SUCCESS )
{
@@ -913,9 +933,10 @@
if( operation->alg == PSA_ALG_GCM )
{
/* Call finish to get the tag for comparison */
- status = mbedtls_to_psa_error( mbedtls_gcm_finish( &operation->ctx.gcm,
- check_tag,
- operation->tag_length ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_gcm_finish( &operation->ctx.gcm,
+ check_tag,
+ operation->tag_length ) );
}
else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_GCM */
@@ -931,17 +952,22 @@
* only way to get the tag, but this time throw away the
results, as verify cannot write that much data. */
temp_buffer_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( operation->key_type,
- operation->alg, operation->body_length );
+ operation->alg,
+ operation->body_length
+ );
temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size );
if( temp_buffer )
{
- ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, operation->body_length,
- operation->nonce, operation->nonce_length,
- operation->ad_buffer, operation->ad_length,
- operation->body_buffer, temp_buffer,
- tag, tag_length );
+ ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm,
+ operation->body_length,
+ operation->nonce,
+ operation->nonce_length,
+ operation->ad_buffer,
+ operation->ad_length,
+ operation->body_buffer,
+ temp_buffer, tag, tag_length );
if( ret == MBEDTLS_ERR_CCM_AUTH_FAILED )
{
@@ -974,8 +1000,9 @@
if( operation->alg == PSA_ALG_CHACHA20_POLY1305 )
{
// call finish to get the tag for comparison.
- status = mbedtls_to_psa_error( mbedtls_chachapoly_finish( &operation->ctx.chachapoly,
- check_tag ) );
+ status = mbedtls_to_psa_error(
+ mbedtls_chachapoly_finish( &operation->ctx.chachapoly,
+ check_tag ) );
}
else
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 6ae5030..04d947f 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -3201,7 +3201,8 @@
TEST_ASSERT( tag_length <= 16 );
output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg,
- ( input_data->len + tag_length ) );
+ ( input_data->len +
+ tag_length ) );
ASSERT_ALLOC( output_data, output_size );
@@ -3224,8 +3225,9 @@
if( nonce->len == 0 )
{
- PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ),
- &nonce_length ) );
+ PSA_ASSERT( psa_aead_generate_nonce( &operation, nonce_buffer,
+ sizeof( nonce_buffer ),
+ &nonce_length ) );
}
else
{
@@ -3236,7 +3238,8 @@
#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
if( operation.alg == PSA_ALG_GCM )
{
- PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len, input_data->len ) );
+ PSA_ASSERT( psa_aead_set_lengths( &operation, additional_data->len,
+ input_data->len ) );
}
#endif
@@ -3256,7 +3259,8 @@
part_length = ad_part_len;
}
- PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x + part_offset,
+ PSA_ASSERT( psa_aead_update_ad( &operation,
+ additional_data->x + part_offset,
part_length ) );
part_offset += part_length;
@@ -3265,13 +3269,15 @@
else
{
/* Pass additional data in one go. */
- PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, additional_data->len) );
+ PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x,
+ additional_data->len) );
}
if( data_part_len != -1 )
{
/* Pass data in parts */
- part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len );
+ part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg,
+ ( size_t ) data_part_len );
ASSERT_ALLOC( part_data, part_data_size );
@@ -3288,13 +3294,16 @@
part_length = data_part_len;
}
- PSA_ASSERT( psa_aead_update( &operation, ( input_data->x + part_offset ),
+ PSA_ASSERT( psa_aead_update( &operation,
+ ( input_data->x + part_offset ),
part_length, part_data,
- part_data_size, &output_part_length ) );
+ part_data_size,
+ &output_part_length ) );
if( output_data && output_part_length )
{
- memcpy( ( output_data + part_offset ), part_data, output_part_length );
+ memcpy( ( output_data + part_offset ), part_data,
+ output_part_length );
}
part_offset += part_length;
@@ -3317,7 +3326,8 @@
if( output_data && output_part_length )
{
- memcpy( ( output_data + output_length ), final_data, output_part_length );
+ memcpy( ( output_data + output_length ), final_data,
+ output_part_length );
}
TEST_EQUAL(tag_length, tag_size);
@@ -3334,7 +3344,8 @@
/* For all currently defined algorithms, PSA_AEAD_ENCRYPT_OUTPUT_SIZE
* should be exact. */
TEST_EQUAL( output_length,
- PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) );
+ PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg,
+ input_data->len ) );
TEST_ASSERT( output_length <=
PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE( input_data->len ) );
@@ -3389,7 +3400,8 @@
PSA_ASSERT( psa_crypto_init( ) );
- psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
+ psa_set_key_usage_flags( &attributes,
+ PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
psa_set_key_algorithm( &attributes, alg );
psa_set_key_type( &attributes, key_type );
@@ -3429,7 +3441,8 @@
if( nonce->len == 0 )
{
- status = psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ),
+ status = psa_aead_generate_nonce( &operation, nonce_buffer,
+ sizeof( nonce_buffer ),
&nonce_length );
}
else
@@ -3447,7 +3460,8 @@
#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
if( operation.alg == PSA_ALG_GCM )
{
- status = psa_aead_set_lengths( &operation, additional_data->len, input_data->len );
+ status = psa_aead_set_lengths( &operation, additional_data->len,
+ input_data->len );
if( status != PSA_SUCCESS )
{
@@ -3472,7 +3486,8 @@
part_length = ad_part_len;
}
- status = psa_aead_update_ad( &operation, additional_data->x + part_offset,
+ status = psa_aead_update_ad( &operation,
+ additional_data->x + part_offset,
part_length );
if( status != PSA_SUCCESS )
@@ -3486,7 +3501,8 @@
}
else
{
- status = psa_aead_update_ad(&operation, additional_data->x, additional_data->len);
+ status = psa_aead_update_ad(&operation, additional_data->x,
+ additional_data->len);
if( status != PSA_SUCCESS )
{
@@ -3499,7 +3515,7 @@
{
/* Pass data in parts */
part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg,
- ( size_t ) data_part_len );
+ ( size_t ) data_part_len );
ASSERT_ALLOC( part_data, part_data_size );
@@ -3516,7 +3532,8 @@
part_length = data_part_len;
}
- status = psa_aead_update( &operation, ( input_data->x + part_offset ),
+ status = psa_aead_update( &operation,
+ ( input_data->x + part_offset ),
part_length, part_data,
part_data_size, &output_part_length );
@@ -3528,7 +3545,8 @@
if( output_data && output_part_length )
{
- memcpy( ( output_data + part_offset ), part_data, output_part_length );
+ memcpy( ( output_data + part_offset ), part_data,
+ output_part_length );
}
part_offset += part_length;
@@ -3562,7 +3580,8 @@
if( output_data &&output_part_length )
{
- memcpy( ( output_data + output_length ), final_data, output_part_length );
+ memcpy( ( output_data + output_length ), final_data,
+ output_part_length );
}
output_length += output_part_length;
@@ -3571,23 +3590,27 @@
* should be exact. */
if( expected_result != PSA_ERROR_INVALID_ARGUMENT )
TEST_EQUAL( ( output_length + tag_length ),
- PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) );
+ PSA_AEAD_ENCRYPT_OUTPUT_SIZE( key_type, alg,
+ input_data->len ) );
TEST_EQUAL(tag_length, tag_size);
if( PSA_SUCCESS == expected_result )
{
- output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, output_length );
+ output_size2 = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg,
+ output_length );
ASSERT_ALLOC( output_data2, output_size2 );
/* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE
* should be exact. */
TEST_EQUAL( input_data->len,
PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg,
- ( output_length + tag_length ) ) );
+ ( output_length +
+ tag_length ) ) );
TEST_ASSERT( input_data->len <=
- PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length + tag_length ) );
+ PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( output_length +
+ tag_length ) );
operation = psa_aead_operation_init();
@@ -3599,7 +3622,8 @@
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_GCM_NOT_12BYTES_NONCE( alg, nonce->len );
+ MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE( alg,
+ nonce->len );
}
TEST_EQUAL( status, expected_result );
@@ -3607,7 +3631,8 @@
if( nonce->len == 0 )
{
/* Use previously generated nonce. */
- status = psa_aead_set_nonce( &operation, nonce_buffer, nonce_length );
+ status = psa_aead_set_nonce( &operation, nonce_buffer,
+ nonce_length );
}
else
{
@@ -3623,7 +3648,8 @@
#if defined(MBEDTLS_PSA_BUILTIN_ALG_GCM)
if( operation.alg == PSA_ALG_GCM )
{
- status = psa_aead_set_lengths( &operation, additional_data->len, output_length );
+ status = psa_aead_set_lengths( &operation, additional_data->len,
+ output_length );
if( status != PSA_SUCCESS )
{
@@ -3638,7 +3664,8 @@
while( part_offset <= additional_data->len)
{
- if( additional_data->len - part_offset < ( uint32_t ) ad_part_len )
+ if( additional_data->len - part_offset <
+ ( uint32_t ) ad_part_len )
{
part_length = additional_data->len - part_offset;
}
@@ -3647,7 +3674,9 @@
part_length = ad_part_len;
}
- PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x + part_offset,
+ PSA_ASSERT( psa_aead_update_ad( &operation,
+ additional_data->x +
+ part_offset,
part_length ) );
part_offset += part_length;
@@ -3655,13 +3684,15 @@
}
else
{
- PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x, additional_data->len) );
+ PSA_ASSERT( psa_aead_update_ad(&operation, additional_data->x,
+ additional_data->len) );
}
if( data_part_len != -1 )
{
/* Pass data in parts */
- part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len );
+ part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg,
+ ( size_t ) data_part_len );
ASSERT_ALLOC( part_data, part_data_size );
@@ -3669,22 +3700,27 @@
while( part_offset <= ( input_data->len - tag_length ) )
{
- if( ( input_data->len - tag_length - part_offset ) < ( uint32_t ) data_part_len )
+ if( ( input_data->len - tag_length - part_offset ) <
+ ( uint32_t ) data_part_len )
{
- part_length = ( input_data->len - tag_length - part_offset );
+ part_length =
+ ( input_data->len - tag_length - part_offset );
}
else
{
part_length = data_part_len;
}
- PSA_ASSERT( psa_aead_update( &operation, ( input_data->x + part_offset ),
+ PSA_ASSERT( psa_aead_update( &operation,
+ ( input_data->x + part_offset ),
part_length, part_data,
- part_data_size, &output_part_length ) );
+ part_data_size,
+ &output_part_length ) );
if( output_data2 && output_part_length )
{
- memcpy( ( output_data2 + part_offset ), part_data, output_part_length );
+ memcpy( ( output_data2 + part_offset ),
+ part_data, output_part_length );
}
part_offset += part_length;
@@ -3705,7 +3741,8 @@
if( output_data2 && output_part_length )
{
- memcpy( ( output_data2 + output_length2 ), final_data, output_part_length);
+ memcpy( ( output_data2 + output_length2 ), final_data,
+ output_part_length);
}
output_length2 += output_part_length;
@@ -3772,7 +3809,8 @@
tag_length = PSA_AEAD_TAG_LENGTH( key_type, key_bits, alg );
output_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg,
- ( input_data->len - tag_length ) );
+ ( input_data->len -
+ tag_length ) );
ASSERT_ALLOC( output_data, output_size );
ASSERT_ALLOC( final_data, PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE );
@@ -3798,7 +3836,8 @@
if( nonce->len == 0 )
{
- status = psa_aead_generate_nonce( &operation, nonce_buffer, sizeof( nonce_buffer ),
+ status = psa_aead_generate_nonce( &operation, nonce_buffer,
+ sizeof( nonce_buffer ),
&nonce_length );
}
else
@@ -3842,7 +3881,8 @@
part_length = ad_part_len;
}
- status = psa_aead_update_ad( &operation, additional_data->x + part_offset,
+ status = psa_aead_update_ad( &operation,
+ additional_data->x + part_offset,
part_length );
if( status != PSA_SUCCESS )
@@ -3856,7 +3896,8 @@
}
else
{
- status = psa_aead_update_ad( &operation, additional_data->x, additional_data->len );
+ status = psa_aead_update_ad( &operation, additional_data->x,
+ additional_data->len );
if( status != PSA_SUCCESS )
{
@@ -3868,7 +3909,8 @@
if( data_part_len != -1 )
{
/* Pass data in parts */
- part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg, ( size_t ) data_part_len );
+ part_data_size = PSA_AEAD_UPDATE_OUTPUT_SIZE( key_type, alg,
+ ( size_t ) data_part_len );
ASSERT_ALLOC( part_data, part_data_size );
@@ -3876,7 +3918,8 @@
while( part_offset <= input_data->len)
{
- if( (input_data->len - tag_length - part_offset ) < ( uint32_t ) data_part_len )
+ if( (input_data->len - tag_length - part_offset ) <
+ ( uint32_t ) data_part_len )
{
part_length = ( input_data->len - tag_length - part_offset );
}
@@ -3885,9 +3928,10 @@
part_length = data_part_len;
}
- status = psa_aead_update( &operation, ( input_data->x + part_offset ),
- part_length, part_data,
- part_data_size, &output_part_length );
+ status = psa_aead_update( &operation,
+ ( input_data->x + part_offset ),
+ part_length, part_data,
+ part_data_size, &output_part_length );
if( status != PSA_SUCCESS )
{
@@ -3897,7 +3941,8 @@
if( output_data && output_part_length )
{
- memcpy( ( output_data + part_offset ), part_data, output_part_length );
+ memcpy( ( output_data + part_offset ), part_data,
+ output_part_length );
}
part_offset += part_length;
@@ -3920,7 +3965,8 @@
status = psa_aead_verify( &operation, final_data,
PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE,
&output_part_length,
- ( input_data->x + input_data->len - tag_length ),
+ ( input_data->x + input_data->len -
+ tag_length ),
tag_length );
if( status != PSA_SUCCESS )
@@ -3931,7 +3977,8 @@
if( output_data && output_part_length )
{
- memcpy( ( output_data + output_length ), final_data, output_part_length );
+ memcpy( ( output_data + output_length ), final_data,
+ output_part_length );
}
output_length += output_part_length;
@@ -3941,7 +3988,8 @@
/* For all currently defined algorithms, PSA_AEAD_DECRYPT_OUTPUT_SIZE
* should be exact. */
TEST_EQUAL( output_length,
- PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg, input_data->len ) );
+ PSA_AEAD_DECRYPT_OUTPUT_SIZE( key_type, alg,
+ input_data->len ) );
TEST_ASSERT( output_length <=
PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE( input_data->len ) );
}