-
Notifications
You must be signed in to change notification settings - Fork 162
BaseCryptOnOneCrypto Support #1570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/202502
Are you sure you want to change the base?
Conversation
ebff900 to
d50126f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/202502 #1570 +/- ##
=================================================
Coverage ? 0.66%
=================================================
Files ? 939
Lines ? 329534
Branches ? 2647
=================================================
Hits ? 2195
Misses ? 327161
Partials ? 178
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5193c91 to
97a90e5
Compare
CryptoPkg/Library/BaseCryptLibOnOneCrypto/StandaloneMmCryptLib.inf
Outdated
Show resolved
Hide resolved
|
Working on fixing the failing gates - uncrustify is failing. |
1847faa to
8818fc3
Compare
faed009 to
acbc9d3
Compare
44569c4 to
cc0e40d
Compare
…ffixes Remove _EX suffix from crypto macro names in unit tests to align with standardized naming conventions. This simplifies the API and makes it consistent across all cryptographic functions. Changes: - Remove _EX from HMAC, hash, and cipher function calls - Update test variable naming for clarity - Delete obsolete Crypto.pcd.ALL.inc.dsc file - Update TestBaseCryptLibHost.inf to reflect current test structure
Add comprehensive OneCrypto.h protocol header defining a unified interface for cryptographic operations across all firmware phases (DXE, SMM, MM). Features: - 171+ cryptographic function typedefs organized into 14 functional groups: * HMAC (SHA256, SHA384) * Big Number operations * AES operations * Hash functions (MD5, SHA1, SHA256, SHA384, SHA512, SM3) * Key derivation (HKDF) * Asymmetric crypto (RSA, EC, DH) * PKCS operations * X.509 certificate handling * TLS primitives * Random number generation * Timestamp verification * Provider version info - Complete doxygen documentation with @SInCE version tags - Protocol versioning support (Major.Minor) - Support for Asn1GetTag and X509CompareDateTime - Buffer-based GetCryptoProviderVersionText API The protocol enables a single cryptographic binary to serve all firmware phases, reducing code duplication and improving security consistency.
b53141d to
e2c6d15
Compare
| Implements the BaseCryptLib and TlsLib using the services of the OneCrypto | ||
| Protocol/PPI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Implements the BaseCryptLib and TlsLib using the services of the OneCrypto | |
| Protocol/PPI. | |
| Implements the backend crypto services of BaseCryptLib and TlsLib using the OneCrypto | |
| Protocol. |
Add GetCryptoProviderVersionText function declaration to BaseCryptLib.h with buffer-based API design. Changes: - Add GetCryptoProviderVersionText function with buffer/size parameters - Function supports query mode (Buffer=NULL returns required size) - Returns EFI_SUCCESS, EFI_BUFFER_TOO_SMALL, or EFI_INVALID_PARAMETER - Replaces previous pointer-returning API for better safety - Enables callers to control memory allocation This API allows cryptographic provider version information (e.g., OpenSSL version) to be retrieved safely without exposing internal string pointers.
Add library implementations that wrap the OneCrypto protocol for use across DXE, SMM, and Standalone MM firmware phases. New libraries: - DxeCryptLib: DXE phase wrapper (locates gOneCryptoDxeProtocolGuid) - SmmCryptLib: SMM phase wrapper (locates gOneCryptoSmmProtocolGuid) - StandaloneMmCryptLib: Standalone MM wrapper (locates gOneCryptoMmProtocolGuid) All libraries share common implementation: - OneCryptoLib.c (6520 lines): Complete BaseCryptLib API wrappers * All 171+ functions call through protocol using CALL_CRYPTO_SERVICE macro * Version checking ensures protocol supports requested operations * Automatic fallback to 'not available' for unsupported operations * Includes Asn1GetTag and X509CompareDateTime support * Buffer-based GetCryptoProviderVersionText implementation - Phase-specific constructors locate the appropriate protocol variant - Unified GetCryptoServices() API returns protocol pointer - Complete error handling with DEBUG output Benefits: - Single protocol implementation serves all phases - Consistent crypto behavior across firmware - Reduced code duplication - Simplified maintenance and updates - Version-aware protocol consumption
- Add gOneCryptoSmmProtocolGuid to CryptoPkg.dec [Protocols] section - Add GuidCheck exception for OneCryptoBinStandaloneMm and OneCryptoBinSupvMm which intentionally share the same GUID for loader identification
Moved the GetCryptoServices() function definition to a new private header file OneCryptoLib.h to improve code organization. Updated all consumers in DxeCryptLib, OneCryptoLib, SmmCryptLib, and StandaloneMmCryptLib to include the new header.
Removes the Dxe and Mm specific OneCrypto protocol GUIDs and replaces them with a single OneCrypto protocol GUID. This simplifies the protocol usage and reduces redundancy.
Fix compiler warning C4319 where bitwise NOT was being applied to a UINT32 before zero-extending to PHYSICAL_ADDRESS. Move the UINTN cast to wrap the entire expression before the bitwise NOT operation to ensure proper width handling across 32-bit and 64-bit platforms. This resolves the "zero extending 'UINT32' to 'PHYSICAL_ADDRESS' of greater size" warning when compiling for IA32 with VS2022.
b9fdcac to
4fe2038
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert this to an extern and drop the function
| PI_SPECIFICATION_VERSION = 0x00010032 | ||
| MODULE_TYPE = MM_STANDALONE | ||
| LIBRARY_CLASS = BaseCryptLib | MM_STANDALONE | ||
| LIBRARY_CLASS = TlsLib | MM_STANDALONE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| LIBRARY_CLASS = TlsLib | MM_STANDALONE | |
| LIBRARY_CLASS = TlsLib | MM_STANDALONE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add document to top level level of CryptoPkg describing what the options are for backing and write out that if a function is added to BaseCryptLib.h that all providers (specifically OneCrypto) needs to be updated to create the WYSIWYG contract


Description
This pull request adds support for forwarding cryptographic library calls to the new OneCrypto protocol across DXE, SMM, and Standalone MM phases, enabling modular and version-aware cryptographic provider integration. It introduces new protocol GUIDs, implements library constructors for protocol lookup, and updates build configuration to support these changes. Additionally, it provides documentation and abstracts for the new libraries, and adds a disabled external binary dependency descriptor.
OneCrypto Protocol Integration:
CryptoPkg.decto support phase-specific cryptographic operations.DxeCryptLib.c,SmmCryptLib.c,StandaloneMmCryptLib.c) that locate and expose the OneCrypto protocol for cryptographic services, with corresponding INF build files for each phase. [1] [2] [3] [4] [5] [6]Documentation and Descriptions:
--- config: layout: elk --- classDiagram namespace Protocol { class OneCrypto:::highlight { <<Protocol Interface>> UINT16 Major; UINT16 Minor; // v1.0 ------------------------------------------ ONE_CRYPTO_PROVIDED_FUNC ONE_CRYPTO_PROVIDED_FUNC; // ... } } namespace Library { class BaseCryptLib:::highlight { } class TlsLib:::library { } class HashApiLib:::library { } } namespace LibraryInstance { class BaseCryptOnOneCrypto:::highlight { <<Library Interface>> EFI_STATUS CryptoFunc(..) } } namespace Driver { class OneCryptoBinSupvMm:::driver { <<Driver>> Phase Agnostic Crypto Driver Shared across Phases Crypto Entry(..) // phase agnostic code SupvMm Entry(..) // stub entry } class OneCryptoLoaderSupvMm:::driver { <<Driver>> } class OneCryptoLoaderDxe:::driver { <<Driver>> } } namespace GenericModules { class GenericDriver:::module { <<Driver>> Any driver that needs crypto } class GenericLibrary:::module { <<Library Interface>> Any library that needs crypto } } OneCryptoLoaderSupvMm --> OneCryptoBinSupvMm : Loads Phase Agnostic Code OneCryptoLoaderDxe --> OneCryptoBinSupvMm : Loads Phase Agnostic Code OneCryptoBinSupvMm ..> OneCryptoLoaderSupvMm : Provides Crypto OneCryptoBinSupvMm ..> OneCryptoLoaderDxe : Provides Crypto OneCryptoLoaderSupvMm ..|> OneCrypto : Publishes OneCryptoLoaderDxe ..|> OneCrypto : Publishes BaseCryptOnOneCrypto ..|> OneCrypto : Locates BaseCryptOnOneCrypto <.. BaseCryptLib : Backed By BaseCryptOnOneCrypto <.. TlsLib : Backed By TlsLib ..> BaseCryptLib : Uses HashApiLib ..> BaseCryptLib : Uses GenericLibrary ..> BaseCryptLib : Uses GenericDriver ..> BaseCryptLib : Uses GenericLibrary ..> TlsLib : Uses GenericDriver ..> HashApiLib : Uses classDef driver fill:#187286,stroke:#333,stroke-width:2px classDef protocol fill:#d63230,stroke:#333,stroke-width:2px classDef library fill:#1c77c3,stroke:#333,stroke-width:2px classDef module fill:#ff8c00,stroke:#333,stroke-width:2px classDef highlight fill:#69995d,stroke:#333,stroke-width:2pxSpecifically this PR is addressing the following (sage green in the chart):
Build and Configuration Updates:
OneCrypto_ext_dep.json.disabled.BaseCryptLib API Enhancements:
BaseCryptLib.h, improving diagnostics and compatibility checks.Code Organization and Comments:
CryptoPkg.decregarding deprecated usage and auto-generated sections for cryptographic provider configuration.BaseCryptOnOneCrypto
OneCryptoProtocol
How This Was Tested
QemuQ35
Integration Instructions
N/A