[openssl-commits] [openssl] OpenSSL_1_1_0-stable update

bernd.edlinger at hotmail.de bernd.edlinger at hotmail.de
Mon Jul 31 19:51:29 UTC 2017


The branch OpenSSL_1_1_0-stable has been updated
       via  09f87aa6a14f518c2fdf7170462b594c24a7c527 (commit)
      from  e118487fee21ebdd959fe514be6b5c121462e272 (commit)


- Log -----------------------------------------------------------------
commit 09f87aa6a14f518c2fdf7170462b594c24a7c527
Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
Date:   Mon Jul 31 20:52:43 2017 +0200

    Fix an information leak in the RSA padding check code.
    The memory blocks contain secret data and must be
    cleared before returning to the system heap.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/4062)
    
    (cherry picked from commit e670db0183079b5f6325ce2abd9d785e0f966890)

-----------------------------------------------------------------------

Summary of changes:
 crypto/rsa/rsa_oaep.c | 6 +++---
 crypto/rsa/rsa_pk1.c  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c
index 868104f..4878d49 100644
--- a/crypto/rsa/rsa_oaep.c
+++ b/crypto/rsa/rsa_oaep.c
@@ -122,7 +122,7 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
                                       int plen, const EVP_MD *md,
                                       const EVP_MD *mgf1md)
 {
-    int i, dblen, mlen = -1, one_index = 0, msg_index;
+    int i, dblen = 0, mlen = -1, one_index = 0, msg_index;
     unsigned int good, found_one_byte;
     const unsigned char *maskedseed, *maskeddb;
     /*
@@ -239,8 +239,8 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
     RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1,
            RSA_R_OAEP_DECODING_ERROR);
  cleanup:
-    OPENSSL_free(db);
-    OPENSSL_free(em);
+    OPENSSL_clear_free(db, dblen);
+    OPENSSL_clear_free(em, num);
     return mlen;
 }
 
diff --git a/crypto/rsa/rsa_pk1.c b/crypto/rsa/rsa_pk1.c
index 5bc91c4..aeeb32c 100644
--- a/crypto/rsa/rsa_pk1.c
+++ b/crypto/rsa/rsa_pk1.c
@@ -235,7 +235,7 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
     memcpy(to, em + msg_index, mlen);
 
  err:
-    OPENSSL_free(em);
+    OPENSSL_clear_free(em, num);
     if (mlen == -1)
         RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,
                RSA_R_PKCS_DECODING_ERROR);


More information about the openssl-commits mailing list