Skip to content
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

MdePkg/DxeRngLib: Refactoring and improvements #6158

Merged
merged 5 commits into from
Sep 13, 2024

Conversation

pierregondois
Copy link
Contributor

Description

Improve the DxeRngLib so that:

  • the RNG prototocol is located only once instead of at each
    random number generation

  • algorithms that are not available on a platform are not called
    when trying to generate a random number

  • gEfiRngAlgorithmArmRndr support is added

  • PcdEnforceSecureRngAlgorithms can be set to allow/avoid non-secure
    algorithms

  • Breaking change?

    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?

    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?

    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

Tested on a Juno. Associated patches to be provided.

@pierregondois
Copy link
Contributor Author

Associated edk2-platforms PR: tianocore/edk2-platforms#185

MdePkg/MdePkg.dsc Outdated Show resolved Hide resolved
MdePkg/Library/DxeRngLib/DxeRngLib.c Outdated Show resolved Hide resolved
MdePkg/Library/DxeRngLib/DxeRngLib.inf Outdated Show resolved Hide resolved
MdePkg/Library/DxeRngLib/DxeRngLib.c Outdated Show resolved Hide resolved
@lgao4 lgao4 added the push Auto push patch series in PR if all checks pass label Sep 13, 2024
Copy link

mergify bot commented Sep 13, 2024

PR can not be merged due to conflict. Please rebase and resubmit

The PcdEnforceSecureRngAlgorithms Pcd enforces the use of RNG
algorithms defined by the UEFI spec. To re-use the Pcd in other
packages and have a generic mean to control the usage of unsecure
algorithms, move the Pcd to the MdePkg.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Pierre Gondois <[email protected]>
Add a library constructor which:
- locate the RNG prototocol and keep a reference to it in order to avoid
  locating it multiple times (for each random number generation)
- check which secure algorithm is available on the platform.
  This avoids to try each secure algorithm until finding one
  available for each random number generation call.

Signed-off-by: Pierre Gondois <[email protected]>
…ithm

Use PcdEnforceSecureRngAlgorithms to allow using the Rng protocol
with the default algorithm. All previous call to the Rng protocol
are requesting a secure Rng algorithm.
Not specifying the Rng algorithm GUID to use is considered unsecure.

Signed-off-by: Pierre Gondois <[email protected]>
DxeRngLib iterates over a list of secure algorithms before trying
to use the default algorithm provided by the Rng protocol. Add
gEfiRngAlgorithmArmRndr to this list. The algorithm represented by
this GUID is a secure DRBG of an unknown type, implemented by the
aarch64 RNDR instruction.
On AARCH64 platform, use the RNDR instruction as the first option
if it is available.

Signed-off-by: Pierre Gondois <[email protected]>
@mergify mergify bot merged commit 273f43c into tianocore:master Sep 13, 2024
126 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push Auto push patch series in PR if all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants