From 43e9297e1299f01e08420ff85b9b54102d7aeab4 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Tue, 9 Feb 2016 14:51:35 +0000 Subject: [PATCH] Included test for integer underflow. --- library/rsa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/rsa.c b/library/rsa.c index f686c4c5d..3bbf24843 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -723,6 +723,10 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, */ 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_setup( &md_ctx, md_info, 0 );