Skip to content

Commit

Permalink
Merge pull request #2732 from guedou/Issue_#2731
Browse files Browse the repository at this point in the history
Support SHA* based authenticators
  • Loading branch information
p-l- committed Jul 25, 2020
2 parents 45c023e + 625ec8b commit 9184e3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scapy/layers/ntp.py
Expand Up @@ -452,10 +452,10 @@ def guess_payload_class(self, payload):
"""
plen = len(payload)

if plen > _NTP_AUTH_MD5_TAIL_SIZE:
return NTPExtensions
elif plen == _NTP_AUTH_MD5_TAIL_SIZE:
if plen - 4 in [16, 20, 32, 64]: # length of MD5, SHA1, SHA256, SHA512
return NTPAuthenticator
elif plen > _NTP_AUTH_MD5_TAIL_SIZE:
return NTPExtensions

return Packet.guess_payload_class(self, payload)

Expand Down
6 changes: 6 additions & 0 deletions test/regression.uts
Expand Up @@ -9579,6 +9579,12 @@ assert(p.version == 4)
assert(p.mode == 3)
assert(p.stratum == 2)

= NTPAuthenticator

s = hex_bytes("000c2962f268d094666d23750800450000640db640004011a519c0a80364c0a80305a51e007b0050731a2300072000000000000000000000000000000000000000000000000000000000000000000000000052c7bc1dda64b97d0000000bcdc3825dbf6b7ad02886ff45aa8b2eaf7ac78bc1")
p = Ether(s)
assert NTPAuthenticator in p and p[NTPAuthenticator].key_id == 3452142173


############
############
Expand Down

0 comments on commit 9184e3d

Please sign in to comment.