Skip to content

Commit 689a627

Browse files
yanescasimonbutcher
authored andcommitted
Fix null pointer dereference in the RSA module.
Introduced null pointer checks in mbedtls_rsa_rsaes_pkcs1_v15_encrypt
1 parent 0705dd0 commit 689a627

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Bugfix
1010
* Fix bug in mbedtls_x509_crt_parse that caused trailing extra data in the
1111
buffer after DER certificates to be included in the raw representation.
1212
* Fix issue that caused a hang when generating RSA keys of odd bitlength
13+
* Fix bug in mbedtls_rsa_rsaes_pkcs1_v15_encrypt that made null pointer
14+
dereference possible.
1315

1416
Changes
1517
* On ARM platforms, when compiling with -O0 with GCC, Clang or armcc5,

library/rsa.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
590590
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
591591
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
592592

593-
if( f_rng == NULL )
593+
// We don't check p_rng because it won't be dereferenced here
594+
if( f_rng == NULL || input == NULL || output == NULL )
594595
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
595596

596597
olen = ctx->len;

0 commit comments

Comments
 (0)