Change logic to reduce indentation

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-05-13 18:26:41 +01:00
parent e2c788d480
commit 6108ee7c2d

View file

@ -540,15 +540,15 @@ psa_status_t mbedtls_psa_aead_update_ad( mbedtls_psa_aead_operation_t
when we have the body. */ when we have the body. */
operation->ad_buffer = ( uint8_t * ) mbedtls_calloc( 1, input_length ); operation->ad_buffer = ( uint8_t * ) mbedtls_calloc( 1, input_length );
if( operation->ad_buffer ) if( operation->ad_buffer == NULL )
{ {
return( PSA_ERROR_INSUFFICIENT_MEMORY );
}
memcpy( operation->ad_buffer, input, input_length ); memcpy( operation->ad_buffer, input, input_length );
operation->ad_length = input_length; operation->ad_length = input_length;
status = PSA_SUCCESS; status = PSA_SUCCESS;
} }
else
return ( PSA_ERROR_INSUFFICIENT_MEMORY );
}
else else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305) #if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
@ -637,8 +637,11 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation,
operation->tag_buffer = operation->tag_buffer =
( uint8_t * ) mbedtls_calloc( 1, operation->tag_length ); ( uint8_t * ) mbedtls_calloc( 1, operation->tag_length );
if( operation->tag_buffer ) if( operation->tag_buffer == NULL)
{ {
return( PSA_ERROR_INSUFFICIENT_MEMORY );
}
if( operation->is_encrypt ) if( operation->is_encrypt )
{ {
/* Perform oneshot CCM encryption with additional data already /* Perform oneshot CCM encryption with additional data already
@ -668,8 +671,11 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation,
operation->body_buffer = operation->body_buffer =
( uint8_t * ) mbedtls_calloc(1, input_length ); ( uint8_t * ) mbedtls_calloc(1, input_length );
if( operation->body_buffer ) if( operation->body_buffer == NULL)
{ {
return( PSA_ERROR_INSUFFICIENT_MEMORY );
}
memcpy( operation->body_buffer, input, input_length ); memcpy( operation->body_buffer, input, input_length );
operation->body_length = input_length; operation->body_length = input_length;
@ -690,12 +696,6 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation,
else else
status = mbedtls_to_psa_error( ret ); status = mbedtls_to_psa_error( ret );
} }
else
status = PSA_ERROR_INSUFFICIENT_MEMORY;
}
}
else
status = PSA_ERROR_INSUFFICIENT_MEMORY;
} }
else else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */
@ -871,8 +871,11 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation,
temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size ); temp_buffer = ( uint8_t * ) mbedtls_calloc(1, temp_buffer_size );
if( temp_buffer ) if( temp_buffer == NULL)
{ {
return( PSA_ERROR_INSUFFICIENT_MEMORY );
}
ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm, ret = mbedtls_ccm_auth_decrypt( &operation->ctx.ccm,
operation->body_length, operation->body_length,
operation->nonce, operation->nonce,
@ -889,9 +892,6 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation,
status = mbedtls_to_psa_error( ret ); status = mbedtls_to_psa_error( ret );
do_tag_check = 0; do_tag_check = 0;
} }
}
else
status = PSA_ERROR_INSUFFICIENT_MEMORY;
/* Even if the above operation fails, we no longer need the data */ /* Even if the above operation fails, we no longer need the data */
mbedtls_free(temp_buffer); mbedtls_free(temp_buffer);