scapy.contrib.macsec

Classes and functions for MACsec.

class scapy.contrib.macsec.MACsec(_pkt, /, *, Ver=0, ES=0, SC=0, SCB=0, E=0, C=0, AN=0, reserved=0, SL=0, PN=1, SCI=None, type=None)[source]

Bases: Packet

representation of one MACsec frame

aliastypes = [<class 'scapy.contrib.macsec.MACsec'>, <class 'scapy.packet.Packet'>]
deprecated_fields: Dict[str, Tuple[str, str]] = {'an': ('AN', '2.4.4'), 'pn': ('PN', '2.4.4'), 'sci': ('SCI', '2.4.4'), 'shortlen': ('SL', '2.4.4')}
fields_desc: ClassVar[List[Field[Any, Any] | _FieldContainer]] = [<BitField (MACsec).Ver>, <BitField (MACsec).ES>, <BitField (MACsec).SC>, <BitField (MACsec).SCB>, <BitField (MACsec).E>, <BitField (MACsec).C>, <BitField (MACsec).AN>, <BitField (MACsec).reserved>, <BitField (MACsec).SL>, <IntField (MACsec).PN>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>]
mysummary()[source]
payload_guess: List[Tuple[Dict[str, Any], Type[Packet]]] = [({'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)[source]

Bases: object

Representation of a MACsec Secure Association

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

c_bit()[source]

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

decap(orig_pkt)[source]

decapsulate a MACsec frame

decrypt(orig_pkt, assoclen=None)[source]

decrypt a MACsec frame for this Secure Association

e_bit()[source]

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

encap(pkt)[source]

encapsulate a frame using this Secure Association

encrypt(orig_pkt, assoclen=None)[source]

encrypt a MACsec frame for this Secure Association

make_iv(pkt)[source]

generate an IV for the packet

static shortlen(pkt)[source]

determine shortlen for a raw packet (not encapsulated yet)

static split_pkt(pkt, assoclen, icvlen=0)[source]

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