MCPcopy Create free account
hub / github.com/secdev/scapy / AH

Class AH

scapy/layers/ipsec.py:71–108  ·  view source on GitHub ↗

Authentication Header See https://tools.ietf.org/rfc/rfc4302.txt

Source from the content-addressed store, hash-verified

69
70###############################################################################
71class AH(Packet):
72 """
73 Authentication Header
74
75 See https://tools.ietf.org/rfc/rfc4302.txt
76 """
77
78 name = 'AH'
79
80 def __get_icv_len(self):
81 """
82 Compute the size of the ICV based on the payloadlen field.
83 Padding size is included as it can only be known from the authentication # noqa: E501
84 algorithm provided by the Security Association.
85 """
86 # payloadlen = length of AH in 32-bit words (4-byte units), minus "2"
87 # payloadlen = 3 32-bit word fixed fields + ICV + padding - 2
88 # ICV = (payloadlen + 2 - 3 - padding) in 32-bit words
89 return (self.payloadlen - 1) * 4
90
91 fields_desc = [
92 ByteEnumField('nh', None, IP_PROTOS),
93 ByteField('payloadlen', None),
94 ShortField('reserved', None),
95 XIntField('spi', 0x00000001),
96 IntField('seq', 0),
97 XStrLenField('icv', None, length_from=__get_icv_len),
98 # Padding len can only be known with the SecurityAssociation.auth_algo
99 XStrLenField('padding', None, length_from=lambda x: 0),
100 ]
101
102 overload_fields = {
103 IP: {'proto': socket.IPPROTO_AH},
104 IPv6: {'nh': socket.IPPROTO_AH},
105 IPv6ExtHdrHopByHop: {'nh': socket.IPPROTO_AH},
106 IPv6ExtHdrDestOpt: {'nh': socket.IPPROTO_AH},
107 IPv6ExtHdrRouting: {'nh': socket.IPPROTO_AH},
108 }
109
110
111bind_layers(IP, AH, proto=socket.IPPROTO_AH)

Callers 1

_encrypt_ahMethod · 0.85

Calls 6

ByteEnumFieldClass · 0.90
ByteFieldClass · 0.90
ShortFieldClass · 0.90
XIntFieldClass · 0.90
IntFieldClass · 0.90
XStrLenFieldClass · 0.90

Tested by

no test coverage detected