Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
IPSEC: ESP with ESN tests and fixes
[vpp.git]
/
test
/
patches
/
scapy-2.4
/
ipsec.patch
diff --git
a/test/patches/scapy-2.4/ipsec.patch
b/test/patches/scapy-2.4/ipsec.patch
index
5a64432
..
b19112d
100644
(file)
--- a/
test/patches/scapy-2.4/ipsec.patch
+++ b/
test/patches/scapy-2.4/ipsec.patch
@@
-1,8
+1,8
@@
diff --git a/scapy/layers/ipsec.py b/scapy/layers/ipsec.py
diff --git a/scapy/layers/ipsec.py b/scapy/layers/ipsec.py
-index 69e7ae3b..
99373466
100644
+index 69e7ae3b..
b35da2b1
100644
--- a/scapy/layers/ipsec.py
+++ b/scapy/layers/ipsec.py
--- a/scapy/layers/ipsec.py
+++ b/scapy/layers/ipsec.py
-@@ -518,12 +51
7
,16 @@ class AuthAlgo(object):
+@@ -518,12 +51
8
,16 @@ class AuthAlgo(object):
else:
return self.mac(key, self.digestmod(), default_backend())
else:
return self.mac(key, self.digestmod(), default_backend())
@@
-20,7
+20,14
@@
index 69e7ae3b..99373466 100644
@return: the signed packet
"""
@return: the signed packet
"""
-@@ -539,11 +542,13 @@ class AuthAlgo(object):
+@@ -534,16 +538,20 @@ class AuthAlgo(object):
+
+ if pkt.haslayer(ESP):
+ mac.update(raw(pkt[ESP]))
++ if trailer:
++ mac.update(trailer)
+ pkt[ESP].data += mac.finalize()[:self.icv_size]
+
elif pkt.haslayer(AH):
clone = zero_mutable_fields(pkt.copy(), sending=True)
mac.update(raw(clone))
elif pkt.haslayer(AH):
clone = zero_mutable_fields(pkt.copy(), sending=True)
mac.update(raw(clone))
@@
-35,7
+42,7
@@
index 69e7ae3b..99373466 100644
"""
Check that the integrity check value (icv) of a packet is valid.
"""
Check that the integrity check value (icv) of a packet is valid.
-@@ -574,6 +5
79
,8 @@ class AuthAlgo(object):
+@@ -574,6 +5
82
,8 @@ class AuthAlgo(object):
clone = zero_mutable_fields(pkt.copy(), sending=False)
mac.update(raw(clone))
clone = zero_mutable_fields(pkt.copy(), sending=False)
mac.update(raw(clone))
@@
-44,7
+51,7
@@
index 69e7ae3b..99373466 100644
computed_icv = mac.finalize()[:self.icv_size]
# XXX: Cannot use mac.verify because the ICV can be truncated
computed_icv = mac.finalize()[:self.icv_size]
# XXX: Cannot use mac.verify because the ICV can be truncated
-@@ -757,7 +76
4
,8 @@ class SecurityAssociation(object):
+@@ -757,7 +76
7
,8 @@ class SecurityAssociation(object):
SUPPORTED_PROTOS = (IP, IPv6)
def __init__(self, proto, spi, seq_num=1, crypt_algo=None, crypt_key=None,
SUPPORTED_PROTOS = (IP, IPv6)
def __init__(self, proto, spi, seq_num=1, crypt_algo=None, crypt_key=None,
@@
-54,7
+61,7
@@
index 69e7ae3b..99373466 100644
"""
@param proto: the IPsec proto to use (ESP or AH)
@param spi: the Security Parameters Index of this SA
"""
@param proto: the IPsec proto to use (ESP or AH)
@param spi: the Security Parameters Index of this SA
-@@ -771,6 +7
79
,7 @@ class SecurityAssociation(object):
+@@ -771,6 +7
82
,7 @@ class SecurityAssociation(object):
to encapsulate the encrypted packets.
@param nat_t_header: an instance of a UDP header that will be used
for NAT-Traversal.
to encapsulate the encrypted packets.
@param nat_t_header: an instance of a UDP header that will be used
for NAT-Traversal.
@@
-62,7
+69,7
@@
index 69e7ae3b..99373466 100644
"""
if proto not in (ESP, AH, ESP.name, AH.name):
"""
if proto not in (ESP, AH, ESP.name, AH.name):
-@@ -782,6 +79
1
,7 @@ class SecurityAssociation(object):
+@@ -782,6 +79
4
,7 @@ class SecurityAssociation(object):
self.spi = spi
self.seq_num = seq_num
self.spi = spi
self.seq_num = seq_num
@@
-70,7
+77,7
@@
index 69e7ae3b..99373466 100644
if crypt_algo:
if crypt_algo not in CRYPT_ALGOS:
if crypt_algo:
if crypt_algo not in CRYPT_ALGOS:
-@@ -827,6 +8
37
,17 @@ class SecurityAssociation(object):
+@@ -827,6 +8
40
,17 @@ class SecurityAssociation(object):
raise TypeError('packet spi=0x%x does not match the SA spi=0x%x' %
(pkt.spi, self.spi))
raise TypeError('packet spi=0x%x does not match the SA spi=0x%x' %
(pkt.spi, self.spi))
@@
-88,7
+95,7
@@
index 69e7ae3b..99373466 100644
def _encrypt_esp(self, pkt, seq_num=None, iv=None):
if iv is None:
def _encrypt_esp(self, pkt, seq_num=None, iv=None):
if iv is None:
-@@ -835,7 +85
6
,8 @@ class SecurityAssociation(object):
+@@ -835,7 +85
9
,8 @@ class SecurityAssociation(object):
if len(iv) != self.crypt_algo.iv_size:
raise TypeError('iv length must be %s' % self.crypt_algo.iv_size)
if len(iv) != self.crypt_algo.iv_size:
raise TypeError('iv length must be %s' % self.crypt_algo.iv_size)
@@
-98,7
+105,7
@@
index 69e7ae3b..99373466 100644
if self.tunnel_header:
tunnel = self.tunnel_header.copy()
if self.tunnel_header:
tunnel = self.tunnel_header.copy()
-@@ -857,7 +8
79
,7 @@ class SecurityAssociation(object):
+@@ -857,7 +8
82
,7 @@ class SecurityAssociation(object):
esp = self.crypt_algo.pad(esp)
esp = self.crypt_algo.encrypt(self, esp, self.crypt_key)
esp = self.crypt_algo.pad(esp)
esp = self.crypt_algo.encrypt(self, esp, self.crypt_key)
@@
-107,7
+114,7
@@
index 69e7ae3b..99373466 100644
if self.nat_t_header:
nat_t_header = self.nat_t_header.copy()
if self.nat_t_header:
nat_t_header = self.nat_t_header.copy()
-@@ -884,7 +90
6
,8 @@ class SecurityAssociation(object):
+@@ -884,7 +90
9
,8 @@ class SecurityAssociation(object):
def _encrypt_ah(self, pkt, seq_num=None):
def _encrypt_ah(self, pkt, seq_num=None):
@@
-117,7
+124,7
@@
index 69e7ae3b..99373466 100644
icv = b"\x00" * self.auth_algo.icv_size)
if self.tunnel_header:
icv = b"\x00" * self.auth_algo.icv_size)
if self.tunnel_header:
-@@ -924,7 +9
47
,8 @@ class SecurityAssociation(object):
+@@ -924,7 +9
50
,8 @@ class SecurityAssociation(object):
else:
ip_header.plen = len(ip_header.payload) + len(ah) + len(payload)
else:
ip_header.plen = len(ip_header.payload) + len(ah) + len(payload)
@@
-127,7
+134,7
@@
index 69e7ae3b..99373466 100644
# sequence number must always change, unless specified by the user
if seq_num is None:
# sequence number must always change, unless specified by the user
if seq_num is None:
-@@ -955,11 +9
79
,12 @@ class SecurityAssociation(object):
+@@ -955,11 +9
82
,12 @@ class SecurityAssociation(object):
def _decrypt_esp(self, pkt, verify=True):
def _decrypt_esp(self, pkt, verify=True):
@@
-141,7
+148,7
@@
index 69e7ae3b..99373466 100644
esp = self.crypt_algo.decrypt(self, encrypted, self.crypt_key,
self.crypt_algo.icv_size or
esp = self.crypt_algo.decrypt(self, encrypted, self.crypt_key,
self.crypt_algo.icv_size or
-@@ -998,9 +102
3
,11 @@ class SecurityAssociation(object):
+@@ -998,9 +102
6
,11 @@ class SecurityAssociation(object):
def _decrypt_ah(self, pkt, verify=True):
def _decrypt_ah(self, pkt, verify=True):