blob: 178b1d248bf694f53cbe508605b99392d237cd0f [file] [log] [blame]
“mystarrocks”23f0c452017-12-11 07:11:51 -08001import socket
Klement Sekera28fb03f2018-04-17 11:36:55 +02002import unittest
Klement Sekera31da2e32018-06-24 22:49:55 +02003from scapy.layers.ipsec import ESP
Christian Hoppsfb7e7ed2019-11-03 07:02:15 -05004from scapy.layers.inet import IP, ICMP, UDP
Neale Ranns041add72020-01-02 04:06:10 +00005from scapy.layers.inet6 import IPv6
6from scapy.layers.l2 import Ether
7from scapy.packet import Raw
“mystarrocks”23f0c452017-12-11 07:11:51 -08008
Neale Ranns00625a62019-07-31 00:13:18 -07009from parameterized import parameterized
juraj.linkes11057662019-07-08 10:22:55 +020010from framework import VppTestRunner
Neale Ranns53f526b2019-02-25 14:32:02 +000011from template_ipsec import IpsecTra46Tests, IpsecTun46Tests, TemplateIpsec, \
Neale Ranns4f33c802019-04-10 12:39:10 +000012 IpsecTcpTests, IpsecTun4Tests, IpsecTra4Tests, config_tra_params, \
Neale Ranns12989b52019-09-26 16:20:19 +000013 config_tun_params, IPsecIPv4Params, IPsecIPv6Params, \
Neale Ranns4a56f4e2019-12-23 04:10:25 +000014 IpsecTra4, IpsecTun4, IpsecTra6, IpsecTun6, \
Neale Ranns02950402019-12-20 00:54:57 +000015 IpsecTun6HandoffTests, IpsecTun4HandoffTests, \
Filip Tehlarefcad1a2020-02-04 09:36:04 +000016 IpsecTra6ExtTests
Klement Sekerabf613952019-01-29 11:38:08 +010017from vpp_ipsec import VppIpsecSpd, VppIpsecSpdEntry, VppIpsecSA,\
Neale Ranns4f33c802019-04-10 12:39:10 +000018 VppIpsecSpdItfBinding
Neale Ranns311124e2019-01-24 04:52:25 -080019from vpp_ip_route import VppIpRoute, VppRoutePath
20from vpp_ip import DpoProto
Neale Ranns17dcec02019-01-09 21:22:20 -080021from vpp_papi import VppEnum
“mystarrocks”23f0c452017-12-11 07:11:51 -080022
Neale Rannsc87b66c2019-02-07 07:26:12 -080023NUM_PKTS = 67
Filip Tehlarefcad1a2020-02-04 09:36:04 +000024engines_supporting_chain_bufs = ["openssl"]
Neale Rannsc87b66c2019-02-07 07:26:12 -080025
“mystarrocks”23f0c452017-12-11 07:11:51 -080026
Neale Ranns4f33c802019-04-10 12:39:10 +000027class ConfigIpsecESP(TemplateIpsec):
28 encryption_type = ESP
29 tra4_encrypt_node_name = "esp4-encrypt"
30 tra4_decrypt_node_name = "esp4-decrypt"
31 tra6_encrypt_node_name = "esp6-encrypt"
32 tra6_decrypt_node_name = "esp6-decrypt"
33 tun4_encrypt_node_name = "esp4-encrypt"
34 tun4_decrypt_node_name = "esp4-decrypt"
35 tun6_encrypt_node_name = "esp6-encrypt"
36 tun6_decrypt_node_name = "esp6-decrypt"
Neale Ranns53f526b2019-02-25 14:32:02 +000037
Neale Ranns4f33c802019-04-10 12:39:10 +000038 @classmethod
39 def setUpClass(cls):
40 super(ConfigIpsecESP, cls).setUpClass()
Neale Ranns53f526b2019-02-25 14:32:02 +000041
Neale Ranns4f33c802019-04-10 12:39:10 +000042 @classmethod
43 def tearDownClass(cls):
44 super(ConfigIpsecESP, cls).tearDownClass()
Neale Ranns53f526b2019-02-25 14:32:02 +000045
Neale Ranns4f33c802019-04-10 12:39:10 +000046 def setUp(self):
47 super(ConfigIpsecESP, self).setUp()
Neale Ranns53f526b2019-02-25 14:32:02 +000048
Neale Ranns4f33c802019-04-10 12:39:10 +000049 def tearDown(self):
50 super(ConfigIpsecESP, self).tearDown()
51
52 def config_network(self, params):
53 self.net_objs = []
54 self.tun_if = self.pg0
55 self.tra_if = self.pg2
56 self.logger.info(self.vapi.ppcli("show int addr"))
57
58 self.tra_spd = VppIpsecSpd(self, self.tra_spd_id)
59 self.tra_spd.add_vpp_config()
60 self.net_objs.append(self.tra_spd)
61 self.tun_spd = VppIpsecSpd(self, self.tun_spd_id)
62 self.tun_spd.add_vpp_config()
63 self.net_objs.append(self.tun_spd)
64
65 b = VppIpsecSpdItfBinding(self, self.tun_spd,
66 self.tun_if)
67 b.add_vpp_config()
68 self.net_objs.append(b)
69
70 b = VppIpsecSpdItfBinding(self, self.tra_spd,
71 self.tra_if)
72 b.add_vpp_config()
73 self.net_objs.append(b)
74
75 for p in params:
76 self.config_esp_tra(p)
77 config_tra_params(p, self.encryption_type)
78 for p in params:
79 self.config_esp_tun(p)
Neale Ranns12989b52019-09-26 16:20:19 +000080 config_tun_params(p, self.encryption_type, self.tun_if)
Neale Ranns4f33c802019-04-10 12:39:10 +000081
82 for p in params:
83 d = DpoProto.DPO_PROTO_IP6 if p.is_ipv6 else DpoProto.DPO_PROTO_IP4
84 r = VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
85 [VppRoutePath(self.tun_if.remote_addr[p.addr_type],
86 0xffffffff,
Neale Ranns097fa662018-05-01 05:17:55 -070087 proto=d)])
Neale Ranns4f33c802019-04-10 12:39:10 +000088 r.add_vpp_config()
89 self.net_objs.append(r)
90
91 self.logger.info(self.vapi.ppcli("show ipsec all"))
92
93 def unconfig_network(self):
94 for o in reversed(self.net_objs):
95 o.remove_vpp_config()
96 self.net_objs = []
97
98 def config_esp_tun(self, params):
99 addr_type = params.addr_type
100 scapy_tun_sa_id = params.scapy_tun_sa_id
101 scapy_tun_spi = params.scapy_tun_spi
102 vpp_tun_sa_id = params.vpp_tun_sa_id
103 vpp_tun_spi = params.vpp_tun_spi
104 auth_algo_vpp_id = params.auth_algo_vpp_id
105 auth_key = params.auth_key
106 crypt_algo_vpp_id = params.crypt_algo_vpp_id
107 crypt_key = params.crypt_key
108 remote_tun_if_host = params.remote_tun_if_host
109 addr_any = params.addr_any
110 addr_bcast = params.addr_bcast
111 e = VppEnum.vl_api_ipsec_spd_action_t
Neale Ranns49e7ef62019-04-10 17:24:29 +0000112 flags = params.flags
Neale Ranns041add72020-01-02 04:06:10 +0000113 tun_flags = params.tun_flags
Neale Ranns80f6fd52019-04-16 02:41:34 +0000114 salt = params.salt
Neale Ranns4f33c802019-04-10 12:39:10 +0000115 objs = []
116
117 params.tun_sa_in = VppIpsecSA(self, scapy_tun_sa_id, scapy_tun_spi,
118 auth_algo_vpp_id, auth_key,
119 crypt_algo_vpp_id, crypt_key,
120 self.vpp_esp_protocol,
121 self.tun_if.local_addr[addr_type],
Neale Ranns49e7ef62019-04-10 17:24:29 +0000122 self.tun_if.remote_addr[addr_type],
Neale Ranns041add72020-01-02 04:06:10 +0000123 tun_flags=tun_flags,
124 dscp=params.dscp,
Neale Ranns80f6fd52019-04-16 02:41:34 +0000125 flags=flags,
126 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000127 params.tun_sa_out = VppIpsecSA(self, vpp_tun_sa_id, vpp_tun_spi,
128 auth_algo_vpp_id, auth_key,
129 crypt_algo_vpp_id, crypt_key,
130 self.vpp_esp_protocol,
131 self.tun_if.remote_addr[addr_type],
Neale Ranns49e7ef62019-04-10 17:24:29 +0000132 self.tun_if.local_addr[addr_type],
Neale Ranns041add72020-01-02 04:06:10 +0000133 tun_flags=tun_flags,
134 dscp=params.dscp,
Neale Ranns80f6fd52019-04-16 02:41:34 +0000135 flags=flags,
136 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000137 objs.append(params.tun_sa_in)
138 objs.append(params.tun_sa_out)
139
140 params.spd_policy_in_any = VppIpsecSpdEntry(self, self.tun_spd,
141 scapy_tun_sa_id,
142 addr_any, addr_bcast,
143 addr_any, addr_bcast,
144 socket.IPPROTO_ESP)
145 params.spd_policy_out_any = VppIpsecSpdEntry(self, self.tun_spd,
146 scapy_tun_sa_id,
147 addr_any, addr_bcast,
148 addr_any, addr_bcast,
149 socket.IPPROTO_ESP,
150 is_outbound=0)
151 objs.append(params.spd_policy_out_any)
152 objs.append(params.spd_policy_in_any)
153
154 objs.append(VppIpsecSpdEntry(self, self.tun_spd, vpp_tun_sa_id,
155 remote_tun_if_host, remote_tun_if_host,
156 self.pg1.remote_addr[addr_type],
157 self.pg1.remote_addr[addr_type],
158 0,
159 priority=10,
160 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
161 is_outbound=0))
162 objs.append(VppIpsecSpdEntry(self, self.tun_spd, scapy_tun_sa_id,
163 self.pg1.remote_addr[addr_type],
164 self.pg1.remote_addr[addr_type],
165 remote_tun_if_host, remote_tun_if_host,
166 0,
167 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
168 priority=10))
169 objs.append(VppIpsecSpdEntry(self, self.tun_spd, vpp_tun_sa_id,
170 remote_tun_if_host, remote_tun_if_host,
171 self.pg0.local_addr[addr_type],
172 self.pg0.local_addr[addr_type],
173 0,
174 priority=20,
175 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
176 is_outbound=0))
177 objs.append(VppIpsecSpdEntry(self, self.tun_spd, scapy_tun_sa_id,
178 self.pg0.local_addr[addr_type],
179 self.pg0.local_addr[addr_type],
180 remote_tun_if_host, remote_tun_if_host,
181 0,
182 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
183 priority=20))
184 for o in objs:
185 o.add_vpp_config()
186 self.net_objs = self.net_objs + objs
187
188 def config_esp_tra(self, params):
189 addr_type = params.addr_type
190 scapy_tra_sa_id = params.scapy_tra_sa_id
191 scapy_tra_spi = params.scapy_tra_spi
192 vpp_tra_sa_id = params.vpp_tra_sa_id
193 vpp_tra_spi = params.vpp_tra_spi
194 auth_algo_vpp_id = params.auth_algo_vpp_id
195 auth_key = params.auth_key
196 crypt_algo_vpp_id = params.crypt_algo_vpp_id
197 crypt_key = params.crypt_key
198 addr_any = params.addr_any
199 addr_bcast = params.addr_bcast
200 flags = (VppEnum.vl_api_ipsec_sad_flags_t.
201 IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY)
202 e = VppEnum.vl_api_ipsec_spd_action_t
203 flags = params.flags | flags
Neale Ranns80f6fd52019-04-16 02:41:34 +0000204 salt = params.salt
Neale Ranns4f33c802019-04-10 12:39:10 +0000205 objs = []
206
207 params.tra_sa_in = VppIpsecSA(self, scapy_tra_sa_id, scapy_tra_spi,
208 auth_algo_vpp_id, auth_key,
209 crypt_algo_vpp_id, crypt_key,
210 self.vpp_esp_protocol,
Neale Ranns80f6fd52019-04-16 02:41:34 +0000211 flags=flags,
212 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000213 params.tra_sa_out = VppIpsecSA(self, vpp_tra_sa_id, vpp_tra_spi,
214 auth_algo_vpp_id, auth_key,
215 crypt_algo_vpp_id, crypt_key,
216 self.vpp_esp_protocol,
Neale Ranns80f6fd52019-04-16 02:41:34 +0000217 flags=flags,
218 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000219 objs.append(params.tra_sa_in)
220 objs.append(params.tra_sa_out)
221
222 objs.append(VppIpsecSpdEntry(self, self.tra_spd, vpp_tra_sa_id,
223 addr_any, addr_bcast,
224 addr_any, addr_bcast,
225 socket.IPPROTO_ESP))
226 objs.append(VppIpsecSpdEntry(self, self.tra_spd, vpp_tra_sa_id,
227 addr_any, addr_bcast,
228 addr_any, addr_bcast,
229 socket.IPPROTO_ESP,
230 is_outbound=0))
231 objs.append(VppIpsecSpdEntry(self, self.tra_spd, vpp_tra_sa_id,
232 self.tra_if.local_addr[addr_type],
233 self.tra_if.local_addr[addr_type],
234 self.tra_if.remote_addr[addr_type],
235 self.tra_if.remote_addr[addr_type],
236 0, priority=10,
237 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
238 is_outbound=0))
239 objs.append(VppIpsecSpdEntry(self, self.tra_spd, scapy_tra_sa_id,
240 self.tra_if.local_addr[addr_type],
241 self.tra_if.local_addr[addr_type],
242 self.tra_if.remote_addr[addr_type],
243 self.tra_if.remote_addr[addr_type],
244 0, policy=e.IPSEC_API_SPD_ACTION_PROTECT,
245 priority=10))
246 for o in objs:
247 o.add_vpp_config()
248 self.net_objs = self.net_objs + objs
Neale Ranns53f526b2019-02-25 14:32:02 +0000249
250
Neale Ranns4f33c802019-04-10 12:39:10 +0000251class TemplateIpsecEsp(ConfigIpsecESP):
“mystarrocks”23f0c452017-12-11 07:11:51 -0800252 """
253 Basic test for ipsec esp sanity - tunnel and transport modes.
254
255 Below 4 cases are covered as part of this test
256 1) ipsec esp v4 transport basic test - IPv4 Transport mode
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700257 scenario using HMAC-SHA1-96 integrity algo
“mystarrocks”23f0c452017-12-11 07:11:51 -0800258 2) ipsec esp v4 transport burst test
259 Above test for 257 pkts
260 3) ipsec esp 4o4 tunnel basic test - IPv4 Tunnel mode
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700261 scenario using HMAC-SHA1-96 integrity algo
“mystarrocks”23f0c452017-12-11 07:11:51 -0800262 4) ipsec esp 4o4 tunnel burst test
263 Above test for 257 pkts
264
265 TRANSPORT MODE:
266
267 --- encrypt ---
268 |pg2| <-------> |VPP|
269 --- decrypt ---
270
271 TUNNEL MODE:
272
273 --- encrypt --- plain ---
Klement Sekera4b089f22018-04-17 18:04:57 +0200274 |pg0| <------- |VPP| <------ |pg1|
“mystarrocks”23f0c452017-12-11 07:11:51 -0800275 --- --- ---
276
277 --- decrypt --- plain ---
Klement Sekera4b089f22018-04-17 18:04:57 +0200278 |pg0| -------> |VPP| ------> |pg1|
“mystarrocks”23f0c452017-12-11 07:11:51 -0800279 --- --- ---
“mystarrocks”23f0c452017-12-11 07:11:51 -0800280 """
281
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700282 @classmethod
283 def setUpClass(cls):
284 super(TemplateIpsecEsp, cls).setUpClass()
285
286 @classmethod
287 def tearDownClass(cls):
288 super(TemplateIpsecEsp, cls).tearDownClass()
289
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800290 def setUp(self):
291 super(TemplateIpsecEsp, self).setUp()
Neale Ranns4f33c802019-04-10 12:39:10 +0000292 self.config_network(self.params.values())
Klement Sekera611864f2018-09-26 11:19:00 +0200293
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800294 def tearDown(self):
Neale Ranns4f33c802019-04-10 12:39:10 +0000295 self.unconfig_network()
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800296 super(TemplateIpsecEsp, self).tearDown()
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800297
Klement Sekera611864f2018-09-26 11:19:00 +0200298
Neale Ranns02950402019-12-20 00:54:57 +0000299class TestIpsecEsp1(TemplateIpsecEsp, IpsecTra46Tests,
Filip Tehlarefcad1a2020-02-04 09:36:04 +0000300 IpsecTun46Tests, IpsecTra6ExtTests):
Klement Sekera31da2e32018-06-24 22:49:55 +0200301 """ Ipsec ESP - TUN & TRA tests """
Neale Rannsb1fd80f2020-05-12 13:33:56 +0000302
303 @classmethod
304 def setUpClass(cls):
305 super(TestIpsecEsp1, cls).setUpClass()
306
307 @classmethod
308 def tearDownClass(cls):
309 super(TestIpsecEsp1, cls).tearDownClass()
310
311 def setUp(self):
312 super(TestIpsecEsp1, self).setUp()
313
314 def tearDown(self):
315 super(TestIpsecEsp1, self).tearDown()
316
317 def test_tun_46(self):
318 """ ipsec 4o6 tunnel """
319 # add an SPD entry to direct 2.2.2.2 to the v6 tunnel SA
320 p6 = self.ipv6_params
321 p4 = self.ipv4_params
322
323 p6.remote_tun_if_host4 = "2.2.2.2"
324 e = VppEnum.vl_api_ipsec_spd_action_t
325
326 VppIpsecSpdEntry(self,
327 self.tun_spd,
328 p6.scapy_tun_sa_id,
329 self.pg1.remote_addr[p4.addr_type],
330 self.pg1.remote_addr[p4.addr_type],
331 p6.remote_tun_if_host4,
332 p6.remote_tun_if_host4,
333 0,
334 priority=10,
335 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
336 is_outbound=1).add_vpp_config()
337 VppIpRoute(self, p6.remote_tun_if_host4, p4.addr_len,
338 [VppRoutePath(self.tun_if.remote_addr[p4.addr_type],
339 0xffffffff)]).add_vpp_config()
340
341 old_name = self.tun6_encrypt_node_name
342 self.tun6_encrypt_node_name = "esp4-encrypt"
343
344 self.verify_tun_46(p6, count=63)
345 self.tun6_encrypt_node_name = old_name
346
347 def test_tun_64(self):
348 """ ipsec 6o4 tunnel """
349 # add an SPD entry to direct 4444::4 to the v4 tunnel SA
350 p6 = self.ipv6_params
351 p4 = self.ipv4_params
352
353 p4.remote_tun_if_host6 = "4444::4"
354 e = VppEnum.vl_api_ipsec_spd_action_t
355
356 VppIpsecSpdEntry(self,
357 self.tun_spd,
358 p4.scapy_tun_sa_id,
359 self.pg1.remote_addr[p6.addr_type],
360 self.pg1.remote_addr[p6.addr_type],
361 p4.remote_tun_if_host6,
362 p4.remote_tun_if_host6,
363 0,
364 priority=10,
365 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
366 is_outbound=1).add_vpp_config()
367 d = DpoProto.DPO_PROTO_IP6
368 VppIpRoute(self, p4.remote_tun_if_host6, p6.addr_len,
369 [VppRoutePath(self.tun_if.remote_addr[p6.addr_type],
370 0xffffffff,
371 proto=d)]).add_vpp_config()
372
373 old_name = self.tun4_encrypt_node_name
374 self.tun4_encrypt_node_name = "esp6-encrypt"
375 self.verify_tun_64(p4, count=63)
376 self.tun4_encrypt_node_name = old_name
“mystarrocks”23f0c452017-12-11 07:11:51 -0800377
“mystarrocks”23f0c452017-12-11 07:11:51 -0800378
Neale Ranns041add72020-01-02 04:06:10 +0000379class TestIpsecEspTun(TemplateIpsecEsp, IpsecTun46Tests):
380 """ Ipsec ESP - TUN encap tests """
381
382 def setUp(self):
383 self.ipv4_params = IPsecIPv4Params()
384 self.ipv6_params = IPsecIPv6Params()
385
386 c = (VppEnum.vl_api_tunnel_encap_decap_flags_t.
387 TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP)
388 c1 = c | (VppEnum.vl_api_tunnel_encap_decap_flags_t.
389 TUNNEL_API_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN)
390
391 self.ipv4_params.tun_flags = c
392 self.ipv6_params.tun_flags = c1
393
394 super(TestIpsecEspTun, self).setUp()
395
396 def gen_pkts(self, sw_intf, src, dst, count=1, payload_size=54):
397 # set the DSCP + ECN - flags are set to copy only DSCP
398 return [Ether(src=sw_intf.remote_mac, dst=sw_intf.local_mac) /
399 IP(src=src, dst=dst, tos=5) /
400 UDP(sport=4444, dport=4444) /
401 Raw(b'X' * payload_size)
402 for i in range(count)]
403
404 def gen_pkts6(self, sw_intf, src, dst, count=1, payload_size=54):
405 # set the DSCP + ECN - flags are set to copy both
406 return [Ether(src=sw_intf.remote_mac, dst=sw_intf.local_mac) /
407 IPv6(src=src, dst=dst, tc=5) /
408 UDP(sport=4444, dport=4444) /
409 Raw(b'X' * payload_size)
410 for i in range(count)]
411
412 def verify_encrypted(self, p, sa, rxs):
413 # just check that only the DSCP is copied
414 for rx in rxs:
415 self.assertEqual(rx[IP].tos, 4)
416
417 def verify_encrypted6(self, p, sa, rxs):
418 # just check that the DSCP & ECN are copied
419 for rx in rxs:
420 self.assertEqual(rx[IPv6].tc, 5)
421
422
423class TestIpsecEspTun2(TemplateIpsecEsp, IpsecTun46Tests):
424 """ Ipsec ESP - TUN DSCP tests """
425
426 def setUp(self):
427 self.ipv4_params = IPsecIPv4Params()
428 self.ipv6_params = IPsecIPv6Params()
429
430 self.ipv4_params.dscp = VppEnum.vl_api_ip_dscp_t.IP_API_DSCP_EF
431 self.ipv6_params.dscp = VppEnum.vl_api_ip_dscp_t.IP_API_DSCP_AF11
432
433 super(TestIpsecEspTun2, self).setUp()
434
435 def gen_pkts(self, sw_intf, src, dst, count=1, payload_size=54):
436 # set the DSCP + ECN - flags are set to copy only DSCP
437 return [Ether(src=sw_intf.remote_mac, dst=sw_intf.local_mac) /
438 IP(src=src, dst=dst) /
439 UDP(sport=4444, dport=4444) /
440 Raw(b'X' * payload_size)
441 for i in range(count)]
442
443 def gen_pkts6(self, sw_intf, src, dst, count=1, payload_size=54):
444 # set the DSCP + ECN - flags are set to copy both
445 return [Ether(src=sw_intf.remote_mac, dst=sw_intf.local_mac) /
446 IPv6(src=src, dst=dst) /
447 UDP(sport=4444, dport=4444) /
448 Raw(b'X' * payload_size)
449 for i in range(count)]
450
451 def verify_encrypted(self, p, sa, rxs):
452 # just check that only the DSCP is copied
453 for rx in rxs:
454 self.assertEqual(rx[IP].tos,
455 VppEnum.vl_api_ip_dscp_t.IP_API_DSCP_EF << 2)
456
457 def verify_encrypted6(self, p, sa, rxs):
458 # just check that the DSCP & ECN are copied
459 for rx in rxs:
460 self.assertEqual(rx[IPv6].tc,
461 VppEnum.vl_api_ip_dscp_t.IP_API_DSCP_AF11 << 2)
462
463
Klement Sekera31da2e32018-06-24 22:49:55 +0200464class TestIpsecEsp2(TemplateIpsecEsp, IpsecTcpTests):
465 """ Ipsec ESP - TCP tests """
466 pass
“mystarrocks”23f0c452017-12-11 07:11:51 -0800467
468
Neale Ranns4a56f4e2019-12-23 04:10:25 +0000469class TestIpsecEspHandoff(TemplateIpsecEsp,
470 IpsecTun6HandoffTests,
471 IpsecTun4HandoffTests):
472 """ Ipsec ESP - handoff tests """
473 pass
474
475
Neale Ranns4f33c802019-04-10 12:39:10 +0000476class TemplateIpsecEspUdp(ConfigIpsecESP):
Neale Ranns53f526b2019-02-25 14:32:02 +0000477 """
478 UDP encapped ESP
479 """
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700480
481 @classmethod
482 def setUpClass(cls):
483 super(TemplateIpsecEspUdp, cls).setUpClass()
484
485 @classmethod
486 def tearDownClass(cls):
487 super(TemplateIpsecEspUdp, cls).tearDownClass()
488
Neale Ranns53f526b2019-02-25 14:32:02 +0000489 def setUp(self):
490 super(TemplateIpsecEspUdp, self).setUp()
Neale Ranns4f33c802019-04-10 12:39:10 +0000491 self.net_objs = []
Neale Ranns53f526b2019-02-25 14:32:02 +0000492 self.tun_if = self.pg0
493 self.tra_if = self.pg2
494 self.logger.info(self.vapi.ppcli("show int addr"))
495
496 p = self.ipv4_params
497 p.flags = (VppEnum.vl_api_ipsec_sad_flags_t.
498 IPSEC_API_SAD_FLAG_UDP_ENCAP)
499 p.nat_header = UDP(sport=5454, dport=4500)
500
501 self.tra_spd = VppIpsecSpd(self, self.tra_spd_id)
502 self.tra_spd.add_vpp_config()
503 VppIpsecSpdItfBinding(self, self.tra_spd,
504 self.tra_if).add_vpp_config()
505
Neale Ranns4f33c802019-04-10 12:39:10 +0000506 self.config_esp_tra(p)
Neale Ranns2ac885c2019-03-20 18:24:43 +0000507 config_tra_params(p, self.encryption_type)
Neale Ranns53f526b2019-02-25 14:32:02 +0000508
509 self.tun_spd = VppIpsecSpd(self, self.tun_spd_id)
510 self.tun_spd.add_vpp_config()
511 VppIpsecSpdItfBinding(self, self.tun_spd,
512 self.tun_if).add_vpp_config()
513
Neale Ranns4f33c802019-04-10 12:39:10 +0000514 self.config_esp_tun(p)
Neale Ranns92e93842019-04-08 07:36:50 +0000515 self.logger.info(self.vapi.ppcli("show ipsec all"))
Neale Ranns53f526b2019-02-25 14:32:02 +0000516
517 d = DpoProto.DPO_PROTO_IP4
518 VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
519 [VppRoutePath(self.tun_if.remote_addr[p.addr_type],
520 0xffffffff,
521 proto=d)]).add_vpp_config()
522
523 def tearDown(self):
524 super(TemplateIpsecEspUdp, self).tearDown()
Paul Vinciguerra90cf21b2019-03-13 09:23:05 -0700525
526 def show_commands_at_teardown(self):
527 self.logger.info(self.vapi.cli("show hardware"))
Neale Ranns53f526b2019-02-25 14:32:02 +0000528
529
Neale Ranns49e7ef62019-04-10 17:24:29 +0000530class TestIpsecEspUdp(TemplateIpsecEspUdp, IpsecTra4Tests):
Neale Ranns53f526b2019-02-25 14:32:02 +0000531 """ Ipsec NAT-T ESP UDP tests """
Neale Ranns53f526b2019-02-25 14:32:02 +0000532 pass
533
534
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000535class MyParameters():
536 def __init__(self):
537 self.engines = ["ia32", "ipsecmb", "openssl"]
538 flag_esn = VppEnum.vl_api_ipsec_sad_flags_t.IPSEC_API_SAD_FLAG_USE_ESN
539 self.flags = [0, flag_esn]
Neale Ranns4f33c802019-04-10 12:39:10 +0000540 # foreach crypto algorithm
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000541 self.algos = {
542 'AES-GCM-128/NONE': {
543 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Neale Ranns47feb112019-04-11 15:14:07 +0000544 IPSEC_API_CRYPTO_ALG_AES_GCM_128),
545 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
546 IPSEC_API_INTEG_ALG_NONE),
547 'scapy-crypto': "AES-GCM",
548 'scapy-integ': "NULL",
Ole Troan64e978b2019-10-17 21:40:36 +0200549 'key': b"JPjyOWBeVEQiMe7h",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000550 'salt': 0},
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000551 'AES-GCM-192/NONE': {
552 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Neale Ranns80f6fd52019-04-16 02:41:34 +0000553 IPSEC_API_CRYPTO_ALG_AES_GCM_192),
554 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
555 IPSEC_API_INTEG_ALG_NONE),
556 'scapy-crypto': "AES-GCM",
557 'scapy-integ': "NULL",
Ole Troan64e978b2019-10-17 21:40:36 +0200558 'key': b"JPjyOWBeVEQiMe7h01234567",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000559 'salt': 1010},
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000560 'AES-GCM-256/NONE': {
561 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Neale Ranns47feb112019-04-11 15:14:07 +0000562 IPSEC_API_CRYPTO_ALG_AES_GCM_256),
563 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
564 IPSEC_API_INTEG_ALG_NONE),
565 'scapy-crypto': "AES-GCM",
566 'scapy-integ': "NULL",
Ole Troan64e978b2019-10-17 21:40:36 +0200567 'key': b"JPjyOWBeVEQiMe7h0123456787654321",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000568 'salt': 2020},
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000569 'AES-CBC-128/MD5-96': {
570 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Neale Ranns47feb112019-04-11 15:14:07 +0000571 IPSEC_API_CRYPTO_ALG_AES_CBC_128),
572 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
Dmitry Vakhrushev77cc14a2019-08-14 00:12:33 -0400573 IPSEC_API_INTEG_ALG_MD5_96),
Neale Ranns47feb112019-04-11 15:14:07 +0000574 'scapy-crypto': "AES-CBC",
Dmitry Vakhrushev77cc14a2019-08-14 00:12:33 -0400575 'scapy-integ': "HMAC-MD5-96",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000576 'salt': 0,
Ole Troan64e978b2019-10-17 21:40:36 +0200577 'key': b"JPjyOWBeVEQiMe7h"},
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000578 'AES-CBC-192/SHA1-96': {
579 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Neale Ranns47feb112019-04-11 15:14:07 +0000580 IPSEC_API_CRYPTO_ALG_AES_CBC_192),
581 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
582 IPSEC_API_INTEG_ALG_SHA1_96),
583 'scapy-crypto': "AES-CBC",
584 'scapy-integ': "HMAC-SHA1-96",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000585 'salt': 0,
Ole Troan64e978b2019-10-17 21:40:36 +0200586 'key': b"JPjyOWBeVEQiMe7hJPjyOWBe"},
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000587 'AES-CBC-256/SHA1-96': {
588 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Neale Ranns47feb112019-04-11 15:14:07 +0000589 IPSEC_API_CRYPTO_ALG_AES_CBC_256),
590 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
591 IPSEC_API_INTEG_ALG_SHA1_96),
592 'scapy-crypto': "AES-CBC",
593 'scapy-integ': "HMAC-SHA1-96",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000594 'salt': 0,
Ole Troan64e978b2019-10-17 21:40:36 +0200595 'key': b"JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"},
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000596 '3DES-CBC/SHA1-96': {
597 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Vladimir Ratnikovf4805072019-05-17 09:17:59 -0400598 IPSEC_API_CRYPTO_ALG_3DES_CBC),
599 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
600 IPSEC_API_INTEG_ALG_SHA1_96),
601 'scapy-crypto': "3DES",
602 'scapy-integ': "HMAC-SHA1-96",
603 'salt': 0,
Ole Troan64e978b2019-10-17 21:40:36 +0200604 'key': b"JPjyOWBeVEQiMe7h00112233"},
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000605 'NONE/SHA1-96': {
606 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
Neale Ranns2cdcd0c2019-08-27 12:26:14 +0000607 IPSEC_API_CRYPTO_ALG_NONE),
608 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
609 IPSEC_API_INTEG_ALG_SHA1_96),
610 'scapy-crypto': "NULL",
611 'scapy-integ': "HMAC-SHA1-96",
612 'salt': 0,
Benoît Ganne490b9272021-01-22 18:03:09 +0100613 'key': b"JPjyOWBeVEQiMe7h00112233"},
614 'AES-CTR-128/SHA1-96': {
615 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
616 IPSEC_API_CRYPTO_ALG_AES_CTR_128),
617 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
618 IPSEC_API_INTEG_ALG_SHA1_96),
619 'scapy-crypto': "AES-CTR",
620 'scapy-integ': "HMAC-SHA1-96",
621 'salt': 0,
622 'key': b"JPjyOWBeVEQiMe7h"},
623 'AES-CTR-192/SHA1-96': {
624 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
625 IPSEC_API_CRYPTO_ALG_AES_CTR_192),
626 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
627 IPSEC_API_INTEG_ALG_SHA1_96),
628 'scapy-crypto': "AES-CTR",
629 'scapy-integ': "HMAC-SHA1-96",
630 'salt': 1010,
631 'key': b"JPjyOWBeVEQiMe7hJPjyOWBe"},
632 'AES-CTR-256/SHA1-96': {
633 'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
634 IPSEC_API_CRYPTO_ALG_AES_CTR_256),
635 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
636 IPSEC_API_INTEG_ALG_SHA1_96),
637 'scapy-crypto': "AES-CTR",
638 'scapy-integ': "HMAC-SHA1-96",
639 'salt': 2020,
640 'key': b"JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"}}
Neale Ranns4f33c802019-04-10 12:39:10 +0000641
Neale Ranns4f33c802019-04-10 12:39:10 +0000642
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000643class RunTestIpsecEspAll(ConfigIpsecESP,
644 IpsecTra4, IpsecTra6,
645 IpsecTun4, IpsecTun6):
646 """ Ipsec ESP all Algos """
647
648 def setUp(self):
649 super(RunTestIpsecEspAll, self).setUp()
650 test_args = str.split(self.__doc__, " ")
651
652 params = MyParameters()
653 self.engine = test_args[0]
654 self.flag = params.flags[0]
655 if test_args[1] == 'ESN':
656 self.flag = params.flags[1]
657
658 self.algo = params.algos[test_args[2]]
659
660 def tearDown(self):
661 super(RunTestIpsecEspAll, self).tearDown()
662
663 def run_test(self):
664 self.run_a_test(self.engine, self.flag, self.algo)
665
Filip Tehlarefcad1a2020-02-04 09:36:04 +0000666 def run_a_test(self, engine, flag, algo, payload_size=None):
Christian Hoppsfb7e7ed2019-11-03 07:02:15 -0500667 if engine == "ia32":
668 engine = "native"
Neale Ranns00625a62019-07-31 00:13:18 -0700669 self.vapi.cli("set crypto handler all %s" % engine)
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000670
671 self.ipv4_params = IPsecIPv4Params()
672 self.ipv6_params = IPsecIPv6Params()
673
674 self.params = {self.ipv4_params.addr_type:
675 self.ipv4_params,
676 self.ipv6_params.addr_type:
677 self.ipv6_params}
678
679 for _, p in self.params.items():
680 p.auth_algo_vpp_id = algo['vpp-integ']
681 p.crypt_algo_vpp_id = algo['vpp-crypto']
682 p.crypt_algo = algo['scapy-crypto']
683 p.auth_algo = algo['scapy-integ']
684 p.crypt_key = algo['key']
685 p.salt = algo['salt']
686 p.flags = p.flags | flag
687
688 self.reporter.send_keep_alive(self)
689
Neale Ranns4f33c802019-04-10 12:39:10 +0000690 #
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000691 # configure the SPDs. SAs, etc
Neale Ranns4f33c802019-04-10 12:39:10 +0000692 #
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000693 self.config_network(self.params.values())
Neale Ranns4f33c802019-04-10 12:39:10 +0000694
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000695 #
696 # run some traffic.
697 # An exhautsive 4o6, 6o4 is not necessary
698 # for each algo
699 #
700 self.verify_tra_basic6(count=NUM_PKTS)
701 self.verify_tra_basic4(count=NUM_PKTS)
702 self.verify_tun_66(self.params[socket.AF_INET6],
703 count=NUM_PKTS)
Christian Hoppsfb7e7ed2019-11-03 07:02:15 -0500704 #
705 # Use an odd-byte payload size to check for correct padding.
706 #
707 # 49 + 2 == 51 which should pad +1 to 52 for 4 byte alignment, +5
708 # to 56 for 8 byte alignment, and +13 to 64 for 64 byte alignment.
709 # This should catch bugs where the code is incorrectly over-padding
710 # for algorithms that don't require it
711 psz = 49 - len(IP()/ICMP()) if payload_size is None else payload_size
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000712 self.verify_tun_44(self.params[socket.AF_INET],
Christian Hoppsfb7e7ed2019-11-03 07:02:15 -0500713 count=NUM_PKTS, payload_size=psz)
Neale Ranns4f33c802019-04-10 12:39:10 +0000714
Filip Tehlarefcad1a2020-02-04 09:36:04 +0000715 LARGE_PKT_SZ = [
Filip Tehlare4e8c6b2020-02-13 07:49:30 +0000716 1970, # results in 2 chained buffers entering decrypt node
717 # but leaving as simple buffer due to ICV removal (tra4)
PiotrX Kleskifdca4dd2020-05-05 14:14:22 +0200718 2004, # footer+ICV will be added to 2nd buffer (tun4)
Filip Tehlarefcad1a2020-02-04 09:36:04 +0000719 4010, # ICV ends up splitted accross 2 buffers in esp_decrypt
720 # for transport4; transport6 takes normal path
Filip Tehlarefcad1a2020-02-04 09:36:04 +0000721 4020, # same as above but tra4 and tra6 are switched
722 ]
723 if self.engine in engines_supporting_chain_bufs:
724 for sz in LARGE_PKT_SZ:
725 self.verify_tra_basic4(count=NUM_PKTS, payload_size=sz)
726 self.verify_tra_basic6(count=NUM_PKTS, payload_size=sz)
727 self.verify_tun_66(self.params[socket.AF_INET6],
728 count=NUM_PKTS, payload_size=sz)
729 self.verify_tun_44(self.params[socket.AF_INET],
730 count=NUM_PKTS, payload_size=sz)
731
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000732 #
733 # remove the SPDs, SAs, etc
734 #
735 self.unconfig_network()
Neale Ranns4f33c802019-04-10 12:39:10 +0000736
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000737 #
738 # reconfigure the network and SA to run the
739 # anti replay tests
740 #
741 self.config_network(self.params.values())
742 self.verify_tra_anti_replay()
743 self.unconfig_network()
juraj.linkes11057662019-07-08 10:22:55 +0200744
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000745#
746# To generate test classes, do:
747# grep '# GEN' test_ipsec_esp.py | sed -e 's/# GEN //g' | bash
748#
749# GEN for ENG in ia32 ipsecmb openssl; do \
750# GEN for FLG in noESN ESN; do for ALG in AES-GCM-128/NONE \
751# GEN AES-GCM-192/NONE AES-GCM-256/NONE AES-CBC-128/MD5-96 \
752# GEN AES-CBC-192/SHA1-96 AES-CBC-256/SHA1-96 \
Benoît Ganne490b9272021-01-22 18:03:09 +0100753# GEN 3DES-CBC/SHA1-96 NONE/SHA1-96 \
754# GEN AES-CTR-128/SHA1-96 AES-CTR-192/SHA1-96 AES-CTR-256/SHA1-96; do \
Filip Tehlar39cf40a2020-03-25 04:08:55 +0000755# GEN [[ ${FLG} == "ESN" && ${ALG} == *"NONE" ]] && continue
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000756# GEN echo -e "\n\nclass Test_${ENG}_${FLG}_${ALG}(RunTestIpsecEspAll):" |
757# GEN sed -e 's/-/_/g' -e 's#/#_#g' ; \
758# GEN echo ' """'$ENG $FLG $ALG IPSec test'"""' ;
759# GEN echo " def test_ipsec(self):";
760# GEN echo " self.run_test()";
761# GEN done; done; done
Neale Ranns4f33c802019-04-10 12:39:10 +0000762
Neale Ranns4f33c802019-04-10 12:39:10 +0000763
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000764class Test_ia32_noESN_AES_GCM_128_NONE(RunTestIpsecEspAll):
765 """ia32 noESN AES-GCM-128/NONE IPSec test"""
766 def test_ipsec(self):
767 self.run_test()
Neale Ranns4f33c802019-04-10 12:39:10 +0000768
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000769
770class Test_ia32_noESN_AES_GCM_192_NONE(RunTestIpsecEspAll):
771 """ia32 noESN AES-GCM-192/NONE IPSec test"""
772 def test_ipsec(self):
773 self.run_test()
774
775
776class Test_ia32_noESN_AES_GCM_256_NONE(RunTestIpsecEspAll):
777 """ia32 noESN AES-GCM-256/NONE IPSec test"""
778 def test_ipsec(self):
779 self.run_test()
780
781
782class Test_ia32_noESN_AES_CBC_128_MD5_96(RunTestIpsecEspAll):
783 """ia32 noESN AES-CBC-128/MD5-96 IPSec test"""
784 def test_ipsec(self):
785 self.run_test()
786
787
788class Test_ia32_noESN_AES_CBC_192_SHA1_96(RunTestIpsecEspAll):
789 """ia32 noESN AES-CBC-192/SHA1-96 IPSec test"""
790 def test_ipsec(self):
791 self.run_test()
792
793
794class Test_ia32_noESN_AES_CBC_256_SHA1_96(RunTestIpsecEspAll):
795 """ia32 noESN AES-CBC-256/SHA1-96 IPSec test"""
796 def test_ipsec(self):
797 self.run_test()
798
799
800class Test_ia32_noESN_3DES_CBC_SHA1_96(RunTestIpsecEspAll):
801 """ia32 noESN 3DES-CBC/SHA1-96 IPSec test"""
802 def test_ipsec(self):
803 self.run_test()
804
805
806class Test_ia32_noESN_NONE_SHA1_96(RunTestIpsecEspAll):
807 """ia32 noESN NONE/SHA1-96 IPSec test"""
808 def test_ipsec(self):
809 self.run_test()
810
811
Benoît Ganne490b9272021-01-22 18:03:09 +0100812class Test_ia32_noESN_AES_CTR_128_SHA1_96(RunTestIpsecEspAll):
813 """ia32 noESN AES-CTR-128/SHA1-96 IPSec test"""
814 def test_ipsec(self):
815 self.run_test()
816
817
818class Test_ia32_noESN_AES_CTR_192_SHA1_96(RunTestIpsecEspAll):
819 """ia32 noESN AES-CTR-192/SHA1-96 IPSec test"""
820 def test_ipsec(self):
821 self.run_test()
822
823
824class Test_ia32_noESN_AES_CTR_256_SHA1_96(RunTestIpsecEspAll):
825 """ia32 noESN AES-CTR-256/SHA1-96 IPSec test"""
826 def test_ipsec(self):
827 self.run_test()
828
829
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000830class Test_ia32_ESN_AES_CBC_128_MD5_96(RunTestIpsecEspAll):
831 """ia32 ESN AES-CBC-128/MD5-96 IPSec test"""
832 def test_ipsec(self):
833 self.run_test()
834
835
836class Test_ia32_ESN_AES_CBC_192_SHA1_96(RunTestIpsecEspAll):
837 """ia32 ESN AES-CBC-192/SHA1-96 IPSec test"""
838 def test_ipsec(self):
839 self.run_test()
840
841
842class Test_ia32_ESN_AES_CBC_256_SHA1_96(RunTestIpsecEspAll):
843 """ia32 ESN AES-CBC-256/SHA1-96 IPSec test"""
844 def test_ipsec(self):
845 self.run_test()
846
847
848class Test_ia32_ESN_3DES_CBC_SHA1_96(RunTestIpsecEspAll):
849 """ia32 ESN 3DES-CBC/SHA1-96 IPSec test"""
850 def test_ipsec(self):
851 self.run_test()
852
853
854class Test_ia32_ESN_NONE_SHA1_96(RunTestIpsecEspAll):
855 """ia32 ESN NONE/SHA1-96 IPSec test"""
856 def test_ipsec(self):
857 self.run_test()
858
859
Benoît Ganne490b9272021-01-22 18:03:09 +0100860class Test_ia32_ESN_AES_CTR_128_SHA1_96(RunTestIpsecEspAll):
861 """ia32 ESN AES-CTR-128/SHA1-96 IPSec test"""
862 def test_ipsec(self):
863 self.run_test()
864
865
866class Test_ia32_ESN_AES_CTR_192_SHA1_96(RunTestIpsecEspAll):
867 """ia32 ESN AES-CTR-192/SHA1-96 IPSec test"""
868 def test_ipsec(self):
869 self.run_test()
870
871
872class Test_ia32_ESN_AES_CTR_256_SHA1_96(RunTestIpsecEspAll):
873 """ia32 ESN AES-CTR-256/SHA1-96 IPSec test"""
874 def test_ipsec(self):
875 self.run_test()
876
877
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000878class Test_ipsecmb_noESN_AES_GCM_128_NONE(RunTestIpsecEspAll):
879 """ipsecmb noESN AES-GCM-128/NONE IPSec test"""
880 def test_ipsec(self):
881 self.run_test()
882
883
884class Test_ipsecmb_noESN_AES_GCM_192_NONE(RunTestIpsecEspAll):
885 """ipsecmb noESN AES-GCM-192/NONE IPSec test"""
886 def test_ipsec(self):
887 self.run_test()
888
889
890class Test_ipsecmb_noESN_AES_GCM_256_NONE(RunTestIpsecEspAll):
891 """ipsecmb noESN AES-GCM-256/NONE IPSec test"""
892 def test_ipsec(self):
893 self.run_test()
894
895
896class Test_ipsecmb_noESN_AES_CBC_128_MD5_96(RunTestIpsecEspAll):
897 """ipsecmb noESN AES-CBC-128/MD5-96 IPSec test"""
898 def test_ipsec(self):
899 self.run_test()
900
901
902class Test_ipsecmb_noESN_AES_CBC_192_SHA1_96(RunTestIpsecEspAll):
903 """ipsecmb noESN AES-CBC-192/SHA1-96 IPSec test"""
904 def test_ipsec(self):
905 self.run_test()
906
907
908class Test_ipsecmb_noESN_AES_CBC_256_SHA1_96(RunTestIpsecEspAll):
909 """ipsecmb noESN AES-CBC-256/SHA1-96 IPSec test"""
910 def test_ipsec(self):
911 self.run_test()
912
913
914class Test_ipsecmb_noESN_3DES_CBC_SHA1_96(RunTestIpsecEspAll):
915 """ipsecmb noESN 3DES-CBC/SHA1-96 IPSec test"""
916 def test_ipsec(self):
917 self.run_test()
918
919
920class Test_ipsecmb_noESN_NONE_SHA1_96(RunTestIpsecEspAll):
921 """ipsecmb noESN NONE/SHA1-96 IPSec test"""
922 def test_ipsec(self):
923 self.run_test()
924
925
Benoît Ganne490b9272021-01-22 18:03:09 +0100926class Test_ipsecmb_noESN_AES_CTR_128_SHA1_96(RunTestIpsecEspAll):
927 """ipsecmb noESN AES-CTR-128/SHA1-96 IPSec test"""
928 def test_ipsec(self):
929 self.run_test()
930
931
932class Test_ipsecmb_noESN_AES_CTR_192_SHA1_96(RunTestIpsecEspAll):
933 """ipsecmb noESN AES-CTR-192/SHA1-96 IPSec test"""
934 def test_ipsec(self):
935 self.run_test()
936
937
938class Test_ipsecmb_noESN_AES_CTR_256_SHA1_96(RunTestIpsecEspAll):
939 """ipsecmb noESN AES-CTR-256/SHA1-96 IPSec test"""
940 def test_ipsec(self):
941 self.run_test()
942
943
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000944class Test_ipsecmb_ESN_AES_CBC_128_MD5_96(RunTestIpsecEspAll):
945 """ipsecmb ESN AES-CBC-128/MD5-96 IPSec test"""
946 def test_ipsec(self):
947 self.run_test()
948
949
950class Test_ipsecmb_ESN_AES_CBC_192_SHA1_96(RunTestIpsecEspAll):
951 """ipsecmb ESN AES-CBC-192/SHA1-96 IPSec test"""
952 def test_ipsec(self):
953 self.run_test()
954
955
956class Test_ipsecmb_ESN_AES_CBC_256_SHA1_96(RunTestIpsecEspAll):
957 """ipsecmb ESN AES-CBC-256/SHA1-96 IPSec test"""
958 def test_ipsec(self):
959 self.run_test()
960
961
962class Test_ipsecmb_ESN_3DES_CBC_SHA1_96(RunTestIpsecEspAll):
963 """ipsecmb ESN 3DES-CBC/SHA1-96 IPSec test"""
964 def test_ipsec(self):
965 self.run_test()
966
967
968class Test_ipsecmb_ESN_NONE_SHA1_96(RunTestIpsecEspAll):
969 """ipsecmb ESN NONE/SHA1-96 IPSec test"""
970 def test_ipsec(self):
971 self.run_test()
972
973
Benoît Ganne490b9272021-01-22 18:03:09 +0100974class Test_ipsecmb_ESN_AES_CTR_128_SHA1_96(RunTestIpsecEspAll):
975 """ipsecmb ESN AES-CTR-128/SHA1-96 IPSec test"""
976 def test_ipsec(self):
977 self.run_test()
978
979
980class Test_ipsecmb_ESN_AES_CTR_192_SHA1_96(RunTestIpsecEspAll):
981 """ipsecmb ESN AES-CTR-192/SHA1-96 IPSec test"""
982 def test_ipsec(self):
983 self.run_test()
984
985
986class Test_ipsecmb_ESN_AES_CTR_256_SHA1_96(RunTestIpsecEspAll):
987 """ipsecmb ESN AES-CTR-256/SHA1-96 IPSec test"""
988 def test_ipsec(self):
989 self.run_test()
990
991
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +0000992class Test_openssl_noESN_AES_GCM_128_NONE(RunTestIpsecEspAll):
993 """openssl noESN AES-GCM-128/NONE IPSec test"""
994 def test_ipsec(self):
995 self.run_test()
996
997
998class Test_openssl_noESN_AES_GCM_192_NONE(RunTestIpsecEspAll):
999 """openssl noESN AES-GCM-192/NONE IPSec test"""
1000 def test_ipsec(self):
1001 self.run_test()
1002
1003
1004class Test_openssl_noESN_AES_GCM_256_NONE(RunTestIpsecEspAll):
1005 """openssl noESN AES-GCM-256/NONE IPSec test"""
1006 def test_ipsec(self):
1007 self.run_test()
1008
1009
1010class Test_openssl_noESN_AES_CBC_128_MD5_96(RunTestIpsecEspAll):
1011 """openssl noESN AES-CBC-128/MD5-96 IPSec test"""
1012 def test_ipsec(self):
1013 self.run_test()
1014
1015
1016class Test_openssl_noESN_AES_CBC_192_SHA1_96(RunTestIpsecEspAll):
1017 """openssl noESN AES-CBC-192/SHA1-96 IPSec test"""
1018 def test_ipsec(self):
1019 self.run_test()
1020
1021
1022class Test_openssl_noESN_AES_CBC_256_SHA1_96(RunTestIpsecEspAll):
1023 """openssl noESN AES-CBC-256/SHA1-96 IPSec test"""
1024 def test_ipsec(self):
1025 self.run_test()
1026
1027
1028class Test_openssl_noESN_3DES_CBC_SHA1_96(RunTestIpsecEspAll):
1029 """openssl noESN 3DES-CBC/SHA1-96 IPSec test"""
1030 def test_ipsec(self):
1031 self.run_test()
1032
1033
1034class Test_openssl_noESN_NONE_SHA1_96(RunTestIpsecEspAll):
1035 """openssl noESN NONE/SHA1-96 IPSec test"""
1036 def test_ipsec(self):
1037 self.run_test()
1038
1039
Benoît Ganne490b9272021-01-22 18:03:09 +01001040class Test_openssl_noESN_AES_CTR_128_SHA1_96(RunTestIpsecEspAll):
1041 """openssl noESN AES-CTR-128/SHA1-96 IPSec test"""
1042 def test_ipsec(self):
1043 self.run_test()
1044
1045
1046class Test_openssl_noESN_AES_CTR_192_SHA1_96(RunTestIpsecEspAll):
1047 """openssl noESN AES-CTR-192/SHA1-96 IPSec test"""
1048 def test_ipsec(self):
1049 self.run_test()
1050
1051
1052class Test_openssl_noESN_AES_CTR_256_SHA1_96(RunTestIpsecEspAll):
1053 """openssl noESN AES-CTR-256/SHA1-96 IPSec test"""
1054 def test_ipsec(self):
1055 self.run_test()
1056
1057
Andrew Yourtchenkofbc38892019-09-09 11:14:59 +00001058class Test_openssl_ESN_AES_CBC_128_MD5_96(RunTestIpsecEspAll):
1059 """openssl ESN AES-CBC-128/MD5-96 IPSec test"""
1060 def test_ipsec(self):
1061 self.run_test()
1062
1063
1064class Test_openssl_ESN_AES_CBC_192_SHA1_96(RunTestIpsecEspAll):
1065 """openssl ESN AES-CBC-192/SHA1-96 IPSec test"""
1066 def test_ipsec(self):
1067 self.run_test()
1068
1069
1070class Test_openssl_ESN_AES_CBC_256_SHA1_96(RunTestIpsecEspAll):
1071 """openssl ESN AES-CBC-256/SHA1-96 IPSec test"""
1072 def test_ipsec(self):
1073 self.run_test()
1074
1075
1076class Test_openssl_ESN_3DES_CBC_SHA1_96(RunTestIpsecEspAll):
1077 """openssl ESN 3DES-CBC/SHA1-96 IPSec test"""
1078 def test_ipsec(self):
1079 self.run_test()
1080
1081
1082class Test_openssl_ESN_NONE_SHA1_96(RunTestIpsecEspAll):
1083 """openssl ESN NONE/SHA1-96 IPSec test"""
1084 def test_ipsec(self):
1085 self.run_test()
Neale Ranns6afaae12019-07-17 15:07:14 +00001086
Neale Ranns4f33c802019-04-10 12:39:10 +00001087
Benoît Ganne490b9272021-01-22 18:03:09 +01001088class Test_openssl_ESN_AES_CTR_128_SHA1_96(RunTestIpsecEspAll):
1089 """openssl ESN AES-CTR-128/SHA1-96 IPSec test"""
1090 def test_ipsec(self):
1091 self.run_test()
1092
1093
1094class Test_openssl_ESN_AES_CTR_192_SHA1_96(RunTestIpsecEspAll):
1095 """openssl ESN AES-CTR-192/SHA1-96 IPSec test"""
1096 def test_ipsec(self):
1097 self.run_test()
1098
1099
1100class Test_openssl_ESN_AES_CTR_256_SHA1_96(RunTestIpsecEspAll):
1101 """openssl ESN AES-CTR-256/SHA1-96 IPSec test"""
1102 def test_ipsec(self):
1103 self.run_test()
1104
1105
“mystarrocks”23f0c452017-12-11 07:11:51 -08001106if __name__ == '__main__':
1107 unittest.main(testRunner=VppTestRunner)