Included test for integer underflow.

This commit is contained in:
Janos Follath 2016-02-09 14:51:35 +00:00 committed by Simon Butcher
parent 9ccbd6313f
commit 43e9297e12

View file

@ -723,6 +723,10 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
*/ */
hlen = mbedtls_md_get_size( md_info ); hlen = mbedtls_md_get_size( md_info );
// checking for integer underflow
if( 2 * hlen + 2 > ilen )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
mbedtls_md_init( &md_ctx ); mbedtls_md_init( &md_ctx );
mbedtls_md_setup( &md_ctx, md_info, 0 ); mbedtls_md_setup( &md_ctx, md_info, 0 );