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)[源代码]

基类:Packet

representation of one MACsec frame

aliastypes
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
Display RFC-like schema
 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V|E|S|S|E|C| AN|RES|     SL    |               PN              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |              SCI              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                           Fig. MACsec                            
MACsec fields

Ver

BitField (1 bit)

0

ES

BitField (1 bit)

0

SC

BitField (1 bit)

0

SCB

BitField (1 bit)

0

E

BitField (1 bit)

0

C

BitField (1 bit)

0

AN

BitField (2 bits)

0

reserved

BitField (2 bits)

0

SL

BitField (6 bits)

0

PN

IntField

1

SCI

PacketField (Cond)

None

type

XShortEnumField (Cond)

None

mysummary()[源代码]
payload_guess

Possible sublayers: IP, IPv6

class scapy.contrib.macsec.MACsecSA(sci, an, pn, key, icvlen, encrypt, send_sci, xpn_en=False, ssci=None, salt=None)[源代码]

基类:object

Representation of a MACsec Secure Association

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

c_bit()[源代码]

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

decap(orig_pkt)[源代码]

decapsulate a MACsec frame

decrypt(orig_pkt, assoclen=None)[源代码]

decrypt a MACsec frame for this Secure Association

e_bit()[源代码]

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

encap(pkt)[源代码]

encapsulate a frame using this Secure Association

encrypt(orig_pkt, assoclen=None)[源代码]

encrypt a MACsec frame for this Secure Association

make_iv(pkt)[源代码]

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