Miscellaneous test coverage and API clarity improvements - #5
Miscellaneous test coverage and API clarity improvements#5danieldia-dev wants to merge 5 commits into
Conversation
Lock in three type-system invariants: Context is not Clone, ExportOnly cannot be used with seal_base, and PQ KEMs cannot be used with seal_auth.
The PSK is randomly generated, so it's reasonable to assume that it's uniformly random. If it's uniformly random, then its length becomes the only measure of entropy.
This is is not a good test. Ideally, you'd test the correctness of the individual components, not do a thing that just runs the same operation 10,000 times.
OK, this is good, could you open a separate PR with this just this change? |
This PR makes three small independent improvements:
InsecurePskis renamed toPskTooShort(with the old variant deprecated) because the original name implied the crate validates entropy, which in fact it does not (since the check is purely a length proxy).A sequential
seal/openstress test is added tocontext.rsthat runs 10,000 consecutiveseal/openpairs and asserts every ciphertext is unique, directly verifying that nonce derivation does not produce a repeated value across sequential operations.Three
trybuildcompile-fail tests are added to lock in type-system invariants that were previously untested:Contextis notClone,ExportOnlycannot be used withseal_base, and PQ KEMs cannot be used withseal_auth. A regression in any of these previously would have silently widened the API.All compile-fail tests pass under
cargo test --features pq compile_fail.Note: A follow-up fix merges the
PskTooShortandInsecurePskdisplay arms into a single match arm to satisfyclippy::match_same_arms, which is enforced by the crate'sclippy::pedanticdeny list.