- New algorithms added to crypto/ :
- SM3 -- the SM3 hash (GB/T 32905-2016 / ISO/IEC 10118-3:2018), ported from bc-java, with HMAC-SM3.
- AES -- AES-128/192/256 in ECB, CBC (PKCS#7 or whole blocks), CFB, CFB8, CTR, CCM and GCM, plus CMAC and GMAC;
the modes and padding are a new
ciphercrate, generic over the block cipher. - ASCON -- Ascon-AEAD128, Ascon-Hash256, Ascon-XOF128 and Ascon-CXOF128 (NIST SP 800-232).
- SP 800-185 -- cSHAKE, KMAC, TupleHash and ParallelHash, in the sha3 crate.
- HMAC and HKDF are generic over the hash, with aliases in each hash crate: HMAC over SHA-3, HMAC-SM3, HMAC-SHA512/224, HMAC-SHA512/256 and HKDF-SHA384 are new (#122).
- Key objects (PRs #170, #172): anything keyed is a key built once from
KeyMaterial--AES128Key<GCM>,AES128Key<CBC<PKCS7>>,HmacKey<H>,KMAC128Key,AsconAEAD128Key-- which validates and expands the key once, hands out workers that borrow it (create_encryptor(rng),create_decryptor(init_data),create_generator()), and provides the one-shots (encrypt,mac,verify). The worker traits keep only the streaming methods:do_*_initand the key-taking one-shots are gone, and resume takes the key object. - Signature keys likewise:
SigningKey(create_signer(rng, ctx),sign),DeterministicSigningKey,VerifyingKey(create_verifier,verify) and the pre-hash forms with the hash as a type parameter (create_ph_signer::<SHA512>);Signeris nowSignatureSigner, anddo_sign_init/do_verify_initare gone. ML-DSA and HashML-DSA are on these traits. - Further memory usage improvements on ML-DSA / ML-KEM, with a slight throughput gain (the work was mostly removing
unnecessary memcpy's). New figures for the largest size:
- ML-DSA-87/Sign 118 kb, ML-DSA-87/Verify 212 kb
- ML-DSA-87_lowmemory/Sign 25 kb, ML-DSA-87_lowmemory/Verify 21 kb
- ML-KEM-1024/Encaps 44 kb, ML-KEM-1024/Decaps 58 kb
- ML-KEM-1024_lowmemory/Encaps 11 kb, ML-KEM-1024_lowmemory/Decaps 21 kb
Trait system:
- Anything that draws randomness takes the caller's
&mut dyn RNG(keygen,create_signer,create_encryptor,encaps_rng); thekeygen()that built its own DRBG is gone.FixedSeedRNGmoved tobouncycastle-rng. AlgorithmInfo(alg_name(),max_security_strength()) is the run-time form ofAlgorithm;Hash,KDF,MACand the signature workers take it as a supertrait, and the factories report the algorithm selected.HashOneShotholds the one-shothash(data)/hash_out(data, out), called asSHA256::hash(msg).Hashno longer requiresClone, and the hash, XOF, cipher and MAC worker traits are usable asdyn.- XOF: absorb-after-squeeze is forbidden; the API is the one-shot
XOF::xof(), orinto_squeezer()thenXOFSqueezer::do_output()/do_output_final(). - Error enums are
#[non_exhaustive](#81);Conditioncovers the unsigned types (PR #63); the constant-time barrier in bouncycastle-utils isread_volatile/write_volatilerather than the best-effortblack_box. hazmatmodules hold what is only safe when composed correctly (bouncycastle_core::hazmatdefines the term):do_hazardous_operations, ML-KEMencaps_with_randomnessandHashDRBG80090A::new_uninitialized(both now extension traits), the raw block permutation, ECB and the CTR keystream.
ML-DSA / ML-KEM:
- Fixed an
i32overflow in ML-DSA-87 verification from a missing reduction, found with Wycheproof (PR #137). - Parameter sets are sealed traits (
MLDSAParams,HashMLDSAParams,MLKEMParams) instead of const-generic turbofish; key types carry onlyP(MLDSAPublicKey<P>), with the encoded lengths inferred (#117). - The ML-DSA external-mu interface is on the keys (
compute_mu,sign_mu,verify_mu,create_mu_builder); the FIPS 204 deterministic variant isDeterministicSigningKeyand the hedged one drawsrndfrom the caller's RNG;sign_with_expanded_key,set_signer_rndandsign_init_from_seedare gone. Expanded keys borrow the key they expand. - HashML-DSA drops
HashMLDSA65_with_SHA256andHashMLDSA87_with_SHA256(SHA-256 is below those sets' strength), leaving ML-DSA-44 with SHA-256 or SHA-512 and ML-DSA-65/87 with SHA-512; the SHA-512 pairings carry OIDs. - ML-KEM gains expanded public and private keys;
mldsa-commonandmlkem-commonhold the arithmetic shared with the low-memory crates.
SHA-2 / SHA-3:
- SHA-2: SHA512/224, SHA512/256, and
do_final_partial_bits()/do_final_partial_bits_out()(FIPS 180-4 s. 5.1). - SHA-3:
squeeze_partial_byte_final()on a first squeeze skipped the SHAKE domain suffix and returned the wrong bits, fixed; the final partial byte's bit order now matches DER BIT STRING (#91). Keccak absorbs whole blocks straight from the caller's slice.
Command line:
- A
bc-rustsubcommand for every new primitive: the AES modes and MACs, Ascon, SM3, SP 800-185, HMAC over every hash.
Docs, build and CI:
-
QUALITY_AND_STYLE.md covers key objects,
hazmat,dyn-compatibility and the_out/_inplace/_noncesuffixes; CONTRIBUTING.md and the new ISSUES_STYLE_GUIDE.md (PR #72, thanks to @jjkurczak) state the submission bar and the AI policy. -
Github Actions build, test, doc and format-check every pull request (#45, thanks to @officialfrancismendoza; #59).
-
Crate versions inherit from the workspace (thanks to Tamish Dahiya); factory docs link the core traits (thanks to Polly Labs); build instructions clarified (thanks to Michael Richardson).
-
A
mutantscargo profile makescargo mutantson ML-DSA / ML-KEM take seconds per mutant rather than minutes. -
Github issues and PRs resolved: #45, #59, #62, #63, #72, #81, #91, #117, #122, #133, #137, #170, #172.