This patch is used to add OpensslTlsLib module to enable 'openssl\ssl' function.
Cc: Long Qin <qin.l...@intel.com> Cc: Ye Ting <ting...@intel.com> Cc: Fu Siyuan <siyuan...@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu <jiaxin...@intel.com> --- CryptoPkg/CryptoPkg.dsc | 1 + CryptoPkg/Include/OpenSslSupport.h | 11 ++- .../Library/BaseCryptLib/SysCall/CrtWrapper.c | 5 + .../Library/BaseCryptLib/SysCall/TimerWrapper.c | 29 +++--- .../Library/OpensslLib/EDKII_openssl-1.0.2f.patch | 9 ++ CryptoPkg/Library/OpensslLib/Install.cmd | 1 + CryptoPkg/Library/OpensslLib/Install.sh | 1 + CryptoPkg/Library/OpensslLib/OpensslLib.inf | 2 +- CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf | 110 +++++++++++++++++++++ CryptoPkg/Library/OpensslLib/OpensslTlsLib.uni | Bin 0 -> 1792 bytes 10 files changed, 155 insertions(+), 14 deletions(-) create mode 100644 CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf create mode 100644 CryptoPkg/Library/OpensslLib/OpensslTlsLib.uni diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc index 5ae0e67..bb7f082 100644 --- a/CryptoPkg/CryptoPkg.dsc +++ b/CryptoPkg/CryptoPkg.dsc @@ -48,10 +48,11 @@ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf + OpensslTlsLib|CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf [LibraryClasses.ARM, LibraryClasses.AARCH64] # # It is not possible to prevent the ARM compiler for generic intrinsic functions. # This library provides the instrinsic functions generate by a given compiler. diff --git a/CryptoPkg/Include/OpenSslSupport.h b/CryptoPkg/Include/OpenSslSupport.h index 239ae8b..13c73b5 100644 --- a/CryptoPkg/Include/OpenSslSupport.h +++ b/CryptoPkg/Include/OpenSslSupport.h @@ -1,9 +1,9 @@ /** @file Root include file to support building OpenSSL Crypto Library. -Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -116,10 +116,12 @@ typedef UINT32 ino_t; typedef UINT32 dev_t; typedef UINT16 nlink_t; typedef int pid_t; typedef void *DIR; typedef void __sighandler_t (int); +typedef UINT8 __uint8_t; +typedef UINT8 sa_family_t; // // Structures from EFI Application Toolkit required to buiild Open SSL // struct tm { @@ -170,10 +172,16 @@ struct stat { UINT32 st_gen; /* file generation number */ INT32 st_lspare; INT64 st_qspare[2]; }; +struct sockaddr { + __uint8_t sa_len; /* total length */ + sa_family_t sa_family; /* address family */ + char sa_data[14]; /* actually longer; address value */ +}; + // // Externs from EFI Application Toolkit required to buiild Open SSL // extern int errno; @@ -270,8 +278,9 @@ extern FILE *stdout; #define strchr(str,ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch) #define abort() ASSERT (FALSE) #define assert(expression) #define localtime(timer) NULL #define gmtime_r(timer,result) (result = NULL) +#define gettimeofday(tvp,tz) do { (tvp)->tv_sec = time(NULL); (tvp)->tv_usec = 0; } while (0) #define atoi(nptr) AsciiStrDecimalToUintn(nptr) #endif diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c index c0ccc0e..e68bfb8 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c @@ -446,5 +446,10 @@ void syslog (int a, const char *c, ...) ssize_t write (int f, const void *b, size_t l) { return 0; } + +int printf (char const *fmt, ...) +{ + return 0; +} diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c index 6422d61..93e487d 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c @@ -1,10 +1,10 @@ /** @file C Run-Time Libraries (CRT) Time Management Routines Wrapper Implementation for OpenSSL-based Cryptographic Library (used in DXE & RUNTIME). -Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -71,10 +71,11 @@ UINTN CumulativeDays[2][14] = { // INTN *timer // ) time_t time (time_t *timer) { EFI_TIME Time; + time_t CalTime; UINTN Year; // // Get the current time and date information // @@ -82,26 +83,30 @@ time_t time (time_t *timer) // // Years Handling // UTime should now be set to 00:00:00 on Jan 1 of the current year. // - for (Year = 1970, *timer = 0; Year != Time.Year; Year++) { - *timer = *timer + (time_t)(CumulativeDays[IsLeap(Year)][13] * SECSPERDAY); + for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) { + CalTime = CalTime + (time_t)(CumulativeDays[IsLeap(Year)][13] * SECSPERDAY); } // // Add in number of seconds for current Month, Day, Hour, Minute, Seconds, and TimeZone adjustment // - *timer = *timer + - (time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) + - (time_t)(CumulativeDays[IsLeap(Time.Year)][Time.Month] * SECSPERDAY) + - (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) + - (time_t)(Time.Hour * SECSPERHOUR) + - (time_t)(Time.Minute * 60) + - (time_t)Time.Second; - - return *timer; + CalTime = CalTime + + (time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) + + (time_t)(CumulativeDays[IsLeap(Time.Year)][Time.Month] * SECSPERDAY) + + (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) + + (time_t)(Time.Hour * SECSPERHOUR) + + (time_t)(Time.Minute * 60) + + (time_t)Time.Second; + + if (timer != NULL) { + *timer = CalTime; + } + + return CalTime; } // // Convert a time value from type time_t to struct tm. // diff --git a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch index c42b776..f2d8f1a 100644 --- a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch +++ b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch @@ -11,10 +11,19 @@ diff U3 crypto/bio/bio.h crypto/bio/bio.h BIO *BIO_new_fp(FILE *stream, int close_flag); +# ifndef OPENSSL_NO_FP_API # define BIO_s_file_internal BIO_s_file # endif BIO *BIO_new(BIO_METHOD *type); +@@ -655,6 +655,8 @@ + BIO *BIO_new_file(const char *filename, const char *mode); + BIO *BIO_new_fp(FILE *stream, int close_flag); + # define BIO_s_file_internal BIO_s_file ++# else ++# define BIO_s_file_internal() NULL + # endif + BIO *BIO_new(BIO_METHOD *type); + int BIO_set(BIO *a, BIO_METHOD *type); diff U3 crypto/bio/bss_file.c crypto/bio/bss_file.c --- crypto/bio/bss_file.c Thu Jan 28 21:38:30 2016 +++ crypto/bio/bss_file.c Wed Feb 17 16:01:02 2016 @@ -467,6 +467,23 @@ return (ret); diff --git a/CryptoPkg/Library/OpensslLib/Install.cmd b/CryptoPkg/Library/OpensslLib/Install.cmd index a96501c..84698a4 100755 --- a/CryptoPkg/Library/OpensslLib/Install.cmd +++ b/CryptoPkg/Library/OpensslLib/Install.cmd @@ -4,10 +4,11 @@ copy crypto\crypto.h ..\..\..\Include\openssl copy crypto\opensslv.h ..\..\..\Include\openssl copy crypto\opensslconf.h ..\..\..\Include\openssl copy crypto\ebcdic.h ..\..\..\Include\openssl copy crypto\symhacks.h ..\..\..\Include\openssl copy crypto\ossl_typ.h ..\..\..\Include\openssl +copy crypto\o_dir.h ..\..\..\Include copy crypto\objects\objects.h ..\..\..\Include\openssl copy crypto\objects\obj_mac.h ..\..\..\Include\openssl copy crypto\md4\md4.h ..\..\..\Include\openssl copy crypto\md5\md5.h ..\..\..\Include\openssl copy crypto\sha\sha.h ..\..\..\Include\openssl diff --git a/CryptoPkg/Library/OpensslLib/Install.sh b/CryptoPkg/Library/OpensslLib/Install.sh index 76648cd..e0c50a2 100755 --- a/CryptoPkg/Library/OpensslLib/Install.sh +++ b/CryptoPkg/Library/OpensslLib/Install.sh @@ -6,10 +6,11 @@ cp crypto/crypto.h ../../../Include/openssl cp crypto/opensslv.h ../../../Include/openssl cp crypto/opensslconf.h ../../../Include/openssl cp crypto/ebcdic.h ../../../Include/openssl cp crypto/symhacks.h ../../../Include/openssl cp crypto/ossl_typ.h ../../../Include/openssl +cp crypto/o_dir.h ../../../Include cp crypto/objects/objects.h ../../../Include/openssl cp crypto/objects/obj_mac.h ../../../Include/openssl cp crypto/md4/md4.h ../../../Include/openssl cp crypto/md5/md5.h ../../../Include/openssl cp crypto/sha/sha.h ../../../Include/openssl diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf index 9b6e860..243fe22 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf @@ -811,11 +811,11 @@ # $(OPENSSL_PATH)/crypto/cms/cms_kari.c # # PQUEUE # - #$(OPENSSL_PATH)/crypto/pqueue/pqueue.c + $(OPENSSL_PATH)/crypto/pqueue/pqueue.c # # TS # #$(OPENSSL_PATH)/crypto/ts/ts_err.c diff --git a/CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf b/CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf new file mode 100644 index 0000000..fbd2b08 --- /dev/null +++ b/CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf @@ -0,0 +1,110 @@ +## @file +# This module provides OpenSSL SSL/TLS Library implementation. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = OpensslTlsLib + MODULE_UNI_FILE = OpensslTlsLib.uni + FILE_GUID = 8F636E6A-394C-428A-A3A5-CE2AAAA7D55B + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = OpensslTlsLib + DEFINE OPENSSL_PATH = openssl-1.0.2f + DEFINE OPENSSL_FLAGS = -DL_ENDIAN -DOPENSSL_SMALL_FOOTPRINT -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE + +# +# VALID_ARCHITECTURES = IA32 X64 IPF ARM AARCH64 +# + +[Sources] + $(OPENSSL_PATH)/e_os.h + $(OPENSSL_PATH)/ssl/s2_meth.c + $(OPENSSL_PATH)/ssl/s2_srvr.c + $(OPENSSL_PATH)/ssl/s2_clnt.c + $(OPENSSL_PATH)/ssl/s2_lib.c + $(OPENSSL_PATH)/ssl/s2_enc.c + $(OPENSSL_PATH)/ssl/s2_pkt.c + $(OPENSSL_PATH)/ssl/s3_meth.c + $(OPENSSL_PATH)/ssl/s3_srvr.c + $(OPENSSL_PATH)/ssl/s3_clnt.c + $(OPENSSL_PATH)/ssl/s3_lib.c + $(OPENSSL_PATH)/ssl/s3_enc.c + $(OPENSSL_PATH)/ssl/s3_pkt.c + $(OPENSSL_PATH)/ssl/s3_both.c + $(OPENSSL_PATH)/ssl/s3_cbc.c + $(OPENSSL_PATH)/ssl/s23_meth.c + $(OPENSSL_PATH)/ssl/s23_srvr.c + $(OPENSSL_PATH)/ssl/s23_clnt.c + $(OPENSSL_PATH)/ssl/s23_lib.c + $(OPENSSL_PATH)/ssl/s23_pkt.c + $(OPENSSL_PATH)/ssl/t1_meth.c + $(OPENSSL_PATH)/ssl/t1_srvr.c + $(OPENSSL_PATH)/ssl/t1_clnt.c + $(OPENSSL_PATH)/ssl/t1_lib.c + $(OPENSSL_PATH)/ssl/t1_enc.c + $(OPENSSL_PATH)/ssl/t1_ext.c + $(OPENSSL_PATH)/ssl/d1_meth.c + $(OPENSSL_PATH)/ssl/d1_srvr.c + $(OPENSSL_PATH)/ssl/d1_clnt.c + $(OPENSSL_PATH)/ssl/d1_lib.c + $(OPENSSL_PATH)/ssl/d1_pkt.c + $(OPENSSL_PATH)/ssl/d1_both.c + $(OPENSSL_PATH)/ssl/d1_srtp.c + $(OPENSSL_PATH)/ssl/ssl_lib.c + $(OPENSSL_PATH)/ssl/ssl_err2.c + $(OPENSSL_PATH)/ssl/ssl_cert.c + $(OPENSSL_PATH)/ssl/ssl_sess.c + $(OPENSSL_PATH)/ssl/ssl_ciph.c + $(OPENSSL_PATH)/ssl/ssl_stat.c + $(OPENSSL_PATH)/ssl/ssl_rsa.c + $(OPENSSL_PATH)/ssl/ssl_asn1.c + $(OPENSSL_PATH)/ssl/ssl_txt.c + $(OPENSSL_PATH)/ssl/ssl_algs.c + # + # Disable SSL command configuration interfaces. + # + # $(OPENSSL_PATH)/ssl/ssl_conf.c + $(OPENSSL_PATH)/ssl/bio_ssl.c + $(OPENSSL_PATH)/ssl/ssl_err.c + $(OPENSSL_PATH)/ssl/kssl.c + $(OPENSSL_PATH)/ssl/t1_reneg.c + $(OPENSSL_PATH)/ssl/tls_srp.c + $(OPENSSL_PATH)/ssl/t1_trce.c + $(OPENSSL_PATH)/ssl/ssl_utst.c + +[Packages] + MdePkg/MdePkg.dec + CryptoPkg/CryptoPkg.dec + +[LibraryClasses] + DebugLib + OpensslLib + +[BuildOptions] + # + # Disables the following Visual Studio compiler warnings brought by openssl source, so we do not break the build with /WX option: + # C4244: conversion from type1 to type2, possible loss of data + # C4702: unreachable code + # C4706: assignment within conditional expression + # C4133: incompatible types - from type1 to type2 + # C4245: conversion from type1 to type2, signed/unsigned mismatch + # C4267: conversion from size_t to type, possible loss of data + # C4305: truncation from type1 to type2 of smaller size + # C4306: conversion from type1 to type2 of greater size + # C4702: Potentially uninitialized local variable name used + # + MSFT:*_*_IA32_CC_FLAGS = -U_WIN32 -U_WIN64 -U_MSC_VER $(OPENSSL_FLAGS) /wd4244 /wd4245 /wd4701 /wd4702 /wd4706 + MSFT:*_*_X64_CC_FLAGS = -U_WIN32 -U_WIN64 -U_MSC_VER $(OPENSSL_FLAGS) /wd4133 /wd4244 /wd4245 /wd4267 /wd4701 /wd4305 /wd4306 /wd4702 /wd4706 /wd4311 + MSFT:*_*_IPF_CC_FLAGS = -U_WIN32 -U_WIN64 -U_MSC_VER $(OPENSSL_FLAGS) /wd4133 /wd4244 /wd4245 /wd4267 /wd4701 /wd4305 /wd4306 /wd4702 /wd4706 + diff --git a/CryptoPkg/Library/OpensslLib/OpensslTlsLib.uni b/CryptoPkg/Library/OpensslLib/OpensslTlsLib.uni new file mode 100644 index 0000000000000000000000000000000000000000..384f0245db8d1d3a1d758f6db58f85f5fc155211 GIT binary patch literal 1792 zcmd6oNpBND5QXcE#D5q$7eI*(95^6^u<-yRLdNo<zzKPeC2tx}9P;OZ?^P4GV}<2_ z1hRUq>Q}F-Uyr|ity#?y+9Q66y|RhTY;I$_Z}-@ht!o$TZI~@=Wh1+Edtz%VSZ}e7 z@RvPjZ){8J@H=H4#u^Bx%oF;V4LH@OU9+BnxOTLKpDVGH?5@D5?il=!OkTrrO%4TY zr_`q;n+G<uhm23{u|2V8cFa5@lak!#%yp*Vl=}TV6RTsFM?_OK3$N;!am#E(MP69L z+V=97l?k^p^%x6K`Y;$VmarWAdI-;zS6;SjGFXy>Zda@nZ^mrSjmFCB#&mj)ZOCki zRh%NePD=;c+0vw<KDR9`C1^%0gdLfLSPNIq4NEbT=L{x62dcyhRmO7-wA5rRHAOCw z>y_(uNG~q8vz@^~h^j`=v|?>oE9(I~Z{k+*3fdR{iK||BB-UT(4_V!=OsJ+bKJfe} z<Pd5gPUT)@rJWL0JoncoRfX!xzwrF3oGrMa+ClX<><r*OvXcW#6_g8FtVx`8?VY9Y zYN4du-qP3Y1MAFRXw%0oyBS*R@p4nIb<fTiQ}$JpfDrE?L)$4H9Y@ZYNz>{pjC%P( zuP`=zt<~`!yL0S9%{^jb=XkZ9*%|v8sKUrSdYhHFYfmw|_{v97gV!5;75x+Adn{tE zx0wEj60%6`;|?dHXVjvFvJ|s<=Ql{-$(nOlP1TNe`U&r-1E02i1}O)l2U^OiPVT`{ zr&?Y3{Oot+FGpCHXl3g9ktR;S64MH}fA2e6+2!(Qc}N8vGLS-AyUO2{%kT5}SN|+A F=kIO^7YhIY literal 0 HcmV?d00001 -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel