AH - Authentication Header#

pcapkit.protocols.internet.ah contains AH only, which implements extractor for Authentication Header (AH) [*], whose structure is described as below:

Octets

Bits

Name

Description

0

0

ah.next

Next Header

1

8

ah.length

Payload Length

2

16

Reserved (must be zero)

4

32

sah.spi

Security Parameters Index (SPI)

8

64

sah.seq

Sequence Number Field

12

96

sah.icv

Integrity Check Value (ICV)

class pcapkit.protocols.internet.ah.AH(file=None, length=None, **kwargs)[source]#

Bases: IPsec[AH, AH]

This class implements Authentication Header.

property name: Literal['Authentication Header']#

Name of corresponding protocol.

property length: int#

Header length of current protocol.

property payload: ProtocolBase | NoReturn#

Payload of current instance.

Raises:

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protocol: str | None | NoReturn#

Name of next layer protocol (if any).

Raises:

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn#

Protocol chain of current instance.

Raises:

UnsupportedCall – if the protocol is used as an IPv6 extension header

classmethod id()[source]#

Index ID of the protocol.

Return type:

tuple[Literal['AH']]

Returns:

Index ID of the protocol.

read(length=None, *, version=4, extension=False, **kwargs)[source]#

Read Authentication Header.

Structure of AH header [RFC 4302]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header   |  Payload Len  |          RESERVED             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Security Parameters Index (SPI)               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Sequence Number Field                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                Integrity Check Value-ICV (variable)           |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • length (Optional[int]) – Length of packet data.

  • version (Literal[4, 6]) – IP protocol version.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

AH

Returns:

Parsed packet data.

make(next=TransType.UDP, next_default=None, next_namespace=None, next_reversed=False, spi=0, seq=0, icv=b'', payload=b'', **kwargs)[source]#

Make (construct) packet data.

Parameters:
Return type:

AH

Returns:

Constructed packet data.

classmethod _make_data(data)[source]#

Create key-value pairs from data for protocol construction.

Parameters:

data (AH) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

__post_init__(file=None, length=None, *, version=4, extension=False, **kwargs)[source]#

Post initialisation hook.

Parameters:
  • file (Union[IO[bytes], bytes, None]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • version (Literal[4, 6]) – IP protocol version.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

None

See also

For construction argument, please refer to self.make.

classmethod __index__()[source]#

Numeral registry index of the protocol.

Return type:

TransType

Returns:

Numeral registry index of the protocol in IANA.

Header Schemas#

class pcapkit.protocols.schema.internet.ah.AH(dict_=None, **kwargs)[source]#

Bases: Schema

Header schema for AH packet.

next: Enum_TransType = <EnumField next>#

Next header.

len: int = <UInt8Field len>#

Payload length.

reserved: bytes = <PaddingField reserved>#

Reserved.

spi: int = <UInt32Field spi>#

Security parameters index.

seq: int = <UInt32Field seq>#

Sequence number field.

icv: bytes = <BytesField icv>#

Integrity check value.

payload: bytes = <PayloadField payload>#

Payload.

Data Models#

class pcapkit.protocols.data.internet.ah.AH(*args: VT, **kwargs: VT)[source]#

Bases: Protocol

Data model for AH protocol.

next: TransType#

Next header.

length: int#

Payload length.

spi: int#

Security parameters index.

seq: int#

Sequence number field.

icv: bytes#

Integrity check value.

Footnotes