You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add tests for SHA1 and SHA256 NTP authenticators, update existing tests
- Add SHA1 (24-byte) authenticator parsing test with round-trip verification
- Add SHA256 (36-byte) authenticator parsing test with round-trip verification
- Update existing MD5 authenticator test to reflect correct SHA1 parsing for 24-byte payloads
- Update NTPControl test to expect SHA1 parsing for 24-byte authenticator data
Co-authored-by: guedou <11683796+guedou@users.noreply.github.com>
Copy file name to clipboardExpand all lines: test/scapy/layers/ntp.uts
+50-4Lines changed: 50 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -103,11 +103,54 @@ assert p.version == 4
103
103
assert p.mode == 3
104
104
assert p.stratum == 2
105
105
106
-
= NTPAuthenticator
106
+
= NTPAuthenticator - MD5 with padding (old test, updated for correct parsing)
107
107
108
+
# This packet has 24 bytes of authenticator data
109
+
# With the old (broken) code, it was parsed as: 4 padding + 4 key_id + 16 MD5 digest
110
+
# With the new (correct) code, it should be parsed as: 4 key_id + 20 SHA1 digest
108
111
s = hex_bytes("000c2962f268d094666d23750800450000640db640004011a519c0a80364c0a80305a51e007b0050731a2300072000000000000000000000000000000000000000000000000000000000000000000000000052c7bc1dda64b97d0000000bcdc3825dbf6b7ad02886ff45aa8b2eaf7ac78bc1")
109
112
p = Ether(s)
110
-
assert NTPAuthenticator in p and p[NTPAuthenticator].key_id == 3452142173
113
+
assert NTPAuthenticator in p
114
+
# With 24 bytes, this is now interpreted as SHA1 (4 + 20), not MD5 with padding
115
+
assert p[NTPAuthenticator].key_id == 11 # First 4 bytes: 0000000b
0 commit comments