feat: add Signature and KEM factory enums - #85
Open
VedantMadane wants to merge 1 commit into
Open
Conversation
Implement SignatureFactory and KEMFactory in bouncycastle-factory as enums that encapsulate all supported ML-DSA / ML-KEM parameter sets, following the existing Hash/MAC/RNG factory pattern. - SignatureFactory / KEMFactory implement AlgorithmFactory (defaults, 128/256-bit defaults, construction by algorithm name) - Key enums wrap public/private keys with encode/from_bytes pass-through - SignatureSigner / SignatureVerifierEngine wrap streaming engines - Inherent methods mirror Signer/SignatureVerifier/KEMEncapsulator/ KEMDecapsulator and dispatch to the underlying types Const-generic sizes on the core traits prevent a single enum from implementing those traits directly; the factory APIs pass through with type-erased keys and Vec encodings instead. Fixes bcgit#68 Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
Author
|
Follow-up: reopen was blocked after the force-push (GitHub 422), so the complete implementation is in #85 on the same branch |
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.
Summary
Implements Signature and KEM factories in
bouncycastle-factory, addressing maintainer feedback on closed PR #84 / issue #68.The previous PR only added empty stub structs at the workspace root. This replaces that with full enum factories that follow the existing
HashFactory/MACFactory/RNGFactorypattern.Design
Core
Signer/SignatureVerifier/KEMEncapsulator/KEMDecapsulatortraits are parameterized by const-generic key and ciphertext/signature sizes. A single enum wrapping ML-DSA-44/65/87 (or ML-KEM-512/768/1024) cannot implement those traits with one fixed size set.So this PR:
SignatureFactory/KEMFactoryenums — algorithm selectors implementingAlgorithmFactory(Default / Default128Bit / Default256Bit /new(name)).SignaturePublicKey,SignaturePrivateKey,KEMPublicKey,KEMPrivateKey) that encapsulate all supported key objects withencode/from_bytespass-through.SignatureSigner,SignatureVerifierEngine) that encapsulate the underlying ML-DSA state machines aftersign_init/verify_init.Defaults
default()default_128_bit()default_256_bit()Tests
crypto/factory/tests/signature_kem_factory_tests.rscovers defaults, name lookup, full sign/verify and encaps/decaps round-trips for every parameter set, streaming sign/verify, and algorithm/key mismatch errors.Fixes #68
Supersedes #84