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

Method make_iv

scapy/contrib/macsec.py:79–86  ·  view source on GitHub ↗

generate an IV for the packet

(self, pkt)

Source from the content-addressed store, hash-verified

77 raise TypeError("Salt must be bytes")
78
79 def make_iv(self, pkt):
80 """generate an IV for the packet"""
81 if self.xpn_en:
82 tmp_pn = (self.pn & 0xFFFFFFFF00000000) | (pkt[MACsec].PN & 0xFFFFFFFF) # noqa: E501
83 tmp_iv = self.ssci + struct.pack('!Q', tmp_pn)
84 return bytes(bytearray([a ^ b for a, b in zip(bytearray(tmp_iv), bytearray(self.salt))])) # noqa: E501
85 else:
86 return self.sci + struct.pack('!I', pkt[MACsec].PN)
87
88 @staticmethod
89 def split_pkt(pkt, assoclen, icvlen=0):

Callers 2

encryptMethod · 0.95
decryptMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected