Remove unnecessary parameter validation from the Cipher module

This commit is contained in:
k-stachowiak 2018-12-19 17:07:02 +01:00
parent 1a9df6bcb7
commit 516897a44a
2 changed files with 0 additions and 28 deletions

View file

@ -1010,8 +1010,6 @@ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx,
CIPHER_VALIDATE_RET( ilen == 0 || input != NULL ); CIPHER_VALIDATE_RET( ilen == 0 || input != NULL );
CIPHER_VALIDATE_RET( output != NULL ); CIPHER_VALIDATE_RET( output != NULL );
CIPHER_VALIDATE_RET( olen != NULL ); CIPHER_VALIDATE_RET( olen != NULL );
if( ctx->cipher_info == NULL )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
if( ( ret = mbedtls_cipher_set_iv( ctx, iv, iv_len ) ) != 0 ) if( ( ret = mbedtls_cipher_set_iv( ctx, iv, iv_len ) ) != 0 )
return( ret ); return( ret );
@ -1048,8 +1046,6 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx,
CIPHER_VALIDATE_RET( output != NULL ); CIPHER_VALIDATE_RET( output != NULL );
CIPHER_VALIDATE_RET( olen != NULL ); CIPHER_VALIDATE_RET( olen != NULL );
CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL ); CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL );
if( ctx->cipher_info == NULL )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
#if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_GCM_C)
if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode )
@ -1105,8 +1101,6 @@ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx,
CIPHER_VALIDATE_RET( output != NULL ); CIPHER_VALIDATE_RET( output != NULL );
CIPHER_VALIDATE_RET( olen != NULL ); CIPHER_VALIDATE_RET( olen != NULL );
CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL ); CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL );
if( ctx->cipher_info == NULL )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
#if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_GCM_C)
if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode )

View file

@ -267,12 +267,6 @@ void cipher_invalid_param( )
valid_buffer, valid_size, valid_buffer, valid_size,
valid_buffer, valid_size, valid_buffer, valid_size,
valid_buffer, &size_t_var ) ); valid_buffer, &size_t_var ) );
TEST_ASSERT(
mbedtls_cipher_crypt( &invalid_ctx,
valid_buffer, valid_size,
valid_buffer, valid_size,
valid_buffer, &size_t_var ) ==
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
TEST_INVALID_PARAM_RET( TEST_INVALID_PARAM_RET(
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
mbedtls_cipher_crypt( &valid_ctx, mbedtls_cipher_crypt( &valid_ctx,
@ -308,14 +302,6 @@ void cipher_invalid_param( )
valid_buffer, valid_size, valid_buffer, valid_size,
valid_buffer, &size_t_var, valid_buffer, &size_t_var,
valid_buffer, valid_size ) ); valid_buffer, valid_size ) );
TEST_ASSERT(
mbedtls_cipher_auth_encrypt( &invalid_ctx,
valid_buffer, valid_size,
valid_buffer, valid_size,
valid_buffer, valid_size,
valid_buffer, &size_t_var,
valid_buffer, valid_size ) ==
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
TEST_INVALID_PARAM_RET( TEST_INVALID_PARAM_RET(
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
mbedtls_cipher_auth_encrypt( &valid_ctx, mbedtls_cipher_auth_encrypt( &valid_ctx,
@ -374,14 +360,6 @@ void cipher_invalid_param( )
valid_buffer, valid_size, valid_buffer, valid_size,
valid_buffer, &size_t_var, valid_buffer, &size_t_var,
valid_buffer, valid_size ) ); valid_buffer, valid_size ) );
TEST_ASSERT(
mbedtls_cipher_auth_decrypt( &invalid_ctx,
valid_buffer, valid_size,
valid_buffer, valid_size,
valid_buffer, valid_size,
valid_buffer, &size_t_var,
valid_buffer, valid_size ) ==
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
TEST_INVALID_PARAM_RET( TEST_INVALID_PARAM_RET(
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
mbedtls_cipher_auth_decrypt( &valid_ctx, mbedtls_cipher_auth_decrypt( &valid_ctx,