public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>,
	Jian J Wang <jian.j.wang@intel.com>,
	Xiaoyu Lu <xiaoyu1.lu@intel.com>,
	Guomin Jiang <guomin.jiang@intel.com>,
	Christopher Zurcher <christopher.zurcher@microsoft.com>,
	Rebecca Cran <quic_rcran@quicinc.com>,
	Ard Biesheuvel <ardb@kernel.org>
Subject: [Patch v2 05/16] CryptoPkg/Library: Cleanup BaseCryptLib and TlsLib
Date: Thu, 20 Oct 2022 11:34:59 -0700	[thread overview]
Message-ID: <20221020183510.1799-6-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20221020183510.1799-1-michael.d.kinney@intel.com>

* Move SysCall/inet_pton.c from BaseCryptLib to TlsLib.  The functions
  in this file are only used by TlsLib instances and not any CryptLib
  instances.
* Fix type mismatch in call to FreePool() in TlsConfig.c
* Remove use of gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled from
  TslLib and CryptLib instances
* Add missing *Null.c files to SecCryptLib.inf and RuntimeCryptLib.inf.
* Remove ARM and AARCH64 sections from SmmCryptLib.inf that does not
  support those architectures.
* Add missing PrintLib dependencies to [LibraryClasses] sections of
  CryptLib INF files
* Remove extra library classes from [LibraryClasses] sections of
  CryptLib INF files
* Remove unnecessary warning disables from [BuildOptions] sections of
  TlsLib and CryptLib INF files
* Remove RVCT support from SecCryptLib.inf

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Cc: Rebecca Cran <quic_rcran@quicinc.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf      | 10 +---------
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf       |  8 +-------
 CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c        |  4 ----
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c        |  4 ----
 CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf   |  9 ++-------
 CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf       | 12 ++++--------
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf       | 12 ------------
 .../{BaseCryptLib => TlsLib}/SysCall/inet_pton.c     |  0
 CryptoPkg/Library/TlsLib/TlsConfig.c                 | 12 ++++--------
 CryptoPkg/Library/TlsLib/TlsLib.inf                  | 12 +-----------
 10 files changed, 13 insertions(+), 70 deletions(-)
 rename CryptoPkg/Library/{BaseCryptLib => TlsLib}/SysCall/inet_pton.c (100%)

diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
index 8896e47095d2..213813cad971 100644
--- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -54,15 +54,13 @@ [Sources]
   Pk/CryptTs.c
   Pk/CryptRsaPss.c
   Pk/CryptRsaPssSign.c
-  Pk/CryptEcNull.c    |*|*|*|!gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
-  Pk/CryptEc.c    |*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  Pk/CryptEc.c
   Pem/CryptPem.c
   Bn/CryptBn.c
 
   SysCall/CrtWrapper.c
   SysCall/TimerWrapper.c
   SysCall/BaseMemAllocation.c
-  SysCall/inet_pton.c
 
 [Sources.Ia32]
   Rand/CryptRandTsc.c
@@ -96,19 +94,13 @@ [LibraryClasses]
   IntrinsicLib
   PrintLib
 
-[FixedPcd]
-  gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
-
 #
 # Remove these [BuildOptions] after this library is cleaned up
 #
 [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with warnings-as-errors:
-  # C4090: 'function' : different 'const' qualifiers
   #
-  MSFT:*_*_*_CC_FLAGS = /wd4090
-
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
index 3799780c9f52..b1629647f9c6 100644
--- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
@@ -79,9 +79,7 @@ [LibraryClasses]
   DebugLib
   OpensslLib
   IntrinsicLib
-
-[FixedPcd]
-  gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
+  PrintLib
 
 #
 # Remove these [BuildOptions] after this library is cleaned up
@@ -89,11 +87,7 @@ [FixedPcd]
 [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with warnings-as-errors:
-  # C4090: 'function' : different 'const' qualifiers
-  # C4718: 'function call' : recursive call has no side effects, deleting
   #
-  MSFT:*_*_*_CC_FLAGS = /wd4090 /wd4718
-
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
diff --git a/CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c b/CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c
index 559a6b4df037..d64cf3d68072 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c
@@ -153,7 +153,6 @@ EcGetPrivateKeyFromPem (
   OUT  VOID         **EcContext
   )
 {
- #if FixedPcdGetBool (PcdOpensslEcEnabled)
   BOOLEAN  Status;
   BIO      *PemBio;
 
@@ -209,7 +208,4 @@ EcGetPrivateKeyFromPem (
   BIO_free (PemBio);
 
   return Status;
- #else
-  return FALSE;
- #endif
 }
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
index 1d91ac3b0f44..2333157e0d17 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
@@ -881,7 +881,6 @@ EcGetPublicKeyFromX509 (
   OUT  VOID         **EcContext
   )
 {
- #if FixedPcdGetBool (PcdOpensslEcEnabled)
   BOOLEAN   Status;
   EVP_PKEY  *Pkey;
   X509      *X509Cert;
@@ -935,9 +934,6 @@ EcGetPublicKeyFromX509 (
   }
 
   return Status;
- #else
-  return FALSE;
- #endif
 }
 
 /**
diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
index bb66604e320f..07dbc0e7a8bd 100644
--- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
@@ -60,7 +60,9 @@ [Sources]
   Pk/CryptTsNull.c
   Pk/CryptRsaPssNull.c
   Pk/CryptRsaPssSignNull.c
+  Pk/CryptEcNull.c
   Pem/CryptPem.c
+  Bn/CryptBnNull.c
 
   SysCall/CrtWrapper.c
   SysCall/TimerWrapper.c
@@ -91,26 +93,19 @@ [Packages]
 [LibraryClasses]
   BaseLib
   BaseMemoryLib
-  UefiBootServicesTableLib
   UefiRuntimeServicesTableLib
   DebugLib
   OpensslLib
   IntrinsicLib
   PrintLib
 
-[FixedPcd]
-  gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
-
 #
 # Remove these [BuildOptions] after this library is cleaned up
 #
 [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with warnings-as-errors:
-  # C4090: 'function' : different 'const' qualifiers
   #
-  MSFT:*_*_*_CC_FLAGS = /wd4090
-
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
diff --git a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
index 4f652be46a82..4ad59b7bbc59 100644
--- a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
@@ -38,6 +38,7 @@ [Sources]
   Hmac/CryptHmacNull.c
   Kdf/CryptHkdfNull.c
   Cipher/CryptAesNull.c
+  Cipher/CryptAeadAesGcmNull.c
   Pk/CryptRsaBasicNull.c
   Pk/CryptRsaExtNull.c
   Pk/CryptPkcs1OaepNull.c
@@ -53,6 +54,8 @@ [Sources]
   Rand/CryptRandNull.c
   Pk/CryptRsaPssNull.c
   Pk/CryptRsaPssSignNull.c
+  Pk/CryptEcNull.c
+  Bn/CryptBnNull.c
 
   SysCall/CrtWrapper.c
   SysCall/ConstantTimeClock.c
@@ -69,6 +72,7 @@ [LibraryClasses]
   DebugLib
   OpensslLib
   IntrinsicLib
+  PrintLib
 
 #
 # Remove these [BuildOptions] after this library is cleaned up
@@ -76,15 +80,7 @@ [LibraryClasses]
 [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with warnings-as-errors:
-  # C4090: 'function' : different 'const' qualifiers
-  # C4718: 'function call' : recursive call has no side effects, deleting
   #
-  MSFT:*_*_*_CC_FLAGS = /wd4090 /wd4718
-
-  # -JCryptoPkg/Include : To disable the use of the system includes provided by RVCT
-  # --diag_remark=1     : Reduce severity of "#1-D: last line of file ends without a newline"
-  RVCT:*_*_ARM_CC_FLAGS = -JCryptoPkg/Include --diag_remark=1
-
   GCC:*_CLANG35_*_CC_FLAGS = -std=c99
   GCC:*_CLANG38_*_CC_FLAGS = -std=c99
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
index 9318052a51c5..0af7a3f96e8f 100644
--- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
@@ -74,19 +74,12 @@ [Sources.Ia32]
 [Sources.X64]
   Rand/CryptRandTsc.c
 
-[Sources.ARM]
-  Rand/CryptRand.c
-
-[Sources.AARCH64]
-  Rand/CryptRand.c
-
 [Packages]
   MdePkg/MdePkg.dec
   CryptoPkg/CryptoPkg.dec
 
 [LibraryClasses]
   BaseLib
-  IoLib
   BaseMemoryLib
   MemoryAllocationLib
   OpensslLib
@@ -95,18 +88,13 @@ [LibraryClasses]
   MmServicesTableLib
   SynchronizationLib
 
-[FixedPcd]
-  gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
-
 #
 # Remove these [BuildOptions] after this library is cleaned up
 #
 [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with warnings-as-errors:
-  # C4090: 'function' : different 'const' qualifiers
   #
-  MSFT:*_*_*_CC_FLAGS = /wd4090
 
   XCODE:*_*_*_CC_FLAGS = -mmmx -msse -std=c99
 
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/inet_pton.c b/CryptoPkg/Library/TlsLib/SysCall/inet_pton.c
similarity index 100%
rename from CryptoPkg/Library/BaseCryptLib/SysCall/inet_pton.c
rename to CryptoPkg/Library/TlsLib/SysCall/inet_pton.c
diff --git a/CryptoPkg/Library/TlsLib/TlsConfig.c b/CryptoPkg/Library/TlsLib/TlsConfig.c
index dbe1f0652996..60559de4a7f3 100644
--- a/CryptoPkg/Library/TlsLib/TlsConfig.c
+++ b/CryptoPkg/Library/TlsLib/TlsConfig.c
@@ -478,7 +478,7 @@ TlsSetCipherList (
   FreePool (CipherString);
 
 FreeMappedCipher:
-  FreePool (MappedCipher);
+  FreePool ((VOID *)MappedCipher);
 
   return Status;
 }
@@ -1136,9 +1136,6 @@ TlsSetEcCurve (
   IN     UINTN  DataSize
   )
 {
- #if !FixedPcdGetBool (PcdOpensslEcEnabled)
-  return EFI_UNSUPPORTED;
- #else
   TLS_CONNECTION  *TlsConn;
   EC_KEY          *EcKey;
   INT32           Nid;
@@ -1170,23 +1167,22 @@ TlsSetEcCurve (
   }
 
   if (SSL_set1_curves (TlsConn->Ssl, &Nid, 1) != 1) {
-    return EFI_INVALID_PARAMETER;
+    return EFI_UNSUPPORTED;
   }
 
   EcKey = EC_KEY_new_by_curve_name (Nid);
   if (EcKey == NULL) {
-    return EFI_INVALID_PARAMETER;
+    return EFI_UNSUPPORTED;
   }
 
   Ret = SSL_set_tmp_ecdh (TlsConn->Ssl, EcKey);
   EC_KEY_free (EcKey);
 
   if (Ret != 1) {
-    return EFI_INVALID_PARAMETER;
+    return EFI_UNSUPPORTED;
   }
 
   return EFI_SUCCESS;
- #endif
 }
 
 /**
diff --git a/CryptoPkg/Library/TlsLib/TlsLib.inf b/CryptoPkg/Library/TlsLib/TlsLib.inf
index 20b0ea683238..4e7b3e535a45 100644
--- a/CryptoPkg/Library/TlsLib/TlsLib.inf
+++ b/CryptoPkg/Library/TlsLib/TlsLib.inf
@@ -28,6 +28,7 @@ [Sources]
   TlsInit.c
   TlsConfig.c
   TlsProcess.c
+  SysCall/inet_pton.c
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -41,14 +42,3 @@ [LibraryClasses]
   MemoryAllocationLib
   OpensslLib
   SafeIntLib
-
-[FixedPcd]
-  gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled
-
-[BuildOptions]
-  #
-  # suppress the following warnings so we do not break the build with warnings-as-errors:
-  # C4090: 'function' : different 'const' qualifiers
-  #
-  MSFT:*_*_*_CC_FLAGS = /wd4090
-
-- 
2.37.1.windows.1


  parent reply	other threads:[~2022-10-20 18:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 18:34 [Patch v2 00/16] CryptoPkg: Remove EC PCD and merge perf opt OpensslLibs Michael D Kinney
2022-10-20 18:34 ` [Patch v2 01/16] CryptoPkg: Document and disable deprecated crypto services Michael D Kinney
2022-10-20 18:34 ` [Patch v2 02/16] CryptoPkg/Library/BaseCryptLib: Add missing UNI file and fix format Michael D Kinney
2022-10-20 18:34 ` [Patch v2 03/16] CryptoPkg/Library/BaseCryptLib: Update internal functions/variables Michael D Kinney
2022-10-20 18:34 ` [Patch v2 04/16] CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes Michael D Kinney
2022-10-20 18:34 ` Michael D Kinney [this message]
2022-10-20 18:35 ` [Patch v2 06/16] CryptoPkg/Library/OpensslLib: Combine all performance optimized INFs Michael D Kinney
2022-10-20 18:35 ` [Patch v2 07/16] CryptoPkg/Library/OpensslLib: Produce consistent set of APIs Michael D Kinney
2022-10-20 18:35 ` [Patch v2 08/16] CryptoPkg/Library/OpensslLib: Remove PrintLib from INF files Michael D Kinney
2022-10-20 18:35 ` [Patch v2 09/16] CryptoPkg: Remove PcdOpensslEcEnabled from CryptoPkg.dec Michael D Kinney
2022-10-20 18:35 ` [Patch v2 10/16] CryptoPkg: Update DSC to improve CI test coverage Michael D Kinney
2022-10-20 18:35 ` [Patch v2 11/16] CryptoPkg: Fixed host-based unit tests Michael D Kinney
2022-10-20 18:35 ` [Patch v2 12/16] CryptoPkg: Add Readme.md Michael D Kinney
2022-10-20 18:35 ` [Patch v2 13/16] Revert "CryptoPkg: Update process_files.pl to auto add PCD config option" Michael D Kinney
2022-10-20 18:35 ` [Patch v2 14/16] CryptoPkg/Library/OpensslLib: Update process_files.pl INF generation Michael D Kinney
2022-10-20 18:35 ` [Patch v2 15/16] CryptoPkg/Library/OpensslLib: Add generated flag to Accel INF Michael D Kinney
2022-10-20 18:35 ` [Patch v2 16/16] CryptoPkg/Library/OpensslLib: update auto-generated files Michael D Kinney
2022-10-24  3:52 ` [Patch v2 00/16] CryptoPkg: Remove EC PCD and merge perf opt OpensslLibs Yao, Jiewen
     [not found] ` <1720E4F0EDFC384F.808@groups.io>
2022-10-24  3:54   ` [edk2-devel] " Yao, Jiewen
2022-10-24  5:43     ` Michael D Kinney
2022-10-24  6:24       ` Yao, Jiewen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221020183510.1799-6-michael.d.kinney@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox