tests: assert the DH ratchet step in lockstep on a bidirectional burst #97
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_d686a78c"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Adds
bidirectional_burst_keeps_the_dh_ratchet_in_locksteptotests/ratchet.rs.The existing
round_trip_across_two_dh_ratchet_stepsonly asserts that neithersending ratchet key stayed put. It would still pass if the two peers stepped onto
unconnected epochs, and it never checks that either peer adopted the key the
other advertised in the frame header. The new test takes the ratchet key out of
the wire header (
dh_pub[0..32]) and asserts the adoption per step.Lockstep semantics the test pins
The bootstrap tie-break means one A->B / B->A round cannot step both sides: only
the lower-key (establishing) peer rotates its sending chain, and the other peer
has still only ever seen bootstrap keys. The test asserts that intermediate state
instead of assuming it, then drives the rounds that complete the lockstep:
arotates,b.public()is unchanged,a.remote_pub()is b's key;a's fresh key reachesb, which takes a full step and adopts exactlythe advertised key;
a;skipped_len() == 0,recv_index() == 3, and that the peer which received lastis keyed to the other's current key. The one-header lag in the other
direction (
b.remote_pub()isa's last advertised key, not the fresh keya's step just generated) is documented in the test rather than asserted away.Verification
cargo test --locked --test ratchet-- 16 passed, 0 failed (new test included)ratchet_wire 5 -- all 0 failed
cargo clippy --locked --all-targets -- -D warnings-- exit 0, no warningsrustfmt --edition 2024 --check tests/ratchet.rs-- clean (exit 0)src/ratchet.rsreverted afterwards; onlytests/ratchet.rsis in this diff): the new test fails for each ofrotate_sending_chainreusing the old keypair -> "round 1 must rotate a'ssending ratchet key";
plan_stepreusing the old keypair instead of generating one -> "b mustDH-ratchet on a's new key";
decrypttreating every frame as the same chain -> fails at round 2.No
src/change, no new dependency, one file.