Skip to content

Commit 05c7a52

Browse files
authored
Add X509CompareDateTime Function (#1355)
## Description Add X509CompareDateTime function. This function was missed before because it has a return type of INT32 which is not included in current generate_cryptodriver.py. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - [x] Backport to release branch? ## How This Was Tested Tested with X64 STANDARD/TINY_SHA, build successfully. ## Integration Instructions When integrating this, consume the latest MU_CRYPTO_RELEASE [PR](microsoft/mu_crypto_release#132) too.
1 parent 7a9ec45 commit 05c7a52

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

CryptoPkg/CryptoPkg.dec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceEcGetPublicKeyFromX509|FALSE|BOOLEAN|0xcc
293293
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceEcDsaSign|FALSE|BOOLEAN|0xcd
294294
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceEcDsaVerify|FALSE|BOOLEAN|0xce
295+
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509CompareDateTime|FALSE|BOOLEAN|0xcf
295296
# AUTOGEN ENDS
296297
# ****************************************************************************
297298
# MU_CHANGE [END]

CryptoPkg/Include/Protocol/Crypto.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/// the EDK II Crypto Protocol is extended, this version define must be
2121
/// increased.
2222
///
23-
#define EDKII_CRYPTO_VERSION 18 // MU_CHANGE
23+
#define EDKII_CRYPTO_VERSION 19 // MU_CHANGE
2424

2525
///
2626
/// EDK II Crypto Protocol forward declaration
@@ -44,7 +44,7 @@ UINTN
4444
// AUTOGENERATED BY CryptoBinPkg\Driver\Packaging\generate_cryptodriver.py
4545
// AUTOGENED AS temp_Crypto.h
4646
// DO NOT MODIFY
47-
// GENERATED ON: 2024-04-08 11:12:11.528450
47+
// GENERATED ON: 2025-05-08 21:32:24.776904
4848

4949
// =============================================================================
5050
// HMACSHA256 functions
@@ -2295,6 +2295,27 @@ BOOLEAN
22952295
IN OUT UINTN *DateTimeSize
22962296
);
22972297

2298+
/**
2299+
Compare DateTime1 object and DateTime2 object.
2300+
If DateTime1 is NULL, then return -2.
2301+
If DateTime2 is NULL, then return -2.
2302+
If DateTime1 == DateTime2, then return 0
2303+
If DateTime1 > DateTime2, then return 1
2304+
If DateTime1 < DateTime2, then return -1
2305+
@param[in] DateTime1 Pointer to a DateTime Ojbect
2306+
@param[in] DateTime2 Pointer to a DateTime Object
2307+
@retval 0 If DateTime1 == DateTime2
2308+
@retval 1 If DateTime1 > DateTime2
2309+
@retval -1 If DateTime1 < DateTime2
2310+
**/
2311+
// FROM BaseCryptLib.h:2817
2312+
typedef
2313+
INT32
2314+
(EFIAPI *EDKII_CRYPTO_X509_COMPARE_DATE_TIME)(
2315+
IN CONST VOID *DateTime1,
2316+
IN CONST VOID *DateTime2
2317+
);
2318+
22982319
/**
22992320
Retrieve the Key Usage from one X.509 certificate.
23002321
@param[in] Cert Pointer to the DER-encoded X509 certificate.
@@ -4772,6 +4793,7 @@ struct _EDKII_CRYPTO_PROTOCOL {
47724793
EDKII_CRYPTO_EC_GET_PUBLIC_KEY_FROM_X509 EcGetPublicKeyFromX509;
47734794
EDKII_CRYPTO_EC_DSA_SIGN EcDsaSign;
47744795
EDKII_CRYPTO_EC_DSA_VERIFY EcDsaVerify;
4796+
EDKII_CRYPTO_X509_COMPARE_DATE_TIME X509CompareDateTime;
47754797
};
47764798

47774799
// AUTOGEN ENDS

CryptoPkg/Library/BaseCryptLibOnProtocolPpi/CryptLib.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ CryptoServiceNotAvailable (
100100
// AUTOGENERATED BY CryptoBinPkg\Driver\Packaging\generate_cryptodriver.py
101101
// AUTOGENED AS temp_CryptLib.c
102102
// DO NOT MODIFY
103-
// GENERATED ON: 2024-04-08 11:12:11.608999
103+
// GENERATED ON: 2025-05-08 21:32:26.186748
104104

105105
// =============================================================================
106106
// HMACSHA256 functions
@@ -5212,6 +5212,30 @@ EcDsaVerify (
52125212
CALL_CRYPTO_SERVICE (EcDsaVerify, (EcContext, HashNid, MessageHash, HashSize, Signature, SigSize), FALSE);
52135213
}
52145214

5215+
/**
5216+
Compare DateTime1 object and DateTime2 object.
5217+
If DateTime1 is NULL, then return -2.
5218+
If DateTime2 is NULL, then return -2.
5219+
If DateTime1 == DateTime2, then return 0
5220+
If DateTime1 > DateTime2, then return 1
5221+
If DateTime1 < DateTime2, then return -1
5222+
@param[in] DateTime1 Pointer to a DateTime Ojbect
5223+
@param[in] DateTime2 Pointer to a DateTime Object
5224+
@retval 0 If DateTime1 == DateTime2
5225+
@retval 1 If DateTime1 > DateTime2
5226+
@retval -1 If DateTime1 < DateTime2
5227+
**/
5228+
// See BaseCryptLib.h:2817
5229+
INT32
5230+
EFIAPI
5231+
X509CompareDateTime (
5232+
IN CONST VOID *DateTime1,
5233+
IN CONST VOID *DateTime2
5234+
)
5235+
{
5236+
CALL_CRYPTO_SERVICE (X509CompareDateTime, (DateTime1, DateTime2), 0);
5237+
}
5238+
52155239
// AUTOGEN ENDS
52165240
// ****************************************************************************
52175241
// MU_CHANGE [END]

CryptoPkg/Library/BaseCryptLibOnProtocolPpi/DxeCryptLib.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509GetExtensionData # CONSUMES
142142
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509GetValidity # CONSUMES
143143
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509FormatDateTime # CONSUMES
144+
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509CompareDateTime # CONSUMES
144145
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509GetKeyUsage # CONSUMES
145146
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509GetExtendedKeyUsage # CONSUMES
146147
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceX509VerifyCertChain # CONSUMES

0 commit comments

Comments
 (0)