From 55d39c51a03048f4bb1218fc70a9ed445e2b75f6 Mon Sep 17 00:00:00 2001
From: Xiang Zheng <zhengxiang9@huawei.com>
Date: Mon, 20 Apr 2020 17:40:25 +0800
Subject: [PATCH 2/2] CryptoPkg: Upgrade OpenSSL to 1.1.1f

Upgrade OpenSLL to 1.1.1f

Signed-off-by: Xiang Zheng <zhengxiang9@huawei.com>
---
 CryptoPkg/CryptoPkg.dec                       |  1 -
 .../Library/BaseCryptLib/Hash/CryptSm3.c      |  2 +-
 .../BaseCryptLib/Pk/CryptPkcs7VerifyEku.c     |  4 +-
 CryptoPkg/Library/Include/crypto/dso_conf.h   |  6 +-
 .../Library/Include/openssl/opensslconf.h     |  3 -
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   | 88 +++++++++----------
 .../Library/OpensslLib/OpensslLibCrypto.inf   | 78 ++++++++--------
 CryptoPkg/Library/OpensslLib/rand_pool.c      |  2 +-
 8 files changed, 90 insertions(+), 94 deletions(-)

diff --git a/CryptoPkg/CryptoPkg.dec b/CryptoPkg/CryptoPkg.dec
index 4d1a1368..5888941b 100644
--- a/CryptoPkg/CryptoPkg.dec
+++ b/CryptoPkg/CryptoPkg.dec
@@ -23,7 +23,6 @@
   Private
   Library/Include
   Library/OpensslLib/openssl/include
-  Library/OpensslLib/openssl/crypto/include
 
 [LibraryClasses]
   ##  @libraryclass  Provides basic library functions for cryptographic primitives.
diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSm3.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSm3.c
index eacf4826..235331c2 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSm3.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSm3.c
@@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include "InternalCryptLib.h"
-#include "internal/sm3.h"
+#include "crypto/sm3.h"
 
 /**
   Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
index 229c244b..c9fdb65b 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
@@ -15,13 +15,13 @@
 #include <openssl/asn1.h>
 #include <openssl/x509.h>
 #include <openssl/bio.h>
-#include <internal/x509_int.h>
+#include <crypto/x509.h>
 #include <openssl/pkcs7.h>
 #include <openssl/bn.h>
 #include <openssl/x509_vfy.h>
 #include <openssl/pem.h>
 #include <openssl/evp.h>
-#include <internal/asn1_int.h>
+#include <crypto/asn1.h>
 
 /**
   This function will return the leaf signer certificate in a chain.  This is
diff --git a/CryptoPkg/Library/Include/crypto/dso_conf.h b/CryptoPkg/Library/Include/crypto/dso_conf.h
index 43c89158..abbbf62c 100644
--- a/CryptoPkg/Library/Include/crypto/dso_conf.h
+++ b/CryptoPkg/Library/Include/crypto/dso_conf.h
@@ -1,5 +1,5 @@
 /* WARNING: do not edit! */
-/* Generated from crypto/include/internal/dso_conf.h.in */
+/* Generated from include/crypto/dso_conf.h.in */
 /*
  * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
  *
@@ -9,8 +9,8 @@
  * https://www.openssl.org/source/license.html
  */
 
-#ifndef HEADER_DSO_CONF_H
-# define HEADER_DSO_CONF_H
+#ifndef OSSL_CRYPTO_DSO_CONF_H
+# define OSSL_CRYPTO_DSO_CONF_H
 # define DSO_NONE
 # define DSO_EXTENSION ".so"
 #endif
diff --git a/CryptoPkg/Library/Include/openssl/opensslconf.h b/CryptoPkg/Library/Include/openssl/opensslconf.h
index 2b4d538e..a27aa658 100644
--- a/CryptoPkg/Library/Include/openssl/opensslconf.h
+++ b/CryptoPkg/Library/Include/openssl/opensslconf.h
@@ -241,9 +241,6 @@ extern "C" {
 #ifndef OPENSSL_NO_DYNAMIC_ENGINE
 # define OPENSSL_NO_DYNAMIC_ENGINE
 #endif
-#ifndef OPENSSL_NO_AFALGENG
-# define OPENSSL_NO_AFALGENG
-#endif
 
 
 /*
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
index 3fa52f55..a010e6bc 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
@@ -494,57 +494,57 @@
   $(OPENSSL_PATH)/crypto/x509v3/v3_tlsf.c
   $(OPENSSL_PATH)/crypto/x509v3/v3_utl.c
   $(OPENSSL_PATH)/crypto/x509v3/v3err.c
-  $(OPENSSL_PATH)/crypto/hmac/hmac_lcl.h
-  $(OPENSSL_PATH)/crypto/dh/dh_locl.h
-  $(OPENSSL_PATH)/crypto/bio/bio_lcl.h
-  $(OPENSSL_PATH)/crypto/conf/conf_def.h
-  $(OPENSSL_PATH)/crypto/conf/conf_lcl.h
-  $(OPENSSL_PATH)/crypto/lhash/lhash_lcl.h
-  $(OPENSSL_PATH)/crypto/sha/sha_locl.h
-  $(OPENSSL_PATH)/crypto/md5/md5_locl.h
-  $(OPENSSL_PATH)/crypto/store/store_locl.h
-  $(OPENSSL_PATH)/crypto/dso/dso_locl.h
-  $(OPENSSL_PATH)/crypto/pkcs12/p12_lcl.h
+  $(OPENSSL_PATH)/crypto/dso/dso_local.h
+  $(OPENSSL_PATH)/crypto/dh/dh_local.h
+  $(OPENSSL_PATH)/crypto/rc4/rc4_local.h
+  $(OPENSSL_PATH)/crypto/ui/ui_local.h
+  $(OPENSSL_PATH)/crypto/async/async_local.h
+  $(OPENSSL_PATH)/crypto/modes/modes_local.h
+  $(OPENSSL_PATH)/crypto/asn1/asn1_item_list.h
+  $(OPENSSL_PATH)/crypto/asn1/asn1_local.h
+  $(OPENSSL_PATH)/crypto/asn1/charmap.h
+  $(OPENSSL_PATH)/crypto/asn1/standard_methods.h
+  $(OPENSSL_PATH)/crypto/asn1/tbl_standard.h
+  $(OPENSSL_PATH)/crypto/md4/md4_local.h
+  $(OPENSSL_PATH)/crypto/rand/rand_local.h
+  $(OPENSSL_PATH)/crypto/pkcs12/p12_local.h
+  $(OPENSSL_PATH)/crypto/lhash/lhash_local.h
+  $(OPENSSL_PATH)/crypto/evp/evp_local.h
+  $(OPENSSL_PATH)/crypto/rsa/rsa_local.h
+  $(OPENSSL_PATH)/crypto/bn/bn_local.h
+  $(OPENSSL_PATH)/crypto/bn/bn_prime.h
+  $(OPENSSL_PATH)/crypto/bn/rsaz_exp.h
+  $(OPENSSL_PATH)/crypto/des/des_local.h
+  $(OPENSSL_PATH)/crypto/des/spr.h
   $(OPENSSL_PATH)/crypto/arm_arch.h
   $(OPENSSL_PATH)/crypto/mips_arch.h
   $(OPENSSL_PATH)/crypto/ppc_arch.h
   $(OPENSSL_PATH)/crypto/s390x_arch.h
   $(OPENSSL_PATH)/crypto/sparc_arch.h
   $(OPENSSL_PATH)/crypto/vms_rms.h
-  $(OPENSSL_PATH)/crypto/bn/bn_lcl.h
-  $(OPENSSL_PATH)/crypto/bn/bn_prime.h
-  $(OPENSSL_PATH)/crypto/bn/rsaz_exp.h
-  $(OPENSSL_PATH)/crypto/ui/ui_locl.h
-  $(OPENSSL_PATH)/crypto/md4/md4_locl.h
-  $(OPENSSL_PATH)/crypto/rc4/rc4_locl.h
-  $(OPENSSL_PATH)/crypto/asn1/asn1_item_list.h
-  $(OPENSSL_PATH)/crypto/asn1/asn1_locl.h
-  $(OPENSSL_PATH)/crypto/asn1/charmap.h
-  $(OPENSSL_PATH)/crypto/asn1/standard_methods.h
-  $(OPENSSL_PATH)/crypto/asn1/tbl_standard.h
-  $(OPENSSL_PATH)/crypto/evp/evp_locl.h
-  $(OPENSSL_PATH)/crypto/rand/rand_lcl.h
-  $(OPENSSL_PATH)/crypto/ocsp/ocsp_lcl.h
-  $(OPENSSL_PATH)/crypto/modes/modes_lcl.h
-  $(OPENSSL_PATH)/crypto/comp/comp_lcl.h
-  $(OPENSSL_PATH)/crypto/rsa/rsa_locl.h
-  $(OPENSSL_PATH)/crypto/x509/x509_lcl.h
+  $(OPENSSL_PATH)/crypto/ocsp/ocsp_local.h
+  $(OPENSSL_PATH)/crypto/md5/md5_local.h
+  $(OPENSSL_PATH)/crypto/aes/aes_local.h
+  $(OPENSSL_PATH)/crypto/store/store_local.h
+  $(OPENSSL_PATH)/crypto/objects/obj_dat.h
+  $(OPENSSL_PATH)/crypto/objects/obj_local.h
+  $(OPENSSL_PATH)/crypto/objects/obj_xref.h
+  $(OPENSSL_PATH)/crypto/hmac/hmac_local.h
   $(OPENSSL_PATH)/crypto/async/arch/async_null.h
   $(OPENSSL_PATH)/crypto/async/arch/async_posix.h
   $(OPENSSL_PATH)/crypto/async/arch/async_win.h
-  $(OPENSSL_PATH)/crypto/sm3/sm3_locl.h
-  $(OPENSSL_PATH)/crypto/des/des_locl.h
-  $(OPENSSL_PATH)/crypto/des/spr.h
-  $(OPENSSL_PATH)/crypto/siphash/siphash_local.h
-  $(OPENSSL_PATH)/crypto/aes/aes_locl.h
-  $(OPENSSL_PATH)/crypto/async/async_locl.h
   $(OPENSSL_PATH)/crypto/x509v3/ext_dat.h
-  $(OPENSSL_PATH)/crypto/x509v3/pcy_int.h
+  $(OPENSSL_PATH)/crypto/x509v3/pcy_local.h
   $(OPENSSL_PATH)/crypto/x509v3/standard_exts.h
   $(OPENSSL_PATH)/crypto/x509v3/v3_admis.h
-  $(OPENSSL_PATH)/crypto/objects/obj_dat.h
-  $(OPENSSL_PATH)/crypto/objects/obj_lcl.h
-  $(OPENSSL_PATH)/crypto/objects/obj_xref.h
+  $(OPENSSL_PATH)/crypto/conf/conf_def.h
+  $(OPENSSL_PATH)/crypto/conf/conf_local.h
+  $(OPENSSL_PATH)/crypto/comp/comp_local.h
+  $(OPENSSL_PATH)/crypto/sha/sha_local.h
+  $(OPENSSL_PATH)/crypto/x509/x509_local.h
+  $(OPENSSL_PATH)/crypto/sm3/sm3_local.h
+  $(OPENSSL_PATH)/crypto/bio/bio_local.h
+  $(OPENSSL_PATH)/crypto/siphash/siphash_local.h
   $(OPENSSL_PATH)/ssl/bio_ssl.c
   $(OPENSSL_PATH)/ssl/d1_lib.c
   $(OPENSSL_PATH)/ssl/d1_msg.c
@@ -589,13 +589,13 @@
   $(OPENSSL_PATH)/ssl/t1_trce.c
   $(OPENSSL_PATH)/ssl/tls13_enc.c
   $(OPENSSL_PATH)/ssl/tls_srp.c
-  $(OPENSSL_PATH)/ssl/statem/statem.h
-  $(OPENSSL_PATH)/ssl/statem/statem_locl.h
-  $(OPENSSL_PATH)/ssl/packet_locl.h
+  $(OPENSSL_PATH)/ssl/packet_local.h
   $(OPENSSL_PATH)/ssl/ssl_cert_table.h
-  $(OPENSSL_PATH)/ssl/ssl_locl.h
+  $(OPENSSL_PATH)/ssl/ssl_local.h
+  $(OPENSSL_PATH)/ssl/statem/statem.h
+  $(OPENSSL_PATH)/ssl/statem/statem_local.h
   $(OPENSSL_PATH)/ssl/record/record.h
-  $(OPENSSL_PATH)/ssl/record/record_locl.h
+  $(OPENSSL_PATH)/ssl/record/record_local.h
 # Autogenerated files list ends here
   buildinf.h
   rand_pool_noise.h
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
index f1f9fbb9..de8a9ef2 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
@@ -494,57 +494,57 @@
   $(OPENSSL_PATH)/crypto/x509v3/v3_tlsf.c
   $(OPENSSL_PATH)/crypto/x509v3/v3_utl.c
   $(OPENSSL_PATH)/crypto/x509v3/v3err.c
-  $(OPENSSL_PATH)/crypto/hmac/hmac_lcl.h
-  $(OPENSSL_PATH)/crypto/dh/dh_locl.h
-  $(OPENSSL_PATH)/crypto/bio/bio_lcl.h
-  $(OPENSSL_PATH)/crypto/conf/conf_def.h
-  $(OPENSSL_PATH)/crypto/conf/conf_lcl.h
-  $(OPENSSL_PATH)/crypto/lhash/lhash_lcl.h
-  $(OPENSSL_PATH)/crypto/sha/sha_locl.h
-  $(OPENSSL_PATH)/crypto/md5/md5_locl.h
-  $(OPENSSL_PATH)/crypto/store/store_locl.h
-  $(OPENSSL_PATH)/crypto/dso/dso_locl.h
-  $(OPENSSL_PATH)/crypto/pkcs12/p12_lcl.h
+  $(OPENSSL_PATH)/crypto/dso/dso_local.h
+  $(OPENSSL_PATH)/crypto/dh/dh_local.h
+  $(OPENSSL_PATH)/crypto/rc4/rc4_local.h
+  $(OPENSSL_PATH)/crypto/ui/ui_local.h
+  $(OPENSSL_PATH)/crypto/async/async_local.h
+  $(OPENSSL_PATH)/crypto/modes/modes_local.h
+  $(OPENSSL_PATH)/crypto/asn1/asn1_item_list.h
+  $(OPENSSL_PATH)/crypto/asn1/asn1_local.h
+  $(OPENSSL_PATH)/crypto/asn1/charmap.h
+  $(OPENSSL_PATH)/crypto/asn1/standard_methods.h
+  $(OPENSSL_PATH)/crypto/asn1/tbl_standard.h
+  $(OPENSSL_PATH)/crypto/md4/md4_local.h
+  $(OPENSSL_PATH)/crypto/rand/rand_local.h
+  $(OPENSSL_PATH)/crypto/pkcs12/p12_local.h
+  $(OPENSSL_PATH)/crypto/lhash/lhash_local.h
+  $(OPENSSL_PATH)/crypto/evp/evp_local.h
+  $(OPENSSL_PATH)/crypto/rsa/rsa_local.h
+  $(OPENSSL_PATH)/crypto/bn/bn_local.h
+  $(OPENSSL_PATH)/crypto/bn/bn_prime.h
+  $(OPENSSL_PATH)/crypto/bn/rsaz_exp.h
+  $(OPENSSL_PATH)/crypto/des/des_local.h
+  $(OPENSSL_PATH)/crypto/des/spr.h
   $(OPENSSL_PATH)/crypto/arm_arch.h
   $(OPENSSL_PATH)/crypto/mips_arch.h
   $(OPENSSL_PATH)/crypto/ppc_arch.h
   $(OPENSSL_PATH)/crypto/s390x_arch.h
   $(OPENSSL_PATH)/crypto/sparc_arch.h
   $(OPENSSL_PATH)/crypto/vms_rms.h
-  $(OPENSSL_PATH)/crypto/bn/bn_lcl.h
-  $(OPENSSL_PATH)/crypto/bn/bn_prime.h
-  $(OPENSSL_PATH)/crypto/bn/rsaz_exp.h
-  $(OPENSSL_PATH)/crypto/ui/ui_locl.h
-  $(OPENSSL_PATH)/crypto/md4/md4_locl.h
-  $(OPENSSL_PATH)/crypto/rc4/rc4_locl.h
-  $(OPENSSL_PATH)/crypto/asn1/asn1_item_list.h
-  $(OPENSSL_PATH)/crypto/asn1/asn1_locl.h
-  $(OPENSSL_PATH)/crypto/asn1/charmap.h
-  $(OPENSSL_PATH)/crypto/asn1/standard_methods.h
-  $(OPENSSL_PATH)/crypto/asn1/tbl_standard.h
-  $(OPENSSL_PATH)/crypto/evp/evp_locl.h
-  $(OPENSSL_PATH)/crypto/rand/rand_lcl.h
-  $(OPENSSL_PATH)/crypto/ocsp/ocsp_lcl.h
-  $(OPENSSL_PATH)/crypto/modes/modes_lcl.h
-  $(OPENSSL_PATH)/crypto/comp/comp_lcl.h
-  $(OPENSSL_PATH)/crypto/rsa/rsa_locl.h
-  $(OPENSSL_PATH)/crypto/x509/x509_lcl.h
+  $(OPENSSL_PATH)/crypto/ocsp/ocsp_local.h
+  $(OPENSSL_PATH)/crypto/md5/md5_local.h
+  $(OPENSSL_PATH)/crypto/aes/aes_local.h
+  $(OPENSSL_PATH)/crypto/store/store_local.h
+  $(OPENSSL_PATH)/crypto/objects/obj_dat.h
+  $(OPENSSL_PATH)/crypto/objects/obj_local.h
+  $(OPENSSL_PATH)/crypto/objects/obj_xref.h
+  $(OPENSSL_PATH)/crypto/hmac/hmac_local.h
   $(OPENSSL_PATH)/crypto/async/arch/async_null.h
   $(OPENSSL_PATH)/crypto/async/arch/async_posix.h
   $(OPENSSL_PATH)/crypto/async/arch/async_win.h
-  $(OPENSSL_PATH)/crypto/sm3/sm3_locl.h
-  $(OPENSSL_PATH)/crypto/des/des_locl.h
-  $(OPENSSL_PATH)/crypto/des/spr.h
-  $(OPENSSL_PATH)/crypto/siphash/siphash_local.h
-  $(OPENSSL_PATH)/crypto/aes/aes_locl.h
-  $(OPENSSL_PATH)/crypto/async/async_locl.h
   $(OPENSSL_PATH)/crypto/x509v3/ext_dat.h
-  $(OPENSSL_PATH)/crypto/x509v3/pcy_int.h
+  $(OPENSSL_PATH)/crypto/x509v3/pcy_local.h
   $(OPENSSL_PATH)/crypto/x509v3/standard_exts.h
   $(OPENSSL_PATH)/crypto/x509v3/v3_admis.h
-  $(OPENSSL_PATH)/crypto/objects/obj_dat.h
-  $(OPENSSL_PATH)/crypto/objects/obj_lcl.h
-  $(OPENSSL_PATH)/crypto/objects/obj_xref.h
+  $(OPENSSL_PATH)/crypto/conf/conf_def.h
+  $(OPENSSL_PATH)/crypto/conf/conf_local.h
+  $(OPENSSL_PATH)/crypto/comp/comp_local.h
+  $(OPENSSL_PATH)/crypto/sha/sha_local.h
+  $(OPENSSL_PATH)/crypto/x509/x509_local.h
+  $(OPENSSL_PATH)/crypto/sm3/sm3_local.h
+  $(OPENSSL_PATH)/crypto/bio/bio_local.h
+  $(OPENSSL_PATH)/crypto/siphash/siphash_local.h
 # Autogenerated files list ends here
   buildinf.h
   rand_pool_noise.h
diff --git a/CryptoPkg/Library/OpensslLib/rand_pool.c b/CryptoPkg/Library/OpensslLib/rand_pool.c
index 9f3983f7..9e0179b0 100644
--- a/CryptoPkg/Library/OpensslLib/rand_pool.c
+++ b/CryptoPkg/Library/OpensslLib/rand_pool.c
@@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#include "internal/rand_int.h"
+#include "crypto/rand.h"
 #include <openssl/aes.h>
 
 #include <Uefi.h>
-- 
2.19.1

