Skip to content

firmware_uefi: Refactor crypto to go through new crypto crate#3175

Merged
smalis-msft merged 11 commits intomicrosoft:mainfrom
smalis-msft:uefi-crypto
Apr 7, 2026
Merged

firmware_uefi: Refactor crypto to go through new crypto crate#3175
smalis-msft merged 11 commits intomicrosoft:mainfrom
smalis-msft:uefi-crypto

Conversation

@smalis-msft
Copy link
Copy Markdown
Contributor

@smalis-msft smalis-msft commented Apr 1, 2026

Fairly straightforward conversion, although there is an open design question about the flags needing to be passed to openssl.

@smalis-msft smalis-msft requested a review from a team as a code owner April 1, 2026 19:25
Copilot AI review requested due to automatic review settings April 1, 2026 19:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors firmware_uefi authenticated-variable (PKCS#7) verification to go through the repository’s new support/crypto crate, consolidating OpenSSL usage behind a backend-agnostic API surface (with an OpenSSL implementation on Unix).

Changes:

  • Switched UEFI auth-var verification from direct openssl calls to crypto::pkcs7 wrappers.
  • Introduced a new crypto::pkcs7 module (OpenSSL-backed) with Pkcs7SignedData and Pkcs7CertStore.
  • Updated firmware_uefi feature/dependencies and workspace lockfile accordingly.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vm/devices/firmware/firmware_uefi/src/service/nvram/spec_services/auth_var_crypto.rs Replaces OpenSSL PKCS#7/X509 verification logic with crypto::pkcs7 usage.
vm/devices/firmware/firmware_uefi/Cargo.toml Switches auth-var-verify-crypto feature dependency from openssl to crypto.
support/crypto/src/pkcs7/ossl.rs Adds OpenSSL-backed implementation of PKCS#7 parsing, cert store, and verification.
support/crypto/src/pkcs7/mod.rs Exposes the PKCS#7 API types and error wrapper.
support/crypto/src/lib.rs Exports pkcs7 on Unix only.
Cargo.lock Adds crypto dependency to firmware_uefi and removes direct openssl dependency.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Copilot AI review requested due to automatic review settings April 1, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

@benhillis benhillis added the enhancement New feature or request label Apr 6, 2026
Copy link
Copy Markdown
Member

@chris-oo chris-oo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not have uefi pass the flags or is it because we don't know how to rationalize those flags across crypto backends?

uefi_mode: bool,
) -> Result<bool, Pkcs7Error> {
if uefi_mode {
// TODO: set these flags through a better api once its clear how different backends handle similar adjustments
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should uefi specify this? or not sure until you refactor/have more call sites? this seems odd to have this bool here / leaky abstraction

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to rationalize these flags across different backends. Agreed it feels odd, but the crypto crate is not intended to be a general purpose abstraction, it is explictly specialized for openvmm use cases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm OK leaving it as-is in this PR, given your TODO comment, as long as we revisit this when you add more callsites or backends. Maybe instead of uefi_mode, we have a strict_mode that does the opposite?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also possible, I need to see what other backends look like. And yeah currently our only callsite is uefi, so...

Copilot AI review requested due to automatic review settings April 6, 2026 17:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

uefi_mode: bool,
) -> Result<bool, Pkcs7Error> {
if uefi_mode {
// TODO: set these flags through a better api once its clear how different backends handle similar adjustments
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm OK leaving it as-is in this PR, given your TODO comment, as long as we revisit this when you add more callsites or backends. Maybe instead of uefi_mode, we have a strict_mode that does the opposite?

/// signature check fails.
pub fn verify(
&self,
store: Pkcs7CertStore,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to take store by reference, but I understand why you take ownership here -- in practice, if the caller never reuses the store after calling verify it's probably OK.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To both of your comments, this API is definitely subject to change in the future. Depending on how other backends do it I imagine it will evolve.

@smalis-msft smalis-msft enabled auto-merge (squash) April 7, 2026 14:30
@smalis-msft smalis-msft merged commit b7a4909 into microsoft:main Apr 7, 2026
65 checks passed
@smalis-msft smalis-msft deleted the uefi-crypto branch April 7, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants