mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 12:05:41 +01:00
Remove redundant block_size validity check
Check the value only once, as soon as we've obtained it.
This commit is contained in:
parent
f4dd8a9a19
commit
0f595f714a
@ -282,6 +282,10 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
|
|||||||
|
|
||||||
*olen = 0;
|
*olen = 0;
|
||||||
block_size = mbedtls_cipher_get_block_size( ctx );
|
block_size = mbedtls_cipher_get_block_size( ctx );
|
||||||
|
if ( 0 == block_size )
|
||||||
|
{
|
||||||
|
return( MBEDTLS_ERR_CIPHER_INVALID_CONTEXT );
|
||||||
|
}
|
||||||
|
|
||||||
if( ctx->cipher_info->mode == MBEDTLS_MODE_ECB )
|
if( ctx->cipher_info->mode == MBEDTLS_MODE_ECB )
|
||||||
{
|
{
|
||||||
@ -308,11 +312,6 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( 0 == block_size )
|
|
||||||
{
|
|
||||||
return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( input == output &&
|
if( input == output &&
|
||||||
( ctx->unprocessed_len != 0 || ilen % block_size ) )
|
( ctx->unprocessed_len != 0 || ilen % block_size ) )
|
||||||
{
|
{
|
||||||
@ -371,11 +370,6 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
|
|||||||
*/
|
*/
|
||||||
if( 0 != ilen )
|
if( 0 != ilen )
|
||||||
{
|
{
|
||||||
if( 0 == block_size )
|
|
||||||
{
|
|
||||||
return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Encryption: only cache partial blocks
|
/* Encryption: only cache partial blocks
|
||||||
* Decryption w/ padding: always keep at least one whole block
|
* Decryption w/ padding: always keep at least one whole block
|
||||||
* Decryption w/o padding: only cache partial blocks
|
* Decryption w/o padding: only cache partial blocks
|
||||||
|
Loading…
Reference in New Issue
Block a user