aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py8
-rw-r--r--test/template_ipsec.py8
-rw-r--r--test/test_ipsec_esp.py16
-rw-r--r--test/test_ipsec_tun_if_esp.py26
4 files changed, 31 insertions, 27 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index c01b2d3bd8b..5b45cd8a569 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -188,8 +188,12 @@ class FixedList_u8(object):
' expected: {}'
.format(self.name, len(data), self.num))
- return self.packer.pack(data)
-
+ try:
+ return self.packer.pack(data)
+ except struct.error:
+ raise VPPSerializerValueError(
+ 'Packing failed for "{}" {}'
+ .format(self.name, kwargs))
def unpack(self, data, offset=0, result=None, ntc=False):
if len(data[offset:]) < self.num:
raise VPPSerializerValueError(
diff --git a/test/template_ipsec.py b/test/template_ipsec.py
index a4f998ee84e..f83f4026832 100644
--- a/test/template_ipsec.py
+++ b/test/template_ipsec.py
@@ -37,12 +37,12 @@ class IPsecIPv4Params(object):
self.auth_algo_vpp_id = (VppEnum.vl_api_ipsec_integ_alg_t.
IPSEC_API_INTEG_ALG_SHA1_96)
self.auth_algo = 'HMAC-SHA1-96' # scapy name
- self.auth_key = 'C91KUR9GYMm5GfkEvNjX'
+ self.auth_key = b'C91KUR9GYMm5GfkEvNjX'
self.crypt_algo_vpp_id = (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_CBC_128)
self.crypt_algo = 'AES-CBC' # scapy name
- self.crypt_key = 'JPjyOWBeVEQiMe7h'
+ self.crypt_key = b'JPjyOWBeVEQiMe7h'
self.salt = 0
self.flags = 0
self.nat_header = None
@@ -73,12 +73,12 @@ class IPsecIPv6Params(object):
self.auth_algo_vpp_id = (VppEnum.vl_api_ipsec_integ_alg_t.
IPSEC_API_INTEG_ALG_SHA1_96)
self.auth_algo = 'HMAC-SHA1-96' # scapy name
- self.auth_key = 'C91KUR9GYMm5GfkEvNjX'
+ self.auth_key = b'C91KUR9GYMm5GfkEvNjX'
self.crypt_algo_vpp_id = (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_CBC_128)
self.crypt_algo = 'AES-CBC' # scapy name
- self.crypt_key = 'JPjyOWBeVEQiMe7h'
+ self.crypt_key = b'JPjyOWBeVEQiMe7h'
self.salt = 0
self.flags = 0
self.nat_header = None
diff --git a/test/test_ipsec_esp.py b/test/test_ipsec_esp.py
index 2ac919142d8..b72b7e1fe48 100644
--- a/test/test_ipsec_esp.py
+++ b/test/test_ipsec_esp.py
@@ -367,7 +367,7 @@ class MyParameters():
IPSEC_API_INTEG_ALG_NONE),
'scapy-crypto': "AES-GCM",
'scapy-integ': "NULL",
- 'key': "JPjyOWBeVEQiMe7h",
+ 'key': b"JPjyOWBeVEQiMe7h",
'salt': 0},
'AES-GCM-192/NONE': {
'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
@@ -376,7 +376,7 @@ class MyParameters():
IPSEC_API_INTEG_ALG_NONE),
'scapy-crypto': "AES-GCM",
'scapy-integ': "NULL",
- 'key': "JPjyOWBeVEQiMe7h01234567",
+ 'key': b"JPjyOWBeVEQiMe7h01234567",
'salt': 1010},
'AES-GCM-256/NONE': {
'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
@@ -385,7 +385,7 @@ class MyParameters():
IPSEC_API_INTEG_ALG_NONE),
'scapy-crypto': "AES-GCM",
'scapy-integ': "NULL",
- 'key': "JPjyOWBeVEQiMe7h0123456787654321",
+ 'key': b"JPjyOWBeVEQiMe7h0123456787654321",
'salt': 2020},
'AES-CBC-128/MD5-96': {
'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
@@ -395,7 +395,7 @@ class MyParameters():
'scapy-crypto': "AES-CBC",
'scapy-integ': "HMAC-MD5-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7h"},
+ 'key': b"JPjyOWBeVEQiMe7h"},
'AES-CBC-192/SHA1-96': {
'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_CBC_192),
@@ -404,7 +404,7 @@ class MyParameters():
'scapy-crypto': "AES-CBC",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7hJPjyOWBe"},
+ 'key': b"JPjyOWBeVEQiMe7hJPjyOWBe"},
'AES-CBC-256/SHA1-96': {
'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_CBC_256),
@@ -413,7 +413,7 @@ class MyParameters():
'scapy-crypto': "AES-CBC",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"},
+ 'key': b"JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"},
'3DES-CBC/SHA1-96': {
'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_3DES_CBC),
@@ -422,7 +422,7 @@ class MyParameters():
'scapy-crypto': "3DES",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7h00112233"},
+ 'key': b"JPjyOWBeVEQiMe7h00112233"},
'NONE/SHA1-96': {
'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_NONE),
@@ -431,7 +431,7 @@ class MyParameters():
'scapy-crypto': "NULL",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7h00112233"}}
+ 'key': b"JPjyOWBeVEQiMe7h00112233"}}
class RunTestIpsecEspAll(ConfigIpsecESP,
diff --git a/test/test_ipsec_tun_if_esp.py b/test/test_ipsec_tun_if_esp.py
index 28854cefa99..971ec79fd67 100644
--- a/test/test_ipsec_tun_if_esp.py
+++ b/test/test_ipsec_tun_if_esp.py
@@ -312,7 +312,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
#
# change the key and the SPI
#
- p.crypt_key = 'X' + p.crypt_key[1:]
+ p.crypt_key = b'X' + p.crypt_key[1:]
p.scapy_tun_spi += 1
p.scapy_tun_sa_id += 1
p.vpp_tun_spi += 1
@@ -370,7 +370,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
IPSEC_API_INTEG_ALG_NONE),
'scapy-crypto': "AES-GCM",
'scapy-integ': "NULL",
- 'key': "JPjyOWBeVEQiMe7h",
+ 'key': b"JPjyOWBeVEQiMe7h",
'salt': 3333},
{'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_GCM_192),
@@ -378,7 +378,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
IPSEC_API_INTEG_ALG_NONE),
'scapy-crypto': "AES-GCM",
'scapy-integ': "NULL",
- 'key': "JPjyOWBeVEQiMe7hJPjyOWBe",
+ 'key': b"JPjyOWBeVEQiMe7hJPjyOWBe",
'salt': 0},
{'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_GCM_256),
@@ -386,7 +386,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
IPSEC_API_INTEG_ALG_NONE),
'scapy-crypto': "AES-GCM",
'scapy-integ': "NULL",
- 'key': "JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h",
+ 'key': b"JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h",
'salt': 9999},
{'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_CBC_128),
@@ -395,7 +395,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
'scapy-crypto': "AES-CBC",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7h"},
+ 'key': b"JPjyOWBeVEQiMe7h"},
{'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_CBC_192),
'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
@@ -403,7 +403,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
'scapy-crypto': "AES-CBC",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7hJPjyOWBe"},
+ 'key': b"JPjyOWBeVEQiMe7hJPjyOWBe"},
{'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_AES_CBC_256),
'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
@@ -411,7 +411,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
'scapy-crypto': "AES-CBC",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"},
+ 'key': b"JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"},
{'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
IPSEC_API_CRYPTO_ALG_NONE),
'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
@@ -419,7 +419,7 @@ class TestIpsec4TunIfEspAll(TemplateIpsec, IpsecTun4):
'scapy-crypto': "NULL",
'scapy-integ': "HMAC-SHA1-96",
'salt': 0,
- 'key': "JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"}]
+ 'key': b"JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"}]
for engine in engines:
self.vapi.cli("set crypto handler all %s" % engine)
@@ -846,7 +846,7 @@ class TestIpsec4TunProtect(TemplateIpsec,
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
- np.crypt_key = 'X' + p.crypt_key[1:]
+ np.crypt_key = b'X' + p.crypt_key[1:]
np.scapy_tun_spi += 100
np.scapy_tun_sa_id += 1
np.vpp_tun_spi += 100
@@ -990,7 +990,7 @@ class TestIpsec4TunProtectTun(TemplateIpsec,
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
- np.crypt_key = 'X' + p.crypt_key[1:]
+ np.crypt_key = b'X' + p.crypt_key[1:]
np.scapy_tun_spi += 100
np.scapy_tun_sa_id += 1
np.vpp_tun_spi += 100
@@ -1123,7 +1123,7 @@ class TestIpsec6TunProtect(TemplateIpsec,
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
- np.crypt_key = 'X' + p.crypt_key[1:]
+ np.crypt_key = b'X' + p.crypt_key[1:]
np.scapy_tun_spi += 100
np.scapy_tun_sa_id += 1
np.vpp_tun_spi += 100
@@ -1146,7 +1146,7 @@ class TestIpsec6TunProtect(TemplateIpsec,
# 2) swap output SA to [new]
# 3) use only [new] input SA
np3 = copy.copy(np)
- np3.crypt_key = 'Z' + p.crypt_key[1:]
+ np3.crypt_key = b'Z' + p.crypt_key[1:]
np3.scapy_tun_spi += 100
np3.scapy_tun_sa_id += 1
np3.vpp_tun_spi += 100
@@ -1285,7 +1285,7 @@ class TestIpsec6TunProtectTun(TemplateIpsec,
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
- np.crypt_key = 'X' + p.crypt_key[1:]
+ np.crypt_key = b'X' + p.crypt_key[1:]
np.scapy_tun_spi += 100
np.scapy_tun_sa_id += 1
np.vpp_tun_spi += 100