blob: eb21c58ae912c978a3855f19264efd51633fe8d7 [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
Neale Ranns53f526b2019-02-25 14:32:02 +00004from scapy.layers.inet import UDP
“mystarrocks”23f0c452017-12-11 07:11:51 -08005
Klement Sekera31da2e32018-06-24 22:49:55 +02006from framework import VppTestRunner
Neale Ranns53f526b2019-02-25 14:32:02 +00007from template_ipsec import IpsecTra46Tests, IpsecTun46Tests, TemplateIpsec, \
Neale Ranns4f33c802019-04-10 12:39:10 +00008 IpsecTcpTests, IpsecTun4Tests, IpsecTra4Tests, config_tra_params, \
9 IPsecIPv4Params, IPsecIPv6Params, \
10 IpsecTra4, IpsecTun4, IpsecTra6, IpsecTun6
Klement Sekerabf613952019-01-29 11:38:08 +010011from vpp_ipsec import VppIpsecSpd, VppIpsecSpdEntry, VppIpsecSA,\
Neale Ranns4f33c802019-04-10 12:39:10 +000012 VppIpsecSpdItfBinding
Neale Ranns311124e2019-01-24 04:52:25 -080013from vpp_ip_route import VppIpRoute, VppRoutePath
14from vpp_ip import DpoProto
Neale Ranns17dcec02019-01-09 21:22:20 -080015from vpp_papi import VppEnum
“mystarrocks”23f0c452017-12-11 07:11:51 -080016
17
Neale Ranns4f33c802019-04-10 12:39:10 +000018class ConfigIpsecESP(TemplateIpsec):
19 encryption_type = ESP
20 tra4_encrypt_node_name = "esp4-encrypt"
21 tra4_decrypt_node_name = "esp4-decrypt"
22 tra6_encrypt_node_name = "esp6-encrypt"
23 tra6_decrypt_node_name = "esp6-decrypt"
24 tun4_encrypt_node_name = "esp4-encrypt"
25 tun4_decrypt_node_name = "esp4-decrypt"
26 tun6_encrypt_node_name = "esp6-encrypt"
27 tun6_decrypt_node_name = "esp6-decrypt"
Neale Ranns53f526b2019-02-25 14:32:02 +000028
Neale Ranns4f33c802019-04-10 12:39:10 +000029 @classmethod
30 def setUpClass(cls):
31 super(ConfigIpsecESP, cls).setUpClass()
Neale Ranns53f526b2019-02-25 14:32:02 +000032
Neale Ranns4f33c802019-04-10 12:39:10 +000033 @classmethod
34 def tearDownClass(cls):
35 super(ConfigIpsecESP, cls).tearDownClass()
Neale Ranns53f526b2019-02-25 14:32:02 +000036
Neale Ranns4f33c802019-04-10 12:39:10 +000037 def setUp(self):
38 super(ConfigIpsecESP, self).setUp()
Neale Ranns53f526b2019-02-25 14:32:02 +000039
Neale Ranns4f33c802019-04-10 12:39:10 +000040 def tearDown(self):
41 super(ConfigIpsecESP, self).tearDown()
42
43 def config_network(self, params):
44 self.net_objs = []
45 self.tun_if = self.pg0
46 self.tra_if = self.pg2
47 self.logger.info(self.vapi.ppcli("show int addr"))
48
49 self.tra_spd = VppIpsecSpd(self, self.tra_spd_id)
50 self.tra_spd.add_vpp_config()
51 self.net_objs.append(self.tra_spd)
52 self.tun_spd = VppIpsecSpd(self, self.tun_spd_id)
53 self.tun_spd.add_vpp_config()
54 self.net_objs.append(self.tun_spd)
55
56 b = VppIpsecSpdItfBinding(self, self.tun_spd,
57 self.tun_if)
58 b.add_vpp_config()
59 self.net_objs.append(b)
60
61 b = VppIpsecSpdItfBinding(self, self.tra_spd,
62 self.tra_if)
63 b.add_vpp_config()
64 self.net_objs.append(b)
65
66 for p in params:
67 self.config_esp_tra(p)
68 config_tra_params(p, self.encryption_type)
69 for p in params:
70 self.config_esp_tun(p)
71
72 for p in params:
73 d = DpoProto.DPO_PROTO_IP6 if p.is_ipv6 else DpoProto.DPO_PROTO_IP4
74 r = VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
75 [VppRoutePath(self.tun_if.remote_addr[p.addr_type],
76 0xffffffff,
77 proto=d)],
78 is_ip6=p.is_ipv6)
79 r.add_vpp_config()
80 self.net_objs.append(r)
81
82 self.logger.info(self.vapi.ppcli("show ipsec all"))
83
84 def unconfig_network(self):
85 for o in reversed(self.net_objs):
86 o.remove_vpp_config()
87 self.net_objs = []
88
89 def config_esp_tun(self, params):
90 addr_type = params.addr_type
91 scapy_tun_sa_id = params.scapy_tun_sa_id
92 scapy_tun_spi = params.scapy_tun_spi
93 vpp_tun_sa_id = params.vpp_tun_sa_id
94 vpp_tun_spi = params.vpp_tun_spi
95 auth_algo_vpp_id = params.auth_algo_vpp_id
96 auth_key = params.auth_key
97 crypt_algo_vpp_id = params.crypt_algo_vpp_id
98 crypt_key = params.crypt_key
99 remote_tun_if_host = params.remote_tun_if_host
100 addr_any = params.addr_any
101 addr_bcast = params.addr_bcast
102 e = VppEnum.vl_api_ipsec_spd_action_t
Neale Ranns49e7ef62019-04-10 17:24:29 +0000103 flags = params.flags
Neale Ranns80f6fd52019-04-16 02:41:34 +0000104 salt = params.salt
Neale Ranns4f33c802019-04-10 12:39:10 +0000105 objs = []
106
107 params.tun_sa_in = VppIpsecSA(self, scapy_tun_sa_id, scapy_tun_spi,
108 auth_algo_vpp_id, auth_key,
109 crypt_algo_vpp_id, crypt_key,
110 self.vpp_esp_protocol,
111 self.tun_if.local_addr[addr_type],
Neale Ranns49e7ef62019-04-10 17:24:29 +0000112 self.tun_if.remote_addr[addr_type],
Neale Ranns80f6fd52019-04-16 02:41:34 +0000113 flags=flags,
114 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000115 params.tun_sa_out = VppIpsecSA(self, vpp_tun_sa_id, vpp_tun_spi,
116 auth_algo_vpp_id, auth_key,
117 crypt_algo_vpp_id, crypt_key,
118 self.vpp_esp_protocol,
119 self.tun_if.remote_addr[addr_type],
Neale Ranns49e7ef62019-04-10 17:24:29 +0000120 self.tun_if.local_addr[addr_type],
Neale Ranns80f6fd52019-04-16 02:41:34 +0000121 flags=flags,
122 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000123 objs.append(params.tun_sa_in)
124 objs.append(params.tun_sa_out)
125
126 params.spd_policy_in_any = VppIpsecSpdEntry(self, self.tun_spd,
127 scapy_tun_sa_id,
128 addr_any, addr_bcast,
129 addr_any, addr_bcast,
130 socket.IPPROTO_ESP)
131 params.spd_policy_out_any = VppIpsecSpdEntry(self, self.tun_spd,
132 scapy_tun_sa_id,
133 addr_any, addr_bcast,
134 addr_any, addr_bcast,
135 socket.IPPROTO_ESP,
136 is_outbound=0)
137 objs.append(params.spd_policy_out_any)
138 objs.append(params.spd_policy_in_any)
139
140 objs.append(VppIpsecSpdEntry(self, self.tun_spd, vpp_tun_sa_id,
141 remote_tun_if_host, remote_tun_if_host,
142 self.pg1.remote_addr[addr_type],
143 self.pg1.remote_addr[addr_type],
144 0,
145 priority=10,
146 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
147 is_outbound=0))
148 objs.append(VppIpsecSpdEntry(self, self.tun_spd, scapy_tun_sa_id,
149 self.pg1.remote_addr[addr_type],
150 self.pg1.remote_addr[addr_type],
151 remote_tun_if_host, remote_tun_if_host,
152 0,
153 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
154 priority=10))
155 objs.append(VppIpsecSpdEntry(self, self.tun_spd, vpp_tun_sa_id,
156 remote_tun_if_host, remote_tun_if_host,
157 self.pg0.local_addr[addr_type],
158 self.pg0.local_addr[addr_type],
159 0,
160 priority=20,
161 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
162 is_outbound=0))
163 objs.append(VppIpsecSpdEntry(self, self.tun_spd, scapy_tun_sa_id,
164 self.pg0.local_addr[addr_type],
165 self.pg0.local_addr[addr_type],
166 remote_tun_if_host, remote_tun_if_host,
167 0,
168 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
169 priority=20))
170 for o in objs:
171 o.add_vpp_config()
172 self.net_objs = self.net_objs + objs
173
174 def config_esp_tra(self, params):
175 addr_type = params.addr_type
176 scapy_tra_sa_id = params.scapy_tra_sa_id
177 scapy_tra_spi = params.scapy_tra_spi
178 vpp_tra_sa_id = params.vpp_tra_sa_id
179 vpp_tra_spi = params.vpp_tra_spi
180 auth_algo_vpp_id = params.auth_algo_vpp_id
181 auth_key = params.auth_key
182 crypt_algo_vpp_id = params.crypt_algo_vpp_id
183 crypt_key = params.crypt_key
184 addr_any = params.addr_any
185 addr_bcast = params.addr_bcast
186 flags = (VppEnum.vl_api_ipsec_sad_flags_t.
187 IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY)
188 e = VppEnum.vl_api_ipsec_spd_action_t
189 flags = params.flags | flags
Neale Ranns80f6fd52019-04-16 02:41:34 +0000190 salt = params.salt
Neale Ranns4f33c802019-04-10 12:39:10 +0000191 objs = []
192
193 params.tra_sa_in = VppIpsecSA(self, scapy_tra_sa_id, scapy_tra_spi,
194 auth_algo_vpp_id, auth_key,
195 crypt_algo_vpp_id, crypt_key,
196 self.vpp_esp_protocol,
Neale Ranns80f6fd52019-04-16 02:41:34 +0000197 flags=flags,
198 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000199 params.tra_sa_out = VppIpsecSA(self, vpp_tra_sa_id, vpp_tra_spi,
200 auth_algo_vpp_id, auth_key,
201 crypt_algo_vpp_id, crypt_key,
202 self.vpp_esp_protocol,
Neale Ranns80f6fd52019-04-16 02:41:34 +0000203 flags=flags,
204 salt=salt)
Neale Ranns4f33c802019-04-10 12:39:10 +0000205 objs.append(params.tra_sa_in)
206 objs.append(params.tra_sa_out)
207
208 objs.append(VppIpsecSpdEntry(self, self.tra_spd, vpp_tra_sa_id,
209 addr_any, addr_bcast,
210 addr_any, addr_bcast,
211 socket.IPPROTO_ESP))
212 objs.append(VppIpsecSpdEntry(self, self.tra_spd, vpp_tra_sa_id,
213 addr_any, addr_bcast,
214 addr_any, addr_bcast,
215 socket.IPPROTO_ESP,
216 is_outbound=0))
217 objs.append(VppIpsecSpdEntry(self, self.tra_spd, vpp_tra_sa_id,
218 self.tra_if.local_addr[addr_type],
219 self.tra_if.local_addr[addr_type],
220 self.tra_if.remote_addr[addr_type],
221 self.tra_if.remote_addr[addr_type],
222 0, priority=10,
223 policy=e.IPSEC_API_SPD_ACTION_PROTECT,
224 is_outbound=0))
225 objs.append(VppIpsecSpdEntry(self, self.tra_spd, scapy_tra_sa_id,
226 self.tra_if.local_addr[addr_type],
227 self.tra_if.local_addr[addr_type],
228 self.tra_if.remote_addr[addr_type],
229 self.tra_if.remote_addr[addr_type],
230 0, policy=e.IPSEC_API_SPD_ACTION_PROTECT,
231 priority=10))
232 for o in objs:
233 o.add_vpp_config()
234 self.net_objs = self.net_objs + objs
Neale Ranns53f526b2019-02-25 14:32:02 +0000235
236
Neale Ranns4f33c802019-04-10 12:39:10 +0000237class TemplateIpsecEsp(ConfigIpsecESP):
“mystarrocks”23f0c452017-12-11 07:11:51 -0800238 """
239 Basic test for ipsec esp sanity - tunnel and transport modes.
240
241 Below 4 cases are covered as part of this test
242 1) ipsec esp v4 transport basic test - IPv4 Transport mode
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700243 scenario using HMAC-SHA1-96 integrity algo
“mystarrocks”23f0c452017-12-11 07:11:51 -0800244 2) ipsec esp v4 transport burst test
245 Above test for 257 pkts
246 3) ipsec esp 4o4 tunnel basic test - IPv4 Tunnel mode
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700247 scenario using HMAC-SHA1-96 integrity algo
“mystarrocks”23f0c452017-12-11 07:11:51 -0800248 4) ipsec esp 4o4 tunnel burst test
249 Above test for 257 pkts
250
251 TRANSPORT MODE:
252
253 --- encrypt ---
254 |pg2| <-------> |VPP|
255 --- decrypt ---
256
257 TUNNEL MODE:
258
259 --- encrypt --- plain ---
Klement Sekera4b089f22018-04-17 18:04:57 +0200260 |pg0| <------- |VPP| <------ |pg1|
“mystarrocks”23f0c452017-12-11 07:11:51 -0800261 --- --- ---
262
263 --- decrypt --- plain ---
Klement Sekera4b089f22018-04-17 18:04:57 +0200264 |pg0| -------> |VPP| ------> |pg1|
“mystarrocks”23f0c452017-12-11 07:11:51 -0800265 --- --- ---
“mystarrocks”23f0c452017-12-11 07:11:51 -0800266 """
267
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700268 @classmethod
269 def setUpClass(cls):
270 super(TemplateIpsecEsp, cls).setUpClass()
271
272 @classmethod
273 def tearDownClass(cls):
274 super(TemplateIpsecEsp, cls).tearDownClass()
275
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800276 def setUp(self):
277 super(TemplateIpsecEsp, self).setUp()
Neale Ranns4f33c802019-04-10 12:39:10 +0000278 self.config_network(self.params.values())
Klement Sekera611864f2018-09-26 11:19:00 +0200279
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800280 def tearDown(self):
Neale Ranns4f33c802019-04-10 12:39:10 +0000281 self.unconfig_network()
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800282 super(TemplateIpsecEsp, self).tearDown()
Neale Ranns8e4a89b2019-01-23 08:16:17 -0800283
Klement Sekera611864f2018-09-26 11:19:00 +0200284
Neale Ranns53f526b2019-02-25 14:32:02 +0000285class TestIpsecEsp1(TemplateIpsecEsp, IpsecTra46Tests, IpsecTun46Tests):
Klement Sekera31da2e32018-06-24 22:49:55 +0200286 """ Ipsec ESP - TUN & TRA tests """
Neale Ranns4f33c802019-04-10 12:39:10 +0000287 pass
“mystarrocks”23f0c452017-12-11 07:11:51 -0800288
“mystarrocks”23f0c452017-12-11 07:11:51 -0800289
Klement Sekera31da2e32018-06-24 22:49:55 +0200290class TestIpsecEsp2(TemplateIpsecEsp, IpsecTcpTests):
291 """ Ipsec ESP - TCP tests """
292 pass
“mystarrocks”23f0c452017-12-11 07:11:51 -0800293
294
Neale Ranns4f33c802019-04-10 12:39:10 +0000295class TemplateIpsecEspUdp(ConfigIpsecESP):
Neale Ranns53f526b2019-02-25 14:32:02 +0000296 """
297 UDP encapped ESP
298 """
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700299
300 @classmethod
301 def setUpClass(cls):
302 super(TemplateIpsecEspUdp, cls).setUpClass()
303
304 @classmethod
305 def tearDownClass(cls):
306 super(TemplateIpsecEspUdp, cls).tearDownClass()
307
Neale Ranns53f526b2019-02-25 14:32:02 +0000308 def setUp(self):
309 super(TemplateIpsecEspUdp, self).setUp()
Neale Ranns4f33c802019-04-10 12:39:10 +0000310 self.net_objs = []
Neale Ranns53f526b2019-02-25 14:32:02 +0000311 self.tun_if = self.pg0
312 self.tra_if = self.pg2
313 self.logger.info(self.vapi.ppcli("show int addr"))
314
315 p = self.ipv4_params
316 p.flags = (VppEnum.vl_api_ipsec_sad_flags_t.
317 IPSEC_API_SAD_FLAG_UDP_ENCAP)
318 p.nat_header = UDP(sport=5454, dport=4500)
319
320 self.tra_spd = VppIpsecSpd(self, self.tra_spd_id)
321 self.tra_spd.add_vpp_config()
322 VppIpsecSpdItfBinding(self, self.tra_spd,
323 self.tra_if).add_vpp_config()
324
Neale Ranns4f33c802019-04-10 12:39:10 +0000325 self.config_esp_tra(p)
Neale Ranns2ac885c2019-03-20 18:24:43 +0000326 config_tra_params(p, self.encryption_type)
Neale Ranns53f526b2019-02-25 14:32:02 +0000327
328 self.tun_spd = VppIpsecSpd(self, self.tun_spd_id)
329 self.tun_spd.add_vpp_config()
330 VppIpsecSpdItfBinding(self, self.tun_spd,
331 self.tun_if).add_vpp_config()
332
Neale Ranns4f33c802019-04-10 12:39:10 +0000333 self.config_esp_tun(p)
Neale Ranns92e93842019-04-08 07:36:50 +0000334 self.logger.info(self.vapi.ppcli("show ipsec all"))
Neale Ranns53f526b2019-02-25 14:32:02 +0000335
336 d = DpoProto.DPO_PROTO_IP4
337 VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
338 [VppRoutePath(self.tun_if.remote_addr[p.addr_type],
339 0xffffffff,
340 proto=d)]).add_vpp_config()
341
342 def tearDown(self):
343 super(TemplateIpsecEspUdp, self).tearDown()
Paul Vinciguerra90cf21b2019-03-13 09:23:05 -0700344
345 def show_commands_at_teardown(self):
346 self.logger.info(self.vapi.cli("show hardware"))
Neale Ranns53f526b2019-02-25 14:32:02 +0000347
348
Neale Ranns49e7ef62019-04-10 17:24:29 +0000349class TestIpsecEspUdp(TemplateIpsecEspUdp, IpsecTra4Tests):
Neale Ranns53f526b2019-02-25 14:32:02 +0000350 """ Ipsec NAT-T ESP UDP tests """
Neale Ranns53f526b2019-02-25 14:32:02 +0000351 pass
352
353
Neale Ranns4f33c802019-04-10 12:39:10 +0000354class TestIpsecEspAll(ConfigIpsecESP,
355 IpsecTra4, IpsecTra6,
356 IpsecTun4, IpsecTun6):
357 """ Ipsec ESP all Algos """
358
359 def setUp(self):
360 super(TestIpsecEspAll, self).setUp()
361
362 def tearDown(self):
363 super(TestIpsecEspAll, self).tearDown()
364
365 def test_crypto_algs(self):
Neale Ranns47feb112019-04-11 15:14:07 +0000366 """All engines AES-[CBC, GCM]-[128, 192, 256] w/ & w/o ESN"""
Neale Ranns4f33c802019-04-10 12:39:10 +0000367
368 # foreach VPP crypto engine
Neale Ranns92e93842019-04-08 07:36:50 +0000369 engines = ["ia32", "ipsecmb", "openssl"]
Neale Ranns4f33c802019-04-10 12:39:10 +0000370
371 # foreach crypto algorithm
Neale Ranns47feb112019-04-11 15:14:07 +0000372 algos = [{'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
373 IPSEC_API_CRYPTO_ALG_AES_GCM_128),
374 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
375 IPSEC_API_INTEG_ALG_NONE),
376 'scapy-crypto': "AES-GCM",
377 'scapy-integ': "NULL",
378 'key': "JPjyOWBeVEQiMe7h",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000379 'salt': 0},
380 {'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
381 IPSEC_API_CRYPTO_ALG_AES_GCM_192),
382 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
383 IPSEC_API_INTEG_ALG_NONE),
384 'scapy-crypto': "AES-GCM",
385 'scapy-integ': "NULL",
386 'key': "JPjyOWBeVEQiMe7h01234567",
387 'salt': 1010},
Neale Ranns47feb112019-04-11 15:14:07 +0000388 {'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
389 IPSEC_API_CRYPTO_ALG_AES_GCM_256),
390 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
391 IPSEC_API_INTEG_ALG_NONE),
392 'scapy-crypto': "AES-GCM",
393 'scapy-integ': "NULL",
394 'key': "JPjyOWBeVEQiMe7h0123456787654321",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000395 'salt': 2020},
Neale Ranns47feb112019-04-11 15:14:07 +0000396 {'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
397 IPSEC_API_CRYPTO_ALG_AES_CBC_128),
398 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
399 IPSEC_API_INTEG_ALG_SHA1_96),
400 'scapy-crypto': "AES-CBC",
401 'scapy-integ': "HMAC-SHA1-96",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000402 'salt': 0,
Neale Ranns4f33c802019-04-10 12:39:10 +0000403 'key': "JPjyOWBeVEQiMe7h"},
Neale Ranns47feb112019-04-11 15:14:07 +0000404 {'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
405 IPSEC_API_CRYPTO_ALG_AES_CBC_192),
406 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
407 IPSEC_API_INTEG_ALG_SHA1_96),
408 'scapy-crypto': "AES-CBC",
409 'scapy-integ': "HMAC-SHA1-96",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000410 'salt': 0,
Neale Ranns4f33c802019-04-10 12:39:10 +0000411 'key': "JPjyOWBeVEQiMe7hJPjyOWBe"},
Neale Ranns47feb112019-04-11 15:14:07 +0000412 {'vpp-crypto': (VppEnum.vl_api_ipsec_crypto_alg_t.
413 IPSEC_API_CRYPTO_ALG_AES_CBC_256),
414 'vpp-integ': (VppEnum.vl_api_ipsec_integ_alg_t.
415 IPSEC_API_INTEG_ALG_SHA1_96),
416 'scapy-crypto': "AES-CBC",
417 'scapy-integ': "HMAC-SHA1-96",
Neale Ranns80f6fd52019-04-16 02:41:34 +0000418 'salt': 0,
Neale Ranns4f33c802019-04-10 12:39:10 +0000419 'key': "JPjyOWBeVEQiMe7hJPjyOWBeVEQiMe7h"}]
420
Neale Ranns49e7ef62019-04-10 17:24:29 +0000421 # with and without ESN
422 flags = [0,
423 VppEnum.vl_api_ipsec_sad_flags_t.IPSEC_API_SAD_FLAG_USE_ESN]
Neale Ranns4f33c802019-04-10 12:39:10 +0000424
425 #
426 # loop through the VPP engines
427 #
428 for engine in engines:
Neale Ranns21ada3b2019-04-11 08:18:34 +0000429 self.vapi.cli("set crypto handler all %s" % engine)
Neale Ranns4f33c802019-04-10 12:39:10 +0000430 #
431 # loop through each of the algorithms
432 #
433 for algo in algos:
434 # with self.subTest(algo=algo['scapy']):
435 for flag in flags:
436 #
437 # setup up the config paramters
438 #
439 self.ipv4_params = IPsecIPv4Params()
440 self.ipv6_params = IPsecIPv6Params()
441
442 self.params = {self.ipv4_params.addr_type:
443 self.ipv4_params,
444 self.ipv6_params.addr_type:
445 self.ipv6_params}
446
447 for _, p in self.params.items():
Neale Ranns47feb112019-04-11 15:14:07 +0000448 p.auth_algo_vpp_id = algo['vpp-integ']
449 p.crypt_algo_vpp_id = algo['vpp-crypto']
450 p.crypt_algo = algo['scapy-crypto']
451 p.auth_algo = algo['scapy-integ']
Neale Ranns4f33c802019-04-10 12:39:10 +0000452 p.crypt_key = algo['key']
Neale Ranns80f6fd52019-04-16 02:41:34 +0000453 p.salt = algo['salt']
Neale Ranns4f33c802019-04-10 12:39:10 +0000454 p.flags = p.flags | flag
455
456 #
457 # configure the SPDs. SAs, etc
458 #
459 self.config_network(self.params.values())
460
461 #
462 # run some traffic.
463 # An exhautsive 4o6, 6o4 is not necessary
464 # for each algo
465 #
466 self.verify_tra_basic6(count=17)
467 self.verify_tra_basic4(count=17)
Neale Ranns47feb112019-04-11 15:14:07 +0000468 self.verify_tun_66(self.params[socket.AF_INET6], 17)
469 self.verify_tun_44(self.params[socket.AF_INET], 17)
Neale Ranns4f33c802019-04-10 12:39:10 +0000470
471 #
472 # remove the SPDs, SAs, etc
473 #
474 self.unconfig_network()
475
476
“mystarrocks”23f0c452017-12-11 07:11:51 -0800477if __name__ == '__main__':
478 unittest.main(testRunner=VppTestRunner)