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>
Subject: [Patch 03/12] CryptoPkg/Library/BaseCryptLib: Update internal functions/variables
Date: Tue, 11 Oct 2022 08:03:49 -0700	[thread overview]
Message-ID: <20221011150358.1332-4-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20221011150358.1332-1-michael.d.kinney@intel.com>

* Update BaseCryptLib internal worker functions to be 'STATIC'
* Update BaseCryptLib internal working functions to not use EFIAPI
* Add GLOBAL_REMOVE_IF_UNREFERENCED to BaseCryptLib global variables

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>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 CryptoPkg/CryptoPkg.ci.yaml                   |  3 +-
 .../Library/BaseCryptLib/Hmac/CryptHmac.c     |  7 +++
 .../Library/BaseCryptLib/Kdf/CryptHkdf.c      |  5 ++-
 .../BaseCryptLib/Pk/CryptAuthenticode.c       |  2 +-
 .../BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c  |  3 +-
 .../BaseCryptLib/Pk/CryptPkcs7VerifyEku.c     |  3 ++
 CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c   | 44 +++++++++++++------
 7 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/CryptoPkg/CryptoPkg.ci.yaml b/CryptoPkg/CryptoPkg.ci.yaml
index 2fa3a3d5ee05..ca129d6ae56c 100644
--- a/CryptoPkg/CryptoPkg.ci.yaml
+++ b/CryptoPkg/CryptoPkg.ci.yaml
@@ -24,7 +24,8 @@
         "ExceptionList": [
             "8001", "IsLeap",
             "8001", "OBJ_get0_data",
-            "8001", "OBJ_length"
+            "8001", "OBJ_length",
+            "5005", "X509PopCertificate"
         ],
         ## Both file path and directory path are accepted.
         "IgnoreFiles": [
diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c
index 2786267a0be1..1ae33b6709cb 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c
@@ -16,6 +16,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
            If the allocations fails, HmacMdNew() returns NULL.
 
 **/
+STATIC
 VOID *
 HmacMdNew (
   VOID
@@ -33,6 +34,7 @@ HmacMdNew (
   @param[in]  HmacMdCtx  Pointer to the HMAC_CTX context to be released.
 
 **/
+STATIC
 VOID
 HmacMdFree (
   IN  VOID  *HmacMdCtx
@@ -59,6 +61,7 @@ HmacMdFree (
   @retval FALSE  The Key is set unsuccessfully.
 
 **/
+STATIC
 BOOLEAN
 HmacMdSetKey (
   IN   CONST EVP_MD  *Md,
@@ -94,6 +97,7 @@ HmacMdSetKey (
   @retval FALSE  HMAC-MD context copy failed.
 
 **/
+STATIC
 BOOLEAN
 HmacMdDuplicate (
   IN   CONST VOID  *HmacMdContext,
@@ -132,6 +136,7 @@ HmacMdDuplicate (
   @retval FALSE  HMAC-MD data digest failed.
 
 **/
+STATIC
 BOOLEAN
 HmacMdUpdate (
   IN OUT  VOID        *HmacMdContext,
@@ -183,6 +188,7 @@ HmacMdUpdate (
   @retval FALSE  HMAC-MD digest computation failed.
 
 **/
+STATIC
 BOOLEAN
 HmacMdFinal (
   IN OUT  VOID   *HmacMdContext,
@@ -233,6 +239,7 @@ HmacMdFinal (
   @retval FALSE  This interface is not supported.
 
 **/
+STATIC
 BOOLEAN
 HmacMdAll (
   IN   CONST EVP_MD  *Md,
diff --git a/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c b/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c
index ffaf5fb131ac..34e81246ed0d 100644
--- a/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c
+++ b/CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c
@@ -6,7 +6,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#include <Library/BaseCryptLib.h>
+#include "InternalCryptLib.h"
 #include <openssl/evp.h>
 #include <openssl/kdf.h>
 
@@ -27,6 +27,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
   @retval FALSE  Hkdf generation failed.
 
 **/
+STATIC
 BOOLEAN
 HkdfMdExtractAndExpand (
   IN   CONST EVP_MD  *Md,
@@ -95,6 +96,7 @@ HkdfMdExtractAndExpand (
   @retval false  Hkdf generation failed.
 
 **/
+STATIC
 BOOLEAN
 HkdfMdExtract (
   IN CONST EVP_MD  *Md,
@@ -174,6 +176,7 @@ HkdfMdExtract (
   @retval FALSE  Hkdf generation failed.
 
 **/
+STATIC
 BOOLEAN
 HkdfMdExpand (
   IN   CONST EVP_MD  *Md,
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c
index aa4a33364d92..6b0dddd4af55 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c
@@ -23,7 +23,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 //
 // OID ASN.1 Value for SPC_INDIRECT_DATA_OBJID
 //
-UINT8  mSpcIndirectOidValue[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  mSpcIndirectOidValue[] = {
   0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x04
 };
 
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c
index f8028181e47f..4e5a14e35210 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c
@@ -22,7 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <openssl/x509v3.h>
 #include <openssl/pkcs7.h>
 
-UINT8  mOidValue[9] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02 };
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  mOidValue[9] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02 };
 
 /**
   Check input P7Data is a wrapped ContentInfo structure or not. If not construct
@@ -145,6 +145,7 @@ WrapPkcs7Data (
   @retval     FALSE           The pop operation failed.
 
 **/
+STATIC
 BOOLEAN
 X509PopCertificate (
   IN  VOID   *X509Stack,
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
index 833b29ae9755..63cd49434e71 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
@@ -62,6 +62,7 @@
   @retval EFI_NOT_FOUND             The number of signers found was not 1.
 
 **/
+STATIC
 EFI_STATUS
 GetSignerCertificate (
   IN CONST PKCS7  *CertChain,
@@ -132,6 +133,7 @@ GetSignerCertificate (
   @retval EFI_NOT_FOUND             One or more EKU's were not found in the signature.
 
 **/
+STATIC
 EFI_STATUS
 IsEkuInCertificate (
   IN CONST X509   *Cert,
@@ -255,6 +257,7 @@ IsEkuInCertificate (
   @retval EFI_INVALID_PARAMETER     A parameter was invalid.
   @retval EFI_NOT_FOUND             One or more EKU's were not found in the signature.
 **/
+STATIC
 EFI_STATUS
 CheckEKUs (
   IN CONST X509    *SignerCert,
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c
index f118f2e9d6aa..027dbb6842dc 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptTs.c
@@ -21,7 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 //
 // OID ASN.1 Value for SPC_RFC3161_OBJID ("1.3.6.1.4.1.311.3.3.1")
 //
-UINT8  mSpcRFC3161OidValue[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  mSpcRFC3161OidValue[] = {
   0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x03, 0x03, 0x01
 };
 
@@ -43,11 +43,17 @@ typedef struct {
 //
 // ASN.1 Functions for TS_MESSAGE_IMPRINT
 //
-DECLARE_ASN1_FUNCTIONS (TS_MESSAGE_IMPRINT)
-ASN1_SEQUENCE (TS_MESSAGE_IMPRINT) = {
+GLOBAL_REMOVE_IF_UNREFERENCED
+DECLARE_ASN1_FUNCTIONS (
+  TS_MESSAGE_IMPRINT
+  )
+ASN1_SEQUENCE (TS_MESSAGE_IMPRINT) =
+{
   ASN1_SIMPLE (TS_MESSAGE_IMPRINT, HashAlgorithm, X509_ALGOR),
   ASN1_SIMPLE (TS_MESSAGE_IMPRINT, HashedMessage, ASN1_OCTET_STRING)
-} ASN1_SEQUENCE_END (TS_MESSAGE_IMPRINT)
+}
+
+ASN1_SEQUENCE_END (TS_MESSAGE_IMPRINT)
 IMPLEMENT_ASN1_FUNCTIONS (TS_MESSAGE_IMPRINT)
 
 ///
@@ -68,12 +74,18 @@ typedef struct {
 //
 // ASN.1 Functions for TS_ACCURACY
 //
-DECLARE_ASN1_FUNCTIONS (TS_ACCURACY)
-ASN1_SEQUENCE (TS_ACCURACY) = {
+GLOBAL_REMOVE_IF_UNREFERENCED
+DECLARE_ASN1_FUNCTIONS (
+  TS_ACCURACY
+  )
+ASN1_SEQUENCE (TS_ACCURACY) =
+{
   ASN1_OPT (TS_ACCURACY,     Seconds, ASN1_INTEGER),
   ASN1_IMP_OPT (TS_ACCURACY, Millis,  ASN1_INTEGER, 0),
   ASN1_IMP_OPT (TS_ACCURACY, Micros,  ASN1_INTEGER, 1)
-} ASN1_SEQUENCE_END (TS_ACCURACY)
+}
+
+ASN1_SEQUENCE_END (TS_ACCURACY)
 IMPLEMENT_ASN1_FUNCTIONS (TS_ACCURACY)
 
 ///
@@ -114,8 +126,12 @@ typedef struct {
 //
 // ASN.1 Functions for TS_TST_INFO
 //
-DECLARE_ASN1_FUNCTIONS (TS_TST_INFO)
-ASN1_SEQUENCE (TS_TST_INFO) = {
+GLOBAL_REMOVE_IF_UNREFERENCED
+DECLARE_ASN1_FUNCTIONS (
+  TS_TST_INFO
+  )
+ASN1_SEQUENCE (TS_TST_INFO) =
+{
   ASN1_SIMPLE (TS_TST_INFO,              Version,        ASN1_INTEGER),
   ASN1_SIMPLE (TS_TST_INFO,              Policy,         ASN1_OBJECT),
   ASN1_SIMPLE (TS_TST_INFO,              MessageImprint, TS_MESSAGE_IMPRINT),
@@ -126,7 +142,9 @@ ASN1_SEQUENCE (TS_TST_INFO) = {
   ASN1_OPT (TS_TST_INFO,                 Nonce,          ASN1_INTEGER),
   ASN1_EXP_OPT (TS_TST_INFO,             Tsa,            GENERAL_NAME,         0),
   ASN1_IMP_SEQUENCE_OF_OPT (TS_TST_INFO, Extensions,     X509_EXTENSION,       1)
-} ASN1_SEQUENCE_END (TS_TST_INFO)
+}
+
+ASN1_SEQUENCE_END (TS_TST_INFO)
 IMPLEMENT_ASN1_FUNCTIONS (TS_TST_INFO)
 
 /**
@@ -139,8 +157,8 @@ IMPLEMENT_ASN1_FUNCTIONS (TS_TST_INFO)
   @retval  FALSE  Invalid parameters.
 
 **/
+STATIC
 BOOLEAN
-EFIAPI
 ConvertAsn1TimeToEfiTime (
   IN  ASN1_TIME  *Asn1Time,
   OUT EFI_TIME   *EfiTime
@@ -222,8 +240,8 @@ ConvertAsn1TimeToEfiTime (
   @retval  FALSE  Invalid TimeStamp Token Information.
 
 **/
+STATIC
 BOOLEAN
-EFIAPI
 CheckTSTInfo (
   IN  CONST TS_TST_INFO  *TstInfo,
   IN  CONST UINT8        *TimestampedData,
@@ -352,8 +370,8 @@ CheckTSTInfo (
   @retval  FALSE  Invalid timestamp token.
 
 **/
+STATIC
 BOOLEAN
-EFIAPI
 TimestampTokenVerify (
   IN  CONST UINT8  *TSToken,
   IN  UINTN        TokenSize,
-- 
2.37.1.windows.1


  parent reply	other threads:[~2022-10-11 15:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 15:03 [Patch 00/12] CryptoPkg: Remove EC PCD and merge perf opt OpensslLibs Michael D Kinney
2022-10-11 15:03 ` [Patch 01/12] CryptoPkg: Document and disable deprecated crypto services Michael D Kinney
2022-10-11 15:03 ` [Patch 02/12] CryptoPkg/Library/BaseCryptLib: Add missing UNI file and fix format Michael D Kinney
2022-10-11 15:03 ` Michael D Kinney [this message]
2022-10-11 15:03 ` [Patch 04/12] CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes Michael D Kinney
2022-10-11 15:03 ` [Patch 05/12] CryptoPkg/Library: Cleanup BaseCryptLib and TlsLib Michael D Kinney
2022-10-11 15:03 ` [Patch 06/12] CryptoPkg/Library/OpensslLib: Combine all performance optimized INFs Michael D Kinney
2022-10-11 23:20   ` [edk2-devel] " Christopher Zurcher
2022-10-11 23:58     ` Michael D Kinney
2022-10-11 15:03 ` [Patch 07/12] CryptoPkg/Library/OpensslLib: Produce consistent set of APIs Michael D Kinney
2022-10-11 15:03 ` [Patch 08/12] CryptoPkg/Library/OpensslLib: Remove PrintLib from INF files Michael D Kinney
2022-10-11 15:03 ` [Patch 09/12] CryptoPkg: Remove PcdOpensslEcEnabled from CryptoPkg.dec Michael D Kinney
2022-10-11 15:03 ` [Patch 10/12] CryptoPkg: Update DSC to improve CI test coverage Michael D Kinney
2022-10-11 15:03 ` [Patch 11/12] CryptoPkg: Fixed host-based unit tests Michael D Kinney
2022-10-11 15:03 ` [Patch 12/12] CryptoPkg: Add Readme.md Michael D Kinney
2022-10-12  1:08 ` [Patch 00/12] CryptoPkg: Remove EC PCD and merge perf opt OpensslLibs Yao, Jiewen
2022-10-12  1:24   ` Michael D Kinney
2022-10-12  1:36     ` Yao, Jiewen
2022-10-12  1:55       ` Michael D Kinney
2022-10-12  2:07         ` Yao, Jiewen
2022-10-12  2:23           ` Michael D Kinney
2022-10-12  8:33             ` Yao, Jiewen
     [not found]         ` <171D30322FF3DC63.20882@groups.io>
2022-10-12  2:12           ` [edk2-devel] " 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=20221011150358.1332-4-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