Looks good to me.
Reviewed-by: Yi Li <yi1...@intel.com>

-----Original Message-----
From: Hou, Wenxing <wenxing....@intel.com> 
Sent: Wednesday, April 24, 2024 4:25 PM
To: devel@edk2.groups.io
Cc: Yao, Jiewen <jiewen....@intel.com>; Li, Yi1 <yi1...@intel.com>
Subject: [PATCH v2] Add SHA3/SM3 functions with openssl for Mbedtls

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4177



Because the Mbedlts 3.3.0 doesn't have SHA3 and Sm3, the SHA3 and Sm3

implementaion based on Openssl.

And the implementaion has passed build check.



Cc: Jiewen Yao <jiewen....@intel.com>

Cc: Yi Li <yi1...@intel.com>

Signed-off-by: Wenxing Hou <wenxing....@intel.com>

---

 CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf   | 9 +++++++--

 CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf    | 9 +++++++--

 .../Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf      | 3 ++-

 CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf    | 9 +++++++--

 .../Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf     | 4 +++-

 CryptoPkg/Library/MbedTlsLib/MbedTlsLib.inf              | 6 ++++++

 CryptoPkg/Library/MbedTlsLib/MbedTlsLibFull.inf          | 6 ++++++

 7 files changed, 38 insertions(+), 8 deletions(-)



diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf

index 16def792c5..999054500f 100644

--- a/CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf

+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.inf

@@ -18,6 +18,7 @@

   MODULE_TYPE                    = DXE_DRIVER

   VERSION_STRING                 = 1.0

   LIBRARY_CLASS                  = BaseCryptLib|DXE_DRIVER DXE_CORE 
UEFI_APPLICATION UEFI_DRIVER

+  DEFINE BASE_CRYPT_PATH         = ../BaseCryptLib

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -31,10 +32,14 @@

   Cipher/CryptAes.c

   Hash/CryptSha256.c

   Hash/CryptSha512.c

-  Hash/CryptParallelHashNull.c

-  Hash/CryptSm3Null.c

   Hash/CryptMd5.c

   Hash/CryptSha1.c

+  $(BASE_CRYPT_PATH)/Hash/CryptCShake256.c

+  $(BASE_CRYPT_PATH)/Hash/CryptDispatchApDxe.c

+  $(BASE_CRYPT_PATH)/Hash/CryptParallelHash.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSha3.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSm3.c

+  $(BASE_CRYPT_PATH)/Hash/CryptXkcp.c

   Hmac/CryptHmac.c

   Kdf/CryptHkdf.c

   Pk/CryptRsaBasic.c

diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf

index 72b22a24e8..a153c0c8e4 100644

--- a/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf

+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.inf

@@ -26,6 +26,7 @@

   MODULE_TYPE                    = PEIM

   VERSION_STRING                 = 1.0

   LIBRARY_CLASS                  = BaseCryptLib|PEIM PEI_CORE

+  DEFINE BASE_CRYPT_PATH         = ../BaseCryptLib

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -38,9 +39,13 @@

   Hash/CryptMd5.c

   Hash/CryptSha1.c

   Hash/CryptSha256.c

-  Hash/CryptSm3Null.c

   Hash/CryptSha512.c

-  Hash/CryptParallelHashNull.c

+  $(BASE_CRYPT_PATH)/Hash/CryptCShake256.c

+  $(BASE_CRYPT_PATH)/Hash/CryptDispatchApPei.c

+  $(BASE_CRYPT_PATH)/Hash/CryptParallelHash.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSha3.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSm3.c

+  $(BASE_CRYPT_PATH)/Hash/CryptXkcp.c

   Hmac/CryptHmac.c

   Kdf/CryptHkdf.c

   Cipher/CryptAes.c

diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf

index 9f17ef00bf..1b33dbdaad 100644

--- a/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf

+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.inf

@@ -25,6 +25,7 @@

   VERSION_STRING                 = 1.0

   LIBRARY_CLASS                  = BaseCryptLib|DXE_RUNTIME_DRIVER

   CONSTRUCTOR                    = RuntimeCryptLibConstructor

+  DEFINE BASE_CRYPT_PATH         = ../BaseCryptLib

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -37,9 +38,9 @@

   Hash/CryptMd5.c

   Hash/CryptSha1.c

   Hash/CryptSha256.c

-  Hash/CryptSm3Null.c

   Hash/CryptSha512.c

   Hash/CryptParallelHashNull.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSm3.c

   Hmac/CryptHmac.c

   Kdf/CryptHkdf.c

   Cipher/CryptAes.c

diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf

index 40c56d1b7d..d9a9cb8d10 100644

--- a/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf

+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.inf

@@ -24,6 +24,7 @@

   VERSION_STRING                 = 1.0

   PI_SPECIFICATION_VERSION       = 0x0001000A

   LIBRARY_CLASS                  = BaseCryptLib|DXE_SMM_DRIVER SMM_CORE 
MM_STANDALONE

+  DEFINE BASE_CRYPT_PATH         = ../BaseCryptLib

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -36,9 +37,13 @@

   Hash/CryptMd5.c

   Hash/CryptSha1.c

   Hash/CryptSha256.c

-  Hash/CryptSm3Null.c

   Hash/CryptSha512.c

-  Hash/CryptParallelHashNull.c

+  $(BASE_CRYPT_PATH)/Hash/CryptCShake256.c

+  $(BASE_CRYPT_PATH)/Hash/CryptDispatchApMm.c

+  $(BASE_CRYPT_PATH)/Hash/CryptParallelHash.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSha3.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSm3.c

+  $(BASE_CRYPT_PATH)/Hash/CryptXkcp.c

   Hmac/CryptHmac.c

   Kdf/CryptHkdf.c

   Cipher/CryptAes.c

diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf

index def990b996..6a7f4bdbf6 100644

--- a/CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf

+++ b/CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.inf

@@ -18,6 +18,7 @@

   MODULE_TYPE                    = DXE_DRIVER

   VERSION_STRING                 = 1.0

   LIBRARY_CLASS                  = BaseCryptLib|DXE_DRIVER DXE_CORE 
UEFI_APPLICATION UEFI_DRIVER

+  DEFINE BASE_CRYPT_PATH         = ../BaseCryptLib

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -31,9 +32,10 @@

   Cipher/CryptAes.c

   Hash/CryptSha256.c

   Hash/CryptSha512.c

-  Hash/CryptSm3Null.c

   Hash/CryptMd5.c

   Hash/CryptSha1.c

+  $(BASE_CRYPT_PATH)/Hash/CryptSm3.c

+  Hash/CryptParallelHashNull.c

   Hmac/CryptHmac.c

   Kdf/CryptHkdf.c

   Pk/CryptRsaBasic.c

diff --git a/CryptoPkg/Library/MbedTlsLib/MbedTlsLib.inf 
b/CryptoPkg/Library/MbedTlsLib/MbedTlsLib.inf

index adcf770902..93f8e69383 100644

--- a/CryptoPkg/Library/MbedTlsLib/MbedTlsLib.inf

+++ b/CryptoPkg/Library/MbedTlsLib/MbedTlsLib.inf

@@ -13,6 +13,7 @@

   MODULE_TYPE                    = BASE

   VERSION_STRING                 = 1.0

   LIBRARY_CLASS                  = MbedTlsLib

+  DEFINE OPENSSL_PATH            = ../OpensslLib/openssl

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -21,6 +22,11 @@

 #

 

 [Sources]

+# Openssl files list starts here

+  $(OPENSSL_PATH)/crypto/mem_clr.c

+  $(OPENSSL_PATH)/crypto/sha/keccak1600.c

+  $(OPENSSL_PATH)/crypto/sm3/sm3.c

+# Openssl files list ends here

   Include/mbedtls/mbedtls_config.h

   mbedtls/library/aes.c

   mbedtls/library/asn1parse.c

diff --git a/CryptoPkg/Library/MbedTlsLib/MbedTlsLibFull.inf 
b/CryptoPkg/Library/MbedTlsLib/MbedTlsLibFull.inf

index 7715392a9d..98695312cf 100644

--- a/CryptoPkg/Library/MbedTlsLib/MbedTlsLibFull.inf

+++ b/CryptoPkg/Library/MbedTlsLib/MbedTlsLibFull.inf

@@ -13,6 +13,7 @@

   MODULE_TYPE                    = BASE

   VERSION_STRING                 = 1.0

   LIBRARY_CLASS                  = MbedTlsLib

+  DEFINE OPENSSL_PATH            = ../OpensslLib/openssl

 

 #

 # The following information is for reference only and not required by the 
build tools.

@@ -21,6 +22,11 @@

 #

 

 [Sources]

+# Openssl files list starts here

+  $(OPENSSL_PATH)/crypto/mem_clr.c

+  $(OPENSSL_PATH)/crypto/sha/keccak1600.c

+  $(OPENSSL_PATH)/crypto/sm3/sm3.c

+# Openssl files list ends here

   Include/mbedtls/mbedtls_config.h

   mbedtls/library/aes.c

   mbedtls/library/asn1parse.c

-- 

2.26.2.windows.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118271): https://edk2.groups.io/g/devel/message/118271
Mute This Topic: https://groups.io/mt/105706562/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to