Re: Unified API for Hashing Algorithms in EDK2
Sukerkar, Amol N
Hi Mike and Nate,
toggle quoted message
Show quoted text
With our implementation we are trying to address the following in EDKII: 1. A common Hashing API for UEFI drivers to consume instead of the current API that directly calls into the specific hashing algorithm, for instance, SHA1_Init, SHA256_Update, etc. Due to a stronger hashing algorithm requirement, certain drivers need to be upgraded to SHA384 from SHA256 and the unified API is proposed, so, while upgrading we remove the hard-coded dependency on each hashing algorithm API. 2. The size issue as a result of statically linking openssl/cryptolib API to the consuming driver. There are two ways we tried to address this issue, although, we didn't explicitly defined a PPI to address it. a. Introduced a fixed PCD per hashing algorithm to include/exclude a particular algorithm from BIOS. b. Use a register mechanism to link the instance of a particular hashing algorithm to Unified API library. This is configurable using PCD. Note that 2.a and 2.b implementation is very similar to HashLibBaseCryptoRouter used for TPM2 operations. From the size and static linking perspective, I believe we can have a discussion between 2.a and 2.b with Mike's implementation(https://github.com/mdkinney/edk2/tree/CryptoPkg_PPI_Protocol_Proposal_V5) below. We still need a common hashing API so the hashing algorithm strength for a particular driver can be increased without having to modify the consumer driver code. Comments are welcome. Thanks, Amol -----Original Message-----
From: rfc@edk2.groups.io <rfc@edk2.groups.io> On Behalf Of Sukerkar, Amol N Sent: Thursday, November 21, 2019 4:45 PM To: rfc@edk2.groups.io; Kinney, Michael D <michael.d.kinney@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>; 'sean.brogan@...' <sean.brogan@...>; Matthew Carlson <macarl@...>; Gao, Liming <liming.gao@...>; Feng, Bob C <bob.c.feng@...>; Wang, Jian J <jian.j.wang@...>; Lu, XiaoyuX <xiaoyux.lu@...> Cc: Agrawal, Sachin <sachin.agrawal@...>; Sukerkar, Amol N <amol.n.sukerkar@...> Subject: Re: [edk2-rfc] Unified API for Hashing Algorithms in EDK2 Thanks, Nate and Mike! I am going through the code and comments and will respond shortly. In the meantime, here is the GitHub link to my PoC for the community to look at and comment: https://github.com/ansukerk/edk2. Best regards, Amol -----Original Message----- From: rfc@edk2.groups.io <rfc@edk2.groups.io> On Behalf Of Michael D Kinney Sent: Thursday, November 21, 2019 4:37 PM To: rfc@edk2.groups.io; Desimone, Nathaniel L <nathaniel.l.desimone@...>; Sukerkar, Amol N <amol.n.sukerkar@...>; Kinney, Michael D <michael.d.kinney@...>; 'sean.brogan@...' <sean.brogan@...>; Matthew Carlson <macarl@...>; Gao, Liming <liming.gao@...>; Feng, Bob C <bob.c.feng@...>; Wang, Jian J <jian.j.wang@...>; Lu, XiaoyuX <xiaoyux.lu@...> Cc: Agrawal, Sachin <sachin.agrawal@...> Subject: Re: [edk2-rfc] Unified API for Hashing Algorithms in EDK2 Nate and Amol, There is some work already started by Sean and Matt that implements a PEIM, DXE Driver, and SMM Driver to produce Protocol/PPI that wraps the BaseCryptLib services. This content broken out into its own package is available here: https://github.com/microsoft/mu_plus/tree/dev/201908/SharedCryptoPkg I have ported and simplified this content into a proposed set of patches to the CryptoPkg. It uses a structured PCD to configure the services mapped into the Protocols/PPIs and avoids the issue Nate notes below with protocols and PPIs including all of the BaseCryptLib services. The structured PCD allows families of crypto services or individual services within a family to be enabled/disabled. https://github.com/mdkinney/edk2/tree/CryptoPkg_PPI_Protocol_Proposal_V5 For example, the DSC file PCD statements to enable the SHA1 family and SHA256 family of hash services with the HashAll service disabled is: [PcdsFixedAtBuild] gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Services.HashAll | FALSE gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Services.HashAll | FALSE Please take a look at this proposal and let me know if this can be used to address. https://bugzilla.tianocore.org/show_bug.cgi?id=2151 There is currently a limitation in the structured PCD feature that does not allow the structured PCD field values to be set in the scope of a module in a <PcdsFixedAtBuild> section. To work around this limitation, the CryptoPkg DSC file has a define called CRYPTO_SERVICES that can be set to ALL, NONE, MIN_PEI, or MIN_DXE_MIN_SMM. The default is ALL. Building with each of these values will build the modules with different sets of enabled services that matches the services enabled using multiple modules in the work from Sean and Matt. If this limitation is addressed in BaseTools, then CryptoPkg could remove the CRYPTO_SERVIES define and all !if statements. Thanks, Mike -----Original Message----- |
|