mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-30 23:11:10 +00:00
Fix off-by-one in iv_off check and add tests
This commit is contained in:
parent
5b89c09273
commit
e55e103bfe
|
@ -1298,7 +1298,7 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
|
||||||
|
|
||||||
n = *iv_off;
|
n = *iv_off;
|
||||||
|
|
||||||
if( n > 16 )
|
if( n > 15 )
|
||||||
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||||
|
|
||||||
if( mode == MBEDTLS_AES_DECRYPT )
|
if( mode == MBEDTLS_AES_DECRYPT )
|
||||||
|
@ -1394,7 +1394,7 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
|
||||||
|
|
||||||
n = *iv_off;
|
n = *iv_off;
|
||||||
|
|
||||||
if( n > 16 )
|
if( n > 15 )
|
||||||
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
return( MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||||
|
|
||||||
while( length-- )
|
while( length-- )
|
||||||
|
|
|
@ -569,6 +569,7 @@ void aes_misc_params( )
|
||||||
#endif
|
#endif
|
||||||
const unsigned char in[16] = { 0 };
|
const unsigned char in[16] = { 0 };
|
||||||
unsigned char out[16];
|
unsigned char out[16];
|
||||||
|
size_t size;
|
||||||
|
|
||||||
/* These calls accept NULL */
|
/* These calls accept NULL */
|
||||||
TEST_VALID_PARAM( mbedtls_aes_free( NULL ) );
|
TEST_VALID_PARAM( mbedtls_aes_free( NULL ) );
|
||||||
|
@ -597,6 +598,19 @@ void aes_misc_params( )
|
||||||
in, in, out )
|
in, in, out )
|
||||||
== MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
|
== MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||||
|
size = 16;
|
||||||
|
TEST_ASSERT( mbedtls_aes_crypt_cfb128( &aes_ctx, MBEDTLS_AES_ENCRYPT, 16,
|
||||||
|
&size, out, in, out )
|
||||||
|
== MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
||||||
|
size = 16;
|
||||||
|
TEST_ASSERT( mbedtls_aes_crypt_ofb( &aes_ctx, 16, &size, out, in, out )
|
||||||
|
== MBEDTLS_ERR_AES_BAD_INPUT_DATA );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue