mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-27 07:51:10 +00:00
Use local variable instead of an ouput parameter
Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
parent
52ae871b27
commit
7fbea09847
|
@ -461,38 +461,39 @@ static psa_status_t cipher_encrypt( const psa_key_attributes_t *attributes,
|
||||||
{
|
{
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
mbedtls_psa_cipher_operation_t operation = MBEDTLS_PSA_CIPHER_OPERATION_INIT;
|
mbedtls_psa_cipher_operation_t operation = MBEDTLS_PSA_CIPHER_OPERATION_INIT;
|
||||||
size_t olength;
|
size_t olength, accumulated_length;
|
||||||
|
|
||||||
status = cipher_encrypt_setup( &operation, attributes,
|
status = cipher_encrypt_setup( &operation, attributes,
|
||||||
key_buffer, key_buffer_size, alg );
|
key_buffer, key_buffer_size, alg );
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
*output_length = 0;
|
accumulated_length = 0;
|
||||||
if( operation.iv_length > 0 )
|
if( operation.iv_length > 0 )
|
||||||
{
|
{
|
||||||
status = cipher_set_iv( &operation, output, operation.iv_length );
|
status = cipher_set_iv( &operation, output, operation.iv_length );
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
*output_length = operation.iv_length;
|
accumulated_length = operation.iv_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
olength = 0;
|
|
||||||
status = cipher_update( &operation, input, input_length,
|
status = cipher_update( &operation, input, input_length,
|
||||||
output + *output_length,output_size - *output_length,
|
output + operation.iv_length,
|
||||||
|
output_size - operation.iv_length,
|
||||||
&olength );
|
&olength );
|
||||||
*output_length += olength;
|
accumulated_length += olength;
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
olength = 0;
|
status = cipher_finish( &operation, output + accumulated_length,
|
||||||
status = cipher_finish( &operation, output + *output_length,
|
output_size - accumulated_length, &olength );
|
||||||
output_size - *output_length, &olength );
|
accumulated_length += olength;
|
||||||
*output_length += olength;
|
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
*output_length = accumulated_length;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
status = cipher_abort( &operation );
|
status = cipher_abort( &operation );
|
||||||
|
@ -513,7 +514,7 @@ static psa_status_t cipher_decrypt( const psa_key_attributes_t *attributes,
|
||||||
{
|
{
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
mbedtls_psa_cipher_operation_t operation = MBEDTLS_PSA_CIPHER_OPERATION_INIT;
|
mbedtls_psa_cipher_operation_t operation = MBEDTLS_PSA_CIPHER_OPERATION_INIT;
|
||||||
size_t olength;
|
size_t olength, accumulated_length;
|
||||||
|
|
||||||
status = cipher_decrypt_setup( &operation, attributes,
|
status = cipher_decrypt_setup( &operation, attributes,
|
||||||
key_buffer, key_buffer_size, alg );
|
key_buffer, key_buffer_size, alg );
|
||||||
|
@ -527,21 +528,21 @@ static psa_status_t cipher_decrypt( const psa_key_attributes_t *attributes,
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
olength = 0;
|
|
||||||
status = cipher_update( &operation, input + operation.iv_length,
|
status = cipher_update( &operation, input + operation.iv_length,
|
||||||
input_length - operation.iv_length,
|
input_length - operation.iv_length,
|
||||||
output, output_size, &olength );
|
output, output_size, &olength );
|
||||||
*output_length = olength;
|
accumulated_length = olength;
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
olength = 0;
|
status = cipher_finish( &operation, output + accumulated_length,
|
||||||
status = cipher_finish( &operation, output + *output_length,
|
output_size - accumulated_length, &olength );
|
||||||
output_size - *output_length, &olength );
|
accumulated_length += olength;
|
||||||
*output_length += olength;
|
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
*output_length = accumulated_length;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if ( status == PSA_SUCCESS )
|
if ( status == PSA_SUCCESS )
|
||||||
status = cipher_abort( &operation );
|
status = cipher_abort( &operation );
|
||||||
|
|
Loading…
Reference in a new issue