scapy.contrib.macsec module

Classes and functions for MACsec.

class scapy.contrib.macsec.MACsec

Bases: scapy.packet.Packet

representation of one MACsec frame

aliastypes = [<class 'scapy.contrib.macsec.MACsec'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACsec).Ver>, <Field (MACsec).ES>, <Field (MACsec).SC>, <Field (MACsec).SCB>, <Field (MACsec).E>, <Field (MACsec).C>, <Field (MACsec).an>, <Field (MACsec).reserved>, <Field (MACsec).shortlen>, <Field (MACsec).pn>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>]

DEV: can be overloaded to return a string that summarizes the layer. Only one mysummary() is used in a whole packet summary: the one of the upper layer, # noqa: E501 except if a mysummary() also returns (as a couple) a list of layers whose # noqa: E501 mysummary() must be called if they are present.

payload_guess = [({'type': 2048}, <class 'scapy.layers.inet.IP'>), ({'type': 34525}, <class 'scapy.layers.inet6.IPv6'>)]
class scapy.contrib.macsec.MACsecSA(sci, an, pn, key, icvlen, encrypt, send_sci, xpn_en=False, ssci=None, salt=None)

Bases: object

Representation of a MACsec Secure Association

Provides encapsulation, decapsulation, encryption, and decryption of MACsec frames


returns the value of the C bit for packets sent through this SA


decapsulate a MACsec frame

decrypt(orig_pkt, assoclen=None)

decrypt a MACsec frame for this Secure Association


returns the value of the E bit for packets sent through this SA


encapsulate a frame using this Secure Association

encrypt(orig_pkt, assoclen=None)

encrypt a MACsec frame for this Secure Association


generate an IV for the packet

static shortlen(pkt)

determine shortlen for a raw packet (not encapsulated yet)

static split_pkt(pkt, assoclen, icvlen=0)

split the packet into associated data, plaintext or ciphertext, and optional ICV