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

Method encrypt

scapy/layers/ipsec.py:1132–1158  ·  view source on GitHub ↗

Encrypt (and encapsulate) an IP(v6) packet with ESP or AH according to this SecurityAssociation. :param pkt: the packet to encrypt :param seq_num: if specified, use this sequence number instead of the generated one :param esn_en:

(self, pkt, seq_num=None, iv=None, esn_en=None, esn=None)

Source from the content-addressed store, hash-verified

1130 return signed_pkt
1131
1132 def encrypt(self, pkt, seq_num=None, iv=None, esn_en=None, esn=None):
1133 """
1134 Encrypt (and encapsulate) an IP(v6) packet with ESP or AH according
1135 to this SecurityAssociation.
1136
1137 :param pkt: the packet to encrypt
1138 :param seq_num: if specified, use this sequence number instead of the
1139 generated one
1140 :param esn_en: extended sequence number enable which allows to
1141 use 64-bit sequence number instead of 32-bit when
1142 using an AEAD algorithm
1143 :param esn: extended sequence number (32 MSB)
1144 :param iv: if specified, use this initialization vector for
1145 encryption instead of a random one.
1146
1147 :returns: the encrypted/encapsulated packet
1148 """
1149 if not isinstance(pkt, self.SUPPORTED_PROTOS):
1150 raise TypeError('cannot encrypt %s, supported protos are %s'
1151 % (pkt.__class__, self.SUPPORTED_PROTOS))
1152 if self.proto is ESP:
1153 return self._encrypt_esp(pkt, seq_num=seq_num,
1154 iv=iv, esn_en=esn_en,
1155 esn=esn)
1156 else:
1157 return self._encrypt_ah(pkt, seq_num=seq_num,
1158 esn_en=esn_en, esn=esn)
1159
1160 def _decrypt_esp(self, pkt, verify=True, esn_en=None, esn=None):
1161

Callers

nothing calls this directly

Calls 2

_encrypt_espMethod · 0.95
_encrypt_ahMethod · 0.95

Tested by

no test coverage detected