Refactor crypto backend architecture to support multiple backends - #118
Open
dwhjames wants to merge 3 commits into
Open
Refactor crypto backend architecture to support multiple backends#118dwhjames wants to merge 3 commits into
dwhjames wants to merge 3 commits into
Conversation
This commit introduces pluggable cryptographic backends, allowing users to select between openssl, ring, and aws-lc-rs at compile time. This unifies the public API across backends while maintaining backend-specific optimizations and compatibility constraints. Key changes: * Extract backend-agnostic crypto traits and abstractions (EcPrivateKey, EcPublicKey) with consistent APIs across all backends * Implement ring and aws-lc-rs backends with feature-gated compilation; exactly one backend must be selected (mutual exclusivity enforced) * Introduce CoseError::KeyDecodingError for precise key parsing/decoding error reporting instead of catch-all SignatureError * Allow key_tpm and key_kms to work with any backend (e.g., ring + key_tpm, aws-lc-rs + key_kms), except ring + key_kms which is compile-time rejected * Refactor repetitive error-handling patterns and OID/encoding helpers to reduce duplication across backends This enables the 0.6.0 release with breaking API changes.
…hash Restore the design where sign.rs owns hashing: new_with_protected and verify_signature now call ActiveBackend::hash() on the Sig_Structure bytes and pass the resulting digest to sign()/verify(), rather than each backend hashing the raw message internally. Key changes: * Add hashes_internally() to SigningPublicKey (default false); ring/aws-lc-rs backends override to true since their ECDSA algorithms always hash internally and provide no raw-signing API * sign.rs conditionally hashes based on hashes_internally(), passing raw bytes to ring-like keys and pre-computed digests to all others * openssl: remove internal openssl::hash::hash() from sign() and verify() * kms: remove internal ActiveBackend::hash(); forward digest directly to KMS as MessageType::Digest; guard verify_with_public_key fast-path to skip ring-like public keys that would double-hash the digest * tpm: remove internal ActiveBackend::hash(); pass digest slice directly to Digest::try_from()
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.
This commit introduces pluggable cryptographic backends, allowing users to select between openssl, ring, and aws-lc-rs at compile time. This unifies the public API across backends while maintaining backend-specific optimizations and compatibility constraints.
Key changes:
This enables the 0.6.0 release with breaking API changes.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.