Repository navigation
Hash clone v2 - #176
Draft
ounsworth wants to merge 6 commits into
Draft
Hash clone v2#176ounsworth wants to merge 6 commits into
ounsworth wants to merge 6 commits into
Conversation
(cherry picked from commit 1f4a84e) Replayed onto the HMAC/HKDF utility-crate split, which had restructured both crate doc headers. Adapted while resolving the conflict: * link [`SHA256Internal`] / [`SHA512Internal`] and [`SHA3Internal`] rather than [`SHA2`] / [`SHA3`]; the latter two are not type names in either crate and would have been dead intra-doc links. * keep the "## HMAC" pointer that the split added to the sha3 header. * move sha2's "Memory Usage" and "Security Considerations" below "Suspending and resuming execution", so that both crates' doc headers present the same section order. sha3 was already in that order. Assisted-by: Claude Code:claude-opus-5 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…aliases
The HMAC test suite exercised HMAC over SHA-2 and SHA-3, which forced
bouncycastle-hmac to carry bouncycastle-sha2, -sha3, -rng and -hex as
dev-dependencies purely in order to test itself. That was a deliberate cycle
through dev-dependencies, flagged with a todo, left over from the
utility-crate split.
Split the suite by the hash it exercises and move each half to the crate that
publishes the aliases under test:
* crypto/sha2/tests/hmac_tests.rs -- HMAC-SHA224/256/384/512: the full
RFC 4231 suite, suspend/resume, keygen, and weak-RNG rejection.
* crypto/sha3/tests/hmac_tests.rs -- HMAC-SHA3-224/256/384/512: the
143-byte long-key regression (SHA3-224 has the largest block at 144
bytes), truncated-tag rejection, suspend/resume, and keygen.
No test bodies or expected values were changed; the suite was partitioned,
not rewritten. bouncycastle-hmac's [dev-dependencies] are gone entirely and
with them the dependency cycle. The hex dev-dependency follows the tests to
bouncycastle-sha2, which did not previously have one.
This leaves bouncycastle-hmac with no tests of its own. That is inherent to
it being a utility crate rather than a gap in coverage: HMAC<H> cannot be
instantiated without a hash, and this crate must not depend on the hash
crates. Every behaviour it had is still exercised, from the two suites above.
On rebasing onto feature/simple-ciphers, its HMAC-SHA512/224 and -SHA512/256 tests
follow SHA-2 here, and its HMAC-SM3 tests move to a new crypto/sm3/tests/hmac_tests.rs.
Assisted-by: Claude Code:claude-opus-5
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ating it Assisted-by: Claude Code:claude-opus-5
This was referenced Oct 24, 2026
Closed
This branch has not been deployed
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 PR replaces #121.
That branch got all tangled up with the #133 changes, so it was easier to cherry-pick the specific commits onto a clean branch.
Original issue:
Adds docs for cloning a hash function mid-stream so that you now have two hash objects that are identical up to this point, but you can feed different suffix input into before finalizing.
I put this next to the existing sections for
[Suspendable], since it's closely-related functionality. (and re-arranged order to put these before Memory Usage and Security Consideration sections).Extension
During development of that, I realized that the pub interface flip of HMAC and HKDF introduced in #122 meant that the way HMACParams was defined was now really clunky. A refactor of that lead to realizing that actually, SP 800-107r1 specifies the security strength of an HMAC higher than the collision strength of the underlying hash function, so I re-worked that as well.