Expand test coverage for auth KEM paths and context sequence number boundaries - #4
Merged
Merged
Conversation
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 is a collection of small targeted improvements to test coverage and code quality following the authenticated KEM refactor. The refactor introduced
extract_and_expand_piecesand updated all threeauthpaths, but left some gaps: the new function had no direct unit test, the auth KEM layer had no focused roundtrip test, and two context sequence number boundary cases were either missing or weakly asserted. The code quality changes address minor inconsistencies in naming and inlining that were noticed during the same review pass.The new tests are:
seal_succeeds_before_message_limit_then_fails(incontext.rs): verifies that sealing atseq == u64::MAX - 1succeeds and that the counter then increments tou64::MAX, at which point the next seal is correctly rejected withMessageLimitReached. The previous test jumped straight toMAXwithout verifying the last valid operation succeeds.extract_and_expand_pieces_matches_concat(indh.rs): directly verifies that feeding two DH slices intoextract_and_expand_piecesproduces the same output as feeding their concatenation into the originalextract_and_expand.x25519_auth_encap_decap_roundtrip(indh.rs): a focused unit test at the KEM layer that callsauth_encap_with_ikmandauth_decapdirectly with deterministic inputs, verifying the shared secret matches on both sides. Previouslyauthcoverage only existed through the full HPKE stack intests/roundtrip.rs, meaning a KEM-layer bug would surface as a (potentially confusing) stack-level failure.All existing tests still pass, and the new tests pass. In fact, the full test suite was run with
--features pq,differential,kat-internalsand all 50 unit + 8 differential + 13 KAT + 59 roundtrip tests pass. This is expected, since no functional changes to the codebase have been made.Finally, the
open_rejects_at_message_limitassertion was strengthened toassert_eq!(r, Err(HpkeError::MessageLimitReached))for consistency with itssealcounterpart, and#[inline]was added toextract_and_expandandextract_and_expand_pieces, withsk_s_authedrenamed tosk_senderinencap_withfor clarity.