Skip to content

Commit e73bbba

Browse files
jperonclaude
andcommitted
fix: 32-bit rshift broke QUIC pn recovery for 4-byte packet numbers
recover_packet_number halved pn_win with bit.rshift, which is 32-bit on LuaJIT: for pn_len = 4, pn_win = 2^32 truncates to 0, so pn_hwin = 0 and any retransmitted packet decoded to pn + 2^32 — wrong nonce, AEAD tag mismatch. Halve with plain arithmetic (exact on doubles). Also fix the stale uncompressed-IPv6 expectation in the openssl-backend google-capture test (same issue as the kernel variant). Both paths only run where libcrypto is available — first exercised by the CI runner. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent db561b6 commit e73bbba

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

ipparse/l4/quic/v1/protection.moon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ recover_packet_number = (truncated, expected, pn_len) ->
9797
pn_win = 1
9898
for _ = 1, pn_len * 8
9999
pn_win *= 2
100-
pn_hwin = rshift pn_win, 1
100+
-- pn_win can be 2^32 (pn_len = 4): bitops are 32-bit on LuaJIT, so halve
101+
-- with plain arithmetic (exact on doubles).
102+
pn_hwin = pn_win / 2
101103
candidate = (expected - (expected % pn_win)) + truncated
102104
if candidate <= expected - pn_hwin
103105
candidate + pn_win

ipparse/tests/l7/quic/test_google_capture_backends.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ EXPECTED = {
2525
dst_mac: "f2198cc26bb3"
2626
src_mac: "f2e9008a2acc"
2727
src_ip: "3ffa:e7fe:4375:16ed:e28f:4cff:fec8:91fa"
28-
dst_ip: "2485:ec87:7655:20de:0:0:0:8b"
28+
dst_ip: "2485:ec87:7655:20de::8b" -- ip62s compresses zero runs (RFC 5952)
2929
udp_spt: 35336
3030
udp_dpt: 443
3131
sni: "google.com"

0 commit comments

Comments
 (0)