replying to the whole chain.
I am not encouraging importing the source directly but still
trying to isolate the "wrapper code" and the external mbedtls
submodule management.
I am advocating that the underlying crypto implementation is 100%
"hidden" from public include/dependency and the rest of the edk2
tree. I am advocating that crypto "releases" are in essence
independent of Edk2 stable tags (obviously a stable tag would
still have reference to version tested at that time) because
crypto needs to be updated more quickly and regularly and should
have very minimal breaking dependencies.
Regarding Jiewen's options for layout my proposal would be more
like option 5. :)
Tianocore/Edk2: CryptoPkg
Tianocore/MbedTlsRepo: MbedTlsCryptoPkg
Tianocore/OpenSslRepo: OpenSslCryptoPkg
I hope that helps explain.
Regarding checking in and then moving later...well i am
skeptical. This is a breaking change and once dependencies are
formed, edk2 has historically had challenges in making these kinds
of changes.
Thanks for consideration.
Sean
Jiewen, Thanks. Option #1 makes more sense if it is the Mbedtls wrapper code. I prefer Option #1. Breaking out into multiple repos also makes it hard to align Releases across multiple repos. We already have this as an unsolved problem for edk2-platforms repo, and I am not interested in adding more repos until we have a complete solution to do edk2-platforms releases in place. Mike-----Original Message----- From: Yao, Jiewen <jiewen.yao@intel.com> Sent: Thursday, August 31, 2023 9:07 AM To: Kinney, Michael D <michael.d.kinney@intel.com>; Leif Lindholm <quic_llindhol@quicinc.com>; devel@edk2.groups.io; spbrogan@outlook.com; Hou, Wenxing <wenxing.hou@intel.com> Cc: afish@apple.com Subject: RE: [edk2-devel] [edk2/add_mbedtls PATCH 0/9] *** Add HMAC/HKDF/RSA/HASH features based on Mbedtls *** Hi Mike We are using submodule for mbedtls in this patch. Copying source code is not preferred. I think we are discussing multiple ways to layout the *mbedtls crypto wrapper*. See following 4 options. Thank you Yao, Jiewen-----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, August 31, 2023 11:45 PM To: Leif Lindholm <quic_llindhol@quicinc.com>; Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io; spbrogan@outlook.com;Hou,Wenxing <wenxing.hou@intel.com> Cc: afish@apple.com; Kinney, Michael D <michael.d.kinney@intel.com> Subject: RE: [edk2-devel] [edk2/add_mbedtls PATCH 0/9] *** Add HMAC/HKDF/RSA/HASH features based on Mbedtls *** I have not looked at the Mbedtls patches in detail yet, but I am curious if it is possible to add the mbedtls based library instances of the edk2 crypto libraries to the existing CryptoPkg and pull the mbedtls sources into the CryptoPkg using a submodule just like openssl? This way, platforms can choose either openssl or mbedtls library instances from CryptoPkg and all INFs would continue to only list CryptoPkg.dec. I think use of submodules makes the most sense for content that edk2 consumes as read-only and edk2 makes decisions to jump from one validated release to the next validated release of the submodule content. In general, we do not want to copy source from a different project into TianoCore repos because of the overhead to keep them in sync. An exception to this is something like cmocka where this was done for CI stability issues and the copy in TianoCore is an automated sync of the upstream repo. Thanks, Mike-----Original Message----- From: Leif Lindholm <quic_llindhol@quicinc.com> Sent: Thursday, August 31, 2023 4:15 AM To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io; spbrogan@outlook.com; Hou, Wenxing <wenxing.hou@intel.com> Cc: afish@apple.com; Kinney, Michael D <michael.d.kinney@intel.com> Subject: Re: [edk2-devel] [edk2/add_mbedtls PATCH 0/9] *** Add HMAC/HKDF/RSA/HASH features based on Mbedtls *** Like Sean, I'm very positive to the work - and I'm excited about the opportunity to formalise the abstractions. But Sean is also asking to import the mbedTLS code outright insteadofusing submodules, which adds an additional dimension to the matrixbelow.I'm not too concerned over the infrastructure change as such, but I would prefer to not move the dial even further in the direction of "upstream is a swarm of repositories". This adds complexity for new developers. And submodules are way easier for upstream to trackexternalprojects through. At the cost of complicating the maintenance process for released products. Which isn't great. Am I kicking the can too far down the road if I suggest we do some brainstorming around ways to achieve this with the least amount of friction for everyone at the plugfest in October? Regards, Leif On 2023-08-31 03:34, Yao, Jiewen wrote:Hi Sean/Andrew/Leif/Mike Now, I think we actually have multiple options to handle this: 1) CryptoPkg in edk2 repo (add MbedTls to existing CryptoPkg) 2) CryptoPkg in edk2 repo + a new MbedTlsCryptoPkg in edk2 repo 3) CryptoPkg in edk2 repo + MbedTlsCryptoPkg in a new repo 4) Move CryptoPkg from edk2 repo to OpensslCryptoPkg in a new repo+MbedTlsCryptoPkg in another new repoCurrent patch is for option 1). Sean's proposal is for option 4). I feel 4) is very aggressive. My worry is that it will involve manyinfrastructure change such as CI, and all edk2 platforms.What about 2) or 3) ? Thank you Yao, Jiewen-----Original Message----- From: Yao, Jiewen Sent: Thursday, August 31, 2023 8:10 AM To: devel@edk2.groups.io; spbrogan@outlook.com; Hou, Wenxing <wenxing.hou@intel.com> Cc: afish@apple.com; quic_llindhol@quicinc.com; Kinney, Michael D <michael.d.kinney@intel.com> Subject: RE: [edk2-devel] [edk2/add_mbedtls PATCH 0/9] *** Add HMAC/HKDF/RSA/HASH features based on Mbedtls *** Hi Sean Thanks for the feedback. Personally, I don't have strong opinionon this.Since this is a big change, I would like to have Steward member'sopinion.Hi Andrew/Leif/Mike What do you think? Thank you Yao, Jiewen-----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf OfSeanSent: Thursday, August 31, 2023 2:57 AM To: devel@edk2.groups.io; Hou, Wenxing <wenxing.hou@intel.com> Subject: Re: [edk2-devel] [edk2/add_mbedtls PATCH 0/9] *** Add HMAC/HKDF/RSA/HASH features based on Mbedtls *** I appreciate and really like this work to enable mbedtls but Idon'tlike the idea of adding another submodule to edk2. For a long time there has been discussion about formalizing the abstraction of the edk2 crypto api so that it would be practicaltoimplement edk2's crypto using various libraries. I propose weremoveopenssl from the edk2 CryptoPkg and into the OpenSslCryptoPkg inanothernew tianocore repository dedicated to OpenSsl. MbedTls couldthen bechecked into the MbedTlsCryptoPkg and added to another newrepository.This would also have the benefit of breaking the tight couplingof edk2stable tags from the crypto used in the code base (crypto hasmorewidely tracked vulnerabilities). Happy to discuss more if others have different ideas. Thanks Sean On 8/30/2023 12:52 AM, Wenxing Hou wrote:*** Add BaseCryptLibMbedTls for CryptoPkg, which can be analternativetoOpenSSL in some scenarios. There are four features in the patch: HMAC/HKDF/RSA/HASH.***Wenxing Hou (9): CryptoPkg: Add mbedtls submodule for EDKII CryptoPkg: Add mbedtls_config and MbedTlsLib.inf CryptoPkg: Add HMAC functions based on Mbedtls CryptoPkg: Add HKDF functions based on Mbedtls CryptoPkg: Add RSA functions based on Mbedtls CryptoPkg: Add all .inf files for BaseCryptLibMbedTls CryptoPkg: Add Null functions for building pass CryptoPkg: Add MD5/SHA1/SHA2 functions based on Mbedtls CryptoPkg: Add Mbedtls submodule in CI .gitmodules | 3 + .pytool/CISettings.py | 2 + CryptoPkg/CryptoPkg.ci.yaml | 66 +- CryptoPkg/CryptoPkg.dec | 4 + CryptoPkg/CryptoPkgMbedTls.dsc | 280 ++ .../BaseCryptLibMbedTls/BaseCryptLib.inf | 81 + .../BaseCryptLibMbedTls/Bn/CryptBnNull.c | 520 +++ .../Cipher/CryptAeadAesGcmNull.c | 100 + .../BaseCryptLibMbedTls/Cipher/CryptAesNull.c | 159 + .../BaseCryptLibMbedTls/Hash/CryptMd5.c | 234 + .../BaseCryptLibMbedTls/Hash/CryptMd5Null.c | 163 + .../Hash/CryptParallelHashNull.c | 40 + .../BaseCryptLibMbedTls/Hash/CryptSha1.c | 234 + .../BaseCryptLibMbedTls/Hash/CryptSha1Null.c | 166 + .../BaseCryptLibMbedTls/Hash/CryptSha256.c | 227 + .../Hash/CryptSha256Null.c | 162 + .../BaseCryptLibMbedTls/Hash/CryptSha512.c | 447 ++ .../Hash/CryptSha512Null.c | 275 ++ .../BaseCryptLibMbedTls/Hash/CryptSm3Null.c | 164 + .../BaseCryptLibMbedTls/Hmac/CryptHmac.c | 620 +++ .../BaseCryptLibMbedTls/Hmac/CryptHmacNull.c | 359 ++ .../BaseCryptLibMbedTls/InternalCryptLib.h | 44 + .../BaseCryptLibMbedTls/Kdf/CryptHkdf.c | 372 ++ .../BaseCryptLibMbedTls/Kdf/CryptHkdfNull.c | 192 + .../BaseCryptLibMbedTls/PeiCryptLib.inf | 101 + .../BaseCryptLibMbedTls/PeiCryptLib.uni | 25 + .../BaseCryptLibMbedTls/Pem/CryptPemNull.c | 69 + .../Pk/CryptAuthenticodeNull.c | 45 + .../BaseCryptLibMbedTls/Pk/CryptDhNull.c | 150 + .../BaseCryptLibMbedTls/Pk/CryptEcNull.c | 578 +++ .../Pk/CryptPkcs1OaepNull.c | 51 + .../Pk/CryptPkcs5Pbkdf2Null.c | 48 + .../Pk/CryptPkcs7Internal.h | 83 + .../Pk/CryptPkcs7SignNull.c | 53 + .../Pk/CryptPkcs7VerifyEkuNull.c | 152 + .../Pk/CryptPkcs7VerifyEkuRuntime.c | 56 + .../Pk/CryptPkcs7VerifyNull.c | 163 + .../Pk/CryptPkcs7VerifyRuntime.c | 38 + .../BaseCryptLibMbedTls/Pk/CryptRsaBasic.c | 268 ++ .../Pk/CryptRsaBasicNull.c | 121 + .../BaseCryptLibMbedTls/Pk/CryptRsaExt.c | 337 ++ .../BaseCryptLibMbedTls/Pk/CryptRsaExtNull.c | 117 + .../BaseCryptLibMbedTls/Pk/CryptRsaPss.c | 164 + .../BaseCryptLibMbedTls/Pk/CryptRsaPssNull.c | 46 + .../BaseCryptLibMbedTls/Pk/CryptRsaPssSign.c | 231 + .../Pk/CryptRsaPssSignNull.c | 60 + .../BaseCryptLibMbedTls/Pk/CryptTsNull.c | 42 + .../BaseCryptLibMbedTls/Pk/CryptX509Null.c | 753 ++++ .../BaseCryptLibMbedTls/Rand/CryptRandNull.c | 56 + .../BaseCryptLibMbedTls/RuntimeCryptLib.inf | 92 + .../BaseCryptLibMbedTls/RuntimeCryptLib.uni | 22 + .../BaseCryptLibMbedTls/SecCryptLib.inf | 84 + .../BaseCryptLibMbedTls/SecCryptLib.uni | 17 + .../BaseCryptLibMbedTls/SmmCryptLib.inf | 92 + .../BaseCryptLibMbedTls/SmmCryptLib.uni | 22 + .../SysCall/ConstantTimeClock.c | 75 + .../BaseCryptLibMbedTls/SysCall/CrtWrapper.c | 58 + .../SysCall/RuntimeMemAllocation.c | 462 ++ .../SysCall/TimerWrapper.c | 198 + .../BaseCryptLibMbedTls/TestBaseCryptLib.inf | 78 + CryptoPkg/Library/MbedTlsLib/CrtWrapper.c | 96 + CryptoPkg/Library/MbedTlsLib/EcSm2Null.c | 495 +++ .../Include/mbedtls/mbedtls_config.h | 3823+++++++++++++++++CryptoPkg/Library/MbedTlsLib/MbedTlsLib.inf | 173 + .../Library/MbedTlsLib/MbedTlsLibFull.inf | 177 + CryptoPkg/Library/MbedTlsLib/mbedtls | 1 + 66 files changed, 14683 insertions(+), 3 deletions(-) create mode 100644 CryptoPkg/CryptoPkgMbedTls.dsc create mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/BaseCryptLib.infcreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Bn/CryptBnNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Cipher/CryptAeadAesGcmNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Cipher/CryptAesNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptMd5.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptMd5Null.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptParallelHashNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha1.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha1Null.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha256.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha256Null.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha512.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSha512Null.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hash/CryptSm3Null.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmac.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmacNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/InternalCryptLib.hcreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Kdf/CryptHkdf.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Kdf/CryptHkdfNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.infcreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/PeiCryptLib.unicreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pem/CryptPemNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptAuthenticodeNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptDhNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptEcNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs1OaepNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs5Pbkdf2Null.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs7Internal.hcreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs7SignNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs7VerifyEkuNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs7VerifyEkuRuntime.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs7VerifyNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs7VerifyRuntime.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaBasic.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaBasicNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaExt.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaExtNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaPss.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaPssNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaPssSign.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptRsaPssSignNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptTsNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptX509Null.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/Rand/CryptRandNull.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.infcreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/RuntimeCryptLib.unicreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.infcreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SecCryptLib.unicreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.infcreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SmmCryptLib.unicreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/ConstantTimeClock.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/RuntimeMemAllocation.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/TimerWrapper.ccreate mode 100644CryptoPkg/Library/BaseCryptLibMbedTls/TestBaseCryptLib.infcreate mode 100644 CryptoPkg/Library/MbedTlsLib/CrtWrapper.c create mode 100644 CryptoPkg/Library/MbedTlsLib/EcSm2Null.c create mode 100644CryptoPkg/Library/MbedTlsLib/Include/mbedtls/mbedtls_config.hcreate mode 100644CryptoPkg/Library/MbedTlsLib/MbedTlsLib.infcreate mode 100644CryptoPkg/Library/MbedTlsLib/MbedTlsLibFull.infcreate mode 160000 CryptoPkg/Library/MbedTlsLib/mbedtls