crypto: Refactor hash algorithm usage across crate#3538
Merged
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors hash algorithm handling in the support/crypto crate by centralizing hash algorithm definitions/conversions and updating RSA/X.509/PKCS7 code (and downstream OpenHCL callers) to use the new shared type.
Changes:
- Introduce
crypto::HashAlgorithm(newhashesmodule) with backend-specific hashing/conversion helpers and SHA-1 deprecation. - Update RSA backends (OpenSSL/RustCrypto/SymCrypt) plus X.509/PKCS7 code to use
HashAlgorithmconversions and shared hashing helpers. - Update
underhill_attestationto usecrypto::HashAlgorithminstead ofcrypto::rsa::HashAlgorithm, adding targeted#[expect(deprecated)]where SHA-1 is still required.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| support/crypto/src/lib.rs | Adds hashes module and re-exports HashAlgorithm from the crate root. |
| support/crypto/src/hashes.rs | New centralized HashAlgorithm type, SHA-1 deprecation, hashing helpers, and backend conversions. |
| support/crypto/src/rsa/mod.rs | Removes RSA-local HashAlgorithm and switches public RSA APIs to use the crate-level type. |
| support/crypto/src/rsa/ossl.rs | Replaces local digest mapping helpers with HashAlgorithm Into conversions. |
| support/crypto/src/rsa/rust.rs | Uses centralized HashAlgorithm and shared hashing helper for PKCS#1 sign/verify. |
| support/crypto/src/rsa/symcrypt.rs | Uses centralized HashAlgorithm hashing/conversion instead of local helpers. |
| support/crypto/src/x509/symcrypt_rust.rs | Centralizes OID→hash mapping via HashAlgorithm::try_from. |
| support/crypto/src/pkcs7/symcrypt_rust.rs | Updates signing to use crate::HashAlgorithm::Sha256. |
| openhcl/underhill_attestation/src/test_helpers.rs | Updates JWT signing helper to use crypto::HashAlgorithm::Sha256. |
| openhcl/underhill_attestation/src/secure_key_release.rs | Switches to crypto::HashAlgorithm, adds #[expect(deprecated)] for required SHA-1 usage. |
| openhcl/underhill_attestation/src/key_protector.rs | Updates RSA-OAEP calls to use crypto::HashAlgorithm. |
| openhcl/underhill_attestation/src/jwt.rs | Updates JWT signature verification/signing to use crypto::HashAlgorithm::Sha256. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor the usage of hash algorithms to consolidates hash algorithm definitions and updates their usage throughout the crate. Annoyingly the RustCrypto crates wants hash algorithms at a type level, so I can't quite clean them up as much without resorting to const generics.