Repository navigation
Conversation
New `kdf` module with the `CASHKDF` trait and `CASHkdfSha256` / `CASHkdfSha512`: `extract(salt, ikm)` returns the PRK, `expand(prk, info, length)` derives a key from it, and `derive` does both. Separate extract and expand let one PRK yield several keys with distinct `info`, as the cas-p2p-chat key schedule needs. An empty salt means RFC 5869's "not provided". A PRK shorter than HashLen is `InvalidKey`; a length of 0 or above 255 * HashLen is `InvalidParameters`. No new `CasError` variant. The `ikm` / `prk` arguments and the output buffer are zeroized. Tested with RFC 5869 Appendix A cases 1-3 (committed, cross-checked with Python's hmac) and Wycheproof hkdf_sha256 / hkdf_sha512 (169 cases, none skipped). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…HKDF tests CodeQL (rust/hard-coded-cryptographic-value) flagged the literal salts in tests/kdf.rs. Draw every salt, IKM and PRK from OsRng instead, and drop the empty-salt-equals-zero-salt test, whose point is a literal zero salt; the Wycheproof EmptySalt cases cover it. The known answers now come only from the downloaded Wycheproof hkdf_sha256 / hkdf_sha512 files, like the other algorithms, so tests/data/hkdf/rfc5869_sha256.txt is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
New
kdfmodule with theCASHKDFtrait andCASHkdfSha256/CASHkdfSha512:extract(salt, ikm)returns the PRK,expand(prk, info, length)derives a key from it, andderivedoes both. Separate extract and expand let one PRK yield several keys with distinctinfo, as the cas-p2p-chat key schedule needs.An empty salt means RFC 5869's "not provided". A PRK shorter than HashLen is
InvalidKey; a length of 0 or above 255 * HashLen isInvalidParameters. No newCasErrorvariant. Theikm/prkarguments and the output buffer are zeroized.Tests:
hkdf_sha256/hkdf_sha512files, downloaded at test time like the other algorithms (169 cases, none skipped, including theEmptySaltcases).deriveandextract+expandare both checked against every case.tests/kdf.rscovers one PRK expanded into several keys, the output-length limits and short PRKs. Its inputs come fromOsRng, so CodeQL's hard-coded-cryptographic-value alerts no longer apply.🤖 Generated with Claude Code