1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2022 Marvell.
4 #ifndef _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
5 #define _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
7 #include "test_cryptodev_security_ipsec.h"
9 uint8_t dummy_ipv4_eth_hdr[] = {
11 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
12 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00,
14 uint8_t dummy_ipv6_eth_hdr[] = {
16 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
17 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd,
20 #define MAX_FRAG_LEN 1500
22 #define MAX_PKT_LEN (MAX_FRAG_LEN * MAX_FRAGS)
24 struct ip_reassembly_test_packet {
27 uint8_t data[MAX_PKT_LEN];
30 struct reassembly_vector {
31 /* input/output text in struct ipsec_test_data are not used */
32 struct ipsec_test_data *sa_data;
33 struct ip_reassembly_test_packet *full_pkt;
34 struct ip_reassembly_test_packet *frags[MAX_FRAGS];
39 /* The source file includes below test vectors */
80 struct ip_reassembly_test_packet pkt_ipv6_udp_p1 = {
85 0x60, 0x00, 0x00, 0x00, 0x05, 0xb4, 0x2C, 0x40,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
87 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
92 0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
96 struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f1 = {
101 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
102 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
103 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
104 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
105 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
106 0x11, 0x00, 0x00, 0x01, 0x5c, 0x92, 0xac, 0xf1,
109 0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
113 struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f2 = {
118 0x60, 0x00, 0x00, 0x00, 0x00, 0x84, 0x2c, 0x40,
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
120 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
122 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
123 0x11, 0x00, 0x05, 0x38, 0x5c, 0x92, 0xac, 0xf1,
127 struct ip_reassembly_test_packet pkt_ipv6_udp_p2 = {
132 0x60, 0x00, 0x00, 0x00, 0x11, 0x5a, 0x2c, 0x40,
133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
134 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
136 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
139 0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
143 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f1 = {
148 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
153 0x11, 0x00, 0x00, 0x01, 0x64, 0x6c, 0x68, 0x9f,
156 0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
160 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f2 = {
165 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
166 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
168 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
170 0x11, 0x00, 0x05, 0x39, 0x64, 0x6c, 0x68, 0x9f,
174 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f3 = {
179 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
184 0x11, 0x00, 0x0a, 0x71, 0x64, 0x6c, 0x68, 0x9f,
188 struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f4 = {
193 0x60, 0x00, 0x00, 0x00, 0x01, 0xba, 0x2c, 0x40,
194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
195 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
198 0x11, 0x00, 0x0f, 0xa8, 0x64, 0x6c, 0x68, 0x9f,
202 struct ip_reassembly_test_packet pkt_ipv6_udp_p3 = {
207 0x60, 0x00, 0x00, 0x00, 0x16, 0x6e, 0x2c, 0x40,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
214 0x08, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
218 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f1 = {
223 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
224 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
227 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
228 0x11, 0x00, 0x00, 0x01, 0x65, 0xcf, 0x5a, 0xae,
231 0x80, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
235 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f2 = {
240 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
242 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
244 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
245 0x11, 0x00, 0x05, 0x39, 0x65, 0xcf, 0x5a, 0xae,
249 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f3 = {
254 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
255 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
256 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
259 0x11, 0x00, 0x0a, 0x71, 0x65, 0xcf, 0x5a, 0xae,
263 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f4 = {
268 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
273 0x11, 0x00, 0x0f, 0xa9, 0x65, 0xcf, 0x5a, 0xae,
277 struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f5 = {
282 0x60, 0x00, 0x00, 0x00, 0x01, 0x96, 0x2c, 0x40,
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
286 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
287 0x11, 0x00, 0x14, 0xe0, 0x65, 0xcf, 0x5a, 0xae,
291 struct ip_reassembly_test_packet pkt_ipv4_udp_p1 = {
296 0x45, 0x00, 0x05, 0xdc, 0x00, 0x01, 0x00, 0x00,
297 0x40, 0x11, 0x66, 0x0d, 0x0d, 0x00, 0x00, 0x02,
298 0x02, 0x00, 0x00, 0x02,
301 0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
305 struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f1 = {
310 0x45, 0x00, 0x05, 0x8c, 0x00, 0x01, 0x20, 0x00,
311 0x40, 0x11, 0x46, 0x5d, 0x0d, 0x00, 0x00, 0x02,
312 0x02, 0x00, 0x00, 0x02,
315 0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
319 struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f2 = {
324 0x45, 0x00, 0x00, 0x64, 0x00, 0x01, 0x00, 0xaf,
325 0x40, 0x11, 0x6a, 0xd6, 0x0d, 0x00, 0x00, 0x02,
326 0x02, 0x00, 0x00, 0x02,
330 struct ip_reassembly_test_packet pkt_ipv4_udp_p2 = {
335 0x45, 0x00, 0x11, 0x82, 0x00, 0x02, 0x00, 0x00,
336 0x40, 0x11, 0x5a, 0x66, 0x0d, 0x00, 0x00, 0x02,
337 0x02, 0x00, 0x00, 0x02,
340 0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
344 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f1 = {
349 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0x00,
350 0x40, 0x11, 0x46, 0x5c, 0x0d, 0x00, 0x00, 0x02,
351 0x02, 0x00, 0x00, 0x02,
354 0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
358 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f2 = {
363 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0xaf,
364 0x40, 0x11, 0x45, 0xad, 0x0d, 0x00, 0x00, 0x02,
365 0x02, 0x00, 0x00, 0x02,
369 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f3 = {
374 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x21, 0x5e,
375 0x40, 0x11, 0x44, 0xfe, 0x0d, 0x00, 0x00, 0x02,
376 0x02, 0x00, 0x00, 0x02,
380 struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f4 = {
385 0x45, 0x00, 0x01, 0x1a, 0x00, 0x02, 0x02, 0x0d,
386 0x40, 0x11, 0x68, 0xc1, 0x0d, 0x00, 0x00, 0x02,
387 0x02, 0x00, 0x00, 0x02,
391 struct ip_reassembly_test_packet pkt_ipv4_udp_p3 = {
396 0x45, 0x00, 0x16, 0x96, 0x00, 0x03, 0x00, 0x00,
397 0x40, 0x11, 0x55, 0x51, 0x0d, 0x00, 0x00, 0x02,
398 0x02, 0x00, 0x00, 0x02,
401 0x08, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
405 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f1 = {
410 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0x00,
411 0x40, 0x11, 0x46, 0x5b, 0x0d, 0x00, 0x00, 0x02,
412 0x02, 0x00, 0x00, 0x02,
415 0x80, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
419 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f2 = {
424 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0xaf,
425 0x40, 0x11, 0x45, 0xac, 0x0d, 0x00, 0x00, 0x02,
426 0x02, 0x00, 0x00, 0x02,
430 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f3 = {
435 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x21, 0x5e,
436 0x40, 0x11, 0x44, 0xfd, 0x0d, 0x00, 0x00, 0x02,
437 0x02, 0x00, 0x00, 0x02,
441 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f4 = {
446 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x22, 0x0d,
447 0x40, 0x11, 0x44, 0x4e, 0x0d, 0x00, 0x00, 0x02,
448 0x02, 0x00, 0x00, 0x02,
452 struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f5 = {
457 0x45, 0x00, 0x00, 0xb6, 0x00, 0x03, 0x02, 0xbc,
458 0x40, 0x11, 0x68, 0x75, 0x0d, 0x00, 0x00, 0x02,
459 0x02, 0x00, 0x00, 0x02,
464 test_vector_payload_populate(struct ip_reassembly_test_packet *pkt,
467 uint32_t i = pkt->l4_offset;
470 * For non-fragmented packets and first frag, skip 8 bytes from
471 * l4_offset for UDP header.
476 for (; i < pkt->len; i++)
480 struct ipsec_test_data conf_aes_128_gcm = {
483 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
484 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
490 0xca, 0xfe, 0xba, 0xbe
497 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
505 .options.udp_encap = 0,
506 .options.copy_dscp = 0,
507 .options.copy_flabel = 0,
508 .options.copy_df = 0,
509 .options.dec_ttl = 0,
512 .options.tunnel_hdr_verify = 0,
513 .options.ip_csum_enable = 0,
514 .options.l4_csum_enable = 0,
515 .options.ip_reassembly_en = 1,
516 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
517 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
518 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
519 .tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
528 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
530 .op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
531 .algo = RTE_CRYPTO_AEAD_AES_GCM,
542 struct ipsec_test_data conf_aes_128_gcm_v6_tunnel = {
545 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
546 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
552 0xca, 0xfe, 0xba, 0xbe
559 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
567 .options.udp_encap = 0,
568 .options.copy_dscp = 0,
569 .options.copy_flabel = 0,
570 .options.copy_df = 0,
571 .options.dec_ttl = 0,
574 .options.tunnel_hdr_verify = 0,
575 .options.ip_csum_enable = 0,
576 .options.l4_csum_enable = 0,
577 .options.ip_reassembly_en = 1,
578 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
579 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
580 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
581 .tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
590 .type = RTE_CRYPTO_SYM_XFORM_AEAD,
592 .op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
593 .algo = RTE_CRYPTO_AEAD_AES_GCM,
604 const struct reassembly_vector ipv4_2frag_vector = {
605 .sa_data = &conf_aes_128_gcm,
606 .full_pkt = &pkt_ipv4_udp_p1,
607 .frags[0] = &pkt_ipv4_udp_p1_f1,
608 .frags[1] = &pkt_ipv4_udp_p1_f2,
613 const struct reassembly_vector ipv6_2frag_vector = {
614 .sa_data = &conf_aes_128_gcm_v6_tunnel,
615 .full_pkt = &pkt_ipv6_udp_p1,
616 .frags[0] = &pkt_ipv6_udp_p1_f1,
617 .frags[1] = &pkt_ipv6_udp_p1_f2,
622 const struct reassembly_vector ipv4_4frag_vector = {
623 .sa_data = &conf_aes_128_gcm,
624 .full_pkt = &pkt_ipv4_udp_p2,
625 .frags[0] = &pkt_ipv4_udp_p2_f1,
626 .frags[1] = &pkt_ipv4_udp_p2_f2,
627 .frags[2] = &pkt_ipv4_udp_p2_f3,
628 .frags[3] = &pkt_ipv4_udp_p2_f4,
633 const struct reassembly_vector ipv6_4frag_vector = {
634 .sa_data = &conf_aes_128_gcm_v6_tunnel,
635 .full_pkt = &pkt_ipv6_udp_p2,
636 .frags[0] = &pkt_ipv6_udp_p2_f1,
637 .frags[1] = &pkt_ipv6_udp_p2_f2,
638 .frags[2] = &pkt_ipv6_udp_p2_f3,
639 .frags[3] = &pkt_ipv6_udp_p2_f4,
643 const struct reassembly_vector ipv4_5frag_vector = {
644 .sa_data = &conf_aes_128_gcm,
645 .full_pkt = &pkt_ipv4_udp_p3,
646 .frags[0] = &pkt_ipv4_udp_p3_f1,
647 .frags[1] = &pkt_ipv4_udp_p3_f2,
648 .frags[2] = &pkt_ipv4_udp_p3_f3,
649 .frags[3] = &pkt_ipv4_udp_p3_f4,
650 .frags[4] = &pkt_ipv4_udp_p3_f5,
654 const struct reassembly_vector ipv6_5frag_vector = {
655 .sa_data = &conf_aes_128_gcm_v6_tunnel,
656 .full_pkt = &pkt_ipv6_udp_p3,
657 .frags[0] = &pkt_ipv6_udp_p3_f1,
658 .frags[1] = &pkt_ipv6_udp_p3_f2,
659 .frags[2] = &pkt_ipv6_udp_p3_f3,
660 .frags[3] = &pkt_ipv6_udp_p3_f4,
661 .frags[4] = &pkt_ipv6_udp_p3_f5,
665 /* Negative test cases. */
666 const struct reassembly_vector ipv4_incomplete_vector = {
667 .sa_data = &conf_aes_128_gcm,
668 .full_pkt = &pkt_ipv4_udp_p2,
669 .frags[0] = &pkt_ipv4_udp_p2_f1,
670 .frags[1] = &pkt_ipv4_udp_p2_f2,
674 const struct reassembly_vector ipv4_overlap_vector = {
675 .sa_data = &conf_aes_128_gcm,
676 .full_pkt = &pkt_ipv4_udp_p1,
677 .frags[0] = &pkt_ipv4_udp_p1_f1,
678 .frags[1] = &pkt_ipv4_udp_p1_f1, /* Overlap */
679 .frags[2] = &pkt_ipv4_udp_p1_f2,
683 const struct reassembly_vector ipv4_out_of_order_vector = {
684 .sa_data = &conf_aes_128_gcm,
685 .full_pkt = &pkt_ipv4_udp_p2,
686 .frags[0] = &pkt_ipv4_udp_p2_f1,
687 .frags[1] = &pkt_ipv4_udp_p2_f3,
688 .frags[2] = &pkt_ipv4_udp_p2_f4,
689 .frags[3] = &pkt_ipv4_udp_p2_f2, /* out of order */
693 const struct reassembly_vector ipv4_4frag_burst_vector = {
694 .sa_data = &conf_aes_128_gcm,
695 .full_pkt = &pkt_ipv4_udp_p2,
696 .frags[0] = &pkt_ipv4_udp_p2_f1,
697 .frags[1] = &pkt_ipv4_udp_p2_f2,
698 .frags[2] = &pkt_ipv4_udp_p2_f3,
699 .frags[3] = &pkt_ipv4_udp_p2_f4,