feat: add Signature and KEM factory enums - #84
Conversation
- src\signature.rs - src\kem.rs - src\lib.rs Fixes bcgit#68 Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
|
Thank you for your contribution, but this is extremely incomplete. The Signature and KEM factories need to be enums that encapsulate all the supported objects, and those enums need to impl the relevant traits, passing them through to the underlying types. Please take a look at the other factory modules as examples. I am going to close this PR, but I would welcome another PR from you that is more complete. :) |
|
Thanks for the clear feedback on the earlier incomplete draft — completely fair to close it. I've force-pushed a full rewrite on this branch (happy to open a fresh PR if you prefer): What changed vs the stubs
Why not
|
|
Follow-up: reopen was blocked after the force-push (GitHub 422), so the complete implementation is in #85 on the same branch |
Summary
Implements Signature and KEM factories in
bouncycastle-factory, addressing maintainer feedback on #84 / #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.keygen,sign,verify,sign_init/sign_update/sign_final,encaps,decaps, …) that match and pass through to the underlying types.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