diff options
author | Michael D Kinney <michael.d.kinney@intel.com> | 2022-10-03 20:45:20 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-10-24 07:49:43 +0000 |
commit | 8f8372439d8ec5f565dbda1548c18deb068e0080 (patch) | |
tree | 2f87b4e5e6b705f4214f997fee7b38ed948adfb0 /CryptoPkg | |
parent | 8437368c69bb124faf266701865f1a0b3f0c5804 (diff) | |
download | edk2-8f8372439d8ec5f565dbda1548c18deb068e0080.tar.gz edk2-8f8372439d8ec5f565dbda1548c18deb068e0080.tar.bz2 edk2-8f8372439d8ec5f565dbda1548c18deb068e0080.zip |
CryptoPkg/Library/BaseCryptLib: Update internal functions/variables
* 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>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'CryptoPkg')
-rw-r--r-- | CryptoPkg/CryptoPkg.ci.yaml | 3 | ||||
-rw-r--r-- | CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmac.c | 7 | ||||
-rw-r--r-- | CryptoPkg/Library/BaseCryptLib/Kdf/CryptHkdf.c | 5 | ||||
-rw-r--r-- | CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c | 2 | ||||
-rw-r--r-- | CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c | 3 | ||||
-rw-r--r-- | CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c | 3 | ||||
-rw-r--r-- | 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 2fa3a3d5ee..ca129d6ae5 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 2786267a0b..1ae33b6709 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 ffaf5fb131..34e81246ed 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 aa4a33364d..6b0dddd4af 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 f8028181e4..4e5a14e352 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 833b29ae97..63cd49434e 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 @@ Exit: @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 @@ Exit: @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 f118f2e9d6..027dbb6842 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 @@ _Exit: @retval FALSE Invalid timestamp token.
**/
+STATIC
BOOLEAN
-EFIAPI
TimestampTokenVerify (
IN CONST UINT8 *TSToken,
IN UINTN TokenSize,
|