Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2015-2020 Intel Corporation
3 : : * Copyright 2020 NXP
4 : : */
5 : :
6 : : #include <stdbool.h>
7 : : #include <time.h>
8 : :
9 : : #include <rte_common.h>
10 : : #include <rte_hexdump.h>
11 : : #include <rte_mbuf.h>
12 : : #include <rte_malloc.h>
13 : : #include <rte_memcpy.h>
14 : : #include <rte_pause.h>
15 : : #include <rte_bus_vdev.h>
16 : : #include <rte_ether.h>
17 : : #include <rte_errno.h>
18 : :
19 : : #include <rte_crypto.h>
20 : : #include <rte_cryptodev.h>
21 : : #include <rte_ethdev.h>
22 : : #include <rte_ip.h>
23 : : #include <rte_string_fns.h>
24 : : #include <rte_tcp.h>
25 : : #include <rte_tls.h>
26 : : #include <rte_udp.h>
27 : :
28 : : #ifdef RTE_CRYPTO_SCHEDULER
29 : : #include <rte_cryptodev_scheduler.h>
30 : : #include <rte_cryptodev_scheduler_operations.h>
31 : : #endif
32 : :
33 : : #include <rte_lcore.h>
34 : :
35 : : #include "test.h"
36 : : #include "test_cryptodev.h"
37 : :
38 : : #include "test_cryptodev_blockcipher.h"
39 : : #include "test_cryptodev_aes_test_vectors.h"
40 : : #include "test_cryptodev_des_test_vectors.h"
41 : : #include "test_cryptodev_hash_test_vectors.h"
42 : : #include "test_cryptodev_kasumi_test_vectors.h"
43 : : #include "test_cryptodev_kasumi_hash_test_vectors.h"
44 : : #include "test_cryptodev_snow3g_test_vectors.h"
45 : : #include "test_cryptodev_snow3g_hash_test_vectors.h"
46 : : #include "test_cryptodev_zuc_test_vectors.h"
47 : : #include "test_cryptodev_aead_test_vectors.h"
48 : : #include "test_cryptodev_hmac_test_vectors.h"
49 : : #include "test_cryptodev_mixed_test_vectors.h"
50 : : #include "test_cryptodev_sm4_test_vectors.h"
51 : : #ifdef RTE_LIB_SECURITY
52 : : #include "test_cryptodev_security_ipsec.h"
53 : : #include "test_cryptodev_security_ipsec_test_vectors.h"
54 : : #include "test_cryptodev_security_pdcp_test_vectors.h"
55 : : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
56 : : #include "test_cryptodev_security_pdcp_test_func.h"
57 : : #include "test_cryptodev_security_docsis_test_vectors.h"
58 : : #include "test_cryptodev_security_tls_record.h"
59 : : #include "test_security_proto.h"
60 : :
61 : : #define SDAP_DISABLED 0
62 : : #define SDAP_ENABLED 1
63 : : #endif
64 : :
65 : : #define VDEV_ARGS_SIZE 100
66 : : #define MAX_NB_SESSIONS 4
67 : :
68 : : #define MAX_RAW_DEQUEUE_COUNT 65535
69 : :
70 : : #define IN_PLACE 0
71 : : #define OUT_OF_PLACE 1
72 : :
73 : : #define QP_DRAIN_TIMEOUT 100
74 : : #define HW_ERR_RECOVER_TIMEOUT 500
75 : :
76 : : static int gbl_driver_id;
77 : :
78 : : static enum rte_security_session_action_type gbl_action_type =
79 : : RTE_SECURITY_ACTION_TYPE_NONE;
80 : :
81 : : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
82 : :
83 : : struct crypto_unittest_params {
84 : : struct rte_crypto_sym_xform cipher_xform;
85 : : struct rte_crypto_sym_xform auth_xform;
86 : : struct rte_crypto_sym_xform aead_xform;
87 : : #ifdef RTE_LIB_SECURITY
88 : : struct rte_security_docsis_xform docsis_xform;
89 : : #endif
90 : :
91 : : union {
92 : : void *sess;
93 : : #ifdef RTE_LIB_SECURITY
94 : : void *sec_session;
95 : : #endif
96 : : };
97 : : #ifdef RTE_LIB_SECURITY
98 : : enum rte_security_session_action_type type;
99 : : #endif
100 : : struct rte_crypto_op *op;
101 : :
102 : : struct rte_mbuf *obuf, *ibuf;
103 : :
104 : : uint8_t *digest;
105 : : };
106 : :
107 : : #define ALIGN_POW2_ROUNDUP(num, align) \
108 : : (((num) + (align) - 1) & ~((align) - 1))
109 : :
110 : : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
111 : : for (j = 0; j < num_child_ts; index++, j++) \
112 : : parent_ts.unit_test_suites[index] = child_ts[j]
113 : :
114 : : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
115 : : for (j = 0; j < num_blk_types; index++, j++) \
116 : : parent_ts.unit_test_suites[index] = \
117 : : build_blockcipher_test_suite(blk_types[j])
118 : :
119 : : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
120 : : for (j = index; j < index + num_blk_types; j++) \
121 : : free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
122 : :
123 : : /*
124 : : * Forward declarations.
125 : : */
126 : : static int
127 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
128 : : struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
129 : : uint8_t *hmac_key);
130 : :
131 : : static int
132 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
133 : : struct crypto_unittest_params *ut_params,
134 : : struct crypto_testsuite_params *ts_param,
135 : : const uint8_t *cipher,
136 : : const uint8_t *digest,
137 : : const uint8_t *iv);
138 : :
139 : : static int
140 : : security_proto_supported(enum rte_security_session_action_type action,
141 : : enum rte_security_session_protocol proto);
142 : :
143 : : static int
144 : : dev_configure_and_start(uint64_t ff_disable);
145 : :
146 : : static int
147 : : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
148 : : const enum rte_crypto_cipher_algorithm cipher_algo,
149 : : const uint16_t key_size, const uint16_t iv_size);
150 : :
151 : : static int
152 : : check_auth_capability(const struct crypto_testsuite_params *ts_params,
153 : : const enum rte_crypto_auth_algorithm auth_algo,
154 : : const uint16_t key_size, const uint16_t iv_size,
155 : : const uint16_t tag_size);
156 : :
157 : : static struct rte_mbuf *
158 : 7 : setup_test_string(struct rte_mempool *mpool,
159 : : const char *string, size_t len, uint8_t blocksize)
160 : : {
161 : 7 : struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
162 [ - + ]: 7 : size_t t_len = len - (blocksize ? (len % blocksize) : 0);
163 : :
164 [ + - ]: 7 : if (m) {
165 : : char *dst;
166 : :
167 : 7 : memset(m->buf_addr, 0, m->buf_len);
168 : 7 : dst = rte_pktmbuf_append(m, t_len);
169 [ - + ]: 7 : if (!dst) {
170 : 0 : rte_pktmbuf_free(m);
171 : 0 : return NULL;
172 : : }
173 [ + - ]: 7 : if (string != NULL)
174 : : rte_memcpy(dst, string, t_len);
175 : : else
176 : : memset(dst, 0, t_len);
177 : : }
178 : :
179 : : return m;
180 : : }
181 : :
182 : : /* Get number of bytes in X bits (rounding up) */
183 : : static uint32_t
184 : : ceil_byte_length(uint32_t num_bits)
185 : : {
186 : 4 : if (num_bits % 8)
187 : 0 : return ((num_bits >> 3) + 1);
188 : : else
189 : 4 : return (num_bits >> 3);
190 : : }
191 : :
192 : : static void
193 : 0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
194 : : uint8_t is_op_success)
195 : : {
196 : : struct rte_crypto_op *op = user_data;
197 [ # # ]: 0 : op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
198 : : RTE_CRYPTO_OP_STATUS_ERROR;
199 : 0 : }
200 : :
201 : : static struct crypto_testsuite_params testsuite_params = { NULL };
202 : : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
203 : : static struct crypto_unittest_params unittest_params;
204 : : static bool enq_cb_called;
205 : : static bool deq_cb_called;
206 : :
207 : : enum cryptodev_err_state {
208 : : CRYPTODEV_ERR_CLEARED,
209 : : CRYPTODEV_ERR_TRIGGERED,
210 : : CRYPTODEV_ERR_UNRECOVERABLE,
211 : : };
212 : :
213 : : static enum cryptodev_err_state crypto_err = CRYPTODEV_ERR_CLEARED;
214 : :
215 : : static void
216 : 0 : test_cryptodev_error_cb(uint8_t dev_id, enum rte_cryptodev_event_type event, void *cb_arg)
217 : : {
218 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
219 : : uint16_t qp_id;
220 : : int ticks = 0;
221 : : int ret = 0;
222 : :
223 : : RTE_SET_USED(event);
224 : : RTE_SET_USED(cb_arg);
225 : :
226 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
227 : 0 : ret = rte_cryptodev_queue_pair_event_error_query(dev_id, qp_id);
228 [ # # ]: 0 : if (ret)
229 : : break;
230 : : }
231 [ # # ]: 0 : if (ret == 1) {
232 : : /* Wait for the queue to be completely drained */
233 [ # # # # ]: 0 : while (rte_cryptodev_qp_depth_used(dev_id, qp_id) != 0) {
234 : : rte_delay_ms(10);
235 : 0 : ticks++;
236 [ # # ]: 0 : if (ticks > QP_DRAIN_TIMEOUT) {
237 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
238 : 0 : return;
239 : : }
240 : : }
241 [ # # ]: 0 : if (rte_cryptodev_queue_pair_reset(dev_id, qp_id, NULL, 0)) {
242 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
243 : 0 : return;
244 : : }
245 : : }
246 : :
247 : 0 : crypto_err = CRYPTODEV_ERR_CLEARED;
248 : : }
249 : :
250 : : static struct rte_mbuf *
251 : 0 : create_mbuf_from_heap(int pkt_len, uint8_t pattern)
252 : : {
253 : : struct rte_mbuf *m = NULL;
254 : : uint8_t *dst;
255 : :
256 : 0 : m = calloc(1, MBUF_SIZE);
257 [ # # ]: 0 : if (m == NULL) {
258 : : printf("Cannot create mbuf from heap");
259 : 0 : return NULL;
260 : : }
261 : :
262 : : /* Set the default values to the mbuf */
263 : 0 : m->nb_segs = 1;
264 : 0 : m->port = RTE_MBUF_PORT_INVALID;
265 : 0 : m->buf_len = MBUF_SIZE - sizeof(struct rte_mbuf) - RTE_PKTMBUF_HEADROOM;
266 : : rte_pktmbuf_reset_headroom(m);
267 : : __rte_mbuf_sanity_check(m, 1);
268 : :
269 : 0 : m->buf_addr = (char *)m + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
270 : :
271 : 0 : memset(m->buf_addr, pattern, m->buf_len);
272 : 0 : dst = (uint8_t *)rte_pktmbuf_append(m, pkt_len);
273 [ # # ]: 0 : if (dst == NULL) {
274 : : printf("Cannot append %d bytes to the mbuf\n", pkt_len);
275 : 0 : free(m);
276 : 0 : return NULL;
277 : : }
278 : :
279 : : return m;
280 : : }
281 : :
282 : : int
283 : 0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
284 : : struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
285 : : uint8_t len_in_bits, uint8_t cipher_iv_len)
286 : : {
287 : 0 : struct rte_crypto_sym_op *sop = op->sym;
288 : 0 : struct rte_crypto_op *ret_op = NULL;
289 : : struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
290 : : struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
291 : : union rte_crypto_sym_ofs ofs;
292 : : struct rte_crypto_sym_vec vec;
293 : : struct rte_crypto_sgl sgl, dest_sgl;
294 : : uint32_t max_len;
295 : : union rte_cryptodev_session_ctx sess;
296 : : uint64_t auth_end_iova;
297 : : uint32_t count = 0;
298 : : struct rte_crypto_raw_dp_ctx *ctx;
299 : : uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
300 : : auth_len = 0;
301 : : int32_t n;
302 : : uint32_t n_success;
303 : : int ctx_service_size;
304 : 0 : int32_t status = 0;
305 : : int enqueue_status, dequeue_status;
306 : : struct crypto_unittest_params *ut_params = &unittest_params;
307 : 0 : int is_sgl = sop->m_src->nb_segs > 1;
308 : : int ret = TEST_SUCCESS, is_oop = 0;
309 : :
310 : 0 : ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
311 [ # # ]: 0 : if (ctx_service_size < 0)
312 : : return TEST_SKIPPED;
313 : :
314 : 0 : ctx = malloc(ctx_service_size);
315 [ # # ]: 0 : if (ctx == NULL)
316 : : return TEST_FAILED;
317 : :
318 : : /* Both are enums, setting crypto_sess will suit any session type */
319 : 0 : sess.crypto_sess = op->sym->session;
320 : :
321 : 0 : ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
322 [ # # ]: 0 : if (ret == -ENOTSUP) {
323 : : ret = TEST_SKIPPED;
324 : 0 : goto exit;
325 [ # # ]: 0 : } else if (ret) {
326 : : ret = TEST_FAILED;
327 : 0 : goto exit;
328 : : }
329 : :
330 : 0 : cipher_iv.iova = 0;
331 : 0 : cipher_iv.va = NULL;
332 : 0 : aad_auth_iv.iova = 0;
333 : 0 : aad_auth_iv.va = NULL;
334 : 0 : digest.iova = 0;
335 : 0 : digest.va = NULL;
336 : 0 : sgl.vec = data_vec;
337 : 0 : vec.num = 1;
338 : 0 : vec.src_sgl = &sgl;
339 : 0 : vec.iv = &cipher_iv;
340 : 0 : vec.digest = &digest;
341 : 0 : vec.aad = &aad_auth_iv;
342 : 0 : vec.status = &status;
343 : :
344 : 0 : ofs.raw = 0;
345 : :
346 [ # # # # ]: 0 : if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
347 : : is_oop = 1;
348 : :
349 [ # # ]: 0 : if (is_cipher && is_auth) {
350 : 0 : cipher_offset = sop->cipher.data.offset;
351 : 0 : cipher_len = sop->cipher.data.length;
352 : 0 : auth_offset = sop->auth.data.offset;
353 : 0 : auth_len = sop->auth.data.length;
354 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len,
355 : : auth_offset + auth_len);
356 [ # # ]: 0 : if (len_in_bits) {
357 : 0 : max_len = max_len >> 3;
358 : 0 : cipher_offset = cipher_offset >> 3;
359 : 0 : auth_offset = auth_offset >> 3;
360 : 0 : cipher_len = cipher_len >> 3;
361 : 0 : auth_len = auth_len >> 3;
362 : : }
363 : 0 : ofs.ofs.cipher.head = cipher_offset;
364 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
365 : 0 : ofs.ofs.auth.head = auth_offset;
366 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
367 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
368 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
369 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
370 : : op, void *, IV_OFFSET + cipher_iv_len);
371 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
372 : : cipher_iv_len);
373 : 0 : digest.va = (void *)sop->auth.digest.data;
374 : 0 : digest.iova = sop->auth.digest.phys_addr;
375 : :
376 [ # # ]: 0 : if (is_sgl) {
377 : 0 : uint32_t remaining_off = auth_offset + auth_len;
378 : 0 : struct rte_mbuf *sgl_buf = sop->m_src;
379 [ # # ]: 0 : if (is_oop)
380 : : sgl_buf = sop->m_dst;
381 : :
382 : 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
383 [ # # # # ]: 0 : && sgl_buf->next != NULL) {
384 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
385 : : sgl_buf = sgl_buf->next;
386 : : }
387 : :
388 : 0 : auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
389 : : sgl_buf, remaining_off);
390 : : } else {
391 : 0 : auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
392 : 0 : auth_offset + auth_len;
393 : : }
394 : : /* Then check if digest-encrypted conditions are met */
395 [ # # # # ]: 0 : if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
396 [ # # ]: 0 : (digest.iova == auth_end_iova) && is_sgl)
397 : 0 : max_len = RTE_MAX(max_len,
398 : : auth_offset + auth_len +
399 : : ut_params->auth_xform.auth.digest_length);
400 : :
401 [ # # ]: 0 : } else if (is_cipher) {
402 : 0 : cipher_offset = sop->cipher.data.offset;
403 : 0 : cipher_len = sop->cipher.data.length;
404 : 0 : max_len = cipher_len + cipher_offset;
405 [ # # ]: 0 : if (len_in_bits) {
406 : 0 : max_len = max_len >> 3;
407 : 0 : cipher_offset = cipher_offset >> 3;
408 : 0 : cipher_len = cipher_len >> 3;
409 : : }
410 : 0 : ofs.ofs.cipher.head = cipher_offset;
411 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
412 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
413 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
414 : :
415 [ # # ]: 0 : } else if (is_auth) {
416 : 0 : auth_offset = sop->auth.data.offset;
417 : 0 : auth_len = sop->auth.data.length;
418 : 0 : max_len = auth_len + auth_offset;
419 [ # # ]: 0 : if (len_in_bits) {
420 : 0 : max_len = max_len >> 3;
421 : 0 : auth_offset = auth_offset >> 3;
422 : 0 : auth_len = auth_len >> 3;
423 : : }
424 : 0 : ofs.ofs.auth.head = auth_offset;
425 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
426 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
427 : : op, void *, IV_OFFSET + cipher_iv_len);
428 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
429 : : cipher_iv_len);
430 : 0 : digest.va = (void *)sop->auth.digest.data;
431 : 0 : digest.iova = sop->auth.digest.phys_addr;
432 : :
433 : : } else { /* aead */
434 : 0 : cipher_offset = sop->aead.data.offset;
435 : 0 : cipher_len = sop->aead.data.length;
436 : 0 : max_len = cipher_len + cipher_offset;
437 [ # # ]: 0 : if (len_in_bits) {
438 : 0 : max_len = max_len >> 3;
439 : 0 : cipher_offset = cipher_offset >> 3;
440 : 0 : cipher_len = cipher_len >> 3;
441 : : }
442 : 0 : ofs.ofs.cipher.head = cipher_offset;
443 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
444 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
445 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
446 : 0 : aad_auth_iv.va = (void *)sop->aead.aad.data;
447 : 0 : aad_auth_iv.iova = sop->aead.aad.phys_addr;
448 : 0 : digest.va = (void *)sop->aead.digest.data;
449 : 0 : digest.iova = sop->aead.digest.phys_addr;
450 : : }
451 : :
452 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
453 : : data_vec, RTE_DIM(data_vec));
454 [ # # # # ]: 0 : if (n < 0 || n > sop->m_src->nb_segs) {
455 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
456 : 0 : goto exit;
457 : : }
458 : :
459 : 0 : sgl.num = n;
460 : : /* Out of place */
461 [ # # ]: 0 : if (is_oop) {
462 : 0 : dest_sgl.vec = dest_data_vec;
463 : 0 : vec.dest_sgl = &dest_sgl;
464 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
465 : : dest_data_vec, RTE_DIM(dest_data_vec));
466 [ # # # # ]: 0 : if (n < 0 || n > sop->m_dst->nb_segs) {
467 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
468 : 0 : goto exit;
469 : : }
470 : 0 : dest_sgl.num = n;
471 : : } else
472 : 0 : vec.dest_sgl = NULL;
473 : :
474 [ # # ]: 0 : if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
475 : : &enqueue_status) < 1) {
476 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
477 : 0 : goto exit;
478 : : }
479 : :
480 [ # # ]: 0 : if (enqueue_status == 0) {
481 : 0 : status = rte_cryptodev_raw_enqueue_done(ctx, 1);
482 [ # # ]: 0 : if (status < 0) {
483 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
484 : 0 : goto exit;
485 : : }
486 [ # # ]: 0 : } else if (enqueue_status < 0) {
487 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
488 : 0 : goto exit;
489 : : }
490 : :
491 : 0 : n = n_success = 0;
492 [ # # # # ]: 0 : while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
493 : 0 : n = rte_cryptodev_raw_dequeue_burst(ctx,
494 : : NULL, 1, post_process_raw_dp_op,
495 : : (void **)&ret_op, 0, &n_success,
496 : : &dequeue_status);
497 [ # # ]: 0 : if (dequeue_status < 0) {
498 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
499 : 0 : goto exit;
500 : : }
501 [ # # ]: 0 : if (n == 0)
502 : : rte_pause();
503 : : }
504 : :
505 [ # # # # ]: 0 : if (n == 1 && dequeue_status == 0) {
506 [ # # ]: 0 : if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
507 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
508 : 0 : goto exit;
509 : : }
510 : : }
511 : :
512 [ # # # # ]: 0 : op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
513 [ # # ]: 0 : ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
514 [ # # ]: 0 : n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
515 : : RTE_CRYPTO_OP_STATUS_SUCCESS;
516 : :
517 : 0 : exit:
518 : 0 : free(ctx);
519 : 0 : return ret;
520 : : }
521 : :
522 : : static void
523 : 0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
524 : : {
525 : : int32_t n, st;
526 : : struct rte_crypto_sym_op *sop;
527 : : union rte_crypto_sym_ofs ofs;
528 : : struct rte_crypto_sgl sgl;
529 : : struct rte_crypto_sym_vec symvec;
530 : : struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
531 : : struct rte_crypto_vec vec[UINT8_MAX];
532 : :
533 : : sop = op->sym;
534 : :
535 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
536 : : sop->aead.data.length, vec, RTE_DIM(vec));
537 : :
538 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
539 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
540 : 0 : return;
541 : : }
542 : :
543 : 0 : sgl.vec = vec;
544 : 0 : sgl.num = n;
545 : 0 : symvec.src_sgl = &sgl;
546 : 0 : symvec.iv = &iv_ptr;
547 : 0 : symvec.digest = &digest_ptr;
548 : 0 : symvec.aad = &aad_ptr;
549 : 0 : symvec.status = &st;
550 : 0 : symvec.num = 1;
551 : :
552 : : /* for CPU crypto the IOVA address is not required */
553 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
554 : 0 : digest_ptr.va = (void *)sop->aead.digest.data;
555 : 0 : aad_ptr.va = (void *)sop->aead.aad.data;
556 : :
557 : 0 : ofs.raw = 0;
558 : :
559 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
560 : : &symvec);
561 : :
562 [ # # ]: 0 : if (n != 1)
563 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
564 : : else
565 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
566 : : }
567 : :
568 : : static void
569 : 0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
570 : : {
571 : : int32_t n, st;
572 : : struct rte_crypto_sym_op *sop;
573 : : union rte_crypto_sym_ofs ofs;
574 : : struct rte_crypto_sgl sgl;
575 : : struct rte_crypto_sym_vec symvec;
576 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
577 : : struct rte_crypto_vec vec[UINT8_MAX];
578 : :
579 : : sop = op->sym;
580 : :
581 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
582 : : sop->auth.data.length, vec, RTE_DIM(vec));
583 : :
584 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
585 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
586 : 0 : return;
587 : : }
588 : :
589 : 0 : sgl.vec = vec;
590 : 0 : sgl.num = n;
591 : 0 : symvec.src_sgl = &sgl;
592 : 0 : symvec.iv = &iv_ptr;
593 : 0 : symvec.digest = &digest_ptr;
594 : 0 : symvec.status = &st;
595 : 0 : symvec.num = 1;
596 : :
597 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
598 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
599 : :
600 : 0 : ofs.raw = 0;
601 : 0 : ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
602 : 0 : ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
603 : 0 : (sop->cipher.data.offset + sop->cipher.data.length);
604 : :
605 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
606 : : &symvec);
607 : :
608 [ # # ]: 0 : if (n != 1)
609 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
610 : : else
611 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
612 : : }
613 : :
614 : : static struct rte_crypto_op *
615 : 116 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
616 : : {
617 : :
618 [ - + ]: 116 : RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
619 : :
620 [ - + ]: 116 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
621 : 0 : RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
622 : 0 : return NULL;
623 : : }
624 : :
625 : 116 : op = NULL;
626 : :
627 [ - + ]: 116 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
628 : : rte_pause();
629 : :
630 [ + + ]: 116 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
631 : 11 : RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
632 : 11 : return NULL;
633 : : }
634 : :
635 : : return op;
636 : : }
637 : :
638 : : static int
639 : 1 : testsuite_setup(void)
640 : : {
641 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
642 : : struct rte_cryptodev_info info;
643 : : uint32_t i = 0, nb_devs, dev_id;
644 : : uint16_t qp_id;
645 : :
646 : : memset(ts_params, 0, sizeof(*ts_params));
647 : :
648 : 1 : ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
649 [ + - ]: 1 : if (ts_params->mbuf_pool == NULL) {
650 : : /* Not already created so create */
651 : 1 : ts_params->mbuf_pool = rte_pktmbuf_pool_create(
652 : : "CRYPTO_MBUFPOOL",
653 : : NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
654 : 1 : rte_socket_id());
655 [ - + ]: 1 : if (ts_params->mbuf_pool == NULL) {
656 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
657 : 0 : return TEST_FAILED;
658 : : }
659 : : }
660 : :
661 : 1 : ts_params->large_mbuf_pool = rte_mempool_lookup(
662 : : "CRYPTO_LARGE_MBUFPOOL");
663 [ + - ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
664 : : /* Not already created so create */
665 : 1 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
666 : : "CRYPTO_LARGE_MBUFPOOL",
667 : : 1, 0, 0, LARGE_MBUF_SIZE,
668 : 1 : rte_socket_id());
669 [ - + ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
670 : 0 : RTE_LOG(ERR, USER1,
671 : : "Can't create CRYPTO_LARGE_MBUFPOOL\n");
672 : 0 : return TEST_FAILED;
673 : : }
674 : : }
675 : :
676 : 1 : ts_params->op_mpool = rte_crypto_op_pool_create(
677 : : "MBUF_CRYPTO_SYM_OP_POOL",
678 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC,
679 : : NUM_MBUFS, MBUF_CACHE_SIZE,
680 : : DEFAULT_NUM_XFORMS *
681 : : sizeof(struct rte_crypto_sym_xform) +
682 : : MAXIMUM_IV_LENGTH,
683 : 1 : rte_socket_id());
684 [ - + ]: 1 : if (ts_params->op_mpool == NULL) {
685 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
686 : 0 : return TEST_FAILED;
687 : : }
688 : :
689 : 1 : nb_devs = rte_cryptodev_count();
690 [ - + ]: 1 : if (nb_devs < 1) {
691 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
692 : 0 : return TEST_SKIPPED;
693 : : }
694 : :
695 [ - + ]: 1 : if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
696 : 0 : RTE_LOG(WARNING, USER1, "No %s devices found?\n",
697 : : rte_cryptodev_driver_name_get(gbl_driver_id));
698 : 0 : return TEST_SKIPPED;
699 : : }
700 : :
701 : : /* Create list of valid crypto devs */
702 [ + + ]: 2 : for (i = 0; i < nb_devs; i++) {
703 : 1 : rte_cryptodev_info_get(i, &info);
704 [ + - ]: 1 : if (info.driver_id == gbl_driver_id)
705 : 1 : ts_params->valid_devs[ts_params->valid_dev_count++] = i;
706 : : }
707 : :
708 [ + - ]: 1 : if (ts_params->valid_dev_count < 1)
709 : : return TEST_FAILED;
710 : :
711 : : /* Set up all the qps on the first of the valid devices found */
712 : :
713 : 1 : dev_id = ts_params->valid_devs[0];
714 : :
715 : 1 : rte_cryptodev_info_get(dev_id, &info);
716 : :
717 : 1 : ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
718 : 1 : ts_params->conf.socket_id = SOCKET_ID_ANY;
719 : 1 : ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
720 : :
721 : : unsigned int session_size =
722 : 1 : rte_cryptodev_sym_get_private_session_size(dev_id);
723 : :
724 : : #ifdef RTE_LIB_SECURITY
725 : 1 : unsigned int security_session_size = rte_security_session_get_size(
726 : : rte_cryptodev_get_sec_ctx(dev_id));
727 : :
728 : : if (session_size < security_session_size)
729 : : session_size = security_session_size;
730 : : #endif
731 : : /*
732 : : * Create mempool with maximum number of sessions.
733 : : */
734 [ - + ]: 1 : if (info.sym.max_nb_sessions != 0 &&
735 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
736 : 0 : RTE_LOG(ERR, USER1, "Device does not support "
737 : : "at least %u sessions\n",
738 : : MAX_NB_SESSIONS);
739 : 0 : return TEST_FAILED;
740 : : }
741 : :
742 : 1 : ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
743 : : "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
744 : : SOCKET_ID_ANY);
745 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
746 : : "session mempool allocation failed");
747 : :
748 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
749 : : &ts_params->conf),
750 : : "Failed to configure cryptodev %u with %u qps",
751 : : dev_id, ts_params->conf.nb_queue_pairs);
752 : :
753 : 1 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
754 : 1 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
755 : :
756 [ + + ]: 9 : for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
757 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
758 : : dev_id, qp_id, &ts_params->qp_conf,
759 : : rte_cryptodev_socket_id(dev_id)),
760 : : "Failed to setup queue pair %u on cryptodev %u",
761 : : qp_id, dev_id);
762 : : }
763 : :
764 : : return TEST_SUCCESS;
765 : : }
766 : :
767 : : static void
768 : 1 : testsuite_teardown(void)
769 : : {
770 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
771 : : int res;
772 : :
773 [ + - ]: 1 : if (ts_params->large_mbuf_pool != NULL) {
774 : 1 : rte_mempool_free(ts_params->large_mbuf_pool);
775 : 1 : ts_params->large_mbuf_pool = NULL;
776 : : }
777 : :
778 [ + - ]: 1 : if (ts_params->mbuf_pool != NULL) {
779 : 1 : rte_mempool_free(ts_params->mbuf_pool);
780 : 1 : ts_params->mbuf_pool = NULL;
781 : : }
782 : :
783 [ + - ]: 1 : if (ts_params->op_mpool != NULL) {
784 : 1 : rte_mempool_free(ts_params->op_mpool);
785 : 1 : ts_params->op_mpool = NULL;
786 : : }
787 : :
788 [ + - ]: 1 : if (ts_params->session_mpool != NULL) {
789 : 1 : rte_mempool_free(ts_params->session_mpool);
790 : 1 : ts_params->session_mpool = NULL;
791 : : }
792 : :
793 : 1 : res = rte_cryptodev_close(ts_params->valid_devs[0]);
794 [ - + ]: 1 : if (res)
795 : 0 : RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
796 : 1 : }
797 : :
798 : : static int
799 : 30 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
800 : : const int *algs, uint16_t num_algs)
801 : : {
802 : 30 : uint8_t dev_id = testsuite_params.valid_devs[0];
803 : : bool some_alg_supported = false;
804 : : uint16_t i;
805 : :
806 [ + + ]: 72 : for (i = 0; i < num_algs && !some_alg_supported; i++) {
807 : 42 : struct rte_cryptodev_sym_capability_idx alg = {
808 : 42 : type, {algs[i]}
809 : : };
810 [ + + ]: 42 : if (rte_cryptodev_sym_capability_get(dev_id,
811 : : &alg) != NULL)
812 : : some_alg_supported = true;
813 : : }
814 [ + + ]: 30 : if (!some_alg_supported)
815 : 13 : return TEST_SKIPPED;
816 : :
817 : : return 0;
818 : : }
819 : :
820 : : int
821 : 9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
822 : : uint16_t num_ciphers)
823 : : {
824 : 17 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
825 : : (const int *) ciphers, num_ciphers);
826 : : }
827 : :
828 : : int
829 : 2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
830 : : uint16_t num_auths)
831 : : {
832 : 9 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
833 : : (const int *) auths, num_auths);
834 : : }
835 : :
836 : : int
837 : 0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
838 : : uint16_t num_aeads)
839 : : {
840 : 4 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
841 : : (const int *) aeads, num_aeads);
842 : : }
843 : :
844 : : static int
845 : 1 : null_testsuite_setup(void)
846 : : {
847 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
848 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
849 : : struct rte_cryptodev_info dev_info;
850 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
851 : : RTE_CRYPTO_CIPHER_NULL
852 : : };
853 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
854 : : RTE_CRYPTO_AUTH_NULL
855 : : };
856 : :
857 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
858 : :
859 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
860 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
861 : : "testsuite not met\n");
862 : 0 : return TEST_SKIPPED;
863 : : }
864 : :
865 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
866 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
867 : : RTE_DIM(auths)) != 0) {
868 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for NULL "
869 : : "testsuite not met\n");
870 : 1 : return TEST_SKIPPED;
871 : : }
872 : :
873 : : return 0;
874 : : }
875 : :
876 : : static int
877 : 1 : crypto_gen_testsuite_setup(void)
878 : : {
879 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
880 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
881 : : struct rte_cryptodev_info dev_info;
882 : :
883 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
884 : :
885 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
886 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
887 : : "testsuite not met\n");
888 : 0 : return TEST_SKIPPED;
889 : : }
890 : :
891 : : return 0;
892 : : }
893 : :
894 : : #ifdef RTE_LIB_SECURITY
895 : : static int
896 : 4 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
897 : : {
898 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
899 : : struct crypto_unittest_params *ut_params = &unittest_params;
900 : : struct rte_cryptodev_info dev_info;
901 : : int ret = 0;
902 : :
903 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
904 : :
905 [ + - ]: 4 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
906 : 4 : RTE_LOG(INFO, USER1,
907 : : "Feature flag requirements for security protocol testsuite not met\n");
908 : 4 : return TEST_SKIPPED;
909 : : }
910 : :
911 : : /* Reconfigure to enable security */
912 : 0 : ret = dev_configure_and_start(0);
913 [ # # ]: 0 : if (ret != TEST_SUCCESS)
914 : : return ret;
915 : :
916 : : /* Set action type */
917 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
918 : :
919 [ # # ]: 0 : if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
920 : 0 : RTE_LOG(INFO, USER1,
921 : : "Capability requirements for security protocol test not met\n");
922 : : ret = TEST_SKIPPED;
923 : : }
924 : :
925 : 0 : test_sec_alg_list_populate();
926 : 0 : test_sec_auth_only_alg_list_populate();
927 : :
928 : : /*
929 : : * Stop the device. Device would be started again by individual test
930 : : * case setup routine.
931 : : */
932 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
933 : :
934 : 0 : return ret;
935 : : }
936 : :
937 : : static int
938 : 1 : ipsec_proto_testsuite_setup(void)
939 : : {
940 : 1 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
941 : : }
942 : :
943 : : static int
944 : 3 : tls_record_proto_testsuite_setup(void)
945 : : {
946 : 3 : test_sec_proto_pattern_generate();
947 : :
948 : 3 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
949 : : }
950 : :
951 : : static int
952 : 1 : pdcp_proto_testsuite_setup(void)
953 : : {
954 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
955 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
956 : : struct rte_cryptodev_info dev_info;
957 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
958 : : RTE_CRYPTO_CIPHER_NULL,
959 : : RTE_CRYPTO_CIPHER_AES_CTR,
960 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
961 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
962 : : };
963 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
964 : : RTE_CRYPTO_AUTH_NULL,
965 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
966 : : RTE_CRYPTO_AUTH_AES_CMAC,
967 : : RTE_CRYPTO_AUTH_ZUC_EIA3
968 : : };
969 : :
970 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
971 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
972 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
973 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
974 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
975 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
976 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
977 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
978 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
979 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
980 : :
981 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
982 : :
983 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
984 : : !(dev_info.feature_flags &
985 : : RTE_CRYPTODEV_FF_SECURITY)) {
986 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
987 : : "testsuite not met\n");
988 : 1 : return TEST_SKIPPED;
989 : : }
990 : :
991 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
992 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
993 : : RTE_DIM(auths)) != 0) {
994 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
995 : : "testsuite not met\n");
996 : 0 : return TEST_SKIPPED;
997 : : }
998 : :
999 : : return 0;
1000 : : }
1001 : :
1002 : : static int
1003 : 1 : docsis_proto_testsuite_setup(void)
1004 : : {
1005 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1006 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1007 : : struct rte_cryptodev_info dev_info;
1008 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1009 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
1010 : : };
1011 : :
1012 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1013 : :
1014 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1015 : : !(dev_info.feature_flags &
1016 : : RTE_CRYPTODEV_FF_SECURITY)) {
1017 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
1018 : : "Proto testsuite not met\n");
1019 : 1 : return TEST_SKIPPED;
1020 : : }
1021 : :
1022 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1023 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
1024 : : "testsuite not met\n");
1025 : 0 : return TEST_SKIPPED;
1026 : : }
1027 : :
1028 : : return 0;
1029 : : }
1030 : : #endif
1031 : :
1032 : : static int
1033 : 1 : aes_ccm_auth_testsuite_setup(void)
1034 : : {
1035 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1036 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1037 : : struct rte_cryptodev_info dev_info;
1038 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1039 : : RTE_CRYPTO_AEAD_AES_CCM
1040 : : };
1041 : :
1042 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1043 : :
1044 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1045 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1046 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1047 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
1048 : : "testsuite not met\n");
1049 : 0 : return TEST_SKIPPED;
1050 : : }
1051 : :
1052 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1053 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
1054 : : "testsuite not met\n");
1055 : 0 : return TEST_SKIPPED;
1056 : : }
1057 : :
1058 : : return 0;
1059 : : }
1060 : :
1061 : : static int
1062 : 1 : aes_gcm_auth_testsuite_setup(void)
1063 : : {
1064 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1065 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1066 : : struct rte_cryptodev_info dev_info;
1067 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1068 : : RTE_CRYPTO_AEAD_AES_GCM
1069 : : };
1070 : :
1071 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1072 : :
1073 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1074 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
1075 : : "testsuite not met\n");
1076 : 0 : return TEST_SKIPPED;
1077 : : }
1078 : :
1079 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1080 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
1081 : : "testsuite not met\n");
1082 : 0 : return TEST_SKIPPED;
1083 : : }
1084 : :
1085 : : return 0;
1086 : : }
1087 : :
1088 : : static int
1089 : 1 : aes_gmac_auth_testsuite_setup(void)
1090 : : {
1091 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1092 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1093 : : struct rte_cryptodev_info dev_info;
1094 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1095 : : RTE_CRYPTO_AUTH_AES_GMAC
1096 : : };
1097 : :
1098 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1099 : :
1100 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1101 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1102 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1103 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1104 : : "testsuite not met\n");
1105 : 0 : return TEST_SKIPPED;
1106 : : }
1107 : :
1108 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1109 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1110 : : "testsuite not met\n");
1111 : 0 : return TEST_SKIPPED;
1112 : : }
1113 : :
1114 : : return 0;
1115 : : }
1116 : :
1117 : : static int
1118 : 1 : chacha20_poly1305_testsuite_setup(void)
1119 : : {
1120 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1121 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1122 : : struct rte_cryptodev_info dev_info;
1123 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1124 : : RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1125 : : };
1126 : :
1127 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1128 : :
1129 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1130 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1131 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1132 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1133 : : "Chacha20-Poly1305 testsuite not met\n");
1134 : 0 : return TEST_SKIPPED;
1135 : : }
1136 : :
1137 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1138 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1139 : : "Chacha20-Poly1305 testsuite not met\n");
1140 : 1 : return TEST_SKIPPED;
1141 : : }
1142 : :
1143 : : return 0;
1144 : : }
1145 : :
1146 : : static int
1147 : 1 : snow3g_testsuite_setup(void)
1148 : : {
1149 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1150 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1151 : : struct rte_cryptodev_info dev_info;
1152 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1153 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1154 : :
1155 : : };
1156 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1157 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2
1158 : : };
1159 : :
1160 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1161 : :
1162 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1163 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1164 : : "testsuite not met\n");
1165 : 0 : return TEST_SKIPPED;
1166 : : }
1167 : :
1168 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1169 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1170 : : RTE_DIM(auths)) != 0) {
1171 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1172 : : "testsuite not met\n");
1173 : 1 : return TEST_SKIPPED;
1174 : : }
1175 : :
1176 : : return 0;
1177 : : }
1178 : :
1179 : : static int
1180 : 1 : zuc_testsuite_setup(void)
1181 : : {
1182 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1183 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1184 : : struct rte_cryptodev_info dev_info;
1185 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1186 : : RTE_CRYPTO_CIPHER_ZUC_EEA3
1187 : : };
1188 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1189 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1190 : : };
1191 : :
1192 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1193 : :
1194 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1195 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1196 : : "testsuite not met\n");
1197 : 0 : return TEST_SKIPPED;
1198 : : }
1199 : :
1200 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1201 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1202 : : RTE_DIM(auths)) != 0) {
1203 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1204 : : "testsuite not met\n");
1205 : 1 : return TEST_SKIPPED;
1206 : : }
1207 : :
1208 : : return 0;
1209 : : }
1210 : :
1211 : : static int
1212 : 1 : hmac_md5_auth_testsuite_setup(void)
1213 : : {
1214 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1215 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1216 : : struct rte_cryptodev_info dev_info;
1217 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1218 : : RTE_CRYPTO_AUTH_MD5_HMAC
1219 : : };
1220 : :
1221 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1222 : :
1223 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1224 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1225 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1226 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1227 : : "Auth testsuite not met\n");
1228 : 0 : return TEST_SKIPPED;
1229 : : }
1230 : :
1231 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1232 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1233 : : "testsuite not met\n");
1234 : 0 : return TEST_SKIPPED;
1235 : : }
1236 : :
1237 : : return 0;
1238 : : }
1239 : :
1240 : : static int
1241 : 1 : kasumi_testsuite_setup(void)
1242 : : {
1243 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1244 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1245 : : struct rte_cryptodev_info dev_info;
1246 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1247 : : RTE_CRYPTO_CIPHER_KASUMI_F8
1248 : : };
1249 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1250 : : RTE_CRYPTO_AUTH_KASUMI_F9
1251 : : };
1252 : :
1253 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1254 : :
1255 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1256 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1257 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1258 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1259 : : "testsuite not met\n");
1260 : 0 : return TEST_SKIPPED;
1261 : : }
1262 : :
1263 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1264 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1265 : : RTE_DIM(auths)) != 0) {
1266 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1267 : : "testsuite not met\n");
1268 : 1 : return TEST_SKIPPED;
1269 : : }
1270 : :
1271 : : return 0;
1272 : : }
1273 : :
1274 : : static int
1275 : 1 : negative_aes_gcm_testsuite_setup(void)
1276 : : {
1277 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1278 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1279 : : struct rte_cryptodev_info dev_info;
1280 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1281 : : RTE_CRYPTO_AEAD_AES_GCM
1282 : : };
1283 : :
1284 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1285 : :
1286 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1287 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1288 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1289 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1290 : : "AES GCM testsuite not met\n");
1291 : 0 : return TEST_SKIPPED;
1292 : : }
1293 : :
1294 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1295 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1296 : : "AES GCM testsuite not met\n");
1297 : 0 : return TEST_SKIPPED;
1298 : : }
1299 : :
1300 : : return 0;
1301 : : }
1302 : :
1303 : : static int
1304 : 1 : negative_aes_gmac_testsuite_setup(void)
1305 : : {
1306 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1307 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1308 : : struct rte_cryptodev_info dev_info;
1309 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1310 : : RTE_CRYPTO_AUTH_AES_GMAC
1311 : : };
1312 : :
1313 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1314 : :
1315 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1316 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1317 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1318 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1319 : : "AES GMAC testsuite not met\n");
1320 : 0 : return TEST_SKIPPED;
1321 : : }
1322 : :
1323 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1324 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1325 : : "AES GMAC testsuite not met\n");
1326 : 0 : return TEST_SKIPPED;
1327 : : }
1328 : :
1329 : : return 0;
1330 : : }
1331 : :
1332 : : static int
1333 : 1 : mixed_cipher_hash_testsuite_setup(void)
1334 : : {
1335 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1336 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1337 : : struct rte_cryptodev_info dev_info;
1338 : : uint64_t feat_flags;
1339 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1340 : : RTE_CRYPTO_CIPHER_NULL,
1341 : : RTE_CRYPTO_CIPHER_AES_CTR,
1342 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
1343 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1344 : : };
1345 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1346 : : RTE_CRYPTO_AUTH_NULL,
1347 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1348 : : RTE_CRYPTO_AUTH_AES_CMAC,
1349 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1350 : : };
1351 : :
1352 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1353 : 1 : feat_flags = dev_info.feature_flags;
1354 : :
1355 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1356 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1357 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1358 : : "Cipher Hash testsuite not met\n");
1359 : 0 : return TEST_SKIPPED;
1360 : : }
1361 : :
1362 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1363 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1364 : : RTE_DIM(auths)) != 0) {
1365 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1366 : : "Cipher Hash testsuite not met\n");
1367 : 0 : return TEST_SKIPPED;
1368 : : }
1369 : :
1370 : : return 0;
1371 : : }
1372 : :
1373 : : static int
1374 : 1 : esn_testsuite_setup(void)
1375 : : {
1376 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1377 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1378 : : struct rte_cryptodev_info dev_info;
1379 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1380 : : RTE_CRYPTO_CIPHER_AES_CBC
1381 : : };
1382 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1383 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1384 : : };
1385 : :
1386 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1387 : :
1388 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1389 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1390 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1391 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1392 : : "testsuite not met\n");
1393 : 0 : return TEST_SKIPPED;
1394 : : }
1395 : :
1396 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1397 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1398 : : RTE_DIM(auths)) != 0) {
1399 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1400 : : "testsuite not met\n");
1401 : 0 : return TEST_SKIPPED;
1402 : : }
1403 : :
1404 : : return 0;
1405 : : }
1406 : :
1407 : : static int
1408 : 1 : multi_session_testsuite_setup(void)
1409 : : {
1410 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1411 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1412 : : struct rte_cryptodev_info dev_info;
1413 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1414 : : RTE_CRYPTO_CIPHER_AES_CBC
1415 : : };
1416 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1417 : : RTE_CRYPTO_AUTH_SHA512_HMAC
1418 : : };
1419 : :
1420 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1421 : :
1422 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1423 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1424 : : "Session testsuite not met\n");
1425 : 0 : return TEST_SKIPPED;
1426 : : }
1427 : :
1428 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1429 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1430 : : RTE_DIM(auths)) != 0) {
1431 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1432 : : "Session testsuite not met\n");
1433 : 0 : return TEST_SKIPPED;
1434 : : }
1435 : :
1436 : : return 0;
1437 : : }
1438 : :
1439 : : static int
1440 : 1 : negative_hmac_sha1_testsuite_setup(void)
1441 : : {
1442 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1443 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1444 : : struct rte_cryptodev_info dev_info;
1445 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1446 : : RTE_CRYPTO_CIPHER_AES_CBC
1447 : : };
1448 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1449 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1450 : : };
1451 : :
1452 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1453 : :
1454 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1455 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1456 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1457 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1458 : : "HMAC SHA1 testsuite not met\n");
1459 : 0 : return TEST_SKIPPED;
1460 : : }
1461 : :
1462 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1463 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1464 : : RTE_DIM(auths)) != 0) {
1465 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1466 : : "HMAC SHA1 testsuite not met\n");
1467 : 0 : return TEST_SKIPPED;
1468 : : }
1469 : :
1470 : : return 0;
1471 : : }
1472 : :
1473 : : static int
1474 : 432 : dev_configure_and_start(uint64_t ff_disable)
1475 : : {
1476 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1477 : : struct crypto_unittest_params *ut_params = &unittest_params;
1478 : :
1479 : : uint16_t qp_id;
1480 : :
1481 : : /* Clear unit test parameters before running test */
1482 : : memset(ut_params, 0, sizeof(*ut_params));
1483 : :
1484 : : /* Reconfigure device to default parameters */
1485 : 432 : ts_params->conf.socket_id = SOCKET_ID_ANY;
1486 : 432 : ts_params->conf.ff_disable = ff_disable;
1487 : 432 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1488 : 432 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
1489 : :
1490 [ - + ]: 432 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1491 : : &ts_params->conf),
1492 : : "Failed to configure cryptodev %u",
1493 : : ts_params->valid_devs[0]);
1494 : :
1495 [ + + ]: 3888 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1496 [ - + ]: 3456 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1497 : : ts_params->valid_devs[0], qp_id,
1498 : : &ts_params->qp_conf,
1499 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1500 : : "Failed to setup queue pair %u on cryptodev %u",
1501 : : qp_id, ts_params->valid_devs[0]);
1502 : : }
1503 : :
1504 : :
1505 : 432 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1506 : :
1507 : : /* Start the device */
1508 [ - + ]: 432 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1509 : : "Failed to start cryptodev %u",
1510 : : ts_params->valid_devs[0]);
1511 : :
1512 : : return TEST_SUCCESS;
1513 : : }
1514 : :
1515 : : int
1516 : 432 : ut_setup(void)
1517 : : {
1518 : : /* Configure and start the device with security feature disabled */
1519 : 432 : return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1520 : : }
1521 : :
1522 : : static int
1523 : 0 : ut_setup_security(void)
1524 : : {
1525 : : /* Configure and start the device with no features disabled */
1526 : 0 : return dev_configure_and_start(0);
1527 : : }
1528 : :
1529 : : static int
1530 : 0 : ut_setup_security_rx_inject(void)
1531 : : {
1532 : 0 : struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1533 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1534 : 0 : struct rte_eth_conf port_conf = {
1535 : : .rxmode = {
1536 : : .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1537 : : RTE_ETH_RX_OFFLOAD_SECURITY,
1538 : : },
1539 : : .txmode = {
1540 : : .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1541 : : },
1542 : : .lpbk_mode = 1, /* Enable loopback */
1543 : : };
1544 : : struct rte_cryptodev_info dev_info;
1545 : 0 : struct rte_eth_rxconf rx_conf = {
1546 : : .rx_thresh = {
1547 : : .pthresh = 8,
1548 : : .hthresh = 8,
1549 : : .wthresh = 8,
1550 : : },
1551 : : .rx_free_thresh = 32,
1552 : : };
1553 : : uint16_t nb_ports;
1554 : : void *sec_ctx;
1555 : : int ret;
1556 : :
1557 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1558 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1559 : : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1560 : 0 : RTE_LOG(INFO, USER1,
1561 : : "Feature requirements for IPsec Rx inject test case not met\n");
1562 : 0 : return TEST_SKIPPED;
1563 : : }
1564 : :
1565 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1566 [ # # ]: 0 : if (sec_ctx == NULL)
1567 : : return TEST_SKIPPED;
1568 : :
1569 : 0 : nb_ports = rte_eth_dev_count_avail();
1570 [ # # ]: 0 : if (nb_ports == 0)
1571 : : return TEST_SKIPPED;
1572 : :
1573 : 0 : ret = rte_eth_dev_configure(0 /* port_id */,
1574 : : 1 /* nb_rx_queue */,
1575 : : 0 /* nb_tx_queue */,
1576 : : &port_conf);
1577 [ # # ]: 0 : if (ret) {
1578 : : printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1579 : 0 : return TEST_SKIPPED;
1580 : : }
1581 : :
1582 : : /* Rx queue setup */
1583 : 0 : ret = rte_eth_rx_queue_setup(0 /* port_id */,
1584 : : 0 /* rx_queue_id */,
1585 : : 1024 /* nb_rx_desc */,
1586 : : SOCKET_ID_ANY,
1587 : : &rx_conf,
1588 : : mbuf_pool);
1589 [ # # ]: 0 : if (ret) {
1590 : : printf("Could not setup eth port 0 queue 0\n");
1591 : 0 : return TEST_SKIPPED;
1592 : : }
1593 : :
1594 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1595 [ # # ]: 0 : if (ret) {
1596 : : printf("Could not enable Rx inject offload");
1597 : 0 : return TEST_SKIPPED;
1598 : : }
1599 : :
1600 : 0 : ret = rte_eth_dev_start(0);
1601 [ # # ]: 0 : if (ret) {
1602 : : printf("Could not start ethdev");
1603 : 0 : return TEST_SKIPPED;
1604 : : }
1605 : :
1606 : 0 : ret = rte_eth_promiscuous_enable(0);
1607 [ # # ]: 0 : if (ret) {
1608 : : printf("Could not enable promiscuous mode");
1609 : 0 : return TEST_SKIPPED;
1610 : : }
1611 : :
1612 : : /* Configure and start cryptodev with no features disabled */
1613 : 0 : return dev_configure_and_start(0);
1614 : : }
1615 : :
1616 : : static inline void
1617 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1618 : : {
1619 : 0 : }
1620 : :
1621 : : static inline void
1622 : 108 : ext_mbuf_memzone_free(int nb_segs)
1623 : : {
1624 : : int i;
1625 : :
1626 [ + + ]: 324 : for (i = 0; i <= nb_segs; i++) {
1627 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1628 : : const struct rte_memzone *memzone;
1629 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1630 : 216 : memzone = rte_memzone_lookup(mz_name);
1631 [ + + ]: 216 : if (memzone != NULL) {
1632 : 2 : rte_memzone_free(memzone);
1633 : : memzone = NULL;
1634 : : }
1635 : : }
1636 : 108 : }
1637 : :
1638 : : static inline struct rte_mbuf *
1639 : 2 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1640 : : int nb_segs, const void *input_text)
1641 : : {
1642 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
1643 : : size_t data_off = 0;
1644 : : uint8_t *dst;
1645 : : int i, size;
1646 : : int t_len;
1647 : :
1648 [ - + ]: 2 : if (pkt_len < 1) {
1649 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1650 : 0 : return NULL;
1651 : : }
1652 : :
1653 [ - + ]: 2 : if (nb_segs < 1) {
1654 : : printf("Number of segments must be 1 or more (is %d)\n",
1655 : : nb_segs);
1656 : 0 : return NULL;
1657 : : }
1658 : :
1659 [ + - ]: 2 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1660 : : size = pkt_len;
1661 : :
1662 : : /* Create chained mbuf_src with external buffer */
1663 [ + + ]: 4 : for (i = 0; size > 0; i++) {
1664 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1665 : 2 : uint16_t data_len = RTE_MIN(size, t_len);
1666 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1667 : : const struct rte_memzone *memzone;
1668 : : void *ext_buf_addr = NULL;
1669 : : rte_iova_t buf_iova;
1670 : 2 : bool freed = false;
1671 : : uint16_t buf_len;
1672 : :
1673 : 2 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1674 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
1675 : :
1676 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1677 : 2 : memzone = rte_memzone_lookup(mz_name);
1678 [ - + - - ]: 2 : if (memzone != NULL && memzone->len != buf_len) {
1679 : 0 : rte_memzone_free(memzone);
1680 : : memzone = NULL;
1681 : : }
1682 [ + - ]: 2 : if (memzone == NULL) {
1683 : 2 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1684 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1685 [ - + ]: 2 : if (memzone == NULL) {
1686 : : printf("Can't allocate memory zone %s\n", mz_name);
1687 : 0 : return NULL;
1688 : : }
1689 : : }
1690 : :
1691 : 2 : ext_buf_addr = memzone->addr;
1692 [ - + ]: 2 : if (input_text)
1693 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1694 : :
1695 : : /* Create buffer to hold rte_mbuf header */
1696 : 2 : m = rte_pktmbuf_alloc(mbuf_pool);
1697 [ + - ]: 2 : if (i == 0)
1698 : : mbuf = m;
1699 : :
1700 [ - + ]: 2 : if (m == NULL) {
1701 : : printf("Cannot create segment for source mbuf");
1702 : 0 : goto fail;
1703 : : }
1704 : :
1705 : : /* Save shared data (like callback function) in external buffer's end */
1706 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1707 : : ext_mbuf_callback_fn_free, &freed);
1708 : : if (ret_shinfo == NULL) {
1709 : : printf("Shared mem initialization failed!\n");
1710 : 0 : goto fail;
1711 : : }
1712 : :
1713 : 2 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
1714 : :
1715 : : /* Attach external buffer to mbuf */
1716 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1717 : : ret_shinfo);
1718 [ - + ]: 2 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1719 : : printf("External buffer is not attached to mbuf\n");
1720 : 0 : goto fail;
1721 : : }
1722 : :
1723 [ - + ]: 2 : if (input_text) {
1724 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1725 [ # # ]: 0 : if (dst == NULL) {
1726 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
1727 : 0 : goto fail;
1728 : : }
1729 : : }
1730 : :
1731 [ - + ]: 2 : if (mbuf != m)
1732 : : rte_pktmbuf_chain(mbuf, m);
1733 : :
1734 : 2 : size -= data_len;
1735 : 2 : data_off += data_len;
1736 : : }
1737 : :
1738 : : return mbuf;
1739 : :
1740 : : fail:
1741 : 0 : rte_pktmbuf_free(mbuf);
1742 : 0 : ext_mbuf_memzone_free(nb_segs);
1743 : 0 : return NULL;
1744 : : }
1745 : :
1746 : : void
1747 : 432 : ut_teardown(void)
1748 : : {
1749 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1750 : : struct crypto_unittest_params *ut_params = &unittest_params;
1751 : :
1752 : : /* free crypto session structure */
1753 : : #ifdef RTE_LIB_SECURITY
1754 [ - + ]: 432 : if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1755 [ # # ]: 0 : if (ut_params->sec_session) {
1756 : 0 : rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1757 : 0 : (ts_params->valid_devs[0]),
1758 : : ut_params->sec_session);
1759 : 0 : ut_params->sec_session = NULL;
1760 : : }
1761 : : } else
1762 : : #endif
1763 : : {
1764 [ + + ]: 432 : if (ut_params->sess) {
1765 : 109 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1766 : : ut_params->sess);
1767 : 109 : ut_params->sess = NULL;
1768 : : }
1769 : : }
1770 : :
1771 : : /* free crypto operation structure */
1772 : 432 : rte_crypto_op_free(ut_params->op);
1773 : :
1774 : : /*
1775 : : * free mbuf - both obuf and ibuf are usually the same,
1776 : : * so check if they point at the same address is necessary,
1777 : : * to avoid freeing the mbuf twice.
1778 : : */
1779 [ + + ]: 432 : if (ut_params->obuf) {
1780 : 6 : rte_pktmbuf_free(ut_params->obuf);
1781 [ + + ]: 6 : if (ut_params->ibuf == ut_params->obuf)
1782 : 3 : ut_params->ibuf = 0;
1783 : 6 : ut_params->obuf = 0;
1784 : : }
1785 [ + + ]: 432 : if (ut_params->ibuf) {
1786 : 108 : ext_mbuf_memzone_free(1);
1787 : 108 : rte_pktmbuf_free(ut_params->ibuf);
1788 : 108 : ut_params->ibuf = 0;
1789 : : }
1790 : :
1791 [ + - ]: 432 : if (ts_params->mbuf_pool != NULL)
1792 : 432 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1793 : : rte_mempool_avail_count(ts_params->mbuf_pool));
1794 : :
1795 : : /* Stop the device */
1796 : 432 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1797 : 432 : }
1798 : :
1799 : : static void
1800 : 0 : ut_teardown_rx_inject(void)
1801 : : {
1802 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1803 : : void *sec_ctx;
1804 : : int ret;
1805 : :
1806 [ # # ]: 0 : if (rte_eth_dev_count_avail() != 0) {
1807 : 0 : ret = rte_eth_dev_reset(0);
1808 [ # # ]: 0 : if (ret)
1809 : : printf("Could not reset eth port 0");
1810 : :
1811 : : }
1812 : :
1813 : 0 : ut_teardown();
1814 : :
1815 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1816 [ # # ]: 0 : if (sec_ctx == NULL)
1817 : : return;
1818 : :
1819 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1820 [ # # ]: 0 : if (ret) {
1821 : : printf("Could not disable Rx inject offload");
1822 : 0 : return;
1823 : : }
1824 : : }
1825 : :
1826 : : static int
1827 : 1 : test_device_configure_invalid_dev_id(void)
1828 : : {
1829 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1830 : : uint16_t dev_id, num_devs = 0;
1831 : :
1832 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1833 : : "Need at least %d devices for test", 1);
1834 : :
1835 : : /* valid dev_id values */
1836 : 1 : dev_id = ts_params->valid_devs[0];
1837 : :
1838 : : /* Stop the device in case it's started so it can be configured */
1839 : 1 : rte_cryptodev_stop(dev_id);
1840 : :
1841 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1842 : : "Failed test for rte_cryptodev_configure: "
1843 : : "invalid dev_num %u", dev_id);
1844 : :
1845 : : /* invalid dev_id values */
1846 : : dev_id = num_devs;
1847 : :
1848 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1849 : : "Failed test for rte_cryptodev_configure: "
1850 : : "invalid dev_num %u", dev_id);
1851 : :
1852 : : dev_id = 0xff;
1853 : :
1854 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1855 : : "Failed test for rte_cryptodev_configure:"
1856 : : "invalid dev_num %u", dev_id);
1857 : :
1858 : : return TEST_SUCCESS;
1859 : : }
1860 : :
1861 : : static int
1862 : 1 : test_device_configure_invalid_queue_pair_ids(void)
1863 : : {
1864 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1865 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1866 : :
1867 : : /* Stop the device in case it's started so it can be configured */
1868 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1869 : :
1870 : : /* valid - max value queue pairs */
1871 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1872 : :
1873 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1874 : : &ts_params->conf),
1875 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1876 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1877 : :
1878 : : /* valid - one queue pairs */
1879 : 1 : ts_params->conf.nb_queue_pairs = 1;
1880 : :
1881 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1882 : : &ts_params->conf),
1883 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1884 : : ts_params->valid_devs[0],
1885 : : ts_params->conf.nb_queue_pairs);
1886 : :
1887 : :
1888 : : /* invalid - zero queue pairs */
1889 : 1 : ts_params->conf.nb_queue_pairs = 0;
1890 : :
1891 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1892 : : &ts_params->conf),
1893 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1894 : : " invalid qps: %u",
1895 : : ts_params->valid_devs[0],
1896 : : ts_params->conf.nb_queue_pairs);
1897 : :
1898 : :
1899 : : /* invalid - max value supported by field queue pairs */
1900 : 1 : ts_params->conf.nb_queue_pairs = UINT16_MAX;
1901 : :
1902 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1903 : : &ts_params->conf),
1904 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1905 : : " invalid qps: %u",
1906 : : ts_params->valid_devs[0],
1907 : : ts_params->conf.nb_queue_pairs);
1908 : :
1909 : :
1910 : : /* invalid - max value + 1 queue pairs */
1911 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1912 : :
1913 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1914 : : &ts_params->conf),
1915 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1916 : : " invalid qps: %u",
1917 : : ts_params->valid_devs[0],
1918 : : ts_params->conf.nb_queue_pairs);
1919 : :
1920 : : /* revert to original testsuite value */
1921 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1922 : :
1923 : 1 : return TEST_SUCCESS;
1924 : : }
1925 : :
1926 : : static int
1927 : 1 : test_queue_pair_descriptor_setup(void)
1928 : : {
1929 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1930 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
1931 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1932 : : };
1933 : : uint16_t qp_id;
1934 : :
1935 : : /* Stop the device in case it's started so it can be configured */
1936 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1937 : :
1938 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1939 : : &ts_params->conf),
1940 : : "Failed to configure cryptodev %u",
1941 : : ts_params->valid_devs[0]);
1942 : :
1943 : : /*
1944 : : * Test various ring sizes on this device. memzones can't be
1945 : : * freed so are re-used if ring is released and re-created.
1946 : : */
1947 : 1 : qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1948 : 1 : qp_conf.mp_session = ts_params->session_mpool;
1949 : :
1950 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1951 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1952 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1953 : : rte_cryptodev_socket_id(
1954 : : ts_params->valid_devs[0])),
1955 : : "Failed test for "
1956 : : "rte_cryptodev_queue_pair_setup: num_inflights "
1957 : : "%u on qp %u on cryptodev %u",
1958 : : qp_conf.nb_descriptors, qp_id,
1959 : : ts_params->valid_devs[0]);
1960 : : }
1961 : :
1962 : 1 : qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1963 : :
1964 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1965 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1966 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1967 : : rte_cryptodev_socket_id(
1968 : : ts_params->valid_devs[0])),
1969 : : "Failed test for"
1970 : : " rte_cryptodev_queue_pair_setup: num_inflights"
1971 : : " %u on qp %u on cryptodev %u",
1972 : : qp_conf.nb_descriptors, qp_id,
1973 : : ts_params->valid_devs[0]);
1974 : : }
1975 : :
1976 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1977 : :
1978 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1979 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1980 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1981 : : rte_cryptodev_socket_id(
1982 : : ts_params->valid_devs[0])),
1983 : : "Failed test for "
1984 : : "rte_cryptodev_queue_pair_setup: num_inflights"
1985 : : " %u on qp %u on cryptodev %u",
1986 : : qp_conf.nb_descriptors, qp_id,
1987 : : ts_params->valid_devs[0]);
1988 : : }
1989 : :
1990 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1991 : :
1992 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1993 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1994 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1995 : : rte_cryptodev_socket_id(
1996 : : ts_params->valid_devs[0])),
1997 : : "Failed test for"
1998 : : " rte_cryptodev_queue_pair_setup:"
1999 : : "num_inflights %u on qp %u on cryptodev %u",
2000 : : qp_conf.nb_descriptors, qp_id,
2001 : : ts_params->valid_devs[0]);
2002 : : }
2003 : :
2004 : : /* test invalid queue pair id */
2005 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
2006 : :
2007 : : qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
2008 : :
2009 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2010 : : ts_params->valid_devs[0],
2011 : : qp_id, &qp_conf,
2012 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2013 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2014 : : "invalid qp %u on cryptodev %u",
2015 : : qp_id, ts_params->valid_devs[0]);
2016 : :
2017 : : qp_id = 0xffff; /*invalid*/
2018 : :
2019 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2020 : : ts_params->valid_devs[0],
2021 : : qp_id, &qp_conf,
2022 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2023 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2024 : : "invalid qp %u on cryptodev %u",
2025 : : qp_id, ts_params->valid_devs[0]);
2026 : :
2027 : : return TEST_SUCCESS;
2028 : : }
2029 : :
2030 : : /* ***** Plaintext data for tests ***** */
2031 : :
2032 : : const char catch_22_quote_1[] =
2033 : : "There was only one catch and that was Catch-22, which "
2034 : : "specified that a concern for one's safety in the face of "
2035 : : "dangers that were real and immediate was the process of a "
2036 : : "rational mind. Orr was crazy and could be grounded. All he "
2037 : : "had to do was ask; and as soon as he did, he would no longer "
2038 : : "be crazy and would have to fly more missions. Orr would be "
2039 : : "crazy to fly more missions and sane if he didn't, but if he "
2040 : : "was sane he had to fly them. If he flew them he was crazy "
2041 : : "and didn't have to; but if he didn't want to he was sane and "
2042 : : "had to. Yossarian was moved very deeply by the absolute "
2043 : : "simplicity of this clause of Catch-22 and let out a "
2044 : : "respectful whistle. \"That's some catch, that Catch-22\", he "
2045 : : "observed. \"It's the best there is,\" Doc Daneeka agreed.";
2046 : :
2047 : : const char catch_22_quote[] =
2048 : : "What a lousy earth! He wondered how many people were "
2049 : : "destitute that same night even in his own prosperous country, "
2050 : : "how many homes were shanties, how many husbands were drunk "
2051 : : "and wives socked, and how many children were bullied, abused, "
2052 : : "or abandoned. How many families hungered for food they could "
2053 : : "not afford to buy? How many hearts were broken? How many "
2054 : : "suicides would take place that same night, how many people "
2055 : : "would go insane? How many cockroaches and landlords would "
2056 : : "triumph? How many winners were losers, successes failures, "
2057 : : "and rich men poor men? How many wise guys were stupid? How "
2058 : : "many happy endings were unhappy endings? How many honest men "
2059 : : "were liars, brave men cowards, loyal men traitors, how many "
2060 : : "sainted men were corrupt, how many people in positions of "
2061 : : "trust had sold their souls to bodyguards, how many had never "
2062 : : "had souls? How many straight-and-narrow paths were crooked "
2063 : : "paths? How many best families were worst families and how "
2064 : : "many good people were bad people? When you added them all up "
2065 : : "and then subtracted, you might be left with only the children, "
2066 : : "and perhaps with Albert Einstein and an old violinist or "
2067 : : "sculptor somewhere.";
2068 : :
2069 : : #define QUOTE_480_BYTES (480)
2070 : : #define QUOTE_512_BYTES (512)
2071 : : #define QUOTE_768_BYTES (768)
2072 : : #define QUOTE_1024_BYTES (1024)
2073 : :
2074 : :
2075 : :
2076 : : /* ***** SHA1 Hash Tests ***** */
2077 : :
2078 : : #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
2079 : :
2080 : : static uint8_t hmac_sha1_key[] = {
2081 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
2082 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
2083 : : 0xDE, 0xF4, 0xDE, 0xAD };
2084 : :
2085 : : /* ***** SHA224 Hash Tests ***** */
2086 : :
2087 : : #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
2088 : :
2089 : :
2090 : : /* ***** AES-CBC Cipher Tests ***** */
2091 : :
2092 : : #define CIPHER_KEY_LENGTH_AES_CBC (16)
2093 : : #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
2094 : :
2095 : : static uint8_t aes_cbc_key[] = {
2096 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2097 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2098 : :
2099 : : static uint8_t aes_cbc_iv[] = {
2100 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2101 : : 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2102 : :
2103 : :
2104 : : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2105 : :
2106 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2107 : : 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2108 : : 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2109 : : 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2110 : : 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2111 : : 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2112 : : 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2113 : : 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2114 : : 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2115 : : 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2116 : : 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2117 : : 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2118 : : 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2119 : : 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2120 : : 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2121 : : 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2122 : : 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2123 : : 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2124 : : 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2125 : : 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2126 : : 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2127 : : 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2128 : : 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2129 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2130 : : 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2131 : : 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2132 : : 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2133 : : 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2134 : : 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2135 : : 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2136 : : 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2137 : : 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2138 : : 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2139 : : 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2140 : : 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2141 : : 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2142 : : 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2143 : : 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2144 : : 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2145 : : 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2146 : : 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2147 : : 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2148 : : 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2149 : : 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2150 : : 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2151 : : 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2152 : : 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2153 : : 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2154 : : 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2155 : : 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2156 : : 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2157 : : 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2158 : : 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2159 : : 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2160 : : 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2161 : : 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2162 : : 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2163 : : 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2164 : : 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2165 : : 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2166 : : 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2167 : : 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2168 : : 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2169 : : 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2170 : : 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2171 : : };
2172 : :
2173 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2174 : : 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2175 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2176 : : 0x18, 0x8c, 0x1d, 0x32
2177 : : };
2178 : :
2179 : :
2180 : : /* Multisession Vector context Test */
2181 : : /*Begin Session 0 */
2182 : : static uint8_t ms_aes_cbc_key0[] = {
2183 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2184 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2185 : : };
2186 : :
2187 : : static uint8_t ms_aes_cbc_iv0[] = {
2188 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2189 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2190 : : };
2191 : :
2192 : : static const uint8_t ms_aes_cbc_cipher0[] = {
2193 : : 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2194 : : 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2195 : : 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2196 : : 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2197 : : 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2198 : : 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2199 : : 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2200 : : 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2201 : : 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2202 : : 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2203 : : 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2204 : : 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2205 : : 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2206 : : 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2207 : : 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2208 : : 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2209 : : 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2210 : : 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2211 : : 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2212 : : 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2213 : : 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2214 : : 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2215 : : 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2216 : : 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2217 : : 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2218 : : 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2219 : : 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2220 : : 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2221 : : 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2222 : : 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2223 : : 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2224 : : 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2225 : : 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2226 : : 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2227 : : 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2228 : : 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2229 : : 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2230 : : 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2231 : : 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2232 : : 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2233 : : 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2234 : : 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2235 : : 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2236 : : 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2237 : : 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2238 : : 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2239 : : 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2240 : : 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2241 : : 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2242 : : 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2243 : : 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2244 : : 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2245 : : 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2246 : : 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2247 : : 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2248 : : 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2249 : : 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2250 : : 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2251 : : 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2252 : : 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2253 : : 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2254 : : 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2255 : : 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2256 : : 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2257 : : };
2258 : :
2259 : :
2260 : : static uint8_t ms_hmac_key0[] = {
2261 : : 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2262 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2263 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2264 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2265 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2266 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2267 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2268 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2269 : : };
2270 : :
2271 : : static const uint8_t ms_hmac_digest0[] = {
2272 : : 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2273 : : 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2274 : : 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2275 : : 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2276 : : 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2277 : : 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2278 : : 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2279 : : 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2280 : : };
2281 : :
2282 : : /* End Session 0 */
2283 : : /* Begin session 1 */
2284 : :
2285 : : static uint8_t ms_aes_cbc_key1[] = {
2286 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2287 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2288 : : };
2289 : :
2290 : : static uint8_t ms_aes_cbc_iv1[] = {
2291 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2292 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2293 : : };
2294 : :
2295 : : static const uint8_t ms_aes_cbc_cipher1[] = {
2296 : : 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2297 : : 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2298 : : 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2299 : : 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2300 : : 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2301 : : 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2302 : : 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2303 : : 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2304 : : 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2305 : : 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2306 : : 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2307 : : 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2308 : : 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2309 : : 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2310 : : 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2311 : : 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2312 : : 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2313 : : 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2314 : : 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2315 : : 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2316 : : 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2317 : : 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2318 : : 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2319 : : 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2320 : : 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2321 : : 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2322 : : 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2323 : : 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2324 : : 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2325 : : 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2326 : : 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2327 : : 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2328 : : 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2329 : : 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2330 : : 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2331 : : 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2332 : : 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2333 : : 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2334 : : 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2335 : : 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2336 : : 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2337 : : 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2338 : : 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2339 : : 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2340 : : 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2341 : : 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2342 : : 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2343 : : 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2344 : : 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2345 : : 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2346 : : 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2347 : : 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2348 : : 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2349 : : 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2350 : : 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2351 : : 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2352 : : 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2353 : : 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2354 : : 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2355 : : 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2356 : : 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2357 : : 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2358 : : 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2359 : : 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2360 : :
2361 : : };
2362 : :
2363 : : static uint8_t ms_hmac_key1[] = {
2364 : : 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2365 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2366 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2367 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2368 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2369 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2370 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2371 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2372 : : };
2373 : :
2374 : : static const uint8_t ms_hmac_digest1[] = {
2375 : : 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2376 : : 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2377 : : 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2378 : : 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2379 : : 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2380 : : 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2381 : : 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2382 : : 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2383 : : };
2384 : : /* End Session 1 */
2385 : : /* Begin Session 2 */
2386 : : static uint8_t ms_aes_cbc_key2[] = {
2387 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2388 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2389 : : };
2390 : :
2391 : : static uint8_t ms_aes_cbc_iv2[] = {
2392 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2393 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2394 : : };
2395 : :
2396 : : static const uint8_t ms_aes_cbc_cipher2[] = {
2397 : : 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2398 : : 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2399 : : 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2400 : : 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2401 : : 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2402 : : 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2403 : : 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2404 : : 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2405 : : 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2406 : : 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2407 : : 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2408 : : 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2409 : : 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2410 : : 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2411 : : 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2412 : : 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2413 : : 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2414 : : 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2415 : : 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2416 : : 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2417 : : 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2418 : : 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2419 : : 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2420 : : 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2421 : : 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2422 : : 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2423 : : 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2424 : : 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2425 : : 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2426 : : 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2427 : : 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2428 : : 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2429 : : 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2430 : : 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2431 : : 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2432 : : 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2433 : : 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2434 : : 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2435 : : 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2436 : : 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2437 : : 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2438 : : 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2439 : : 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2440 : : 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2441 : : 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2442 : : 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2443 : : 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2444 : : 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2445 : : 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2446 : : 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2447 : : 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2448 : : 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2449 : : 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2450 : : 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2451 : : 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2452 : : 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2453 : : 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2454 : : 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2455 : : 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2456 : : 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2457 : : 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2458 : : 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2459 : : 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2460 : : 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2461 : : };
2462 : :
2463 : : static uint8_t ms_hmac_key2[] = {
2464 : : 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2465 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2466 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2467 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2468 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2469 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2470 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2471 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2472 : : };
2473 : :
2474 : : static const uint8_t ms_hmac_digest2[] = {
2475 : : 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2476 : : 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2477 : : 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2478 : : 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2479 : : 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2480 : : 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2481 : : 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2482 : : 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2483 : : };
2484 : :
2485 : : /* End Session 2 */
2486 : :
2487 : : #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
2488 : : static int
2489 : 1 : test_queue_pair_descriptor_count(void)
2490 : : {
2491 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2492 : : struct crypto_unittest_params *ut_params = &unittest_params;
2493 : 1 : struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
2494 : 1 : struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
2495 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2496 : : int qp_depth = 0;
2497 : : int i;
2498 : :
2499 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2500 : : return TEST_SKIPPED;
2501 : :
2502 : : /* Verify if the queue pair depth API is supported by driver */
2503 [ + - ]: 1 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2504 [ # # ]: 0 : if (qp_depth == -ENOTSUP)
2505 : 1 : return TEST_SKIPPED;
2506 : :
2507 : : /* Verify the capabilities */
2508 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2509 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2510 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2511 : : return TEST_SKIPPED;
2512 : :
2513 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2514 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2515 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2516 : : return TEST_SKIPPED;
2517 : :
2518 : : /* Setup Cipher Parameters */
2519 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2520 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2521 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2522 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2523 : 0 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2524 : 0 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2525 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2526 : 0 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2527 : :
2528 : : /* Setup HMAC Parameters */
2529 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2530 : 0 : ut_params->auth_xform.next = NULL;
2531 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2532 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2533 : 0 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2534 : 0 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2535 : 0 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2536 : :
2537 : 0 : rte_errno = 0;
2538 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
2539 : : &ut_params->cipher_xform, ts_params->session_mpool);
2540 [ # # ]: 0 : if (rte_errno == ENOTSUP)
2541 : : return TEST_SKIPPED;
2542 : :
2543 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2544 : :
2545 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
2546 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
2547 : : MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
2548 : :
2549 : : /* Generate crypto op data structure */
2550 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2551 : : struct rte_mbuf *m;
2552 : : uint8_t *digest;
2553 : :
2554 : : /* Generate test mbuf data and space for digest */
2555 : 0 : m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
2556 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
2557 : :
2558 : : digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
2559 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
2560 : :
2561 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
2562 : :
2563 : : /* set crypto operation source mbuf */
2564 : 0 : ops[i]->sym->m_src = m;
2565 : :
2566 : : /* Set crypto operation authentication parameters */
2567 : 0 : ops[i]->sym->auth.digest.data = digest;
2568 : 0 : ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
2569 : :
2570 : 0 : ops[i]->sym->auth.data.offset = 0;
2571 : 0 : ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
2572 : :
2573 : : /* Copy IV at the end of the crypto operation */
2574 : 0 : memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
2575 : : CIPHER_IV_LENGTH_AES_CBC);
2576 : :
2577 : : /* Set crypto operation cipher parameters */
2578 : 0 : ops[i]->sym->cipher.data.offset = 0;
2579 : 0 : ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
2580 : :
2581 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
2582 : : &ops[i], 1), 1, "Error enqueuing");
2583 : : }
2584 : :
2585 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2586 [ # # ]: 0 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2587 [ # # ]: 0 : TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
2588 : : "Crypto queue pair depth used does not match with inflight ops");
2589 : :
2590 : 0 : while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
2591 [ # # ]: 0 : &ops_deq[i], 1) == 0)
2592 : : rte_pause();
2593 : :
2594 [ # # ]: 0 : TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2595 : : "crypto op processing failed");
2596 : :
2597 : 0 : rte_pktmbuf_free(ops_deq[i]->sym->m_src);
2598 : 0 : rte_crypto_op_free(ops_deq[i]);
2599 : : }
2600 : :
2601 : : return TEST_SUCCESS;
2602 : : }
2603 : :
2604 : : static int
2605 : 2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2606 : : {
2607 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2608 : : struct crypto_unittest_params *ut_params = &unittest_params;
2609 : : /* Verify the capabilities */
2610 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2611 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2612 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2613 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2614 : : &cap_idx) == NULL)
2615 : : return TEST_SKIPPED;
2616 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2617 : 2 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2618 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2619 : : &cap_idx) == NULL)
2620 : : return TEST_SKIPPED;
2621 : :
2622 : : /* Generate test mbuf data and space for digest */
2623 : 2 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2624 : : catch_22_quote, QUOTE_512_BYTES, 0);
2625 : :
2626 : 2 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2627 : : DIGEST_BYTE_LENGTH_SHA1);
2628 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2629 : :
2630 : : /* Setup Cipher Parameters */
2631 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2632 : 2 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2633 : :
2634 : 2 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2635 : 2 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2636 : 2 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2637 : 2 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2638 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2639 : 2 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2640 : :
2641 : : /* Setup HMAC Parameters */
2642 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2643 : :
2644 : 2 : ut_params->auth_xform.next = NULL;
2645 : :
2646 : 2 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2647 : 2 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2648 : 2 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2649 : 2 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2650 : 2 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2651 : :
2652 : 2 : rte_errno = 0;
2653 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(
2654 : 2 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2655 : : ts_params->session_mpool);
2656 [ + - ]: 2 : if (rte_errno == ENOTSUP)
2657 : : return TEST_SKIPPED;
2658 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2659 : :
2660 : : /* Generate crypto op data structure */
2661 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2662 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2663 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
2664 : : "Failed to allocate symmetric crypto operation struct");
2665 : :
2666 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2667 : :
2668 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2669 : :
2670 : : /* set crypto operation source mbuf */
2671 : 2 : sym_op->m_src = ut_params->ibuf;
2672 : :
2673 : : /* Set crypto operation authentication parameters */
2674 : 2 : sym_op->auth.digest.data = ut_params->digest;
2675 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2676 : : ut_params->ibuf, QUOTE_512_BYTES);
2677 : :
2678 : 2 : sym_op->auth.data.offset = 0;
2679 : 2 : sym_op->auth.data.length = QUOTE_512_BYTES;
2680 : :
2681 : : /* Copy IV at the end of the crypto operation */
2682 [ - + ]: 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2683 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2684 : :
2685 : : /* Set crypto operation cipher parameters */
2686 : 2 : sym_op->cipher.data.offset = 0;
2687 : 2 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2688 : :
2689 : : /* Process crypto operation */
2690 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2691 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2692 : : ut_params->op);
2693 : : else
2694 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
2695 : : process_crypto_request(ts_params->valid_devs[0],
2696 : : ut_params->op),
2697 : : "failed to process sym crypto op");
2698 : :
2699 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2700 : : "crypto op processing failed");
2701 : :
2702 : : /* Validate obuf */
2703 : 2 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2704 : : uint8_t *);
2705 : :
2706 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2707 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2708 : : QUOTE_512_BYTES,
2709 : : "ciphertext data not as expected");
2710 : :
2711 : 2 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2712 : :
2713 [ + - - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2714 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2715 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2716 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2717 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2718 : : DIGEST_BYTE_LENGTH_SHA1,
2719 : : "Generated digest data not as expected");
2720 : :
2721 : : return TEST_SUCCESS;
2722 : : }
2723 : :
2724 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2725 : :
2726 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2727 : :
2728 : : static uint8_t hmac_sha512_key[] = {
2729 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2730 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2731 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2732 : : 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2733 : : 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2734 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2735 : : 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2736 : : 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2737 : :
2738 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2739 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2740 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2741 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2742 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2743 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2744 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2745 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2746 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2747 : :
2748 : :
2749 : :
2750 : : static int
2751 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2752 : : struct crypto_unittest_params *ut_params,
2753 : : uint8_t *cipher_key,
2754 : : uint8_t *hmac_key);
2755 : :
2756 : : static int
2757 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2758 : : struct crypto_unittest_params *ut_params,
2759 : : struct crypto_testsuite_params *ts_params,
2760 : : const uint8_t *cipher,
2761 : : const uint8_t *digest,
2762 : : const uint8_t *iv);
2763 : :
2764 : :
2765 : : static int
2766 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2767 : : struct crypto_unittest_params *ut_params,
2768 : : uint8_t *cipher_key,
2769 : : uint8_t *hmac_key)
2770 : : {
2771 : :
2772 : : /* Setup Cipher Parameters */
2773 : 4 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2774 : 4 : ut_params->cipher_xform.next = NULL;
2775 : :
2776 : 4 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2777 : 4 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2778 : 4 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2779 : 4 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2780 : 4 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2781 : 4 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2782 : :
2783 : : /* Setup HMAC Parameters */
2784 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2785 : 4 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2786 : :
2787 : 4 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2788 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2789 : 4 : ut_params->auth_xform.auth.key.data = hmac_key;
2790 : 4 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2791 : 4 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2792 : :
2793 : : return TEST_SUCCESS;
2794 : : }
2795 : :
2796 : :
2797 : : static int
2798 : 5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2799 : : struct crypto_unittest_params *ut_params,
2800 : : struct crypto_testsuite_params *ts_params,
2801 : : const uint8_t *cipher,
2802 : : const uint8_t *digest,
2803 : : const uint8_t *iv)
2804 : : {
2805 : : int ret;
2806 : :
2807 : : /* Generate test mbuf data and digest */
2808 : 5 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2809 : : (const char *)
2810 : : cipher,
2811 : : QUOTE_512_BYTES, 0);
2812 : :
2813 : 5 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2814 : : DIGEST_BYTE_LENGTH_SHA512);
2815 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2816 : :
2817 : : rte_memcpy(ut_params->digest,
2818 : : digest,
2819 : : DIGEST_BYTE_LENGTH_SHA512);
2820 : :
2821 : : /* Generate Crypto op data structure */
2822 : 5 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2823 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2824 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->op,
2825 : : "Failed to allocate symmetric crypto operation struct");
2826 : :
2827 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2828 : :
2829 : 5 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2830 : :
2831 : : /* set crypto operation source mbuf */
2832 : 5 : sym_op->m_src = ut_params->ibuf;
2833 : :
2834 : 5 : sym_op->auth.digest.data = ut_params->digest;
2835 [ - + ]: 5 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2836 : : ut_params->ibuf, QUOTE_512_BYTES);
2837 : :
2838 : 5 : sym_op->auth.data.offset = 0;
2839 : 5 : sym_op->auth.data.length = QUOTE_512_BYTES;
2840 : :
2841 : : /* Copy IV at the end of the crypto operation */
2842 [ - + ]: 5 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2843 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2844 : :
2845 : 5 : sym_op->cipher.data.offset = 0;
2846 : 5 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2847 : :
2848 : : /* Process crypto operation */
2849 [ - + ]: 5 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2850 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2851 : : ut_params->op);
2852 [ - + ]: 5 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2853 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2854 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2855 : : return ret;
2856 : : } else
2857 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(
2858 : : process_crypto_request(ts_params->valid_devs[0],
2859 : : ut_params->op),
2860 : : "failed to process sym crypto op");
2861 : :
2862 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2863 : : "crypto op processing failed");
2864 : :
2865 : 5 : ut_params->obuf = ut_params->op->sym->m_src;
2866 : :
2867 : : /* Validate obuf */
2868 [ - + ]: 5 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2869 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2870 : : catch_22_quote,
2871 : : QUOTE_512_BYTES,
2872 : : "Plaintext data not as expected");
2873 : :
2874 : : /* Validate obuf */
2875 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2876 : : "Digest verification failed");
2877 : :
2878 : : return TEST_SUCCESS;
2879 : : }
2880 : :
2881 : : /* ***** SNOW 3G Tests ***** */
2882 : : static int
2883 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2884 : : const uint8_t *key, const uint8_t key_len,
2885 : : const uint8_t iv_len, const uint8_t auth_len,
2886 : : enum rte_crypto_auth_operation op,
2887 : : enum rte_crypto_auth_algorithm algo)
2888 : : {
2889 : 0 : uint8_t *hash_key = alloca(key_len);
2890 : :
2891 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2892 : : struct crypto_unittest_params *ut_params = &unittest_params;
2893 : :
2894 : : memcpy(hash_key, key, key_len);
2895 : :
2896 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2897 : :
2898 : : /* Setup Authentication Parameters */
2899 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2900 : 0 : ut_params->auth_xform.next = NULL;
2901 : :
2902 : 0 : ut_params->auth_xform.auth.op = op;
2903 : 0 : ut_params->auth_xform.auth.algo = algo;
2904 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2905 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2906 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2907 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2908 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2909 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2910 : : &ut_params->auth_xform, ts_params->session_mpool);
2911 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2912 : : return TEST_SKIPPED;
2913 : :
2914 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2915 : : return 0;
2916 : : }
2917 : :
2918 : : static int
2919 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2920 : : enum rte_crypto_cipher_operation op,
2921 : : enum rte_crypto_cipher_algorithm algo,
2922 : : const uint8_t *key, const uint8_t key_len,
2923 : : uint8_t iv_len)
2924 : : {
2925 : 0 : uint8_t *cipher_key = alloca(key_len);
2926 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2927 : : struct crypto_unittest_params *ut_params = &unittest_params;
2928 : :
2929 : : memcpy(cipher_key, key, key_len);
2930 : :
2931 : : /* Setup Cipher Parameters */
2932 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2933 : 0 : ut_params->cipher_xform.next = NULL;
2934 : :
2935 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2936 : 0 : ut_params->cipher_xform.cipher.op = op;
2937 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2938 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2939 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2940 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2941 : :
2942 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2943 : :
2944 : : /* Create Crypto session */
2945 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2946 : : &ut_params->cipher_xform, ts_params->session_mpool);
2947 : :
2948 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2949 : : return TEST_SKIPPED;
2950 : :
2951 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2952 : : return 0;
2953 : : }
2954 : :
2955 : : static int
2956 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2957 : : unsigned int cipher_len,
2958 : : unsigned int cipher_offset)
2959 : : {
2960 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2961 : : struct crypto_unittest_params *ut_params = &unittest_params;
2962 : :
2963 : : /* Generate Crypto op data structure */
2964 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2965 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2966 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2967 : : "Failed to allocate pktmbuf offload");
2968 : :
2969 : : /* Set crypto operation data parameters */
2970 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2971 : :
2972 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2973 : :
2974 : : /* set crypto operation source mbuf */
2975 : 0 : sym_op->m_src = ut_params->ibuf;
2976 : :
2977 : : /* iv */
2978 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2979 : : iv, iv_len);
2980 : 0 : sym_op->cipher.data.length = cipher_len;
2981 : 0 : sym_op->cipher.data.offset = cipher_offset;
2982 : 0 : return 0;
2983 : : }
2984 : :
2985 : : static int
2986 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2987 : : unsigned int cipher_len,
2988 : : unsigned int cipher_offset)
2989 : : {
2990 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 : : struct crypto_unittest_params *ut_params = &unittest_params;
2992 : :
2993 : : /* Generate Crypto op data structure */
2994 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2995 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2996 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2997 : : "Failed to allocate pktmbuf offload");
2998 : :
2999 : : /* Set crypto operation data parameters */
3000 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3001 : :
3002 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3003 : :
3004 : : /* set crypto operation source mbuf */
3005 : 0 : sym_op->m_src = ut_params->ibuf;
3006 : 0 : sym_op->m_dst = ut_params->obuf;
3007 : :
3008 : : /* iv */
3009 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3010 : : iv, iv_len);
3011 : 0 : sym_op->cipher.data.length = cipher_len;
3012 : 0 : sym_op->cipher.data.offset = cipher_offset;
3013 : 0 : return 0;
3014 : : }
3015 : :
3016 : : static int
3017 : 1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
3018 : : enum rte_crypto_cipher_operation cipher_op,
3019 : : enum rte_crypto_auth_operation auth_op,
3020 : : enum rte_crypto_auth_algorithm auth_algo,
3021 : : enum rte_crypto_cipher_algorithm cipher_algo,
3022 : : const uint8_t *a_key, uint8_t a_key_len,
3023 : : const uint8_t *c_key, uint8_t c_key_len,
3024 : : uint8_t auth_iv_len, uint8_t auth_len,
3025 : : uint8_t cipher_iv_len)
3026 : :
3027 : : {
3028 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3029 : : struct crypto_unittest_params *ut_params = &unittest_params;
3030 : :
3031 : : /* Setup Authentication Parameters */
3032 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3033 : 1 : ut_params->auth_xform.next = NULL;
3034 : :
3035 : 1 : ut_params->auth_xform.auth.op = auth_op;
3036 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3037 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3038 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3039 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3040 : : /* Auth IV will be after cipher IV */
3041 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3042 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3043 : :
3044 : : /* Setup Cipher Parameters */
3045 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3046 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3047 : :
3048 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3049 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3050 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3051 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3052 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3053 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3054 : :
3055 : 1 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
3056 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3057 : :
3058 : : /* Create Crypto session*/
3059 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3060 : : &ut_params->cipher_xform, ts_params->session_mpool);
3061 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3062 : : return TEST_SKIPPED;
3063 : :
3064 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3065 : : return 0;
3066 : : }
3067 : :
3068 : : static int
3069 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
3070 : : enum rte_crypto_cipher_operation cipher_op,
3071 : : enum rte_crypto_auth_operation auth_op,
3072 : : enum rte_crypto_auth_algorithm auth_algo,
3073 : : enum rte_crypto_cipher_algorithm cipher_algo,
3074 : : const struct wireless_test_data *tdata)
3075 : : {
3076 : 0 : const uint8_t key_len = tdata->key.len;
3077 : 0 : uint8_t *cipher_auth_key = alloca(key_len);
3078 : :
3079 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3080 : : struct crypto_unittest_params *ut_params = &unittest_params;
3081 : 0 : const uint8_t *key = tdata->key.data;
3082 : 0 : const uint8_t auth_len = tdata->digest.len;
3083 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
3084 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
3085 : :
3086 : : memcpy(cipher_auth_key, key, key_len);
3087 : :
3088 : : /* Setup Authentication Parameters */
3089 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3090 : 0 : ut_params->auth_xform.next = NULL;
3091 : :
3092 : 0 : ut_params->auth_xform.auth.op = auth_op;
3093 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
3094 : 0 : ut_params->auth_xform.auth.key.length = key_len;
3095 : : /* Hash key = cipher key */
3096 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
3097 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
3098 : : /* Auth IV will be after cipher IV */
3099 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3100 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3101 : :
3102 : : /* Setup Cipher Parameters */
3103 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3104 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3105 : :
3106 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3107 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
3108 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
3109 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
3110 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3111 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3112 : :
3113 : :
3114 : 0 : debug_hexdump(stdout, "key:", key, key_len);
3115 : :
3116 : : /* Create Crypto session*/
3117 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3118 : : &ut_params->cipher_xform, ts_params->session_mpool);
3119 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3120 : : return TEST_SKIPPED;
3121 : :
3122 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3123 : : return 0;
3124 : : }
3125 : :
3126 : : static int
3127 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
3128 : : const struct wireless_test_data *tdata)
3129 : : {
3130 : 0 : return create_wireless_cipher_auth_session(dev_id,
3131 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3132 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
3133 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
3134 : : }
3135 : :
3136 : : static int
3137 : 1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
3138 : : enum rte_crypto_cipher_operation cipher_op,
3139 : : enum rte_crypto_auth_operation auth_op,
3140 : : enum rte_crypto_auth_algorithm auth_algo,
3141 : : enum rte_crypto_cipher_algorithm cipher_algo,
3142 : : const uint8_t *a_key, const uint8_t a_key_len,
3143 : : const uint8_t *c_key, const uint8_t c_key_len,
3144 : : uint8_t auth_iv_len, uint8_t auth_len,
3145 : : uint8_t cipher_iv_len)
3146 : : {
3147 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3148 : : struct crypto_unittest_params *ut_params = &unittest_params;
3149 : :
3150 : : /* Setup Authentication Parameters */
3151 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3152 : 1 : ut_params->auth_xform.auth.op = auth_op;
3153 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
3154 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3155 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3156 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3157 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3158 : : /* Auth IV will be after cipher IV */
3159 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3160 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3161 : :
3162 : : /* Setup Cipher Parameters */
3163 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3164 : 1 : ut_params->cipher_xform.next = NULL;
3165 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3166 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3167 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3168 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3169 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3170 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3171 : :
3172 : 1 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
3173 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3174 : :
3175 : : /* Create Crypto session*/
3176 [ - + ]: 1 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3177 : 0 : ut_params->auth_xform.next = NULL;
3178 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3179 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3180 : : &ut_params->cipher_xform, ts_params->session_mpool);
3181 : : } else
3182 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3183 : : &ut_params->auth_xform, ts_params->session_mpool);
3184 : :
3185 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3186 : : return TEST_SKIPPED;
3187 : :
3188 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3189 : :
3190 : : return 0;
3191 : : }
3192 : :
3193 : : static int
3194 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
3195 : : unsigned int auth_tag_len,
3196 : : const uint8_t *iv, unsigned int iv_len,
3197 : : unsigned int data_pad_len,
3198 : : enum rte_crypto_auth_operation op,
3199 : : unsigned int auth_len, unsigned int auth_offset)
3200 : : {
3201 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3202 : :
3203 : : struct crypto_unittest_params *ut_params = &unittest_params;
3204 : :
3205 : : /* Generate Crypto op data structure */
3206 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3207 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3208 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3209 : : "Failed to allocate pktmbuf offload");
3210 : :
3211 : : /* Set crypto operation data parameters */
3212 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3213 : :
3214 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3215 : :
3216 : : /* set crypto operation source mbuf */
3217 : 0 : sym_op->m_src = ut_params->ibuf;
3218 : :
3219 : : /* iv */
3220 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3221 : : iv, iv_len);
3222 : : /* digest */
3223 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3224 : : ut_params->ibuf, auth_tag_len);
3225 : :
3226 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3227 : : "no room to append auth tag");
3228 : 0 : ut_params->digest = sym_op->auth.digest.data;
3229 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3230 : : ut_params->ibuf, data_pad_len);
3231 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3232 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3233 : : else
3234 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3235 : :
3236 : 0 : debug_hexdump(stdout, "digest:",
3237 : 0 : sym_op->auth.digest.data,
3238 : : auth_tag_len);
3239 : :
3240 : 0 : sym_op->auth.data.length = auth_len;
3241 : 0 : sym_op->auth.data.offset = auth_offset;
3242 : :
3243 : 0 : return 0;
3244 : : }
3245 : :
3246 : : static int
3247 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3248 : : enum rte_crypto_auth_operation op)
3249 : : {
3250 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3251 : : struct crypto_unittest_params *ut_params = &unittest_params;
3252 : :
3253 : 0 : const uint8_t *auth_tag = tdata->digest.data;
3254 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
3255 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3256 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3257 : :
3258 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
3259 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3260 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
3261 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
3262 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3263 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
3264 : :
3265 : : /* Generate Crypto op data structure */
3266 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3267 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3268 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3269 : : "Failed to allocate pktmbuf offload");
3270 : : /* Set crypto operation data parameters */
3271 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3272 : :
3273 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3274 : :
3275 : : /* set crypto operation source mbuf */
3276 : 0 : sym_op->m_src = ut_params->ibuf;
3277 : :
3278 : : /* digest */
3279 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3280 : : ut_params->ibuf, auth_tag_len);
3281 : :
3282 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3283 : : "no room to append auth tag");
3284 : 0 : ut_params->digest = sym_op->auth.digest.data;
3285 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3286 : : ut_params->ibuf, data_pad_len);
3287 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3288 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3289 : : else
3290 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3291 : :
3292 : 0 : debug_hexdump(stdout, "digest:",
3293 : 0 : sym_op->auth.digest.data,
3294 : : auth_tag_len);
3295 : :
3296 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3297 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3298 : : IV_OFFSET);
3299 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3300 : 0 : iv_ptr += cipher_iv_len;
3301 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3302 : :
3303 : 0 : sym_op->cipher.data.length = cipher_len;
3304 : 0 : sym_op->cipher.data.offset = 0;
3305 : 0 : sym_op->auth.data.length = auth_len;
3306 : 0 : sym_op->auth.data.offset = 0;
3307 : :
3308 : 0 : return 0;
3309 : : }
3310 : :
3311 : : static int
3312 : : create_zuc_cipher_hash_generate_operation(
3313 : : const struct wireless_test_data *tdata)
3314 : : {
3315 : 0 : return create_wireless_cipher_hash_operation(tdata,
3316 : : RTE_CRYPTO_AUTH_OP_GENERATE);
3317 : : }
3318 : :
3319 : : static int
3320 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3321 : : const unsigned auth_tag_len,
3322 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3323 : : unsigned data_pad_len,
3324 : : enum rte_crypto_auth_operation op,
3325 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3326 : : const unsigned cipher_len, const unsigned cipher_offset,
3327 : : const unsigned auth_len, const unsigned auth_offset)
3328 : : {
3329 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3330 : : struct crypto_unittest_params *ut_params = &unittest_params;
3331 : :
3332 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
3333 : : ut_params->cipher_xform.cipher.algo;
3334 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3335 : : ut_params->auth_xform.auth.algo;
3336 : :
3337 : : /* Generate Crypto op data structure */
3338 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3339 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3340 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3341 : : "Failed to allocate pktmbuf offload");
3342 : : /* Set crypto operation data parameters */
3343 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3344 : :
3345 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3346 : :
3347 : : /* set crypto operation source mbuf */
3348 : 0 : sym_op->m_src = ut_params->ibuf;
3349 : :
3350 : : /* digest */
3351 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3352 : : ut_params->ibuf, auth_tag_len);
3353 : :
3354 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3355 : : "no room to append auth tag");
3356 : 0 : ut_params->digest = sym_op->auth.digest.data;
3357 : :
3358 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3359 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3360 : : ut_params->ibuf, data_pad_len);
3361 : : } else {
3362 : : struct rte_mbuf *m = ut_params->ibuf;
3363 : : unsigned int offset = data_pad_len;
3364 : :
3365 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3366 : 0 : offset -= m->data_len;
3367 : : m = m->next;
3368 : : }
3369 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3370 : : m, offset);
3371 : : }
3372 : :
3373 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3374 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3375 : : else
3376 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3377 : :
3378 : 0 : debug_hexdump(stdout, "digest:",
3379 : 0 : sym_op->auth.digest.data,
3380 : : auth_tag_len);
3381 : :
3382 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3383 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3384 : : IV_OFFSET);
3385 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3386 : 0 : iv_ptr += cipher_iv_len;
3387 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3388 : :
3389 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3390 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3391 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3392 : 0 : sym_op->cipher.data.length = cipher_len;
3393 : 0 : sym_op->cipher.data.offset = cipher_offset;
3394 : : } else {
3395 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3396 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3397 : : }
3398 : :
3399 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3400 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3401 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3402 : 0 : sym_op->auth.data.length = auth_len;
3403 : 0 : sym_op->auth.data.offset = auth_offset;
3404 : : } else {
3405 : 0 : sym_op->auth.data.length = auth_len >> 3;
3406 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3407 : : }
3408 : :
3409 : : return 0;
3410 : : }
3411 : :
3412 : : static int
3413 : 2 : create_wireless_algo_auth_cipher_operation(
3414 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3415 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3416 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3417 : : unsigned int data_pad_len,
3418 : : unsigned int cipher_len, unsigned int cipher_offset,
3419 : : unsigned int auth_len, unsigned int auth_offset,
3420 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3421 : : {
3422 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3423 : : struct crypto_unittest_params *ut_params = &unittest_params;
3424 : :
3425 : 2 : enum rte_crypto_cipher_algorithm cipher_algo =
3426 : : ut_params->cipher_xform.cipher.algo;
3427 : 2 : enum rte_crypto_auth_algorithm auth_algo =
3428 : : ut_params->auth_xform.auth.algo;
3429 : :
3430 : : /* Generate Crypto op data structure */
3431 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3432 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3433 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
3434 : : "Failed to allocate pktmbuf offload");
3435 : :
3436 : : /* Set crypto operation data parameters */
3437 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3438 : :
3439 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3440 : :
3441 : : /* set crypto operation mbufs */
3442 : 2 : sym_op->m_src = ut_params->ibuf;
3443 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE)
3444 : 0 : sym_op->m_dst = ut_params->obuf;
3445 : :
3446 : : /* digest */
3447 [ - + ]: 2 : if (!do_sgl) {
3448 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3449 : : (op_mode == IN_PLACE ?
3450 : : ut_params->ibuf : ut_params->obuf),
3451 : : uint8_t *, data_pad_len);
3452 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3453 : : (op_mode == IN_PLACE ?
3454 : : ut_params->ibuf : ut_params->obuf),
3455 : : data_pad_len);
3456 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3457 : : } else {
3458 : 2 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3459 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3460 [ - + ]: 2 : sym_op->m_src : sym_op->m_dst);
3461 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3462 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3463 : 30 : sgl_buf = sgl_buf->next;
3464 : : }
3465 : :
3466 : : /* The last segment should be large enough to hold full digest */
3467 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3468 : 0 : rte_pktmbuf_free(sgl_buf->next);
3469 : 0 : sgl_buf->next = NULL;
3470 [ # # # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3471 : : auth_tag_len - sgl_buf->data_len),
3472 : : "No room to append auth tag");
3473 : : }
3474 : :
3475 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3476 : : uint8_t *, remaining_off);
3477 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3478 : : remaining_off);
3479 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3480 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3481 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3482 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3483 : 0 : sgl_buf = sgl_buf->next;
3484 : : }
3485 : : }
3486 : :
3487 : : /* Copy digest for the verification */
3488 [ + + ]: 2 : if (verify)
3489 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3490 : :
3491 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3492 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3493 : : ut_params->op, uint8_t *, IV_OFFSET);
3494 : :
3495 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3496 : 2 : iv_ptr += cipher_iv_len;
3497 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3498 : :
3499 : : /* Only copy over the offset data needed from src to dst in OOP,
3500 : : * if the auth and cipher offsets are not aligned
3501 : : */
3502 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3503 [ # # ]: 0 : if (cipher_offset > auth_offset)
3504 : 0 : rte_memcpy(
3505 : 0 : rte_pktmbuf_mtod_offset(
3506 : : sym_op->m_dst,
3507 : : uint8_t *, auth_offset >> 3),
3508 : 0 : rte_pktmbuf_mtod_offset(
3509 : : sym_op->m_src,
3510 : : uint8_t *, auth_offset >> 3),
3511 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3512 : : }
3513 : :
3514 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3515 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3516 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3517 : 0 : sym_op->cipher.data.length = cipher_len;
3518 : 0 : sym_op->cipher.data.offset = cipher_offset;
3519 : : } else {
3520 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3521 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3522 : : }
3523 : :
3524 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3525 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3526 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3527 : 0 : sym_op->auth.data.length = auth_len;
3528 : 0 : sym_op->auth.data.offset = auth_offset;
3529 : : } else {
3530 : 2 : sym_op->auth.data.length = auth_len >> 3;
3531 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3532 : : }
3533 : :
3534 : : return 0;
3535 : : }
3536 : :
3537 : : static int
3538 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3539 : : {
3540 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3541 : : struct crypto_unittest_params *ut_params = &unittest_params;
3542 : :
3543 : : int retval;
3544 : : unsigned plaintext_pad_len;
3545 : : unsigned plaintext_len;
3546 : : uint8_t *plaintext;
3547 : : struct rte_cryptodev_info dev_info;
3548 : :
3549 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3550 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3551 : :
3552 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3553 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3554 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3555 : 0 : return TEST_SKIPPED;
3556 : : }
3557 : :
3558 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3559 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3560 : : printf("Device doesn't support RAW data-path APIs.\n");
3561 : 0 : return TEST_SKIPPED;
3562 : : }
3563 : :
3564 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3565 : : return TEST_SKIPPED;
3566 : :
3567 : : /* Verify the capabilities */
3568 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3569 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3570 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3571 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3572 : : &cap_idx) == NULL)
3573 : : return TEST_SKIPPED;
3574 : :
3575 : : /* Create SNOW 3G session */
3576 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3577 : 0 : tdata->key.data, tdata->key.len,
3578 : 0 : tdata->auth_iv.len, tdata->digest.len,
3579 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3580 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3581 [ # # ]: 0 : if (retval < 0)
3582 : : return retval;
3583 : :
3584 : : /* alloc mbuf and set payload */
3585 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3586 : :
3587 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3588 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3589 : :
3590 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3591 : : /* Append data which is padded to a multiple of */
3592 : : /* the algorithms block size */
3593 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3594 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3595 : : plaintext_pad_len);
3596 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3597 : :
3598 : : /* Create SNOW 3G operation */
3599 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3600 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3601 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3602 : 0 : tdata->validAuthLenInBits.len,
3603 : : 0);
3604 [ # # ]: 0 : if (retval < 0)
3605 : : return retval;
3606 : :
3607 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3608 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3609 : : 0);
3610 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3611 : : return retval;
3612 : : } else
3613 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3614 : : ut_params->op);
3615 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3616 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3617 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3618 : : uint8_t *,
3619 : : plaintext_pad_len);
3620 : :
3621 : : /* Validate obuf */
3622 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3623 : : ut_params->digest,
3624 : : tdata->digest.data,
3625 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3626 : : "SNOW 3G Generated auth tag not as expected");
3627 : :
3628 : : return 0;
3629 : : }
3630 : :
3631 : : static int
3632 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3633 : : {
3634 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3635 : : struct crypto_unittest_params *ut_params = &unittest_params;
3636 : :
3637 : : int retval;
3638 : : unsigned plaintext_pad_len;
3639 : : unsigned plaintext_len;
3640 : : uint8_t *plaintext;
3641 : : struct rte_cryptodev_info dev_info;
3642 : :
3643 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3644 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3645 : :
3646 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3647 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3648 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3649 : 0 : return TEST_SKIPPED;
3650 : : }
3651 : :
3652 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3653 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3654 : : printf("Device doesn't support RAW data-path APIs.\n");
3655 : 0 : return TEST_SKIPPED;
3656 : : }
3657 : :
3658 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3659 : : return TEST_SKIPPED;
3660 : :
3661 : : /* Verify the capabilities */
3662 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3663 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3664 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3665 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3666 : : &cap_idx) == NULL)
3667 : : return TEST_SKIPPED;
3668 : :
3669 : : /* Create SNOW 3G session */
3670 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3671 : 0 : tdata->key.data, tdata->key.len,
3672 : 0 : tdata->auth_iv.len, tdata->digest.len,
3673 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3674 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3675 [ # # ]: 0 : if (retval < 0)
3676 : : return retval;
3677 : : /* alloc mbuf and set payload */
3678 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3679 : :
3680 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3681 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3682 : :
3683 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3684 : : /* Append data which is padded to a multiple of */
3685 : : /* the algorithms block size */
3686 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3687 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3688 : : plaintext_pad_len);
3689 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3690 : :
3691 : : /* Create SNOW 3G operation */
3692 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3693 : 0 : tdata->digest.len,
3694 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3695 : : plaintext_pad_len,
3696 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3697 : 0 : tdata->validAuthLenInBits.len,
3698 : : 0);
3699 [ # # ]: 0 : if (retval < 0)
3700 : : return retval;
3701 : :
3702 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3703 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3704 : : 0);
3705 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3706 : : return retval;
3707 : : } else
3708 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3709 : : ut_params->op);
3710 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3711 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3712 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3713 : : uint8_t *,
3714 : : plaintext_pad_len);
3715 : :
3716 : : /* Validate obuf */
3717 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3718 : : return 0;
3719 : : else
3720 : 0 : return -1;
3721 : :
3722 : : return 0;
3723 : : }
3724 : :
3725 : : static int
3726 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3727 : : {
3728 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3729 : : struct crypto_unittest_params *ut_params = &unittest_params;
3730 : :
3731 : : int retval;
3732 : : unsigned plaintext_pad_len;
3733 : : unsigned plaintext_len;
3734 : : uint8_t *plaintext;
3735 : : struct rte_cryptodev_info dev_info;
3736 : :
3737 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3738 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3739 : :
3740 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3741 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3742 : : printf("Device doesn't support RAW data-path APIs.\n");
3743 : 0 : return TEST_SKIPPED;
3744 : : }
3745 : :
3746 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3747 : : return TEST_SKIPPED;
3748 : :
3749 : : /* Verify the capabilities */
3750 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3751 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3752 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3753 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3754 : : &cap_idx) == NULL)
3755 : : return TEST_SKIPPED;
3756 : :
3757 : : /* Create KASUMI session */
3758 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3759 : 0 : tdata->key.data, tdata->key.len,
3760 : 0 : 0, tdata->digest.len,
3761 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3762 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3763 [ # # ]: 0 : if (retval < 0)
3764 : : return retval;
3765 : :
3766 : : /* alloc mbuf and set payload */
3767 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3768 : :
3769 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3770 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3771 : :
3772 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3773 : : /* Append data which is padded to a multiple of */
3774 : : /* the algorithms block size */
3775 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3776 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3777 : : plaintext_pad_len);
3778 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3779 : :
3780 : : /* Create KASUMI operation */
3781 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3782 : : NULL, 0,
3783 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3784 : 0 : tdata->plaintext.len,
3785 : : 0);
3786 [ # # ]: 0 : if (retval < 0)
3787 : : return retval;
3788 : :
3789 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3790 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3791 : : ut_params->op);
3792 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3793 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3794 : : 0);
3795 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3796 : : return retval;
3797 : : } else
3798 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3799 : : ut_params->op);
3800 : :
3801 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3802 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3803 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3804 : : uint8_t *,
3805 : : plaintext_pad_len);
3806 : :
3807 : : /* Validate obuf */
3808 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3809 : : ut_params->digest,
3810 : : tdata->digest.data,
3811 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3812 : : "KASUMI Generated auth tag not as expected");
3813 : :
3814 : : return 0;
3815 : : }
3816 : :
3817 : : static int
3818 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3819 : : {
3820 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3821 : : struct crypto_unittest_params *ut_params = &unittest_params;
3822 : :
3823 : : int retval;
3824 : : unsigned plaintext_pad_len;
3825 : : unsigned plaintext_len;
3826 : : uint8_t *plaintext;
3827 : : struct rte_cryptodev_info dev_info;
3828 : :
3829 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3830 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3831 : :
3832 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3833 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3834 : : printf("Device doesn't support RAW data-path APIs.\n");
3835 : 0 : return TEST_SKIPPED;
3836 : : }
3837 : :
3838 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3839 : : return TEST_SKIPPED;
3840 : :
3841 : : /* Verify the capabilities */
3842 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3843 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3844 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3845 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3846 : : &cap_idx) == NULL)
3847 : : return TEST_SKIPPED;
3848 : :
3849 : : /* Create KASUMI session */
3850 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3851 : 0 : tdata->key.data, tdata->key.len,
3852 : 0 : 0, tdata->digest.len,
3853 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3854 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3855 [ # # ]: 0 : if (retval < 0)
3856 : : return retval;
3857 : : /* alloc mbuf and set payload */
3858 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3859 : :
3860 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3861 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3862 : :
3863 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3864 : : /* Append data which is padded to a multiple */
3865 : : /* of the algorithms block size */
3866 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3867 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3868 : : plaintext_pad_len);
3869 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3870 : :
3871 : : /* Create KASUMI operation */
3872 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3873 : 0 : tdata->digest.len,
3874 : : NULL, 0,
3875 : : plaintext_pad_len,
3876 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3877 : 0 : tdata->plaintext.len,
3878 : : 0);
3879 [ # # ]: 0 : if (retval < 0)
3880 : : return retval;
3881 : :
3882 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3883 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3884 : : 0);
3885 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3886 : : return retval;
3887 : : } else
3888 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3889 : : ut_params->op);
3890 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3891 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3892 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3893 : : uint8_t *,
3894 : : plaintext_pad_len);
3895 : :
3896 : : /* Validate obuf */
3897 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3898 : : return 0;
3899 : : else
3900 : 0 : return -1;
3901 : :
3902 : : return 0;
3903 : : }
3904 : :
3905 : : static int
3906 : 0 : test_snow3g_hash_generate_test_case_1(void)
3907 : : {
3908 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3909 : : }
3910 : :
3911 : : static int
3912 : 0 : test_snow3g_hash_generate_test_case_2(void)
3913 : : {
3914 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3915 : : }
3916 : :
3917 : : static int
3918 : 0 : test_snow3g_hash_generate_test_case_3(void)
3919 : : {
3920 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3921 : : }
3922 : :
3923 : : static int
3924 : 0 : test_snow3g_hash_generate_test_case_4(void)
3925 : : {
3926 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3927 : : }
3928 : :
3929 : : static int
3930 : 0 : test_snow3g_hash_generate_test_case_5(void)
3931 : : {
3932 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3933 : : }
3934 : :
3935 : : static int
3936 : 0 : test_snow3g_hash_generate_test_case_6(void)
3937 : : {
3938 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3939 : : }
3940 : :
3941 : : static int
3942 : 0 : test_snow3g_hash_verify_test_case_1(void)
3943 : : {
3944 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3945 : :
3946 : : }
3947 : :
3948 : : static int
3949 : 0 : test_snow3g_hash_verify_test_case_2(void)
3950 : : {
3951 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3952 : : }
3953 : :
3954 : : static int
3955 : 0 : test_snow3g_hash_verify_test_case_3(void)
3956 : : {
3957 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3958 : : }
3959 : :
3960 : : static int
3961 : 0 : test_snow3g_hash_verify_test_case_4(void)
3962 : : {
3963 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3964 : : }
3965 : :
3966 : : static int
3967 : 0 : test_snow3g_hash_verify_test_case_5(void)
3968 : : {
3969 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3970 : : }
3971 : :
3972 : : static int
3973 : 0 : test_snow3g_hash_verify_test_case_6(void)
3974 : : {
3975 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3976 : : }
3977 : :
3978 : : static int
3979 : 0 : test_kasumi_hash_generate_test_case_1(void)
3980 : : {
3981 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
3982 : : }
3983 : :
3984 : : static int
3985 : 0 : test_kasumi_hash_generate_test_case_2(void)
3986 : : {
3987 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
3988 : : }
3989 : :
3990 : : static int
3991 : 0 : test_kasumi_hash_generate_test_case_3(void)
3992 : : {
3993 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
3994 : : }
3995 : :
3996 : : static int
3997 : 0 : test_kasumi_hash_generate_test_case_4(void)
3998 : : {
3999 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
4000 : : }
4001 : :
4002 : : static int
4003 : 0 : test_kasumi_hash_generate_test_case_5(void)
4004 : : {
4005 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
4006 : : }
4007 : :
4008 : : static int
4009 : 0 : test_kasumi_hash_generate_test_case_6(void)
4010 : : {
4011 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
4012 : : }
4013 : :
4014 : : static int
4015 : 0 : test_kasumi_hash_verify_test_case_1(void)
4016 : : {
4017 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
4018 : : }
4019 : :
4020 : : static int
4021 : 0 : test_kasumi_hash_verify_test_case_2(void)
4022 : : {
4023 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
4024 : : }
4025 : :
4026 : : static int
4027 : 0 : test_kasumi_hash_verify_test_case_3(void)
4028 : : {
4029 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
4030 : : }
4031 : :
4032 : : static int
4033 : 0 : test_kasumi_hash_verify_test_case_4(void)
4034 : : {
4035 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
4036 : : }
4037 : :
4038 : : static int
4039 : 0 : test_kasumi_hash_verify_test_case_5(void)
4040 : : {
4041 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
4042 : : }
4043 : :
4044 : : static int
4045 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
4046 : : {
4047 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4048 : : struct crypto_unittest_params *ut_params = &unittest_params;
4049 : :
4050 : : int retval;
4051 : : uint8_t *plaintext, *ciphertext;
4052 : : unsigned plaintext_pad_len;
4053 : : unsigned plaintext_len;
4054 : : struct rte_cryptodev_info dev_info;
4055 : :
4056 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4057 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4058 : :
4059 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4060 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4061 : : printf("Device doesn't support RAW data-path APIs.\n");
4062 : 0 : return TEST_SKIPPED;
4063 : : }
4064 : :
4065 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4066 : : return TEST_SKIPPED;
4067 : :
4068 : : /* Verify the capabilities */
4069 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4070 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4071 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4072 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4073 : : &cap_idx) == NULL)
4074 : : return TEST_SKIPPED;
4075 : :
4076 : : /* Create KASUMI session */
4077 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4078 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4079 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4080 : 0 : tdata->key.data, tdata->key.len,
4081 : 0 : tdata->cipher_iv.len);
4082 [ # # ]: 0 : if (retval < 0)
4083 : : return retval;
4084 : :
4085 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4086 : :
4087 : : /* Clear mbuf payload */
4088 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4089 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4090 : :
4091 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4092 : : /* Append data which is padded to a multiple */
4093 : : /* of the algorithms block size */
4094 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4095 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4096 : : plaintext_pad_len);
4097 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4098 : :
4099 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4100 : :
4101 : : /* Create KASUMI operation */
4102 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4103 : 0 : tdata->cipher_iv.len,
4104 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4105 : 0 : tdata->validCipherOffsetInBits.len);
4106 [ # # ]: 0 : if (retval < 0)
4107 : : return retval;
4108 : :
4109 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4110 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4111 : 0 : tdata->cipher_iv.len);
4112 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4113 : : return retval;
4114 : : } else
4115 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4116 : : ut_params->op);
4117 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4118 : :
4119 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4120 [ # # ]: 0 : if (ut_params->obuf)
4121 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4122 : : else
4123 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4124 : :
4125 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4126 : :
4127 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4128 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4129 : : /* Validate obuf */
4130 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4131 : : ciphertext,
4132 : : reference_ciphertext,
4133 : : tdata->validCipherLenInBits.len,
4134 : : "KASUMI Ciphertext data not as expected");
4135 : : return 0;
4136 : : }
4137 : :
4138 : : static int
4139 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4140 : : {
4141 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4142 : : struct crypto_unittest_params *ut_params = &unittest_params;
4143 : :
4144 : : int retval;
4145 : :
4146 : : unsigned int plaintext_pad_len;
4147 : : unsigned int plaintext_len;
4148 : :
4149 : : uint8_t buffer[10000];
4150 : : const uint8_t *ciphertext;
4151 : :
4152 : : struct rte_cryptodev_info dev_info;
4153 : :
4154 : : /* Verify the capabilities */
4155 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4156 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4157 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4158 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4159 : : &cap_idx) == NULL)
4160 : : return TEST_SKIPPED;
4161 : :
4162 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4163 : :
4164 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4165 : :
4166 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4167 : : printf("Device doesn't support in-place scatter-gather. "
4168 : : "Test Skipped.\n");
4169 : 0 : return TEST_SKIPPED;
4170 : : }
4171 : :
4172 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4173 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4174 : : printf("Device doesn't support RAW data-path APIs.\n");
4175 : 0 : return TEST_SKIPPED;
4176 : : }
4177 : :
4178 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4179 : : return TEST_SKIPPED;
4180 : :
4181 : : /* Create KASUMI session */
4182 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4183 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4184 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4185 : 0 : tdata->key.data, tdata->key.len,
4186 : 0 : tdata->cipher_iv.len);
4187 [ # # ]: 0 : if (retval < 0)
4188 : : return retval;
4189 : :
4190 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4191 : :
4192 : :
4193 : : /* Append data which is padded to a multiple */
4194 : : /* of the algorithms block size */
4195 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4196 : :
4197 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4198 : : plaintext_pad_len, 10, 0);
4199 : :
4200 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4201 : :
4202 : : /* Create KASUMI operation */
4203 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4204 : 0 : tdata->cipher_iv.len,
4205 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4206 : 0 : tdata->validCipherOffsetInBits.len);
4207 [ # # ]: 0 : if (retval < 0)
4208 : : return retval;
4209 : :
4210 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4211 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4212 : 0 : tdata->cipher_iv.len);
4213 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4214 : : return retval;
4215 : : } else
4216 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4217 : : ut_params->op);
4218 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4219 : :
4220 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4221 : :
4222 [ # # ]: 0 : if (ut_params->obuf)
4223 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4224 : : plaintext_len, buffer);
4225 : : else
4226 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4227 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4228 : : plaintext_len, buffer);
4229 : :
4230 : : /* Validate obuf */
4231 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4232 : :
4233 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4234 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4235 : : /* Validate obuf */
4236 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4237 : : ciphertext,
4238 : : reference_ciphertext,
4239 : : tdata->validCipherLenInBits.len,
4240 : : "KASUMI Ciphertext data not as expected");
4241 : : return 0;
4242 : : }
4243 : :
4244 : : static int
4245 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4246 : : {
4247 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4248 : : struct crypto_unittest_params *ut_params = &unittest_params;
4249 : :
4250 : : int retval;
4251 : : uint8_t *plaintext, *ciphertext;
4252 : : unsigned plaintext_pad_len;
4253 : : unsigned plaintext_len;
4254 : :
4255 : : /* Verify the capabilities */
4256 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4257 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4258 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4259 : : /* Data-path service does not support OOP */
4260 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4261 : : &cap_idx) == NULL)
4262 : : return TEST_SKIPPED;
4263 : :
4264 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4265 : : return TEST_SKIPPED;
4266 : :
4267 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4268 : : return TEST_SKIPPED;
4269 : :
4270 : : /* Create KASUMI session */
4271 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4272 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4273 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4274 : 0 : tdata->key.data, tdata->key.len,
4275 : 0 : tdata->cipher_iv.len);
4276 [ # # ]: 0 : if (retval < 0)
4277 : : return retval;
4278 : :
4279 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4280 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4281 : :
4282 : : /* Clear mbuf payload */
4283 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4284 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4285 : :
4286 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4287 : : /* Append data which is padded to a multiple */
4288 : : /* of the algorithms block size */
4289 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4290 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4291 : : plaintext_pad_len);
4292 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4293 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4294 : :
4295 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4296 : :
4297 : : /* Create KASUMI operation */
4298 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4299 : 0 : tdata->cipher_iv.len,
4300 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4301 : 0 : tdata->validCipherOffsetInBits.len);
4302 [ # # ]: 0 : if (retval < 0)
4303 : : return retval;
4304 : :
4305 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4306 : : ut_params->op);
4307 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4308 : :
4309 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4310 [ # # ]: 0 : if (ut_params->obuf)
4311 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4312 : : else
4313 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4314 : :
4315 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4316 : :
4317 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4318 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4319 : : /* Validate obuf */
4320 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4321 : : ciphertext,
4322 : : reference_ciphertext,
4323 : : tdata->validCipherLenInBits.len,
4324 : : "KASUMI Ciphertext data not as expected");
4325 : : return 0;
4326 : : }
4327 : :
4328 : : static int
4329 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4330 : : {
4331 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4332 : : struct crypto_unittest_params *ut_params = &unittest_params;
4333 : :
4334 : : int retval;
4335 : : unsigned int plaintext_pad_len;
4336 : : unsigned int plaintext_len;
4337 : :
4338 : : const uint8_t *ciphertext;
4339 : : uint8_t buffer[2048];
4340 : :
4341 : : struct rte_cryptodev_info dev_info;
4342 : :
4343 : : /* Verify the capabilities */
4344 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4345 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4346 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4347 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4348 : : &cap_idx) == NULL)
4349 : : return TEST_SKIPPED;
4350 : :
4351 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4352 : : return TEST_SKIPPED;
4353 : :
4354 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4355 : : return TEST_SKIPPED;
4356 : :
4357 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4358 : :
4359 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4360 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4361 : : printf("Device doesn't support out-of-place scatter-gather "
4362 : : "in both input and output mbufs. "
4363 : : "Test Skipped.\n");
4364 : 0 : return TEST_SKIPPED;
4365 : : }
4366 : :
4367 : : /* Create KASUMI session */
4368 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4369 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4370 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4371 : 0 : tdata->key.data, tdata->key.len,
4372 : 0 : tdata->cipher_iv.len);
4373 [ # # ]: 0 : if (retval < 0)
4374 : : return retval;
4375 : :
4376 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4377 : : /* Append data which is padded to a multiple */
4378 : : /* of the algorithms block size */
4379 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4380 : :
4381 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4382 : : plaintext_pad_len, 10, 0);
4383 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4384 : : plaintext_pad_len, 3, 0);
4385 : :
4386 : : /* Append data which is padded to a multiple */
4387 : : /* of the algorithms block size */
4388 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4389 : :
4390 : : /* Create KASUMI operation */
4391 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4392 : 0 : tdata->cipher_iv.len,
4393 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4394 : 0 : tdata->validCipherOffsetInBits.len);
4395 [ # # ]: 0 : if (retval < 0)
4396 : : return retval;
4397 : :
4398 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4399 : : ut_params->op);
4400 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4401 : :
4402 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4403 [ # # ]: 0 : if (ut_params->obuf)
4404 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4405 : : plaintext_pad_len, buffer);
4406 : : else
4407 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4408 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4409 : : plaintext_pad_len, buffer);
4410 : :
4411 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4412 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4413 : : /* Validate obuf */
4414 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4415 : : ciphertext,
4416 : : reference_ciphertext,
4417 : : tdata->validCipherLenInBits.len,
4418 : : "KASUMI Ciphertext data not as expected");
4419 : : return 0;
4420 : : }
4421 : :
4422 : :
4423 : : static int
4424 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4425 : : {
4426 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4427 : : struct crypto_unittest_params *ut_params = &unittest_params;
4428 : :
4429 : : int retval;
4430 : : uint8_t *ciphertext, *plaintext;
4431 : : unsigned ciphertext_pad_len;
4432 : : unsigned ciphertext_len;
4433 : :
4434 : : /* Verify the capabilities */
4435 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4436 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4437 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4438 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4439 : : &cap_idx) == NULL)
4440 : : return TEST_SKIPPED;
4441 : :
4442 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4443 : : return TEST_SKIPPED;
4444 : :
4445 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4446 : : return TEST_SKIPPED;
4447 : :
4448 : : /* Create KASUMI session */
4449 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4450 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4451 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4452 : 0 : tdata->key.data, tdata->key.len,
4453 : 0 : tdata->cipher_iv.len);
4454 [ # # ]: 0 : if (retval < 0)
4455 : : return retval;
4456 : :
4457 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4458 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4459 : :
4460 : : /* Clear mbuf payload */
4461 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4462 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4463 : :
4464 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4465 : : /* Append data which is padded to a multiple */
4466 : : /* of the algorithms block size */
4467 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4468 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4469 : : ciphertext_pad_len);
4470 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4471 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4472 : :
4473 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4474 : :
4475 : : /* Create KASUMI operation */
4476 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4477 : 0 : tdata->cipher_iv.len,
4478 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4479 : 0 : tdata->validCipherOffsetInBits.len);
4480 [ # # ]: 0 : if (retval < 0)
4481 : : return retval;
4482 : :
4483 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4484 : : ut_params->op);
4485 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4486 : :
4487 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4488 [ # # ]: 0 : if (ut_params->obuf)
4489 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4490 : : else
4491 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4492 : :
4493 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4494 : :
4495 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4496 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4497 : : /* Validate obuf */
4498 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4499 : : plaintext,
4500 : : reference_plaintext,
4501 : : tdata->validCipherLenInBits.len,
4502 : : "KASUMI Plaintext data not as expected");
4503 : : return 0;
4504 : : }
4505 : :
4506 : : static int
4507 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4508 : : {
4509 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4510 : : struct crypto_unittest_params *ut_params = &unittest_params;
4511 : :
4512 : : int retval;
4513 : : uint8_t *ciphertext, *plaintext;
4514 : : unsigned ciphertext_pad_len;
4515 : : unsigned ciphertext_len;
4516 : : struct rte_cryptodev_info dev_info;
4517 : :
4518 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4519 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4520 : :
4521 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4522 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4523 : : printf("Device doesn't support RAW data-path APIs.\n");
4524 : 0 : return TEST_SKIPPED;
4525 : : }
4526 : :
4527 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4528 : : return TEST_SKIPPED;
4529 : :
4530 : : /* Verify the capabilities */
4531 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4532 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4533 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4534 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4535 : : &cap_idx) == NULL)
4536 : : return TEST_SKIPPED;
4537 : :
4538 : : /* Create KASUMI session */
4539 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4540 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4541 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4542 : 0 : tdata->key.data, tdata->key.len,
4543 : 0 : tdata->cipher_iv.len);
4544 [ # # ]: 0 : if (retval < 0)
4545 : : return retval;
4546 : :
4547 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4548 : :
4549 : : /* Clear mbuf payload */
4550 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4551 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4552 : :
4553 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4554 : : /* Append data which is padded to a multiple */
4555 : : /* of the algorithms block size */
4556 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4557 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4558 : : ciphertext_pad_len);
4559 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4560 : :
4561 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4562 : :
4563 : : /* Create KASUMI operation */
4564 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4565 : 0 : tdata->cipher_iv.len,
4566 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4567 : 0 : tdata->validCipherOffsetInBits.len);
4568 [ # # ]: 0 : if (retval < 0)
4569 : : return retval;
4570 : :
4571 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4572 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4573 : : 0);
4574 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4575 : : return retval;
4576 : : } else
4577 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4578 : : ut_params->op);
4579 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4580 : :
4581 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4582 [ # # ]: 0 : if (ut_params->obuf)
4583 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4584 : : else
4585 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4586 : :
4587 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4588 : :
4589 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4590 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4591 : : /* Validate obuf */
4592 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4593 : : plaintext,
4594 : : reference_plaintext,
4595 : : tdata->validCipherLenInBits.len,
4596 : : "KASUMI Plaintext data not as expected");
4597 : : return 0;
4598 : : }
4599 : :
4600 : : static int
4601 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4602 : : {
4603 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4604 : : struct crypto_unittest_params *ut_params = &unittest_params;
4605 : :
4606 : : int retval;
4607 : : uint8_t *plaintext, *ciphertext;
4608 : : unsigned plaintext_pad_len;
4609 : : unsigned plaintext_len;
4610 : : struct rte_cryptodev_info dev_info;
4611 : :
4612 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4613 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4614 : :
4615 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4616 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4617 : : printf("Device doesn't support RAW data-path APIs.\n");
4618 : 0 : return TEST_SKIPPED;
4619 : : }
4620 : :
4621 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4622 : : return TEST_SKIPPED;
4623 : :
4624 : : /* Verify the capabilities */
4625 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4626 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4627 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4628 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4629 : : &cap_idx) == NULL)
4630 : : return TEST_SKIPPED;
4631 : :
4632 : : /* Create SNOW 3G session */
4633 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4634 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4635 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4636 : 0 : tdata->key.data, tdata->key.len,
4637 : 0 : tdata->cipher_iv.len);
4638 [ # # ]: 0 : if (retval < 0)
4639 : : return retval;
4640 : :
4641 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4642 : :
4643 : : /* Clear mbuf payload */
4644 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4645 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4646 : :
4647 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4648 : : /* Append data which is padded to a multiple of */
4649 : : /* the algorithms block size */
4650 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4651 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4652 : : plaintext_pad_len);
4653 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4654 : :
4655 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4656 : :
4657 : : /* Create SNOW 3G operation */
4658 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4659 : 0 : tdata->cipher_iv.len,
4660 : 0 : tdata->validCipherLenInBits.len,
4661 : : 0);
4662 [ # # ]: 0 : if (retval < 0)
4663 : : return retval;
4664 : :
4665 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4666 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4667 : 0 : tdata->cipher_iv.len);
4668 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4669 : : return retval;
4670 : : } else
4671 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4672 : : ut_params->op);
4673 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4674 : :
4675 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4676 [ # # ]: 0 : if (ut_params->obuf)
4677 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4678 : : else
4679 : : ciphertext = plaintext;
4680 : :
4681 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4682 : :
4683 : : /* Validate obuf */
4684 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4685 : : ciphertext,
4686 : : tdata->ciphertext.data,
4687 : : tdata->validDataLenInBits.len,
4688 : : "SNOW 3G Ciphertext data not as expected");
4689 : : return 0;
4690 : : }
4691 : :
4692 : :
4693 : : static int
4694 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4695 : : {
4696 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4697 : : struct crypto_unittest_params *ut_params = &unittest_params;
4698 : : uint8_t *plaintext, *ciphertext;
4699 : :
4700 : : int retval;
4701 : : unsigned plaintext_pad_len;
4702 : : unsigned plaintext_len;
4703 : : struct rte_cryptodev_info dev_info;
4704 : :
4705 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4706 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4707 : :
4708 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4709 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4710 : : printf("Device does not support RAW data-path APIs.\n");
4711 : 0 : return -ENOTSUP;
4712 : : }
4713 : :
4714 : : /* Verify the capabilities */
4715 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4716 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4717 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4718 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4719 : : &cap_idx) == NULL)
4720 : : return TEST_SKIPPED;
4721 : :
4722 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4723 : : return TEST_SKIPPED;
4724 : :
4725 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4726 : : return TEST_SKIPPED;
4727 : :
4728 : : /* Create SNOW 3G session */
4729 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4730 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4731 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4732 : 0 : tdata->key.data, tdata->key.len,
4733 : 0 : tdata->cipher_iv.len);
4734 [ # # ]: 0 : if (retval < 0)
4735 : : return retval;
4736 : :
4737 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4738 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4739 : :
4740 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4741 : : "Failed to allocate input buffer in mempool");
4742 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4743 : : "Failed to allocate output buffer in mempool");
4744 : :
4745 : : /* Clear mbuf payload */
4746 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4747 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4748 : :
4749 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4750 : : /* Append data which is padded to a multiple of */
4751 : : /* the algorithms block size */
4752 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4753 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4754 : : plaintext_pad_len);
4755 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4756 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4757 : :
4758 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4759 : :
4760 : : /* Create SNOW 3G operation */
4761 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4762 : 0 : tdata->cipher_iv.len,
4763 : 0 : tdata->validCipherLenInBits.len,
4764 : : 0);
4765 [ # # ]: 0 : if (retval < 0)
4766 : : return retval;
4767 : :
4768 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4769 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4770 : 0 : tdata->cipher_iv.len);
4771 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4772 : : return retval;
4773 : : } else
4774 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4775 : : ut_params->op);
4776 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4777 : :
4778 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4779 [ # # ]: 0 : if (ut_params->obuf)
4780 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4781 : : else
4782 : : ciphertext = plaintext;
4783 : :
4784 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4785 : :
4786 : : /* Validate obuf */
4787 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4788 : : ciphertext,
4789 : : tdata->ciphertext.data,
4790 : : tdata->validDataLenInBits.len,
4791 : : "SNOW 3G Ciphertext data not as expected");
4792 : : return 0;
4793 : : }
4794 : :
4795 : : static int
4796 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4797 : : uint8_t sgl_in, uint8_t sgl_out)
4798 : : {
4799 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4800 : : struct crypto_unittest_params *ut_params = &unittest_params;
4801 : :
4802 : : int retval;
4803 : : unsigned int plaintext_pad_len;
4804 : : unsigned int plaintext_len;
4805 : : uint8_t buffer[10000];
4806 : : const uint8_t *ciphertext;
4807 : :
4808 : : struct rte_cryptodev_info dev_info;
4809 : :
4810 : : /* Verify the capabilities */
4811 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4812 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4813 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4814 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4815 : : &cap_idx) == NULL)
4816 : : return TEST_SKIPPED;
4817 : :
4818 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4819 : : return TEST_SKIPPED;
4820 : :
4821 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4822 : : return TEST_SKIPPED;
4823 : :
4824 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4825 : :
4826 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4827 : :
4828 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4829 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4830 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4831 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4832 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4833 : : printf("Device doesn't support out-of-place scatter gather type. "
4834 : : "Test Skipped.\n");
4835 : 0 : return TEST_SKIPPED;
4836 : : }
4837 : :
4838 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4839 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4840 : : printf("Device does not support RAW data-path APIs.\n");
4841 : 0 : return -ENOTSUP;
4842 : : }
4843 : :
4844 : : /* Create SNOW 3G session */
4845 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4846 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4847 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4848 : 0 : tdata->key.data, tdata->key.len,
4849 : 0 : tdata->cipher_iv.len);
4850 [ # # ]: 0 : if (retval < 0)
4851 : : return retval;
4852 : :
4853 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4854 : : /* Append data which is padded to a multiple of */
4855 : : /* the algorithms block size */
4856 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4857 : :
4858 [ # # ]: 0 : if (sgl_in)
4859 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4860 : : plaintext_pad_len, 10, 0);
4861 : : else {
4862 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4863 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4864 : : }
4865 : :
4866 [ # # ]: 0 : if (sgl_out)
4867 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4868 : : plaintext_pad_len, 3, 0);
4869 : : else {
4870 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4871 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4872 : : }
4873 : :
4874 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4875 : : "Failed to allocate input buffer in mempool");
4876 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4877 : : "Failed to allocate output buffer in mempool");
4878 : :
4879 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4880 : :
4881 : : /* Create SNOW 3G operation */
4882 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4883 : 0 : tdata->cipher_iv.len,
4884 : 0 : tdata->validCipherLenInBits.len,
4885 : : 0);
4886 [ # # ]: 0 : if (retval < 0)
4887 : : return retval;
4888 : :
4889 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4890 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4891 : 0 : tdata->cipher_iv.len);
4892 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4893 : : return retval;
4894 : : } else
4895 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4896 : : ut_params->op);
4897 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4898 : :
4899 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4900 [ # # ]: 0 : if (ut_params->obuf)
4901 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4902 : : plaintext_len, buffer);
4903 : : else
4904 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4905 : : plaintext_len, buffer);
4906 : :
4907 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4908 : :
4909 : : /* Validate obuf */
4910 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4911 : : ciphertext,
4912 : : tdata->ciphertext.data,
4913 : : tdata->validDataLenInBits.len,
4914 : : "SNOW 3G Ciphertext data not as expected");
4915 : :
4916 : : return 0;
4917 : : }
4918 : :
4919 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4920 : : static void
4921 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4922 : : {
4923 : : uint8_t curr_byte, prev_byte;
4924 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4925 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4926 : : unsigned i;
4927 : :
4928 : 0 : prev_byte = buffer[0];
4929 : 0 : buffer[0] >>= offset;
4930 : :
4931 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4932 : 0 : curr_byte = buffer[i];
4933 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4934 : 0 : (curr_byte >> offset);
4935 : : prev_byte = curr_byte;
4936 : : }
4937 : 0 : }
4938 : :
4939 : : static int
4940 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4941 : : {
4942 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4943 : : struct crypto_unittest_params *ut_params = &unittest_params;
4944 : : uint8_t *plaintext, *ciphertext;
4945 : : int retval;
4946 : : uint32_t plaintext_len;
4947 : : uint32_t plaintext_pad_len;
4948 : : uint8_t extra_offset = 4;
4949 : : uint8_t *expected_ciphertext_shifted;
4950 : : struct rte_cryptodev_info dev_info;
4951 : :
4952 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4953 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4954 : :
4955 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4956 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4957 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4958 : 0 : return TEST_SKIPPED;
4959 : : }
4960 : :
4961 : : /* Verify the capabilities */
4962 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4963 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4964 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4965 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4966 : : &cap_idx) == NULL)
4967 : : return TEST_SKIPPED;
4968 : :
4969 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4970 : : return TEST_SKIPPED;
4971 : :
4972 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4973 : : return TEST_SKIPPED;
4974 : :
4975 : : /* Create SNOW 3G session */
4976 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4977 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4978 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4979 : 0 : tdata->key.data, tdata->key.len,
4980 : 0 : tdata->cipher_iv.len);
4981 [ # # ]: 0 : if (retval < 0)
4982 : : return retval;
4983 : :
4984 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4985 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4986 : :
4987 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4988 : : "Failed to allocate input buffer in mempool");
4989 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4990 : : "Failed to allocate output buffer in mempool");
4991 : :
4992 : : /* Clear mbuf payload */
4993 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4994 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4995 : :
4996 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4997 : : /*
4998 : : * Append data which is padded to a
4999 : : * multiple of the algorithms block size
5000 : : */
5001 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5002 : :
5003 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
5004 : : plaintext_pad_len);
5005 : :
5006 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5007 : :
5008 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
5009 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
5010 : :
5011 : : #ifdef RTE_APP_TEST_DEBUG
5012 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
5013 : : #endif
5014 : : /* Create SNOW 3G operation */
5015 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5016 : 0 : tdata->cipher_iv.len,
5017 : 0 : tdata->validCipherLenInBits.len,
5018 : : extra_offset);
5019 [ # # ]: 0 : if (retval < 0)
5020 : : return retval;
5021 : :
5022 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5023 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5024 : 0 : tdata->cipher_iv.len);
5025 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5026 : : return retval;
5027 : : } else
5028 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5029 : : ut_params->op);
5030 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5031 : :
5032 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5033 [ # # ]: 0 : if (ut_params->obuf)
5034 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5035 : : else
5036 : : ciphertext = plaintext;
5037 : :
5038 : : #ifdef RTE_APP_TEST_DEBUG
5039 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5040 : : #endif
5041 : :
5042 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
5043 : :
5044 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
5045 : : "failed to reserve memory for ciphertext shifted\n");
5046 : :
5047 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
5048 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
5049 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
5050 : : extra_offset);
5051 : : /* Validate obuf */
5052 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
5053 : : ciphertext,
5054 : : expected_ciphertext_shifted,
5055 : : tdata->validDataLenInBits.len,
5056 : : extra_offset,
5057 : : "SNOW 3G Ciphertext data not as expected");
5058 : : return 0;
5059 : : }
5060 : :
5061 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
5062 : : {
5063 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5064 : : struct crypto_unittest_params *ut_params = &unittest_params;
5065 : :
5066 : : int retval;
5067 : :
5068 : : uint8_t *plaintext, *ciphertext;
5069 : : unsigned ciphertext_pad_len;
5070 : : unsigned ciphertext_len;
5071 : : struct rte_cryptodev_info dev_info;
5072 : :
5073 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5074 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5075 : :
5076 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5077 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5078 : : printf("Device doesn't support RAW data-path APIs.\n");
5079 : 0 : return TEST_SKIPPED;
5080 : : }
5081 : :
5082 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5083 : : return TEST_SKIPPED;
5084 : :
5085 : : /* Verify the capabilities */
5086 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5087 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5088 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5089 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5090 : : &cap_idx) == NULL)
5091 : : return TEST_SKIPPED;
5092 : :
5093 : : /* Create SNOW 3G session */
5094 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5095 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5096 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5097 : 0 : tdata->key.data, tdata->key.len,
5098 : 0 : tdata->cipher_iv.len);
5099 [ # # ]: 0 : if (retval < 0)
5100 : : return retval;
5101 : :
5102 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5103 : :
5104 : : /* Clear mbuf payload */
5105 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5106 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5107 : :
5108 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5109 : : /* Append data which is padded to a multiple of */
5110 : : /* the algorithms block size */
5111 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5112 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5113 : : ciphertext_pad_len);
5114 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5115 : :
5116 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5117 : :
5118 : : /* Create SNOW 3G operation */
5119 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5120 : 0 : tdata->cipher_iv.len,
5121 : 0 : tdata->validCipherLenInBits.len,
5122 : 0 : tdata->cipher.offset_bits);
5123 [ # # ]: 0 : if (retval < 0)
5124 : : return retval;
5125 : :
5126 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5127 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5128 : 0 : tdata->cipher_iv.len);
5129 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5130 : : return retval;
5131 : : } else
5132 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5133 : : ut_params->op);
5134 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5135 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5136 [ # # ]: 0 : if (ut_params->obuf)
5137 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5138 : : else
5139 : : plaintext = ciphertext;
5140 : :
5141 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5142 : :
5143 : : /* Validate obuf */
5144 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5145 : : tdata->plaintext.data,
5146 : : tdata->validDataLenInBits.len,
5147 : : "SNOW 3G Plaintext data not as expected");
5148 : : return 0;
5149 : : }
5150 : :
5151 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5152 : : {
5153 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5154 : : struct crypto_unittest_params *ut_params = &unittest_params;
5155 : :
5156 : : int retval;
5157 : :
5158 : : uint8_t *plaintext, *ciphertext;
5159 : : unsigned ciphertext_pad_len;
5160 : : unsigned ciphertext_len;
5161 : : struct rte_cryptodev_info dev_info;
5162 : :
5163 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5164 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5165 : :
5166 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5167 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5168 : : printf("Device does not support RAW data-path APIs.\n");
5169 : 0 : return -ENOTSUP;
5170 : : }
5171 : : /* Verify the capabilities */
5172 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5173 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5174 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5175 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5176 : : &cap_idx) == NULL)
5177 : : return TEST_SKIPPED;
5178 : :
5179 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5180 : : return TEST_SKIPPED;
5181 : :
5182 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5183 : : return TEST_SKIPPED;
5184 : :
5185 : : /* Create SNOW 3G session */
5186 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5187 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5188 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5189 : 0 : tdata->key.data, tdata->key.len,
5190 : 0 : tdata->cipher_iv.len);
5191 [ # # ]: 0 : if (retval < 0)
5192 : : return retval;
5193 : :
5194 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5195 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5196 : :
5197 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5198 : : "Failed to allocate input buffer");
5199 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5200 : : "Failed to allocate output buffer");
5201 : :
5202 : : /* Clear mbuf payload */
5203 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5204 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5205 : :
5206 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5207 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5208 : :
5209 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5210 : : /* Append data which is padded to a multiple of */
5211 : : /* the algorithms block size */
5212 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5213 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5214 : : ciphertext_pad_len);
5215 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5216 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5217 : :
5218 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5219 : :
5220 : : /* Create SNOW 3G operation */
5221 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5222 : 0 : tdata->cipher_iv.len,
5223 : 0 : tdata->validCipherLenInBits.len,
5224 : : 0);
5225 [ # # ]: 0 : if (retval < 0)
5226 : : return retval;
5227 : :
5228 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5229 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5230 : 0 : tdata->cipher_iv.len);
5231 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5232 : : return retval;
5233 : : } else
5234 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5235 : : ut_params->op);
5236 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5237 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5238 [ # # ]: 0 : if (ut_params->obuf)
5239 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5240 : : else
5241 : : plaintext = ciphertext;
5242 : :
5243 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5244 : :
5245 : : /* Validate obuf */
5246 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5247 : : tdata->plaintext.data,
5248 : : tdata->validDataLenInBits.len,
5249 : : "SNOW 3G Plaintext data not as expected");
5250 : : return 0;
5251 : : }
5252 : :
5253 : : static int
5254 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5255 : : {
5256 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5257 : : struct crypto_unittest_params *ut_params = &unittest_params;
5258 : :
5259 : : int retval;
5260 : :
5261 : : uint8_t *plaintext, *ciphertext;
5262 : : unsigned int plaintext_pad_len;
5263 : : unsigned int plaintext_len;
5264 : :
5265 : : struct rte_cryptodev_info dev_info;
5266 : :
5267 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5268 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5269 : :
5270 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5271 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
5272 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
5273 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
5274 : 0 : return TEST_SKIPPED;
5275 : : }
5276 : :
5277 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5278 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5279 : : printf("Device doesn't support RAW data-path APIs.\n");
5280 : 0 : return TEST_SKIPPED;
5281 : : }
5282 : :
5283 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5284 : : return TEST_SKIPPED;
5285 : :
5286 : : /* Check if device supports ZUC EEA3 */
5287 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5288 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
5289 : : return TEST_SKIPPED;
5290 : :
5291 : : /* Check if device supports ZUC EIA3 */
5292 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5293 : 0 : tdata->key.len, tdata->auth_iv.len,
5294 : 0 : tdata->digest.len) < 0)
5295 : : return TEST_SKIPPED;
5296 : :
5297 : : /* Create ZUC session */
5298 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
5299 : 0 : ts_params->valid_devs[0],
5300 : : tdata);
5301 [ # # ]: 0 : if (retval != 0)
5302 : : return retval;
5303 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5304 : :
5305 : : /* clear mbuf payload */
5306 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5307 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5308 : :
5309 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5310 : : /* Append data which is padded to a multiple of */
5311 : : /* the algorithms block size */
5312 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5313 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5314 : : plaintext_pad_len);
5315 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5316 : :
5317 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5318 : :
5319 : : /* Create ZUC operation */
5320 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
5321 [ # # ]: 0 : if (retval < 0)
5322 : : return retval;
5323 : :
5324 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5325 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5326 : 0 : tdata->cipher_iv.len);
5327 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5328 : : return retval;
5329 : : } else
5330 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5331 : : ut_params->op);
5332 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5333 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5334 [ # # ]: 0 : if (ut_params->obuf)
5335 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5336 : : else
5337 : : ciphertext = plaintext;
5338 : :
5339 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5340 : : /* Validate obuf */
5341 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5342 : : ciphertext,
5343 : : tdata->ciphertext.data,
5344 : : tdata->validDataLenInBits.len,
5345 : : "ZUC Ciphertext data not as expected");
5346 : :
5347 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5348 : : uint8_t *,
5349 : : plaintext_pad_len);
5350 : :
5351 : : /* Validate obuf */
5352 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5353 : : ut_params->digest,
5354 : : tdata->digest.data,
5355 : : tdata->digest.len,
5356 : : "ZUC Generated auth tag not as expected");
5357 : : return 0;
5358 : : }
5359 : :
5360 : : static int
5361 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5362 : : {
5363 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5364 : : struct crypto_unittest_params *ut_params = &unittest_params;
5365 : :
5366 : : int retval;
5367 : :
5368 : : uint8_t *plaintext, *ciphertext;
5369 : : unsigned plaintext_pad_len;
5370 : : unsigned plaintext_len;
5371 : : struct rte_cryptodev_info dev_info;
5372 : :
5373 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5374 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5375 : :
5376 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5377 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5378 : : printf("Device doesn't support RAW data-path APIs.\n");
5379 : 0 : return TEST_SKIPPED;
5380 : : }
5381 : :
5382 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5383 : : return TEST_SKIPPED;
5384 : :
5385 : : /* Verify the capabilities */
5386 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5387 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5388 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5389 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5390 : : &cap_idx) == NULL)
5391 : : return TEST_SKIPPED;
5392 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5393 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5394 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5395 : : &cap_idx) == NULL)
5396 : : return TEST_SKIPPED;
5397 : :
5398 : : /* Create SNOW 3G session */
5399 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5400 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5401 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5402 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5403 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5404 : : tdata->key.data, tdata->key.len,
5405 : 0 : tdata->key.data, tdata->key.len,
5406 : 0 : tdata->auth_iv.len, tdata->digest.len,
5407 : 0 : tdata->cipher_iv.len);
5408 [ # # ]: 0 : if (retval != 0)
5409 : : return retval;
5410 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5411 : :
5412 : : /* clear mbuf payload */
5413 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5414 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5415 : :
5416 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5417 : : /* Append data which is padded to a multiple of */
5418 : : /* the algorithms block size */
5419 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5420 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5421 : : plaintext_pad_len);
5422 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5423 : :
5424 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5425 : :
5426 : : /* Create SNOW 3G operation */
5427 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5428 : 0 : tdata->digest.len, tdata->auth_iv.data,
5429 : 0 : tdata->auth_iv.len,
5430 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5431 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5432 : 0 : tdata->validCipherLenInBits.len,
5433 : : 0,
5434 : 0 : tdata->validAuthLenInBits.len,
5435 : : 0
5436 : : );
5437 [ # # ]: 0 : if (retval < 0)
5438 : : return retval;
5439 : :
5440 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5441 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5442 : 0 : tdata->cipher_iv.len);
5443 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5444 : : return retval;
5445 : : } else
5446 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5447 : : ut_params->op);
5448 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5449 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5450 [ # # ]: 0 : if (ut_params->obuf)
5451 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5452 : : else
5453 : : ciphertext = plaintext;
5454 : :
5455 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5456 : : /* Validate obuf */
5457 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5458 : : ciphertext,
5459 : : tdata->ciphertext.data,
5460 : : tdata->validDataLenInBits.len,
5461 : : "SNOW 3G Ciphertext data not as expected");
5462 : :
5463 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5464 : : uint8_t *,
5465 : : plaintext_pad_len);
5466 : :
5467 : : /* Validate obuf */
5468 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5469 : : ut_params->digest,
5470 : : tdata->digest.data,
5471 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5472 : : "SNOW 3G Generated auth tag not as expected");
5473 : : return 0;
5474 : : }
5475 : :
5476 : : static int
5477 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5478 : : uint8_t op_mode, uint8_t verify)
5479 : : {
5480 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5481 : : struct crypto_unittest_params *ut_params = &unittest_params;
5482 : :
5483 : : int retval;
5484 : :
5485 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5486 : : unsigned int plaintext_pad_len;
5487 : : unsigned int plaintext_len;
5488 : : unsigned int ciphertext_pad_len;
5489 : : unsigned int ciphertext_len;
5490 : : unsigned int digest_offset;
5491 : :
5492 : : struct rte_cryptodev_info dev_info;
5493 : :
5494 : : /* Verify the capabilities */
5495 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5496 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5497 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5498 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5499 : : &cap_idx) == NULL)
5500 : : return TEST_SKIPPED;
5501 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5502 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5503 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5504 : : &cap_idx) == NULL)
5505 : : return TEST_SKIPPED;
5506 : :
5507 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5508 : : return TEST_SKIPPED;
5509 : :
5510 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5511 : :
5512 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5513 : :
5514 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5515 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5516 : : printf("Device doesn't support digest encrypted.\n");
5517 : 0 : return TEST_SKIPPED;
5518 : : }
5519 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5520 : : return TEST_SKIPPED;
5521 : : }
5522 : :
5523 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5524 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5525 : : printf("Device doesn't support RAW data-path APIs.\n");
5526 : 0 : return TEST_SKIPPED;
5527 : : }
5528 : :
5529 : : /* Create SNOW 3G session */
5530 : 0 : retval = create_wireless_algo_auth_cipher_session(
5531 : 0 : ts_params->valid_devs[0],
5532 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5533 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5534 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5535 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5536 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5537 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5538 : : tdata->key.data, tdata->key.len,
5539 : 0 : tdata->key.data, tdata->key.len,
5540 : 0 : tdata->auth_iv.len, tdata->digest.len,
5541 : 0 : tdata->cipher_iv.len);
5542 [ # # ]: 0 : if (retval != 0)
5543 : : return retval;
5544 : :
5545 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5546 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5547 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5548 : :
5549 : : /* clear mbuf payload */
5550 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5551 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5552 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5553 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5554 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5555 : :
5556 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5557 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5558 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5559 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5560 : :
5561 [ # # ]: 0 : if (verify) {
5562 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5563 : : ciphertext_pad_len);
5564 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5565 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5566 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5567 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5568 : : ciphertext_len);
5569 : : } else {
5570 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5571 : : plaintext_pad_len);
5572 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5573 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5574 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5575 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5576 : : }
5577 : :
5578 : : /* Create SNOW 3G operation */
5579 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5580 : 0 : tdata->digest.data, tdata->digest.len,
5581 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5582 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5583 : 0 : (tdata->digest.offset_bytes == 0 ?
5584 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5585 : : : tdata->digest.offset_bytes),
5586 : 0 : tdata->validCipherLenInBits.len,
5587 : 0 : tdata->cipher.offset_bits,
5588 : 0 : tdata->validAuthLenInBits.len,
5589 [ # # ]: 0 : tdata->auth.offset_bits,
5590 : : op_mode, 0, verify);
5591 : :
5592 [ # # ]: 0 : if (retval < 0)
5593 : : return retval;
5594 : :
5595 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5596 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5597 : 0 : tdata->cipher_iv.len);
5598 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5599 : : return retval;
5600 : : } else
5601 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5602 : : ut_params->op);
5603 : :
5604 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5605 : :
5606 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5607 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5608 : :
5609 [ # # ]: 0 : if (verify) {
5610 [ # # ]: 0 : if (ut_params->obuf)
5611 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5612 : : uint8_t *);
5613 : : else
5614 : 0 : plaintext = ciphertext +
5615 : 0 : (tdata->cipher.offset_bits >> 3);
5616 : :
5617 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5618 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5619 : 0 : debug_hexdump(stdout, "plaintext expected:",
5620 : 0 : tdata->plaintext.data,
5621 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5622 : : } else {
5623 [ # # ]: 0 : if (ut_params->obuf)
5624 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5625 : : uint8_t *);
5626 : : else
5627 : : ciphertext = plaintext;
5628 : :
5629 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5630 : : ciphertext_len);
5631 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5632 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5633 : :
5634 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5635 : : digest_offset = plaintext_pad_len;
5636 : : else
5637 : : digest_offset = tdata->digest.offset_bytes;
5638 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5639 : : uint8_t *, digest_offset);
5640 : :
5641 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5642 : 0 : tdata->digest.len);
5643 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5644 : 0 : tdata->digest.len);
5645 : : }
5646 : :
5647 : : /* Validate obuf */
5648 [ # # ]: 0 : if (verify) {
5649 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5650 : : plaintext,
5651 : : tdata->plaintext.data,
5652 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5653 : : (tdata->digest.len << 3)),
5654 : : tdata->cipher.offset_bits,
5655 : : "SNOW 3G Plaintext data not as expected");
5656 : : } else {
5657 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5658 : : ciphertext,
5659 : : tdata->ciphertext.data,
5660 : : (tdata->validDataLenInBits.len -
5661 : : tdata->cipher.offset_bits),
5662 : : tdata->cipher.offset_bits,
5663 : : "SNOW 3G Ciphertext data not as expected");
5664 : :
5665 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5666 : : ut_params->digest,
5667 : : tdata->digest.data,
5668 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5669 : : "SNOW 3G Generated auth tag not as expected");
5670 : : }
5671 : : return 0;
5672 : : }
5673 : :
5674 : : static int
5675 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5676 : : uint8_t op_mode, uint8_t verify)
5677 : : {
5678 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5679 : : struct crypto_unittest_params *ut_params = &unittest_params;
5680 : :
5681 : : int retval;
5682 : :
5683 : : const uint8_t *plaintext = NULL;
5684 : : const uint8_t *ciphertext = NULL;
5685 : : const uint8_t *digest = NULL;
5686 : : unsigned int plaintext_pad_len;
5687 : : unsigned int plaintext_len;
5688 : : unsigned int ciphertext_pad_len;
5689 : : unsigned int ciphertext_len;
5690 : : uint8_t buffer[10000];
5691 : : uint8_t digest_buffer[10000];
5692 : :
5693 : : struct rte_cryptodev_info dev_info;
5694 : :
5695 : : /* Verify the capabilities */
5696 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5697 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5698 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5699 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5700 : : &cap_idx) == NULL)
5701 : : return TEST_SKIPPED;
5702 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5703 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5704 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5705 : : &cap_idx) == NULL)
5706 : : return TEST_SKIPPED;
5707 : :
5708 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5709 : : return TEST_SKIPPED;
5710 : :
5711 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5712 : :
5713 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5714 : :
5715 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5716 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5717 : : printf("Device doesn't support in-place scatter-gather "
5718 : : "in both input and output mbufs.\n");
5719 : 0 : return TEST_SKIPPED;
5720 : : }
5721 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5722 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5723 : : printf("Device doesn't support RAW data-path APIs.\n");
5724 : 0 : return TEST_SKIPPED;
5725 : : }
5726 : : } else {
5727 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5728 : : return TEST_SKIPPED;
5729 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5730 : : printf("Device doesn't support out-of-place scatter-gather "
5731 : : "in both input and output mbufs.\n");
5732 : 0 : return TEST_SKIPPED;
5733 : : }
5734 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5735 : : printf("Device doesn't support digest encrypted.\n");
5736 : 0 : return TEST_SKIPPED;
5737 : : }
5738 : : }
5739 : :
5740 : : /* Create SNOW 3G session */
5741 : 0 : retval = create_wireless_algo_auth_cipher_session(
5742 : 0 : ts_params->valid_devs[0],
5743 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5744 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5745 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5746 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5747 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5748 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5749 : : tdata->key.data, tdata->key.len,
5750 : 0 : tdata->key.data, tdata->key.len,
5751 : 0 : tdata->auth_iv.len, tdata->digest.len,
5752 : 0 : tdata->cipher_iv.len);
5753 : :
5754 [ # # ]: 0 : if (retval != 0)
5755 : : return retval;
5756 : :
5757 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5758 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5759 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5760 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5761 : :
5762 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5763 : : plaintext_pad_len, 15, 0);
5764 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5765 : : "Failed to allocate input buffer in mempool");
5766 : :
5767 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5768 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5769 : : plaintext_pad_len, 15, 0);
5770 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5771 : : "Failed to allocate output buffer in mempool");
5772 : : }
5773 : :
5774 [ # # ]: 0 : if (verify) {
5775 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5776 : 0 : tdata->ciphertext.data);
5777 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5778 : : ciphertext_len, buffer);
5779 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5780 : : ciphertext_len);
5781 : : } else {
5782 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5783 : 0 : tdata->plaintext.data);
5784 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5785 : : plaintext_len, buffer);
5786 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5787 : : plaintext_len);
5788 : : }
5789 : : memset(buffer, 0, sizeof(buffer));
5790 : :
5791 : : /* Create SNOW 3G operation */
5792 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5793 : 0 : tdata->digest.data, tdata->digest.len,
5794 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5795 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5796 : 0 : (tdata->digest.offset_bytes == 0 ?
5797 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5798 : : : tdata->digest.offset_bytes),
5799 : 0 : tdata->validCipherLenInBits.len,
5800 : 0 : tdata->cipher.offset_bits,
5801 : 0 : tdata->validAuthLenInBits.len,
5802 [ # # ]: 0 : tdata->auth.offset_bits,
5803 : : op_mode, 1, verify);
5804 : :
5805 [ # # ]: 0 : if (retval < 0)
5806 : : return retval;
5807 : :
5808 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5809 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5810 : 0 : tdata->cipher_iv.len);
5811 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5812 : : return retval;
5813 : : } else
5814 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5815 : : ut_params->op);
5816 : :
5817 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5818 : :
5819 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5820 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5821 : :
5822 [ # # ]: 0 : if (verify) {
5823 [ # # ]: 0 : if (ut_params->obuf)
5824 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5825 : : plaintext_len, buffer);
5826 : : else
5827 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5828 : : plaintext_len, buffer);
5829 : :
5830 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5831 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5832 : 0 : debug_hexdump(stdout, "plaintext expected:",
5833 : 0 : tdata->plaintext.data,
5834 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5835 : : } else {
5836 [ # # ]: 0 : if (ut_params->obuf)
5837 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5838 : : ciphertext_len, buffer);
5839 : : else
5840 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5841 : : ciphertext_len, buffer);
5842 : :
5843 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5844 : : ciphertext_len);
5845 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5846 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5847 : :
5848 [ # # ]: 0 : if (ut_params->obuf)
5849 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5850 : 0 : (tdata->digest.offset_bytes == 0 ?
5851 : : plaintext_pad_len : tdata->digest.offset_bytes),
5852 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5853 : : else
5854 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5855 : 0 : (tdata->digest.offset_bytes == 0 ?
5856 : : plaintext_pad_len : tdata->digest.offset_bytes),
5857 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5858 : :
5859 : 0 : debug_hexdump(stdout, "digest:", digest,
5860 : 0 : tdata->digest.len);
5861 : 0 : debug_hexdump(stdout, "digest expected:",
5862 : 0 : tdata->digest.data, tdata->digest.len);
5863 : : }
5864 : :
5865 : : /* Validate obuf */
5866 [ # # ]: 0 : if (verify) {
5867 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5868 : : plaintext,
5869 : : tdata->plaintext.data,
5870 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5871 : : (tdata->digest.len << 3)),
5872 : : tdata->cipher.offset_bits,
5873 : : "SNOW 3G Plaintext data not as expected");
5874 : : } else {
5875 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5876 : : ciphertext,
5877 : : tdata->ciphertext.data,
5878 : : (tdata->validDataLenInBits.len -
5879 : : tdata->cipher.offset_bits),
5880 : : tdata->cipher.offset_bits,
5881 : : "SNOW 3G Ciphertext data not as expected");
5882 : :
5883 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5884 : : digest,
5885 : : tdata->digest.data,
5886 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5887 : : "SNOW 3G Generated auth tag not as expected");
5888 : : }
5889 : : return 0;
5890 : : }
5891 : :
5892 : : static int
5893 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5894 : : uint8_t op_mode, uint8_t verify)
5895 : : {
5896 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5897 : : struct crypto_unittest_params *ut_params = &unittest_params;
5898 : :
5899 : : int retval;
5900 : :
5901 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5902 : : unsigned int plaintext_pad_len;
5903 : : unsigned int plaintext_len;
5904 : : unsigned int ciphertext_pad_len;
5905 : : unsigned int ciphertext_len;
5906 : : unsigned int digest_offset;
5907 : :
5908 : : struct rte_cryptodev_info dev_info;
5909 : :
5910 : : /* Verify the capabilities */
5911 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5912 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5913 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5914 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5915 : : &cap_idx) == NULL)
5916 : : return TEST_SKIPPED;
5917 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5918 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5919 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5920 : : &cap_idx) == NULL)
5921 : : return TEST_SKIPPED;
5922 : :
5923 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5924 : :
5925 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5926 : :
5927 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5928 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5929 : : printf("Device doesn't support RAW data-path APIs.\n");
5930 : 0 : return TEST_SKIPPED;
5931 : : }
5932 : :
5933 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5934 : : return TEST_SKIPPED;
5935 : :
5936 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5937 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5938 : : return TEST_SKIPPED;
5939 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5940 : : printf("Device doesn't support digest encrypted.\n");
5941 : 0 : return TEST_SKIPPED;
5942 : : }
5943 : : }
5944 : :
5945 : : /* Create KASUMI session */
5946 : 0 : retval = create_wireless_algo_auth_cipher_session(
5947 : 0 : ts_params->valid_devs[0],
5948 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5949 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5950 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5951 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5952 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5953 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5954 : : tdata->key.data, tdata->key.len,
5955 : 0 : tdata->key.data, tdata->key.len,
5956 : 0 : 0, tdata->digest.len,
5957 : 0 : tdata->cipher_iv.len);
5958 : :
5959 [ # # ]: 0 : if (retval != 0)
5960 : : return retval;
5961 : :
5962 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5963 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5964 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5965 : :
5966 : : /* clear mbuf payload */
5967 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5968 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5969 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5970 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5971 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5972 : :
5973 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5974 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5975 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5976 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5977 : :
5978 [ # # ]: 0 : if (verify) {
5979 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5980 : : ciphertext_pad_len);
5981 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5982 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5983 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5984 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5985 : : ciphertext_len);
5986 : : } else {
5987 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5988 : : plaintext_pad_len);
5989 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5990 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5991 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5992 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5993 : : plaintext_len);
5994 : : }
5995 : :
5996 : : /* Create KASUMI operation */
5997 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5998 : 0 : tdata->digest.data, tdata->digest.len,
5999 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6000 : : NULL, 0,
6001 : 0 : (tdata->digest.offset_bytes == 0 ?
6002 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6003 : : : tdata->digest.offset_bytes),
6004 : 0 : tdata->validCipherLenInBits.len,
6005 : 0 : tdata->validCipherOffsetInBits.len,
6006 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6007 : : 0,
6008 : : op_mode, 0, verify);
6009 : :
6010 [ # # ]: 0 : if (retval < 0)
6011 : : return retval;
6012 : :
6013 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6014 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6015 : 0 : tdata->cipher_iv.len);
6016 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6017 : : return retval;
6018 : : } else
6019 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6020 : : ut_params->op);
6021 : :
6022 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6023 : :
6024 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6025 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6026 : :
6027 : :
6028 [ # # ]: 0 : if (verify) {
6029 [ # # ]: 0 : if (ut_params->obuf)
6030 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6031 : : uint8_t *);
6032 : : else
6033 : : plaintext = ciphertext;
6034 : :
6035 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6036 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6037 : 0 : debug_hexdump(stdout, "plaintext expected:",
6038 : 0 : tdata->plaintext.data,
6039 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6040 : : } else {
6041 [ # # ]: 0 : if (ut_params->obuf)
6042 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6043 : : uint8_t *);
6044 : : else
6045 : : ciphertext = plaintext;
6046 : :
6047 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6048 : : ciphertext_len);
6049 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6050 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6051 : :
6052 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6053 : : digest_offset = plaintext_pad_len;
6054 : : else
6055 : : digest_offset = tdata->digest.offset_bytes;
6056 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6057 : : uint8_t *, digest_offset);
6058 : :
6059 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6060 : 0 : tdata->digest.len);
6061 : 0 : debug_hexdump(stdout, "digest expected:",
6062 : 0 : tdata->digest.data, tdata->digest.len);
6063 : : }
6064 : :
6065 : : /* Validate obuf */
6066 [ # # ]: 0 : if (verify) {
6067 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6068 : : plaintext,
6069 : : tdata->plaintext.data,
6070 : : tdata->plaintext.len >> 3,
6071 : : "KASUMI Plaintext data not as expected");
6072 : : } else {
6073 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6074 : : ciphertext,
6075 : : tdata->ciphertext.data,
6076 : : tdata->ciphertext.len >> 3,
6077 : : "KASUMI Ciphertext data not as expected");
6078 : :
6079 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6080 : : ut_params->digest,
6081 : : tdata->digest.data,
6082 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6083 : : "KASUMI Generated auth tag not as expected");
6084 : : }
6085 : : return 0;
6086 : : }
6087 : :
6088 : : static int
6089 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6090 : : uint8_t op_mode, uint8_t verify)
6091 : : {
6092 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6093 : : struct crypto_unittest_params *ut_params = &unittest_params;
6094 : :
6095 : : int retval;
6096 : :
6097 : : const uint8_t *plaintext = NULL;
6098 : : const uint8_t *ciphertext = NULL;
6099 : : const uint8_t *digest = NULL;
6100 : : unsigned int plaintext_pad_len;
6101 : : unsigned int plaintext_len;
6102 : : unsigned int ciphertext_pad_len;
6103 : : unsigned int ciphertext_len;
6104 : : uint8_t buffer[10000];
6105 : : uint8_t digest_buffer[10000];
6106 : :
6107 : : struct rte_cryptodev_info dev_info;
6108 : :
6109 : : /* Verify the capabilities */
6110 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6111 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6112 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6113 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6114 : : &cap_idx) == NULL)
6115 : : return TEST_SKIPPED;
6116 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6117 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6118 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6119 : : &cap_idx) == NULL)
6120 : : return TEST_SKIPPED;
6121 : :
6122 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6123 : : return TEST_SKIPPED;
6124 : :
6125 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6126 : :
6127 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6128 : :
6129 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6130 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6131 : : printf("Device doesn't support in-place scatter-gather "
6132 : : "in both input and output mbufs.\n");
6133 : 0 : return TEST_SKIPPED;
6134 : : }
6135 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6136 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6137 : : printf("Device doesn't support RAW data-path APIs.\n");
6138 : 0 : return TEST_SKIPPED;
6139 : : }
6140 : : } else {
6141 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6142 : : return TEST_SKIPPED;
6143 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6144 : : printf("Device doesn't support out-of-place scatter-gather "
6145 : : "in both input and output mbufs.\n");
6146 : 0 : return TEST_SKIPPED;
6147 : : }
6148 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6149 : : printf("Device doesn't support digest encrypted.\n");
6150 : 0 : return TEST_SKIPPED;
6151 : : }
6152 : : }
6153 : :
6154 : : /* Create KASUMI session */
6155 : 0 : retval = create_wireless_algo_auth_cipher_session(
6156 : 0 : ts_params->valid_devs[0],
6157 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6158 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6159 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6160 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6161 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6162 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6163 : : tdata->key.data, tdata->key.len,
6164 : 0 : tdata->key.data, tdata->key.len,
6165 : 0 : 0, tdata->digest.len,
6166 : 0 : tdata->cipher_iv.len);
6167 : :
6168 [ # # ]: 0 : if (retval != 0)
6169 : : return retval;
6170 : :
6171 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6172 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6173 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6174 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6175 : :
6176 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6177 : : plaintext_pad_len, 15, 0);
6178 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6179 : : "Failed to allocate input buffer in mempool");
6180 : :
6181 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6182 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6183 : : plaintext_pad_len, 15, 0);
6184 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6185 : : "Failed to allocate output buffer in mempool");
6186 : : }
6187 : :
6188 [ # # ]: 0 : if (verify) {
6189 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6190 : 0 : tdata->ciphertext.data);
6191 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6192 : : ciphertext_len, buffer);
6193 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6194 : : ciphertext_len);
6195 : : } else {
6196 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6197 : 0 : tdata->plaintext.data);
6198 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6199 : : plaintext_len, buffer);
6200 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6201 : : plaintext_len);
6202 : : }
6203 : : memset(buffer, 0, sizeof(buffer));
6204 : :
6205 : : /* Create KASUMI operation */
6206 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6207 : 0 : tdata->digest.data, tdata->digest.len,
6208 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6209 : : NULL, 0,
6210 : 0 : (tdata->digest.offset_bytes == 0 ?
6211 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6212 : : : tdata->digest.offset_bytes),
6213 : 0 : tdata->validCipherLenInBits.len,
6214 : 0 : tdata->validCipherOffsetInBits.len,
6215 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6216 : : 0,
6217 : : op_mode, 1, verify);
6218 : :
6219 [ # # ]: 0 : if (retval < 0)
6220 : : return retval;
6221 : :
6222 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6223 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6224 : 0 : tdata->cipher_iv.len);
6225 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6226 : : return retval;
6227 : : } else
6228 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6229 : : ut_params->op);
6230 : :
6231 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6232 : :
6233 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6234 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6235 : :
6236 [ # # ]: 0 : if (verify) {
6237 [ # # ]: 0 : if (ut_params->obuf)
6238 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6239 : : plaintext_len, buffer);
6240 : : else
6241 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6242 : : plaintext_len, buffer);
6243 : :
6244 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6245 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6246 : 0 : debug_hexdump(stdout, "plaintext expected:",
6247 : 0 : tdata->plaintext.data,
6248 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6249 : : } else {
6250 [ # # ]: 0 : if (ut_params->obuf)
6251 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6252 : : ciphertext_len, buffer);
6253 : : else
6254 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6255 : : ciphertext_len, buffer);
6256 : :
6257 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6258 : : ciphertext_len);
6259 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6260 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6261 : :
6262 [ # # ]: 0 : if (ut_params->obuf)
6263 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6264 : 0 : (tdata->digest.offset_bytes == 0 ?
6265 : : plaintext_pad_len : tdata->digest.offset_bytes),
6266 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6267 : : else
6268 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6269 : 0 : (tdata->digest.offset_bytes == 0 ?
6270 : : plaintext_pad_len : tdata->digest.offset_bytes),
6271 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6272 : :
6273 : 0 : debug_hexdump(stdout, "digest:", digest,
6274 : 0 : tdata->digest.len);
6275 : 0 : debug_hexdump(stdout, "digest expected:",
6276 : 0 : tdata->digest.data, tdata->digest.len);
6277 : : }
6278 : :
6279 : : /* Validate obuf */
6280 [ # # ]: 0 : if (verify) {
6281 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6282 : : plaintext,
6283 : : tdata->plaintext.data,
6284 : : tdata->plaintext.len >> 3,
6285 : : "KASUMI Plaintext data not as expected");
6286 : : } else {
6287 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6288 : : ciphertext,
6289 : : tdata->ciphertext.data,
6290 : : tdata->validDataLenInBits.len,
6291 : : "KASUMI Ciphertext data not as expected");
6292 : :
6293 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6294 : : digest,
6295 : : tdata->digest.data,
6296 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6297 : : "KASUMI Generated auth tag not as expected");
6298 : : }
6299 : : return 0;
6300 : : }
6301 : :
6302 : : static int
6303 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6304 : : {
6305 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6306 : : struct crypto_unittest_params *ut_params = &unittest_params;
6307 : :
6308 : : int retval;
6309 : :
6310 : : uint8_t *plaintext, *ciphertext;
6311 : : unsigned plaintext_pad_len;
6312 : : unsigned plaintext_len;
6313 : : struct rte_cryptodev_info dev_info;
6314 : :
6315 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6316 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6317 : :
6318 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6319 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6320 : : printf("Device doesn't support RAW data-path APIs.\n");
6321 : 0 : return TEST_SKIPPED;
6322 : : }
6323 : :
6324 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6325 : : return TEST_SKIPPED;
6326 : :
6327 : : /* Verify the capabilities */
6328 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6329 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6330 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6331 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6332 : : &cap_idx) == NULL)
6333 : : return TEST_SKIPPED;
6334 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6335 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6336 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6337 : : &cap_idx) == NULL)
6338 : : return TEST_SKIPPED;
6339 : :
6340 : : /* Create KASUMI session */
6341 : 0 : retval = create_wireless_algo_cipher_auth_session(
6342 : 0 : ts_params->valid_devs[0],
6343 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6344 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6345 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6346 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6347 : : tdata->key.data, tdata->key.len,
6348 : 0 : tdata->key.data, tdata->key.len,
6349 : 0 : 0, tdata->digest.len,
6350 : 0 : tdata->cipher_iv.len);
6351 [ # # ]: 0 : if (retval != 0)
6352 : : return retval;
6353 : :
6354 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6355 : :
6356 : : /* clear mbuf payload */
6357 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6358 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6359 : :
6360 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6361 : : /* Append data which is padded to a multiple of */
6362 : : /* the algorithms block size */
6363 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6364 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6365 : : plaintext_pad_len);
6366 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6367 : :
6368 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6369 : :
6370 : : /* Create KASUMI operation */
6371 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6372 : 0 : tdata->digest.len, NULL, 0,
6373 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6374 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6375 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6376 : 0 : tdata->validCipherOffsetInBits.len,
6377 : 0 : tdata->validAuthLenInBits.len,
6378 : : 0
6379 : : );
6380 [ # # ]: 0 : if (retval < 0)
6381 : : return retval;
6382 : :
6383 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6384 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6385 : 0 : tdata->cipher_iv.len);
6386 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6387 : : return retval;
6388 : : } else
6389 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6390 : : ut_params->op);
6391 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6392 : :
6393 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6394 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6395 : : else
6396 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6397 : :
6398 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6399 : : tdata->validCipherOffsetInBits.len >> 3);
6400 : :
6401 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6402 : : uint8_t *,
6403 : : plaintext_pad_len);
6404 : :
6405 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6406 : : (tdata->validCipherOffsetInBits.len >> 3);
6407 : : /* Validate obuf */
6408 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6409 : : ciphertext,
6410 : : reference_ciphertext,
6411 : : tdata->validCipherLenInBits.len,
6412 : : "KASUMI Ciphertext data not as expected");
6413 : :
6414 : : /* Validate obuf */
6415 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6416 : : ut_params->digest,
6417 : : tdata->digest.data,
6418 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6419 : : "KASUMI Generated auth tag not as expected");
6420 : : return 0;
6421 : : }
6422 : :
6423 : : static int
6424 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6425 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6426 : : const uint16_t key_size, const uint16_t iv_size)
6427 : : {
6428 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6429 : : const struct rte_cryptodev_symmetric_capability *cap;
6430 : :
6431 : : /* Check if device supports the algorithm */
6432 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6433 : 0 : cap_idx.algo.cipher = cipher_algo;
6434 : :
6435 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6436 : : &cap_idx);
6437 : :
6438 [ # # ]: 0 : if (cap == NULL)
6439 : : return -1;
6440 : :
6441 : : /* Check if device supports key size and IV size */
6442 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6443 : : iv_size) < 0) {
6444 : 0 : return -1;
6445 : : }
6446 : :
6447 : : return 0;
6448 : : }
6449 : :
6450 : : static int
6451 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6452 : : const enum rte_crypto_auth_algorithm auth_algo,
6453 : : const uint16_t key_size, const uint16_t iv_size,
6454 : : const uint16_t tag_size)
6455 : : {
6456 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6457 : : const struct rte_cryptodev_symmetric_capability *cap;
6458 : :
6459 : : /* Check if device supports the algorithm */
6460 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6461 : 0 : cap_idx.algo.auth = auth_algo;
6462 : :
6463 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6464 : : &cap_idx);
6465 : :
6466 [ # # ]: 0 : if (cap == NULL)
6467 : : return -1;
6468 : :
6469 : : /* Check if device supports key size and IV size */
6470 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6471 : : tag_size, iv_size) < 0) {
6472 : 0 : return -1;
6473 : : }
6474 : :
6475 : : return 0;
6476 : : }
6477 : :
6478 : : static int
6479 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6480 : : enum rte_crypto_cipher_operation direction)
6481 : : {
6482 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6483 : : struct crypto_unittest_params *ut_params = &unittest_params;
6484 : :
6485 : : int retval;
6486 : : uint8_t *plaintext = NULL;
6487 : : uint8_t *ciphertext = NULL;
6488 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6489 : : unsigned int plaintext_len = 0;
6490 : : unsigned int ciphertext_len = 0;
6491 : : struct rte_cryptodev_info dev_info;
6492 : :
6493 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6494 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6495 : :
6496 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6497 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6498 : : printf("Device doesn't support RAW data-path APIs.\n");
6499 : 0 : return TEST_SKIPPED;
6500 : : }
6501 : :
6502 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6503 : : return TEST_SKIPPED;
6504 : :
6505 : : /* Check if device supports ZUC EEA3 */
6506 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6507 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6508 : : return TEST_SKIPPED;
6509 : :
6510 : : /* Create ZUC session */
6511 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6512 : : direction,
6513 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6514 : 0 : tdata->key.data, tdata->key.len,
6515 : 0 : tdata->cipher_iv.len);
6516 [ # # ]: 0 : if (retval != 0)
6517 : : return retval;
6518 : :
6519 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6520 : :
6521 : : /* Clear mbuf payload */
6522 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6523 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6524 : :
6525 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6526 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6527 : : /* Append data which is padded to a multiple */
6528 : : /* of the algorithms block size */
6529 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6530 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6531 : : plaintext_pad_len);
6532 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6533 : :
6534 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6535 : : } else {
6536 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6537 : : /* Append data which is padded to a multiple */
6538 : : /* of the algorithms block size */
6539 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6540 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6541 : : ciphertext_pad_len);
6542 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6543 : :
6544 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6545 : : }
6546 : :
6547 : : /* Create ZUC operation */
6548 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6549 : 0 : tdata->cipher_iv.len,
6550 : 0 : tdata->plaintext.len,
6551 : 0 : tdata->validCipherOffsetInBits.len);
6552 [ # # ]: 0 : if (retval < 0)
6553 : : return retval;
6554 : :
6555 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6556 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6557 : 0 : tdata->cipher_iv.len);
6558 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6559 : : return retval;
6560 : : } else
6561 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6562 : : ut_params->op);
6563 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6564 : :
6565 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6566 : :
6567 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6568 [ # # ]: 0 : if (ut_params->obuf)
6569 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6570 : : else
6571 : : ciphertext = plaintext;
6572 : :
6573 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6574 : :
6575 : : /* Validate obuf */
6576 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6577 : : ciphertext,
6578 : : tdata->ciphertext.data,
6579 : : tdata->validCipherLenInBits.len,
6580 : : "ZUC Ciphertext data not as expected");
6581 : : } else {
6582 [ # # ]: 0 : if (ut_params->obuf)
6583 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6584 : : else
6585 : : plaintext = ciphertext;
6586 : :
6587 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6588 : :
6589 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6590 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6591 : :
6592 : : /* Validate obuf */
6593 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6594 : : plaintext,
6595 : : reference_plaintext,
6596 : : tdata->validCipherLenInBits.len,
6597 : : "ZUC Plaintext data not as expected");
6598 : : }
6599 : :
6600 : : return 0;
6601 : : }
6602 : :
6603 : : static int
6604 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6605 : : enum rte_crypto_cipher_operation direction)
6606 : : {
6607 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6608 : : struct crypto_unittest_params *ut_params = &unittest_params;
6609 : :
6610 : : int retval;
6611 : :
6612 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6613 : : unsigned int plaintext_len = 0;
6614 : : unsigned int ciphertext_len = 0;
6615 : : const uint8_t *ciphertext, *plaintext;
6616 : : uint8_t buffer[2048];
6617 : : struct rte_cryptodev_info dev_info;
6618 : :
6619 : : /* Check if device supports ZUC EEA3 */
6620 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6621 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6622 : : return TEST_SKIPPED;
6623 : :
6624 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6625 : : return TEST_SKIPPED;
6626 : :
6627 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6628 : :
6629 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6630 : :
6631 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6632 : : printf("Device doesn't support in-place scatter-gather. "
6633 : : "Test Skipped.\n");
6634 : 0 : return TEST_SKIPPED;
6635 : : }
6636 : :
6637 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6638 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6639 : : printf("Device doesn't support RAW data-path APIs.\n");
6640 : 0 : return TEST_SKIPPED;
6641 : : }
6642 : :
6643 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6644 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6645 : :
6646 : : /* Append data which is padded to a multiple */
6647 : : /* of the algorithms block size */
6648 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6649 : :
6650 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6651 : : plaintext_pad_len, 10, 0);
6652 : :
6653 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6654 : 0 : tdata->plaintext.data);
6655 : : } else {
6656 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6657 : :
6658 : : /* Append data which is padded to a multiple */
6659 : : /* of the algorithms block size */
6660 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6661 : :
6662 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6663 : : ciphertext_pad_len, 10, 0);
6664 : :
6665 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6666 : 0 : tdata->ciphertext.data);
6667 : :
6668 : : }
6669 : :
6670 : : /* Create ZUC session */
6671 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6672 : : direction,
6673 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6674 : 0 : tdata->key.data, tdata->key.len,
6675 : 0 : tdata->cipher_iv.len);
6676 [ # # ]: 0 : if (retval < 0)
6677 : : return retval;
6678 : :
6679 : : /* Clear mbuf payload */
6680 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6681 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6682 : : else
6683 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6684 : :
6685 : : /* Create ZUC operation */
6686 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6687 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6688 : 0 : tdata->validCipherOffsetInBits.len);
6689 [ # # ]: 0 : if (retval < 0)
6690 : : return retval;
6691 : :
6692 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6693 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6694 : 0 : tdata->cipher_iv.len);
6695 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6696 : : return retval;
6697 : : } else
6698 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6699 : : ut_params->op);
6700 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6701 : :
6702 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6703 : :
6704 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6705 [ # # ]: 0 : if (ut_params->obuf)
6706 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6707 : : 0, plaintext_len, buffer);
6708 : : else
6709 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6710 : : 0, plaintext_len, buffer);
6711 : :
6712 : : /* Validate obuf */
6713 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6714 : :
6715 : : /* Validate obuf */
6716 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6717 : : ciphertext,
6718 : : tdata->ciphertext.data,
6719 : : tdata->validCipherLenInBits.len,
6720 : : "ZUC Ciphertext data not as expected");
6721 : : } else {
6722 [ # # ]: 0 : if (ut_params->obuf)
6723 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6724 : : 0, ciphertext_len, buffer);
6725 : : else
6726 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6727 : : 0, ciphertext_len, buffer);
6728 : :
6729 : : /* Validate obuf */
6730 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6731 : :
6732 : : /* Validate obuf */
6733 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6734 : : plaintext,
6735 : : tdata->plaintext.data,
6736 : : tdata->validCipherLenInBits.len,
6737 : : "ZUC Plaintext data not as expected");
6738 : : }
6739 : :
6740 : : return 0;
6741 : : }
6742 : :
6743 : : static int
6744 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6745 : : enum rte_crypto_auth_operation auth_op)
6746 : : {
6747 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6748 : : struct crypto_unittest_params *ut_params = &unittest_params;
6749 : :
6750 : : int retval;
6751 : : unsigned plaintext_pad_len;
6752 : : unsigned plaintext_len;
6753 : : uint8_t *plaintext;
6754 : :
6755 : : struct rte_cryptodev_info dev_info;
6756 : :
6757 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6758 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6759 : :
6760 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6761 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6762 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6763 : 0 : return TEST_SKIPPED;
6764 : : }
6765 : :
6766 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6767 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6768 : : printf("Device doesn't support RAW data-path APIs.\n");
6769 : 0 : return TEST_SKIPPED;
6770 : : }
6771 : :
6772 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6773 : : return TEST_SKIPPED;
6774 : :
6775 : : /* Check if device supports ZUC EIA3 */
6776 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6777 : 0 : tdata->key.len, tdata->auth_iv.len,
6778 : 0 : tdata->digest.len) < 0)
6779 : : return TEST_SKIPPED;
6780 : :
6781 : : /* Create ZUC session */
6782 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6783 : 0 : tdata->key.data, tdata->key.len,
6784 : 0 : tdata->auth_iv.len, tdata->digest.len,
6785 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6786 [ # # ]: 0 : if (retval != 0)
6787 : : return retval;
6788 : :
6789 : : /* alloc mbuf and set payload */
6790 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6791 : :
6792 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6793 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6794 : :
6795 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6796 : : /* Append data which is padded to a multiple of */
6797 : : /* the algorithms block size */
6798 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6799 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6800 : : plaintext_pad_len);
6801 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6802 : :
6803 : : /* Create ZUC operation */
6804 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6805 : 0 : tdata->digest.len,
6806 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6807 : : plaintext_pad_len,
6808 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6809 [ # # ]: 0 : if (retval < 0)
6810 : : return retval;
6811 : :
6812 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6813 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6814 : : 0);
6815 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6816 : : return retval;
6817 : : } else
6818 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6819 : : ut_params->op);
6820 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6821 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6822 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6823 : : uint8_t *,
6824 : : plaintext_pad_len);
6825 : :
6826 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6827 : : /* Validate obuf */
6828 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6829 : : ut_params->digest,
6830 : : tdata->digest.data,
6831 : : tdata->digest.len,
6832 : : "ZUC Generated auth tag not as expected");
6833 : : return 0;
6834 : : }
6835 : :
6836 : : /* Validate obuf */
6837 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6838 : : return 0;
6839 : : else
6840 : 0 : return -1;
6841 : :
6842 : : return 0;
6843 : : }
6844 : :
6845 : : static int
6846 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6847 : : uint8_t op_mode, uint8_t verify)
6848 : : {
6849 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6850 : : struct crypto_unittest_params *ut_params = &unittest_params;
6851 : :
6852 : : int retval;
6853 : :
6854 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6855 : : unsigned int plaintext_pad_len;
6856 : : unsigned int plaintext_len;
6857 : : unsigned int ciphertext_pad_len;
6858 : : unsigned int ciphertext_len;
6859 : : unsigned int digest_offset;
6860 : :
6861 : : struct rte_cryptodev_info dev_info;
6862 : :
6863 : : /* Check if device supports ZUC EEA3 */
6864 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6865 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6866 : : return TEST_SKIPPED;
6867 : :
6868 : : /* Check if device supports ZUC EIA3 */
6869 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6870 : 0 : tdata->key.len, tdata->auth_iv.len,
6871 : 0 : tdata->digest.len) < 0)
6872 : : return TEST_SKIPPED;
6873 : :
6874 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6875 : : return TEST_SKIPPED;
6876 : :
6877 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6878 : :
6879 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6880 : :
6881 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6882 : : printf("Device doesn't support digest encrypted.\n");
6883 : 0 : return TEST_SKIPPED;
6884 : : }
6885 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6886 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6887 : : printf("Device doesn't support in-place scatter-gather "
6888 : : "in both input and output mbufs.\n");
6889 : 0 : return TEST_SKIPPED;
6890 : : }
6891 : :
6892 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6893 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6894 : : printf("Device doesn't support RAW data-path APIs.\n");
6895 : 0 : return TEST_SKIPPED;
6896 : : }
6897 : : } else {
6898 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6899 : : return TEST_SKIPPED;
6900 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6901 : : printf("Device doesn't support out-of-place scatter-gather "
6902 : : "in both input and output mbufs.\n");
6903 : 0 : return TEST_SKIPPED;
6904 : : }
6905 : : }
6906 : :
6907 : : /* Create ZUC session */
6908 : 0 : retval = create_wireless_algo_auth_cipher_session(
6909 : 0 : ts_params->valid_devs[0],
6910 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6911 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6912 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6913 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6914 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6915 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6916 : : tdata->key.data, tdata->key.len,
6917 : 0 : tdata->key.data, tdata->key.len,
6918 : 0 : tdata->auth_iv.len, tdata->digest.len,
6919 : 0 : tdata->cipher_iv.len);
6920 : :
6921 [ # # ]: 0 : if (retval != 0)
6922 : : return retval;
6923 : :
6924 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6925 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6926 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6927 : :
6928 : : /* clear mbuf payload */
6929 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6930 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6931 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6932 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6933 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6934 : :
6935 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6936 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6937 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6938 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6939 : :
6940 [ # # ]: 0 : if (verify) {
6941 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6942 : : ciphertext_pad_len);
6943 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6944 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6945 : : ciphertext_len);
6946 : : } else {
6947 : : /* make sure enough space to cover partial digest verify case */
6948 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6949 : : ciphertext_pad_len);
6950 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6951 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6952 : : plaintext_len);
6953 : : }
6954 : :
6955 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6956 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6957 : :
6958 : : /* Create ZUC operation */
6959 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6960 : 0 : tdata->digest.data, tdata->digest.len,
6961 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6962 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6963 : 0 : (tdata->digest.offset_bytes == 0 ?
6964 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6965 : : : tdata->digest.offset_bytes),
6966 : 0 : tdata->validCipherLenInBits.len,
6967 : 0 : tdata->validCipherOffsetInBits.len,
6968 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6969 : : 0,
6970 : : op_mode, 0, verify);
6971 : :
6972 [ # # ]: 0 : if (retval < 0)
6973 : : return retval;
6974 : :
6975 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6976 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6977 : 0 : tdata->cipher_iv.len);
6978 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6979 : : return retval;
6980 : : } else
6981 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6982 : : ut_params->op);
6983 : :
6984 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6985 : :
6986 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6987 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6988 : :
6989 : :
6990 [ # # ]: 0 : if (verify) {
6991 [ # # ]: 0 : if (ut_params->obuf)
6992 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6993 : : uint8_t *);
6994 : : else
6995 : : plaintext = ciphertext;
6996 : :
6997 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6998 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6999 : 0 : debug_hexdump(stdout, "plaintext expected:",
7000 : 0 : tdata->plaintext.data,
7001 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7002 : : } else {
7003 [ # # ]: 0 : if (ut_params->obuf)
7004 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7005 : : uint8_t *);
7006 : : else
7007 : : ciphertext = plaintext;
7008 : :
7009 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7010 : : ciphertext_len);
7011 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7012 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7013 : :
7014 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
7015 : : digest_offset = plaintext_pad_len;
7016 : : else
7017 : : digest_offset = tdata->digest.offset_bytes;
7018 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
7019 : : uint8_t *, digest_offset);
7020 : :
7021 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
7022 : 0 : tdata->digest.len);
7023 : 0 : debug_hexdump(stdout, "digest expected:",
7024 : 0 : tdata->digest.data, tdata->digest.len);
7025 : : }
7026 : :
7027 : : /* Validate obuf */
7028 [ # # ]: 0 : if (verify) {
7029 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7030 : : plaintext,
7031 : : tdata->plaintext.data,
7032 : : tdata->plaintext.len >> 3,
7033 : : "ZUC Plaintext data not as expected");
7034 : : } else {
7035 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7036 : : ciphertext,
7037 : : tdata->ciphertext.data,
7038 : : tdata->ciphertext.len >> 3,
7039 : : "ZUC Ciphertext data not as expected");
7040 : :
7041 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7042 : : ut_params->digest,
7043 : : tdata->digest.data,
7044 : : tdata->digest.len,
7045 : : "ZUC Generated auth tag not as expected");
7046 : : }
7047 : : return 0;
7048 : : }
7049 : :
7050 : : static int
7051 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
7052 : : uint8_t op_mode, uint8_t verify)
7053 : : {
7054 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7055 : : struct crypto_unittest_params *ut_params = &unittest_params;
7056 : :
7057 : : int retval;
7058 : :
7059 : : const uint8_t *plaintext = NULL;
7060 : : const uint8_t *ciphertext = NULL;
7061 : : const uint8_t *digest = NULL;
7062 : : unsigned int plaintext_pad_len;
7063 : : unsigned int plaintext_len;
7064 : : unsigned int ciphertext_pad_len;
7065 : : unsigned int ciphertext_len;
7066 : : uint8_t buffer[10000];
7067 : : uint8_t digest_buffer[10000];
7068 : :
7069 : : struct rte_cryptodev_info dev_info;
7070 : :
7071 : : /* Check if device supports ZUC EEA3 */
7072 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
7073 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
7074 : : return TEST_SKIPPED;
7075 : :
7076 : : /* Check if device supports ZUC EIA3 */
7077 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
7078 : 0 : tdata->key.len, tdata->auth_iv.len,
7079 : 0 : tdata->digest.len) < 0)
7080 : : return TEST_SKIPPED;
7081 : :
7082 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7083 : : return TEST_SKIPPED;
7084 : :
7085 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7086 : :
7087 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7088 : :
7089 [ # # ]: 0 : if (op_mode == IN_PLACE) {
7090 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7091 : : printf("Device doesn't support in-place scatter-gather "
7092 : : "in both input and output mbufs.\n");
7093 : 0 : return TEST_SKIPPED;
7094 : : }
7095 : :
7096 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7097 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7098 : : printf("Device doesn't support RAW data-path APIs.\n");
7099 : 0 : return TEST_SKIPPED;
7100 : : }
7101 : : } else {
7102 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7103 : : return TEST_SKIPPED;
7104 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7105 : : printf("Device doesn't support out-of-place scatter-gather "
7106 : : "in both input and output mbufs.\n");
7107 : 0 : return TEST_SKIPPED;
7108 : : }
7109 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7110 : : printf("Device doesn't support digest encrypted.\n");
7111 : 0 : return TEST_SKIPPED;
7112 : : }
7113 : : }
7114 : :
7115 : : /* Create ZUC session */
7116 : 0 : retval = create_wireless_algo_auth_cipher_session(
7117 : 0 : ts_params->valid_devs[0],
7118 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7119 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7120 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7121 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
7122 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
7123 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
7124 : : tdata->key.data, tdata->key.len,
7125 : 0 : tdata->key.data, tdata->key.len,
7126 : 0 : tdata->auth_iv.len, tdata->digest.len,
7127 : 0 : tdata->cipher_iv.len);
7128 : :
7129 [ # # ]: 0 : if (retval != 0)
7130 : : return retval;
7131 : :
7132 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7133 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
7134 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7135 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7136 : :
7137 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7138 : : plaintext_pad_len, 15, 0);
7139 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7140 : : "Failed to allocate input buffer in mempool");
7141 : :
7142 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
7143 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7144 : : plaintext_pad_len, 15, 0);
7145 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
7146 : : "Failed to allocate output buffer in mempool");
7147 : : }
7148 : :
7149 [ # # ]: 0 : if (verify) {
7150 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7151 : 0 : tdata->ciphertext.data);
7152 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7153 : : ciphertext_len, buffer);
7154 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7155 : : ciphertext_len);
7156 : : } else {
7157 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7158 : 0 : tdata->plaintext.data);
7159 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7160 : : plaintext_len, buffer);
7161 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7162 : : plaintext_len);
7163 : : }
7164 : : memset(buffer, 0, sizeof(buffer));
7165 : :
7166 : : /* Create ZUC operation */
7167 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7168 : 0 : tdata->digest.data, tdata->digest.len,
7169 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7170 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7171 : 0 : (tdata->digest.offset_bytes == 0 ?
7172 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7173 : : : tdata->digest.offset_bytes),
7174 : 0 : tdata->validCipherLenInBits.len,
7175 : 0 : tdata->validCipherOffsetInBits.len,
7176 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7177 : : 0,
7178 : : op_mode, 1, verify);
7179 : :
7180 [ # # ]: 0 : if (retval < 0)
7181 : : return retval;
7182 : :
7183 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7184 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7185 : 0 : tdata->cipher_iv.len);
7186 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7187 : : return retval;
7188 : : } else
7189 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7190 : : ut_params->op);
7191 : :
7192 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7193 : :
7194 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7195 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7196 : :
7197 [ # # ]: 0 : if (verify) {
7198 [ # # ]: 0 : if (ut_params->obuf)
7199 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7200 : : plaintext_len, buffer);
7201 : : else
7202 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7203 : : plaintext_len, buffer);
7204 : :
7205 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7206 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7207 : 0 : debug_hexdump(stdout, "plaintext expected:",
7208 : 0 : tdata->plaintext.data,
7209 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7210 : : } else {
7211 [ # # ]: 0 : if (ut_params->obuf)
7212 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7213 : : ciphertext_len, buffer);
7214 : : else
7215 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7216 : : ciphertext_len, buffer);
7217 : :
7218 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7219 : : ciphertext_len);
7220 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7221 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7222 : :
7223 [ # # ]: 0 : if (ut_params->obuf)
7224 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
7225 : 0 : (tdata->digest.offset_bytes == 0 ?
7226 : : plaintext_pad_len : tdata->digest.offset_bytes),
7227 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7228 : : else
7229 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
7230 : 0 : (tdata->digest.offset_bytes == 0 ?
7231 : : plaintext_pad_len : tdata->digest.offset_bytes),
7232 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7233 : :
7234 : 0 : debug_hexdump(stdout, "digest:", digest,
7235 : 0 : tdata->digest.len);
7236 : 0 : debug_hexdump(stdout, "digest expected:",
7237 : 0 : tdata->digest.data, tdata->digest.len);
7238 : : }
7239 : :
7240 : : /* Validate obuf */
7241 [ # # ]: 0 : if (verify) {
7242 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7243 : : plaintext,
7244 : : tdata->plaintext.data,
7245 : : tdata->plaintext.len >> 3,
7246 : : "ZUC Plaintext data not as expected");
7247 : : } else {
7248 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7249 : : ciphertext,
7250 : : tdata->ciphertext.data,
7251 : : tdata->validDataLenInBits.len,
7252 : : "ZUC Ciphertext data not as expected");
7253 : :
7254 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7255 : : digest,
7256 : : tdata->digest.data,
7257 : : tdata->digest.len,
7258 : : "ZUC Generated auth tag not as expected");
7259 : : }
7260 : : return 0;
7261 : : }
7262 : :
7263 : : static int
7264 : 0 : test_kasumi_encryption_test_case_1(void)
7265 : : {
7266 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
7267 : : }
7268 : :
7269 : : static int
7270 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
7271 : : {
7272 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7273 : : }
7274 : :
7275 : : static int
7276 : 0 : test_kasumi_encryption_test_case_1_oop(void)
7277 : : {
7278 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
7279 : : }
7280 : :
7281 : : static int
7282 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
7283 : : {
7284 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7285 : : }
7286 : :
7287 : : static int
7288 : 0 : test_kasumi_encryption_test_case_2(void)
7289 : : {
7290 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
7291 : : }
7292 : :
7293 : : static int
7294 : 0 : test_kasumi_encryption_test_case_3(void)
7295 : : {
7296 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
7297 : : }
7298 : :
7299 : : static int
7300 : 0 : test_kasumi_encryption_test_case_4(void)
7301 : : {
7302 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
7303 : : }
7304 : :
7305 : : static int
7306 : 0 : test_kasumi_encryption_test_case_5(void)
7307 : : {
7308 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
7309 : : }
7310 : :
7311 : : static int
7312 : 0 : test_kasumi_decryption_test_case_1(void)
7313 : : {
7314 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
7315 : : }
7316 : :
7317 : : static int
7318 : 0 : test_kasumi_decryption_test_case_1_oop(void)
7319 : : {
7320 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
7321 : : }
7322 : :
7323 : : static int
7324 : 0 : test_kasumi_decryption_test_case_2(void)
7325 : : {
7326 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
7327 : : }
7328 : :
7329 : : static int
7330 : 0 : test_kasumi_decryption_test_case_3(void)
7331 : : {
7332 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7333 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7334 : : return TEST_SKIPPED;
7335 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7336 : : }
7337 : :
7338 : : static int
7339 : 0 : test_kasumi_decryption_test_case_4(void)
7340 : : {
7341 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7342 : : }
7343 : :
7344 : : static int
7345 : 0 : test_kasumi_decryption_test_case_5(void)
7346 : : {
7347 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7348 : : }
7349 : : static int
7350 : 0 : test_snow3g_encryption_test_case_1(void)
7351 : : {
7352 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7353 : : }
7354 : :
7355 : : static int
7356 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7357 : : {
7358 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7359 : : }
7360 : :
7361 : : static int
7362 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7363 : : {
7364 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7365 : : }
7366 : :
7367 : : static int
7368 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7369 : : {
7370 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7371 : : }
7372 : :
7373 : : static int
7374 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7375 : : {
7376 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7377 : : }
7378 : :
7379 : : static int
7380 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7381 : : {
7382 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7383 : : }
7384 : :
7385 : : static int
7386 : 0 : test_snow3g_encryption_test_case_2(void)
7387 : : {
7388 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7389 : : }
7390 : :
7391 : : static int
7392 : 0 : test_snow3g_encryption_test_case_3(void)
7393 : : {
7394 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7395 : : }
7396 : :
7397 : : static int
7398 : 0 : test_snow3g_encryption_test_case_4(void)
7399 : : {
7400 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7401 : : }
7402 : :
7403 : : static int
7404 : 0 : test_snow3g_encryption_test_case_5(void)
7405 : : {
7406 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7407 : : }
7408 : :
7409 : : static int
7410 : 0 : test_snow3g_decryption_test_case_1(void)
7411 : : {
7412 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7413 : : }
7414 : :
7415 : : static int
7416 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7417 : : {
7418 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7419 : : }
7420 : :
7421 : : static int
7422 : 0 : test_snow3g_decryption_test_case_2(void)
7423 : : {
7424 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7425 : : }
7426 : :
7427 : : static int
7428 : 0 : test_snow3g_decryption_test_case_3(void)
7429 : : {
7430 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7431 : : }
7432 : :
7433 : : static int
7434 : 0 : test_snow3g_decryption_test_case_4(void)
7435 : : {
7436 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7437 : : }
7438 : :
7439 : : static int
7440 : 0 : test_snow3g_decryption_test_case_5(void)
7441 : : {
7442 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7443 : : }
7444 : :
7445 : : /*
7446 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7447 : : * Pattern digest from snow3g_test_data must be allocated as
7448 : : * 4 last bytes in plaintext.
7449 : : */
7450 : : static void
7451 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7452 : : struct snow3g_hash_test_data *output)
7453 : : {
7454 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7455 : 0 : output->key.len = pattern->key.len;
7456 : :
7457 : 0 : memcpy(output->key.data,
7458 : 0 : pattern->key.data, pattern->key.len);
7459 : :
7460 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7461 : :
7462 : 0 : memcpy(output->auth_iv.data,
7463 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7464 : :
7465 : 0 : output->plaintext.len = pattern->plaintext.len;
7466 : :
7467 : 0 : memcpy(output->plaintext.data,
7468 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7469 : :
7470 : 0 : output->digest.len = pattern->digest.len;
7471 : :
7472 : 0 : memcpy(output->digest.data,
7473 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7474 : : pattern->digest.len);
7475 : :
7476 : 0 : output->validAuthLenInBits.len =
7477 : 0 : pattern->validAuthLenInBits.len;
7478 : : }
7479 : 0 : }
7480 : :
7481 : : /*
7482 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7483 : : */
7484 : : static int
7485 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7486 : : {
7487 : : int ret;
7488 : : struct snow3g_hash_test_data snow3g_hash_data;
7489 : : struct rte_cryptodev_info dev_info;
7490 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7491 : :
7492 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7493 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7494 : :
7495 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7496 : : printf("Device doesn't support encrypted digest operations.\n");
7497 : 0 : return TEST_SKIPPED;
7498 : : }
7499 : :
7500 : : /*
7501 : : * Function prepare data for hash verification test case.
7502 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7503 : : */
7504 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7505 : :
7506 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7507 [ # # ]: 0 : if (ret != 0)
7508 : : return ret;
7509 : :
7510 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7511 : : }
7512 : :
7513 : : static int
7514 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7515 : : {
7516 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7517 : : }
7518 : :
7519 : : static int
7520 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7521 : : {
7522 : 0 : return test_snow3g_auth_cipher(
7523 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7524 : : }
7525 : :
7526 : : static int
7527 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7528 : : {
7529 : 0 : return test_snow3g_auth_cipher(
7530 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7531 : : }
7532 : :
7533 : : static int
7534 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7535 : : {
7536 : 0 : return test_snow3g_auth_cipher(
7537 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7538 : : }
7539 : :
7540 : : static int
7541 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7542 : : {
7543 : 0 : return test_snow3g_auth_cipher(
7544 : : &snow3g_auth_cipher_partial_digest_encryption,
7545 : : IN_PLACE, 0);
7546 : : }
7547 : :
7548 : : static int
7549 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7550 : : {
7551 : 0 : return test_snow3g_auth_cipher(
7552 : : &snow3g_auth_cipher_partial_digest_encryption,
7553 : : OUT_OF_PLACE, 0);
7554 : : }
7555 : :
7556 : : static int
7557 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7558 : : {
7559 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7560 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7561 : : return TEST_SKIPPED;
7562 : 0 : return test_snow3g_auth_cipher_sgl(
7563 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7564 : : }
7565 : :
7566 : : static int
7567 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7568 : : {
7569 : 0 : return test_snow3g_auth_cipher_sgl(
7570 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7571 : : }
7572 : :
7573 : : static int
7574 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7575 : : {
7576 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7577 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7578 : : return TEST_SKIPPED;
7579 : 0 : return test_snow3g_auth_cipher_sgl(
7580 : : &snow3g_auth_cipher_partial_digest_encryption,
7581 : : IN_PLACE, 0);
7582 : : }
7583 : :
7584 : : static int
7585 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7586 : : {
7587 : 0 : return test_snow3g_auth_cipher_sgl(
7588 : : &snow3g_auth_cipher_partial_digest_encryption,
7589 : : OUT_OF_PLACE, 0);
7590 : : }
7591 : :
7592 : : static int
7593 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7594 : : {
7595 : 0 : return test_snow3g_auth_cipher(
7596 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7597 : : }
7598 : :
7599 : : static int
7600 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7601 : : {
7602 : 0 : return test_snow3g_auth_cipher(
7603 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7604 : : }
7605 : :
7606 : : static int
7607 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7608 : : {
7609 : 0 : return test_snow3g_auth_cipher_sgl(
7610 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7611 : : }
7612 : :
7613 : : static int
7614 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7615 : : {
7616 : 0 : return test_snow3g_auth_cipher_sgl(
7617 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7618 : : }
7619 : :
7620 : : static int
7621 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7622 : : {
7623 : 0 : return test_snow3g_auth_cipher(
7624 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7625 : : }
7626 : :
7627 : : static int
7628 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7629 : : {
7630 : 0 : return test_snow3g_auth_cipher(
7631 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7632 : : }
7633 : :
7634 : : static int
7635 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7636 : : {
7637 : 0 : return test_snow3g_auth_cipher(
7638 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7639 : : }
7640 : :
7641 : : static int
7642 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7643 : : {
7644 : 0 : return test_snow3g_auth_cipher(
7645 : : &snow3g_auth_cipher_partial_digest_encryption,
7646 : : IN_PLACE, 1);
7647 : : }
7648 : :
7649 : : static int
7650 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7651 : : {
7652 : 0 : return test_snow3g_auth_cipher(
7653 : : &snow3g_auth_cipher_partial_digest_encryption,
7654 : : OUT_OF_PLACE, 1);
7655 : : }
7656 : :
7657 : : static int
7658 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7659 : : {
7660 : 0 : return test_snow3g_auth_cipher_sgl(
7661 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7662 : : }
7663 : :
7664 : : static int
7665 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7666 : : {
7667 : 0 : return test_snow3g_auth_cipher_sgl(
7668 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7669 : : }
7670 : :
7671 : : static int
7672 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7673 : : {
7674 : 0 : return test_snow3g_auth_cipher_sgl(
7675 : : &snow3g_auth_cipher_partial_digest_encryption,
7676 : : IN_PLACE, 1);
7677 : : }
7678 : :
7679 : : static int
7680 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7681 : : {
7682 : 0 : return test_snow3g_auth_cipher_sgl(
7683 : : &snow3g_auth_cipher_partial_digest_encryption,
7684 : : OUT_OF_PLACE, 1);
7685 : : }
7686 : :
7687 : : static int
7688 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7689 : : {
7690 : 0 : return test_snow3g_auth_cipher(
7691 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7692 : : }
7693 : :
7694 : : static int
7695 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7696 : : {
7697 : 0 : return test_snow3g_auth_cipher(
7698 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7699 : : }
7700 : :
7701 : : static int
7702 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7703 : : {
7704 : 0 : return test_snow3g_auth_cipher_sgl(
7705 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7706 : : }
7707 : :
7708 : : static int
7709 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7710 : : {
7711 : 0 : return test_snow3g_auth_cipher_sgl(
7712 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7713 : : }
7714 : :
7715 : : static int
7716 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7717 : : {
7718 : 0 : return test_snow3g_auth_cipher(
7719 : : &snow3g_test_case_7, IN_PLACE, 0);
7720 : : }
7721 : :
7722 : : static int
7723 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7724 : : {
7725 : 0 : return test_kasumi_auth_cipher(
7726 : : &kasumi_test_case_3, IN_PLACE, 0);
7727 : : }
7728 : :
7729 : : static int
7730 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7731 : : {
7732 : 0 : return test_kasumi_auth_cipher(
7733 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7734 : : }
7735 : :
7736 : : static int
7737 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7738 : : {
7739 : 0 : return test_kasumi_auth_cipher(
7740 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7741 : : }
7742 : :
7743 : : static int
7744 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7745 : : {
7746 : 0 : return test_kasumi_auth_cipher_sgl(
7747 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7748 : : }
7749 : :
7750 : : static int
7751 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7752 : : {
7753 : 0 : return test_kasumi_auth_cipher_sgl(
7754 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7755 : : }
7756 : :
7757 : : static int
7758 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7759 : : {
7760 : 0 : return test_kasumi_auth_cipher(
7761 : : &kasumi_test_case_3, IN_PLACE, 1);
7762 : : }
7763 : :
7764 : : static int
7765 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7766 : : {
7767 : 0 : return test_kasumi_auth_cipher(
7768 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7769 : : }
7770 : :
7771 : : static int
7772 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7773 : : {
7774 : 0 : return test_kasumi_auth_cipher(
7775 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7776 : : }
7777 : :
7778 : : static int
7779 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7780 : : {
7781 : 0 : return test_kasumi_auth_cipher_sgl(
7782 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7783 : : }
7784 : :
7785 : : static int
7786 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7787 : : {
7788 : 0 : return test_kasumi_auth_cipher_sgl(
7789 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7790 : : }
7791 : :
7792 : : static int
7793 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7794 : : {
7795 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7796 : : }
7797 : :
7798 : : static int
7799 : 0 : test_zuc_encryption_test_case_1(void)
7800 : : {
7801 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7802 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7803 : : }
7804 : :
7805 : : static int
7806 : 0 : test_zuc_encryption_test_case_2(void)
7807 : : {
7808 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7809 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7810 : : }
7811 : :
7812 : : static int
7813 : 0 : test_zuc_encryption_test_case_3(void)
7814 : : {
7815 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7816 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7817 : : }
7818 : :
7819 : : static int
7820 : 0 : test_zuc_encryption_test_case_4(void)
7821 : : {
7822 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7823 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7824 : : }
7825 : :
7826 : : static int
7827 : 0 : test_zuc_encryption_test_case_5(void)
7828 : : {
7829 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7830 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7831 : : }
7832 : :
7833 : : static int
7834 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7835 : : {
7836 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7837 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7838 : : }
7839 : :
7840 : : static int
7841 : 0 : test_zuc_decryption_test_case_1(void)
7842 : : {
7843 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7844 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7845 : : }
7846 : :
7847 : : static int
7848 : 0 : test_zuc_decryption_test_case_2(void)
7849 : : {
7850 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7851 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7852 : : }
7853 : :
7854 : : static int
7855 : 0 : test_zuc_decryption_test_case_3(void)
7856 : : {
7857 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7858 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7859 : : }
7860 : :
7861 : : static int
7862 : 0 : test_zuc_decryption_test_case_4(void)
7863 : : {
7864 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7865 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7866 : : }
7867 : :
7868 : : static int
7869 : 0 : test_zuc_decryption_test_case_5(void)
7870 : : {
7871 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7872 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7873 : : }
7874 : :
7875 : : static int
7876 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7877 : : {
7878 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7879 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7880 : : }
7881 : :
7882 : : static int
7883 : 0 : test_zuc_hash_generate_test_case_1(void)
7884 : : {
7885 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7886 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7887 : : }
7888 : :
7889 : : static int
7890 : 0 : test_zuc_hash_generate_test_case_2(void)
7891 : : {
7892 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7893 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7894 : : }
7895 : :
7896 : : static int
7897 : 0 : test_zuc_hash_generate_test_case_3(void)
7898 : : {
7899 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7900 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7901 : : }
7902 : :
7903 : : static int
7904 : 0 : test_zuc_hash_generate_test_case_4(void)
7905 : : {
7906 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7907 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7908 : : }
7909 : :
7910 : : static int
7911 : 0 : test_zuc_hash_generate_test_case_5(void)
7912 : : {
7913 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7914 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7915 : : }
7916 : :
7917 : : static int
7918 : 0 : test_zuc_hash_generate_test_case_6(void)
7919 : : {
7920 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7921 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7922 : : }
7923 : :
7924 : : static int
7925 : 0 : test_zuc_hash_generate_test_case_7(void)
7926 : : {
7927 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7928 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7929 : : }
7930 : :
7931 : : static int
7932 : 0 : test_zuc_hash_generate_test_case_8(void)
7933 : : {
7934 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7935 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7936 : : }
7937 : :
7938 : : static int
7939 : 0 : test_zuc_hash_verify_test_case_1(void)
7940 : : {
7941 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7942 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7943 : : }
7944 : :
7945 : : static int
7946 : 0 : test_zuc_hash_verify_test_case_2(void)
7947 : : {
7948 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7949 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7950 : : }
7951 : :
7952 : : static int
7953 : 0 : test_zuc_hash_verify_test_case_3(void)
7954 : : {
7955 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7956 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7957 : : }
7958 : :
7959 : : static int
7960 : 0 : test_zuc_hash_verify_test_case_4(void)
7961 : : {
7962 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7963 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7964 : : }
7965 : :
7966 : : static int
7967 : 0 : test_zuc_hash_verify_test_case_5(void)
7968 : : {
7969 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7970 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7971 : : }
7972 : :
7973 : : static int
7974 : 0 : test_zuc_hash_verify_test_case_6(void)
7975 : : {
7976 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7977 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7978 : : }
7979 : :
7980 : : static int
7981 : 0 : test_zuc_hash_verify_test_case_7(void)
7982 : : {
7983 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7984 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7985 : : }
7986 : :
7987 : : static int
7988 : 0 : test_zuc_hash_verify_test_case_8(void)
7989 : : {
7990 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7991 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7992 : : }
7993 : :
7994 : : static int
7995 : 0 : test_zuc_cipher_auth_test_case_1(void)
7996 : : {
7997 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7998 : : }
7999 : :
8000 : : static int
8001 : 0 : test_zuc_cipher_auth_test_case_2(void)
8002 : : {
8003 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
8004 : : }
8005 : :
8006 : : static int
8007 : 0 : test_zuc_auth_cipher_test_case_1(void)
8008 : : {
8009 : 0 : return test_zuc_auth_cipher(
8010 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8011 : : }
8012 : :
8013 : : static int
8014 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
8015 : : {
8016 : 0 : return test_zuc_auth_cipher(
8017 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8018 : : }
8019 : :
8020 : : static int
8021 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
8022 : : {
8023 : 0 : return test_zuc_auth_cipher_sgl(
8024 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8025 : : }
8026 : :
8027 : : static int
8028 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
8029 : : {
8030 : 0 : return test_zuc_auth_cipher_sgl(
8031 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8032 : : }
8033 : :
8034 : : static int
8035 : 0 : test_zuc_auth_cipher_test_case_2(void)
8036 : : {
8037 : 0 : return test_zuc_auth_cipher(
8038 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
8039 : : }
8040 : :
8041 : : static int
8042 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
8043 : : {
8044 : 0 : return test_zuc_auth_cipher(
8045 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
8046 : : }
8047 : :
8048 : : static int
8049 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
8050 : : {
8051 : 0 : return test_zuc_auth_cipher(
8052 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8053 : : }
8054 : :
8055 : : static int
8056 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
8057 : : {
8058 : 0 : return test_zuc_auth_cipher(
8059 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8060 : : }
8061 : :
8062 : : static int
8063 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
8064 : : {
8065 : 0 : return test_zuc_auth_cipher_sgl(
8066 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8067 : : }
8068 : :
8069 : : static int
8070 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
8071 : : {
8072 : 0 : return test_zuc_auth_cipher_sgl(
8073 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8074 : : }
8075 : :
8076 : : static int
8077 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
8078 : : {
8079 : 0 : return test_zuc_auth_cipher(
8080 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
8081 : : }
8082 : :
8083 : : static int
8084 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
8085 : : {
8086 : 0 : return test_zuc_auth_cipher(
8087 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8088 : : }
8089 : :
8090 : : static int
8091 : 0 : test_zuc256_encryption_test_case_1(void)
8092 : : {
8093 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8094 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8095 : : }
8096 : :
8097 : : static int
8098 : 0 : test_zuc256_encryption_test_case_2(void)
8099 : : {
8100 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8101 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8102 : : }
8103 : :
8104 : : static int
8105 : 0 : test_zuc256_decryption_test_case_1(void)
8106 : : {
8107 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8108 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8109 : : }
8110 : :
8111 : : static int
8112 : 0 : test_zuc256_decryption_test_case_2(void)
8113 : : {
8114 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8115 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8116 : : }
8117 : :
8118 : : static int
8119 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
8120 : : {
8121 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8122 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8123 : : }
8124 : :
8125 : : static int
8126 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
8127 : : {
8128 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8129 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8130 : : }
8131 : :
8132 : : static int
8133 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
8134 : : {
8135 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8136 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8137 : : }
8138 : :
8139 : : static int
8140 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
8141 : : {
8142 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8143 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8144 : : }
8145 : :
8146 : : static int
8147 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
8148 : : {
8149 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8150 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8151 : : }
8152 : :
8153 : : static int
8154 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
8155 : : {
8156 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8157 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8158 : : }
8159 : :
8160 : : static int
8161 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
8162 : : {
8163 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8164 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8165 : : }
8166 : :
8167 : : static int
8168 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
8169 : : {
8170 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8171 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8172 : : }
8173 : :
8174 : : static int
8175 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
8176 : : {
8177 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8178 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8179 : : }
8180 : :
8181 : : static int
8182 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
8183 : : {
8184 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8185 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8186 : : }
8187 : :
8188 : : static int
8189 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8190 : : {
8191 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8192 : : }
8193 : :
8194 : : static int
8195 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8196 : : {
8197 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8198 : : }
8199 : :
8200 : : static int
8201 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8202 : : {
8203 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8204 : : }
8205 : :
8206 : : static int
8207 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8208 : : {
8209 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8210 : : }
8211 : :
8212 : : static int
8213 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8214 : : {
8215 : 0 : return test_zuc_auth_cipher(
8216 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8217 : : }
8218 : :
8219 : : static int
8220 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8221 : : {
8222 : 0 : return test_zuc_auth_cipher(
8223 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8224 : : }
8225 : :
8226 : : static int
8227 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8228 : : {
8229 : 0 : return test_zuc_auth_cipher(
8230 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8231 : : }
8232 : :
8233 : : static int
8234 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8235 : : {
8236 : 0 : return test_zuc_auth_cipher(
8237 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8238 : : }
8239 : :
8240 : : static int
8241 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8242 : : {
8243 : 0 : return test_zuc_auth_cipher(
8244 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8245 : : }
8246 : :
8247 : : static int
8248 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8249 : : {
8250 : 0 : return test_zuc_auth_cipher(
8251 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8252 : : }
8253 : :
8254 : : static int
8255 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8256 : : {
8257 : 0 : return test_zuc_auth_cipher(
8258 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8259 : : }
8260 : :
8261 : : static int
8262 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8263 : : {
8264 : 0 : return test_zuc_auth_cipher(
8265 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8266 : : }
8267 : :
8268 : : static int
8269 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8270 : : {
8271 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
8272 : :
8273 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8274 : :
8275 : : /* Check if device supports particular cipher algorithm */
8276 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8277 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
8278 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8279 : : return TEST_SKIPPED;
8280 : :
8281 : : /* Check if device supports particular hash algorithm */
8282 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8283 : 24 : cap_idx.algo.auth = tdata->auth_algo;
8284 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8285 : 12 : return TEST_SKIPPED;
8286 : :
8287 : : return 0;
8288 : : }
8289 : :
8290 : : static int
8291 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8292 : : uint8_t op_mode, uint8_t verify)
8293 : : {
8294 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8295 : : struct crypto_unittest_params *ut_params = &unittest_params;
8296 : :
8297 : : int retval;
8298 : :
8299 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
8300 : : unsigned int plaintext_pad_len;
8301 : : unsigned int plaintext_len;
8302 : : unsigned int ciphertext_pad_len;
8303 : : unsigned int ciphertext_len;
8304 : : unsigned int digest_offset;
8305 : :
8306 : : struct rte_cryptodev_info dev_info;
8307 : : struct rte_crypto_op *op;
8308 : :
8309 : : /* Check if device supports particular algorithms separately */
8310 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
8311 : : return TEST_SKIPPED;
8312 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8313 : : return TEST_SKIPPED;
8314 : :
8315 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8316 : : return TEST_SKIPPED;
8317 : :
8318 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8319 : :
8320 : 8 : uint64_t feat_flags = dev_info.feature_flags;
8321 : :
8322 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8323 : : printf("Device doesn't support digest encrypted.\n");
8324 : 8 : return TEST_SKIPPED;
8325 : : }
8326 : :
8327 : : /* Create the session */
8328 [ # # ]: 0 : if (verify)
8329 : 0 : retval = create_wireless_algo_cipher_auth_session(
8330 : 0 : ts_params->valid_devs[0],
8331 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8332 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8333 : 0 : tdata->auth_algo,
8334 : 0 : tdata->cipher_algo,
8335 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8336 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8337 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8338 : 0 : tdata->cipher_iv.len);
8339 : : else
8340 : 0 : retval = create_wireless_algo_auth_cipher_session(
8341 : 0 : ts_params->valid_devs[0],
8342 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8343 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8344 : 0 : tdata->auth_algo,
8345 : 0 : tdata->cipher_algo,
8346 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8347 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8348 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8349 : 0 : tdata->cipher_iv.len);
8350 [ # # ]: 0 : if (retval != 0)
8351 : : return retval;
8352 : :
8353 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8354 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8355 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8356 : :
8357 : : /* clear mbuf payload */
8358 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8359 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8360 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8361 : :
8362 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8363 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8364 : : }
8365 : :
8366 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8367 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8368 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8369 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8370 : :
8371 [ # # ]: 0 : if (verify) {
8372 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8373 : : ciphertext_pad_len);
8374 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8375 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8376 : : ciphertext_len);
8377 : : } else {
8378 : : /* make sure enough space to cover partial digest verify case */
8379 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8380 : : ciphertext_pad_len);
8381 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8382 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8383 : : }
8384 : :
8385 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8386 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8387 : :
8388 : : /* Create the operation */
8389 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8390 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8391 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8392 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8393 : 0 : (tdata->digest_enc.offset == 0 ?
8394 : : plaintext_pad_len
8395 : : : tdata->digest_enc.offset),
8396 : 0 : tdata->validCipherLen.len_bits,
8397 : 0 : tdata->cipher.offset_bits,
8398 : 0 : tdata->validAuthLen.len_bits,
8399 [ # # ]: 0 : tdata->auth.offset_bits,
8400 : : op_mode, 0, verify);
8401 : :
8402 [ # # ]: 0 : if (retval < 0)
8403 : : return retval;
8404 : :
8405 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8406 : :
8407 : : /* Check if the op failed because the device doesn't */
8408 : : /* support this particular combination of algorithms */
8409 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8410 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8411 : : printf("Device doesn't support this mixed combination. "
8412 : : "Test Skipped.\n");
8413 : 0 : return TEST_SKIPPED;
8414 : : }
8415 : 0 : ut_params->op = op;
8416 : :
8417 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8418 : :
8419 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8420 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8421 : :
8422 [ # # ]: 0 : if (verify) {
8423 [ # # ]: 0 : if (ut_params->obuf)
8424 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8425 : : uint8_t *);
8426 : : else
8427 : 0 : plaintext = ciphertext +
8428 : 0 : (tdata->cipher.offset_bits >> 3);
8429 : :
8430 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8431 : 0 : tdata->plaintext.len_bits >> 3);
8432 : 0 : debug_hexdump(stdout, "plaintext expected:",
8433 : 0 : tdata->plaintext.data,
8434 : 0 : tdata->plaintext.len_bits >> 3);
8435 : : } else {
8436 [ # # ]: 0 : if (ut_params->obuf)
8437 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8438 : : uint8_t *);
8439 : : else
8440 : : ciphertext = plaintext;
8441 : :
8442 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8443 : : ciphertext_len);
8444 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8445 : 0 : tdata->ciphertext.data,
8446 : 0 : tdata->ciphertext.len_bits >> 3);
8447 : :
8448 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8449 : : digest_offset = plaintext_pad_len;
8450 : : else
8451 : : digest_offset = tdata->digest_enc.offset;
8452 : :
8453 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8454 : : uint8_t *, digest_offset);
8455 : :
8456 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8457 : 0 : tdata->digest_enc.len);
8458 : 0 : debug_hexdump(stdout, "digest expected:",
8459 : : tdata->digest_enc.data,
8460 : 0 : tdata->digest_enc.len);
8461 : : }
8462 : :
8463 [ # # ]: 0 : if (!verify) {
8464 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8465 : : ut_params->digest,
8466 : : tdata->digest_enc.data,
8467 : : tdata->digest_enc.len,
8468 : : "Generated auth tag not as expected");
8469 : : }
8470 : :
8471 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8472 [ # # ]: 0 : if (verify) {
8473 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8474 : : plaintext,
8475 : : tdata->plaintext.data,
8476 : : tdata->plaintext.len_bits >> 3,
8477 : : "Plaintext data not as expected");
8478 : : } else {
8479 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8480 : : ciphertext,
8481 : : tdata->ciphertext.data,
8482 : : tdata->validDataLen.len_bits,
8483 : : "Ciphertext data not as expected");
8484 : : }
8485 : : }
8486 : :
8487 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8488 : : "crypto op processing failed");
8489 : :
8490 : : return 0;
8491 : : }
8492 : :
8493 : : static int
8494 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8495 : : uint8_t op_mode, uint8_t verify)
8496 : : {
8497 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8498 : : struct crypto_unittest_params *ut_params = &unittest_params;
8499 : :
8500 : : int retval;
8501 : :
8502 : : const uint8_t *plaintext = NULL;
8503 : : const uint8_t *ciphertext = NULL;
8504 : : const uint8_t *digest = NULL;
8505 : : unsigned int plaintext_pad_len;
8506 : : unsigned int plaintext_len;
8507 : : unsigned int ciphertext_pad_len;
8508 : : unsigned int ciphertext_len;
8509 : : uint8_t buffer[10000];
8510 : : uint8_t digest_buffer[10000];
8511 : :
8512 : : struct rte_cryptodev_info dev_info;
8513 : : struct rte_crypto_op *op;
8514 : :
8515 : : /* Check if device supports particular algorithms */
8516 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8517 : : return TEST_SKIPPED;
8518 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8519 : : return TEST_SKIPPED;
8520 : :
8521 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8522 : :
8523 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8524 : :
8525 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8526 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8527 : : printf("Device doesn't support in-place scatter-gather "
8528 : : "in both input and output mbufs.\n");
8529 : 0 : return TEST_SKIPPED;
8530 : : }
8531 : : } else {
8532 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8533 : : printf("Device doesn't support out-of-place scatter-gather "
8534 : : "in both input and output mbufs.\n");
8535 : 2 : return TEST_SKIPPED;
8536 : : }
8537 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8538 : : printf("Device doesn't support digest encrypted.\n");
8539 : 0 : return TEST_SKIPPED;
8540 : : }
8541 : : }
8542 : :
8543 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8544 : : return TEST_SKIPPED;
8545 : :
8546 : : /* Create the session */
8547 [ + + ]: 2 : if (verify)
8548 : 1 : retval = create_wireless_algo_cipher_auth_session(
8549 : 1 : ts_params->valid_devs[0],
8550 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8551 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8552 : 1 : tdata->auth_algo,
8553 : 1 : tdata->cipher_algo,
8554 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8555 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8556 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8557 : 1 : tdata->cipher_iv.len);
8558 : : else
8559 : 1 : retval = create_wireless_algo_auth_cipher_session(
8560 : 1 : ts_params->valid_devs[0],
8561 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8562 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8563 : 1 : tdata->auth_algo,
8564 : 1 : tdata->cipher_algo,
8565 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8566 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8567 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8568 : 1 : tdata->cipher_iv.len);
8569 [ + - ]: 2 : if (retval != 0)
8570 : : return retval;
8571 : :
8572 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8573 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8574 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8575 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8576 : :
8577 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8578 : : ciphertext_pad_len, 15, 0);
8579 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8580 : : "Failed to allocate input buffer in mempool");
8581 : :
8582 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8583 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8584 : : plaintext_pad_len, 15, 0);
8585 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8586 : : "Failed to allocate output buffer in mempool");
8587 : : }
8588 : :
8589 [ + + ]: 2 : if (verify) {
8590 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8591 : 1 : tdata->ciphertext.data);
8592 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8593 : : ciphertext_len, buffer);
8594 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8595 : : ciphertext_len);
8596 : : } else {
8597 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8598 : 1 : tdata->plaintext.data);
8599 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8600 : : plaintext_len, buffer);
8601 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8602 : : plaintext_len);
8603 : : }
8604 : : memset(buffer, 0, sizeof(buffer));
8605 : :
8606 : : /* Create the operation */
8607 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8608 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8609 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8610 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8611 : 2 : (tdata->digest_enc.offset == 0 ?
8612 : : plaintext_pad_len
8613 : : : tdata->digest_enc.offset),
8614 : 2 : tdata->validCipherLen.len_bits,
8615 : 2 : tdata->cipher.offset_bits,
8616 : 2 : tdata->validAuthLen.len_bits,
8617 [ + - ]: 2 : tdata->auth.offset_bits,
8618 : : op_mode, 1, verify);
8619 : :
8620 [ + - ]: 2 : if (retval < 0)
8621 : : return retval;
8622 : :
8623 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8624 : :
8625 : : /* Check if the op failed because the device doesn't */
8626 : : /* support this particular combination of algorithms */
8627 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8628 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8629 : : printf("Device doesn't support this mixed combination. "
8630 : : "Test Skipped.\n");
8631 : 0 : return TEST_SKIPPED;
8632 : : }
8633 : 2 : ut_params->op = op;
8634 : :
8635 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8636 : :
8637 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8638 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8639 : :
8640 [ + + ]: 2 : if (verify) {
8641 [ + - ]: 1 : if (ut_params->obuf)
8642 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8643 : : plaintext_len, buffer);
8644 : : else
8645 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8646 : : plaintext_len, buffer);
8647 : :
8648 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8649 : 1 : (tdata->plaintext.len_bits >> 3) -
8650 : 1 : tdata->digest_enc.len);
8651 : 1 : debug_hexdump(stdout, "plaintext expected:",
8652 : 1 : tdata->plaintext.data,
8653 : 1 : (tdata->plaintext.len_bits >> 3) -
8654 : 1 : tdata->digest_enc.len);
8655 : : } else {
8656 [ + - ]: 1 : if (ut_params->obuf)
8657 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8658 : : ciphertext_len, buffer);
8659 : : else
8660 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8661 : : ciphertext_len, buffer);
8662 : :
8663 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8664 : : ciphertext_len);
8665 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8666 : 1 : tdata->ciphertext.data,
8667 : 1 : tdata->ciphertext.len_bits >> 3);
8668 : :
8669 [ + - ]: 1 : if (ut_params->obuf)
8670 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8671 : 1 : (tdata->digest_enc.offset == 0 ?
8672 : : plaintext_pad_len :
8673 : : tdata->digest_enc.offset),
8674 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8675 : : else
8676 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8677 : 0 : (tdata->digest_enc.offset == 0 ?
8678 : : plaintext_pad_len :
8679 : : tdata->digest_enc.offset),
8680 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8681 : :
8682 : 1 : debug_hexdump(stdout, "digest:", digest,
8683 : 1 : tdata->digest_enc.len);
8684 : 1 : debug_hexdump(stdout, "digest expected:",
8685 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8686 : : }
8687 : :
8688 [ + + ]: 2 : if (!verify) {
8689 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8690 : : digest,
8691 : : tdata->digest_enc.data,
8692 : : tdata->digest_enc.len,
8693 : : "Generated auth tag not as expected");
8694 : : }
8695 : :
8696 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8697 [ + + ]: 2 : if (verify) {
8698 [ - + + - : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- + ]
8699 : : plaintext,
8700 : : tdata->plaintext.data,
8701 : : tdata->plaintext.len_bits >> 3,
8702 : : "Plaintext data not as expected");
8703 : : } else {
8704 [ - + - + : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- - ]
8705 : : ciphertext,
8706 : : tdata->ciphertext.data,
8707 : : tdata->validDataLen.len_bits,
8708 : : "Ciphertext data not as expected");
8709 : : }
8710 : : }
8711 : :
8712 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8713 : : "crypto op processing failed");
8714 : :
8715 : : return 0;
8716 : : }
8717 : :
8718 : : /** AUTH AES CMAC + CIPHER AES CTR */
8719 : :
8720 : : static int
8721 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8722 : : {
8723 : 1 : return test_mixed_auth_cipher(
8724 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8725 : : }
8726 : :
8727 : : static int
8728 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8729 : : {
8730 : 1 : return test_mixed_auth_cipher(
8731 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8732 : : }
8733 : :
8734 : : static int
8735 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8736 : : {
8737 : 1 : return test_mixed_auth_cipher_sgl(
8738 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8739 : : }
8740 : :
8741 : : static int
8742 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8743 : : {
8744 : 1 : return test_mixed_auth_cipher_sgl(
8745 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8746 : : }
8747 : :
8748 : : static int
8749 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8750 : : {
8751 : 1 : return test_mixed_auth_cipher(
8752 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8753 : : }
8754 : :
8755 : : static int
8756 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8757 : : {
8758 : 1 : return test_mixed_auth_cipher(
8759 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8760 : : }
8761 : :
8762 : : static int
8763 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8764 : : {
8765 : 1 : return test_mixed_auth_cipher(
8766 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8767 : : }
8768 : :
8769 : : static int
8770 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8771 : : {
8772 : 1 : return test_mixed_auth_cipher(
8773 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8774 : : }
8775 : :
8776 : : static int
8777 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8778 : : {
8779 : 1 : return test_mixed_auth_cipher(
8780 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8781 : : }
8782 : :
8783 : : static int
8784 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8785 : : {
8786 : 1 : return test_mixed_auth_cipher_sgl(
8787 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8788 : : }
8789 : :
8790 : : static int
8791 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8792 : : {
8793 : 1 : return test_mixed_auth_cipher_sgl(
8794 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8795 : : }
8796 : :
8797 : : static int
8798 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8799 : : {
8800 : 1 : return test_mixed_auth_cipher(
8801 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8802 : : }
8803 : :
8804 : : /** MIXED AUTH + CIPHER */
8805 : :
8806 : : static int
8807 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8808 : : {
8809 : 1 : return test_mixed_auth_cipher(
8810 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8811 : : }
8812 : :
8813 : : static int
8814 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8815 : : {
8816 : 1 : return test_mixed_auth_cipher(
8817 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8818 : : }
8819 : :
8820 : : static int
8821 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8822 : : {
8823 : 1 : return test_mixed_auth_cipher(
8824 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8825 : : }
8826 : :
8827 : : static int
8828 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8829 : : {
8830 : 1 : return test_mixed_auth_cipher(
8831 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8832 : : }
8833 : :
8834 : :
8835 : : static int
8836 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8837 : : {
8838 : 1 : return test_mixed_auth_cipher(
8839 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8840 : : }
8841 : :
8842 : : static int
8843 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8844 : : {
8845 : 1 : return test_mixed_auth_cipher(
8846 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8847 : : }
8848 : :
8849 : : static int
8850 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8851 : : {
8852 : 1 : return test_mixed_auth_cipher(
8853 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8854 : : }
8855 : :
8856 : : static int
8857 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8858 : : {
8859 : 1 : return test_mixed_auth_cipher(
8860 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8861 : : }
8862 : :
8863 : : static int
8864 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8865 : : {
8866 : 1 : return test_mixed_auth_cipher(
8867 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8868 : : }
8869 : :
8870 : : static int
8871 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8872 : : {
8873 : 1 : return test_mixed_auth_cipher(
8874 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8875 : : }
8876 : :
8877 : : static int
8878 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8879 : : {
8880 : 1 : return test_mixed_auth_cipher(
8881 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8882 : : }
8883 : :
8884 : : static int
8885 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8886 : : {
8887 : 1 : return test_mixed_auth_cipher(
8888 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8889 : : }
8890 : :
8891 : : static int
8892 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8893 : : {
8894 : 1 : return test_mixed_auth_cipher(
8895 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8896 : : }
8897 : :
8898 : : static int
8899 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8900 : : {
8901 : 1 : return test_mixed_auth_cipher(
8902 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8903 : : }
8904 : :
8905 : : static int
8906 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8907 : : {
8908 : 1 : return test_mixed_auth_cipher_sgl(
8909 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8910 : : }
8911 : :
8912 : : static int
8913 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8914 : : {
8915 : 1 : return test_mixed_auth_cipher(
8916 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8917 : : }
8918 : :
8919 : : static int
8920 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8921 : : {
8922 : 1 : return test_mixed_auth_cipher_sgl(
8923 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8924 : : }
8925 : :
8926 : : static int
8927 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8928 : : {
8929 : 1 : return test_mixed_auth_cipher(
8930 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8931 : : }
8932 : :
8933 : : static int
8934 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8935 : : {
8936 : 1 : return test_mixed_auth_cipher(
8937 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8938 : : }
8939 : :
8940 : : static int
8941 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8942 : : {
8943 : 1 : return test_mixed_auth_cipher(
8944 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8945 : : }
8946 : :
8947 : : static int
8948 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8949 : : {
8950 : 1 : return test_mixed_auth_cipher(
8951 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8952 : : }
8953 : :
8954 : : static int
8955 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8956 : : {
8957 : 1 : return test_mixed_auth_cipher(
8958 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8959 : : }
8960 : :
8961 : : static int
8962 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8963 : : {
8964 : 1 : return test_mixed_auth_cipher(
8965 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8966 : : }
8967 : :
8968 : : static int
8969 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8970 : : {
8971 : 1 : return test_mixed_auth_cipher(
8972 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8973 : : }
8974 : : static int
8975 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8976 : : {
8977 : 1 : return test_mixed_auth_cipher(
8978 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8979 : : }
8980 : :
8981 : : static int
8982 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8983 : : {
8984 : 1 : return test_mixed_auth_cipher(
8985 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8986 : : }
8987 : :
8988 : : static int
8989 : 1 : test_auth_null_cipher_snow_test_case_1(void)
8990 : : {
8991 : 1 : return test_mixed_auth_cipher(
8992 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8993 : : }
8994 : :
8995 : : static int
8996 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
8997 : : {
8998 : 1 : return test_mixed_auth_cipher(
8999 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
9000 : : }
9001 : :
9002 : : static int
9003 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
9004 : : {
9005 : 1 : return test_mixed_auth_cipher(
9006 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9007 : : }
9008 : :
9009 : : static int
9010 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
9011 : : {
9012 : 1 : return test_mixed_auth_cipher(
9013 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9014 : : }
9015 : :
9016 : : static int
9017 : 1 : test_auth_snow_cipher_null_test_case_1(void)
9018 : : {
9019 : 1 : return test_mixed_auth_cipher(
9020 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9021 : : }
9022 : :
9023 : : static int
9024 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
9025 : : {
9026 : 1 : return test_mixed_auth_cipher(
9027 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9028 : : }
9029 : :
9030 : : static int
9031 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
9032 : : {
9033 : 1 : return test_mixed_auth_cipher(
9034 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9035 : : }
9036 : :
9037 : : static int
9038 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
9039 : : {
9040 : 1 : return test_mixed_auth_cipher(
9041 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9042 : : }
9043 : :
9044 : : static int
9045 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
9046 : : {
9047 : 1 : return test_mixed_auth_cipher(
9048 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
9049 : : }
9050 : :
9051 : : static int
9052 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
9053 : : {
9054 : 1 : return test_mixed_auth_cipher(
9055 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
9056 : : }
9057 : :
9058 : : static int
9059 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
9060 : : {
9061 : 1 : return test_mixed_auth_cipher(
9062 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9063 : : }
9064 : :
9065 : : static int
9066 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
9067 : : {
9068 : 1 : return test_mixed_auth_cipher(
9069 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9070 : : }
9071 : :
9072 : : /* ***** AEAD algorithm Tests ***** */
9073 : :
9074 : : static int
9075 : 85 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
9076 : : enum rte_crypto_aead_operation op,
9077 : : const uint8_t *key, const uint8_t key_len,
9078 : : const uint16_t aad_len, const uint8_t auth_len,
9079 : : uint8_t iv_len)
9080 : : {
9081 : 85 : uint8_t *aead_key = alloca(key_len);
9082 : :
9083 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9084 : : struct crypto_unittest_params *ut_params = &unittest_params;
9085 : :
9086 : : memcpy(aead_key, key, key_len);
9087 : :
9088 : : /* Setup AEAD Parameters */
9089 : 85 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9090 : 85 : ut_params->aead_xform.next = NULL;
9091 : 85 : ut_params->aead_xform.aead.algo = algo;
9092 : 85 : ut_params->aead_xform.aead.op = op;
9093 : 85 : ut_params->aead_xform.aead.key.data = aead_key;
9094 : 85 : ut_params->aead_xform.aead.key.length = key_len;
9095 : 85 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9096 : 85 : ut_params->aead_xform.aead.iv.length = iv_len;
9097 : 85 : ut_params->aead_xform.aead.digest_length = auth_len;
9098 : 85 : ut_params->aead_xform.aead.aad_length = aad_len;
9099 : :
9100 : 85 : debug_hexdump(stdout, "key:", key, key_len);
9101 : :
9102 : : /* Create Crypto session*/
9103 : 85 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9104 : : &ut_params->aead_xform, ts_params->session_mpool);
9105 [ - + - - ]: 85 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9106 : : return TEST_SKIPPED;
9107 [ - + ]: 85 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9108 : : return 0;
9109 : : }
9110 : :
9111 : : static int
9112 : 2 : create_aead_xform(struct rte_crypto_op *op,
9113 : : enum rte_crypto_aead_algorithm algo,
9114 : : enum rte_crypto_aead_operation aead_op,
9115 : : uint8_t *key, const uint8_t key_len,
9116 : : const uint8_t aad_len, const uint8_t auth_len,
9117 : : uint8_t iv_len)
9118 : : {
9119 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9120 : : "failed to allocate space for crypto transform");
9121 : :
9122 : : struct rte_crypto_sym_op *sym_op = op->sym;
9123 : :
9124 : : /* Setup AEAD Parameters */
9125 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9126 : 2 : sym_op->xform->next = NULL;
9127 : 2 : sym_op->xform->aead.algo = algo;
9128 : 2 : sym_op->xform->aead.op = aead_op;
9129 : 2 : sym_op->xform->aead.key.data = key;
9130 : 2 : sym_op->xform->aead.key.length = key_len;
9131 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
9132 : 2 : sym_op->xform->aead.iv.length = iv_len;
9133 : 2 : sym_op->xform->aead.digest_length = auth_len;
9134 : 2 : sym_op->xform->aead.aad_length = aad_len;
9135 : :
9136 : 2 : debug_hexdump(stdout, "key:", key, key_len);
9137 : :
9138 : : return 0;
9139 : : }
9140 : :
9141 : : static int
9142 : 86 : create_aead_operation(enum rte_crypto_aead_operation op,
9143 : : const struct aead_test_data *tdata)
9144 : : {
9145 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9146 : : struct crypto_unittest_params *ut_params = &unittest_params;
9147 : :
9148 : : uint8_t *plaintext, *ciphertext;
9149 : : unsigned int aad_pad_len, plaintext_pad_len;
9150 : :
9151 : : /* Generate Crypto op data structure */
9152 : 86 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9153 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9154 [ - + ]: 86 : TEST_ASSERT_NOT_NULL(ut_params->op,
9155 : : "Failed to allocate symmetric crypto operation struct");
9156 : :
9157 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9158 : :
9159 : : /* Append aad data */
9160 [ + + ]: 86 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9161 : 18 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9162 : 18 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9163 : : aad_pad_len);
9164 [ - + ]: 18 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9165 : : "no room to append aad");
9166 : :
9167 : 18 : sym_op->aead.aad.phys_addr =
9168 : 18 : rte_pktmbuf_iova(ut_params->ibuf);
9169 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9170 : 18 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9171 : 18 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9172 : 18 : tdata->aad.len);
9173 : :
9174 : : /* Append IV at the end of the crypto operation*/
9175 : 18 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9176 : : uint8_t *, IV_OFFSET);
9177 : :
9178 : : /* Copy IV 1 byte after the IV pointer, according to the API */
9179 [ - + ]: 18 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9180 : 18 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
9181 : 18 : tdata->iv.len);
9182 : : } else {
9183 : 68 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9184 : 68 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9185 : : aad_pad_len);
9186 [ - + ]: 68 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9187 : : "no room to append aad");
9188 : :
9189 : 68 : sym_op->aead.aad.phys_addr =
9190 : 68 : rte_pktmbuf_iova(ut_params->ibuf);
9191 : 68 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9192 : 68 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9193 : 68 : tdata->aad.len);
9194 : :
9195 : : /* Append IV at the end of the crypto operation*/
9196 : 68 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9197 : : uint8_t *, IV_OFFSET);
9198 : :
9199 [ - + ]: 68 : if (tdata->iv.len == 0) {
9200 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9201 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
9202 : : AES_GCM_J0_LENGTH);
9203 : : } else {
9204 [ - + ]: 68 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9205 : 68 : debug_hexdump(stdout, "iv:", iv_ptr,
9206 : 68 : tdata->iv.len);
9207 : : }
9208 : : }
9209 : :
9210 : : /* Append plaintext/ciphertext */
9211 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9212 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9213 : 43 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9214 : : plaintext_pad_len);
9215 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9216 : :
9217 : 43 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9218 : 43 : debug_hexdump(stdout, "plaintext:", plaintext,
9219 : 43 : tdata->plaintext.len);
9220 : :
9221 [ + + ]: 43 : if (ut_params->obuf) {
9222 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
9223 : : ut_params->obuf,
9224 : 1 : plaintext_pad_len + aad_pad_len);
9225 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
9226 : : "no room to append ciphertext");
9227 : :
9228 : 1 : memset(ciphertext + aad_pad_len, 0,
9229 : 1 : tdata->ciphertext.len);
9230 : : }
9231 : : } else {
9232 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9233 : 43 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9234 : : plaintext_pad_len);
9235 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(ciphertext,
9236 : : "no room to append ciphertext");
9237 : :
9238 : 43 : memcpy(ciphertext, tdata->ciphertext.data,
9239 : 43 : tdata->ciphertext.len);
9240 : 43 : debug_hexdump(stdout, "ciphertext:", ciphertext,
9241 : 43 : tdata->ciphertext.len);
9242 : :
9243 [ + + ]: 43 : if (ut_params->obuf) {
9244 : : plaintext = (uint8_t *)rte_pktmbuf_append(
9245 : : ut_params->obuf,
9246 : 1 : plaintext_pad_len + aad_pad_len);
9247 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
9248 : : "no room to append plaintext");
9249 : :
9250 : 1 : memset(plaintext + aad_pad_len, 0,
9251 : 1 : tdata->plaintext.len);
9252 : : }
9253 : : }
9254 : :
9255 : : /* Append digest data */
9256 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9257 : 42 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9258 : 43 : ut_params->obuf ? ut_params->obuf :
9259 : : ut_params->ibuf,
9260 [ + + ]: 43 : tdata->auth_tag.len);
9261 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9262 : : "no room to append digest");
9263 [ + + ]: 43 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9264 [ + + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9265 : : ut_params->obuf ? ut_params->obuf :
9266 : : ut_params->ibuf,
9267 : : plaintext_pad_len +
9268 : : aad_pad_len);
9269 : : } else {
9270 : 86 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9271 : 43 : ut_params->ibuf, tdata->auth_tag.len);
9272 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9273 : : "no room to append digest");
9274 [ - + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9275 : : ut_params->ibuf,
9276 : : plaintext_pad_len + aad_pad_len);
9277 : :
9278 : 43 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9279 [ - + ]: 43 : tdata->auth_tag.len);
9280 : 43 : debug_hexdump(stdout, "digest:",
9281 : 43 : sym_op->aead.digest.data,
9282 : 43 : tdata->auth_tag.len);
9283 : : }
9284 : :
9285 : 86 : sym_op->aead.data.length = tdata->plaintext.len;
9286 : 86 : sym_op->aead.data.offset = aad_pad_len;
9287 : :
9288 : 86 : return 0;
9289 : : }
9290 : :
9291 : : static int
9292 : 42 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9293 : : {
9294 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9295 : : struct crypto_unittest_params *ut_params = &unittest_params;
9296 : :
9297 : : int retval;
9298 : : uint8_t *ciphertext, *auth_tag;
9299 : : uint16_t plaintext_pad_len;
9300 : : uint32_t i;
9301 : : struct rte_cryptodev_info dev_info;
9302 : :
9303 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9304 : 42 : uint64_t feat_flags = dev_info.feature_flags;
9305 : :
9306 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9307 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9308 : : printf("Device doesn't support RAW data-path APIs.\n");
9309 : 0 : return TEST_SKIPPED;
9310 : : }
9311 : :
9312 : : /* Verify the capabilities */
9313 : : struct rte_cryptodev_sym_capability_idx cap_idx;
9314 : : const struct rte_cryptodev_symmetric_capability *capability;
9315 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9316 : 42 : cap_idx.algo.aead = tdata->algo;
9317 : 42 : capability = rte_cryptodev_sym_capability_get(
9318 : 42 : ts_params->valid_devs[0], &cap_idx);
9319 [ + - ]: 42 : if (capability == NULL)
9320 : : return TEST_SKIPPED;
9321 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
9322 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
9323 : 42 : tdata->aad.len, tdata->iv.len))
9324 : : return TEST_SKIPPED;
9325 : :
9326 : : /* Create AEAD session */
9327 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
9328 : 41 : tdata->algo,
9329 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
9330 : 41 : tdata->key.data, tdata->key.len,
9331 : 41 : tdata->aad.len, tdata->auth_tag.len,
9332 : 41 : tdata->iv.len);
9333 [ + - ]: 41 : if (retval != TEST_SUCCESS)
9334 : : return retval;
9335 : :
9336 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
9337 [ - + ]: 2 : if (use_ext_mbuf) {
9338 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9339 : : AEAD_TEXT_MAX_LENGTH,
9340 : : 1 /* nb_segs */,
9341 : : NULL);
9342 : : } else {
9343 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9344 : : }
9345 : : /* Populate full size of add data */
9346 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9347 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9348 : : } else {
9349 [ + + ]: 39 : if (use_ext_mbuf) {
9350 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9351 : : AEAD_TEXT_MAX_LENGTH,
9352 : : 1 /* nb_segs */,
9353 : : NULL);
9354 : : } else {
9355 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9356 : : }
9357 : : }
9358 : :
9359 : : /* clear mbuf payload */
9360 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9361 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
9362 : :
9363 : : /* Create AEAD operation */
9364 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9365 [ + - ]: 41 : if (retval < 0)
9366 : : return retval;
9367 : :
9368 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9369 : :
9370 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
9371 : :
9372 : : /* Process crypto operation */
9373 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9374 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9375 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9376 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9377 : : 0);
9378 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9379 : : return retval;
9380 : : } else
9381 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(
9382 : : process_crypto_request(ts_params->valid_devs[0],
9383 : : ut_params->op), "failed to process sym crypto op");
9384 : :
9385 [ - + ]: 41 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9386 : : "crypto op processing failed");
9387 : :
9388 : 41 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9389 : :
9390 [ - + ]: 41 : if (ut_params->op->sym->m_dst) {
9391 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9392 : : uint8_t *);
9393 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9394 : : uint8_t *, plaintext_pad_len);
9395 : : } else {
9396 : 41 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9397 : : uint8_t *,
9398 : : ut_params->op->sym->cipher.data.offset);
9399 : 41 : auth_tag = ciphertext + plaintext_pad_len;
9400 : : }
9401 : :
9402 : 41 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9403 : 41 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9404 : :
9405 : : /* Validate obuf */
9406 [ + + ]: 44 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9407 : : ciphertext,
9408 : : tdata->ciphertext.data,
9409 : : tdata->ciphertext.len,
9410 : : "Ciphertext data not as expected");
9411 : :
9412 [ + + ]: 41 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9413 : : auth_tag,
9414 : : tdata->auth_tag.data,
9415 : : tdata->auth_tag.len,
9416 : : "Generated auth tag not as expected");
9417 : :
9418 : : return 0;
9419 : :
9420 : : }
9421 : :
9422 : : static int
9423 : : test_authenticated_encryption(const struct aead_test_data *tdata)
9424 : : {
9425 : 41 : return test_authenticated_encryption_helper(tdata, false);
9426 : : }
9427 : :
9428 : : #ifdef RTE_LIB_SECURITY
9429 : : static int
9430 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9431 : : enum rte_security_session_protocol proto)
9432 : : {
9433 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9434 : :
9435 : : const struct rte_security_capability *capabilities;
9436 : : const struct rte_security_capability *capability;
9437 : : uint16_t i = 0;
9438 : :
9439 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9440 : :
9441 : :
9442 : 0 : capabilities = rte_security_capabilities_get(ctx);
9443 : :
9444 [ # # ]: 0 : if (capabilities == NULL)
9445 : : return -ENOTSUP;
9446 : :
9447 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9448 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9449 [ # # ]: 0 : if (capability->action == action &&
9450 [ # # ]: 0 : capability->protocol == proto)
9451 : : return 0;
9452 : : }
9453 : :
9454 : : return -ENOTSUP;
9455 : : }
9456 : :
9457 : : /* Basic algorithm run function for async inplace mode.
9458 : : * Creates a session from input parameters and runs one operation
9459 : : * on input_vec. Checks the output of the crypto operation against
9460 : : * output_vec.
9461 : : */
9462 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9463 : : enum rte_crypto_auth_operation opa,
9464 : : const uint8_t *input_vec, unsigned int input_vec_len,
9465 : : const uint8_t *output_vec,
9466 : : unsigned int output_vec_len,
9467 : : enum rte_crypto_cipher_algorithm cipher_alg,
9468 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9469 : : enum rte_crypto_auth_algorithm auth_alg,
9470 : : const uint8_t *auth_key, uint32_t auth_key_len,
9471 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9472 : : uint8_t packet_direction, uint8_t sn_size,
9473 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9474 : : {
9475 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9476 : : struct crypto_unittest_params *ut_params = &unittest_params;
9477 : : uint8_t *plaintext;
9478 : : int ret = TEST_SUCCESS;
9479 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9480 : : struct rte_cryptodev_info dev_info;
9481 : : uint64_t feat_flags;
9482 : :
9483 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9484 : 0 : feat_flags = dev_info.feature_flags;
9485 : :
9486 : : /* Verify the capabilities */
9487 : : struct rte_security_capability_idx sec_cap_idx;
9488 : :
9489 : 0 : sec_cap_idx.action = ut_params->type;
9490 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9491 : 0 : sec_cap_idx.pdcp.domain = domain;
9492 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9493 : : return TEST_SKIPPED;
9494 : :
9495 : : /* Generate test mbuf data */
9496 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9497 : :
9498 : : /* clear mbuf payload */
9499 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9500 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9501 : :
9502 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9503 : : input_vec_len);
9504 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9505 : :
9506 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9507 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9508 : : printf("Device does not support RAW data-path APIs.\n");
9509 : 0 : return TEST_SKIPPED;
9510 : : }
9511 : : /* Out of place support */
9512 [ # # ]: 0 : if (oop) {
9513 : : /*
9514 : : * For out-of-place we need to alloc another mbuf
9515 : : */
9516 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9517 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9518 : : }
9519 : :
9520 : : /* Setup Cipher Parameters */
9521 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9522 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9523 : 0 : ut_params->cipher_xform.cipher.op = opc;
9524 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9525 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9526 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9527 : : packet_direction ? 4 : 0;
9528 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9529 : :
9530 : : /* Setup HMAC Parameters if ICV header is required */
9531 [ # # ]: 0 : if (auth_alg != 0) {
9532 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9533 : 0 : ut_params->auth_xform.next = NULL;
9534 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9535 : 0 : ut_params->auth_xform.auth.op = opa;
9536 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9537 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9538 : :
9539 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9540 : : } else {
9541 : 0 : ut_params->cipher_xform.next = NULL;
9542 : : }
9543 : :
9544 : 0 : struct rte_security_session_conf sess_conf = {
9545 : 0 : .action_type = ut_params->type,
9546 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9547 : : {.pdcp = {
9548 : : .bearer = bearer,
9549 : : .domain = domain,
9550 : : .pkt_dir = packet_direction,
9551 : : .sn_size = sn_size,
9552 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9553 : : /**
9554 : : * hfn can be set as pdcp_test_hfn[i]
9555 : : * if hfn_ovrd is not set. Here, PDCP
9556 : : * packet direction is just used to
9557 : : * run half of the cases with session
9558 : : * HFN and other half with per packet
9559 : : * HFN.
9560 : : */
9561 : : .hfn_threshold = hfn_threshold,
9562 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9563 : : .sdap_enabled = sdap,
9564 : : } },
9565 : : .crypto_xform = &ut_params->cipher_xform
9566 : : };
9567 : :
9568 : : /* Create security session */
9569 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9570 : : &sess_conf, ts_params->session_mpool);
9571 : :
9572 [ # # ]: 0 : if (!ut_params->sec_session) {
9573 : : printf("TestCase %s()-%d line %d failed %s: ",
9574 : : __func__, i, __LINE__, "Failed to allocate session");
9575 : : ret = TEST_FAILED;
9576 : 0 : goto on_err;
9577 : : }
9578 : :
9579 : : /* Generate crypto op data structure */
9580 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9581 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9582 [ # # ]: 0 : if (!ut_params->op) {
9583 : : printf("TestCase %s()-%d line %d failed %s: ",
9584 : : __func__, i, __LINE__,
9585 : : "Failed to allocate symmetric crypto operation struct");
9586 : : ret = TEST_FAILED;
9587 : 0 : goto on_err;
9588 : : }
9589 : :
9590 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9591 : : uint32_t *, IV_OFFSET);
9592 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9593 : :
9594 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9595 : :
9596 : : /* set crypto operation source mbuf */
9597 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9598 [ # # ]: 0 : if (oop)
9599 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9600 : :
9601 : : /* Process crypto operation */
9602 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9603 : : /* filling lengths */
9604 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9605 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9606 : :
9607 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9608 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9609 : : return ret;
9610 : : } else {
9611 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9612 : : }
9613 [ # # ]: 0 : if (ut_params->op == NULL) {
9614 : : printf("TestCase %s()-%d line %d failed %s: ",
9615 : : __func__, i, __LINE__,
9616 : : "failed to process sym crypto op");
9617 : : ret = TEST_FAILED;
9618 : 0 : goto on_err;
9619 : : }
9620 : :
9621 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9622 : : printf("TestCase %s()-%d line %d failed %s: ",
9623 : : __func__, i, __LINE__, "crypto op processing failed");
9624 : : ret = TEST_FAILED;
9625 : 0 : goto on_err;
9626 : : }
9627 : :
9628 : : /* Validate obuf */
9629 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9630 : : uint8_t *);
9631 [ # # ]: 0 : if (oop) {
9632 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9633 : : uint8_t *);
9634 : : }
9635 : :
9636 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9637 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9638 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9639 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9640 : : ret = TEST_FAILED;
9641 : 0 : goto on_err;
9642 : : }
9643 : :
9644 : 0 : on_err:
9645 : 0 : rte_crypto_op_free(ut_params->op);
9646 : 0 : ut_params->op = NULL;
9647 : :
9648 [ # # ]: 0 : if (ut_params->sec_session)
9649 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9650 : 0 : ut_params->sec_session = NULL;
9651 : :
9652 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9653 : 0 : ut_params->ibuf = NULL;
9654 [ # # ]: 0 : if (oop) {
9655 : 0 : rte_pktmbuf_free(ut_params->obuf);
9656 : 0 : ut_params->obuf = NULL;
9657 : : }
9658 : :
9659 : : return ret;
9660 : : }
9661 : :
9662 : : static int
9663 : 0 : test_pdcp_proto_SGL(int i, int oop,
9664 : : enum rte_crypto_cipher_operation opc,
9665 : : enum rte_crypto_auth_operation opa,
9666 : : uint8_t *input_vec,
9667 : : unsigned int input_vec_len,
9668 : : uint8_t *output_vec,
9669 : : unsigned int output_vec_len,
9670 : : uint32_t fragsz,
9671 : : uint32_t fragsz_oop)
9672 : : {
9673 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9674 : : struct crypto_unittest_params *ut_params = &unittest_params;
9675 : : uint8_t *plaintext;
9676 : : struct rte_mbuf *buf, *buf_oop = NULL;
9677 : : int ret = TEST_SUCCESS;
9678 : : int to_trn = 0;
9679 : : int to_trn_tbl[16];
9680 : : int segs = 1;
9681 : : unsigned int trn_data = 0;
9682 : : struct rte_cryptodev_info dev_info;
9683 : : uint64_t feat_flags;
9684 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9685 : : struct rte_mbuf *temp_mbuf;
9686 : :
9687 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9688 : 0 : feat_flags = dev_info.feature_flags;
9689 : :
9690 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9691 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9692 : : printf("Device does not support RAW data-path APIs.\n");
9693 : 0 : return -ENOTSUP;
9694 : : }
9695 : : /* Verify the capabilities */
9696 : : struct rte_security_capability_idx sec_cap_idx;
9697 : :
9698 : 0 : sec_cap_idx.action = ut_params->type;
9699 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9700 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9701 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9702 : : return TEST_SKIPPED;
9703 : :
9704 : : if (fragsz > input_vec_len)
9705 : : fragsz = input_vec_len;
9706 : :
9707 : 0 : uint16_t plaintext_len = fragsz;
9708 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9709 : :
9710 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9711 : 0 : frag_size_oop = output_vec_len;
9712 : :
9713 : : int ecx = 0;
9714 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9715 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9716 : : return 1;
9717 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9718 : : return 1;
9719 : :
9720 : : /* Out of place support */
9721 [ # # ]: 0 : if (oop) {
9722 : : /*
9723 : : * For out-of-place we need to alloc another mbuf
9724 : : */
9725 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9726 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9727 : 0 : buf_oop = ut_params->obuf;
9728 : : }
9729 : :
9730 : : /* Generate test mbuf data */
9731 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9732 : :
9733 : : /* clear mbuf payload */
9734 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9735 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9736 : :
9737 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9738 : : plaintext_len);
9739 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9740 : : trn_data += plaintext_len;
9741 : :
9742 : 0 : buf = ut_params->ibuf;
9743 : :
9744 : : /*
9745 : : * Loop until no more fragments
9746 : : */
9747 : :
9748 [ # # ]: 0 : while (trn_data < input_vec_len) {
9749 : 0 : ++segs;
9750 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9751 : 0 : (input_vec_len - trn_data) : fragsz;
9752 : :
9753 : 0 : to_trn_tbl[ecx++] = to_trn;
9754 : :
9755 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9756 : : buf = buf->next;
9757 : :
9758 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9759 : : rte_pktmbuf_tailroom(buf));
9760 : :
9761 : : /* OOP */
9762 [ # # ]: 0 : if (oop && !fragsz_oop) {
9763 : 0 : buf_oop->next =
9764 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9765 : : buf_oop = buf_oop->next;
9766 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9767 : : 0, rte_pktmbuf_tailroom(buf_oop));
9768 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9769 : : }
9770 : :
9771 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9772 : : to_trn);
9773 : :
9774 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9775 : 0 : trn_data += to_trn;
9776 : : }
9777 : :
9778 : 0 : ut_params->ibuf->nb_segs = segs;
9779 : :
9780 : : segs = 1;
9781 [ # # ]: 0 : if (fragsz_oop && oop) {
9782 : : to_trn = 0;
9783 : : ecx = 0;
9784 : :
9785 : 0 : trn_data = frag_size_oop;
9786 [ # # ]: 0 : while (trn_data < output_vec_len) {
9787 : 0 : ++segs;
9788 : 0 : to_trn =
9789 : 0 : (output_vec_len - trn_data <
9790 : : frag_size_oop) ?
9791 : 0 : (output_vec_len - trn_data) :
9792 : : frag_size_oop;
9793 : :
9794 : 0 : to_trn_tbl[ecx++] = to_trn;
9795 : :
9796 : 0 : buf_oop->next =
9797 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9798 : : buf_oop = buf_oop->next;
9799 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9800 : : 0, rte_pktmbuf_tailroom(buf_oop));
9801 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9802 : :
9803 : 0 : trn_data += to_trn;
9804 : : }
9805 : 0 : ut_params->obuf->nb_segs = segs;
9806 : : }
9807 : :
9808 : : /* Setup Cipher Parameters */
9809 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9810 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9811 : 0 : ut_params->cipher_xform.cipher.op = opc;
9812 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9813 : 0 : ut_params->cipher_xform.cipher.key.length =
9814 : 0 : pdcp_test_params[i].cipher_key_len;
9815 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9816 : :
9817 : : /* Setup HMAC Parameters if ICV header is required */
9818 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9819 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9820 : 0 : ut_params->auth_xform.next = NULL;
9821 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9822 : 0 : ut_params->auth_xform.auth.op = opa;
9823 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9824 : 0 : ut_params->auth_xform.auth.key.length =
9825 : 0 : pdcp_test_params[i].auth_key_len;
9826 : :
9827 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9828 : : } else {
9829 : 0 : ut_params->cipher_xform.next = NULL;
9830 : : }
9831 : :
9832 : 0 : struct rte_security_session_conf sess_conf = {
9833 : 0 : .action_type = ut_params->type,
9834 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9835 : : {.pdcp = {
9836 : 0 : .bearer = pdcp_test_bearer[i],
9837 : 0 : .domain = pdcp_test_params[i].domain,
9838 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9839 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9840 : 0 : .hfn = pdcp_test_hfn[i],
9841 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9842 : : .hfn_ovrd = 0,
9843 : : } },
9844 : : .crypto_xform = &ut_params->cipher_xform
9845 : : };
9846 : :
9847 : : /* Create security session */
9848 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9849 : : &sess_conf, ts_params->session_mpool);
9850 : :
9851 [ # # ]: 0 : if (!ut_params->sec_session) {
9852 : : printf("TestCase %s()-%d line %d failed %s: ",
9853 : : __func__, i, __LINE__, "Failed to allocate session");
9854 : : ret = TEST_FAILED;
9855 : 0 : goto on_err;
9856 : : }
9857 : :
9858 : : /* Generate crypto op data structure */
9859 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9860 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9861 [ # # ]: 0 : if (!ut_params->op) {
9862 : : printf("TestCase %s()-%d line %d failed %s: ",
9863 : : __func__, i, __LINE__,
9864 : : "Failed to allocate symmetric crypto operation struct");
9865 : : ret = TEST_FAILED;
9866 : 0 : goto on_err;
9867 : : }
9868 : :
9869 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9870 : :
9871 : : /* set crypto operation source mbuf */
9872 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9873 [ # # ]: 0 : if (oop)
9874 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9875 : :
9876 : : /* Process crypto operation */
9877 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9878 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9879 : : /* filling lengths */
9880 [ # # ]: 0 : while (temp_mbuf) {
9881 : 0 : ut_params->op->sym->cipher.data.length
9882 : 0 : += temp_mbuf->pkt_len;
9883 : 0 : ut_params->op->sym->auth.data.length
9884 : 0 : += temp_mbuf->pkt_len;
9885 : 0 : temp_mbuf = temp_mbuf->next;
9886 : : }
9887 : :
9888 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9889 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9890 : : return ret;
9891 : : } else {
9892 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9893 : : ut_params->op);
9894 : : }
9895 [ # # ]: 0 : if (ut_params->op == NULL) {
9896 : : printf("TestCase %s()-%d line %d failed %s: ",
9897 : : __func__, i, __LINE__,
9898 : : "failed to process sym crypto op");
9899 : : ret = TEST_FAILED;
9900 : 0 : goto on_err;
9901 : : }
9902 : :
9903 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9904 : : printf("TestCase %s()-%d line %d failed %s: ",
9905 : : __func__, i, __LINE__, "crypto op processing failed");
9906 : : ret = TEST_FAILED;
9907 : 0 : goto on_err;
9908 : : }
9909 : :
9910 : : /* Validate obuf */
9911 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9912 : : uint8_t *);
9913 [ # # ]: 0 : if (oop) {
9914 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9915 : : uint8_t *);
9916 : : }
9917 [ # # ]: 0 : if (fragsz_oop)
9918 : 0 : fragsz = frag_size_oop;
9919 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9920 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9921 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9922 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9923 : : ret = TEST_FAILED;
9924 : 0 : goto on_err;
9925 : : }
9926 : :
9927 : 0 : buf = ut_params->op->sym->m_src->next;
9928 [ # # ]: 0 : if (oop)
9929 : 0 : buf = ut_params->op->sym->m_dst->next;
9930 : :
9931 : : unsigned int off = fragsz;
9932 : :
9933 : : ecx = 0;
9934 [ # # ]: 0 : while (buf) {
9935 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9936 : : uint8_t *);
9937 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9938 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9939 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9940 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9941 : : to_trn_tbl[ecx]);
9942 : : ret = TEST_FAILED;
9943 : 0 : goto on_err;
9944 : : }
9945 : 0 : off += to_trn_tbl[ecx++];
9946 : 0 : buf = buf->next;
9947 : : }
9948 : 0 : on_err:
9949 : 0 : rte_crypto_op_free(ut_params->op);
9950 : 0 : ut_params->op = NULL;
9951 : :
9952 [ # # ]: 0 : if (ut_params->sec_session)
9953 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9954 : 0 : ut_params->sec_session = NULL;
9955 : :
9956 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9957 : 0 : ut_params->ibuf = NULL;
9958 [ # # ]: 0 : if (oop) {
9959 : 0 : rte_pktmbuf_free(ut_params->obuf);
9960 : 0 : ut_params->obuf = NULL;
9961 : : }
9962 : :
9963 : : return ret;
9964 : : }
9965 : :
9966 : : int
9967 : 0 : test_pdcp_proto_cplane_encap(int i)
9968 : : {
9969 : 0 : return test_pdcp_proto(
9970 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9971 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9972 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9973 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9974 : 0 : pdcp_test_params[i].cipher_key_len,
9975 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9976 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9977 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9978 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9979 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9980 : : }
9981 : :
9982 : : int
9983 : 0 : test_pdcp_proto_uplane_encap(int i)
9984 : : {
9985 : 0 : return test_pdcp_proto(
9986 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9987 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9988 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9989 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9990 : 0 : pdcp_test_params[i].cipher_key_len,
9991 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9992 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9993 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9994 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9995 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9996 : : }
9997 : :
9998 : : int
9999 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
10000 : : {
10001 : 0 : return test_pdcp_proto(
10002 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10003 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10004 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10005 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10006 : 0 : pdcp_test_params[i].cipher_key_len,
10007 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10008 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10009 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10010 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10011 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10012 : : }
10013 : :
10014 : : int
10015 : 0 : test_pdcp_proto_cplane_decap(int i)
10016 : : {
10017 : 0 : return test_pdcp_proto(
10018 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10019 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10020 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10021 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10022 : 0 : pdcp_test_params[i].cipher_key_len,
10023 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10024 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10025 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10026 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10027 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10028 : : }
10029 : :
10030 : : int
10031 : 0 : test_pdcp_proto_uplane_decap(int i)
10032 : : {
10033 : 0 : return test_pdcp_proto(
10034 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10035 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10036 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10037 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10038 : 0 : pdcp_test_params[i].cipher_key_len,
10039 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10040 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10041 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10042 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10043 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10044 : : }
10045 : :
10046 : : int
10047 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
10048 : : {
10049 : 0 : return test_pdcp_proto(
10050 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10051 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10052 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10053 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10054 : 0 : pdcp_test_params[i].cipher_key_len,
10055 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10056 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10057 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10058 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10059 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10060 : : }
10061 : :
10062 : : static int
10063 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
10064 : : {
10065 : : /* i can be used for running any PDCP case
10066 : : * In this case it is uplane 12-bit AES-SNOW DL encap
10067 : : */
10068 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
10069 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
10070 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10071 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10072 : : pdcp_test_data_in[i],
10073 : : pdcp_test_data_in_len[i],
10074 : : pdcp_test_data_out[i],
10075 : 0 : pdcp_test_data_in_len[i]+4,
10076 : : 32, 0);
10077 : : }
10078 : : static int
10079 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
10080 : : {
10081 : : /* i can be used for running any PDCP case
10082 : : * In this case it is uplane 18-bit NULL-NULL DL encap
10083 : : */
10084 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10085 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10086 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10087 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10088 : : pdcp_test_data_in[i],
10089 : : pdcp_test_data_in_len[i],
10090 : : pdcp_test_data_out[i],
10091 : 0 : pdcp_test_data_in_len[i]+4,
10092 : : 32, 128);
10093 : : }
10094 : : static int
10095 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
10096 : : {
10097 : : /* i can be used for running any PDCP case
10098 : : * In this case it is uplane 18-bit AES DL encap
10099 : : */
10100 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10101 : : + DOWNLINK;
10102 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10103 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10104 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10105 : : pdcp_test_data_in[i],
10106 : : pdcp_test_data_in_len[i],
10107 : : pdcp_test_data_out[i],
10108 : : pdcp_test_data_in_len[i],
10109 : : 32, 40);
10110 : : }
10111 : : static int
10112 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
10113 : : {
10114 : : /* i can be used for running any PDCP case
10115 : : * In this case it is cplane 12-bit AES-ZUC DL encap
10116 : : */
10117 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10118 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10119 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10120 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10121 : : pdcp_test_data_in[i],
10122 : : pdcp_test_data_in_len[i],
10123 : : pdcp_test_data_out[i],
10124 : 0 : pdcp_test_data_in_len[i]+4,
10125 : : 128, 32);
10126 : : }
10127 : :
10128 : : static int
10129 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
10130 : : {
10131 : : int i = 0, size = 0;
10132 : : int err, all_err = TEST_SUCCESS;
10133 : : const struct pdcp_sdap_test *cur_test;
10134 : :
10135 : : size = RTE_DIM(list_pdcp_sdap_tests);
10136 : :
10137 [ # # ]: 0 : for (i = 0; i < size; i++) {
10138 : : cur_test = &list_pdcp_sdap_tests[i];
10139 : 0 : err = test_pdcp_proto(
10140 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10141 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10142 : 0 : cur_test->in_len, cur_test->data_out,
10143 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10144 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
10145 : 0 : cur_test->param.cipher_key_len,
10146 : 0 : cur_test->param.auth_alg,
10147 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10148 : 0 : cur_test->bearer, cur_test->param.domain,
10149 : 0 : cur_test->packet_direction, cur_test->sn_size,
10150 : 0 : cur_test->hfn,
10151 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10152 [ # # ]: 0 : if (err) {
10153 : : printf("\t%d) %s: Encapsulation failed\n",
10154 : 0 : cur_test->test_idx,
10155 : 0 : cur_test->param.name);
10156 : : err = TEST_FAILED;
10157 : : } else {
10158 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10159 : 0 : cur_test->param.name);
10160 : : err = TEST_SUCCESS;
10161 : : }
10162 : 0 : all_err += err;
10163 : : }
10164 : :
10165 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10166 : :
10167 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10168 : : }
10169 : :
10170 : : static int
10171 : 0 : test_PDCP_PROTO_short_mac(void)
10172 : : {
10173 : : int i = 0, size = 0;
10174 : : int err, all_err = TEST_SUCCESS;
10175 : : const struct pdcp_short_mac_test *cur_test;
10176 : :
10177 : : size = RTE_DIM(list_pdcp_smac_tests);
10178 : :
10179 [ # # ]: 0 : for (i = 0; i < size; i++) {
10180 : : cur_test = &list_pdcp_smac_tests[i];
10181 : 0 : err = test_pdcp_proto(
10182 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10183 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10184 : 0 : cur_test->in_len, cur_test->data_out,
10185 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10186 : : RTE_CRYPTO_CIPHER_NULL, NULL,
10187 : 0 : 0, cur_test->param.auth_alg,
10188 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10189 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
10190 : : 0, 0, 0);
10191 [ # # ]: 0 : if (err) {
10192 : : printf("\t%d) %s: Short MAC test failed\n",
10193 : 0 : cur_test->test_idx,
10194 : 0 : cur_test->param.name);
10195 : : err = TEST_FAILED;
10196 : : } else {
10197 : : printf("\t%d) %s: Short MAC test PASS\n",
10198 : 0 : cur_test->test_idx,
10199 : 0 : cur_test->param.name);
10200 : 0 : rte_hexdump(stdout, "MAC I",
10201 : 0 : cur_test->data_out + cur_test->in_len + 2,
10202 : : 2);
10203 : : err = TEST_SUCCESS;
10204 : : }
10205 : 0 : all_err += err;
10206 : : }
10207 : :
10208 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10209 : :
10210 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10211 : :
10212 : : }
10213 : :
10214 : : static int
10215 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
10216 : : {
10217 : : int i = 0, size = 0;
10218 : : int err, all_err = TEST_SUCCESS;
10219 : : const struct pdcp_sdap_test *cur_test;
10220 : :
10221 : : size = RTE_DIM(list_pdcp_sdap_tests);
10222 : :
10223 [ # # ]: 0 : for (i = 0; i < size; i++) {
10224 : : cur_test = &list_pdcp_sdap_tests[i];
10225 : 0 : err = test_pdcp_proto(
10226 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10227 : : RTE_CRYPTO_AUTH_OP_VERIFY,
10228 : 0 : cur_test->data_out,
10229 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10230 : 0 : cur_test->data_in, cur_test->in_len,
10231 : 0 : cur_test->param.cipher_alg,
10232 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
10233 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
10234 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
10235 : 0 : cur_test->param.domain, cur_test->packet_direction,
10236 : 0 : cur_test->sn_size, cur_test->hfn,
10237 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10238 [ # # ]: 0 : if (err) {
10239 : : printf("\t%d) %s: Decapsulation failed\n",
10240 : 0 : cur_test->test_idx,
10241 : 0 : cur_test->param.name);
10242 : : err = TEST_FAILED;
10243 : : } else {
10244 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10245 : 0 : cur_test->param.name);
10246 : : err = TEST_SUCCESS;
10247 : : }
10248 : 0 : all_err += err;
10249 : : }
10250 : :
10251 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10252 : :
10253 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10254 : : }
10255 : :
10256 : : static int
10257 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10258 : : struct crypto_unittest_params *ut_params,
10259 : : struct rte_security_ipsec_xform *ipsec_xform,
10260 : : const struct ipsec_test_data *td,
10261 : : const struct ipsec_test_flags *flags,
10262 : : int pkt_num)
10263 : : {
10264 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10265 : : enum rte_security_ipsec_sa_direction dir;
10266 : : int ret;
10267 : :
10268 : 0 : dir = ipsec_xform->direction;
10269 : :
10270 : : /* Generate crypto op data structure */
10271 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10272 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10273 [ # # ]: 0 : if (!ut_params->op) {
10274 : : printf("Could not allocate crypto op");
10275 : 0 : return TEST_FAILED;
10276 : : }
10277 : :
10278 : : /* Attach session to operation */
10279 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10280 : :
10281 : : /* Set crypto operation mbufs */
10282 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10283 : 0 : ut_params->op->sym->m_dst = NULL;
10284 : :
10285 : : /* Copy IV in crypto operation when IV generation is disabled */
10286 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10287 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10288 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10289 : : uint8_t *,
10290 : : IV_OFFSET);
10291 : : int len;
10292 : :
10293 [ # # ]: 0 : if (td->aead)
10294 : 0 : len = td->xform.aead.aead.iv.length;
10295 [ # # ]: 0 : else if (td->aes_gmac)
10296 : 0 : len = td->xform.chain.auth.auth.iv.length;
10297 : : else
10298 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10299 : :
10300 : 0 : memcpy(iv, td->iv.data, len);
10301 : : }
10302 : :
10303 : : /* Process crypto operation */
10304 : 0 : process_crypto_request(dev_id, ut_params->op);
10305 : :
10306 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10307 : :
10308 : 0 : rte_crypto_op_free(ut_params->op);
10309 : 0 : ut_params->op = NULL;
10310 : :
10311 : 0 : return ret;
10312 : : }
10313 : :
10314 : : static int
10315 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10316 : : struct crypto_unittest_params *ut_params,
10317 : : void *ctx)
10318 : : {
10319 : : uint64_t timeout, userdata;
10320 : : struct rte_ether_hdr *hdr;
10321 : : struct rte_mbuf *m;
10322 : : void **sec_sess;
10323 : : int ret;
10324 : :
10325 : : RTE_SET_USED(ts_params);
10326 : :
10327 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10328 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10329 : :
10330 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10331 : 0 : ut_params->ibuf->port = 0;
10332 : :
10333 : 0 : sec_sess = &ut_params->sec_session;
10334 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10335 : :
10336 [ # # ]: 0 : if (ret != 1)
10337 : : return TEST_FAILED;
10338 : :
10339 : 0 : ut_params->ibuf = NULL;
10340 : :
10341 : : /* Add a timeout for 1 s */
10342 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10343 : :
10344 : : do {
10345 : : /* Get packet from port 0, queue 0 */
10346 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10347 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10348 : :
10349 [ # # ]: 0 : if (ret == 0) {
10350 : : printf("Could not receive packets from ethdev\n");
10351 : 0 : return TEST_FAILED;
10352 : : }
10353 : :
10354 [ # # ]: 0 : if (m == NULL) {
10355 : : printf("Received mbuf is NULL\n");
10356 : 0 : return TEST_FAILED;
10357 : : }
10358 : :
10359 : 0 : ut_params->ibuf = m;
10360 : :
10361 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10362 : : printf("Received packet is not Rx security processed\n");
10363 : 0 : return TEST_FAILED;
10364 : : }
10365 : :
10366 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10367 : : printf("Received packet has failed Rx security processing\n");
10368 : 0 : return TEST_FAILED;
10369 : : }
10370 : :
10371 : : /*
10372 : : * 'ut_params' is set as userdata. Verify that the field is returned
10373 : : * correctly.
10374 : : */
10375 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10376 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10377 : : printf("Userdata retrieved not matching expected\n");
10378 : 0 : return TEST_FAILED;
10379 : : }
10380 : :
10381 : : /* Trim L2 header */
10382 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10383 : :
10384 : : return TEST_SUCCESS;
10385 : : }
10386 : :
10387 : : static int
10388 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10389 : : struct ipsec_test_data res_d[],
10390 : : int nb_td,
10391 : : bool silent,
10392 : : const struct ipsec_test_flags *flags)
10393 : : {
10394 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10395 : : 0x0000, 0x001a};
10396 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10397 : : 0xe82c, 0x4887};
10398 : : const struct rte_ipv4_hdr *ipv4 =
10399 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10400 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10401 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10402 : : struct crypto_unittest_params *ut_params = &unittest_params;
10403 : : struct rte_security_capability_idx sec_cap_idx;
10404 : : const struct rte_security_capability *sec_cap;
10405 : : struct rte_security_ipsec_xform ipsec_xform;
10406 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10407 : : enum rte_security_ipsec_sa_direction dir;
10408 : : struct ipsec_test_data *res_d_tmp = NULL;
10409 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10410 : : int salt_len, i, ret = TEST_SUCCESS;
10411 : : void *ctx;
10412 : : uint32_t src, dst;
10413 : : uint32_t verify;
10414 : :
10415 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10416 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10417 : :
10418 : : /* Use first test data to create session */
10419 : :
10420 : : /* Copy IPsec xform */
10421 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10422 : :
10423 : 0 : dir = ipsec_xform.direction;
10424 : 0 : verify = flags->tunnel_hdr_verify;
10425 : :
10426 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10427 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10428 : :
10429 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10430 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10431 : 0 : src += 1;
10432 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10433 : 0 : dst += 1;
10434 : : }
10435 : :
10436 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10437 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10438 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10439 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10440 : : sizeof(src));
10441 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10442 : : sizeof(dst));
10443 : :
10444 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10445 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10446 : :
10447 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10448 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10449 : :
10450 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10451 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10452 : :
10453 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10454 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10455 : : TEST_IPSEC_DSCP_VAL;
10456 : :
10457 : : } else {
10458 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10459 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10460 : :
10461 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10462 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10463 : : TEST_IPSEC_DSCP_VAL;
10464 : :
10465 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10466 : : sizeof(v6_src));
10467 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10468 : : sizeof(v6_dst));
10469 : : }
10470 : : }
10471 : :
10472 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10473 : :
10474 : 0 : sec_cap_idx.action = ut_params->type;
10475 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10476 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10477 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10478 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10479 : :
10480 [ # # ]: 0 : if (flags->udp_encap)
10481 : 0 : ipsec_xform.options.udp_encap = 1;
10482 : :
10483 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10484 [ # # ]: 0 : if (sec_cap == NULL)
10485 : : return TEST_SKIPPED;
10486 : :
10487 : : /* Copy cipher session parameters */
10488 [ # # ]: 0 : if (td[0].aead) {
10489 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10490 : : sizeof(ut_params->aead_xform));
10491 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10492 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10493 : :
10494 : : /* Verify crypto capabilities */
10495 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10496 [ # # ]: 0 : if (!silent)
10497 : 0 : RTE_LOG(INFO, USER1,
10498 : : "Crypto capabilities not supported\n");
10499 : 0 : return TEST_SKIPPED;
10500 : : }
10501 [ # # ]: 0 : } else if (td[0].auth_only) {
10502 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10503 : : sizeof(ut_params->auth_xform));
10504 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10505 : :
10506 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10507 [ # # ]: 0 : if (!silent)
10508 : 0 : RTE_LOG(INFO, USER1,
10509 : : "Auth crypto capabilities not supported\n");
10510 : 0 : return TEST_SKIPPED;
10511 : : }
10512 : : } else {
10513 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10514 : : sizeof(ut_params->cipher_xform));
10515 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10516 : : sizeof(ut_params->auth_xform));
10517 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10518 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10519 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10520 : :
10521 : : /* Verify crypto capabilities */
10522 : :
10523 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10524 [ # # ]: 0 : if (!silent)
10525 : 0 : RTE_LOG(INFO, USER1,
10526 : : "Cipher crypto capabilities not supported\n");
10527 : 0 : return TEST_SKIPPED;
10528 : : }
10529 : :
10530 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10531 [ # # ]: 0 : if (!silent)
10532 : 0 : RTE_LOG(INFO, USER1,
10533 : : "Auth crypto capabilities not supported\n");
10534 : 0 : return TEST_SKIPPED;
10535 : : }
10536 : : }
10537 : :
10538 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10539 : : return TEST_SKIPPED;
10540 : :
10541 : 0 : struct rte_security_session_conf sess_conf = {
10542 : 0 : .action_type = ut_params->type,
10543 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10544 : : };
10545 : :
10546 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac) {
10547 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10548 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10549 : : }
10550 : :
10551 [ # # ]: 0 : if (td[0].aead) {
10552 : 0 : sess_conf.ipsec = ipsec_xform;
10553 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10554 [ # # ]: 0 : } else if (td[0].auth_only) {
10555 : 0 : sess_conf.ipsec = ipsec_xform;
10556 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10557 : : } else {
10558 : 0 : sess_conf.ipsec = ipsec_xform;
10559 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10560 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10561 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10562 : : } else {
10563 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10564 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10565 : : }
10566 : : }
10567 : :
10568 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10569 : 0 : sess_conf.userdata = ut_params;
10570 : :
10571 : : /* Create security session */
10572 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10573 : : ts_params->session_mpool);
10574 : :
10575 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10576 : : return TEST_SKIPPED;
10577 : :
10578 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10579 [ # # # # ]: 0 : if (flags->antireplay &&
10580 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10581 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10582 : 0 : ret = rte_security_session_update(ctx,
10583 : : ut_params->sec_session, &sess_conf);
10584 [ # # ]: 0 : if (ret) {
10585 : : printf("Could not update sequence number in "
10586 : : "session\n");
10587 : 0 : return TEST_SKIPPED;
10588 : : }
10589 : : }
10590 : :
10591 : : /* Copy test data before modification */
10592 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10593 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10594 : : ret = TEST_FAILED;
10595 : 0 : goto mbuf_free;
10596 : : }
10597 : :
10598 : : /* Setup source mbuf payload */
10599 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10600 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10601 : 0 : td[i].input_text.len, nb_segs, input_text);
10602 : : } else {
10603 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10604 : 0 : td[i].input_text.len, nb_segs, 0);
10605 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10606 : : }
10607 : :
10608 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10609 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10610 : : ctx);
10611 : : else
10612 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10613 : : ut_params,
10614 : : &ipsec_xform,
10615 : : &td[i], flags,
10616 : : i + 1);
10617 : :
10618 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10619 : 0 : goto mbuf_free;
10620 : :
10621 [ # # ]: 0 : if (res_d != NULL)
10622 : 0 : res_d_tmp = &res_d[i];
10623 : :
10624 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10625 : : res_d_tmp, silent, flags);
10626 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10627 : 0 : goto mbuf_free;
10628 : :
10629 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10630 : : flags, dir);
10631 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10632 : 0 : goto mbuf_free;
10633 : :
10634 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10635 : 0 : ut_params->ibuf = NULL;
10636 : : }
10637 : :
10638 : 0 : mbuf_free:
10639 [ # # ]: 0 : if (flags->use_ext_mbuf)
10640 : 0 : ext_mbuf_memzone_free(nb_segs);
10641 : :
10642 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10643 : 0 : ut_params->ibuf = NULL;
10644 : :
10645 [ # # ]: 0 : if (ut_params->sec_session)
10646 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10647 : 0 : ut_params->sec_session = NULL;
10648 : :
10649 : 0 : return ret;
10650 : : }
10651 : :
10652 : : static int
10653 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10654 : : {
10655 : : struct ipsec_test_data td_outb;
10656 : : struct ipsec_test_flags flags;
10657 : :
10658 : : memset(&flags, 0, sizeof(flags));
10659 : :
10660 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10661 : :
10662 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10663 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10664 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10665 : : /* Disable IV gen to be able to test with known vectors */
10666 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10667 : : }
10668 : :
10669 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10670 : : }
10671 : :
10672 : : static int
10673 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10674 : : {
10675 : : struct ipsec_test_data td_outb;
10676 : : struct ipsec_test_flags flags;
10677 : :
10678 : : memset(&flags, 0, sizeof(flags));
10679 [ # # ]: 0 : flags.use_ext_mbuf = true;
10680 : :
10681 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10682 : :
10683 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10684 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10685 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10686 : : /* Disable IV gen to be able to test with known vectors */
10687 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10688 : : }
10689 : :
10690 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10691 : : }
10692 : :
10693 : : static int
10694 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10695 : : {
10696 : : const struct ipsec_test_data *td = test_data;
10697 : : struct ipsec_test_flags flags;
10698 : : struct ipsec_test_data td_inb;
10699 : :
10700 : : memset(&flags, 0, sizeof(flags));
10701 : :
10702 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10703 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10704 : : else
10705 : : memcpy(&td_inb, td, sizeof(td_inb));
10706 : :
10707 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10708 : : }
10709 : :
10710 : : static int
10711 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10712 : : {
10713 : : struct ipsec_test_data td_outb;
10714 : : struct ipsec_test_flags flags;
10715 : :
10716 : : memset(&flags, 0, sizeof(flags));
10717 : 0 : flags.fragment = true;
10718 : :
10719 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10720 : :
10721 : : /* Disable IV gen to be able to test with known vectors */
10722 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10723 : :
10724 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10725 : : }
10726 : :
10727 : : static int
10728 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10729 : : {
10730 : : const struct ipsec_test_data *td = test_data;
10731 : : struct ipsec_test_flags flags;
10732 : : struct ipsec_test_data td_inb;
10733 : :
10734 : : memset(&flags, 0, sizeof(flags));
10735 : 0 : flags.rx_inject = true;
10736 : :
10737 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10738 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10739 : : else
10740 : : memcpy(&td_inb, td, sizeof(td_inb));
10741 : :
10742 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10743 : : }
10744 : :
10745 : : static int
10746 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10747 : : {
10748 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10749 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10750 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10751 : : int ret;
10752 : :
10753 [ # # ]: 0 : if (flags->iv_gen ||
10754 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10755 : : flags->sa_expiry_pkts_hard)
10756 : : nb_pkts = TEST_SEC_PKTS_MAX;
10757 : :
10758 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10759 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10760 : : sec_alg_list[i].param2,
10761 : : flags,
10762 : : td_outb,
10763 : : nb_pkts);
10764 : :
10765 [ # # ]: 0 : if (!td_outb->aead) {
10766 : : enum rte_crypto_cipher_algorithm cipher_alg;
10767 : : enum rte_crypto_auth_algorithm auth_alg;
10768 : :
10769 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10770 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10771 : :
10772 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10773 : 0 : continue;
10774 : :
10775 : : /* ICV is not applicable for NULL auth */
10776 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10777 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10778 : 0 : continue;
10779 : :
10780 : : /* IV is not applicable for NULL cipher */
10781 [ # # # # ]: 0 : if (flags->iv_gen &&
10782 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10783 : 0 : continue;
10784 : : }
10785 : :
10786 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10787 : : flags);
10788 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10789 : 0 : continue;
10790 : :
10791 [ # # ]: 0 : if (ret == TEST_FAILED)
10792 : : return TEST_FAILED;
10793 : :
10794 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10795 : :
10796 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10797 : : flags);
10798 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10799 : 0 : continue;
10800 : :
10801 [ # # ]: 0 : if (ret == TEST_FAILED)
10802 : : return TEST_FAILED;
10803 : :
10804 [ # # ]: 0 : if (flags->display_alg)
10805 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10806 : :
10807 : 0 : pass_cnt++;
10808 : : }
10809 : :
10810 [ # # ]: 0 : if (pass_cnt > 0)
10811 : : return TEST_SUCCESS;
10812 : : else
10813 : 0 : return TEST_SKIPPED;
10814 : : }
10815 : :
10816 : : static int
10817 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10818 : : {
10819 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10820 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10821 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10822 : : int ret;
10823 : :
10824 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10825 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10826 : : sec_auth_only_alg_list[i].param2,
10827 : : flags,
10828 : : td_outb,
10829 : : nb_pkts);
10830 : :
10831 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10832 : : flags);
10833 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10834 : 0 : continue;
10835 : :
10836 [ # # ]: 0 : if (ret == TEST_FAILED)
10837 : : return TEST_FAILED;
10838 : :
10839 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10840 : :
10841 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10842 : : flags);
10843 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10844 : 0 : continue;
10845 : :
10846 [ # # ]: 0 : if (ret == TEST_FAILED)
10847 : : return TEST_FAILED;
10848 : :
10849 [ # # ]: 0 : if (flags->display_alg)
10850 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10851 : : sec_auth_only_alg_list[i].param2);
10852 : :
10853 : 0 : pass_cnt++;
10854 : : }
10855 : :
10856 [ # # ]: 0 : if (pass_cnt > 0)
10857 : : return TEST_SUCCESS;
10858 : : else
10859 : 0 : return TEST_SKIPPED;
10860 : : }
10861 : :
10862 : : static int
10863 : 0 : test_ipsec_proto_display_list(void)
10864 : : {
10865 : : struct ipsec_test_flags flags;
10866 : :
10867 : : memset(&flags, 0, sizeof(flags));
10868 : :
10869 : 0 : flags.display_alg = true;
10870 : :
10871 : 0 : return test_ipsec_proto_all(&flags);
10872 : : }
10873 : :
10874 : : static int
10875 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10876 : : {
10877 : : struct ipsec_test_flags flags;
10878 : :
10879 : : memset(&flags, 0, sizeof(flags));
10880 : :
10881 : 0 : flags.ah = true;
10882 : 0 : flags.display_alg = true;
10883 : :
10884 : 0 : return test_ipsec_ah_proto_all(&flags);
10885 : : }
10886 : :
10887 : : static int
10888 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10889 : : {
10890 : : struct ipsec_test_flags flags;
10891 : :
10892 : : memset(&flags, 0, sizeof(flags));
10893 : :
10894 : 0 : flags.ah = true;
10895 : 0 : flags.transport = true;
10896 : :
10897 : 0 : return test_ipsec_ah_proto_all(&flags);
10898 : : }
10899 : :
10900 : : static int
10901 : 0 : test_ipsec_proto_iv_gen(void)
10902 : : {
10903 : : struct ipsec_test_flags flags;
10904 : :
10905 : : memset(&flags, 0, sizeof(flags));
10906 : :
10907 : 0 : flags.iv_gen = true;
10908 : :
10909 : 0 : return test_ipsec_proto_all(&flags);
10910 : : }
10911 : :
10912 : : static int
10913 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10914 : : {
10915 : : struct ipsec_test_flags flags;
10916 : :
10917 : : memset(&flags, 0, sizeof(flags));
10918 : :
10919 : 0 : flags.sa_expiry_pkts_soft = true;
10920 : :
10921 : 0 : return test_ipsec_proto_all(&flags);
10922 : : }
10923 : :
10924 : : static int
10925 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10926 : : {
10927 : : struct ipsec_test_flags flags;
10928 : :
10929 : : memset(&flags, 0, sizeof(flags));
10930 : :
10931 : 0 : flags.sa_expiry_pkts_hard = true;
10932 : :
10933 : 0 : return test_ipsec_proto_all(&flags);
10934 : : }
10935 : :
10936 : : static int
10937 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10938 : : {
10939 : : struct ipsec_test_flags flags;
10940 : :
10941 : : memset(&flags, 0, sizeof(flags));
10942 : :
10943 : 0 : flags.icv_corrupt = true;
10944 : :
10945 : 0 : return test_ipsec_proto_all(&flags);
10946 : : }
10947 : :
10948 : : static int
10949 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10950 : : {
10951 : : struct ipsec_test_flags flags;
10952 : :
10953 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10954 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10955 : : return TEST_SKIPPED;
10956 : :
10957 : : memset(&flags, 0, sizeof(flags));
10958 : :
10959 : 0 : flags.udp_encap = true;
10960 : 0 : flags.udp_encap_custom_ports = true;
10961 : :
10962 : 0 : return test_ipsec_proto_all(&flags);
10963 : : }
10964 : :
10965 : : static int
10966 : 0 : test_ipsec_proto_udp_encap(void)
10967 : : {
10968 : : struct ipsec_test_flags flags;
10969 : :
10970 : : memset(&flags, 0, sizeof(flags));
10971 : :
10972 : 0 : flags.udp_encap = true;
10973 : :
10974 : 0 : return test_ipsec_proto_all(&flags);
10975 : : }
10976 : :
10977 : : static int
10978 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10979 : : {
10980 : : struct ipsec_test_flags flags;
10981 : :
10982 : : memset(&flags, 0, sizeof(flags));
10983 : :
10984 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10985 : :
10986 : 0 : return test_ipsec_proto_all(&flags);
10987 : : }
10988 : :
10989 : : static int
10990 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
10991 : : {
10992 : : struct ipsec_test_flags flags;
10993 : :
10994 : : memset(&flags, 0, sizeof(flags));
10995 : :
10996 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10997 : :
10998 : 0 : return test_ipsec_proto_all(&flags);
10999 : : }
11000 : :
11001 : : static int
11002 : 0 : test_ipsec_proto_udp_ports_verify(void)
11003 : : {
11004 : : struct ipsec_test_flags flags;
11005 : :
11006 : : memset(&flags, 0, sizeof(flags));
11007 : :
11008 : 0 : flags.udp_encap = true;
11009 : 0 : flags.udp_ports_verify = true;
11010 : :
11011 : 0 : return test_ipsec_proto_all(&flags);
11012 : : }
11013 : :
11014 : : static int
11015 : 0 : test_ipsec_proto_inner_ip_csum(void)
11016 : : {
11017 : : struct ipsec_test_flags flags;
11018 : :
11019 : : memset(&flags, 0, sizeof(flags));
11020 : :
11021 : 0 : flags.ip_csum = true;
11022 : :
11023 : 0 : return test_ipsec_proto_all(&flags);
11024 : : }
11025 : :
11026 : : static int
11027 : 0 : test_ipsec_proto_inner_l4_csum(void)
11028 : : {
11029 : : struct ipsec_test_flags flags;
11030 : :
11031 : : memset(&flags, 0, sizeof(flags));
11032 : :
11033 : 0 : flags.l4_csum = true;
11034 : :
11035 : 0 : return test_ipsec_proto_all(&flags);
11036 : : }
11037 : :
11038 : : static int
11039 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
11040 : : {
11041 : : struct ipsec_test_flags flags;
11042 : :
11043 : : memset(&flags, 0, sizeof(flags));
11044 : :
11045 : : flags.ipv6 = false;
11046 : : flags.tunnel_ipv6 = false;
11047 : :
11048 : 0 : return test_ipsec_proto_all(&flags);
11049 : : }
11050 : :
11051 : : static int
11052 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
11053 : : {
11054 : : struct ipsec_test_flags flags;
11055 : :
11056 : : memset(&flags, 0, sizeof(flags));
11057 : :
11058 : 0 : flags.ipv6 = true;
11059 : 0 : flags.tunnel_ipv6 = true;
11060 : :
11061 : 0 : return test_ipsec_proto_all(&flags);
11062 : : }
11063 : :
11064 : : static int
11065 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
11066 : : {
11067 : : struct ipsec_test_flags flags;
11068 : :
11069 : : memset(&flags, 0, sizeof(flags));
11070 : :
11071 : : flags.ipv6 = false;
11072 : 0 : flags.tunnel_ipv6 = true;
11073 : :
11074 : 0 : return test_ipsec_proto_all(&flags);
11075 : : }
11076 : :
11077 : : static int
11078 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
11079 : : {
11080 : : struct ipsec_test_flags flags;
11081 : :
11082 : : memset(&flags, 0, sizeof(flags));
11083 : :
11084 : 0 : flags.ipv6 = true;
11085 : : flags.tunnel_ipv6 = false;
11086 : :
11087 : 0 : return test_ipsec_proto_all(&flags);
11088 : : }
11089 : :
11090 : : static int
11091 : 0 : test_ipsec_proto_transport_v4(void)
11092 : : {
11093 : : struct ipsec_test_flags flags;
11094 : :
11095 : : memset(&flags, 0, sizeof(flags));
11096 : :
11097 : : flags.ipv6 = false;
11098 : 0 : flags.transport = true;
11099 : :
11100 : 0 : return test_ipsec_proto_all(&flags);
11101 : : }
11102 : :
11103 : : static int
11104 : 0 : test_ipsec_proto_transport_l4_csum(void)
11105 : : {
11106 : 0 : struct ipsec_test_flags flags = {
11107 : : .l4_csum = true,
11108 : : .transport = true,
11109 : : };
11110 : :
11111 : 0 : return test_ipsec_proto_all(&flags);
11112 : : }
11113 : :
11114 : : static int
11115 : 0 : test_ipsec_proto_stats(void)
11116 : : {
11117 : : struct ipsec_test_flags flags;
11118 : :
11119 : : memset(&flags, 0, sizeof(flags));
11120 : :
11121 : 0 : flags.stats_success = true;
11122 : :
11123 : 0 : return test_ipsec_proto_all(&flags);
11124 : : }
11125 : :
11126 : : static int
11127 : 0 : test_ipsec_proto_pkt_fragment(void)
11128 : : {
11129 : : struct ipsec_test_flags flags;
11130 : :
11131 : : memset(&flags, 0, sizeof(flags));
11132 : :
11133 : 0 : flags.fragment = true;
11134 : :
11135 : 0 : return test_ipsec_proto_all(&flags);
11136 : :
11137 : : }
11138 : :
11139 : : static int
11140 : 0 : test_ipsec_proto_copy_df_inner_0(void)
11141 : : {
11142 : : struct ipsec_test_flags flags;
11143 : :
11144 : : memset(&flags, 0, sizeof(flags));
11145 : :
11146 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11147 : :
11148 : 0 : return test_ipsec_proto_all(&flags);
11149 : : }
11150 : :
11151 : : static int
11152 : 0 : test_ipsec_proto_copy_df_inner_1(void)
11153 : : {
11154 : : struct ipsec_test_flags flags;
11155 : :
11156 : : memset(&flags, 0, sizeof(flags));
11157 : :
11158 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11159 : :
11160 : 0 : return test_ipsec_proto_all(&flags);
11161 : : }
11162 : :
11163 : : static int
11164 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
11165 : : {
11166 : : struct ipsec_test_flags flags;
11167 : :
11168 : : memset(&flags, 0, sizeof(flags));
11169 : :
11170 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11171 : :
11172 : 0 : return test_ipsec_proto_all(&flags);
11173 : : }
11174 : :
11175 : : static int
11176 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
11177 : : {
11178 : : struct ipsec_test_flags flags;
11179 : :
11180 : : memset(&flags, 0, sizeof(flags));
11181 : :
11182 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11183 : :
11184 : 0 : return test_ipsec_proto_all(&flags);
11185 : : }
11186 : :
11187 : : static int
11188 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11189 : : {
11190 : : struct ipsec_test_flags flags;
11191 : :
11192 : : memset(&flags, 0, sizeof(flags));
11193 : :
11194 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11195 : :
11196 : 0 : return test_ipsec_proto_all(&flags);
11197 : : }
11198 : :
11199 : : static int
11200 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11201 : : {
11202 : : struct ipsec_test_flags flags;
11203 : :
11204 : : memset(&flags, 0, sizeof(flags));
11205 : :
11206 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11207 : :
11208 : 0 : return test_ipsec_proto_all(&flags);
11209 : : }
11210 : :
11211 : : static int
11212 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11213 : : {
11214 : : struct ipsec_test_flags flags;
11215 : :
11216 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11217 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11218 : : return TEST_SKIPPED;
11219 : :
11220 : : memset(&flags, 0, sizeof(flags));
11221 : :
11222 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11223 : :
11224 : 0 : return test_ipsec_proto_all(&flags);
11225 : : }
11226 : :
11227 : : static int
11228 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11229 : : {
11230 : : struct ipsec_test_flags flags;
11231 : :
11232 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11233 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11234 : : return TEST_SKIPPED;
11235 : :
11236 : : memset(&flags, 0, sizeof(flags));
11237 : :
11238 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11239 : :
11240 : 0 : return test_ipsec_proto_all(&flags);
11241 : : }
11242 : :
11243 : : static int
11244 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11245 : : {
11246 : : struct ipsec_test_flags flags;
11247 : :
11248 : : memset(&flags, 0, sizeof(flags));
11249 : :
11250 : 0 : flags.ipv6 = true;
11251 : 0 : flags.tunnel_ipv6 = true;
11252 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11253 : :
11254 : 0 : return test_ipsec_proto_all(&flags);
11255 : : }
11256 : :
11257 : : static int
11258 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11259 : : {
11260 : : struct ipsec_test_flags flags;
11261 : :
11262 : : memset(&flags, 0, sizeof(flags));
11263 : :
11264 : 0 : flags.ipv6 = true;
11265 : 0 : flags.tunnel_ipv6 = true;
11266 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11267 : :
11268 : 0 : return test_ipsec_proto_all(&flags);
11269 : : }
11270 : :
11271 : : static int
11272 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11273 : : {
11274 : : struct ipsec_test_flags flags;
11275 : :
11276 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11277 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11278 : : return TEST_SKIPPED;
11279 : :
11280 : : memset(&flags, 0, sizeof(flags));
11281 : :
11282 : 0 : flags.ipv6 = true;
11283 : 0 : flags.tunnel_ipv6 = true;
11284 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11285 : :
11286 : 0 : return test_ipsec_proto_all(&flags);
11287 : : }
11288 : :
11289 : : static int
11290 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11291 : : {
11292 : : struct ipsec_test_flags flags;
11293 : :
11294 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11295 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11296 : : return TEST_SKIPPED;
11297 : :
11298 : : memset(&flags, 0, sizeof(flags));
11299 : :
11300 : 0 : flags.ipv6 = true;
11301 : 0 : flags.tunnel_ipv6 = true;
11302 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11303 : :
11304 : 0 : return test_ipsec_proto_all(&flags);
11305 : : }
11306 : :
11307 : : static int
11308 : 0 : test_ipsec_proto_sgl(void)
11309 : : {
11310 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11311 : : struct rte_cryptodev_info dev_info;
11312 : :
11313 : 0 : struct ipsec_test_flags flags = {
11314 : : .nb_segs_in_mbuf = 5
11315 : : };
11316 : :
11317 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11318 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11319 : : printf("Device doesn't support in-place scatter-gather. "
11320 : : "Test Skipped.\n");
11321 : 0 : return TEST_SKIPPED;
11322 : : }
11323 : :
11324 : 0 : return test_ipsec_proto_all(&flags);
11325 : : }
11326 : :
11327 : : static int
11328 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11329 : : {
11330 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11331 : : struct rte_cryptodev_info dev_info;
11332 : :
11333 : 0 : struct ipsec_test_flags flags = {
11334 : : .nb_segs_in_mbuf = 5,
11335 : : .use_ext_mbuf = 1
11336 : : };
11337 : :
11338 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11339 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11340 : : printf("Device doesn't support in-place scatter-gather. "
11341 : : "Test Skipped.\n");
11342 : 0 : return TEST_SKIPPED;
11343 : : }
11344 : :
11345 : 0 : return test_ipsec_proto_all(&flags);
11346 : : }
11347 : :
11348 : : static int
11349 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11350 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11351 : : uint64_t winsz)
11352 : : {
11353 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11354 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11355 : : struct ipsec_test_flags flags;
11356 : : uint32_t i = 0, ret = 0;
11357 : :
11358 [ # # ]: 0 : if (nb_pkts == 0)
11359 : : return TEST_FAILED;
11360 : :
11361 : : memset(&flags, 0, sizeof(flags));
11362 : 0 : flags.antireplay = true;
11363 : :
11364 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11365 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11366 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11367 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11368 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11369 : : }
11370 : :
11371 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11372 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11373 : :
11374 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11375 : : &flags);
11376 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11377 : : return ret;
11378 : :
11379 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11380 : :
11381 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11382 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11383 : : /* Set antireplay flag for packets to be dropped */
11384 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11385 : : }
11386 : :
11387 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11388 : : &flags);
11389 : :
11390 : 0 : return ret;
11391 : : }
11392 : :
11393 : : static int
11394 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11395 : : {
11396 : :
11397 : : uint32_t nb_pkts = 5;
11398 : : bool replayed_pkt[5];
11399 : : uint64_t esn[5];
11400 : :
11401 : : /* 1. Advance the TOP of the window to WS * 2 */
11402 : 0 : esn[0] = winsz * 2;
11403 : : /* 2. Test sequence number within the new window(WS + 1) */
11404 : 0 : esn[1] = winsz + 1;
11405 : : /* 3. Test sequence number less than the window BOTTOM */
11406 : 0 : esn[2] = winsz;
11407 : : /* 4. Test sequence number in the middle of the window */
11408 : 0 : esn[3] = winsz + (winsz / 2);
11409 : : /* 5. Test replay of the packet in the middle of the window */
11410 : 0 : esn[4] = winsz + (winsz / 2);
11411 : :
11412 : 0 : replayed_pkt[0] = false;
11413 : 0 : replayed_pkt[1] = false;
11414 : 0 : replayed_pkt[2] = true;
11415 : 0 : replayed_pkt[3] = false;
11416 : 0 : replayed_pkt[4] = true;
11417 : :
11418 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11419 : : false, winsz);
11420 : : }
11421 : :
11422 : : static int
11423 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11424 : : {
11425 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11426 : : }
11427 : :
11428 : : static int
11429 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11430 : : {
11431 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11432 : : }
11433 : :
11434 : : static int
11435 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11436 : : {
11437 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11438 : : }
11439 : :
11440 : : static int
11441 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11442 : : {
11443 : :
11444 : : uint32_t nb_pkts = 7;
11445 : : bool replayed_pkt[7];
11446 : : uint64_t esn[7];
11447 : :
11448 : : /* Set the initial sequence number */
11449 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11450 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11451 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11452 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11453 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11454 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11455 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11456 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11457 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11458 : : /* 5. Test with duplicate sequence number within
11459 : : * new window (1<<32 - 1)
11460 : : */
11461 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11462 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11463 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11464 : :
11465 : 0 : replayed_pkt[0] = false;
11466 : 0 : replayed_pkt[1] = false;
11467 : 0 : replayed_pkt[2] = false;
11468 : 0 : replayed_pkt[3] = false;
11469 : 0 : replayed_pkt[4] = false;
11470 : 0 : replayed_pkt[5] = true;
11471 : 0 : replayed_pkt[6] = true;
11472 : :
11473 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11474 : : true, winsz);
11475 : : }
11476 : :
11477 : : static int
11478 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11479 : : {
11480 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11481 : : }
11482 : :
11483 : : static int
11484 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11485 : : {
11486 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11487 : : }
11488 : :
11489 : : static int
11490 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11491 : : {
11492 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11493 : : }
11494 : :
11495 : : static int
11496 : 0 : test_PDCP_PROTO_all(void)
11497 : : {
11498 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11499 : : struct crypto_unittest_params *ut_params = &unittest_params;
11500 : : struct rte_cryptodev_info dev_info;
11501 : : int status;
11502 : :
11503 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11504 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11505 : :
11506 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11507 : : return TEST_SKIPPED;
11508 : :
11509 : : /* Set action type */
11510 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11511 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11512 : : gbl_action_type;
11513 : :
11514 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11515 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11516 : : return TEST_SKIPPED;
11517 : :
11518 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11519 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11520 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11521 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11522 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11523 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11524 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11525 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11526 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11527 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11528 : 0 : status += test_PDCP_PROTO_short_mac();
11529 : :
11530 [ # # ]: 0 : if (status)
11531 : : return TEST_FAILED;
11532 : : else
11533 : 0 : return TEST_SUCCESS;
11534 : : }
11535 : :
11536 : : static int
11537 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11538 : : {
11539 : 0 : struct ipsec_test_flags flags = {
11540 : : .dec_ttl_or_hop_limit = true
11541 : : };
11542 : :
11543 : 0 : return test_ipsec_proto_all(&flags);
11544 : : }
11545 : :
11546 : : static int
11547 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11548 : : {
11549 : 0 : struct ipsec_test_flags flags = {
11550 : : .ipv6 = true,
11551 : : .dec_ttl_or_hop_limit = true
11552 : : };
11553 : :
11554 : 0 : return test_ipsec_proto_all(&flags);
11555 : : }
11556 : :
11557 : : static int
11558 : 0 : test_docsis_proto_uplink(const void *data)
11559 : : {
11560 : : const struct docsis_test_data *d_td = data;
11561 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11562 : : struct crypto_unittest_params *ut_params = &unittest_params;
11563 : : uint8_t *plaintext = NULL;
11564 : : uint8_t *ciphertext = NULL;
11565 : : uint8_t *iv_ptr;
11566 : : int32_t cipher_len, crc_len;
11567 : : uint32_t crc_data_len;
11568 : : int ret = TEST_SUCCESS;
11569 : :
11570 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11571 : :
11572 : : /* Verify the capabilities */
11573 : : struct rte_security_capability_idx sec_cap_idx;
11574 : : const struct rte_security_capability *sec_cap;
11575 : : const struct rte_cryptodev_capabilities *crypto_cap;
11576 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11577 : : int j = 0;
11578 : :
11579 : : /* Set action type */
11580 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11581 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11582 : : gbl_action_type;
11583 : :
11584 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11585 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11586 : : return TEST_SKIPPED;
11587 : :
11588 : 0 : sec_cap_idx.action = ut_params->type;
11589 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11590 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11591 : :
11592 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11593 [ # # ]: 0 : if (sec_cap == NULL)
11594 : : return TEST_SKIPPED;
11595 : :
11596 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11597 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11598 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11599 : : crypto_cap->sym.xform_type ==
11600 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11601 : : crypto_cap->sym.cipher.algo ==
11602 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11603 : 0 : sym_cap = &crypto_cap->sym;
11604 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11605 : 0 : d_td->key.len,
11606 : 0 : d_td->iv.len) == 0)
11607 : : break;
11608 : : }
11609 : : }
11610 : :
11611 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11612 : : return TEST_SKIPPED;
11613 : :
11614 : : /* Setup source mbuf payload */
11615 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11616 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11617 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11618 : :
11619 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11620 : 0 : d_td->ciphertext.len);
11621 : :
11622 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11623 : :
11624 : : /* Setup cipher session parameters */
11625 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11626 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11627 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11628 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11629 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11630 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11631 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11632 : 0 : ut_params->cipher_xform.next = NULL;
11633 : :
11634 : : /* Setup DOCSIS session parameters */
11635 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11636 : :
11637 : 0 : struct rte_security_session_conf sess_conf = {
11638 : 0 : .action_type = ut_params->type,
11639 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11640 : : .docsis = ut_params->docsis_xform,
11641 : : .crypto_xform = &ut_params->cipher_xform,
11642 : : };
11643 : :
11644 : : /* Create security session */
11645 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11646 : : ts_params->session_mpool);
11647 : :
11648 [ # # ]: 0 : if (!ut_params->sec_session) {
11649 : : printf("Test function %s line %u: failed to allocate session\n",
11650 : : __func__, __LINE__);
11651 : : ret = TEST_FAILED;
11652 : 0 : goto on_err;
11653 : : }
11654 : :
11655 : : /* Generate crypto op data structure */
11656 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11657 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11658 [ # # ]: 0 : if (!ut_params->op) {
11659 : : printf("Test function %s line %u: failed to allocate symmetric "
11660 : : "crypto operation\n", __func__, __LINE__);
11661 : : ret = TEST_FAILED;
11662 : 0 : goto on_err;
11663 : : }
11664 : :
11665 : : /* Setup CRC operation parameters */
11666 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11667 : 0 : (d_td->ciphertext.len -
11668 : 0 : d_td->ciphertext.crc_offset -
11669 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11670 : : 0;
11671 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11672 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11673 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11674 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11675 : :
11676 : : /* Setup cipher operation parameters */
11677 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11678 : 0 : (d_td->ciphertext.len -
11679 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11680 : : 0;
11681 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11682 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11683 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11684 : :
11685 : : /* Setup cipher IV */
11686 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11687 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11688 : :
11689 : : /* Attach session to operation */
11690 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11691 : :
11692 : : /* Set crypto operation mbufs */
11693 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11694 : 0 : ut_params->op->sym->m_dst = NULL;
11695 : :
11696 : : /* Process crypto operation */
11697 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11698 : : NULL) {
11699 : : printf("Test function %s line %u: failed to process security "
11700 : : "crypto op\n", __func__, __LINE__);
11701 : : ret = TEST_FAILED;
11702 : 0 : goto on_err;
11703 : : }
11704 : :
11705 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11706 : : printf("Test function %s line %u: failed to process crypto op\n",
11707 : : __func__, __LINE__);
11708 : : ret = TEST_FAILED;
11709 : 0 : goto on_err;
11710 : : }
11711 : :
11712 : : /* Validate plaintext */
11713 : : plaintext = ciphertext;
11714 : :
11715 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11716 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11717 : : printf("Test function %s line %u: plaintext not as expected\n",
11718 : : __func__, __LINE__);
11719 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11720 : 0 : d_td->plaintext.len);
11721 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11722 : : ret = TEST_FAILED;
11723 : 0 : goto on_err;
11724 : : }
11725 : :
11726 : 0 : on_err:
11727 : 0 : rte_crypto_op_free(ut_params->op);
11728 : 0 : ut_params->op = NULL;
11729 : :
11730 [ # # ]: 0 : if (ut_params->sec_session)
11731 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11732 : 0 : ut_params->sec_session = NULL;
11733 : :
11734 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11735 : 0 : ut_params->ibuf = NULL;
11736 : :
11737 : 0 : return ret;
11738 : : }
11739 : :
11740 : : static int
11741 : 0 : test_docsis_proto_downlink(const void *data)
11742 : : {
11743 : : const struct docsis_test_data *d_td = data;
11744 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11745 : : struct crypto_unittest_params *ut_params = &unittest_params;
11746 : : uint8_t *plaintext = NULL;
11747 : : uint8_t *ciphertext = NULL;
11748 : : uint8_t *iv_ptr;
11749 : : int32_t cipher_len, crc_len;
11750 : : int ret = TEST_SUCCESS;
11751 : :
11752 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11753 : :
11754 : : /* Verify the capabilities */
11755 : : struct rte_security_capability_idx sec_cap_idx;
11756 : : const struct rte_security_capability *sec_cap;
11757 : : const struct rte_cryptodev_capabilities *crypto_cap;
11758 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11759 : : int j = 0;
11760 : :
11761 : : /* Set action type */
11762 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11763 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11764 : : gbl_action_type;
11765 : :
11766 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11767 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11768 : : return TEST_SKIPPED;
11769 : :
11770 : 0 : sec_cap_idx.action = ut_params->type;
11771 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11772 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11773 : :
11774 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11775 [ # # ]: 0 : if (sec_cap == NULL)
11776 : : return TEST_SKIPPED;
11777 : :
11778 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11779 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11780 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11781 : : crypto_cap->sym.xform_type ==
11782 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11783 : : crypto_cap->sym.cipher.algo ==
11784 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11785 : 0 : sym_cap = &crypto_cap->sym;
11786 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11787 : 0 : d_td->key.len,
11788 : 0 : d_td->iv.len) == 0)
11789 : : break;
11790 : : }
11791 : : }
11792 : :
11793 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11794 : : return TEST_SKIPPED;
11795 : :
11796 : : /* Setup source mbuf payload */
11797 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11798 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11799 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11800 : :
11801 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11802 : 0 : d_td->plaintext.len);
11803 : :
11804 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11805 : :
11806 : : /* Setup cipher session parameters */
11807 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11808 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11809 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11810 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11811 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11812 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11813 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11814 : 0 : ut_params->cipher_xform.next = NULL;
11815 : :
11816 : : /* Setup DOCSIS session parameters */
11817 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11818 : :
11819 : 0 : struct rte_security_session_conf sess_conf = {
11820 : 0 : .action_type = ut_params->type,
11821 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11822 : : .docsis = ut_params->docsis_xform,
11823 : : .crypto_xform = &ut_params->cipher_xform,
11824 : : };
11825 : :
11826 : : /* Create security session */
11827 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11828 : : ts_params->session_mpool);
11829 : :
11830 [ # # ]: 0 : if (!ut_params->sec_session) {
11831 : : printf("Test function %s line %u: failed to allocate session\n",
11832 : : __func__, __LINE__);
11833 : : ret = TEST_FAILED;
11834 : 0 : goto on_err;
11835 : : }
11836 : :
11837 : : /* Generate crypto op data structure */
11838 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11839 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11840 [ # # ]: 0 : if (!ut_params->op) {
11841 : : printf("Test function %s line %u: failed to allocate symmetric "
11842 : : "crypto operation\n", __func__, __LINE__);
11843 : : ret = TEST_FAILED;
11844 : 0 : goto on_err;
11845 : : }
11846 : :
11847 : : /* Setup CRC operation parameters */
11848 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11849 : 0 : (d_td->plaintext.len -
11850 : 0 : d_td->plaintext.crc_offset -
11851 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11852 : : 0;
11853 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11854 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11855 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11856 : :
11857 : : /* Setup cipher operation parameters */
11858 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11859 : 0 : (d_td->plaintext.len -
11860 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11861 : : 0;
11862 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11863 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11864 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11865 : :
11866 : : /* Setup cipher IV */
11867 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11868 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11869 : :
11870 : : /* Attach session to operation */
11871 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11872 : :
11873 : : /* Set crypto operation mbufs */
11874 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11875 : 0 : ut_params->op->sym->m_dst = NULL;
11876 : :
11877 : : /* Process crypto operation */
11878 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11879 : : NULL) {
11880 : : printf("Test function %s line %u: failed to process crypto op\n",
11881 : : __func__, __LINE__);
11882 : : ret = TEST_FAILED;
11883 : 0 : goto on_err;
11884 : : }
11885 : :
11886 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11887 : : printf("Test function %s line %u: crypto op processing failed\n",
11888 : : __func__, __LINE__);
11889 : : ret = TEST_FAILED;
11890 : 0 : goto on_err;
11891 : : }
11892 : :
11893 : : /* Validate ciphertext */
11894 : : ciphertext = plaintext;
11895 : :
11896 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11897 : : printf("Test function %s line %u: plaintext not as expected\n",
11898 : : __func__, __LINE__);
11899 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11900 : 0 : d_td->ciphertext.len);
11901 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11902 : : ret = TEST_FAILED;
11903 : 0 : goto on_err;
11904 : : }
11905 : :
11906 : 0 : on_err:
11907 : 0 : rte_crypto_op_free(ut_params->op);
11908 : 0 : ut_params->op = NULL;
11909 : :
11910 [ # # ]: 0 : if (ut_params->sec_session)
11911 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11912 : 0 : ut_params->sec_session = NULL;
11913 : :
11914 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11915 : 0 : ut_params->ibuf = NULL;
11916 : :
11917 : 0 : return ret;
11918 : : }
11919 : :
11920 : : static void
11921 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11922 : : struct rte_security_tls_record_xform *tls_record_xform)
11923 : : {
11924 : : unsigned int imp_nonce_len;
11925 : : uint8_t *imp_nonce;
11926 : :
11927 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11928 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11929 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11930 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11931 : 0 : break;
11932 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11933 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11934 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11935 : 0 : break;
11936 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
11937 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11938 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11939 : 0 : break;
11940 : : default:
11941 : : return;
11942 : : }
11943 : :
11944 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11945 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11946 : : }
11947 : :
11948 : : static int
11949 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
11950 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
11951 : : const struct tls_record_test_flags *flags)
11952 : : {
11953 : 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11954 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11955 : : struct crypto_unittest_params *ut_params = &unittest_params;
11956 : : struct rte_security_tls_record_xform tls_record_xform;
11957 : : struct rte_security_capability_idx sec_cap_idx;
11958 : : const struct rte_security_capability *sec_cap;
11959 : : struct tls_record_test_data *res_d_tmp = NULL;
11960 : : enum rte_security_tls_sess_type sess_type;
11961 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
11962 : : struct rte_security_ctx *ctx;
11963 : : int i, ret = TEST_SUCCESS;
11964 : :
11965 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11966 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11967 : :
11968 : : /* Use first test data to create session */
11969 : :
11970 : : /* Copy TLS record xform */
11971 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11972 : :
11973 : 0 : sess_type = tls_record_xform.type;
11974 : :
11975 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
11976 : :
11977 : 0 : sec_cap_idx.action = ut_params->type;
11978 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11979 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
11980 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11981 : :
11982 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11983 [ # # ]: 0 : if (sec_cap == NULL)
11984 : : return TEST_SKIPPED;
11985 : :
11986 : : /* Copy cipher session parameters */
11987 [ # # ]: 0 : if (td[0].aead) {
11988 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11989 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
11990 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11991 : :
11992 : : /* Verify crypto capabilities */
11993 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11994 [ # # ]: 0 : if (!silent)
11995 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11996 : 0 : return TEST_SKIPPED;
11997 : : }
11998 : : } else {
11999 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
12000 : : sizeof(ut_params->cipher_xform));
12001 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
12002 : : sizeof(ut_params->auth_xform));
12003 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
12004 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12005 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
12006 : :
12007 : : /* Verify crypto capabilities */
12008 : :
12009 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
12010 [ # # ]: 0 : if (!silent)
12011 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
12012 : 0 : return TEST_SKIPPED;
12013 : : }
12014 : :
12015 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
12016 [ # # ]: 0 : if (!silent)
12017 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
12018 : 0 : return TEST_SKIPPED;
12019 : : }
12020 : : }
12021 : :
12022 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
12023 : : return TEST_SKIPPED;
12024 : :
12025 : 0 : struct rte_security_session_conf sess_conf = {
12026 : 0 : .action_type = ut_params->type,
12027 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
12028 : : };
12029 : :
12030 : : if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
12031 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
12032 : : sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
12033 : :
12034 [ # # ]: 0 : if (td[0].aead)
12035 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
12036 : :
12037 [ # # ]: 0 : if (flags->opt_padding)
12038 : 0 : tls_record_xform.options.extra_padding_enable = 1;
12039 : :
12040 : 0 : sess_conf.tls_record = tls_record_xform;
12041 : :
12042 [ # # ]: 0 : if (td[0].aead) {
12043 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
12044 : : } else {
12045 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
12046 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
12047 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
12048 : : } else {
12049 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
12050 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
12051 : : }
12052 : : }
12053 : :
12054 [ # # ]: 0 : if (ut_params->sec_session == NULL) {
12055 : : /* Create security session */
12056 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
12057 : : ts_params->session_mpool);
12058 : : }
12059 : :
12060 [ # # ]: 0 : if (ut_params->sec_session == NULL)
12061 : : return TEST_SKIPPED;
12062 : :
12063 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
12064 [ # # # # ]: 0 : if (flags->ar_win_size &&
12065 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
12066 : 0 : sess_conf.tls_record.dtls_1_2.seq_no =
12067 : 0 : td[i].tls_record_xform.dtls_1_2.seq_no;
12068 : 0 : ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
12069 [ # # ]: 0 : if (ret) {
12070 : : printf("Could not update sequence number in session\n");
12071 : 0 : return TEST_SKIPPED;
12072 : : }
12073 : : }
12074 : :
12075 : : /* Setup source mbuf payload */
12076 : 0 : ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12077 : 0 : ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
12078 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
12079 [ # # ]: 0 : if (flags->out_of_place)
12080 : 0 : ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12081 : 0 : ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
12082 : : 0);
12083 : : else
12084 : 0 : ut_params->obuf = NULL;
12085 : :
12086 : : /* Generate crypto op data structure */
12087 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12088 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12089 [ # # ]: 0 : if (ut_params->op == NULL) {
12090 : : printf("Could not allocate crypto op");
12091 : : ret = TEST_FAILED;
12092 : 0 : goto crypto_op_free;
12093 : : }
12094 : :
12095 : : /* Attach session to operation */
12096 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
12097 : :
12098 : : /* Set crypto operation mbufs */
12099 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12100 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12101 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
12102 : :
12103 [ # # ]: 0 : if (flags->opt_padding)
12104 : 0 : ut_params->op->aux_flags = flags->opt_padding;
12105 : :
12106 : : /* Copy IV in crypto operation when IV generation is disabled */
12107 [ # # ]: 0 : if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12108 [ # # ]: 0 : (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12109 [ # # ]: 0 : (tls_record_xform.options.iv_gen_disable == 1)) {
12110 : : uint8_t *iv;
12111 : : int len;
12112 : :
12113 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12114 [ # # ]: 0 : if (td[i].aead)
12115 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
12116 : : else
12117 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
12118 : 0 : memcpy(iv, td[i].iv.data, len);
12119 : : }
12120 : :
12121 : : /* Process crypto operation */
12122 : 0 : process_crypto_request(dev_id, ut_params->op);
12123 : :
12124 : 0 : ret = test_tls_record_status_check(ut_params->op, &td[i]);
12125 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12126 : 0 : goto crypto_op_free;
12127 : :
12128 [ # # ]: 0 : if (res_d != NULL)
12129 : 0 : res_d_tmp = &res_d[i];
12130 : :
12131 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12132 [ # # ]: 0 : struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12133 : : ut_params->ibuf;
12134 : :
12135 : 0 : ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12136 : : silent, flags);
12137 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12138 : 0 : goto crypto_op_free;
12139 : : }
12140 : :
12141 : 0 : rte_crypto_op_free(ut_params->op);
12142 : 0 : ut_params->op = NULL;
12143 : :
12144 [ # # ]: 0 : if (flags->out_of_place) {
12145 : 0 : rte_pktmbuf_free(ut_params->obuf);
12146 : 0 : ut_params->obuf = NULL;
12147 : : }
12148 : :
12149 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12150 : 0 : ut_params->ibuf = NULL;
12151 : : }
12152 : :
12153 : 0 : crypto_op_free:
12154 : 0 : rte_crypto_op_free(ut_params->op);
12155 : 0 : ut_params->op = NULL;
12156 : :
12157 [ # # ]: 0 : if (flags->out_of_place) {
12158 : 0 : rte_pktmbuf_free(ut_params->obuf);
12159 : 0 : ut_params->obuf = NULL;
12160 : : }
12161 : :
12162 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12163 : 0 : ut_params->ibuf = NULL;
12164 : :
12165 [ # # # # ]: 0 : if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12166 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
12167 : 0 : ut_params->sec_session = NULL;
12168 : : }
12169 : :
12170 : : RTE_SET_USED(flags);
12171 : :
12172 : : return ret;
12173 : : }
12174 : :
12175 : : static int
12176 : 0 : test_tls_record_proto_known_vec(const void *test_data)
12177 : : {
12178 : : struct tls_record_test_data td_write;
12179 : : struct tls_record_test_flags flags;
12180 : :
12181 : : memset(&flags, 0, sizeof(flags));
12182 : :
12183 : : memcpy(&td_write, test_data, sizeof(td_write));
12184 : :
12185 : : /* Disable IV gen to be able to test with known vectors */
12186 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
12187 : :
12188 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12189 : : }
12190 : :
12191 : : static int
12192 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
12193 : : {
12194 : : const struct tls_record_test_data *td = test_data;
12195 : : struct tls_record_test_flags flags;
12196 : : struct tls_record_test_data td_inb;
12197 : :
12198 : : memset(&flags, 0, sizeof(flags));
12199 : :
12200 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12201 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
12202 : : else
12203 : : memcpy(&td_inb, td, sizeof(td_inb));
12204 : :
12205 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12206 : : }
12207 : :
12208 : : static int
12209 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12210 : : {
12211 : : unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12212 : : struct crypto_unittest_params *ut_params = &unittest_params;
12213 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12214 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12215 : : void *sec_session_outb = NULL;
12216 : : void *sec_session_inb = NULL;
12217 : : int ret;
12218 : :
12219 [ # # # ]: 0 : switch (flags->tls_version) {
12220 : : case RTE_SECURITY_VERSION_TLS_1_2:
12221 : : max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12222 : : break;
12223 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
12224 : : max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12225 : 0 : break;
12226 : : case RTE_SECURITY_VERSION_DTLS_1_2:
12227 : : max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12228 : : break;
12229 : 0 : default:
12230 : : max_payload_len = 0;
12231 : : }
12232 : :
12233 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12234 : : payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12235 [ # # ]: 0 : if (flags->nb_segs_in_mbuf)
12236 : 0 : payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12237 : :
12238 [ # # ]: 0 : if (flags->zero_len)
12239 : : payload_len = 0;
12240 : 0 : again:
12241 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12242 : : flags, td_outb, nb_pkts, payload_len);
12243 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12244 : 0 : continue;
12245 : :
12246 [ # # ]: 0 : if (flags->skip_sess_destroy)
12247 : 0 : ut_params->sec_session = sec_session_outb;
12248 : :
12249 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12250 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12251 : 0 : continue;
12252 : :
12253 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_outb == NULL)
12254 : 0 : sec_session_outb = ut_params->sec_session;
12255 : :
12256 [ # # # # ]: 0 : if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
12257 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12258 : : return TEST_FAILED;
12259 : 0 : goto skip_decrypt;
12260 [ # # ]: 0 : } else if (ret == TEST_FAILED) {
12261 : : return TEST_FAILED;
12262 : : }
12263 : :
12264 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12265 : :
12266 [ # # ]: 0 : if (flags->skip_sess_destroy)
12267 : 0 : ut_params->sec_session = sec_session_inb;
12268 : :
12269 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12270 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12271 : 0 : continue;
12272 : :
12273 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_inb == NULL)
12274 : 0 : sec_session_inb = ut_params->sec_session;
12275 : :
12276 [ # # # # ]: 0 : if (flags->pkt_corruption || flags->padding_corruption) {
12277 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12278 : : return TEST_FAILED;
12279 : : } else {
12280 [ # # ]: 0 : if (ret == TEST_FAILED)
12281 : : return TEST_FAILED;
12282 : : }
12283 : :
12284 : 0 : skip_decrypt:
12285 [ # # # # ]: 0 : if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12286 : 0 : goto again;
12287 : :
12288 [ # # ]: 0 : if (flags->display_alg)
12289 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12290 : :
12291 [ # # ]: 0 : if (flags->skip_sess_destroy) {
12292 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
12293 : : struct rte_security_ctx *ctx;
12294 : :
12295 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12296 [ # # ]: 0 : if (sec_session_inb != NULL) {
12297 : 0 : rte_security_session_destroy(ctx, sec_session_inb);
12298 : : sec_session_inb = NULL;
12299 : : }
12300 [ # # ]: 0 : if (sec_session_outb != NULL) {
12301 : 0 : rte_security_session_destroy(ctx, sec_session_outb);
12302 : : sec_session_outb = NULL;
12303 : : }
12304 : 0 : ut_params->sec_session = NULL;
12305 : : }
12306 : :
12307 : 0 : pass_cnt++;
12308 : : }
12309 : :
12310 [ # # ]: 0 : if (flags->data_walkthrough)
12311 : : printf("\t Min payload size: %d, Max payload size: %d\n",
12312 : : TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
12313 : :
12314 [ # # ]: 0 : if (pass_cnt > 0)
12315 : : return TEST_SUCCESS;
12316 : : else
12317 : 0 : return TEST_SKIPPED;
12318 : : }
12319 : :
12320 : : static int
12321 : 0 : test_tls_1_2_record_proto_data_walkthrough(void)
12322 : : {
12323 : : struct tls_record_test_flags flags;
12324 : :
12325 : : memset(&flags, 0, sizeof(flags));
12326 : :
12327 : 0 : flags.data_walkthrough = true;
12328 : 0 : flags.skip_sess_destroy = true;
12329 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12330 : :
12331 : 0 : return test_tls_record_proto_all(&flags);
12332 : : }
12333 : :
12334 : : static int
12335 : 0 : test_tls_1_2_record_proto_display_list(void)
12336 : : {
12337 : : struct tls_record_test_flags flags;
12338 : :
12339 : : memset(&flags, 0, sizeof(flags));
12340 : :
12341 : 0 : flags.display_alg = true;
12342 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12343 : :
12344 : 0 : return test_tls_record_proto_all(&flags);
12345 : : }
12346 : :
12347 : : static int
12348 : 0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12349 : : {
12350 : 0 : struct tls_record_test_flags flags = {
12351 : : .nb_segs_in_mbuf = 5,
12352 : : .tls_version = tls_version
12353 : : };
12354 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12355 : : struct rte_cryptodev_info dev_info;
12356 : :
12357 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12358 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12359 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12360 : 0 : return TEST_SKIPPED;
12361 : : }
12362 : :
12363 : 0 : return test_tls_record_proto_all(&flags);
12364 : : }
12365 : :
12366 : : static int
12367 : 0 : test_tls_1_2_record_proto_sgl(void)
12368 : : {
12369 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12370 : : }
12371 : :
12372 : : static int
12373 : 0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12374 : : {
12375 : 0 : struct tls_record_test_flags flags = {
12376 : : .nb_segs_in_mbuf = 5,
12377 : : .tls_version = tls_version,
12378 : : .skip_sess_destroy = true,
12379 : : .data_walkthrough = true
12380 : : };
12381 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12382 : : struct rte_cryptodev_info dev_info;
12383 : :
12384 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12385 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12386 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12387 : 0 : return TEST_SKIPPED;
12388 : : }
12389 : :
12390 : 0 : return test_tls_record_proto_all(&flags);
12391 : : }
12392 : :
12393 : : static int
12394 : 0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12395 : : {
12396 : 0 : struct tls_record_test_flags flags = {
12397 : : .nb_segs_in_mbuf = 5,
12398 : : .out_of_place = true,
12399 : : .tls_version = tls_version
12400 : : };
12401 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12402 : : struct rte_cryptodev_info dev_info;
12403 : :
12404 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12405 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12406 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12407 : 0 : return TEST_SKIPPED;
12408 : : }
12409 : :
12410 : 0 : return test_tls_record_proto_all(&flags);
12411 : : }
12412 : :
12413 : : static int
12414 : 0 : test_tls_1_2_record_proto_sgl_oop(void)
12415 : : {
12416 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12417 : : }
12418 : :
12419 : : static int
12420 : 0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12421 : : {
12422 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12423 : : }
12424 : :
12425 : : static int
12426 : 0 : test_tls_record_proto_corrupt_pkt(void)
12427 : : {
12428 : 0 : struct tls_record_test_flags flags = {
12429 : : .pkt_corruption = 1
12430 : : };
12431 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12432 : : struct rte_cryptodev_info dev_info;
12433 : :
12434 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12435 : :
12436 : 0 : return test_tls_record_proto_all(&flags);
12437 : : }
12438 : :
12439 : : static int
12440 : 0 : test_tls_record_proto_custom_content_type(void)
12441 : : {
12442 : 0 : struct tls_record_test_flags flags = {
12443 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12444 : : };
12445 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12446 : : struct rte_cryptodev_info dev_info;
12447 : :
12448 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12449 : :
12450 : 0 : return test_tls_record_proto_all(&flags);
12451 : : }
12452 : :
12453 : : static int
12454 : 0 : test_tls_record_proto_zero_len(void)
12455 : : {
12456 : 0 : struct tls_record_test_flags flags = {
12457 : : .zero_len = 1
12458 : : };
12459 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12460 : : struct rte_cryptodev_info dev_info;
12461 : :
12462 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12463 : :
12464 : 0 : return test_tls_record_proto_all(&flags);
12465 : : }
12466 : :
12467 : : static int
12468 : 0 : test_tls_record_proto_zero_len_non_app(void)
12469 : : {
12470 : 0 : struct tls_record_test_flags flags = {
12471 : : .zero_len = 1,
12472 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12473 : : };
12474 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12475 : : struct rte_cryptodev_info dev_info;
12476 : :
12477 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12478 : :
12479 : 0 : return test_tls_record_proto_all(&flags);
12480 : : }
12481 : :
12482 : : static int
12483 : 0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12484 : : enum rte_security_tls_version tls_version)
12485 : : {
12486 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12487 : : struct rte_cryptodev_info dev_info;
12488 : 0 : struct tls_record_test_flags flags = {
12489 : : .nb_segs_in_mbuf = num_segs,
12490 : : .tls_version = tls_version,
12491 : : .opt_padding = padding
12492 : : };
12493 : :
12494 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12495 : :
12496 : 0 : return test_tls_record_proto_all(&flags);
12497 : : }
12498 : :
12499 : : static int
12500 : 0 : test_tls_record_proto_dm_opt_padding(void)
12501 : : {
12502 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12503 : : }
12504 : :
12505 : : static int
12506 : 0 : test_tls_record_proto_dm_opt_padding_1(void)
12507 : : {
12508 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12509 : : }
12510 : :
12511 : : static int
12512 : 0 : test_tls_record_proto_sg_opt_padding(void)
12513 : : {
12514 : 0 : return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12515 : : }
12516 : :
12517 : : static int
12518 : 0 : test_tls_record_proto_sg_opt_padding_1(void)
12519 : : {
12520 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12521 : : }
12522 : :
12523 : : static int
12524 : 0 : test_tls_record_proto_sg_opt_padding_2(void)
12525 : : {
12526 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12527 : : }
12528 : :
12529 : : static int
12530 : 0 : test_tls_record_proto_sg_opt_padding_max(void)
12531 : : {
12532 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12533 : : }
12534 : :
12535 : : static int
12536 : 0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
12537 : : {
12538 : 0 : struct tls_record_test_flags flags = {
12539 : : .opt_padding = 8,
12540 : : .padding_corruption = true,
12541 : : .nb_segs_in_mbuf = 4,
12542 : : };
12543 : :
12544 : 0 : return test_tls_record_proto_all(&flags);
12545 : : }
12546 : :
12547 : : static int
12548 : 0 : test_dtls_1_2_record_proto_data_walkthrough(void)
12549 : : {
12550 : : struct tls_record_test_flags flags;
12551 : :
12552 : : memset(&flags, 0, sizeof(flags));
12553 : :
12554 : 0 : flags.data_walkthrough = true;
12555 : 0 : flags.skip_sess_destroy = true;
12556 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12557 : :
12558 : 0 : return test_tls_record_proto_all(&flags);
12559 : : }
12560 : :
12561 : : static int
12562 : 0 : test_dtls_1_2_record_proto_display_list(void)
12563 : : {
12564 : : struct tls_record_test_flags flags;
12565 : :
12566 : : memset(&flags, 0, sizeof(flags));
12567 : :
12568 : 0 : flags.display_alg = true;
12569 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12570 : :
12571 : 0 : return test_tls_record_proto_all(&flags);
12572 : : }
12573 : :
12574 : : static int
12575 : 0 : test_dtls_pkt_replay(const uint64_t seq_no[],
12576 : : bool replayed_pkt[], uint32_t nb_pkts,
12577 : : struct tls_record_test_flags *flags)
12578 : : {
12579 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12580 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12581 : : unsigned int i, idx, pass_cnt = 0;
12582 : : int ret;
12583 : :
12584 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12585 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12586 : : flags, td_outb, nb_pkts, 0);
12587 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12588 : 0 : continue;
12589 : :
12590 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++)
12591 : 0 : td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12592 : :
12593 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12594 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12595 : 0 : continue;
12596 : :
12597 [ # # ]: 0 : if (ret == TEST_FAILED)
12598 : : return TEST_FAILED;
12599 : :
12600 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12601 : :
12602 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
12603 : 0 : td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12604 : : /* Set antireplay flag for packets to be dropped */
12605 : 0 : td_inb[idx].ar_packet = replayed_pkt[idx];
12606 : : }
12607 : :
12608 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12609 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12610 : 0 : continue;
12611 : :
12612 [ # # ]: 0 : if (ret == TEST_FAILED)
12613 : : return TEST_FAILED;
12614 : :
12615 [ # # ]: 0 : if (flags->display_alg)
12616 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12617 : :
12618 : 0 : pass_cnt++;
12619 : : }
12620 : :
12621 [ # # ]: 0 : if (pass_cnt > 0)
12622 : : return TEST_SUCCESS;
12623 : : else
12624 : 0 : return TEST_SKIPPED;
12625 : : }
12626 : :
12627 : : static int
12628 : 0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12629 : : {
12630 : : struct tls_record_test_flags flags;
12631 : : uint32_t nb_pkts = 5;
12632 : : bool replayed_pkt[5];
12633 : : uint64_t seq_no[5];
12634 : :
12635 : : memset(&flags, 0, sizeof(flags));
12636 : :
12637 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12638 : 0 : flags.ar_win_size = winsz;
12639 : :
12640 : : /* 1. Advance the TOP of the window to WS * 2 */
12641 : 0 : seq_no[0] = winsz * 2;
12642 : : /* 2. Test sequence number within the new window(WS + 1) */
12643 : 0 : seq_no[1] = winsz + 1;
12644 : : /* 3. Test sequence number less than the window BOTTOM */
12645 : 0 : seq_no[2] = winsz;
12646 : : /* 4. Test sequence number in the middle of the window */
12647 : 0 : seq_no[3] = winsz + (winsz / 2);
12648 : : /* 5. Test replay of the packet in the middle of the window */
12649 : 0 : seq_no[4] = winsz + (winsz / 2);
12650 : :
12651 : 0 : replayed_pkt[0] = false;
12652 : 0 : replayed_pkt[1] = false;
12653 : 0 : replayed_pkt[2] = true;
12654 : 0 : replayed_pkt[3] = false;
12655 : 0 : replayed_pkt[4] = true;
12656 : :
12657 : 0 : return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12658 : : }
12659 : :
12660 : : static int
12661 : 0 : test_dtls_1_2_record_proto_antireplay64(void)
12662 : : {
12663 : 0 : return test_dtls_1_2_record_proto_antireplay(64);
12664 : : }
12665 : :
12666 : : static int
12667 : 0 : test_dtls_1_2_record_proto_antireplay128(void)
12668 : : {
12669 : 0 : return test_dtls_1_2_record_proto_antireplay(128);
12670 : : }
12671 : :
12672 : : static int
12673 : 0 : test_dtls_1_2_record_proto_antireplay256(void)
12674 : : {
12675 : 0 : return test_dtls_1_2_record_proto_antireplay(256);
12676 : : }
12677 : :
12678 : : static int
12679 : 0 : test_dtls_1_2_record_proto_antireplay512(void)
12680 : : {
12681 : 0 : return test_dtls_1_2_record_proto_antireplay(512);
12682 : : }
12683 : :
12684 : : static int
12685 : 0 : test_dtls_1_2_record_proto_antireplay1024(void)
12686 : : {
12687 : 0 : return test_dtls_1_2_record_proto_antireplay(1024);
12688 : : }
12689 : :
12690 : : static int
12691 : 0 : test_dtls_1_2_record_proto_antireplay2048(void)
12692 : : {
12693 : 0 : return test_dtls_1_2_record_proto_antireplay(2048);
12694 : : }
12695 : :
12696 : : static int
12697 : 0 : test_dtls_1_2_record_proto_antireplay4096(void)
12698 : : {
12699 : 0 : return test_dtls_1_2_record_proto_antireplay(4096);
12700 : : }
12701 : :
12702 : : static int
12703 : 0 : test_dtls_1_2_record_proto_sgl(void)
12704 : : {
12705 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12706 : : }
12707 : :
12708 : : static int
12709 : 0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12710 : : {
12711 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12712 : : }
12713 : :
12714 : : static int
12715 : 0 : test_dtls_1_2_record_proto_sgl_oop(void)
12716 : : {
12717 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12718 : : }
12719 : :
12720 : : static int
12721 : 0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
12722 : : {
12723 : 0 : struct tls_record_test_flags flags = {
12724 : : .pkt_corruption = 1,
12725 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12726 : : };
12727 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12728 : : struct rte_cryptodev_info dev_info;
12729 : :
12730 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12731 : :
12732 : 0 : return test_tls_record_proto_all(&flags);
12733 : : }
12734 : :
12735 : : static int
12736 : 0 : test_dtls_1_2_record_proto_custom_content_type(void)
12737 : : {
12738 : 0 : struct tls_record_test_flags flags = {
12739 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12740 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12741 : : };
12742 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12743 : : struct rte_cryptodev_info dev_info;
12744 : :
12745 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12746 : :
12747 : 0 : return test_tls_record_proto_all(&flags);
12748 : : }
12749 : :
12750 : : static int
12751 : 0 : test_dtls_1_2_record_proto_zero_len(void)
12752 : : {
12753 : 0 : struct tls_record_test_flags flags = {
12754 : : .zero_len = 1,
12755 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12756 : : };
12757 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12758 : : struct rte_cryptodev_info dev_info;
12759 : :
12760 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12761 : :
12762 : 0 : return test_tls_record_proto_all(&flags);
12763 : : }
12764 : :
12765 : : static int
12766 : 0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
12767 : : {
12768 : 0 : struct tls_record_test_flags flags = {
12769 : : .zero_len = 1,
12770 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12771 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12772 : : };
12773 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12774 : : struct rte_cryptodev_info dev_info;
12775 : :
12776 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12777 : :
12778 : 0 : return test_tls_record_proto_all(&flags);
12779 : : }
12780 : :
12781 : : static int
12782 : 0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
12783 : : {
12784 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12785 : : }
12786 : :
12787 : : static int
12788 : 0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12789 : : {
12790 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12791 : : }
12792 : :
12793 : : static int
12794 : 0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
12795 : : {
12796 : 0 : return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12797 : : }
12798 : :
12799 : : static int
12800 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12801 : : {
12802 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12803 : : }
12804 : :
12805 : : static int
12806 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12807 : : {
12808 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12809 : : }
12810 : :
12811 : : static int
12812 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12813 : : {
12814 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12815 : : }
12816 : :
12817 : : static int
12818 : 0 : test_tls_1_3_record_proto_display_list(void)
12819 : : {
12820 : : struct tls_record_test_flags flags;
12821 : :
12822 : : memset(&flags, 0, sizeof(flags));
12823 : :
12824 : 0 : flags.display_alg = true;
12825 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12826 : :
12827 : 0 : return test_tls_record_proto_all(&flags);
12828 : : }
12829 : :
12830 : : static int
12831 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12832 : : {
12833 : 0 : struct tls_record_test_flags flags = {
12834 : : .opt_padding = 8,
12835 : : .padding_corruption = true,
12836 : : .nb_segs_in_mbuf = 4,
12837 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12838 : : };
12839 : :
12840 : 0 : return test_tls_record_proto_all(&flags);
12841 : : }
12842 : :
12843 : : static int
12844 : 0 : test_tls_1_3_record_proto_corrupt_pkt(void)
12845 : : {
12846 : 0 : struct tls_record_test_flags flags = {
12847 : : .pkt_corruption = 1,
12848 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12849 : : };
12850 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12851 : : struct rte_cryptodev_info dev_info;
12852 : :
12853 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12854 : :
12855 : 0 : return test_tls_record_proto_all(&flags);
12856 : : }
12857 : :
12858 : : static int
12859 : 0 : test_tls_1_3_record_proto_custom_content_type(void)
12860 : : {
12861 : 0 : struct tls_record_test_flags flags = {
12862 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12863 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12864 : : };
12865 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12866 : : struct rte_cryptodev_info dev_info;
12867 : :
12868 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12869 : :
12870 : 0 : return test_tls_record_proto_all(&flags);
12871 : : }
12872 : :
12873 : : static int
12874 : 0 : test_tls_1_3_record_proto_zero_len(void)
12875 : : {
12876 : 0 : struct tls_record_test_flags flags = {
12877 : : .zero_len = 1,
12878 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12879 : : };
12880 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12881 : : struct rte_cryptodev_info dev_info;
12882 : :
12883 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12884 : :
12885 : 0 : return test_tls_record_proto_all(&flags);
12886 : : }
12887 : :
12888 : : static int
12889 : 0 : test_tls_1_3_record_proto_zero_len_non_app(void)
12890 : : {
12891 : 0 : struct tls_record_test_flags flags = {
12892 : : .zero_len = 1,
12893 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12894 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12895 : : };
12896 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12897 : : struct rte_cryptodev_info dev_info;
12898 : :
12899 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12900 : :
12901 : 0 : return test_tls_record_proto_all(&flags);
12902 : : }
12903 : :
12904 : : static int
12905 : 0 : test_tls_1_3_record_proto_dm_opt_padding(void)
12906 : : {
12907 : 0 : return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12908 : : }
12909 : :
12910 : : static int
12911 : 0 : test_tls_1_3_record_proto_sg_opt_padding(void)
12912 : : {
12913 : 0 : return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12914 : : }
12915 : :
12916 : : static int
12917 : 0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
12918 : : {
12919 : 0 : return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12920 : : }
12921 : :
12922 : : static int
12923 : 0 : test_tls_1_3_record_proto_data_walkthrough(void)
12924 : : {
12925 : : struct tls_record_test_flags flags;
12926 : :
12927 : : memset(&flags, 0, sizeof(flags));
12928 : :
12929 : 0 : flags.data_walkthrough = true;
12930 : 0 : flags.skip_sess_destroy = true;
12931 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12932 : :
12933 : 0 : return test_tls_record_proto_all(&flags);
12934 : : }
12935 : :
12936 : : static int
12937 : 0 : test_tls_1_3_record_proto_sgl(void)
12938 : : {
12939 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
12940 : : }
12941 : :
12942 : : static int
12943 : 0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
12944 : : {
12945 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
12946 : : }
12947 : :
12948 : : static int
12949 : 0 : test_tls_1_3_record_proto_sgl_oop(void)
12950 : : {
12951 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
12952 : : }
12953 : :
12954 : : #endif
12955 : :
12956 : : static int
12957 : 1 : test_cryptodev_error_recover_helper_check(void)
12958 : : {
12959 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12960 : : struct rte_cryptodev_info dev_info;
12961 : : uint64_t feat_flags;
12962 : : int ret;
12963 : :
12964 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12965 : 1 : feat_flags = dev_info.feature_flags;
12966 : :
12967 : : /* Skip the test if queue pair reset is not supported */
12968 : 1 : ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
12969 [ - + ]: 1 : if (ret == -ENOTSUP)
12970 : : return TEST_SKIPPED;
12971 : :
12972 [ # # ]: 0 : ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
12973 [ # # ]: 0 : if (ret == -ENOTSUP)
12974 : 0 : return TEST_SKIPPED;
12975 : :
12976 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
12977 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12978 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12979 : 0 : RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
12980 : 0 : return TEST_SKIPPED;
12981 : : }
12982 : :
12983 : : return 0;
12984 : : }
12985 : :
12986 : : static int
12987 : 0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
12988 : : {
12989 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12990 : : struct crypto_unittest_params *ut_params = &unittest_params;
12991 : : const struct blockcipher_test_data *tdata = test_data;
12992 : 0 : uint8_t *cipher_key = alloca(tdata->cipher_key.len);
12993 : : struct rte_crypto_sym_op *sym_op = NULL;
12994 : : struct rte_crypto_op *op = NULL;
12995 : : char *dst;
12996 : :
12997 : 0 : memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
12998 : 0 : ut_params->cipher_xform.next = NULL;
12999 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13000 : 0 : ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
13001 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13002 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
13003 : 0 : ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
13004 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13005 : 0 : ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
13006 : :
13007 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
13008 : : ts_params->session_mpool);
13009 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13010 : : return TEST_SKIPPED;
13011 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13012 : :
13013 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13014 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
13015 : :
13016 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
13017 [ # # ]: 0 : tdata->iv.len);
13018 : : sym_op = ut_params->op->sym;
13019 : 0 : sym_op->cipher.data.offset = tdata->cipher_offset;
13020 : 0 : sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
13021 : :
13022 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13023 : :
13024 [ # # ]: 0 : if (generate_err) {
13025 : 0 : ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
13026 [ # # ]: 0 : if (ut_params->ibuf == NULL)
13027 : : return TEST_FAILED;
13028 : 0 : crypto_err = CRYPTODEV_ERR_TRIGGERED;
13029 : : } else {
13030 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13031 : : }
13032 : :
13033 : : /* clear mbuf payload */
13034 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13035 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
13036 : :
13037 : 0 : dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
13038 : 0 : memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
13039 : :
13040 : 0 : sym_op->m_src = ut_params->ibuf;
13041 : 0 : sym_op->m_dst = NULL;
13042 : :
13043 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
13044 : :
13045 [ # # ]: 0 : if (generate_err) {
13046 : 0 : free(ut_params->ibuf);
13047 : 0 : ut_params->ibuf = NULL;
13048 [ # # ]: 0 : if (op == NULL) {
13049 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13050 : 0 : ut_params->sess = NULL;
13051 : 0 : return TEST_SUCCESS;
13052 : : } else {
13053 : : return TEST_FAILED;
13054 : : }
13055 : : }
13056 : :
13057 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13058 : : "crypto op processing failed");
13059 : :
13060 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
13061 : : tdata->ciphertext.len - tdata->cipher_offset,
13062 : : "Data not as expected");
13063 : :
13064 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13065 : 0 : ut_params->sess = NULL;
13066 : :
13067 : 0 : return TEST_SUCCESS;
13068 : : }
13069 : :
13070 : : /*
13071 : : * This unit test verifies the recovery of the cryptodev from any fatal error.
13072 : : * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
13073 : : * for every call to helper function.
13074 : : *
13075 : : * When the flag is set to 0, the helper function verifies the test data without generating any
13076 : : * errors, i.e: verifies the default behaviour of the cryptodev.
13077 : : *
13078 : : * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
13079 : : * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
13080 : : * is generated, it waits till the cryptodev is recoverd from the error.
13081 : : *
13082 : : * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
13083 : : * of cryptodev after the recovery.
13084 : : */
13085 : : static int
13086 : 1 : test_cryptodev_verify_error_recover(const void *test_data)
13087 : : {
13088 : : int ret = TEST_FAILED;
13089 : : int i, num_itr = 5;
13090 : :
13091 : 1 : ret = test_cryptodev_error_recover_helper_check();
13092 [ - + ]: 1 : if (ret)
13093 : : return ret;
13094 : :
13095 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
13096 : : RTE_CRYPTODEV_EVENT_ERROR,
13097 : : test_cryptodev_error_cb, NULL),
13098 : : "Failed to register Cryptodev callback");
13099 : :
13100 [ # # ]: 0 : for (i = 0; i < num_itr; i++) {
13101 : : int ticks = 0;
13102 : :
13103 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13104 : : test_data, false);
13105 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13106 : :
13107 : : /* Generate Error */
13108 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13109 : : test_data, true);
13110 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13111 : :
13112 : : /* Wait till cryptodev recovered from error */
13113 [ # # ]: 0 : while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
13114 : : rte_delay_ms(10);
13115 [ # # ]: 0 : if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
13116 : : return TEST_FAILED;
13117 : : }
13118 : : }
13119 [ # # ]: 0 : TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
13120 : :
13121 : : return ret;
13122 : : }
13123 : :
13124 : : static int
13125 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
13126 : : {
13127 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
13128 : : }
13129 : :
13130 : : static int
13131 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
13132 : : {
13133 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
13134 : : }
13135 : :
13136 : : static int
13137 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
13138 : : {
13139 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
13140 : : }
13141 : :
13142 : : static int
13143 : 1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
13144 : : {
13145 : 1 : return test_authenticated_encryption_helper(&gcm_test_case_3, true);
13146 : : }
13147 : :
13148 : : static int
13149 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
13150 : : {
13151 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
13152 : : }
13153 : :
13154 : : static int
13155 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
13156 : : {
13157 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
13158 : : }
13159 : :
13160 : : static int
13161 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
13162 : : {
13163 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
13164 : : }
13165 : :
13166 : : static int
13167 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
13168 : : {
13169 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
13170 : : }
13171 : :
13172 : : static int
13173 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
13174 : : {
13175 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
13176 : : }
13177 : :
13178 : : static int
13179 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
13180 : : {
13181 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
13182 : : }
13183 : :
13184 : : static int
13185 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
13186 : : {
13187 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
13188 : : }
13189 : :
13190 : : static int
13191 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
13192 : : {
13193 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
13194 : : }
13195 : :
13196 : : static int
13197 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
13198 : : {
13199 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
13200 : : }
13201 : :
13202 : : static int
13203 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
13204 : : {
13205 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
13206 : : }
13207 : :
13208 : : static int
13209 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
13210 : : {
13211 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
13212 : : }
13213 : :
13214 : : static int
13215 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
13216 : : {
13217 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
13218 : : }
13219 : :
13220 : : static int
13221 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
13222 : : {
13223 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
13224 : : }
13225 : :
13226 : : static int
13227 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
13228 : : {
13229 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
13230 : : }
13231 : :
13232 : : static int
13233 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
13234 : : {
13235 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
13236 : : }
13237 : :
13238 : : static int
13239 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
13240 : : {
13241 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
13242 : : }
13243 : :
13244 : : static int
13245 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
13246 : : {
13247 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
13248 : : }
13249 : :
13250 : : static int
13251 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
13252 : : {
13253 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
13254 : : }
13255 : :
13256 : : static int
13257 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
13258 : : {
13259 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
13260 : : }
13261 : :
13262 : : static int
13263 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
13264 : : {
13265 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
13266 : : }
13267 : :
13268 : : static int
13269 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
13270 : : {
13271 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
13272 : : }
13273 : :
13274 : : static int
13275 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
13276 : : {
13277 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
13278 : : }
13279 : :
13280 : : static int
13281 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13282 : : {
13283 : : struct aead_test_data tdata;
13284 : : int res;
13285 : :
13286 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13287 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13288 : 1 : tdata.iv.data[0] += 1;
13289 : : res = test_authenticated_encryption(&tdata);
13290 [ + - ]: 1 : if (res == TEST_SKIPPED)
13291 : : return res;
13292 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13293 : : return TEST_SUCCESS;
13294 : : }
13295 : :
13296 : : static int
13297 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13298 : : {
13299 : : struct aead_test_data tdata;
13300 : : int res;
13301 : :
13302 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13303 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13304 : 1 : tdata.plaintext.data[0] += 1;
13305 : : res = test_authenticated_encryption(&tdata);
13306 [ + - ]: 1 : if (res == TEST_SKIPPED)
13307 : : return res;
13308 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13309 : : return TEST_SUCCESS;
13310 : : }
13311 : :
13312 : : static int
13313 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13314 : : {
13315 : : struct aead_test_data tdata;
13316 : : int res;
13317 : :
13318 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13319 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13320 : 1 : tdata.ciphertext.data[0] += 1;
13321 : : res = test_authenticated_encryption(&tdata);
13322 [ + - ]: 1 : if (res == TEST_SKIPPED)
13323 : : return res;
13324 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13325 : : return TEST_SUCCESS;
13326 : : }
13327 : :
13328 : : static int
13329 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13330 : : {
13331 : : struct aead_test_data tdata;
13332 : : int res;
13333 : :
13334 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13335 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13336 : 1 : tdata.aad.len += 1;
13337 : : res = test_authenticated_encryption(&tdata);
13338 [ + - ]: 1 : if (res == TEST_SKIPPED)
13339 : : return res;
13340 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13341 : : return TEST_SUCCESS;
13342 : : }
13343 : :
13344 : : static int
13345 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13346 : : {
13347 : : struct aead_test_data tdata;
13348 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13349 : : int res;
13350 : :
13351 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13352 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13353 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13354 : 1 : aad[0] += 1;
13355 : 1 : tdata.aad.data = aad;
13356 : : res = test_authenticated_encryption(&tdata);
13357 [ + - ]: 1 : if (res == TEST_SKIPPED)
13358 : : return res;
13359 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13360 : : return TEST_SUCCESS;
13361 : : }
13362 : :
13363 : : static int
13364 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13365 : : {
13366 : : struct aead_test_data tdata;
13367 : : int res;
13368 : :
13369 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13370 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13371 : 1 : tdata.auth_tag.data[0] += 1;
13372 : : res = test_authenticated_encryption(&tdata);
13373 [ + - ]: 1 : if (res == TEST_SKIPPED)
13374 : : return res;
13375 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13376 : : return TEST_SUCCESS;
13377 : : }
13378 : :
13379 : : static int
13380 : 42 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13381 : : {
13382 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13383 : : struct crypto_unittest_params *ut_params = &unittest_params;
13384 : :
13385 : : int retval;
13386 : : uint8_t *plaintext;
13387 : : uint32_t i;
13388 : : struct rte_cryptodev_info dev_info;
13389 : :
13390 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13391 : 42 : uint64_t feat_flags = dev_info.feature_flags;
13392 : :
13393 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13394 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13395 : : printf("Device doesn't support RAW data-path APIs.\n");
13396 : 0 : return TEST_SKIPPED;
13397 : : }
13398 : :
13399 : : /* Verify the capabilities */
13400 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13401 : : const struct rte_cryptodev_symmetric_capability *capability;
13402 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13403 : 42 : cap_idx.algo.aead = tdata->algo;
13404 : 42 : capability = rte_cryptodev_sym_capability_get(
13405 : 42 : ts_params->valid_devs[0], &cap_idx);
13406 [ + - ]: 42 : if (capability == NULL)
13407 : : return TEST_SKIPPED;
13408 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
13409 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
13410 : 42 : tdata->aad.len, tdata->iv.len))
13411 : : return TEST_SKIPPED;
13412 : :
13413 : : /* Create AEAD session */
13414 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
13415 : 41 : tdata->algo,
13416 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13417 : 41 : tdata->key.data, tdata->key.len,
13418 : 41 : tdata->aad.len, tdata->auth_tag.len,
13419 : 41 : tdata->iv.len);
13420 [ + - ]: 41 : if (retval != TEST_SUCCESS)
13421 : : return retval;
13422 : :
13423 : : /* alloc mbuf and set payload */
13424 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
13425 [ - + ]: 2 : if (use_ext_mbuf) {
13426 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13427 : : AEAD_TEXT_MAX_LENGTH,
13428 : : 1 /* nb_segs */,
13429 : : NULL);
13430 : : } else {
13431 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13432 : : }
13433 : : /* Populate full size of add data */
13434 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13435 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13436 : : } else {
13437 [ + + ]: 39 : if (use_ext_mbuf) {
13438 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13439 : : AEAD_TEXT_MAX_LENGTH,
13440 : : 1 /* nb_segs */,
13441 : : NULL);
13442 : : } else {
13443 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13444 : : }
13445 : : }
13446 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13447 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
13448 : :
13449 : : /* Create AEAD operation */
13450 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13451 [ + - ]: 41 : if (retval < 0)
13452 : : return retval;
13453 : :
13454 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13455 : :
13456 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
13457 : :
13458 : : /* Process crypto operation */
13459 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13460 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13461 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13462 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13463 : : 0);
13464 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13465 : : return retval;
13466 : : } else
13467 [ + + ]: 41 : TEST_ASSERT_NOT_NULL(
13468 : : process_crypto_request(ts_params->valid_devs[0],
13469 : : ut_params->op), "failed to process sym crypto op");
13470 : :
13471 [ - + ]: 36 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13472 : : "crypto op processing failed");
13473 : :
13474 [ - + ]: 36 : if (ut_params->op->sym->m_dst)
13475 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13476 : : uint8_t *);
13477 : : else
13478 : 36 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13479 : : uint8_t *,
13480 : : ut_params->op->sym->cipher.data.offset);
13481 : :
13482 : 36 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13483 : :
13484 : : /* Validate obuf */
13485 [ + + ]: 37 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13486 : : plaintext,
13487 : : tdata->plaintext.data,
13488 : : tdata->plaintext.len,
13489 : : "Plaintext data not as expected");
13490 : :
13491 [ - + ]: 35 : TEST_ASSERT_EQUAL(ut_params->op->status,
13492 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13493 : : "Authentication failed");
13494 : :
13495 : : return 0;
13496 : : }
13497 : :
13498 : : static int
13499 : : test_authenticated_decryption(const struct aead_test_data *tdata)
13500 : : {
13501 : 41 : return test_authenticated_decryption_helper(tdata, false);
13502 : : }
13503 : :
13504 : : static int
13505 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
13506 : : {
13507 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
13508 : : }
13509 : :
13510 : : static int
13511 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
13512 : : {
13513 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
13514 : : }
13515 : :
13516 : : static int
13517 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
13518 : : {
13519 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
13520 : : }
13521 : :
13522 : : static int
13523 : 1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13524 : : {
13525 : 1 : return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13526 : : }
13527 : :
13528 : : static int
13529 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
13530 : : {
13531 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
13532 : : }
13533 : :
13534 : : static int
13535 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
13536 : : {
13537 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
13538 : : }
13539 : :
13540 : : static int
13541 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
13542 : : {
13543 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
13544 : : }
13545 : :
13546 : : static int
13547 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
13548 : : {
13549 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
13550 : : }
13551 : :
13552 : : static int
13553 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
13554 : : {
13555 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
13556 : : }
13557 : :
13558 : : static int
13559 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13560 : : {
13561 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
13562 : : }
13563 : :
13564 : : static int
13565 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
13566 : : {
13567 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
13568 : : }
13569 : :
13570 : : static int
13571 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
13572 : : {
13573 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
13574 : : }
13575 : :
13576 : : static int
13577 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
13578 : : {
13579 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
13580 : : }
13581 : :
13582 : : static int
13583 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
13584 : : {
13585 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
13586 : : }
13587 : :
13588 : : static int
13589 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
13590 : : {
13591 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
13592 : : }
13593 : :
13594 : : static int
13595 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
13596 : : {
13597 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
13598 : : }
13599 : :
13600 : : static int
13601 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
13602 : : {
13603 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
13604 : : }
13605 : :
13606 : : static int
13607 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
13608 : : {
13609 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
13610 : : }
13611 : :
13612 : : static int
13613 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
13614 : : {
13615 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
13616 : : }
13617 : :
13618 : : static int
13619 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
13620 : : {
13621 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
13622 : : }
13623 : :
13624 : : static int
13625 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
13626 : : {
13627 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
13628 : : }
13629 : :
13630 : : static int
13631 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
13632 : : {
13633 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
13634 : : }
13635 : :
13636 : : static int
13637 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
13638 : : {
13639 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
13640 : : }
13641 : :
13642 : : static int
13643 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
13644 : : {
13645 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
13646 : : }
13647 : :
13648 : : static int
13649 : 1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
13650 : : {
13651 : 1 : return test_authenticated_decryption(&gcm_test_case_256_8);
13652 : : }
13653 : :
13654 : : static int
13655 : 1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
13656 : : {
13657 : 1 : return test_authenticated_encryption(&gcm_test_case_256_8);
13658 : : }
13659 : :
13660 : : static int
13661 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
13662 : : {
13663 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
13664 : : }
13665 : :
13666 : : static int
13667 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
13668 : : {
13669 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
13670 : : }
13671 : :
13672 : : static int
13673 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13674 : : {
13675 : : struct aead_test_data tdata;
13676 : : int res;
13677 : :
13678 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13679 : 1 : tdata.iv.data[0] += 1;
13680 : : res = test_authenticated_decryption(&tdata);
13681 [ + - ]: 1 : if (res == TEST_SKIPPED)
13682 : : return res;
13683 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13684 : : return TEST_SUCCESS;
13685 : : }
13686 : :
13687 : : static int
13688 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13689 : : {
13690 : : struct aead_test_data tdata;
13691 : : int res;
13692 : :
13693 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13694 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13695 : 1 : tdata.plaintext.data[0] += 1;
13696 : : res = test_authenticated_decryption(&tdata);
13697 [ + - ]: 1 : if (res == TEST_SKIPPED)
13698 : : return res;
13699 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13700 : : return TEST_SUCCESS;
13701 : : }
13702 : :
13703 : : static int
13704 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13705 : : {
13706 : : struct aead_test_data tdata;
13707 : : int res;
13708 : :
13709 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13710 : 1 : tdata.ciphertext.data[0] += 1;
13711 : : res = test_authenticated_decryption(&tdata);
13712 [ + - ]: 1 : if (res == TEST_SKIPPED)
13713 : : return res;
13714 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13715 : : return TEST_SUCCESS;
13716 : : }
13717 : :
13718 : : static int
13719 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13720 : : {
13721 : : struct aead_test_data tdata;
13722 : : int res;
13723 : :
13724 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13725 : 1 : tdata.aad.len += 1;
13726 : : res = test_authenticated_decryption(&tdata);
13727 [ + - ]: 1 : if (res == TEST_SKIPPED)
13728 : : return res;
13729 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13730 : : return TEST_SUCCESS;
13731 : : }
13732 : :
13733 : : static int
13734 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13735 : : {
13736 : : struct aead_test_data tdata;
13737 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13738 : : int res;
13739 : :
13740 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13741 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13742 : 1 : aad[0] += 1;
13743 : 1 : tdata.aad.data = aad;
13744 : : res = test_authenticated_decryption(&tdata);
13745 [ + - ]: 1 : if (res == TEST_SKIPPED)
13746 : : return res;
13747 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13748 : : return TEST_SUCCESS;
13749 : : }
13750 : :
13751 : : static int
13752 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13753 : : {
13754 : : struct aead_test_data tdata;
13755 : : int res;
13756 : :
13757 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13758 : 1 : tdata.auth_tag.data[0] += 1;
13759 : : res = test_authenticated_decryption(&tdata);
13760 [ + - ]: 1 : if (res == TEST_SKIPPED)
13761 : : return res;
13762 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13763 : : return TEST_SUCCESS;
13764 : : }
13765 : :
13766 : : static int
13767 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13768 : : {
13769 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13770 : : struct crypto_unittest_params *ut_params = &unittest_params;
13771 : :
13772 : : int retval;
13773 : : uint8_t *ciphertext, *auth_tag;
13774 : : uint16_t plaintext_pad_len;
13775 : : struct rte_cryptodev_info dev_info;
13776 : :
13777 : : /* Verify the capabilities */
13778 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13779 : : const struct rte_cryptodev_symmetric_capability *capability;
13780 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13781 : 1 : cap_idx.algo.aead = tdata->algo;
13782 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13783 [ + - ]: 1 : if (capability == NULL)
13784 : : return TEST_SKIPPED;
13785 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(
13786 : 1 : capability, tdata->key.len, tdata->auth_tag.len,
13787 : 1 : tdata->aad.len, tdata->iv.len))
13788 : : return TEST_SKIPPED;
13789 : :
13790 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13791 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13792 : :
13793 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13794 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13795 : : return TEST_SKIPPED;
13796 : :
13797 : : /* not supported with CPU crypto */
13798 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13799 : : return TEST_SKIPPED;
13800 : :
13801 : : /* Create AEAD session */
13802 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13803 : 1 : tdata->algo,
13804 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13805 : 1 : tdata->key.data, tdata->key.len,
13806 : 1 : tdata->aad.len, tdata->auth_tag.len,
13807 : 1 : tdata->iv.len);
13808 [ + - ]: 1 : if (retval < 0)
13809 : : return retval;
13810 : :
13811 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13812 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13813 : :
13814 : : /* clear mbuf payload */
13815 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13816 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13817 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13818 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13819 : :
13820 : : /* Create AEAD operation */
13821 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13822 [ + - ]: 1 : if (retval < 0)
13823 : : return retval;
13824 : :
13825 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13826 : :
13827 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13828 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13829 : :
13830 : : /* Process crypto operation */
13831 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13832 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13833 : : 0);
13834 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13835 : : return retval;
13836 : : } else
13837 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13838 : : ut_params->op), "failed to process sym crypto op");
13839 : :
13840 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13841 : : "crypto op processing failed");
13842 : :
13843 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13844 : :
13845 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13846 : : ut_params->op->sym->cipher.data.offset);
13847 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13848 : :
13849 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13850 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13851 : :
13852 : : /* Validate obuf */
13853 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13854 : : ciphertext,
13855 : : tdata->ciphertext.data,
13856 : : tdata->ciphertext.len,
13857 : : "Ciphertext data not as expected");
13858 : :
13859 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13860 : : auth_tag,
13861 : : tdata->auth_tag.data,
13862 : : tdata->auth_tag.len,
13863 : : "Generated auth tag not as expected");
13864 : :
13865 : : return 0;
13866 : :
13867 : : }
13868 : :
13869 : : static int
13870 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13871 : : {
13872 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
13873 : : }
13874 : :
13875 : : static int
13876 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13877 : : {
13878 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13879 : : struct crypto_unittest_params *ut_params = &unittest_params;
13880 : :
13881 : : int retval;
13882 : : uint8_t *plaintext;
13883 : : struct rte_cryptodev_info dev_info;
13884 : :
13885 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13886 : : uint64_t feat_flags = dev_info.feature_flags;
13887 : :
13888 : : /* Verify the capabilities */
13889 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13890 : : const struct rte_cryptodev_symmetric_capability *capability;
13891 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13892 : 1 : cap_idx.algo.aead = tdata->algo;
13893 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13894 : :
13895 [ + - ]: 1 : if (capability == NULL)
13896 : : return TEST_SKIPPED;
13897 : :
13898 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13899 : 1 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13900 : : return TEST_SKIPPED;
13901 : :
13902 : : /* not supported with CPU crypto and raw data-path APIs*/
13903 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13904 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
13905 : : return TEST_SKIPPED;
13906 : :
13907 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13908 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13909 : : printf("Device does not support RAW data-path APIs.\n");
13910 : : return TEST_SKIPPED;
13911 : : }
13912 : :
13913 : : /* Create AEAD session */
13914 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13915 : 1 : tdata->algo,
13916 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13917 : 1 : tdata->key.data, tdata->key.len,
13918 : 1 : tdata->aad.len, tdata->auth_tag.len,
13919 : 1 : tdata->iv.len);
13920 [ + - ]: 1 : if (retval < 0)
13921 : : return retval;
13922 : :
13923 : : /* alloc mbuf and set payload */
13924 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13925 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13926 : :
13927 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13928 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13929 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13930 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13931 : :
13932 : : /* Create AEAD operation */
13933 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13934 [ + - ]: 1 : if (retval < 0)
13935 : : return retval;
13936 : :
13937 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13938 : :
13939 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13940 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13941 : :
13942 : : /* Process crypto operation */
13943 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13944 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13945 : : 0);
13946 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13947 : : return retval;
13948 : : } else
13949 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13950 : : ut_params->op), "failed to process sym crypto op");
13951 : :
13952 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13953 : : "crypto op processing failed");
13954 : :
13955 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13956 : : ut_params->op->sym->cipher.data.offset);
13957 : :
13958 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13959 : :
13960 : : /* Validate obuf */
13961 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13962 : : plaintext,
13963 : : tdata->plaintext.data,
13964 : : tdata->plaintext.len,
13965 : : "Plaintext data not as expected");
13966 : :
13967 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
13968 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13969 : : "Authentication failed");
13970 : : return 0;
13971 : : }
13972 : :
13973 : : static int
13974 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
13975 : : {
13976 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
13977 : : }
13978 : :
13979 : : static int
13980 : 1 : test_authenticated_encryption_sessionless(
13981 : : const struct aead_test_data *tdata)
13982 : : {
13983 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13984 : : struct crypto_unittest_params *ut_params = &unittest_params;
13985 : :
13986 : : int retval;
13987 : : uint8_t *ciphertext, *auth_tag;
13988 : : uint16_t plaintext_pad_len;
13989 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
13990 : : struct rte_cryptodev_info dev_info;
13991 : :
13992 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13993 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13994 : :
13995 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13996 : : printf("Device doesn't support Sessionless ops.\n");
13997 : 0 : return TEST_SKIPPED;
13998 : : }
13999 : :
14000 : : /* not supported with CPU crypto */
14001 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14002 : : return TEST_SKIPPED;
14003 : :
14004 : : /* Verify the capabilities */
14005 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14006 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14007 : 1 : cap_idx.algo.aead = tdata->algo;
14008 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14009 : : &cap_idx) == NULL)
14010 : : return TEST_SKIPPED;
14011 : :
14012 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14013 : :
14014 : : /* clear mbuf payload */
14015 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14016 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14017 : :
14018 : : /* Create AEAD operation */
14019 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
14020 [ + - ]: 1 : if (retval < 0)
14021 : : return retval;
14022 : :
14023 : : /* Create GCM xform */
14024 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14025 : 1 : retval = create_aead_xform(ut_params->op,
14026 : 1 : tdata->algo,
14027 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
14028 : : key, tdata->key.len,
14029 : 1 : tdata->aad.len, tdata->auth_tag.len,
14030 : 1 : tdata->iv.len);
14031 [ + - ]: 1 : if (retval < 0)
14032 : : return retval;
14033 : :
14034 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14035 : :
14036 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14037 : : RTE_CRYPTO_OP_SESSIONLESS,
14038 : : "crypto op session type not sessionless");
14039 : :
14040 : : /* Process crypto operation */
14041 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14042 : : ut_params->op), "failed to process sym crypto op");
14043 : :
14044 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14045 : :
14046 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14047 : : "crypto op status not success");
14048 : :
14049 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14050 : :
14051 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14052 : : ut_params->op->sym->cipher.data.offset);
14053 : 1 : auth_tag = ciphertext + plaintext_pad_len;
14054 : :
14055 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
14056 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
14057 : :
14058 : : /* Validate obuf */
14059 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14060 : : ciphertext,
14061 : : tdata->ciphertext.data,
14062 : : tdata->ciphertext.len,
14063 : : "Ciphertext data not as expected");
14064 : :
14065 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14066 : : auth_tag,
14067 : : tdata->auth_tag.data,
14068 : : tdata->auth_tag.len,
14069 : : "Generated auth tag not as expected");
14070 : :
14071 : : return 0;
14072 : :
14073 : : }
14074 : :
14075 : : static int
14076 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
14077 : : {
14078 : 1 : return test_authenticated_encryption_sessionless(
14079 : : &gcm_test_case_5);
14080 : : }
14081 : :
14082 : : static int
14083 : 1 : test_authenticated_decryption_sessionless(
14084 : : const struct aead_test_data *tdata)
14085 : : {
14086 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14087 : : struct crypto_unittest_params *ut_params = &unittest_params;
14088 : :
14089 : : int retval;
14090 : : uint8_t *plaintext;
14091 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14092 : : struct rte_cryptodev_info dev_info;
14093 : :
14094 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14095 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14096 : :
14097 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14098 : : printf("Device doesn't support Sessionless ops.\n");
14099 : 0 : return TEST_SKIPPED;
14100 : : }
14101 : :
14102 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14103 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14104 : : printf("Device doesn't support RAW data-path APIs.\n");
14105 : 0 : return TEST_SKIPPED;
14106 : : }
14107 : :
14108 : : /* not supported with CPU crypto */
14109 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14110 : : return TEST_SKIPPED;
14111 : :
14112 : : /* Verify the capabilities */
14113 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14114 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14115 : 1 : cap_idx.algo.aead = tdata->algo;
14116 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14117 : : &cap_idx) == NULL)
14118 : : return TEST_SKIPPED;
14119 : :
14120 : : /* alloc mbuf and set payload */
14121 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14122 : :
14123 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14124 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14125 : :
14126 : : /* Create AEAD operation */
14127 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14128 [ + - ]: 1 : if (retval < 0)
14129 : : return retval;
14130 : :
14131 : : /* Create AEAD xform */
14132 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14133 : 1 : retval = create_aead_xform(ut_params->op,
14134 : 1 : tdata->algo,
14135 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
14136 : : key, tdata->key.len,
14137 : 1 : tdata->aad.len, tdata->auth_tag.len,
14138 : 1 : tdata->iv.len);
14139 [ + - ]: 1 : if (retval < 0)
14140 : : return retval;
14141 : :
14142 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14143 : :
14144 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14145 : : RTE_CRYPTO_OP_SESSIONLESS,
14146 : : "crypto op session type not sessionless");
14147 : :
14148 : : /* Process crypto operation */
14149 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14150 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14151 : : 0);
14152 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14153 : : return retval;
14154 : : } else
14155 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
14156 : : ts_params->valid_devs[0], ut_params->op),
14157 : : "failed to process sym crypto op");
14158 : :
14159 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14160 : :
14161 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14162 : : "crypto op status not success");
14163 : :
14164 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14165 : : ut_params->op->sym->cipher.data.offset);
14166 : :
14167 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14168 : :
14169 : : /* Validate obuf */
14170 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14171 : : plaintext,
14172 : : tdata->plaintext.data,
14173 : : tdata->plaintext.len,
14174 : : "Plaintext data not as expected");
14175 : :
14176 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14177 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14178 : : "Authentication failed");
14179 : : return 0;
14180 : : }
14181 : :
14182 : : static int
14183 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
14184 : : {
14185 : 1 : return test_authenticated_decryption_sessionless(
14186 : : &gcm_test_case_5);
14187 : : }
14188 : :
14189 : : static int
14190 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
14191 : : {
14192 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
14193 : : }
14194 : :
14195 : : static int
14196 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
14197 : : {
14198 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
14199 : : }
14200 : :
14201 : : static int
14202 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
14203 : : {
14204 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
14205 : : }
14206 : :
14207 : : static int
14208 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
14209 : : {
14210 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
14211 : : }
14212 : :
14213 : : static int
14214 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
14215 : : {
14216 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
14217 : : }
14218 : :
14219 : : static int
14220 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
14221 : : {
14222 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
14223 : : }
14224 : :
14225 : : static int
14226 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
14227 : : {
14228 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
14229 : : }
14230 : :
14231 : : static int
14232 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
14233 : : {
14234 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
14235 : : }
14236 : :
14237 : : static int
14238 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
14239 : : {
14240 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
14241 : : }
14242 : :
14243 : : static int
14244 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
14245 : : {
14246 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
14247 : : }
14248 : :
14249 : : static int
14250 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
14251 : : {
14252 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
14253 : : }
14254 : :
14255 : : static int
14256 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14257 : : {
14258 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
14259 : : }
14260 : :
14261 : : static int
14262 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14263 : : {
14264 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
14265 : : }
14266 : :
14267 : : static int
14268 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14269 : : {
14270 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
14271 : : }
14272 : :
14273 : : static int
14274 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14275 : : {
14276 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
14277 : : }
14278 : :
14279 : : static int
14280 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14281 : : {
14282 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
14283 : : }
14284 : :
14285 : : static int
14286 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14287 : : {
14288 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
14289 : : }
14290 : :
14291 : : static int
14292 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14293 : : {
14294 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
14295 : : }
14296 : :
14297 : : static int
14298 : 1 : test_stats(void)
14299 : : {
14300 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14301 : : struct rte_cryptodev_stats stats;
14302 : :
14303 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14304 : : return TEST_SKIPPED;
14305 : :
14306 : : /* Verify the capabilities */
14307 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14308 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14309 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14310 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14311 : : &cap_idx) == NULL)
14312 : : return TEST_SKIPPED;
14313 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14314 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14315 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14316 : : &cap_idx) == NULL)
14317 : : return TEST_SKIPPED;
14318 : :
14319 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14320 : : == -ENOTSUP)
14321 : : return TEST_SKIPPED;
14322 : :
14323 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14324 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14325 : : &stats) == -ENODEV),
14326 : : "rte_cryptodev_stats_get invalid dev failed");
14327 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14328 : : "rte_cryptodev_stats_get invalid Param failed");
14329 : :
14330 : : /* Test expected values */
14331 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
14332 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14333 : : &stats),
14334 : : "rte_cryptodev_stats_get failed");
14335 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14336 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
14337 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
14338 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
14339 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
14340 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14341 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
14342 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14343 : :
14344 : : /* invalid device but should ignore and not reset device stats*/
14345 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14346 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14347 : : &stats),
14348 : : "rte_cryptodev_stats_get failed");
14349 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14350 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14351 : :
14352 : : /* check that a valid reset clears stats */
14353 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14354 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14355 : : &stats),
14356 : : "rte_cryptodev_stats_get failed");
14357 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
14358 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14359 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
14360 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14361 : :
14362 : : return TEST_SUCCESS;
14363 : : }
14364 : :
14365 : : static int
14366 : 1 : test_device_reconfigure(void)
14367 : : {
14368 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14369 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14370 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14371 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14372 : 1 : .mp_session = ts_params->session_mpool
14373 : : };
14374 : : uint16_t qp_id, dev_id, num_devs = 0;
14375 : :
14376 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14377 : : "Need at least %d devices for test", 1);
14378 : :
14379 : 1 : dev_id = ts_params->valid_devs[0];
14380 : :
14381 : : /* Stop the device in case it's started so it can be configured */
14382 : 1 : rte_cryptodev_stop(dev_id);
14383 : :
14384 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14385 : : "Failed test for rte_cryptodev_configure: "
14386 : : "dev_num %u", dev_id);
14387 : :
14388 : : /* Reconfigure with same configure params */
14389 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14390 : : "Failed test for rte_cryptodev_configure: "
14391 : : "dev_num %u", dev_id);
14392 : :
14393 : : /* Reconfigure with just one queue pair */
14394 : 1 : ts_params->conf.nb_queue_pairs = 1;
14395 : :
14396 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14397 : : &ts_params->conf),
14398 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14399 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14400 : :
14401 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14402 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14403 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14404 : : rte_cryptodev_socket_id(
14405 : : ts_params->valid_devs[0])),
14406 : : "Failed test for "
14407 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14408 : : "%u on qp %u on cryptodev %u",
14409 : : qp_conf.nb_descriptors, qp_id,
14410 : : ts_params->valid_devs[0]);
14411 : : }
14412 : :
14413 : : /* Reconfigure with max number of queue pairs */
14414 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
14415 : :
14416 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14417 : : &ts_params->conf),
14418 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14419 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14420 : :
14421 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14422 : :
14423 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14424 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14425 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14426 : : rte_cryptodev_socket_id(
14427 : : ts_params->valid_devs[0])),
14428 : : "Failed test for "
14429 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14430 : : "%u on qp %u on cryptodev %u",
14431 : : qp_conf.nb_descriptors, qp_id,
14432 : : ts_params->valid_devs[0]);
14433 : : }
14434 : :
14435 : : /* Start the device */
14436 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14437 : : "Failed to start cryptodev %u",
14438 : : ts_params->valid_devs[0]);
14439 : :
14440 : : /* Test expected values */
14441 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14442 : : }
14443 : :
14444 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14445 : : struct crypto_unittest_params *ut_params,
14446 : : enum rte_crypto_auth_operation op,
14447 : : const struct HMAC_MD5_vector *test_case)
14448 : : {
14449 : : uint8_t key[64];
14450 : :
14451 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
14452 : :
14453 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14454 : 4 : ut_params->auth_xform.next = NULL;
14455 : 4 : ut_params->auth_xform.auth.op = op;
14456 : :
14457 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14458 : :
14459 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14460 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
14461 : 4 : ut_params->auth_xform.auth.key.data = key;
14462 : :
14463 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
14464 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14465 : : ts_params->session_mpool);
14466 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14467 : : return TEST_SKIPPED;
14468 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14469 : :
14470 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14471 : :
14472 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14473 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14474 : :
14475 : 4 : return 0;
14476 : : }
14477 : :
14478 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14479 : : const struct HMAC_MD5_vector *test_case,
14480 : : uint8_t **plaintext)
14481 : : {
14482 : : uint16_t plaintext_pad_len;
14483 : :
14484 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14485 : :
14486 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14487 : : 16);
14488 : :
14489 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14490 : : plaintext_pad_len);
14491 : 4 : memcpy(*plaintext, test_case->plaintext.data,
14492 : 4 : test_case->plaintext.len);
14493 : :
14494 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14495 : : ut_params->ibuf, MD5_DIGEST_LEN);
14496 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14497 : : "no room to append digest");
14498 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14499 : : ut_params->ibuf, plaintext_pad_len);
14500 : :
14501 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14502 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14503 [ - + ]: 2 : test_case->auth_tag.len);
14504 : : }
14505 : :
14506 : 4 : sym_op->auth.data.offset = 0;
14507 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
14508 : :
14509 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14510 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14511 : :
14512 : 4 : return 0;
14513 : : }
14514 : :
14515 : : static int
14516 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14517 : : {
14518 : : uint16_t plaintext_pad_len;
14519 : : uint8_t *plaintext, *auth_tag;
14520 : : int ret;
14521 : :
14522 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14523 : : struct crypto_unittest_params *ut_params = &unittest_params;
14524 : : struct rte_cryptodev_info dev_info;
14525 : :
14526 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14527 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14528 : :
14529 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14530 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14531 : : printf("Device doesn't support RAW data-path APIs.\n");
14532 : 0 : return TEST_SKIPPED;
14533 : : }
14534 : :
14535 : : /* Verify the capabilities */
14536 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14537 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14538 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14539 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14540 : : &cap_idx) == NULL)
14541 : : return TEST_SKIPPED;
14542 : :
14543 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14544 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14545 : : return TEST_FAILED;
14546 : :
14547 : : /* Generate Crypto op data structure */
14548 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14549 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14550 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14551 : : "Failed to allocate symmetric crypto operation struct");
14552 : :
14553 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14554 : : 16);
14555 : :
14556 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14557 : : return TEST_FAILED;
14558 : :
14559 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14560 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14561 : : ut_params->op);
14562 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14563 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14564 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14565 : : return ret;
14566 : : } else
14567 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14568 : : process_crypto_request(ts_params->valid_devs[0],
14569 : : ut_params->op),
14570 : : "failed to process sym crypto op");
14571 : :
14572 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14573 : : "crypto op processing failed");
14574 : :
14575 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
14576 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14577 : : uint8_t *, plaintext_pad_len);
14578 : : } else {
14579 : 2 : auth_tag = plaintext + plaintext_pad_len;
14580 : : }
14581 : :
14582 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14583 : : auth_tag,
14584 : : test_case->auth_tag.data,
14585 : : test_case->auth_tag.len,
14586 : : "HMAC_MD5 generated tag not as expected");
14587 : :
14588 : : return TEST_SUCCESS;
14589 : : }
14590 : :
14591 : : static int
14592 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14593 : : {
14594 : : uint8_t *plaintext;
14595 : : int ret;
14596 : :
14597 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14598 : : struct crypto_unittest_params *ut_params = &unittest_params;
14599 : : struct rte_cryptodev_info dev_info;
14600 : :
14601 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14602 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14603 : :
14604 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14605 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14606 : : printf("Device doesn't support RAW data-path APIs.\n");
14607 : 0 : return TEST_SKIPPED;
14608 : : }
14609 : :
14610 : : /* Verify the capabilities */
14611 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14612 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14613 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14614 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14615 : : &cap_idx) == NULL)
14616 : : return TEST_SKIPPED;
14617 : :
14618 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14619 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14620 : : return TEST_FAILED;
14621 : : }
14622 : :
14623 : : /* Generate Crypto op data structure */
14624 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14625 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14626 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14627 : : "Failed to allocate symmetric crypto operation struct");
14628 : :
14629 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14630 : : return TEST_FAILED;
14631 : :
14632 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14633 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14634 : : ut_params->op);
14635 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14636 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14637 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14638 : : return ret;
14639 : : } else
14640 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14641 : : process_crypto_request(ts_params->valid_devs[0],
14642 : : ut_params->op),
14643 : : "failed to process sym crypto op");
14644 : :
14645 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14646 : : "HMAC_MD5 crypto op processing failed");
14647 : :
14648 : : return TEST_SUCCESS;
14649 : : }
14650 : :
14651 : : static int
14652 : 1 : test_MD5_HMAC_generate_case_1(void)
14653 : : {
14654 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14655 : : }
14656 : :
14657 : : static int
14658 : 1 : test_MD5_HMAC_verify_case_1(void)
14659 : : {
14660 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14661 : : }
14662 : :
14663 : : static int
14664 : 1 : test_MD5_HMAC_generate_case_2(void)
14665 : : {
14666 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14667 : : }
14668 : :
14669 : : static int
14670 : 1 : test_MD5_HMAC_verify_case_2(void)
14671 : : {
14672 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14673 : : }
14674 : :
14675 : : static int
14676 : 1 : test_multi_session(void)
14677 : : {
14678 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14679 : : struct crypto_unittest_params *ut_params = &unittest_params;
14680 : : struct rte_cryptodev_info dev_info;
14681 : : int i, nb_sess, ret = TEST_SUCCESS;
14682 : : void **sessions;
14683 : :
14684 : : /* Verify the capabilities */
14685 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14686 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14687 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14688 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14689 : : &cap_idx) == NULL)
14690 : : return TEST_SKIPPED;
14691 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14692 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14693 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14694 : : &cap_idx) == NULL)
14695 : : return TEST_SKIPPED;
14696 : :
14697 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14698 : : aes_cbc_key, hmac_sha512_key);
14699 : :
14700 : :
14701 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14702 : :
14703 : 1 : sessions = rte_malloc(NULL,
14704 : : sizeof(void *) *
14705 : : (MAX_NB_SESSIONS + 1), 0);
14706 : :
14707 : : /* Create multiple crypto sessions*/
14708 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
14709 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
14710 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14711 : : ts_params->session_mpool);
14712 [ - + ]: 4 : if (sessions[i] == NULL) {
14713 : : nb_sess = i;
14714 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14715 : : ret = TEST_SKIPPED;
14716 : : else {
14717 : : ret = TEST_FAILED;
14718 : : printf("TestCase %s() line %d failed : "
14719 : : "Session creation failed at session number %u",
14720 : : __func__, __LINE__, i);
14721 : : }
14722 : : break;
14723 : : }
14724 : :
14725 : :
14726 : : /* Attempt to send a request on each session */
14727 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14728 : : sessions[i],
14729 : : ut_params,
14730 : : ts_params,
14731 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14732 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14733 : : aes_cbc_iv);
14734 : :
14735 : : /* free crypto operation structure */
14736 : 4 : rte_crypto_op_free(ut_params->op);
14737 : :
14738 : : /*
14739 : : * free mbuf - both obuf and ibuf are usually the same,
14740 : : * so check if they point at the same address is necessary,
14741 : : * to avoid freeing the mbuf twice.
14742 : : */
14743 [ + - ]: 4 : if (ut_params->obuf) {
14744 : 4 : rte_pktmbuf_free(ut_params->obuf);
14745 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
14746 : 4 : ut_params->ibuf = 0;
14747 : 4 : ut_params->obuf = 0;
14748 : : }
14749 [ - + ]: 4 : if (ut_params->ibuf) {
14750 : 0 : rte_pktmbuf_free(ut_params->ibuf);
14751 : 0 : ut_params->ibuf = 0;
14752 : : }
14753 : :
14754 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
14755 : 0 : i++;
14756 : 0 : break;
14757 : : }
14758 : : }
14759 : :
14760 : : nb_sess = i;
14761 : :
14762 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
14763 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14764 : 4 : sessions[i]);
14765 : : }
14766 : :
14767 : 1 : rte_free(sessions);
14768 : :
14769 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14770 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14771 : :
14772 : : return ret;
14773 : : }
14774 : :
14775 : : struct multi_session_params {
14776 : : struct crypto_unittest_params ut_params;
14777 : : uint8_t *cipher_key;
14778 : : uint8_t *hmac_key;
14779 : : const uint8_t *cipher;
14780 : : const uint8_t *digest;
14781 : : uint8_t *iv;
14782 : : };
14783 : :
14784 : : #define MB_SESSION_NUMBER 3
14785 : :
14786 : : static int
14787 : 1 : test_multi_session_random_usage(void)
14788 : : {
14789 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14790 : : struct rte_cryptodev_info dev_info;
14791 : : int index = 0, ret = TEST_SUCCESS;
14792 : : uint32_t nb_sess, i, j;
14793 : : void **sessions;
14794 : 1 : struct multi_session_params ut_paramz[] = {
14795 : :
14796 : : {
14797 : : .cipher_key = ms_aes_cbc_key0,
14798 : : .hmac_key = ms_hmac_key0,
14799 : : .cipher = ms_aes_cbc_cipher0,
14800 : : .digest = ms_hmac_digest0,
14801 : : .iv = ms_aes_cbc_iv0
14802 : : },
14803 : : {
14804 : : .cipher_key = ms_aes_cbc_key1,
14805 : : .hmac_key = ms_hmac_key1,
14806 : : .cipher = ms_aes_cbc_cipher1,
14807 : : .digest = ms_hmac_digest1,
14808 : : .iv = ms_aes_cbc_iv1
14809 : : },
14810 : : {
14811 : : .cipher_key = ms_aes_cbc_key2,
14812 : : .hmac_key = ms_hmac_key2,
14813 : : .cipher = ms_aes_cbc_cipher2,
14814 : : .digest = ms_hmac_digest2,
14815 : : .iv = ms_aes_cbc_iv2
14816 : : },
14817 : :
14818 : : };
14819 : :
14820 : : /* Verify the capabilities */
14821 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14822 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14823 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14824 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14825 : : &cap_idx) == NULL)
14826 : : return TEST_SKIPPED;
14827 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14828 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14829 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14830 : : &cap_idx) == NULL)
14831 : : return TEST_SKIPPED;
14832 : :
14833 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14834 : :
14835 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
14836 : : * MAX_NB_SESSIONS) + 1, 0);
14837 : :
14838 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
14839 : :
14840 [ + + ]: 3 : rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
14841 : : sizeof(struct crypto_unittest_params));
14842 : :
14843 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14844 : : &ut_paramz[i].ut_params,
14845 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14846 : :
14847 : : /* Create multiple crypto sessions*/
14848 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
14849 : 3 : ts_params->valid_devs[0],
14850 : : &ut_paramz[i].ut_params.auth_xform,
14851 : : ts_params->session_mpool);
14852 [ - + ]: 3 : if (sessions[i] == NULL) {
14853 : : nb_sess = i;
14854 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14855 : : ret = TEST_SKIPPED;
14856 : : else {
14857 : : ret = TEST_FAILED;
14858 : : printf("TestCase %s() line %d failed : "
14859 : : "Session creation failed at session number %u",
14860 : : __func__, __LINE__, i);
14861 : : }
14862 : 0 : goto session_clear;
14863 : : }
14864 : :
14865 : : }
14866 : :
14867 : : nb_sess = i;
14868 : :
14869 : 1 : srand(time(NULL));
14870 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
14871 : :
14872 : 1 : j = rand() % MB_SESSION_NUMBER;
14873 : :
14874 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14875 : 1 : sessions[j],
14876 : : &ut_paramz[j].ut_params,
14877 : : ts_params, ut_paramz[j].cipher,
14878 : : ut_paramz[j].digest,
14879 : 1 : ut_paramz[j].iv);
14880 : :
14881 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
14882 : :
14883 : : /*
14884 : : * free mbuf - both obuf and ibuf are usually the same,
14885 : : * so check if they point at the same address is necessary,
14886 : : * to avoid freeing the mbuf twice.
14887 : : */
14888 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
14889 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14890 : 1 : if (ut_paramz[j].ut_params.ibuf
14891 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
14892 : 1 : ut_paramz[j].ut_params.ibuf = 0;
14893 : 1 : ut_paramz[j].ut_params.obuf = 0;
14894 : : }
14895 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
14896 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14897 : 0 : ut_paramz[j].ut_params.ibuf = 0;
14898 : : }
14899 : :
14900 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
14901 : 1 : index = i;
14902 : 1 : break;
14903 : : }
14904 : : }
14905 : :
14906 : 0 : session_clear:
14907 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
14908 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14909 : 3 : sessions[i]);
14910 : : }
14911 : :
14912 : 1 : rte_free(sessions);
14913 : :
14914 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14915 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14916 : :
14917 : : return TEST_SUCCESS;
14918 : : }
14919 : :
14920 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14921 : : 0xab, 0xab, 0xab, 0xab,
14922 : : 0xab, 0xab, 0xab, 0xab,
14923 : : 0xab, 0xab, 0xab, 0xab};
14924 : :
14925 : : static int
14926 : 0 : test_null_invalid_operation(void)
14927 : : {
14928 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14929 : : struct crypto_unittest_params *ut_params = &unittest_params;
14930 : :
14931 : : /* This test is for NULL PMD only */
14932 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
14933 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14934 : : return TEST_SKIPPED;
14935 : :
14936 : : /* Setup Cipher Parameters */
14937 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14938 : 0 : ut_params->cipher_xform.next = NULL;
14939 : :
14940 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14941 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14942 : :
14943 : : /* Create Crypto session*/
14944 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
14945 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
14946 : : ts_params->session_mpool);
14947 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14948 : : return TEST_SKIPPED;
14949 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
14950 : : "Session creation succeeded unexpectedly");
14951 : :
14952 : : /* Setup HMAC Parameters */
14953 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14954 : 0 : ut_params->auth_xform.next = NULL;
14955 : :
14956 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
14957 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14958 : :
14959 : : /* Create Crypto session*/
14960 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
14961 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
14962 : : ts_params->session_mpool);
14963 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14964 : : return TEST_SKIPPED;
14965 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
14966 : : "Session creation succeeded unexpectedly");
14967 : :
14968 : : return TEST_SUCCESS;
14969 : : }
14970 : :
14971 : :
14972 : : #define NULL_BURST_LENGTH (32)
14973 : :
14974 : : static int
14975 : 0 : test_null_burst_operation(void)
14976 : : {
14977 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14978 : : struct crypto_unittest_params *ut_params = &unittest_params;
14979 : :
14980 : : unsigned i, burst_len = NULL_BURST_LENGTH;
14981 : :
14982 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
14983 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
14984 : :
14985 : : /* This test is for NULL PMD only */
14986 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
14987 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14988 : : return TEST_SKIPPED;
14989 : :
14990 : : /* Setup Cipher Parameters */
14991 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14992 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
14993 : :
14994 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
14995 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14996 : :
14997 : : /* Setup HMAC Parameters */
14998 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14999 : 0 : ut_params->auth_xform.next = NULL;
15000 : :
15001 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15002 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15003 : :
15004 : : /* Create Crypto session*/
15005 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15006 : 0 : ts_params->valid_devs[0],
15007 : : &ut_params->auth_xform,
15008 : : ts_params->session_mpool);
15009 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15010 : : return TEST_SKIPPED;
15011 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15012 : :
15013 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
15014 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
15015 : : burst_len, "failed to generate burst of crypto ops");
15016 : :
15017 : : /* Generate an operation for each mbuf in burst */
15018 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15019 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15020 : :
15021 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
15022 : :
15023 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
15024 : : sizeof(unsigned));
15025 : 0 : *data = i;
15026 : :
15027 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
15028 : :
15029 : 0 : burst[i]->sym->m_src = m;
15030 : : }
15031 : :
15032 : : /* Process crypto operation */
15033 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
15034 : : 0, burst, burst_len),
15035 : : burst_len,
15036 : : "Error enqueuing burst");
15037 : :
15038 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
15039 : : 0, burst_dequeued, burst_len),
15040 : : burst_len,
15041 : : "Error dequeuing burst");
15042 : :
15043 : :
15044 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15045 [ # # ]: 0 : TEST_ASSERT_EQUAL(
15046 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
15047 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
15048 : : uint32_t *),
15049 : : "data not as expected");
15050 : :
15051 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
15052 : 0 : rte_crypto_op_free(burst[i]);
15053 : : }
15054 : :
15055 : : return TEST_SUCCESS;
15056 : : }
15057 : :
15058 : : static uint16_t
15059 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15060 : : uint16_t nb_ops, void *user_param)
15061 : : {
15062 : : RTE_SET_USED(dev_id);
15063 : : RTE_SET_USED(qp_id);
15064 : : RTE_SET_USED(ops);
15065 : : RTE_SET_USED(user_param);
15066 : :
15067 : 0 : enq_cb_called = true;
15068 : : printf("crypto enqueue callback called\n");
15069 : 0 : return nb_ops;
15070 : : }
15071 : :
15072 : : static uint16_t
15073 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15074 : : uint16_t nb_ops, void *user_param)
15075 : : {
15076 : : RTE_SET_USED(dev_id);
15077 : : RTE_SET_USED(qp_id);
15078 : : RTE_SET_USED(ops);
15079 : : RTE_SET_USED(user_param);
15080 : :
15081 : 0 : deq_cb_called = true;
15082 : : printf("crypto dequeue callback called\n");
15083 : 0 : return nb_ops;
15084 : : }
15085 : :
15086 : : /*
15087 : : * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
15088 : : */
15089 : : static int
15090 : 0 : test_enqdeq_callback_null_cipher(void)
15091 : : {
15092 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15093 : : struct crypto_unittest_params *ut_params = &unittest_params;
15094 : :
15095 : : /* Setup Cipher Parameters */
15096 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15097 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15098 : :
15099 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15100 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15101 : :
15102 : : /* Setup Auth Parameters */
15103 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15104 : 0 : ut_params->auth_xform.next = NULL;
15105 : :
15106 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15107 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15108 : :
15109 : : /* Create Crypto session */
15110 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
15111 : : &ut_params->auth_xform, ts_params->session_mpool);
15112 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15113 : : return TEST_SKIPPED;
15114 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15115 : :
15116 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15117 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
15118 : :
15119 : : /* Allocate mbuf */
15120 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15121 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
15122 : :
15123 : : /* Append some random data */
15124 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
15125 : : "no room to append data");
15126 : :
15127 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15128 : :
15129 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15130 : :
15131 : : /* Process crypto operation */
15132 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
15133 : : "failed to process sym crypto op");
15134 : :
15135 : : return 0;
15136 : : }
15137 : :
15138 : : static int
15139 : 1 : test_enq_callback_setup(void)
15140 : : {
15141 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15142 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15143 : : struct rte_cryptodev_info dev_info;
15144 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15145 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15146 : : };
15147 : :
15148 : : struct rte_cryptodev_cb *cb;
15149 : : uint16_t qp_id = 0;
15150 : : int j = 0;
15151 : :
15152 : : /* Skip test if synchronous API is used */
15153 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15154 : : return TEST_SKIPPED;
15155 : :
15156 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15157 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15158 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15159 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15160 : : &cap_idx) == NULL)
15161 : : return TEST_SKIPPED;
15162 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15163 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15164 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15165 : : &cap_idx) == NULL)
15166 : : return TEST_SKIPPED;
15167 : :
15168 : : /* Stop the device in case it's started so it can be configured */
15169 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15170 : :
15171 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15172 : :
15173 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15174 : : &ts_params->conf),
15175 : : "Failed to configure cryptodev %u",
15176 : : ts_params->valid_devs[0]);
15177 : :
15178 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15179 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15180 : :
15181 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15182 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15183 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15184 : : "Failed test for "
15185 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15186 : : "%u on qp %u on cryptodev %u",
15187 : : qp_conf.nb_descriptors, qp_id,
15188 : : ts_params->valid_devs[0]);
15189 : :
15190 : 0 : enq_cb_called = false;
15191 : : /* Test with invalid crypto device */
15192 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
15193 : : qp_id, test_enq_callback, NULL);
15194 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15195 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15196 : : "rte_cryptodev_add_enq_callback() "
15197 : : "Not supported, skipped\n", __func__, __LINE__);
15198 : 0 : return TEST_SKIPPED;
15199 : : }
15200 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15201 : : "cryptodev %u did not fail",
15202 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15203 : :
15204 : : /* Test with invalid queue pair */
15205 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15206 : 0 : dev_info.max_nb_queue_pairs + 1,
15207 : : test_enq_callback, NULL);
15208 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15209 : : "cryptodev %u did not fail",
15210 : : dev_info.max_nb_queue_pairs + 1,
15211 : : ts_params->valid_devs[0]);
15212 : :
15213 : : /* Test with NULL callback */
15214 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15215 : : qp_id, NULL, NULL);
15216 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15217 : : "cryptodev %u did not fail",
15218 : : qp_id, ts_params->valid_devs[0]);
15219 : :
15220 : : /* Test with valid configuration */
15221 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15222 : : qp_id, test_enq_callback, NULL);
15223 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15224 : : "qp %u on cryptodev %u",
15225 : : qp_id, ts_params->valid_devs[0]);
15226 : :
15227 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15228 : :
15229 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
15230 : :
15231 : : /* Wait until callback not called. */
15232 [ # # # # ]: 0 : while (!enq_cb_called && (j++ < 10))
15233 : : rte_delay_ms(10);
15234 : :
15235 : : /* Test with invalid crypto device */
15236 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15237 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15238 : : "Expected call to fail as crypto device is invalid");
15239 : :
15240 : : /* Test with invalid queue pair */
15241 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15242 : : ts_params->valid_devs[0],
15243 : : dev_info.max_nb_queue_pairs + 1, cb),
15244 : : "Expected call to fail as queue pair is invalid");
15245 : :
15246 : : /* Test with NULL callback */
15247 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15248 : : ts_params->valid_devs[0], qp_id, NULL),
15249 : : "Expected call to fail as callback is NULL");
15250 : :
15251 : : /* Test with valid configuration */
15252 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
15253 : : ts_params->valid_devs[0], qp_id, cb),
15254 : : "Failed test to remove callback on "
15255 : : "qp %u on cryptodev %u",
15256 : : qp_id, ts_params->valid_devs[0]);
15257 : :
15258 [ # # ]: 0 : TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
15259 : :
15260 : : return TEST_SUCCESS;
15261 : : }
15262 : :
15263 : : static int
15264 : 1 : test_deq_callback_setup(void)
15265 : : {
15266 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15267 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15268 : : struct rte_cryptodev_info dev_info;
15269 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15270 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15271 : : };
15272 : :
15273 : : struct rte_cryptodev_cb *cb;
15274 : : uint16_t qp_id = 0;
15275 : : int j = 0;
15276 : :
15277 : : /* Skip test if synchronous API is used */
15278 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15279 : : return TEST_SKIPPED;
15280 : :
15281 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15282 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15283 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15284 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15285 : : &cap_idx) == NULL)
15286 : : return TEST_SKIPPED;
15287 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15288 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15289 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15290 : : &cap_idx) == NULL)
15291 : : return TEST_SKIPPED;
15292 : :
15293 : : /* Stop the device in case it's started so it can be configured */
15294 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15295 : :
15296 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15297 : :
15298 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15299 : : &ts_params->conf),
15300 : : "Failed to configure cryptodev %u",
15301 : : ts_params->valid_devs[0]);
15302 : :
15303 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15304 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15305 : :
15306 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15307 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15308 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15309 : : "Failed test for "
15310 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15311 : : "%u on qp %u on cryptodev %u",
15312 : : qp_conf.nb_descriptors, qp_id,
15313 : : ts_params->valid_devs[0]);
15314 : :
15315 : 0 : deq_cb_called = false;
15316 : : /* Test with invalid crypto device */
15317 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15318 : : qp_id, test_deq_callback, NULL);
15319 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15320 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15321 : : "rte_cryptodev_add_deq_callback() "
15322 : : "Not supported, skipped\n", __func__, __LINE__);
15323 : 0 : return TEST_SKIPPED;
15324 : : }
15325 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15326 : : "cryptodev %u did not fail",
15327 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15328 : :
15329 : : /* Test with invalid queue pair */
15330 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15331 : 0 : dev_info.max_nb_queue_pairs + 1,
15332 : : test_deq_callback, NULL);
15333 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15334 : : "cryptodev %u did not fail",
15335 : : dev_info.max_nb_queue_pairs + 1,
15336 : : ts_params->valid_devs[0]);
15337 : :
15338 : : /* Test with NULL callback */
15339 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15340 : : qp_id, NULL, NULL);
15341 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15342 : : "cryptodev %u did not fail",
15343 : : qp_id, ts_params->valid_devs[0]);
15344 : :
15345 : : /* Test with valid configuration */
15346 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15347 : : qp_id, test_deq_callback, NULL);
15348 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15349 : : "qp %u on cryptodev %u",
15350 : : qp_id, ts_params->valid_devs[0]);
15351 : :
15352 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15353 : :
15354 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15355 : :
15356 : : /* Wait until callback not called. */
15357 [ # # # # ]: 0 : while (!deq_cb_called && (j++ < 10))
15358 : : rte_delay_ms(10);
15359 : :
15360 : : /* Test with invalid crypto device */
15361 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15362 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15363 : : "Expected call to fail as crypto device is invalid");
15364 : :
15365 : : /* Test with invalid queue pair */
15366 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15367 : : ts_params->valid_devs[0],
15368 : : dev_info.max_nb_queue_pairs + 1, cb),
15369 : : "Expected call to fail as queue pair is invalid");
15370 : :
15371 : : /* Test with NULL callback */
15372 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15373 : : ts_params->valid_devs[0], qp_id, NULL),
15374 : : "Expected call to fail as callback is NULL");
15375 : :
15376 : : /* Test with valid configuration */
15377 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15378 : : ts_params->valid_devs[0], qp_id, cb),
15379 : : "Failed test to remove callback on "
15380 : : "qp %u on cryptodev %u",
15381 : : qp_id, ts_params->valid_devs[0]);
15382 : :
15383 [ # # ]: 0 : TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15384 : :
15385 : : return TEST_SUCCESS;
15386 : : }
15387 : :
15388 : : static void
15389 : : generate_gmac_large_plaintext(uint8_t *data)
15390 : : {
15391 : : uint16_t i;
15392 : :
15393 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15394 : 4082 : memcpy(&data[i], &data[0], 32);
15395 : : }
15396 : :
15397 : : static int
15398 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
15399 : : const struct gmac_test_data *tdata)
15400 : : {
15401 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15402 : : struct crypto_unittest_params *ut_params = &unittest_params;
15403 : : struct rte_crypto_sym_op *sym_op;
15404 : :
15405 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15406 : :
15407 : : /* Generate Crypto op data structure */
15408 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15409 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15410 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
15411 : : "Failed to allocate symmetric crypto operation struct");
15412 : :
15413 : : sym_op = ut_params->op->sym;
15414 : :
15415 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15416 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
15417 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15418 : : "no room to append digest");
15419 : :
15420 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15421 : : ut_params->ibuf, plaintext_pad_len);
15422 : :
15423 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15424 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15425 [ - + ]: 4 : tdata->gmac_tag.len);
15426 : 4 : debug_hexdump(stdout, "digest:",
15427 : 4 : sym_op->auth.digest.data,
15428 : 4 : tdata->gmac_tag.len);
15429 : : }
15430 : :
15431 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15432 : : uint8_t *, IV_OFFSET);
15433 : :
15434 [ - + ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15435 : :
15436 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15437 : :
15438 : 8 : sym_op->cipher.data.length = 0;
15439 : 8 : sym_op->cipher.data.offset = 0;
15440 : :
15441 : 8 : sym_op->auth.data.offset = 0;
15442 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
15443 : :
15444 : 8 : return 0;
15445 : : }
15446 : :
15447 : : static int
15448 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15449 : : const struct gmac_test_data *tdata,
15450 : : void *digest_mem, uint64_t digest_phys)
15451 : : {
15452 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15453 : : struct crypto_unittest_params *ut_params = &unittest_params;
15454 : : struct rte_crypto_sym_op *sym_op;
15455 : :
15456 : : /* Generate Crypto op data structure */
15457 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15458 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15459 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15460 : : "Failed to allocate symmetric crypto operation struct");
15461 : :
15462 : : sym_op = ut_params->op->sym;
15463 : :
15464 : 0 : sym_op->auth.digest.data = digest_mem;
15465 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15466 : : "no room to append digest");
15467 : :
15468 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
15469 : :
15470 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15471 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15472 [ # # ]: 0 : tdata->gmac_tag.len);
15473 : 0 : debug_hexdump(stdout, "digest:",
15474 : 0 : sym_op->auth.digest.data,
15475 : 0 : tdata->gmac_tag.len);
15476 : : }
15477 : :
15478 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15479 : : uint8_t *, IV_OFFSET);
15480 : :
15481 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15482 : :
15483 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15484 : :
15485 : 0 : sym_op->cipher.data.length = 0;
15486 : 0 : sym_op->cipher.data.offset = 0;
15487 : :
15488 : 0 : sym_op->auth.data.offset = 0;
15489 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
15490 : :
15491 : 0 : return 0;
15492 : : }
15493 : :
15494 : 8 : static int create_gmac_session(uint8_t dev_id,
15495 : : const struct gmac_test_data *tdata,
15496 : : enum rte_crypto_auth_operation auth_op)
15497 : : {
15498 : 8 : uint8_t *auth_key = alloca(tdata->key.len);
15499 : :
15500 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15501 : : struct crypto_unittest_params *ut_params = &unittest_params;
15502 : :
15503 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
15504 : :
15505 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15506 : 8 : ut_params->auth_xform.next = NULL;
15507 : :
15508 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15509 : 8 : ut_params->auth_xform.auth.op = auth_op;
15510 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15511 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
15512 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
15513 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15514 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15515 : :
15516 : :
15517 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15518 : : &ut_params->auth_xform, ts_params->session_mpool);
15519 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15520 : : return TEST_SKIPPED;
15521 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15522 : :
15523 : : return 0;
15524 : : }
15525 : :
15526 : : static int
15527 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15528 : : {
15529 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15530 : : struct crypto_unittest_params *ut_params = &unittest_params;
15531 : : struct rte_cryptodev_info dev_info;
15532 : :
15533 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15534 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15535 : :
15536 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15537 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15538 : : printf("Device doesn't support RAW data-path APIs.\n");
15539 : 0 : return TEST_SKIPPED;
15540 : : }
15541 : :
15542 : : int retval;
15543 : :
15544 : : uint8_t *auth_tag, *plaintext;
15545 : : uint16_t plaintext_pad_len;
15546 : :
15547 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15548 : : "No GMAC length in the source data");
15549 : :
15550 : : /* Verify the capabilities */
15551 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15552 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15553 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15554 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15555 : : &cap_idx) == NULL)
15556 : : return TEST_SKIPPED;
15557 : :
15558 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15559 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15560 : :
15561 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15562 : : return TEST_SKIPPED;
15563 [ + - ]: 4 : if (retval < 0)
15564 : : return retval;
15565 : :
15566 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15567 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15568 : : else
15569 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15570 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15571 : : "Failed to allocate input buffer in mempool");
15572 : :
15573 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15574 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15575 : :
15576 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15577 : : /*
15578 : : * Runtime generate the large plain text instead of use hard code
15579 : : * plain text vector. It is done to avoid create huge source file
15580 : : * with the test vector.
15581 : : */
15582 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15583 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15584 : :
15585 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15586 : : plaintext_pad_len);
15587 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15588 : :
15589 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15590 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15591 : 4 : tdata->plaintext.len);
15592 : :
15593 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15594 : : tdata);
15595 : :
15596 [ + - ]: 4 : if (retval < 0)
15597 : : return retval;
15598 : :
15599 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15600 : :
15601 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15602 : :
15603 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15604 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15605 : : ut_params->op);
15606 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15607 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15608 : : 0);
15609 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15610 : : return retval;
15611 : : } else
15612 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15613 : : process_crypto_request(ts_params->valid_devs[0],
15614 : : ut_params->op), "failed to process sym crypto op");
15615 : :
15616 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15617 : : "crypto op processing failed");
15618 : :
15619 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
15620 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15621 : : uint8_t *, plaintext_pad_len);
15622 : : } else {
15623 : 4 : auth_tag = plaintext + plaintext_pad_len;
15624 : : }
15625 : :
15626 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15627 : :
15628 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15629 : : auth_tag,
15630 : : tdata->gmac_tag.data,
15631 : : tdata->gmac_tag.len,
15632 : : "GMAC Generated auth tag not as expected");
15633 : :
15634 : : return 0;
15635 : : }
15636 : :
15637 : : static int
15638 : 1 : test_AES_GMAC_authentication_test_case_1(void)
15639 : : {
15640 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
15641 : : }
15642 : :
15643 : : static int
15644 : 1 : test_AES_GMAC_authentication_test_case_2(void)
15645 : : {
15646 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
15647 : : }
15648 : :
15649 : : static int
15650 : 1 : test_AES_GMAC_authentication_test_case_3(void)
15651 : : {
15652 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
15653 : : }
15654 : :
15655 : : static int
15656 : 1 : test_AES_GMAC_authentication_test_case_4(void)
15657 : : {
15658 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
15659 : : }
15660 : :
15661 : : static int
15662 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15663 : : {
15664 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15665 : : struct crypto_unittest_params *ut_params = &unittest_params;
15666 : : int retval;
15667 : : uint32_t plaintext_pad_len;
15668 : : uint8_t *plaintext;
15669 : : struct rte_cryptodev_info dev_info;
15670 : :
15671 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15672 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15673 : :
15674 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15675 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15676 : : printf("Device doesn't support RAW data-path APIs.\n");
15677 : 0 : return TEST_SKIPPED;
15678 : : }
15679 : :
15680 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15681 : : "No GMAC length in the source data");
15682 : :
15683 : : /* Verify the capabilities */
15684 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15685 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15686 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15687 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15688 : : &cap_idx) == NULL)
15689 : : return TEST_SKIPPED;
15690 : :
15691 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15692 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15693 : :
15694 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15695 : : return TEST_SKIPPED;
15696 [ + - ]: 4 : if (retval < 0)
15697 : : return retval;
15698 : :
15699 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15700 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15701 : : else
15702 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15703 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15704 : : "Failed to allocate input buffer in mempool");
15705 : :
15706 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15707 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15708 : :
15709 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15710 : :
15711 : : /*
15712 : : * Runtime generate the large plain text instead of use hard code
15713 : : * plain text vector. It is done to avoid create huge source file
15714 : : * with the test vector.
15715 : : */
15716 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15717 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15718 : :
15719 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15720 : : plaintext_pad_len);
15721 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15722 : :
15723 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15724 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15725 : 4 : tdata->plaintext.len);
15726 : :
15727 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15728 : : tdata);
15729 : :
15730 [ + - ]: 4 : if (retval < 0)
15731 : : return retval;
15732 : :
15733 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15734 : :
15735 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15736 : :
15737 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15738 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15739 : : ut_params->op);
15740 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15741 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15742 : : 0);
15743 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15744 : : return retval;
15745 : : } else
15746 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15747 : : process_crypto_request(ts_params->valid_devs[0],
15748 : : ut_params->op), "failed to process sym crypto op");
15749 : :
15750 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15751 : : "crypto op processing failed");
15752 : :
15753 : : return 0;
15754 : :
15755 : : }
15756 : :
15757 : : static int
15758 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
15759 : : {
15760 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15761 : : }
15762 : :
15763 : : static int
15764 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
15765 : : {
15766 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15767 : : }
15768 : :
15769 : : static int
15770 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
15771 : : {
15772 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15773 : : }
15774 : :
15775 : : static int
15776 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
15777 : : {
15778 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15779 : : }
15780 : :
15781 : : static int
15782 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15783 : : uint32_t fragsz)
15784 : : {
15785 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15786 : : struct crypto_unittest_params *ut_params = &unittest_params;
15787 : : struct rte_cryptodev_info dev_info;
15788 : : uint64_t feature_flags;
15789 : : unsigned int trn_data = 0;
15790 : : void *digest_mem = NULL;
15791 : : uint32_t segs = 1;
15792 : : unsigned int to_trn = 0;
15793 : : struct rte_mbuf *buf = NULL;
15794 : : uint8_t *auth_tag, *plaintext;
15795 : : int retval;
15796 : :
15797 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15798 : : "No GMAC length in the source data");
15799 : :
15800 : : /* Verify the capabilities */
15801 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15802 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15803 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15804 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15805 : : &cap_idx) == NULL)
15806 : : return TEST_SKIPPED;
15807 : :
15808 : : /* Check for any input SGL support */
15809 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15810 : 4 : feature_flags = dev_info.feature_flags;
15811 : :
15812 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15813 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15814 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15815 : : return TEST_SKIPPED;
15816 : :
15817 : 0 : if (fragsz > tdata->plaintext.len)
15818 : : fragsz = tdata->plaintext.len;
15819 : :
15820 : 0 : uint16_t plaintext_len = fragsz;
15821 : :
15822 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
15823 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15824 : :
15825 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15826 : : return TEST_SKIPPED;
15827 [ # # ]: 0 : if (retval < 0)
15828 : : return retval;
15829 : :
15830 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15831 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15832 : : "Failed to allocate input buffer in mempool");
15833 : :
15834 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15835 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15836 : :
15837 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15838 : : plaintext_len);
15839 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15840 : :
15841 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15842 : :
15843 : : trn_data += plaintext_len;
15844 : :
15845 : 0 : buf = ut_params->ibuf;
15846 : :
15847 : : /*
15848 : : * Loop until no more fragments
15849 : : */
15850 : :
15851 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15852 : 0 : ++segs;
15853 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15854 : : (tdata->plaintext.len - trn_data) : fragsz;
15855 : :
15856 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15857 : : buf = buf->next;
15858 : :
15859 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15860 : : rte_pktmbuf_tailroom(buf));
15861 : :
15862 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15863 : : to_trn);
15864 : :
15865 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15866 : : to_trn);
15867 : 0 : trn_data += to_trn;
15868 [ # # ]: 0 : if (trn_data == tdata->plaintext.len)
15869 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15870 : 0 : tdata->gmac_tag.len);
15871 : : }
15872 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
15873 : :
15874 : : /*
15875 : : * Place digest at the end of the last buffer
15876 : : */
15877 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15878 : :
15879 [ # # ]: 0 : if (!digest_mem) {
15880 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15881 : 0 : + tdata->gmac_tag.len);
15882 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15883 : : tdata->plaintext.len);
15884 : : }
15885 : :
15886 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15887 : : tdata, digest_mem, digest_phys);
15888 : :
15889 [ # # ]: 0 : if (retval < 0)
15890 : : return retval;
15891 : :
15892 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15893 : :
15894 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15895 : :
15896 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15897 : : return TEST_SKIPPED;
15898 : :
15899 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15900 : : process_crypto_request(ts_params->valid_devs[0],
15901 : : ut_params->op), "failed to process sym crypto op");
15902 : :
15903 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15904 : : "crypto op processing failed");
15905 : :
15906 : : auth_tag = digest_mem;
15907 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15908 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15909 : : auth_tag,
15910 : : tdata->gmac_tag.data,
15911 : : tdata->gmac_tag.len,
15912 : : "GMAC Generated auth tag not as expected");
15913 : :
15914 : : return 0;
15915 : : }
15916 : :
15917 : : /* Segment size not multiple of block size (16B) */
15918 : : static int
15919 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
15920 : : {
15921 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15922 : : }
15923 : :
15924 : : static int
15925 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
15926 : : {
15927 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15928 : : }
15929 : :
15930 : : static int
15931 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
15932 : : {
15933 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15934 : : }
15935 : :
15936 : : /* Segment size not multiple of block size (16B) */
15937 : : static int
15938 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
15939 : : {
15940 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15941 : : }
15942 : :
15943 : : struct test_crypto_vector {
15944 : : enum rte_crypto_cipher_algorithm crypto_algo;
15945 : : unsigned int cipher_offset;
15946 : : unsigned int cipher_len;
15947 : :
15948 : : struct {
15949 : : uint8_t data[64];
15950 : : unsigned int len;
15951 : : } cipher_key;
15952 : :
15953 : : struct {
15954 : : uint8_t data[64];
15955 : : unsigned int len;
15956 : : } iv;
15957 : :
15958 : : struct {
15959 : : const uint8_t *data;
15960 : : unsigned int len;
15961 : : } plaintext;
15962 : :
15963 : : struct {
15964 : : const uint8_t *data;
15965 : : unsigned int len;
15966 : : } ciphertext;
15967 : :
15968 : : enum rte_crypto_auth_algorithm auth_algo;
15969 : : unsigned int auth_offset;
15970 : :
15971 : : struct {
15972 : : uint8_t data[128];
15973 : : unsigned int len;
15974 : : } auth_key;
15975 : :
15976 : : struct {
15977 : : const uint8_t *data;
15978 : : unsigned int len;
15979 : : } aad;
15980 : :
15981 : : struct {
15982 : : uint8_t data[128];
15983 : : unsigned int len;
15984 : : } digest;
15985 : : };
15986 : :
15987 : : static const struct test_crypto_vector
15988 : : hmac_sha1_test_crypto_vector = {
15989 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15990 : : .plaintext = {
15991 : : .data = plaintext_hash,
15992 : : .len = 512
15993 : : },
15994 : : .auth_key = {
15995 : : .data = {
15996 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15997 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15998 : : 0xDE, 0xF4, 0xDE, 0xAD
15999 : : },
16000 : : .len = 20
16001 : : },
16002 : : .digest = {
16003 : : .data = {
16004 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
16005 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
16006 : : 0x3F, 0x91, 0x64, 0x59
16007 : : },
16008 : : .len = 20
16009 : : }
16010 : : };
16011 : :
16012 : : static const struct test_crypto_vector
16013 : : aes128_gmac_test_vector = {
16014 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
16015 : : .plaintext = {
16016 : : .data = plaintext_hash,
16017 : : .len = 512
16018 : : },
16019 : : .iv = {
16020 : : .data = {
16021 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16022 : : 0x08, 0x09, 0x0A, 0x0B
16023 : : },
16024 : : .len = 12
16025 : : },
16026 : : .auth_key = {
16027 : : .data = {
16028 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16029 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
16030 : : },
16031 : : .len = 16
16032 : : },
16033 : : .digest = {
16034 : : .data = {
16035 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
16036 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
16037 : : },
16038 : : .len = 16
16039 : : }
16040 : : };
16041 : :
16042 : : static const struct test_crypto_vector
16043 : : aes128cbc_hmac_sha1_test_vector = {
16044 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16045 : : .cipher_offset = 0,
16046 : : .cipher_len = 512,
16047 : : .cipher_key = {
16048 : : .data = {
16049 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16050 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16051 : : },
16052 : : .len = 16
16053 : : },
16054 : : .iv = {
16055 : : .data = {
16056 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16057 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16058 : : },
16059 : : .len = 16
16060 : : },
16061 : : .plaintext = {
16062 : : .data = plaintext_hash,
16063 : : .len = 512
16064 : : },
16065 : : .ciphertext = {
16066 : : .data = ciphertext512_aes128cbc,
16067 : : .len = 512
16068 : : },
16069 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16070 : : .auth_offset = 0,
16071 : : .auth_key = {
16072 : : .data = {
16073 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16074 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16075 : : 0xDE, 0xF4, 0xDE, 0xAD
16076 : : },
16077 : : .len = 20
16078 : : },
16079 : : .digest = {
16080 : : .data = {
16081 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
16082 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16083 : : 0x18, 0x8C, 0x1D, 0x32
16084 : : },
16085 : : .len = 20
16086 : : }
16087 : : };
16088 : :
16089 : : static const struct test_crypto_vector
16090 : : aes128cbc_hmac_sha1_aad_test_vector = {
16091 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16092 : : .cipher_offset = 8,
16093 : : .cipher_len = 496,
16094 : : .cipher_key = {
16095 : : .data = {
16096 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16097 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16098 : : },
16099 : : .len = 16
16100 : : },
16101 : : .iv = {
16102 : : .data = {
16103 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16104 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16105 : : },
16106 : : .len = 16
16107 : : },
16108 : : .plaintext = {
16109 : : .data = plaintext_hash,
16110 : : .len = 512
16111 : : },
16112 : : .ciphertext = {
16113 : : .data = ciphertext512_aes128cbc_aad,
16114 : : .len = 512
16115 : : },
16116 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16117 : : .auth_offset = 0,
16118 : : .auth_key = {
16119 : : .data = {
16120 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16121 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16122 : : 0xDE, 0xF4, 0xDE, 0xAD
16123 : : },
16124 : : .len = 20
16125 : : },
16126 : : .digest = {
16127 : : .data = {
16128 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
16129 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
16130 : : 0x62, 0x0F, 0xFB, 0x10
16131 : : },
16132 : : .len = 20
16133 : : }
16134 : : };
16135 : :
16136 : : static void
16137 : : data_corruption(uint8_t *data)
16138 : : {
16139 : 3 : data[0] += 1;
16140 : 3 : }
16141 : :
16142 : : static void
16143 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
16144 : : {
16145 : 3 : data[tag_offset] += 1;
16146 : 3 : }
16147 : :
16148 : : static int
16149 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
16150 : : uint8_t dev_id,
16151 : : const struct test_crypto_vector *reference,
16152 : : enum rte_crypto_auth_operation auth_op)
16153 : : {
16154 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16155 : 2 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16156 : :
16157 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16158 : :
16159 : : /* Setup Authentication Parameters */
16160 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16161 : 2 : ut_params->auth_xform.auth.op = auth_op;
16162 : 2 : ut_params->auth_xform.next = NULL;
16163 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16164 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16165 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
16166 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16167 : :
16168 : : /* Create Crypto session*/
16169 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16170 : : &ut_params->auth_xform,
16171 : : ts_params->session_mpool);
16172 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16173 : : return TEST_SKIPPED;
16174 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16175 : :
16176 : : return 0;
16177 : : }
16178 : :
16179 : : static int
16180 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
16181 : : uint8_t dev_id,
16182 : : const struct test_crypto_vector *reference,
16183 : : enum rte_crypto_auth_operation auth_op,
16184 : : enum rte_crypto_cipher_operation cipher_op)
16185 : : {
16186 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16187 : 4 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16188 : 4 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16189 : :
16190 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
16191 : : reference->cipher_key.len);
16192 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16193 : :
16194 : : /* Setup Authentication Parameters */
16195 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16196 : 4 : ut_params->auth_xform.auth.op = auth_op;
16197 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16198 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16199 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
16200 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16201 : :
16202 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
16203 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
16204 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
16205 : : } else {
16206 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16207 : :
16208 : : /* Setup Cipher Parameters */
16209 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16210 : 2 : ut_params->cipher_xform.next = NULL;
16211 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16212 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
16213 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16214 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16215 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16216 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16217 : : }
16218 : :
16219 : : /* Create Crypto session*/
16220 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16221 : : &ut_params->auth_xform,
16222 : : ts_params->session_mpool);
16223 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16224 : : return TEST_SKIPPED;
16225 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16226 : :
16227 : : return 0;
16228 : : }
16229 : :
16230 : : static int
16231 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
16232 : : struct crypto_unittest_params *ut_params,
16233 : : const struct test_crypto_vector *reference,
16234 : : unsigned int auth_generate)
16235 : : {
16236 : : /* Generate Crypto op data structure */
16237 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16238 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16239 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16240 : : "Failed to allocate pktmbuf offload");
16241 : :
16242 : : /* Set crypto operation data parameters */
16243 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16244 : :
16245 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16246 : :
16247 : : /* set crypto operation source mbuf */
16248 : 2 : sym_op->m_src = ut_params->ibuf;
16249 : :
16250 : : /* digest */
16251 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16252 : 2 : ut_params->ibuf, reference->digest.len);
16253 : :
16254 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16255 : : "no room to append auth tag");
16256 : :
16257 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16258 : : ut_params->ibuf, reference->plaintext.len);
16259 : :
16260 [ - + ]: 2 : if (auth_generate)
16261 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16262 : : else
16263 : 2 : memcpy(sym_op->auth.digest.data,
16264 : 2 : reference->digest.data,
16265 : 2 : reference->digest.len);
16266 : :
16267 : 2 : debug_hexdump(stdout, "digest:",
16268 : 2 : sym_op->auth.digest.data,
16269 : 2 : reference->digest.len);
16270 : :
16271 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16272 : 2 : sym_op->auth.data.offset = 0;
16273 : :
16274 : 2 : return 0;
16275 : : }
16276 : :
16277 : : static int
16278 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16279 : : struct crypto_unittest_params *ut_params,
16280 : : const struct test_crypto_vector *reference,
16281 : : unsigned int auth_generate)
16282 : : {
16283 : : /* Generate Crypto op data structure */
16284 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16285 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16286 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16287 : : "Failed to allocate pktmbuf offload");
16288 : :
16289 : : /* Set crypto operation data parameters */
16290 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16291 : :
16292 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16293 : :
16294 : : /* set crypto operation source mbuf */
16295 : 2 : sym_op->m_src = ut_params->ibuf;
16296 : :
16297 : : /* digest */
16298 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16299 : 2 : ut_params->ibuf, reference->digest.len);
16300 : :
16301 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16302 : : "no room to append auth tag");
16303 : :
16304 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16305 : : ut_params->ibuf, reference->ciphertext.len);
16306 : :
16307 [ - + ]: 2 : if (auth_generate)
16308 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16309 : : else
16310 : 2 : memcpy(sym_op->auth.digest.data,
16311 : 2 : reference->digest.data,
16312 : 2 : reference->digest.len);
16313 : :
16314 : 2 : debug_hexdump(stdout, "digest:",
16315 : 2 : sym_op->auth.digest.data,
16316 : 2 : reference->digest.len);
16317 : :
16318 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16319 [ - + ]: 2 : reference->iv.data, reference->iv.len);
16320 : :
16321 : 2 : sym_op->cipher.data.length = 0;
16322 : 2 : sym_op->cipher.data.offset = 0;
16323 : :
16324 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16325 : 2 : sym_op->auth.data.offset = 0;
16326 : :
16327 : 2 : return 0;
16328 : : }
16329 : :
16330 : : static int
16331 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16332 : : struct crypto_unittest_params *ut_params,
16333 : : const struct test_crypto_vector *reference,
16334 : : unsigned int auth_generate)
16335 : : {
16336 : : /* Generate Crypto op data structure */
16337 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16338 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16339 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
16340 : : "Failed to allocate pktmbuf offload");
16341 : :
16342 : : /* Set crypto operation data parameters */
16343 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16344 : :
16345 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16346 : :
16347 : : /* set crypto operation source mbuf */
16348 : 4 : sym_op->m_src = ut_params->ibuf;
16349 : :
16350 : : /* digest */
16351 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16352 : 4 : ut_params->ibuf, reference->digest.len);
16353 : :
16354 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16355 : : "no room to append auth tag");
16356 : :
16357 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16358 : : ut_params->ibuf, reference->ciphertext.len);
16359 : :
16360 [ - + ]: 4 : if (auth_generate)
16361 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16362 : : else
16363 : 4 : memcpy(sym_op->auth.digest.data,
16364 : 4 : reference->digest.data,
16365 : 4 : reference->digest.len);
16366 : :
16367 : 4 : debug_hexdump(stdout, "digest:",
16368 : 4 : sym_op->auth.digest.data,
16369 : 4 : reference->digest.len);
16370 : :
16371 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16372 [ - + ]: 4 : reference->iv.data, reference->iv.len);
16373 : :
16374 : 4 : sym_op->cipher.data.length = reference->cipher_len;
16375 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
16376 : :
16377 : 4 : sym_op->auth.data.length = reference->plaintext.len;
16378 : 4 : sym_op->auth.data.offset = reference->auth_offset;
16379 : :
16380 : 4 : return 0;
16381 : : }
16382 : :
16383 : : static int
16384 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16385 : : struct crypto_unittest_params *ut_params,
16386 : : const struct test_crypto_vector *reference)
16387 : : {
16388 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
16389 : : }
16390 : :
16391 : : static int
16392 : : create_auth_verify_GMAC_operation(
16393 : : struct crypto_testsuite_params *ts_params,
16394 : : struct crypto_unittest_params *ut_params,
16395 : : const struct test_crypto_vector *reference)
16396 : : {
16397 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16398 : : }
16399 : :
16400 : : static int
16401 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16402 : : struct crypto_unittest_params *ut_params,
16403 : : const struct test_crypto_vector *reference)
16404 : : {
16405 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16406 : : }
16407 : :
16408 : : static int
16409 : 2 : test_authentication_verify_fail_when_data_corruption(
16410 : : struct crypto_testsuite_params *ts_params,
16411 : : struct crypto_unittest_params *ut_params,
16412 : : const struct test_crypto_vector *reference,
16413 : : unsigned int data_corrupted)
16414 : : {
16415 : : int retval;
16416 : :
16417 : : uint8_t *plaintext;
16418 : : struct rte_cryptodev_info dev_info;
16419 : :
16420 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16421 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16422 : :
16423 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16424 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16425 : : printf("Device doesn't support RAW data-path APIs.\n");
16426 : 0 : return TEST_SKIPPED;
16427 : : }
16428 : :
16429 : : /* Verify the capabilities */
16430 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16431 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16432 : 2 : cap_idx.algo.auth = reference->auth_algo;
16433 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16434 : : &cap_idx) == NULL)
16435 : : return TEST_SKIPPED;
16436 : :
16437 : :
16438 : : /* Create session */
16439 : 2 : retval = create_auth_session(ut_params,
16440 : 2 : ts_params->valid_devs[0],
16441 : : reference,
16442 : : RTE_CRYPTO_AUTH_OP_VERIFY);
16443 : :
16444 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16445 : : return TEST_SKIPPED;
16446 [ + - ]: 2 : if (retval < 0)
16447 : : return retval;
16448 : :
16449 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16450 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16451 : : "Failed to allocate input buffer in mempool");
16452 : :
16453 : : /* clear mbuf payload */
16454 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16455 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16456 : :
16457 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16458 : 2 : reference->plaintext.len);
16459 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16460 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16461 : :
16462 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16463 : 2 : reference->plaintext.len);
16464 : :
16465 : : /* Create operation */
16466 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
16467 : :
16468 [ + - ]: 2 : if (retval < 0)
16469 : : return retval;
16470 : :
16471 [ + + ]: 2 : if (data_corrupted)
16472 : : data_corruption(plaintext);
16473 : : else
16474 : 1 : tag_corruption(plaintext, reference->plaintext.len);
16475 : :
16476 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16477 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16478 : : ut_params->op);
16479 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16480 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16481 : : "authentication not failed");
16482 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16483 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16484 : : 0);
16485 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16486 : : return retval;
16487 : : } else {
16488 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16489 : : ut_params->op);
16490 : : }
16491 [ - + ]: 2 : if (ut_params->op == NULL)
16492 : : return 0;
16493 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16494 : 0 : return 0;
16495 : :
16496 : : return -1;
16497 : : }
16498 : :
16499 : : static int
16500 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
16501 : : struct crypto_testsuite_params *ts_params,
16502 : : struct crypto_unittest_params *ut_params,
16503 : : const struct test_crypto_vector *reference,
16504 : : unsigned int data_corrupted)
16505 : : {
16506 : : int retval;
16507 : : uint8_t *plaintext;
16508 : : struct rte_cryptodev_info dev_info;
16509 : :
16510 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16511 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16512 : :
16513 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16514 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16515 : : printf("Device doesn't support RAW data-path APIs.\n");
16516 : 0 : return TEST_SKIPPED;
16517 : : }
16518 : :
16519 : : /* Verify the capabilities */
16520 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16521 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16522 : 2 : cap_idx.algo.auth = reference->auth_algo;
16523 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16524 : : &cap_idx) == NULL)
16525 : : return TEST_SKIPPED;
16526 : :
16527 : : /* Create session */
16528 : 2 : retval = create_auth_cipher_session(ut_params,
16529 : 2 : ts_params->valid_devs[0],
16530 : : reference,
16531 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16532 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16533 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16534 : : return TEST_SKIPPED;
16535 [ + - ]: 2 : if (retval < 0)
16536 : : return retval;
16537 : :
16538 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16539 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16540 : : "Failed to allocate input buffer in mempool");
16541 : :
16542 : : /* clear mbuf payload */
16543 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16544 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16545 : :
16546 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16547 : 2 : reference->plaintext.len);
16548 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16549 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16550 : :
16551 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16552 : 2 : reference->plaintext.len);
16553 : :
16554 : : /* Create operation */
16555 : : retval = create_auth_verify_GMAC_operation(ts_params,
16556 : : ut_params,
16557 : : reference);
16558 : :
16559 [ + - ]: 2 : if (retval < 0)
16560 : : return retval;
16561 : :
16562 [ + + ]: 2 : if (data_corrupted)
16563 : : data_corruption(plaintext);
16564 : : else
16565 : 1 : tag_corruption(plaintext, reference->aad.len);
16566 : :
16567 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16568 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16569 : : ut_params->op);
16570 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16571 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16572 : : "authentication not failed");
16573 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16574 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16575 : : 0);
16576 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16577 : 0 : return retval;
16578 : : } else {
16579 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16580 : : ut_params->op);
16581 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16582 : : }
16583 : :
16584 : : return 0;
16585 : : }
16586 : :
16587 : : static int
16588 : 2 : test_authenticated_decryption_fail_when_corruption(
16589 : : struct crypto_testsuite_params *ts_params,
16590 : : struct crypto_unittest_params *ut_params,
16591 : : const struct test_crypto_vector *reference,
16592 : : unsigned int data_corrupted)
16593 : : {
16594 : : int retval;
16595 : :
16596 : : uint8_t *ciphertext;
16597 : : struct rte_cryptodev_info dev_info;
16598 : :
16599 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16600 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16601 : :
16602 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16603 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16604 : : printf("Device doesn't support RAW data-path APIs.\n");
16605 : 0 : return TEST_SKIPPED;
16606 : : }
16607 : :
16608 : : /* Verify the capabilities */
16609 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16610 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16611 : 2 : cap_idx.algo.auth = reference->auth_algo;
16612 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16613 : : &cap_idx) == NULL)
16614 : : return TEST_SKIPPED;
16615 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16616 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
16617 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16618 : : &cap_idx) == NULL)
16619 : : return TEST_SKIPPED;
16620 : :
16621 : : /* Create session */
16622 : 2 : retval = create_auth_cipher_session(ut_params,
16623 : 2 : ts_params->valid_devs[0],
16624 : : reference,
16625 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16626 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16627 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16628 : : return TEST_SKIPPED;
16629 [ + - ]: 2 : if (retval < 0)
16630 : : return retval;
16631 : :
16632 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16633 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16634 : : "Failed to allocate input buffer in mempool");
16635 : :
16636 : : /* clear mbuf payload */
16637 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16638 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16639 : :
16640 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16641 : 2 : reference->ciphertext.len);
16642 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16643 : 2 : memcpy(ciphertext, reference->ciphertext.data,
16644 : 2 : reference->ciphertext.len);
16645 : :
16646 : : /* Create operation */
16647 : : retval = create_cipher_auth_verify_operation(ts_params,
16648 : : ut_params,
16649 : : reference);
16650 : :
16651 [ + - ]: 2 : if (retval < 0)
16652 : : return retval;
16653 : :
16654 [ + + ]: 2 : if (data_corrupted)
16655 : : data_corruption(ciphertext);
16656 : : else
16657 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
16658 : :
16659 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16660 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16661 : : ut_params->op);
16662 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16663 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16664 : : "authentication not failed");
16665 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16666 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16667 : : 0);
16668 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16669 : 0 : return retval;
16670 : : } else {
16671 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16672 : : ut_params->op);
16673 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16674 : : }
16675 : :
16676 : : return 0;
16677 : : }
16678 : :
16679 : : static int
16680 : 1 : test_authenticated_encrypt_with_esn(
16681 : : struct crypto_testsuite_params *ts_params,
16682 : : struct crypto_unittest_params *ut_params,
16683 : : const struct test_crypto_vector *reference)
16684 : : {
16685 : : int retval;
16686 : :
16687 : : uint8_t *authciphertext, *plaintext, *auth_tag;
16688 : : uint16_t plaintext_pad_len;
16689 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16690 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16691 : : struct rte_cryptodev_info dev_info;
16692 : :
16693 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16694 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16695 : :
16696 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16697 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16698 : : printf("Device doesn't support RAW data-path APIs.\n");
16699 : 0 : return TEST_SKIPPED;
16700 : : }
16701 : :
16702 : : /* Verify the capabilities */
16703 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16704 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16705 : 1 : cap_idx.algo.auth = reference->auth_algo;
16706 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16707 : : &cap_idx) == NULL)
16708 : : return TEST_SKIPPED;
16709 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16710 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16711 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16712 : : &cap_idx) == NULL)
16713 : : return TEST_SKIPPED;
16714 : :
16715 : : /* Create session */
16716 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16717 : 1 : reference->cipher_key.len);
16718 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16719 : :
16720 : : /* Setup Cipher Parameters */
16721 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16722 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16723 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16724 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16725 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16726 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16727 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16728 : :
16729 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
16730 : :
16731 : : /* Setup Authentication Parameters */
16732 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16733 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16734 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16735 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16736 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16737 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16738 : 1 : ut_params->auth_xform.next = NULL;
16739 : :
16740 : : /* Create Crypto session*/
16741 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16742 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
16743 : : ts_params->session_mpool);
16744 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16745 : : return TEST_SKIPPED;
16746 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16747 : :
16748 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16749 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16750 : : "Failed to allocate input buffer in mempool");
16751 : :
16752 : : /* clear mbuf payload */
16753 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16754 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16755 : :
16756 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16757 : 1 : reference->plaintext.len);
16758 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16759 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16760 : :
16761 : : /* Create operation */
16762 : 1 : retval = create_cipher_auth_operation(ts_params,
16763 : : ut_params,
16764 : : reference, 0);
16765 : :
16766 [ + - ]: 1 : if (retval < 0)
16767 : : return retval;
16768 : :
16769 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16770 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16771 : : ut_params->op);
16772 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16773 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16774 : : 0);
16775 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16776 : : return retval;
16777 : : } else
16778 : 1 : ut_params->op = process_crypto_request(
16779 : 1 : ts_params->valid_devs[0], ut_params->op);
16780 : :
16781 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16782 : :
16783 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16784 : : "crypto op processing failed");
16785 : :
16786 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16787 : :
16788 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16789 : : ut_params->op->sym->auth.data.offset);
16790 : 1 : auth_tag = authciphertext + plaintext_pad_len;
16791 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
16792 : 1 : reference->ciphertext.len);
16793 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16794 : :
16795 : : /* Validate obuf */
16796 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16797 : : authciphertext,
16798 : : reference->ciphertext.data,
16799 : : reference->ciphertext.len,
16800 : : "Ciphertext data not as expected");
16801 : :
16802 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16803 : : auth_tag,
16804 : : reference->digest.data,
16805 : : reference->digest.len,
16806 : : "Generated digest not as expected");
16807 : :
16808 : : return TEST_SUCCESS;
16809 : :
16810 : : }
16811 : :
16812 : : static int
16813 : 1 : test_authenticated_decrypt_with_esn(
16814 : : struct crypto_testsuite_params *ts_params,
16815 : : struct crypto_unittest_params *ut_params,
16816 : : const struct test_crypto_vector *reference)
16817 : : {
16818 : : int retval;
16819 : :
16820 : : uint8_t *ciphertext;
16821 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16822 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16823 : : struct rte_cryptodev_info dev_info;
16824 : :
16825 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16826 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16827 : :
16828 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16829 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16830 : : printf("Device doesn't support RAW data-path APIs.\n");
16831 : 0 : return TEST_SKIPPED;
16832 : : }
16833 : :
16834 : : /* Verify the capabilities */
16835 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16836 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16837 : 1 : cap_idx.algo.auth = reference->auth_algo;
16838 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16839 : : &cap_idx) == NULL)
16840 : : return TEST_SKIPPED;
16841 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16842 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16843 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16844 : : &cap_idx) == NULL)
16845 : : return TEST_SKIPPED;
16846 : :
16847 : : /* Create session */
16848 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16849 : 1 : reference->cipher_key.len);
16850 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16851 : :
16852 : : /* Setup Authentication Parameters */
16853 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16854 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16855 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16856 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16857 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16858 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16859 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16860 : :
16861 : : /* Setup Cipher Parameters */
16862 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16863 : 1 : ut_params->cipher_xform.next = NULL;
16864 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16865 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16866 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16867 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16868 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16869 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16870 : :
16871 : : /* Create Crypto session*/
16872 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16873 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
16874 : : ts_params->session_mpool);
16875 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16876 : : return TEST_SKIPPED;
16877 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16878 : :
16879 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16880 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16881 : : "Failed to allocate input buffer in mempool");
16882 : :
16883 : : /* clear mbuf payload */
16884 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16885 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16886 : :
16887 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16888 : 1 : reference->ciphertext.len);
16889 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16890 : 1 : memcpy(ciphertext, reference->ciphertext.data,
16891 : 1 : reference->ciphertext.len);
16892 : :
16893 : : /* Create operation */
16894 : : retval = create_cipher_auth_verify_operation(ts_params,
16895 : : ut_params,
16896 : : reference);
16897 : :
16898 [ + - ]: 1 : if (retval < 0)
16899 : : return retval;
16900 : :
16901 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16902 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16903 : : ut_params->op);
16904 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16905 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16906 : : 0);
16907 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16908 : : return retval;
16909 : : } else
16910 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16911 : : ut_params->op);
16912 : :
16913 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16914 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
16915 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16916 : : "crypto op processing passed");
16917 : :
16918 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
16919 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16920 : :
16921 : : return 0;
16922 : : }
16923 : :
16924 : : static int
16925 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16926 : : const struct aead_test_data *tdata,
16927 : : void *digest_mem, uint64_t digest_phys)
16928 : : {
16929 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16930 : : struct crypto_unittest_params *ut_params = &unittest_params;
16931 : :
16932 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
16933 : 1 : const unsigned int iv_len = tdata->iv.len;
16934 : 1 : unsigned int aad_len = tdata->aad.len;
16935 : : unsigned int aad_len_pad = 0;
16936 : :
16937 : : /* Generate Crypto op data structure */
16938 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16939 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16940 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
16941 : : "Failed to allocate symmetric crypto operation struct");
16942 : :
16943 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16944 : :
16945 : 1 : sym_op->aead.digest.data = digest_mem;
16946 : :
16947 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
16948 : : "no room to append digest");
16949 : :
16950 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
16951 : :
16952 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
16953 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
16954 : : auth_tag_len);
16955 : 0 : debug_hexdump(stdout, "digest:",
16956 : 0 : sym_op->aead.digest.data,
16957 : : auth_tag_len);
16958 : : }
16959 : :
16960 : : /* Append aad data */
16961 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
16962 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16963 : : uint8_t *, IV_OFFSET);
16964 : :
16965 : : /* Copy IV 1 byte after the IV pointer, according to the API */
16966 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
16967 : :
16968 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
16969 : :
16970 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16971 : : ut_params->ibuf, aad_len);
16972 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16973 : : "no room to prepend aad");
16974 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16975 : : ut_params->ibuf);
16976 : :
16977 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
16978 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
16979 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16980 : :
16981 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16982 : 0 : debug_hexdump(stdout, "aad:",
16983 : 0 : sym_op->aead.aad.data, aad_len);
16984 : : } else {
16985 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16986 : : uint8_t *, IV_OFFSET);
16987 : :
16988 [ - + ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
16989 : :
16990 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
16991 : :
16992 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16993 : : ut_params->ibuf, aad_len_pad);
16994 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16995 : : "no room to prepend aad");
16996 [ - + ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16997 : : ut_params->ibuf);
16998 : :
16999 [ - + ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
17000 [ - + ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17001 : :
17002 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17003 : 1 : debug_hexdump(stdout, "aad:",
17004 : 1 : sym_op->aead.aad.data, aad_len);
17005 : : }
17006 : :
17007 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
17008 : 1 : sym_op->aead.data.offset = aad_len_pad;
17009 : :
17010 : 1 : return 0;
17011 : : }
17012 : :
17013 : : #define SGL_MAX_NO 16
17014 : :
17015 : : static int
17016 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
17017 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
17018 : : {
17019 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17020 : : struct crypto_unittest_params *ut_params = &unittest_params;
17021 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
17022 : : int retval;
17023 : : int to_trn = 0;
17024 : : int to_trn_tbl[SGL_MAX_NO];
17025 : : int segs = 1;
17026 : : unsigned int trn_data = 0;
17027 : : uint8_t *plaintext, *ciphertext, *auth_tag;
17028 : : struct rte_cryptodev_info dev_info;
17029 : :
17030 : : /* Verify the capabilities */
17031 : : struct rte_cryptodev_sym_capability_idx cap_idx;
17032 : : const struct rte_cryptodev_symmetric_capability *capability;
17033 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
17034 : 3 : cap_idx.algo.aead = tdata->algo;
17035 : 3 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
17036 [ + - ]: 3 : if (capability == NULL)
17037 : : return TEST_SKIPPED;
17038 [ + - ]: 3 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
17039 : 3 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
17040 : : return TEST_SKIPPED;
17041 : :
17042 : : /*
17043 : : * SGL not supported on AESNI_MB PMD CPU crypto,
17044 : : * OOP not supported on AESNI_GCM CPU crypto
17045 : : */
17046 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
17047 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
17048 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
17049 : : return TEST_SKIPPED;
17050 : :
17051 : : /* Detailed check for the particular SGL support flag */
17052 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
17053 [ - + ]: 3 : if (!oop) {
17054 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17055 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
17056 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
17057 : : return TEST_SKIPPED;
17058 : :
17059 : 0 : uint64_t feat_flags = dev_info.feature_flags;
17060 : :
17061 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
17062 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
17063 : : printf("Device doesn't support RAW data-path APIs.\n");
17064 : 0 : return TEST_SKIPPED;
17065 : : }
17066 : : } else {
17067 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17068 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
17069 : : tdata->plaintext.len;
17070 : : /* Raw data path API does not support OOP */
17071 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
17072 : : return TEST_SKIPPED;
17073 [ + + ]: 3 : if (sgl_in && !sgl_out) {
17074 [ + - ]: 1 : if (!(dev_info.feature_flags &
17075 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
17076 : : return TEST_SKIPPED;
17077 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
17078 [ # # ]: 0 : if (!(dev_info.feature_flags &
17079 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
17080 : : return TEST_SKIPPED;
17081 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
17082 [ - + ]: 2 : if (!(dev_info.feature_flags &
17083 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
17084 : : return TEST_SKIPPED;
17085 : : }
17086 : : }
17087 : :
17088 : 1 : if (fragsz > tdata->plaintext.len)
17089 : : fragsz = tdata->plaintext.len;
17090 : :
17091 : 1 : uint16_t plaintext_len = fragsz;
17092 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
17093 : :
17094 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
17095 : 0 : frag_size_oop = tdata->plaintext.len;
17096 : :
17097 : : int ecx = 0;
17098 : : void *digest_mem = NULL;
17099 : :
17100 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
17101 : :
17102 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
17103 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
17104 : : return 1;
17105 : : } else {
17106 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
17107 : : return 1;
17108 : : }
17109 : :
17110 : : /*
17111 : : * For out-of-place we need to alloc another mbuf
17112 : : */
17113 [ + - ]: 1 : if (oop) {
17114 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17115 : : rte_pktmbuf_append(ut_params->obuf,
17116 : 1 : frag_size_oop + prepend_len);
17117 : 1 : buf_oop = ut_params->obuf;
17118 : : }
17119 : :
17120 : : /* Create AEAD session */
17121 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
17122 : 1 : tdata->algo,
17123 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
17124 : 1 : tdata->key.data, tdata->key.len,
17125 : 1 : tdata->aad.len, tdata->auth_tag.len,
17126 : 1 : tdata->iv.len);
17127 [ + - ]: 1 : if (retval < 0)
17128 : : return retval;
17129 : :
17130 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17131 : :
17132 : : /* clear mbuf payload */
17133 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
17134 : : rte_pktmbuf_tailroom(ut_params->ibuf));
17135 : :
17136 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17137 : : plaintext_len);
17138 : :
17139 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
17140 : :
17141 : : trn_data += plaintext_len;
17142 : :
17143 : 1 : buf = ut_params->ibuf;
17144 : :
17145 : : /*
17146 : : * Loop until no more fragments
17147 : : */
17148 : :
17149 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
17150 : 5 : ++segs;
17151 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
17152 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
17153 : :
17154 : 5 : to_trn_tbl[ecx++] = to_trn;
17155 : :
17156 [ - + ]: 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17157 : : buf = buf->next;
17158 : :
17159 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
17160 : : rte_pktmbuf_tailroom(buf));
17161 : :
17162 : : /* OOP */
17163 [ - + ]: 5 : if (oop && !fragsz_oop) {
17164 : 0 : buf_last_oop = buf_oop->next =
17165 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17166 : : buf_oop = buf_oop->next;
17167 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17168 : : 0, rte_pktmbuf_tailroom(buf_oop));
17169 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
17170 : : }
17171 : :
17172 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
17173 : : to_trn);
17174 : :
17175 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
17176 : : to_trn);
17177 : 5 : trn_data += to_trn;
17178 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
17179 [ + - ]: 1 : if (oop) {
17180 [ - + ]: 1 : if (!fragsz_oop)
17181 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
17182 : 0 : tdata->auth_tag.len);
17183 : : } else
17184 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
17185 : 0 : tdata->auth_tag.len);
17186 : : }
17187 : : }
17188 : :
17189 : : uint64_t digest_phys = 0;
17190 : :
17191 : 1 : ut_params->ibuf->nb_segs = segs;
17192 : :
17193 : : segs = 1;
17194 [ + - ]: 1 : if (fragsz_oop && oop) {
17195 : : to_trn = 0;
17196 : : ecx = 0;
17197 : :
17198 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
17199 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17200 : 1 : tdata->auth_tag.len);
17201 : :
17202 : 1 : digest_phys = rte_pktmbuf_iova_offset(
17203 : : ut_params->obuf,
17204 : : tdata->plaintext.len + prepend_len);
17205 : : }
17206 : :
17207 : : trn_data = frag_size_oop;
17208 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
17209 : 0 : ++segs;
17210 : 0 : to_trn =
17211 : 0 : (tdata->plaintext.len - trn_data <
17212 : : frag_size_oop) ?
17213 : 0 : (tdata->plaintext.len - trn_data) :
17214 : : frag_size_oop;
17215 : :
17216 : 0 : to_trn_tbl[ecx++] = to_trn;
17217 : :
17218 : 0 : buf_last_oop = buf_oop->next =
17219 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17220 : : buf_oop = buf_oop->next;
17221 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17222 : : 0, rte_pktmbuf_tailroom(buf_oop));
17223 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
17224 : :
17225 : 0 : trn_data += to_trn;
17226 : :
17227 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
17228 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
17229 : 0 : tdata->auth_tag.len);
17230 : : }
17231 : : }
17232 : :
17233 : 1 : ut_params->obuf->nb_segs = segs;
17234 : : }
17235 : :
17236 : : /*
17237 : : * Place digest at the end of the last buffer
17238 : : */
17239 [ - + ]: 1 : if (!digest_phys)
17240 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
17241 [ - + ]: 1 : if (oop && buf_last_oop)
17242 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
17243 : :
17244 [ - + ]: 1 : if (!digest_mem && !oop) {
17245 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17246 : 0 : + tdata->auth_tag.len);
17247 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
17248 : : tdata->plaintext.len);
17249 : : }
17250 : :
17251 : : /* Create AEAD operation */
17252 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
17253 : : tdata, digest_mem, digest_phys);
17254 : :
17255 [ + - ]: 1 : if (retval < 0)
17256 : : return retval;
17257 : :
17258 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
17259 : :
17260 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
17261 [ + - ]: 1 : if (oop)
17262 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
17263 : :
17264 : : /* Process crypto operation */
17265 [ - + ]: 1 : if (oop == IN_PLACE &&
17266 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17267 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
17268 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17269 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
17270 : : 0);
17271 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17272 : : return retval;
17273 : : } else
17274 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
17275 : : process_crypto_request(ts_params->valid_devs[0],
17276 : : ut_params->op), "failed to process sym crypto op");
17277 : :
17278 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17279 : : "crypto op processing failed");
17280 : :
17281 : :
17282 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17283 : : uint8_t *, prepend_len);
17284 [ + - ]: 1 : if (oop) {
17285 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17286 : : uint8_t *, prepend_len);
17287 : : }
17288 : :
17289 [ + - ]: 1 : if (fragsz_oop)
17290 : : fragsz = fragsz_oop;
17291 : :
17292 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17293 : : ciphertext,
17294 : : tdata->ciphertext.data,
17295 : : fragsz,
17296 : : "Ciphertext data not as expected");
17297 : :
17298 : 1 : buf = ut_params->op->sym->m_src->next;
17299 [ + - ]: 1 : if (oop)
17300 : 1 : buf = ut_params->op->sym->m_dst->next;
17301 : :
17302 : : unsigned int off = fragsz;
17303 : :
17304 : : ecx = 0;
17305 [ - + ]: 1 : while (buf) {
17306 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
17307 : : uint8_t *);
17308 : :
17309 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17310 : : ciphertext,
17311 : : tdata->ciphertext.data + off,
17312 : : to_trn_tbl[ecx],
17313 : : "Ciphertext data not as expected");
17314 : :
17315 : 0 : off += to_trn_tbl[ecx++];
17316 : 0 : buf = buf->next;
17317 : : }
17318 : :
17319 : : auth_tag = digest_mem;
17320 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17321 : : auth_tag,
17322 : : tdata->auth_tag.data,
17323 : : tdata->auth_tag.len,
17324 : : "Generated auth tag not as expected");
17325 : :
17326 : : return 0;
17327 : : }
17328 : :
17329 : : static int
17330 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17331 : : {
17332 : 1 : return test_authenticated_encryption_SGL(
17333 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17334 : : }
17335 : :
17336 : : static int
17337 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17338 : : {
17339 : 1 : return test_authenticated_encryption_SGL(
17340 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17341 : : }
17342 : :
17343 : : static int
17344 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17345 : : {
17346 : 1 : return test_authenticated_encryption_SGL(
17347 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
17348 : : gcm_test_case_8.plaintext.len);
17349 : : }
17350 : :
17351 : : static int
17352 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17353 : : {
17354 : : /* This test is not for OPENSSL PMD */
17355 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17356 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17357 : : return TEST_SKIPPED;
17358 : :
17359 : 0 : return test_authenticated_encryption_SGL(
17360 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17361 : : }
17362 : :
17363 : : static int
17364 : : test_authentication_verify_fail_when_data_corrupted(
17365 : : struct crypto_testsuite_params *ts_params,
17366 : : struct crypto_unittest_params *ut_params,
17367 : : const struct test_crypto_vector *reference)
17368 : : {
17369 : 1 : return test_authentication_verify_fail_when_data_corruption(
17370 : : ts_params, ut_params, reference, 1);
17371 : : }
17372 : :
17373 : : static int
17374 : : test_authentication_verify_fail_when_tag_corrupted(
17375 : : struct crypto_testsuite_params *ts_params,
17376 : : struct crypto_unittest_params *ut_params,
17377 : : const struct test_crypto_vector *reference)
17378 : : {
17379 : 1 : return test_authentication_verify_fail_when_data_corruption(
17380 : : ts_params, ut_params, reference, 0);
17381 : : }
17382 : :
17383 : : static int
17384 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
17385 : : struct crypto_testsuite_params *ts_params,
17386 : : struct crypto_unittest_params *ut_params,
17387 : : const struct test_crypto_vector *reference)
17388 : : {
17389 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17390 : : ts_params, ut_params, reference, 1);
17391 : : }
17392 : :
17393 : : static int
17394 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
17395 : : struct crypto_testsuite_params *ts_params,
17396 : : struct crypto_unittest_params *ut_params,
17397 : : const struct test_crypto_vector *reference)
17398 : : {
17399 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17400 : : ts_params, ut_params, reference, 0);
17401 : : }
17402 : :
17403 : : static int
17404 : : test_authenticated_decryption_fail_when_data_corrupted(
17405 : : struct crypto_testsuite_params *ts_params,
17406 : : struct crypto_unittest_params *ut_params,
17407 : : const struct test_crypto_vector *reference)
17408 : : {
17409 : 1 : return test_authenticated_decryption_fail_when_corruption(
17410 : : ts_params, ut_params, reference, 1);
17411 : : }
17412 : :
17413 : : static int
17414 : : test_authenticated_decryption_fail_when_tag_corrupted(
17415 : : struct crypto_testsuite_params *ts_params,
17416 : : struct crypto_unittest_params *ut_params,
17417 : : const struct test_crypto_vector *reference)
17418 : : {
17419 : 1 : return test_authenticated_decryption_fail_when_corruption(
17420 : : ts_params, ut_params, reference, 0);
17421 : : }
17422 : :
17423 : : static int
17424 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17425 : : {
17426 : 1 : return test_authentication_verify_fail_when_data_corrupted(
17427 : : &testsuite_params, &unittest_params,
17428 : : &hmac_sha1_test_crypto_vector);
17429 : : }
17430 : :
17431 : : static int
17432 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17433 : : {
17434 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
17435 : : &testsuite_params, &unittest_params,
17436 : : &hmac_sha1_test_crypto_vector);
17437 : : }
17438 : :
17439 : : static int
17440 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17441 : : {
17442 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
17443 : : &testsuite_params, &unittest_params,
17444 : : &aes128_gmac_test_vector);
17445 : : }
17446 : :
17447 : : static int
17448 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17449 : : {
17450 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17451 : : &testsuite_params, &unittest_params,
17452 : : &aes128_gmac_test_vector);
17453 : : }
17454 : :
17455 : : static int
17456 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17457 : : {
17458 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
17459 : : &testsuite_params,
17460 : : &unittest_params,
17461 : : &aes128cbc_hmac_sha1_test_vector);
17462 : : }
17463 : :
17464 : : static int
17465 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17466 : : {
17467 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
17468 : : &testsuite_params,
17469 : : &unittest_params,
17470 : : &aes128cbc_hmac_sha1_test_vector);
17471 : : }
17472 : :
17473 : : static int
17474 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17475 : : {
17476 : 1 : return test_authenticated_encrypt_with_esn(
17477 : : &testsuite_params,
17478 : : &unittest_params,
17479 : : &aes128cbc_hmac_sha1_aad_test_vector);
17480 : : }
17481 : :
17482 : : static int
17483 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17484 : : {
17485 : 1 : return test_authenticated_decrypt_with_esn(
17486 : : &testsuite_params,
17487 : : &unittest_params,
17488 : : &aes128cbc_hmac_sha1_aad_test_vector);
17489 : : }
17490 : :
17491 : : static int
17492 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17493 : : {
17494 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17495 : : }
17496 : :
17497 : : static int
17498 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17499 : : {
17500 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17501 : : }
17502 : :
17503 : : static int
17504 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17505 : : {
17506 : 0 : return test_authenticated_encryption_SGL(
17507 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17508 : : chacha20_poly1305_case_2.plaintext.len);
17509 : : }
17510 : :
17511 : : #ifdef RTE_CRYPTO_SCHEDULER
17512 : :
17513 : : /* global AESNI worker IDs for the scheduler test */
17514 : : uint8_t aesni_ids[2];
17515 : :
17516 : : static int
17517 : 0 : scheduler_testsuite_setup(void)
17518 : : {
17519 : : uint32_t i = 0;
17520 : : int32_t nb_devs, ret;
17521 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
17522 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17523 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
17524 : : uint16_t worker_core_count = 0;
17525 : : uint16_t socket_id = 0;
17526 : :
17527 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17528 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17529 : :
17530 : : /* Identify the Worker Cores
17531 : : * Use 2 worker cores for the device args
17532 : : */
17533 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
17534 [ # # ]: 0 : if (worker_core_count > 1)
17535 : : break;
17536 : : snprintf(vdev_args, sizeof(vdev_args),
17537 : : "%s%d", temp_str, i);
17538 : : strcpy(temp_str, vdev_args);
17539 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
17540 : 0 : worker_core_count++;
17541 : 0 : socket_id = rte_lcore_to_socket_id(i);
17542 : : }
17543 [ # # ]: 0 : if (worker_core_count != 2) {
17544 : 0 : RTE_LOG(ERR, USER1,
17545 : : "Cryptodev scheduler test require at least "
17546 : : "two worker cores to run. "
17547 : : "Please use the correct coremask.\n");
17548 : 0 : return TEST_FAILED;
17549 : : }
17550 : : strcpy(temp_str, vdev_args);
17551 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
17552 : : temp_str, socket_id);
17553 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17554 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
17555 : 0 : rte_cryptodev_driver_id_get(
17556 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17557 [ # # ]: 0 : if (nb_devs < 1) {
17558 : 0 : ret = rte_vdev_init(
17559 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17560 : : vdev_args);
17561 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17562 : : "Failed to create instance %u of pmd : %s",
17563 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17564 : : }
17565 : : }
17566 : 0 : return testsuite_setup();
17567 : : }
17568 : :
17569 : : static int
17570 : 0 : test_scheduler_attach_worker_op(void)
17571 : : {
17572 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17573 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17574 : : uint32_t i, nb_devs_attached = 0;
17575 : : int ret;
17576 : : char vdev_name[32];
17577 : 0 : unsigned int count = rte_cryptodev_count();
17578 : :
17579 : : /* create 2 AESNI_MB vdevs on top of existing devices */
17580 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17581 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17582 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17583 : : i);
17584 : 0 : ret = rte_vdev_init(vdev_name, NULL);
17585 : :
17586 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17587 : : "Failed to create instance %u of"
17588 : : " pmd : %s",
17589 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17590 : :
17591 : : if (ret < 0) {
17592 : : RTE_LOG(ERR, USER1,
17593 : : "Failed to create 2 AESNI MB PMDs.\n");
17594 : : return TEST_SKIPPED;
17595 : : }
17596 : : }
17597 : :
17598 : : /* attach 2 AESNI_MB cdevs */
17599 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17600 : : struct rte_cryptodev_info info;
17601 : : unsigned int session_size;
17602 : :
17603 : 0 : rte_cryptodev_info_get(i, &info);
17604 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
17605 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17606 : 0 : continue;
17607 : :
17608 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
17609 : : /*
17610 : : * Create the session mempool again, since now there are new devices
17611 : : * to use the mempool.
17612 : : */
17613 [ # # ]: 0 : if (ts_params->session_mpool) {
17614 : 0 : rte_mempool_free(ts_params->session_mpool);
17615 : 0 : ts_params->session_mpool = NULL;
17616 : : }
17617 : :
17618 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
17619 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17620 : 0 : RTE_LOG(ERR, USER1,
17621 : : "Device does not support "
17622 : : "at least %u sessions\n",
17623 : : MAX_NB_SESSIONS);
17624 : 0 : return TEST_FAILED;
17625 : : }
17626 : : /*
17627 : : * Create mempool with maximum number of sessions,
17628 : : * to include the session headers
17629 : : */
17630 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
17631 : 0 : ts_params->session_mpool =
17632 : 0 : rte_cryptodev_sym_session_pool_create(
17633 : : "test_sess_mp",
17634 : : MAX_NB_SESSIONS, session_size,
17635 : : 0, 0, SOCKET_ID_ANY);
17636 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17637 : : "session mempool allocation failed");
17638 : : }
17639 : :
17640 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
17641 : :
17642 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17643 : : (uint8_t)i);
17644 : :
17645 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17646 : : "Failed to attach device %u of pmd : %s", i,
17647 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17648 : :
17649 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
17650 : :
17651 : 0 : nb_devs_attached++;
17652 : : }
17653 : :
17654 : : return 0;
17655 : : }
17656 : :
17657 : : static int
17658 : 0 : test_scheduler_detach_worker_op(void)
17659 : : {
17660 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17661 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17662 : : uint32_t i;
17663 : : int ret;
17664 : :
17665 [ # # ]: 0 : for (i = 0; i < 2; i++) {
17666 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17667 : 0 : aesni_ids[i]);
17668 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17669 : : "Failed to detach device %u", aesni_ids[i]);
17670 : : }
17671 : :
17672 : : return 0;
17673 : : }
17674 : :
17675 : : static int
17676 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17677 : : {
17678 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17679 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17680 : : /* set mode */
17681 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
17682 : : scheduler_mode);
17683 : : }
17684 : :
17685 : : static int
17686 : 0 : test_scheduler_mode_roundrobin_op(void)
17687 : : {
17688 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17689 : : 0, "Failed to set roundrobin mode");
17690 : : return 0;
17691 : :
17692 : : }
17693 : :
17694 : : static int
17695 : 0 : test_scheduler_mode_multicore_op(void)
17696 : : {
17697 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17698 : : 0, "Failed to set multicore mode");
17699 : :
17700 : : return 0;
17701 : : }
17702 : :
17703 : : static int
17704 : 0 : test_scheduler_mode_failover_op(void)
17705 : : {
17706 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17707 : : 0, "Failed to set failover mode");
17708 : :
17709 : : return 0;
17710 : : }
17711 : :
17712 : : static int
17713 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
17714 : : {
17715 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17716 : : 0, "Failed to set pktsize mode");
17717 : :
17718 : : return 0;
17719 : : }
17720 : :
17721 : : static int
17722 : 0 : scheduler_multicore_testsuite_setup(void)
17723 : : {
17724 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17725 : : return TEST_SKIPPED;
17726 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17727 : 0 : return TEST_SKIPPED;
17728 : : return 0;
17729 : : }
17730 : :
17731 : : static int
17732 : 0 : scheduler_roundrobin_testsuite_setup(void)
17733 : : {
17734 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17735 : : return TEST_SKIPPED;
17736 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17737 : 0 : return TEST_SKIPPED;
17738 : : return 0;
17739 : : }
17740 : :
17741 : : static int
17742 : 0 : scheduler_failover_testsuite_setup(void)
17743 : : {
17744 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17745 : : return TEST_SKIPPED;
17746 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17747 : 0 : return TEST_SKIPPED;
17748 : : return 0;
17749 : : }
17750 : :
17751 : : static int
17752 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
17753 : : {
17754 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17755 : : return TEST_SKIPPED;
17756 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17757 : 0 : return TEST_SKIPPED;
17758 : : return 0;
17759 : : }
17760 : :
17761 : : static void
17762 : 0 : scheduler_mode_testsuite_teardown(void)
17763 : : {
17764 : 0 : test_scheduler_detach_worker_op();
17765 : 0 : }
17766 : :
17767 : : #endif /* RTE_CRYPTO_SCHEDULER */
17768 : :
17769 : : static struct unit_test_suite end_testsuite = {
17770 : : .suite_name = NULL,
17771 : : .setup = NULL,
17772 : : .teardown = NULL,
17773 : : .unit_test_suites = NULL
17774 : : };
17775 : :
17776 : : #ifdef RTE_LIB_SECURITY
17777 : : static struct unit_test_suite ipsec_proto_testsuite = {
17778 : : .suite_name = "IPsec Proto Unit Test Suite",
17779 : : .setup = ipsec_proto_testsuite_setup,
17780 : : .unit_test_cases = {
17781 : : TEST_CASE_NAMED_WITH_DATA(
17782 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17783 : : ut_setup_security, ut_teardown,
17784 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17785 : : TEST_CASE_NAMED_WITH_DATA(
17786 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17787 : : ut_setup_security, ut_teardown,
17788 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17789 : : TEST_CASE_NAMED_WITH_DATA(
17790 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17791 : : ut_setup_security, ut_teardown,
17792 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17793 : : TEST_CASE_NAMED_WITH_DATA(
17794 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17795 : : ut_setup_security, ut_teardown,
17796 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17797 : : TEST_CASE_NAMED_WITH_DATA(
17798 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17799 : : ut_setup_security, ut_teardown,
17800 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17801 : : TEST_CASE_NAMED_WITH_DATA(
17802 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17803 : : ut_setup_security, ut_teardown,
17804 : : test_ipsec_proto_known_vec,
17805 : : &pkt_aes_128_cbc_md5),
17806 : : TEST_CASE_NAMED_WITH_DATA(
17807 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17808 : : ut_setup_security, ut_teardown,
17809 : : test_ipsec_proto_known_vec,
17810 : : &pkt_aes_128_cbc_hmac_sha256),
17811 : : TEST_CASE_NAMED_WITH_DATA(
17812 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17813 : : ut_setup_security, ut_teardown,
17814 : : test_ipsec_proto_known_vec,
17815 : : &pkt_aes_128_cbc_hmac_sha384),
17816 : : TEST_CASE_NAMED_WITH_DATA(
17817 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17818 : : ut_setup_security, ut_teardown,
17819 : : test_ipsec_proto_known_vec,
17820 : : &pkt_aes_128_cbc_hmac_sha512),
17821 : : TEST_CASE_NAMED_WITH_DATA(
17822 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17823 : : ut_setup_security, ut_teardown,
17824 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
17825 : : TEST_CASE_NAMED_WITH_DATA(
17826 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17827 : : ut_setup_security, ut_teardown,
17828 : : test_ipsec_proto_known_vec,
17829 : : &pkt_aes_128_cbc_hmac_sha256_v6),
17830 : : TEST_CASE_NAMED_WITH_DATA(
17831 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17832 : : ut_setup_security, ut_teardown,
17833 : : test_ipsec_proto_known_vec,
17834 : : &pkt_null_aes_xcbc),
17835 : : TEST_CASE_NAMED_WITH_DATA(
17836 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17837 : : ut_setup_security, ut_teardown,
17838 : : test_ipsec_proto_known_vec,
17839 : : &pkt_des_cbc_hmac_sha256),
17840 : : TEST_CASE_NAMED_WITH_DATA(
17841 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17842 : : ut_setup_security, ut_teardown,
17843 : : test_ipsec_proto_known_vec,
17844 : : &pkt_des_cbc_hmac_sha384),
17845 : : TEST_CASE_NAMED_WITH_DATA(
17846 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17847 : : ut_setup_security, ut_teardown,
17848 : : test_ipsec_proto_known_vec,
17849 : : &pkt_des_cbc_hmac_sha512),
17850 : : TEST_CASE_NAMED_WITH_DATA(
17851 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17852 : : ut_setup_security, ut_teardown,
17853 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
17854 : : TEST_CASE_NAMED_WITH_DATA(
17855 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17856 : : ut_setup_security, ut_teardown,
17857 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
17858 : : TEST_CASE_NAMED_WITH_DATA(
17859 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17860 : : ut_setup_security, ut_teardown,
17861 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
17862 : : TEST_CASE_NAMED_WITH_DATA(
17863 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17864 : : ut_setup_security, ut_teardown,
17865 : : test_ipsec_proto_known_vec,
17866 : : &pkt_des_cbc_hmac_sha256_v6),
17867 : : TEST_CASE_NAMED_WITH_DATA(
17868 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17869 : : ut_setup_security, ut_teardown,
17870 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
17871 : : TEST_CASE_NAMED_WITH_DATA(
17872 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17873 : : ut_setup_security, ut_teardown,
17874 : : test_ipsec_proto_known_vec,
17875 : : &pkt_ah_tunnel_sha256),
17876 : : TEST_CASE_NAMED_WITH_DATA(
17877 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17878 : : ut_setup_security, ut_teardown,
17879 : : test_ipsec_proto_known_vec,
17880 : : &pkt_ah_transport_sha256),
17881 : : TEST_CASE_NAMED_WITH_DATA(
17882 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17883 : : ut_setup_security, ut_teardown,
17884 : : test_ipsec_proto_known_vec,
17885 : : &pkt_ah_ipv4_aes_gmac_128),
17886 : : TEST_CASE_NAMED_WITH_DATA(
17887 : : "Outbound fragmented packet",
17888 : : ut_setup_security, ut_teardown,
17889 : : test_ipsec_proto_known_vec_fragmented,
17890 : : &pkt_aes_128_gcm_frag),
17891 : : TEST_CASE_NAMED_WITH_DATA(
17892 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17893 : : ut_setup_security, ut_teardown,
17894 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
17895 : : TEST_CASE_NAMED_WITH_DATA(
17896 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17897 : : ut_setup_security, ut_teardown,
17898 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
17899 : : TEST_CASE_NAMED_WITH_DATA(
17900 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17901 : : ut_setup_security, ut_teardown,
17902 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
17903 : : TEST_CASE_NAMED_WITH_DATA(
17904 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17905 : : ut_setup_security, ut_teardown,
17906 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
17907 : : TEST_CASE_NAMED_WITH_DATA(
17908 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
17909 : : ut_setup_security, ut_teardown,
17910 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
17911 : : TEST_CASE_NAMED_WITH_DATA(
17912 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17913 : : ut_setup_security, ut_teardown,
17914 : : test_ipsec_proto_known_vec_inb,
17915 : : &pkt_aes_128_cbc_md5),
17916 : : TEST_CASE_NAMED_WITH_DATA(
17917 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17918 : : ut_setup_security, ut_teardown,
17919 : : test_ipsec_proto_known_vec_inb,
17920 : : &pkt_aes_128_cbc_hmac_sha256),
17921 : : TEST_CASE_NAMED_WITH_DATA(
17922 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17923 : : ut_setup_security, ut_teardown,
17924 : : test_ipsec_proto_known_vec_inb,
17925 : : &pkt_aes_128_cbc_hmac_sha384),
17926 : : TEST_CASE_NAMED_WITH_DATA(
17927 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17928 : : ut_setup_security, ut_teardown,
17929 : : test_ipsec_proto_known_vec_inb,
17930 : : &pkt_aes_128_cbc_hmac_sha512),
17931 : : TEST_CASE_NAMED_WITH_DATA(
17932 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17933 : : ut_setup_security, ut_teardown,
17934 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
17935 : : TEST_CASE_NAMED_WITH_DATA(
17936 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17937 : : ut_setup_security, ut_teardown,
17938 : : test_ipsec_proto_known_vec_inb,
17939 : : &pkt_aes_128_cbc_hmac_sha256_v6),
17940 : : TEST_CASE_NAMED_WITH_DATA(
17941 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17942 : : ut_setup_security, ut_teardown,
17943 : : test_ipsec_proto_known_vec_inb,
17944 : : &pkt_null_aes_xcbc),
17945 : : TEST_CASE_NAMED_WITH_DATA(
17946 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17947 : : ut_setup_security, ut_teardown,
17948 : : test_ipsec_proto_known_vec_inb,
17949 : : &pkt_des_cbc_hmac_sha256),
17950 : : TEST_CASE_NAMED_WITH_DATA(
17951 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17952 : : ut_setup_security, ut_teardown,
17953 : : test_ipsec_proto_known_vec_inb,
17954 : : &pkt_des_cbc_hmac_sha384),
17955 : : TEST_CASE_NAMED_WITH_DATA(
17956 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17957 : : ut_setup_security, ut_teardown,
17958 : : test_ipsec_proto_known_vec_inb,
17959 : : &pkt_des_cbc_hmac_sha512),
17960 : : TEST_CASE_NAMED_WITH_DATA(
17961 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17962 : : ut_setup_security, ut_teardown,
17963 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
17964 : : TEST_CASE_NAMED_WITH_DATA(
17965 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17966 : : ut_setup_security, ut_teardown,
17967 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
17968 : : TEST_CASE_NAMED_WITH_DATA(
17969 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17970 : : ut_setup_security, ut_teardown,
17971 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
17972 : : TEST_CASE_NAMED_WITH_DATA(
17973 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17974 : : ut_setup_security, ut_teardown,
17975 : : test_ipsec_proto_known_vec_inb,
17976 : : &pkt_des_cbc_hmac_sha256_v6),
17977 : : TEST_CASE_NAMED_WITH_DATA(
17978 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17979 : : ut_setup_security, ut_teardown,
17980 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
17981 : : TEST_CASE_NAMED_WITH_DATA(
17982 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17983 : : ut_setup_security, ut_teardown,
17984 : : test_ipsec_proto_known_vec_inb,
17985 : : &pkt_ah_tunnel_sha256),
17986 : : TEST_CASE_NAMED_WITH_DATA(
17987 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17988 : : ut_setup_security, ut_teardown,
17989 : : test_ipsec_proto_known_vec_inb,
17990 : : &pkt_ah_transport_sha256),
17991 : : TEST_CASE_NAMED_WITH_DATA(
17992 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17993 : : ut_setup_security, ut_teardown,
17994 : : test_ipsec_proto_known_vec_inb,
17995 : : &pkt_ah_ipv4_aes_gmac_128),
17996 : : TEST_CASE_NAMED_ST(
17997 : : "Combined test alg list",
17998 : : ut_setup_security, ut_teardown,
17999 : : test_ipsec_proto_display_list),
18000 : : TEST_CASE_NAMED_ST(
18001 : : "Combined test alg list (AH)",
18002 : : ut_setup_security, ut_teardown,
18003 : : test_ipsec_proto_ah_tunnel_ipv4),
18004 : : TEST_CASE_NAMED_ST(
18005 : : "IV generation",
18006 : : ut_setup_security, ut_teardown,
18007 : : test_ipsec_proto_iv_gen),
18008 : : TEST_CASE_NAMED_ST(
18009 : : "UDP encapsulation",
18010 : : ut_setup_security, ut_teardown,
18011 : : test_ipsec_proto_udp_encap),
18012 : : TEST_CASE_NAMED_ST(
18013 : : "UDP encapsulation with custom ports",
18014 : : ut_setup_security, ut_teardown,
18015 : : test_ipsec_proto_udp_encap_custom_ports),
18016 : : TEST_CASE_NAMED_ST(
18017 : : "UDP encapsulation ports verification test",
18018 : : ut_setup_security, ut_teardown,
18019 : : test_ipsec_proto_udp_ports_verify),
18020 : : TEST_CASE_NAMED_ST(
18021 : : "SA expiry packets soft",
18022 : : ut_setup_security, ut_teardown,
18023 : : test_ipsec_proto_sa_exp_pkts_soft),
18024 : : TEST_CASE_NAMED_ST(
18025 : : "SA expiry packets hard",
18026 : : ut_setup_security, ut_teardown,
18027 : : test_ipsec_proto_sa_exp_pkts_hard),
18028 : : TEST_CASE_NAMED_ST(
18029 : : "Negative test: ICV corruption",
18030 : : ut_setup_security, ut_teardown,
18031 : : test_ipsec_proto_err_icv_corrupt),
18032 : : TEST_CASE_NAMED_ST(
18033 : : "Tunnel dst addr verification",
18034 : : ut_setup_security, ut_teardown,
18035 : : test_ipsec_proto_tunnel_dst_addr_verify),
18036 : : TEST_CASE_NAMED_ST(
18037 : : "Tunnel src and dst addr verification",
18038 : : ut_setup_security, ut_teardown,
18039 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
18040 : : TEST_CASE_NAMED_ST(
18041 : : "Inner IP checksum",
18042 : : ut_setup_security, ut_teardown,
18043 : : test_ipsec_proto_inner_ip_csum),
18044 : : TEST_CASE_NAMED_ST(
18045 : : "Inner L4 checksum",
18046 : : ut_setup_security, ut_teardown,
18047 : : test_ipsec_proto_inner_l4_csum),
18048 : : TEST_CASE_NAMED_ST(
18049 : : "Tunnel IPv4 in IPv4",
18050 : : ut_setup_security, ut_teardown,
18051 : : test_ipsec_proto_tunnel_v4_in_v4),
18052 : : TEST_CASE_NAMED_ST(
18053 : : "Tunnel IPv6 in IPv6",
18054 : : ut_setup_security, ut_teardown,
18055 : : test_ipsec_proto_tunnel_v6_in_v6),
18056 : : TEST_CASE_NAMED_ST(
18057 : : "Tunnel IPv4 in IPv6",
18058 : : ut_setup_security, ut_teardown,
18059 : : test_ipsec_proto_tunnel_v4_in_v6),
18060 : : TEST_CASE_NAMED_ST(
18061 : : "Tunnel IPv6 in IPv4",
18062 : : ut_setup_security, ut_teardown,
18063 : : test_ipsec_proto_tunnel_v6_in_v4),
18064 : : TEST_CASE_NAMED_ST(
18065 : : "Transport IPv4",
18066 : : ut_setup_security, ut_teardown,
18067 : : test_ipsec_proto_transport_v4),
18068 : : TEST_CASE_NAMED_ST(
18069 : : "AH transport IPv4",
18070 : : ut_setup_security, ut_teardown,
18071 : : test_ipsec_proto_ah_transport_ipv4),
18072 : : TEST_CASE_NAMED_ST(
18073 : : "Transport l4 checksum",
18074 : : ut_setup_security, ut_teardown,
18075 : : test_ipsec_proto_transport_l4_csum),
18076 : : TEST_CASE_NAMED_ST(
18077 : : "Statistics: success",
18078 : : ut_setup_security, ut_teardown,
18079 : : test_ipsec_proto_stats),
18080 : : TEST_CASE_NAMED_ST(
18081 : : "Fragmented packet",
18082 : : ut_setup_security, ut_teardown,
18083 : : test_ipsec_proto_pkt_fragment),
18084 : : TEST_CASE_NAMED_ST(
18085 : : "Tunnel header copy DF (inner 0)",
18086 : : ut_setup_security, ut_teardown,
18087 : : test_ipsec_proto_copy_df_inner_0),
18088 : : TEST_CASE_NAMED_ST(
18089 : : "Tunnel header copy DF (inner 1)",
18090 : : ut_setup_security, ut_teardown,
18091 : : test_ipsec_proto_copy_df_inner_1),
18092 : : TEST_CASE_NAMED_ST(
18093 : : "Tunnel header set DF 0 (inner 1)",
18094 : : ut_setup_security, ut_teardown,
18095 : : test_ipsec_proto_set_df_0_inner_1),
18096 : : TEST_CASE_NAMED_ST(
18097 : : "Tunnel header set DF 1 (inner 0)",
18098 : : ut_setup_security, ut_teardown,
18099 : : test_ipsec_proto_set_df_1_inner_0),
18100 : : TEST_CASE_NAMED_ST(
18101 : : "Tunnel header IPv4 copy DSCP (inner 0)",
18102 : : ut_setup_security, ut_teardown,
18103 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
18104 : : TEST_CASE_NAMED_ST(
18105 : : "Tunnel header IPv4 copy DSCP (inner 1)",
18106 : : ut_setup_security, ut_teardown,
18107 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
18108 : : TEST_CASE_NAMED_ST(
18109 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
18110 : : ut_setup_security, ut_teardown,
18111 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
18112 : : TEST_CASE_NAMED_ST(
18113 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
18114 : : ut_setup_security, ut_teardown,
18115 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
18116 : : TEST_CASE_NAMED_ST(
18117 : : "Tunnel header IPv6 copy DSCP (inner 0)",
18118 : : ut_setup_security, ut_teardown,
18119 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
18120 : : TEST_CASE_NAMED_ST(
18121 : : "Tunnel header IPv6 copy DSCP (inner 1)",
18122 : : ut_setup_security, ut_teardown,
18123 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
18124 : : TEST_CASE_NAMED_ST(
18125 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
18126 : : ut_setup_security, ut_teardown,
18127 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
18128 : : TEST_CASE_NAMED_ST(
18129 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
18130 : : ut_setup_security, ut_teardown,
18131 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
18132 : : TEST_CASE_NAMED_WITH_DATA(
18133 : : "Antireplay with window size 1024",
18134 : : ut_setup_security, ut_teardown,
18135 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
18136 : : TEST_CASE_NAMED_WITH_DATA(
18137 : : "Antireplay with window size 2048",
18138 : : ut_setup_security, ut_teardown,
18139 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
18140 : : TEST_CASE_NAMED_WITH_DATA(
18141 : : "Antireplay with window size 4096",
18142 : : ut_setup_security, ut_teardown,
18143 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
18144 : : TEST_CASE_NAMED_WITH_DATA(
18145 : : "ESN and Antireplay with window size 1024",
18146 : : ut_setup_security, ut_teardown,
18147 : : test_ipsec_proto_pkt_esn_antireplay1024,
18148 : : &pkt_aes_128_gcm),
18149 : : TEST_CASE_NAMED_WITH_DATA(
18150 : : "ESN and Antireplay with window size 2048",
18151 : : ut_setup_security, ut_teardown,
18152 : : test_ipsec_proto_pkt_esn_antireplay2048,
18153 : : &pkt_aes_128_gcm),
18154 : : TEST_CASE_NAMED_WITH_DATA(
18155 : : "ESN and Antireplay with window size 4096",
18156 : : ut_setup_security, ut_teardown,
18157 : : test_ipsec_proto_pkt_esn_antireplay4096,
18158 : : &pkt_aes_128_gcm),
18159 : : TEST_CASE_NAMED_ST(
18160 : : "Tunnel header IPv4 decrement inner TTL",
18161 : : ut_setup_security, ut_teardown,
18162 : : test_ipsec_proto_ipv4_ttl_decrement),
18163 : : TEST_CASE_NAMED_ST(
18164 : : "Tunnel header IPv6 decrement inner hop limit",
18165 : : ut_setup_security, ut_teardown,
18166 : : test_ipsec_proto_ipv6_hop_limit_decrement),
18167 : : TEST_CASE_NAMED_ST(
18168 : : "Multi-segmented mode",
18169 : : ut_setup_security, ut_teardown,
18170 : : test_ipsec_proto_sgl),
18171 : : TEST_CASE_NAMED_ST(
18172 : : "Multi-segmented external mbuf mode",
18173 : : ut_setup_security, ut_teardown,
18174 : : test_ipsec_proto_sgl_ext_mbuf),
18175 : : TEST_CASE_NAMED_WITH_DATA(
18176 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
18177 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18178 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
18179 : : TEST_CASES_END() /**< NULL terminate unit test array */
18180 : : }
18181 : : };
18182 : :
18183 : : static struct unit_test_suite pdcp_proto_testsuite = {
18184 : : .suite_name = "PDCP Proto Unit Test Suite",
18185 : : .setup = pdcp_proto_testsuite_setup,
18186 : : .unit_test_cases = {
18187 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
18188 : : test_PDCP_PROTO_all),
18189 : : TEST_CASES_END() /**< NULL terminate unit test array */
18190 : : }
18191 : : };
18192 : :
18193 : : static struct unit_test_suite tls12_record_proto_testsuite = {
18194 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
18195 : : .setup = tls_record_proto_testsuite_setup,
18196 : : .unit_test_cases = {
18197 : : TEST_CASE_NAMED_WITH_DATA(
18198 : : "Write record known vector AES-GCM-128 (vector 1)",
18199 : : ut_setup_security, ut_teardown,
18200 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
18201 : : TEST_CASE_NAMED_WITH_DATA(
18202 : : "Write record known vector AES-GCM-128 (vector 2)",
18203 : : ut_setup_security, ut_teardown,
18204 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
18205 : : TEST_CASE_NAMED_WITH_DATA(
18206 : : "Write record known vector AES-GCM-256",
18207 : : ut_setup_security, ut_teardown,
18208 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
18209 : : TEST_CASE_NAMED_WITH_DATA(
18210 : : "Write record known vector AES-CBC-128-SHA1",
18211 : : ut_setup_security, ut_teardown,
18212 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
18213 : : TEST_CASE_NAMED_WITH_DATA(
18214 : : "Write record known vector AES-128-CBC-SHA256",
18215 : : ut_setup_security, ut_teardown,
18216 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
18217 : : TEST_CASE_NAMED_WITH_DATA(
18218 : : "Write record known vector AES-256-CBC-SHA1",
18219 : : ut_setup_security, ut_teardown,
18220 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
18221 : : TEST_CASE_NAMED_WITH_DATA(
18222 : : "Write record known vector AES-256-CBC-SHA256",
18223 : : ut_setup_security, ut_teardown,
18224 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
18225 : : TEST_CASE_NAMED_WITH_DATA(
18226 : : "Write record known vector AES-256-CBC-SHA384",
18227 : : ut_setup_security, ut_teardown,
18228 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
18229 : : TEST_CASE_NAMED_WITH_DATA(
18230 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18231 : : ut_setup_security, ut_teardown,
18232 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
18233 : : TEST_CASE_NAMED_WITH_DATA(
18234 : : "Write record known vector NULL-SHA1-HMAC",
18235 : : ut_setup_security, ut_teardown,
18236 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
18237 : : TEST_CASE_NAMED_WITH_DATA(
18238 : : "Write record known vector CHACHA20-POLY1305",
18239 : : ut_setup_security, ut_teardown,
18240 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
18241 : :
18242 : : TEST_CASE_NAMED_WITH_DATA(
18243 : : "Read record known vector AES-GCM-128 (vector 1)",
18244 : : ut_setup_security, ut_teardown,
18245 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
18246 : : TEST_CASE_NAMED_WITH_DATA(
18247 : : "Read record known vector AES-GCM-128 (vector 2)",
18248 : : ut_setup_security, ut_teardown,
18249 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
18250 : : TEST_CASE_NAMED_WITH_DATA(
18251 : : "Read record known vector AES-GCM-256",
18252 : : ut_setup_security, ut_teardown,
18253 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
18254 : : TEST_CASE_NAMED_WITH_DATA(
18255 : : "Read record known vector AES-128-CBC-SHA1",
18256 : : ut_setup_security, ut_teardown,
18257 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
18258 : : TEST_CASE_NAMED_WITH_DATA(
18259 : : "Read record known vector AES-128-CBC-SHA256",
18260 : : ut_setup_security, ut_teardown,
18261 : : test_tls_record_proto_known_vec_read,
18262 : : &tls_test_data_aes_128_cbc_sha256_hmac),
18263 : : TEST_CASE_NAMED_WITH_DATA(
18264 : : "Read record known vector AES-256-CBC-SHA1",
18265 : : ut_setup_security, ut_teardown,
18266 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
18267 : : TEST_CASE_NAMED_WITH_DATA(
18268 : : "Read record known vector AES-256-CBC-SHA256",
18269 : : ut_setup_security, ut_teardown,
18270 : : test_tls_record_proto_known_vec_read,
18271 : : &tls_test_data_aes_256_cbc_sha256_hmac),
18272 : : TEST_CASE_NAMED_WITH_DATA(
18273 : : "Read record known vector AES-256-CBC-SHA384",
18274 : : ut_setup_security, ut_teardown,
18275 : : test_tls_record_proto_known_vec_read,
18276 : : &tls_test_data_aes_256_cbc_sha384_hmac),
18277 : : TEST_CASE_NAMED_WITH_DATA(
18278 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18279 : : ut_setup_security, ut_teardown,
18280 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18281 : : TEST_CASE_NAMED_WITH_DATA(
18282 : : "Read record known vector NULL-SHA1-HMAC",
18283 : : ut_setup_security, ut_teardown,
18284 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18285 : : TEST_CASE_NAMED_WITH_DATA(
18286 : : "Read record known vector CHACHA20-POLY1305",
18287 : : ut_setup_security, ut_teardown,
18288 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18289 : :
18290 : : TEST_CASE_NAMED_ST(
18291 : : "Combined test alg list",
18292 : : ut_setup_security, ut_teardown,
18293 : : test_tls_1_2_record_proto_display_list),
18294 : : TEST_CASE_NAMED_ST(
18295 : : "Data walkthrough combined test alg list",
18296 : : ut_setup_security, ut_teardown,
18297 : : test_tls_1_2_record_proto_data_walkthrough),
18298 : : TEST_CASE_NAMED_ST(
18299 : : "Multi-segmented mode",
18300 : : ut_setup_security, ut_teardown,
18301 : : test_tls_1_2_record_proto_sgl),
18302 : : TEST_CASE_NAMED_ST(
18303 : : "Multi-segmented mode data walkthrough",
18304 : : ut_setup_security, ut_teardown,
18305 : : test_tls_1_2_record_proto_sgl_data_walkthrough),
18306 : : TEST_CASE_NAMED_ST(
18307 : : "Multi-segmented mode out of place",
18308 : : ut_setup_security, ut_teardown,
18309 : : test_tls_1_2_record_proto_sgl_oop),
18310 : : TEST_CASE_NAMED_ST(
18311 : : "TLS packet header corruption",
18312 : : ut_setup_security, ut_teardown,
18313 : : test_tls_record_proto_corrupt_pkt),
18314 : : TEST_CASE_NAMED_ST(
18315 : : "Custom content type",
18316 : : ut_setup_security, ut_teardown,
18317 : : test_tls_record_proto_custom_content_type),
18318 : : TEST_CASE_NAMED_ST(
18319 : : "Zero len TLS record with content type as app",
18320 : : ut_setup_security, ut_teardown,
18321 : : test_tls_record_proto_zero_len),
18322 : : TEST_CASE_NAMED_ST(
18323 : : "Zero len TLS record with content type as ctrl",
18324 : : ut_setup_security, ut_teardown,
18325 : : test_tls_record_proto_zero_len_non_app),
18326 : : TEST_CASE_NAMED_ST(
18327 : : "TLS record DM mode with optional padding < 2 blocks",
18328 : : ut_setup_security, ut_teardown,
18329 : : test_tls_record_proto_dm_opt_padding),
18330 : : TEST_CASE_NAMED_ST(
18331 : : "TLS record DM mode with optional padding > 2 blocks",
18332 : : ut_setup_security, ut_teardown,
18333 : : test_tls_record_proto_dm_opt_padding_1),
18334 : : TEST_CASE_NAMED_ST(
18335 : : "TLS record SG mode with optional padding < 2 blocks",
18336 : : ut_setup_security, ut_teardown,
18337 : : test_tls_record_proto_sg_opt_padding),
18338 : : TEST_CASE_NAMED_ST(
18339 : : "TLS record SG mode with optional padding > 2 blocks",
18340 : : ut_setup_security, ut_teardown,
18341 : : test_tls_record_proto_sg_opt_padding_1),
18342 : : TEST_CASE_NAMED_ST(
18343 : : "TLS record SG mode with optional padding > 2 blocks",
18344 : : ut_setup_security, ut_teardown,
18345 : : test_tls_record_proto_sg_opt_padding_2),
18346 : : TEST_CASE_NAMED_ST(
18347 : : "TLS record SG mode with optional padding > max range",
18348 : : ut_setup_security, ut_teardown,
18349 : : test_tls_record_proto_sg_opt_padding_max),
18350 : : TEST_CASE_NAMED_ST(
18351 : : "TLS record SG mode with padding corruption",
18352 : : ut_setup_security, ut_teardown,
18353 : : test_tls_record_proto_sg_opt_padding_corrupt),
18354 : : TEST_CASES_END() /**< NULL terminate unit test array */
18355 : : }
18356 : : };
18357 : :
18358 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
18359 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18360 : : .setup = tls_record_proto_testsuite_setup,
18361 : : .unit_test_cases = {
18362 : : TEST_CASE_NAMED_WITH_DATA(
18363 : : "Write record known vector AES-GCM-128",
18364 : : ut_setup_security, ut_teardown,
18365 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18366 : : TEST_CASE_NAMED_WITH_DATA(
18367 : : "Write record known vector AES-GCM-256",
18368 : : ut_setup_security, ut_teardown,
18369 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18370 : : TEST_CASE_NAMED_WITH_DATA(
18371 : : "Write record known vector AES-128-CBC-SHA1",
18372 : : ut_setup_security, ut_teardown,
18373 : : test_tls_record_proto_known_vec,
18374 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18375 : : TEST_CASE_NAMED_WITH_DATA(
18376 : : "Write record known vector AES-128-CBC-SHA256",
18377 : : ut_setup_security, ut_teardown,
18378 : : test_tls_record_proto_known_vec,
18379 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18380 : : TEST_CASE_NAMED_WITH_DATA(
18381 : : "Write record known vector AES-256-CBC-SHA1",
18382 : : ut_setup_security, ut_teardown,
18383 : : test_tls_record_proto_known_vec,
18384 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18385 : : TEST_CASE_NAMED_WITH_DATA(
18386 : : "Write record known vector AES-256-CBC-SHA256",
18387 : : ut_setup_security, ut_teardown,
18388 : : test_tls_record_proto_known_vec,
18389 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18390 : : TEST_CASE_NAMED_WITH_DATA(
18391 : : "Write record known vector AES-256-CBC-SHA384",
18392 : : ut_setup_security, ut_teardown,
18393 : : test_tls_record_proto_known_vec,
18394 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18395 : : TEST_CASE_NAMED_WITH_DATA(
18396 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18397 : : ut_setup_security, ut_teardown,
18398 : : test_tls_record_proto_known_vec,
18399 : : &dtls_test_data_3des_cbc_sha1_hmac),
18400 : : TEST_CASE_NAMED_WITH_DATA(
18401 : : "Write record known vector NULL-SHA1-HMAC",
18402 : : ut_setup_security, ut_teardown,
18403 : : test_tls_record_proto_known_vec,
18404 : : &dtls_test_data_null_cipher_sha1_hmac),
18405 : : TEST_CASE_NAMED_WITH_DATA(
18406 : : "Write record known vector CHACHA20-POLY1305",
18407 : : ut_setup_security, ut_teardown,
18408 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18409 : : TEST_CASE_NAMED_WITH_DATA(
18410 : : "Read record known vector AES-GCM-128",
18411 : : ut_setup_security, ut_teardown,
18412 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18413 : : TEST_CASE_NAMED_WITH_DATA(
18414 : : "Read record known vector AES-GCM-256",
18415 : : ut_setup_security, ut_teardown,
18416 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18417 : : TEST_CASE_NAMED_WITH_DATA(
18418 : : "Read record known vector AES-128-CBC-SHA1",
18419 : : ut_setup_security, ut_teardown,
18420 : : test_tls_record_proto_known_vec_read,
18421 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18422 : : TEST_CASE_NAMED_WITH_DATA(
18423 : : "Read record known vector AES-128-CBC-SHA256",
18424 : : ut_setup_security, ut_teardown,
18425 : : test_tls_record_proto_known_vec_read,
18426 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18427 : : TEST_CASE_NAMED_WITH_DATA(
18428 : : "Read record known vector AES-256-CBC-SHA1",
18429 : : ut_setup_security, ut_teardown,
18430 : : test_tls_record_proto_known_vec_read,
18431 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18432 : : TEST_CASE_NAMED_WITH_DATA(
18433 : : "Read record known vector AES-256-CBC-SHA256",
18434 : : ut_setup_security, ut_teardown,
18435 : : test_tls_record_proto_known_vec_read,
18436 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18437 : : TEST_CASE_NAMED_WITH_DATA(
18438 : : "Read record known vector AES-256-CBC-SHA384",
18439 : : ut_setup_security, ut_teardown,
18440 : : test_tls_record_proto_known_vec_read,
18441 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18442 : : TEST_CASE_NAMED_WITH_DATA(
18443 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18444 : : ut_setup_security, ut_teardown,
18445 : : test_tls_record_proto_known_vec_read,
18446 : : &dtls_test_data_3des_cbc_sha1_hmac),
18447 : : TEST_CASE_NAMED_WITH_DATA(
18448 : : "Read record known vector NULL-SHA1-HMAC",
18449 : : ut_setup_security, ut_teardown,
18450 : : test_tls_record_proto_known_vec_read,
18451 : : &dtls_test_data_null_cipher_sha1_hmac),
18452 : : TEST_CASE_NAMED_WITH_DATA(
18453 : : "Read record known vector CHACHA20-POLY1305",
18454 : : ut_setup_security, ut_teardown,
18455 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18456 : :
18457 : : TEST_CASE_NAMED_ST(
18458 : : "Combined test alg list",
18459 : : ut_setup_security, ut_teardown,
18460 : : test_dtls_1_2_record_proto_display_list),
18461 : : TEST_CASE_NAMED_ST(
18462 : : "Data walkthrough combined test alg list",
18463 : : ut_setup_security, ut_teardown,
18464 : : test_dtls_1_2_record_proto_data_walkthrough),
18465 : : TEST_CASE_NAMED_ST(
18466 : : "Multi-segmented mode",
18467 : : ut_setup_security, ut_teardown,
18468 : : test_dtls_1_2_record_proto_sgl),
18469 : : TEST_CASE_NAMED_ST(
18470 : : "Multi-segmented mode data walkthrough",
18471 : : ut_setup_security, ut_teardown,
18472 : : test_dtls_1_2_record_proto_sgl_data_walkthrough),
18473 : : TEST_CASE_NAMED_ST(
18474 : : "Multi-segmented mode out of place",
18475 : : ut_setup_security, ut_teardown,
18476 : : test_dtls_1_2_record_proto_sgl_oop),
18477 : : TEST_CASE_NAMED_ST(
18478 : : "Packet corruption",
18479 : : ut_setup_security, ut_teardown,
18480 : : test_dtls_1_2_record_proto_corrupt_pkt),
18481 : : TEST_CASE_NAMED_ST(
18482 : : "Custom content type",
18483 : : ut_setup_security, ut_teardown,
18484 : : test_dtls_1_2_record_proto_custom_content_type),
18485 : : TEST_CASE_NAMED_ST(
18486 : : "Zero len DTLS record with content type as app",
18487 : : ut_setup_security, ut_teardown,
18488 : : test_dtls_1_2_record_proto_zero_len),
18489 : : TEST_CASE_NAMED_ST(
18490 : : "Zero len DTLS record with content type as ctrl",
18491 : : ut_setup_security, ut_teardown,
18492 : : test_dtls_1_2_record_proto_zero_len_non_app),
18493 : : TEST_CASE_NAMED_ST(
18494 : : "Antireplay with window size 64",
18495 : : ut_setup_security, ut_teardown,
18496 : : test_dtls_1_2_record_proto_antireplay64),
18497 : : TEST_CASE_NAMED_ST(
18498 : : "Antireplay with window size 128",
18499 : : ut_setup_security, ut_teardown,
18500 : : test_dtls_1_2_record_proto_antireplay128),
18501 : : TEST_CASE_NAMED_ST(
18502 : : "Antireplay with window size 256",
18503 : : ut_setup_security, ut_teardown,
18504 : : test_dtls_1_2_record_proto_antireplay256),
18505 : : TEST_CASE_NAMED_ST(
18506 : : "Antireplay with window size 512",
18507 : : ut_setup_security, ut_teardown,
18508 : : test_dtls_1_2_record_proto_antireplay512),
18509 : : TEST_CASE_NAMED_ST(
18510 : : "Antireplay with window size 1024",
18511 : : ut_setup_security, ut_teardown,
18512 : : test_dtls_1_2_record_proto_antireplay1024),
18513 : : TEST_CASE_NAMED_ST(
18514 : : "Antireplay with window size 2048",
18515 : : ut_setup_security, ut_teardown,
18516 : : test_dtls_1_2_record_proto_antireplay2048),
18517 : : TEST_CASE_NAMED_ST(
18518 : : "Antireplay with window size 4096",
18519 : : ut_setup_security, ut_teardown,
18520 : : test_dtls_1_2_record_proto_antireplay4096),
18521 : : TEST_CASE_NAMED_ST(
18522 : : "DTLS record DM mode with optional padding < 2 blocks",
18523 : : ut_setup_security, ut_teardown,
18524 : : test_dtls_1_2_record_proto_dm_opt_padding),
18525 : : TEST_CASE_NAMED_ST(
18526 : : "DTLS record DM mode with optional padding > 2 blocks",
18527 : : ut_setup_security, ut_teardown,
18528 : : test_dtls_1_2_record_proto_dm_opt_padding_1),
18529 : : TEST_CASE_NAMED_ST(
18530 : : "DTLS record SG mode with optional padding < 2 blocks",
18531 : : ut_setup_security, ut_teardown,
18532 : : test_dtls_1_2_record_proto_sg_opt_padding),
18533 : : TEST_CASE_NAMED_ST(
18534 : : "DTLS record SG mode with optional padding > 2 blocks",
18535 : : ut_setup_security, ut_teardown,
18536 : : test_dtls_1_2_record_proto_sg_opt_padding_1),
18537 : : TEST_CASE_NAMED_ST(
18538 : : "DTLS record SG mode with optional padding > 2 blocks",
18539 : : ut_setup_security, ut_teardown,
18540 : : test_dtls_1_2_record_proto_sg_opt_padding_2),
18541 : : TEST_CASE_NAMED_ST(
18542 : : "DTLS record SG mode with optional padding > max range",
18543 : : ut_setup_security, ut_teardown,
18544 : : test_dtls_1_2_record_proto_sg_opt_padding_max),
18545 : : TEST_CASE_NAMED_ST(
18546 : : "DTLS record SG mode with padding corruption",
18547 : : ut_setup_security, ut_teardown,
18548 : : test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18549 : : TEST_CASES_END() /**< NULL terminate unit test array */
18550 : : }
18551 : : };
18552 : :
18553 : : static struct unit_test_suite tls13_record_proto_testsuite = {
18554 : : .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18555 : : .setup = tls_record_proto_testsuite_setup,
18556 : : .unit_test_cases = {
18557 : : TEST_CASE_NAMED_WITH_DATA(
18558 : : "Write record known vector AES-GCM-128",
18559 : : ut_setup_security, ut_teardown,
18560 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18561 : : TEST_CASE_NAMED_WITH_DATA(
18562 : : "Write record known vector AES-GCM-256",
18563 : : ut_setup_security, ut_teardown,
18564 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18565 : : TEST_CASE_NAMED_WITH_DATA(
18566 : : "Write record known vector CHACHA20-POLY1305",
18567 : : ut_setup_security, ut_teardown,
18568 : : test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18569 : :
18570 : : TEST_CASE_NAMED_WITH_DATA(
18571 : : "Read record known vector AES-GCM-128",
18572 : : ut_setup_security, ut_teardown,
18573 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18574 : : TEST_CASE_NAMED_WITH_DATA(
18575 : : "Read record known vector AES-GCM-256",
18576 : : ut_setup_security, ut_teardown,
18577 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18578 : : TEST_CASE_NAMED_WITH_DATA(
18579 : : "Read record known vector CHACHA20-POLY1305",
18580 : : ut_setup_security, ut_teardown,
18581 : : test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18582 : : TEST_CASE_NAMED_ST(
18583 : : "TLS-1.3 record header corruption",
18584 : : ut_setup_security, ut_teardown,
18585 : : test_tls_1_3_record_proto_corrupt_pkt),
18586 : : TEST_CASE_NAMED_ST(
18587 : : "TLS-1.3 record header with custom content type",
18588 : : ut_setup_security, ut_teardown,
18589 : : test_tls_1_3_record_proto_custom_content_type),
18590 : : TEST_CASE_NAMED_ST(
18591 : : "TLS-1.3 record with zero len and content type as app",
18592 : : ut_setup_security, ut_teardown,
18593 : : test_tls_1_3_record_proto_zero_len),
18594 : : TEST_CASE_NAMED_ST(
18595 : : "TLS-1.3 record with zero len and content type as ctrl",
18596 : : ut_setup_security, ut_teardown,
18597 : : test_tls_1_3_record_proto_zero_len_non_app),
18598 : : TEST_CASE_NAMED_ST(
18599 : : "TLS-1.3 record DM mode with optional padding",
18600 : : ut_setup_security, ut_teardown,
18601 : : test_tls_1_3_record_proto_dm_opt_padding),
18602 : : TEST_CASE_NAMED_ST(
18603 : : "TLS-1.3 record SG mode with optional padding - 1",
18604 : : ut_setup_security, ut_teardown,
18605 : : test_tls_1_3_record_proto_sg_opt_padding),
18606 : : TEST_CASE_NAMED_ST(
18607 : : "TLS-1.3 record SG mode with optional padding",
18608 : : ut_setup_security, ut_teardown,
18609 : : test_tls_1_3_record_proto_sg_opt_padding_1),
18610 : : TEST_CASE_NAMED_ST(
18611 : : "Combined test alg list",
18612 : : ut_setup_security, ut_teardown,
18613 : : test_tls_1_3_record_proto_display_list),
18614 : : TEST_CASE_NAMED_ST(
18615 : : "Data walkthrough combined test alg list",
18616 : : ut_setup_security, ut_teardown,
18617 : : test_tls_1_3_record_proto_data_walkthrough),
18618 : : TEST_CASE_NAMED_ST(
18619 : : "Multi-segmented mode",
18620 : : ut_setup_security, ut_teardown,
18621 : : test_tls_1_3_record_proto_sgl),
18622 : : TEST_CASE_NAMED_ST(
18623 : : "Multi-segmented mode data walkthrough",
18624 : : ut_setup_security, ut_teardown,
18625 : : test_tls_1_3_record_proto_sgl_data_walkthrough),
18626 : : TEST_CASE_NAMED_ST(
18627 : : "Multi-segmented mode out of place",
18628 : : ut_setup_security, ut_teardown,
18629 : : test_tls_1_3_record_proto_sgl_oop),
18630 : : TEST_CASES_END() /**< NULL terminate unit test array */
18631 : : }
18632 : : };
18633 : :
18634 : : #define ADD_UPLINK_TESTCASE(data) \
18635 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
18636 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
18637 : :
18638 : : #define ADD_DOWNLINK_TESTCASE(data) \
18639 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
18640 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
18641 : :
18642 : : static struct unit_test_suite docsis_proto_testsuite = {
18643 : : .suite_name = "DOCSIS Proto Unit Test Suite",
18644 : : .setup = docsis_proto_testsuite_setup,
18645 : : .unit_test_cases = {
18646 : : /* Uplink */
18647 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
18648 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
18649 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
18650 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
18651 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
18652 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
18653 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
18654 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
18655 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
18656 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
18657 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
18658 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
18659 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
18660 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
18661 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
18662 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
18663 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
18664 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
18665 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
18666 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
18667 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
18668 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
18669 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
18670 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
18671 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
18672 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
18673 : : /* Downlink */
18674 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18675 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18676 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18677 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18678 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18679 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18680 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18681 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18682 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18683 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18684 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18685 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18686 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18687 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18688 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18689 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18690 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18691 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18692 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18693 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18694 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18695 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18696 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18697 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18698 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18699 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18700 : : TEST_CASES_END() /**< NULL terminate unit test array */
18701 : : }
18702 : : };
18703 : : #endif
18704 : :
18705 : : static struct unit_test_suite cryptodev_gen_testsuite = {
18706 : : .suite_name = "Crypto General Unit Test Suite",
18707 : : .setup = crypto_gen_testsuite_setup,
18708 : : .unit_test_cases = {
18709 : : TEST_CASE_ST(ut_setup, ut_teardown,
18710 : : test_device_reconfigure),
18711 : : TEST_CASE_ST(ut_setup, ut_teardown,
18712 : : test_device_configure_invalid_dev_id),
18713 : : TEST_CASE_ST(ut_setup, ut_teardown,
18714 : : test_queue_pair_descriptor_setup),
18715 : : TEST_CASE_ST(ut_setup, ut_teardown,
18716 : : test_device_configure_invalid_queue_pair_ids),
18717 : : TEST_CASE_ST(ut_setup, ut_teardown,
18718 : : test_queue_pair_descriptor_count),
18719 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18720 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18721 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18722 : : TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
18723 : : test_cryptodev_verify_error_recover, &aes_test_data_4),
18724 : : TEST_CASES_END() /**< NULL terminate unit test array */
18725 : : }
18726 : : };
18727 : :
18728 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18729 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
18730 : : .setup = negative_hmac_sha1_testsuite_setup,
18731 : : .unit_test_cases = {
18732 : : /** Negative tests */
18733 : : TEST_CASE_ST(ut_setup, ut_teardown,
18734 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
18735 : : TEST_CASE_ST(ut_setup, ut_teardown,
18736 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18737 : : TEST_CASE_ST(ut_setup, ut_teardown,
18738 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18739 : : TEST_CASE_ST(ut_setup, ut_teardown,
18740 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18741 : :
18742 : : TEST_CASES_END() /**< NULL terminate unit test array */
18743 : : }
18744 : : };
18745 : :
18746 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
18747 : : .suite_name = "Multi Session Unit Test Suite",
18748 : : .setup = multi_session_testsuite_setup,
18749 : : .unit_test_cases = {
18750 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18751 : : TEST_CASE_ST(ut_setup, ut_teardown,
18752 : : test_multi_session_random_usage),
18753 : :
18754 : : TEST_CASES_END() /**< NULL terminate unit test array */
18755 : : }
18756 : : };
18757 : :
18758 : : static struct unit_test_suite cryptodev_null_testsuite = {
18759 : : .suite_name = "NULL Test Suite",
18760 : : .setup = null_testsuite_setup,
18761 : : .unit_test_cases = {
18762 : : TEST_CASE_ST(ut_setup, ut_teardown,
18763 : : test_null_invalid_operation),
18764 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
18765 : : TEST_CASES_END()
18766 : : }
18767 : : };
18768 : :
18769 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
18770 : : .suite_name = "AES CCM Authenticated Test Suite",
18771 : : .setup = aes_ccm_auth_testsuite_setup,
18772 : : .unit_test_cases = {
18773 : : /** AES CCM Authenticated Encryption 128 bits key*/
18774 : : TEST_CASE_ST(ut_setup, ut_teardown,
18775 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
18776 : : TEST_CASE_ST(ut_setup, ut_teardown,
18777 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
18778 : : TEST_CASE_ST(ut_setup, ut_teardown,
18779 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
18780 : :
18781 : : /** AES CCM Authenticated Decryption 128 bits key*/
18782 : : TEST_CASE_ST(ut_setup, ut_teardown,
18783 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
18784 : : TEST_CASE_ST(ut_setup, ut_teardown,
18785 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
18786 : : TEST_CASE_ST(ut_setup, ut_teardown,
18787 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
18788 : :
18789 : : /** AES CCM Authenticated Encryption 192 bits key */
18790 : : TEST_CASE_ST(ut_setup, ut_teardown,
18791 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
18792 : : TEST_CASE_ST(ut_setup, ut_teardown,
18793 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
18794 : : TEST_CASE_ST(ut_setup, ut_teardown,
18795 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
18796 : :
18797 : : /** AES CCM Authenticated Decryption 192 bits key*/
18798 : : TEST_CASE_ST(ut_setup, ut_teardown,
18799 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
18800 : : TEST_CASE_ST(ut_setup, ut_teardown,
18801 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
18802 : : TEST_CASE_ST(ut_setup, ut_teardown,
18803 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
18804 : :
18805 : : /** AES CCM Authenticated Encryption 256 bits key */
18806 : : TEST_CASE_ST(ut_setup, ut_teardown,
18807 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
18808 : : TEST_CASE_ST(ut_setup, ut_teardown,
18809 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
18810 : : TEST_CASE_ST(ut_setup, ut_teardown,
18811 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
18812 : :
18813 : : /** AES CCM Authenticated Decryption 256 bits key*/
18814 : : TEST_CASE_ST(ut_setup, ut_teardown,
18815 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
18816 : : TEST_CASE_ST(ut_setup, ut_teardown,
18817 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
18818 : : TEST_CASE_ST(ut_setup, ut_teardown,
18819 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
18820 : : TEST_CASES_END()
18821 : : }
18822 : : };
18823 : :
18824 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
18825 : : .suite_name = "AES GCM Authenticated Test Suite",
18826 : : .setup = aes_gcm_auth_testsuite_setup,
18827 : : .unit_test_cases = {
18828 : : /** AES GCM Authenticated Encryption */
18829 : : TEST_CASE_ST(ut_setup, ut_teardown,
18830 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
18831 : : TEST_CASE_ST(ut_setup, ut_teardown,
18832 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
18833 : : TEST_CASE_ST(ut_setup, ut_teardown,
18834 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
18835 : : TEST_CASE_ST(ut_setup, ut_teardown,
18836 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
18837 : : TEST_CASE_ST(ut_setup, ut_teardown,
18838 : : test_AES_GCM_authenticated_encryption_test_case_1),
18839 : : TEST_CASE_ST(ut_setup, ut_teardown,
18840 : : test_AES_GCM_authenticated_encryption_test_case_2),
18841 : : TEST_CASE_ST(ut_setup, ut_teardown,
18842 : : test_AES_GCM_authenticated_encryption_test_case_3),
18843 : : TEST_CASE_ST(ut_setup, ut_teardown,
18844 : : test_AES_GCM_authenticated_encryption_test_case_4),
18845 : : TEST_CASE_ST(ut_setup, ut_teardown,
18846 : : test_AES_GCM_authenticated_encryption_test_case_5),
18847 : : TEST_CASE_ST(ut_setup, ut_teardown,
18848 : : test_AES_GCM_authenticated_encryption_test_case_6),
18849 : : TEST_CASE_ST(ut_setup, ut_teardown,
18850 : : test_AES_GCM_authenticated_encryption_test_case_7),
18851 : : TEST_CASE_ST(ut_setup, ut_teardown,
18852 : : test_AES_GCM_authenticated_encryption_test_case_8),
18853 : : TEST_CASE_ST(ut_setup, ut_teardown,
18854 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
18855 : :
18856 : : /** AES GCM Authenticated Decryption */
18857 : : TEST_CASE_ST(ut_setup, ut_teardown,
18858 : : test_AES_GCM_authenticated_decryption_test_case_1),
18859 : : TEST_CASE_ST(ut_setup, ut_teardown,
18860 : : test_AES_GCM_authenticated_decryption_test_case_2),
18861 : : TEST_CASE_ST(ut_setup, ut_teardown,
18862 : : test_AES_GCM_authenticated_decryption_test_case_3),
18863 : : TEST_CASE_ST(ut_setup, ut_teardown,
18864 : : test_AES_GCM_authenticated_decryption_test_case_4),
18865 : : TEST_CASE_ST(ut_setup, ut_teardown,
18866 : : test_AES_GCM_authenticated_decryption_test_case_5),
18867 : : TEST_CASE_ST(ut_setup, ut_teardown,
18868 : : test_AES_GCM_authenticated_decryption_test_case_6),
18869 : : TEST_CASE_ST(ut_setup, ut_teardown,
18870 : : test_AES_GCM_authenticated_decryption_test_case_7),
18871 : : TEST_CASE_ST(ut_setup, ut_teardown,
18872 : : test_AES_GCM_authenticated_decryption_test_case_8),
18873 : : TEST_CASE_ST(ut_setup, ut_teardown,
18874 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
18875 : :
18876 : : /** AES GCM Authenticated Encryption 192 bits key */
18877 : : TEST_CASE_ST(ut_setup, ut_teardown,
18878 : : test_AES_GCM_auth_encryption_test_case_192_1),
18879 : : TEST_CASE_ST(ut_setup, ut_teardown,
18880 : : test_AES_GCM_auth_encryption_test_case_192_2),
18881 : : TEST_CASE_ST(ut_setup, ut_teardown,
18882 : : test_AES_GCM_auth_encryption_test_case_192_3),
18883 : : TEST_CASE_ST(ut_setup, ut_teardown,
18884 : : test_AES_GCM_auth_encryption_test_case_192_4),
18885 : : TEST_CASE_ST(ut_setup, ut_teardown,
18886 : : test_AES_GCM_auth_encryption_test_case_192_5),
18887 : : TEST_CASE_ST(ut_setup, ut_teardown,
18888 : : test_AES_GCM_auth_encryption_test_case_192_6),
18889 : : TEST_CASE_ST(ut_setup, ut_teardown,
18890 : : test_AES_GCM_auth_encryption_test_case_192_7),
18891 : :
18892 : : /** AES GCM Authenticated Decryption 192 bits key */
18893 : : TEST_CASE_ST(ut_setup, ut_teardown,
18894 : : test_AES_GCM_auth_decryption_test_case_192_1),
18895 : : TEST_CASE_ST(ut_setup, ut_teardown,
18896 : : test_AES_GCM_auth_decryption_test_case_192_2),
18897 : : TEST_CASE_ST(ut_setup, ut_teardown,
18898 : : test_AES_GCM_auth_decryption_test_case_192_3),
18899 : : TEST_CASE_ST(ut_setup, ut_teardown,
18900 : : test_AES_GCM_auth_decryption_test_case_192_4),
18901 : : TEST_CASE_ST(ut_setup, ut_teardown,
18902 : : test_AES_GCM_auth_decryption_test_case_192_5),
18903 : : TEST_CASE_ST(ut_setup, ut_teardown,
18904 : : test_AES_GCM_auth_decryption_test_case_192_6),
18905 : : TEST_CASE_ST(ut_setup, ut_teardown,
18906 : : test_AES_GCM_auth_decryption_test_case_192_7),
18907 : :
18908 : : /** AES GCM Authenticated Encryption 256 bits key */
18909 : : TEST_CASE_ST(ut_setup, ut_teardown,
18910 : : test_AES_GCM_auth_encryption_test_case_256_1),
18911 : : TEST_CASE_ST(ut_setup, ut_teardown,
18912 : : test_AES_GCM_auth_encryption_test_case_256_2),
18913 : : TEST_CASE_ST(ut_setup, ut_teardown,
18914 : : test_AES_GCM_auth_encryption_test_case_256_3),
18915 : : TEST_CASE_ST(ut_setup, ut_teardown,
18916 : : test_AES_GCM_auth_encryption_test_case_256_4),
18917 : : TEST_CASE_ST(ut_setup, ut_teardown,
18918 : : test_AES_GCM_auth_encryption_test_case_256_5),
18919 : : TEST_CASE_ST(ut_setup, ut_teardown,
18920 : : test_AES_GCM_auth_encryption_test_case_256_6),
18921 : : TEST_CASE_ST(ut_setup, ut_teardown,
18922 : : test_AES_GCM_auth_encryption_test_case_256_7),
18923 : : TEST_CASE_ST(ut_setup, ut_teardown,
18924 : : test_AES_GCM_auth_encryption_test_case_256_8),
18925 : :
18926 : : /** AES GCM Authenticated Decryption 256 bits key */
18927 : : TEST_CASE_ST(ut_setup, ut_teardown,
18928 : : test_AES_GCM_auth_decryption_test_case_256_1),
18929 : : TEST_CASE_ST(ut_setup, ut_teardown,
18930 : : test_AES_GCM_auth_decryption_test_case_256_2),
18931 : : TEST_CASE_ST(ut_setup, ut_teardown,
18932 : : test_AES_GCM_auth_decryption_test_case_256_3),
18933 : : TEST_CASE_ST(ut_setup, ut_teardown,
18934 : : test_AES_GCM_auth_decryption_test_case_256_4),
18935 : : TEST_CASE_ST(ut_setup, ut_teardown,
18936 : : test_AES_GCM_auth_decryption_test_case_256_5),
18937 : : TEST_CASE_ST(ut_setup, ut_teardown,
18938 : : test_AES_GCM_auth_decryption_test_case_256_6),
18939 : : TEST_CASE_ST(ut_setup, ut_teardown,
18940 : : test_AES_GCM_auth_decryption_test_case_256_7),
18941 : : TEST_CASE_ST(ut_setup, ut_teardown,
18942 : : test_AES_GCM_auth_decryption_test_case_256_8),
18943 : :
18944 : : /** AES GCM Authenticated Encryption big aad size */
18945 : : TEST_CASE_ST(ut_setup, ut_teardown,
18946 : : test_AES_GCM_auth_encryption_test_case_aad_1),
18947 : : TEST_CASE_ST(ut_setup, ut_teardown,
18948 : : test_AES_GCM_auth_encryption_test_case_aad_2),
18949 : :
18950 : : /** AES GCM Authenticated Decryption big aad size */
18951 : : TEST_CASE_ST(ut_setup, ut_teardown,
18952 : : test_AES_GCM_auth_decryption_test_case_aad_1),
18953 : : TEST_CASE_ST(ut_setup, ut_teardown,
18954 : : test_AES_GCM_auth_decryption_test_case_aad_2),
18955 : :
18956 : : /** Out of place tests */
18957 : : TEST_CASE_ST(ut_setup, ut_teardown,
18958 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
18959 : : TEST_CASE_ST(ut_setup, ut_teardown,
18960 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
18961 : :
18962 : : /** Session-less tests */
18963 : : TEST_CASE_ST(ut_setup, ut_teardown,
18964 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
18965 : : TEST_CASE_ST(ut_setup, ut_teardown,
18966 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
18967 : :
18968 : : /** AES GCM external mbuf tests */
18969 : : TEST_CASE_ST(ut_setup, ut_teardown,
18970 : : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
18971 : : TEST_CASE_ST(ut_setup, ut_teardown,
18972 : : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
18973 : :
18974 : : TEST_CASES_END()
18975 : : }
18976 : : };
18977 : :
18978 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
18979 : : .suite_name = "AES GMAC Authentication Test Suite",
18980 : : .setup = aes_gmac_auth_testsuite_setup,
18981 : : .unit_test_cases = {
18982 : : TEST_CASE_ST(ut_setup, ut_teardown,
18983 : : test_AES_GMAC_authentication_test_case_1),
18984 : : TEST_CASE_ST(ut_setup, ut_teardown,
18985 : : test_AES_GMAC_authentication_verify_test_case_1),
18986 : : TEST_CASE_ST(ut_setup, ut_teardown,
18987 : : test_AES_GMAC_authentication_test_case_2),
18988 : : TEST_CASE_ST(ut_setup, ut_teardown,
18989 : : test_AES_GMAC_authentication_verify_test_case_2),
18990 : : TEST_CASE_ST(ut_setup, ut_teardown,
18991 : : test_AES_GMAC_authentication_test_case_3),
18992 : : TEST_CASE_ST(ut_setup, ut_teardown,
18993 : : test_AES_GMAC_authentication_verify_test_case_3),
18994 : : TEST_CASE_ST(ut_setup, ut_teardown,
18995 : : test_AES_GMAC_authentication_test_case_4),
18996 : : TEST_CASE_ST(ut_setup, ut_teardown,
18997 : : test_AES_GMAC_authentication_verify_test_case_4),
18998 : : TEST_CASE_ST(ut_setup, ut_teardown,
18999 : : test_AES_GMAC_authentication_SGL_40B),
19000 : : TEST_CASE_ST(ut_setup, ut_teardown,
19001 : : test_AES_GMAC_authentication_SGL_80B),
19002 : : TEST_CASE_ST(ut_setup, ut_teardown,
19003 : : test_AES_GMAC_authentication_SGL_2048B),
19004 : : TEST_CASE_ST(ut_setup, ut_teardown,
19005 : : test_AES_GMAC_authentication_SGL_2047B),
19006 : :
19007 : : TEST_CASES_END()
19008 : : }
19009 : : };
19010 : :
19011 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
19012 : : .suite_name = "Chacha20-Poly1305 Test Suite",
19013 : : .setup = chacha20_poly1305_testsuite_setup,
19014 : : .unit_test_cases = {
19015 : : TEST_CASE_ST(ut_setup, ut_teardown,
19016 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
19017 : : TEST_CASE_ST(ut_setup, ut_teardown,
19018 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
19019 : : TEST_CASE_ST(ut_setup, ut_teardown,
19020 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
19021 : : TEST_CASES_END()
19022 : : }
19023 : : };
19024 : :
19025 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
19026 : : .suite_name = "SNOW 3G Test Suite",
19027 : : .setup = snow3g_testsuite_setup,
19028 : : .unit_test_cases = {
19029 : : /** SNOW 3G encrypt only (UEA2) */
19030 : : TEST_CASE_ST(ut_setup, ut_teardown,
19031 : : test_snow3g_encryption_test_case_1),
19032 : : TEST_CASE_ST(ut_setup, ut_teardown,
19033 : : test_snow3g_encryption_test_case_2),
19034 : : TEST_CASE_ST(ut_setup, ut_teardown,
19035 : : test_snow3g_encryption_test_case_3),
19036 : : TEST_CASE_ST(ut_setup, ut_teardown,
19037 : : test_snow3g_encryption_test_case_4),
19038 : : TEST_CASE_ST(ut_setup, ut_teardown,
19039 : : test_snow3g_encryption_test_case_5),
19040 : :
19041 : : TEST_CASE_ST(ut_setup, ut_teardown,
19042 : : test_snow3g_encryption_test_case_1_oop),
19043 : : TEST_CASE_ST(ut_setup, ut_teardown,
19044 : : test_snow3g_encryption_test_case_1_oop_sgl),
19045 : : TEST_CASE_ST(ut_setup, ut_teardown,
19046 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
19047 : : TEST_CASE_ST(ut_setup, ut_teardown,
19048 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
19049 : : TEST_CASE_ST(ut_setup, ut_teardown,
19050 : : test_snow3g_encryption_test_case_1_offset_oop),
19051 : : TEST_CASE_ST(ut_setup, ut_teardown,
19052 : : test_snow3g_decryption_test_case_1_oop),
19053 : :
19054 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
19055 : : TEST_CASE_ST(ut_setup, ut_teardown,
19056 : : test_snow3g_auth_cipher_test_case_1),
19057 : : TEST_CASE_ST(ut_setup, ut_teardown,
19058 : : test_snow3g_auth_cipher_test_case_2),
19059 : : TEST_CASE_ST(ut_setup, ut_teardown,
19060 : : test_snow3g_auth_cipher_test_case_2_oop),
19061 : : TEST_CASE_ST(ut_setup, ut_teardown,
19062 : : test_snow3g_auth_cipher_part_digest_enc),
19063 : : TEST_CASE_ST(ut_setup, ut_teardown,
19064 : : test_snow3g_auth_cipher_part_digest_enc_oop),
19065 : : TEST_CASE_ST(ut_setup, ut_teardown,
19066 : : test_snow3g_auth_cipher_test_case_3_sgl),
19067 : : TEST_CASE_ST(ut_setup, ut_teardown,
19068 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
19069 : : TEST_CASE_ST(ut_setup, ut_teardown,
19070 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
19071 : : TEST_CASE_ST(ut_setup, ut_teardown,
19072 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
19073 : : TEST_CASE_ST(ut_setup, ut_teardown,
19074 : : test_snow3g_auth_cipher_total_digest_enc_1),
19075 : : TEST_CASE_ST(ut_setup, ut_teardown,
19076 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
19077 : : TEST_CASE_ST(ut_setup, ut_teardown,
19078 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
19079 : : TEST_CASE_ST(ut_setup, ut_teardown,
19080 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
19081 : :
19082 : : /** SNOW 3G decrypt (UEA2), then verify auth */
19083 : : TEST_CASE_ST(ut_setup, ut_teardown,
19084 : : test_snow3g_auth_cipher_verify_test_case_1),
19085 : : TEST_CASE_ST(ut_setup, ut_teardown,
19086 : : test_snow3g_auth_cipher_verify_test_case_2),
19087 : : TEST_CASE_ST(ut_setup, ut_teardown,
19088 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
19089 : : TEST_CASE_ST(ut_setup, ut_teardown,
19090 : : test_snow3g_auth_cipher_verify_part_digest_enc),
19091 : : TEST_CASE_ST(ut_setup, ut_teardown,
19092 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
19093 : : TEST_CASE_ST(ut_setup, ut_teardown,
19094 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
19095 : : TEST_CASE_ST(ut_setup, ut_teardown,
19096 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
19097 : : TEST_CASE_ST(ut_setup, ut_teardown,
19098 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
19099 : : TEST_CASE_ST(ut_setup, ut_teardown,
19100 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
19101 : : TEST_CASE_ST(ut_setup, ut_teardown,
19102 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
19103 : : TEST_CASE_ST(ut_setup, ut_teardown,
19104 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
19105 : : TEST_CASE_ST(ut_setup, ut_teardown,
19106 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
19107 : : TEST_CASE_ST(ut_setup, ut_teardown,
19108 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
19109 : :
19110 : : /** SNOW 3G decrypt only (UEA2) */
19111 : : TEST_CASE_ST(ut_setup, ut_teardown,
19112 : : test_snow3g_decryption_test_case_1),
19113 : : TEST_CASE_ST(ut_setup, ut_teardown,
19114 : : test_snow3g_decryption_test_case_2),
19115 : : TEST_CASE_ST(ut_setup, ut_teardown,
19116 : : test_snow3g_decryption_test_case_3),
19117 : : TEST_CASE_ST(ut_setup, ut_teardown,
19118 : : test_snow3g_decryption_test_case_4),
19119 : : TEST_CASE_ST(ut_setup, ut_teardown,
19120 : : test_snow3g_decryption_test_case_5),
19121 : : TEST_CASE_ST(ut_setup, ut_teardown,
19122 : : test_snow3g_decryption_with_digest_test_case_1),
19123 : : TEST_CASE_ST(ut_setup, ut_teardown,
19124 : : test_snow3g_hash_generate_test_case_1),
19125 : : TEST_CASE_ST(ut_setup, ut_teardown,
19126 : : test_snow3g_hash_generate_test_case_2),
19127 : : TEST_CASE_ST(ut_setup, ut_teardown,
19128 : : test_snow3g_hash_generate_test_case_3),
19129 : :
19130 : : /* Tests with buffers which length is not byte-aligned */
19131 : : TEST_CASE_ST(ut_setup, ut_teardown,
19132 : : test_snow3g_hash_generate_test_case_4),
19133 : : TEST_CASE_ST(ut_setup, ut_teardown,
19134 : : test_snow3g_hash_generate_test_case_5),
19135 : : TEST_CASE_ST(ut_setup, ut_teardown,
19136 : : test_snow3g_hash_generate_test_case_6),
19137 : : TEST_CASE_ST(ut_setup, ut_teardown,
19138 : : test_snow3g_hash_verify_test_case_1),
19139 : : TEST_CASE_ST(ut_setup, ut_teardown,
19140 : : test_snow3g_hash_verify_test_case_2),
19141 : : TEST_CASE_ST(ut_setup, ut_teardown,
19142 : : test_snow3g_hash_verify_test_case_3),
19143 : :
19144 : : /* Tests with buffers which length is not byte-aligned */
19145 : : TEST_CASE_ST(ut_setup, ut_teardown,
19146 : : test_snow3g_hash_verify_test_case_4),
19147 : : TEST_CASE_ST(ut_setup, ut_teardown,
19148 : : test_snow3g_hash_verify_test_case_5),
19149 : : TEST_CASE_ST(ut_setup, ut_teardown,
19150 : : test_snow3g_hash_verify_test_case_6),
19151 : : TEST_CASE_ST(ut_setup, ut_teardown,
19152 : : test_snow3g_cipher_auth_test_case_1),
19153 : : TEST_CASE_ST(ut_setup, ut_teardown,
19154 : : test_snow3g_auth_cipher_with_digest_test_case_1),
19155 : : TEST_CASES_END()
19156 : : }
19157 : : };
19158 : :
19159 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
19160 : : .suite_name = "ZUC Test Suite",
19161 : : .setup = zuc_testsuite_setup,
19162 : : .unit_test_cases = {
19163 : : /** ZUC encrypt only (EEA3) */
19164 : : TEST_CASE_ST(ut_setup, ut_teardown,
19165 : : test_zuc_encryption_test_case_1),
19166 : : TEST_CASE_ST(ut_setup, ut_teardown,
19167 : : test_zuc_encryption_test_case_2),
19168 : : TEST_CASE_ST(ut_setup, ut_teardown,
19169 : : test_zuc_encryption_test_case_3),
19170 : : TEST_CASE_ST(ut_setup, ut_teardown,
19171 : : test_zuc_encryption_test_case_4),
19172 : : TEST_CASE_ST(ut_setup, ut_teardown,
19173 : : test_zuc_encryption_test_case_5),
19174 : : TEST_CASE_ST(ut_setup, ut_teardown,
19175 : : test_zuc_encryption_test_case_6_sgl),
19176 : :
19177 : : /** ZUC decrypt only (EEA3) */
19178 : : TEST_CASE_ST(ut_setup, ut_teardown,
19179 : : test_zuc_decryption_test_case_1),
19180 : : TEST_CASE_ST(ut_setup, ut_teardown,
19181 : : test_zuc_decryption_test_case_2),
19182 : : TEST_CASE_ST(ut_setup, ut_teardown,
19183 : : test_zuc_decryption_test_case_3),
19184 : : TEST_CASE_ST(ut_setup, ut_teardown,
19185 : : test_zuc_decryption_test_case_4),
19186 : : TEST_CASE_ST(ut_setup, ut_teardown,
19187 : : test_zuc_decryption_test_case_5),
19188 : : TEST_CASE_ST(ut_setup, ut_teardown,
19189 : : test_zuc_decryption_test_case_6_sgl),
19190 : :
19191 : : /** ZUC authenticate (EIA3) */
19192 : : TEST_CASE_ST(ut_setup, ut_teardown,
19193 : : test_zuc_hash_generate_test_case_1),
19194 : : TEST_CASE_ST(ut_setup, ut_teardown,
19195 : : test_zuc_hash_generate_test_case_2),
19196 : : TEST_CASE_ST(ut_setup, ut_teardown,
19197 : : test_zuc_hash_generate_test_case_3),
19198 : : TEST_CASE_ST(ut_setup, ut_teardown,
19199 : : test_zuc_hash_generate_test_case_4),
19200 : : TEST_CASE_ST(ut_setup, ut_teardown,
19201 : : test_zuc_hash_generate_test_case_5),
19202 : : TEST_CASE_ST(ut_setup, ut_teardown,
19203 : : test_zuc_hash_generate_test_case_6),
19204 : : TEST_CASE_ST(ut_setup, ut_teardown,
19205 : : test_zuc_hash_generate_test_case_7),
19206 : : TEST_CASE_ST(ut_setup, ut_teardown,
19207 : : test_zuc_hash_generate_test_case_8),
19208 : :
19209 : : /** ZUC verify (EIA3) */
19210 : : TEST_CASE_ST(ut_setup, ut_teardown,
19211 : : test_zuc_hash_verify_test_case_1),
19212 : : TEST_CASE_ST(ut_setup, ut_teardown,
19213 : : test_zuc_hash_verify_test_case_2),
19214 : : TEST_CASE_ST(ut_setup, ut_teardown,
19215 : : test_zuc_hash_verify_test_case_3),
19216 : : TEST_CASE_ST(ut_setup, ut_teardown,
19217 : : test_zuc_hash_verify_test_case_4),
19218 : : TEST_CASE_ST(ut_setup, ut_teardown,
19219 : : test_zuc_hash_verify_test_case_5),
19220 : : TEST_CASE_ST(ut_setup, ut_teardown,
19221 : : test_zuc_hash_verify_test_case_6),
19222 : : TEST_CASE_ST(ut_setup, ut_teardown,
19223 : : test_zuc_hash_verify_test_case_7),
19224 : : TEST_CASE_ST(ut_setup, ut_teardown,
19225 : : test_zuc_hash_verify_test_case_8),
19226 : :
19227 : : /** ZUC alg-chain (EEA3/EIA3) */
19228 : : TEST_CASE_ST(ut_setup, ut_teardown,
19229 : : test_zuc_cipher_auth_test_case_1),
19230 : : TEST_CASE_ST(ut_setup, ut_teardown,
19231 : : test_zuc_cipher_auth_test_case_2),
19232 : :
19233 : : /** ZUC generate auth, then encrypt (EEA3) */
19234 : : TEST_CASE_ST(ut_setup, ut_teardown,
19235 : : test_zuc_auth_cipher_test_case_1),
19236 : : TEST_CASE_ST(ut_setup, ut_teardown,
19237 : : test_zuc_auth_cipher_test_case_1_oop),
19238 : : TEST_CASE_ST(ut_setup, ut_teardown,
19239 : : test_zuc_auth_cipher_test_case_1_sgl),
19240 : : TEST_CASE_ST(ut_setup, ut_teardown,
19241 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
19242 : : TEST_CASE_ST(ut_setup, ut_teardown,
19243 : : test_zuc_auth_cipher_test_case_2),
19244 : : TEST_CASE_ST(ut_setup, ut_teardown,
19245 : : test_zuc_auth_cipher_test_case_2_oop),
19246 : :
19247 : : /** ZUC decrypt (EEA3), then verify auth */
19248 : : TEST_CASE_ST(ut_setup, ut_teardown,
19249 : : test_zuc_auth_cipher_verify_test_case_1),
19250 : : TEST_CASE_ST(ut_setup, ut_teardown,
19251 : : test_zuc_auth_cipher_verify_test_case_1_oop),
19252 : : TEST_CASE_ST(ut_setup, ut_teardown,
19253 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
19254 : : TEST_CASE_ST(ut_setup, ut_teardown,
19255 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
19256 : : TEST_CASE_ST(ut_setup, ut_teardown,
19257 : : test_zuc_auth_cipher_verify_test_case_2),
19258 : : TEST_CASE_ST(ut_setup, ut_teardown,
19259 : : test_zuc_auth_cipher_verify_test_case_2_oop),
19260 : :
19261 : : /** ZUC-256 encrypt only **/
19262 : : TEST_CASE_ST(ut_setup, ut_teardown,
19263 : : test_zuc256_encryption_test_case_1),
19264 : : TEST_CASE_ST(ut_setup, ut_teardown,
19265 : : test_zuc256_encryption_test_case_2),
19266 : :
19267 : : /** ZUC-256 decrypt only **/
19268 : : TEST_CASE_ST(ut_setup, ut_teardown,
19269 : : test_zuc256_decryption_test_case_1),
19270 : : TEST_CASE_ST(ut_setup, ut_teardown,
19271 : : test_zuc256_decryption_test_case_2),
19272 : :
19273 : : /** ZUC-256 authentication only **/
19274 : : TEST_CASE_ST(ut_setup, ut_teardown,
19275 : : test_zuc256_hash_generate_4b_tag_test_case_1),
19276 : : TEST_CASE_ST(ut_setup, ut_teardown,
19277 : : test_zuc256_hash_generate_4b_tag_test_case_2),
19278 : : TEST_CASE_ST(ut_setup, ut_teardown,
19279 : : test_zuc256_hash_generate_4b_tag_test_case_3),
19280 : : TEST_CASE_ST(ut_setup, ut_teardown,
19281 : : test_zuc256_hash_generate_8b_tag_test_case_1),
19282 : : TEST_CASE_ST(ut_setup, ut_teardown,
19283 : : test_zuc256_hash_generate_16b_tag_test_case_1),
19284 : :
19285 : : /** ZUC-256 authentication verify only **/
19286 : : TEST_CASE_ST(ut_setup, ut_teardown,
19287 : : test_zuc256_hash_verify_4b_tag_test_case_1),
19288 : : TEST_CASE_ST(ut_setup, ut_teardown,
19289 : : test_zuc256_hash_verify_4b_tag_test_case_2),
19290 : : TEST_CASE_ST(ut_setup, ut_teardown,
19291 : : test_zuc256_hash_verify_4b_tag_test_case_3),
19292 : : TEST_CASE_ST(ut_setup, ut_teardown,
19293 : : test_zuc256_hash_verify_8b_tag_test_case_1),
19294 : : TEST_CASE_ST(ut_setup, ut_teardown,
19295 : : test_zuc256_hash_verify_16b_tag_test_case_1),
19296 : :
19297 : : /** ZUC-256 encrypt and authenticate **/
19298 : : TEST_CASE_ST(ut_setup, ut_teardown,
19299 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
19300 : : TEST_CASE_ST(ut_setup, ut_teardown,
19301 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
19302 : : TEST_CASE_ST(ut_setup, ut_teardown,
19303 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
19304 : : TEST_CASE_ST(ut_setup, ut_teardown,
19305 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
19306 : :
19307 : : /** ZUC-256 generate auth, then encrypt */
19308 : : TEST_CASE_ST(ut_setup, ut_teardown,
19309 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
19310 : : TEST_CASE_ST(ut_setup, ut_teardown,
19311 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
19312 : : TEST_CASE_ST(ut_setup, ut_teardown,
19313 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
19314 : : TEST_CASE_ST(ut_setup, ut_teardown,
19315 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
19316 : :
19317 : : /** ZUC-256 decrypt, then verify auth */
19318 : : TEST_CASE_ST(ut_setup, ut_teardown,
19319 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19320 : : TEST_CASE_ST(ut_setup, ut_teardown,
19321 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19322 : : TEST_CASE_ST(ut_setup, ut_teardown,
19323 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19324 : : TEST_CASE_ST(ut_setup, ut_teardown,
19325 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19326 : :
19327 : : TEST_CASES_END()
19328 : : }
19329 : : };
19330 : :
19331 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
19332 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
19333 : : .setup = hmac_md5_auth_testsuite_setup,
19334 : : .unit_test_cases = {
19335 : : TEST_CASE_ST(ut_setup, ut_teardown,
19336 : : test_MD5_HMAC_generate_case_1),
19337 : : TEST_CASE_ST(ut_setup, ut_teardown,
19338 : : test_MD5_HMAC_verify_case_1),
19339 : : TEST_CASE_ST(ut_setup, ut_teardown,
19340 : : test_MD5_HMAC_generate_case_2),
19341 : : TEST_CASE_ST(ut_setup, ut_teardown,
19342 : : test_MD5_HMAC_verify_case_2),
19343 : : TEST_CASES_END()
19344 : : }
19345 : : };
19346 : :
19347 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
19348 : : .suite_name = "Kasumi Test Suite",
19349 : : .setup = kasumi_testsuite_setup,
19350 : : .unit_test_cases = {
19351 : : /** KASUMI hash only (UIA1) */
19352 : : TEST_CASE_ST(ut_setup, ut_teardown,
19353 : : test_kasumi_hash_generate_test_case_1),
19354 : : TEST_CASE_ST(ut_setup, ut_teardown,
19355 : : test_kasumi_hash_generate_test_case_2),
19356 : : TEST_CASE_ST(ut_setup, ut_teardown,
19357 : : test_kasumi_hash_generate_test_case_3),
19358 : : TEST_CASE_ST(ut_setup, ut_teardown,
19359 : : test_kasumi_hash_generate_test_case_4),
19360 : : TEST_CASE_ST(ut_setup, ut_teardown,
19361 : : test_kasumi_hash_generate_test_case_5),
19362 : : TEST_CASE_ST(ut_setup, ut_teardown,
19363 : : test_kasumi_hash_generate_test_case_6),
19364 : :
19365 : : TEST_CASE_ST(ut_setup, ut_teardown,
19366 : : test_kasumi_hash_verify_test_case_1),
19367 : : TEST_CASE_ST(ut_setup, ut_teardown,
19368 : : test_kasumi_hash_verify_test_case_2),
19369 : : TEST_CASE_ST(ut_setup, ut_teardown,
19370 : : test_kasumi_hash_verify_test_case_3),
19371 : : TEST_CASE_ST(ut_setup, ut_teardown,
19372 : : test_kasumi_hash_verify_test_case_4),
19373 : : TEST_CASE_ST(ut_setup, ut_teardown,
19374 : : test_kasumi_hash_verify_test_case_5),
19375 : :
19376 : : /** KASUMI encrypt only (UEA1) */
19377 : : TEST_CASE_ST(ut_setup, ut_teardown,
19378 : : test_kasumi_encryption_test_case_1),
19379 : : TEST_CASE_ST(ut_setup, ut_teardown,
19380 : : test_kasumi_encryption_test_case_1_sgl),
19381 : : TEST_CASE_ST(ut_setup, ut_teardown,
19382 : : test_kasumi_encryption_test_case_1_oop),
19383 : : TEST_CASE_ST(ut_setup, ut_teardown,
19384 : : test_kasumi_encryption_test_case_1_oop_sgl),
19385 : : TEST_CASE_ST(ut_setup, ut_teardown,
19386 : : test_kasumi_encryption_test_case_2),
19387 : : TEST_CASE_ST(ut_setup, ut_teardown,
19388 : : test_kasumi_encryption_test_case_3),
19389 : : TEST_CASE_ST(ut_setup, ut_teardown,
19390 : : test_kasumi_encryption_test_case_4),
19391 : : TEST_CASE_ST(ut_setup, ut_teardown,
19392 : : test_kasumi_encryption_test_case_5),
19393 : :
19394 : : /** KASUMI decrypt only (UEA1) */
19395 : : TEST_CASE_ST(ut_setup, ut_teardown,
19396 : : test_kasumi_decryption_test_case_1),
19397 : : TEST_CASE_ST(ut_setup, ut_teardown,
19398 : : test_kasumi_decryption_test_case_2),
19399 : : TEST_CASE_ST(ut_setup, ut_teardown,
19400 : : test_kasumi_decryption_test_case_3),
19401 : : TEST_CASE_ST(ut_setup, ut_teardown,
19402 : : test_kasumi_decryption_test_case_4),
19403 : : TEST_CASE_ST(ut_setup, ut_teardown,
19404 : : test_kasumi_decryption_test_case_5),
19405 : : TEST_CASE_ST(ut_setup, ut_teardown,
19406 : : test_kasumi_decryption_test_case_1_oop),
19407 : : TEST_CASE_ST(ut_setup, ut_teardown,
19408 : : test_kasumi_cipher_auth_test_case_1),
19409 : :
19410 : : /** KASUMI generate auth, then encrypt (F8) */
19411 : : TEST_CASE_ST(ut_setup, ut_teardown,
19412 : : test_kasumi_auth_cipher_test_case_1),
19413 : : TEST_CASE_ST(ut_setup, ut_teardown,
19414 : : test_kasumi_auth_cipher_test_case_2),
19415 : : TEST_CASE_ST(ut_setup, ut_teardown,
19416 : : test_kasumi_auth_cipher_test_case_2_oop),
19417 : : TEST_CASE_ST(ut_setup, ut_teardown,
19418 : : test_kasumi_auth_cipher_test_case_2_sgl),
19419 : : TEST_CASE_ST(ut_setup, ut_teardown,
19420 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
19421 : :
19422 : : /** KASUMI decrypt (F8), then verify auth */
19423 : : TEST_CASE_ST(ut_setup, ut_teardown,
19424 : : test_kasumi_auth_cipher_verify_test_case_1),
19425 : : TEST_CASE_ST(ut_setup, ut_teardown,
19426 : : test_kasumi_auth_cipher_verify_test_case_2),
19427 : : TEST_CASE_ST(ut_setup, ut_teardown,
19428 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
19429 : : TEST_CASE_ST(ut_setup, ut_teardown,
19430 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
19431 : : TEST_CASE_ST(ut_setup, ut_teardown,
19432 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19433 : :
19434 : : TEST_CASES_END()
19435 : : }
19436 : : };
19437 : :
19438 : : static struct unit_test_suite cryptodev_esn_testsuite = {
19439 : : .suite_name = "ESN Test Suite",
19440 : : .setup = esn_testsuite_setup,
19441 : : .unit_test_cases = {
19442 : : TEST_CASE_ST(ut_setup, ut_teardown,
19443 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19444 : : TEST_CASE_ST(ut_setup, ut_teardown,
19445 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19446 : : TEST_CASES_END()
19447 : : }
19448 : : };
19449 : :
19450 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
19451 : : .suite_name = "Negative AES GCM Test Suite",
19452 : : .setup = negative_aes_gcm_testsuite_setup,
19453 : : .unit_test_cases = {
19454 : : TEST_CASE_ST(ut_setup, ut_teardown,
19455 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
19456 : : TEST_CASE_ST(ut_setup, ut_teardown,
19457 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19458 : : TEST_CASE_ST(ut_setup, ut_teardown,
19459 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19460 : : TEST_CASE_ST(ut_setup, ut_teardown,
19461 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19462 : : TEST_CASE_ST(ut_setup, ut_teardown,
19463 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
19464 : : TEST_CASE_ST(ut_setup, ut_teardown,
19465 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
19466 : : TEST_CASE_ST(ut_setup, ut_teardown,
19467 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
19468 : : TEST_CASE_ST(ut_setup, ut_teardown,
19469 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19470 : : TEST_CASE_ST(ut_setup, ut_teardown,
19471 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19472 : : TEST_CASE_ST(ut_setup, ut_teardown,
19473 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19474 : : TEST_CASE_ST(ut_setup, ut_teardown,
19475 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
19476 : : TEST_CASE_ST(ut_setup, ut_teardown,
19477 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
19478 : :
19479 : : TEST_CASES_END()
19480 : : }
19481 : : };
19482 : :
19483 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
19484 : : .suite_name = "Negative AES GMAC Test Suite",
19485 : : .setup = negative_aes_gmac_testsuite_setup,
19486 : : .unit_test_cases = {
19487 : : TEST_CASE_ST(ut_setup, ut_teardown,
19488 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
19489 : : TEST_CASE_ST(ut_setup, ut_teardown,
19490 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
19491 : :
19492 : : TEST_CASES_END()
19493 : : }
19494 : : };
19495 : :
19496 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
19497 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19498 : : .setup = mixed_cipher_hash_testsuite_setup,
19499 : : .unit_test_cases = {
19500 : : /** AUTH AES CMAC + CIPHER AES CTR */
19501 : : TEST_CASE_ST(ut_setup, ut_teardown,
19502 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19503 : : TEST_CASE_ST(ut_setup, ut_teardown,
19504 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19505 : : TEST_CASE_ST(ut_setup, ut_teardown,
19506 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19507 : : TEST_CASE_ST(ut_setup, ut_teardown,
19508 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19509 : : TEST_CASE_ST(ut_setup, ut_teardown,
19510 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19511 : : TEST_CASE_ST(ut_setup, ut_teardown,
19512 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19513 : : TEST_CASE_ST(ut_setup, ut_teardown,
19514 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19515 : : TEST_CASE_ST(ut_setup, ut_teardown,
19516 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19517 : : TEST_CASE_ST(ut_setup, ut_teardown,
19518 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19519 : : TEST_CASE_ST(ut_setup, ut_teardown,
19520 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19521 : : TEST_CASE_ST(ut_setup, ut_teardown,
19522 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19523 : : TEST_CASE_ST(ut_setup, ut_teardown,
19524 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19525 : :
19526 : : /** AUTH ZUC + CIPHER SNOW3G */
19527 : : TEST_CASE_ST(ut_setup, ut_teardown,
19528 : : test_auth_zuc_cipher_snow_test_case_1),
19529 : : TEST_CASE_ST(ut_setup, ut_teardown,
19530 : : test_verify_auth_zuc_cipher_snow_test_case_1),
19531 : : TEST_CASE_ST(ut_setup, ut_teardown,
19532 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
19533 : : TEST_CASE_ST(ut_setup, ut_teardown,
19534 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19535 : : /** AUTH AES CMAC + CIPHER SNOW3G */
19536 : : TEST_CASE_ST(ut_setup, ut_teardown,
19537 : : test_auth_aes_cmac_cipher_snow_test_case_1),
19538 : : TEST_CASE_ST(ut_setup, ut_teardown,
19539 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19540 : : TEST_CASE_ST(ut_setup, ut_teardown,
19541 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19542 : : TEST_CASE_ST(ut_setup, ut_teardown,
19543 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19544 : : /** AUTH ZUC + CIPHER AES CTR */
19545 : : TEST_CASE_ST(ut_setup, ut_teardown,
19546 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
19547 : : TEST_CASE_ST(ut_setup, ut_teardown,
19548 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19549 : : TEST_CASE_ST(ut_setup, ut_teardown,
19550 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19551 : : TEST_CASE_ST(ut_setup, ut_teardown,
19552 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19553 : : /** AUTH SNOW3G + CIPHER AES CTR */
19554 : : TEST_CASE_ST(ut_setup, ut_teardown,
19555 : : test_auth_snow_cipher_aes_ctr_test_case_1),
19556 : : TEST_CASE_ST(ut_setup, ut_teardown,
19557 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19558 : : TEST_CASE_ST(ut_setup, ut_teardown,
19559 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19560 : : TEST_CASE_ST(ut_setup, ut_teardown,
19561 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19562 : : TEST_CASE_ST(ut_setup, ut_teardown,
19563 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19564 : : TEST_CASE_ST(ut_setup, ut_teardown,
19565 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19566 : : /** AUTH SNOW3G + CIPHER ZUC */
19567 : : TEST_CASE_ST(ut_setup, ut_teardown,
19568 : : test_auth_snow_cipher_zuc_test_case_1),
19569 : : TEST_CASE_ST(ut_setup, ut_teardown,
19570 : : test_verify_auth_snow_cipher_zuc_test_case_1),
19571 : : TEST_CASE_ST(ut_setup, ut_teardown,
19572 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
19573 : : TEST_CASE_ST(ut_setup, ut_teardown,
19574 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19575 : : /** AUTH AES CMAC + CIPHER ZUC */
19576 : : TEST_CASE_ST(ut_setup, ut_teardown,
19577 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
19578 : : TEST_CASE_ST(ut_setup, ut_teardown,
19579 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19580 : : TEST_CASE_ST(ut_setup, ut_teardown,
19581 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19582 : : TEST_CASE_ST(ut_setup, ut_teardown,
19583 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19584 : :
19585 : : /** AUTH NULL + CIPHER SNOW3G */
19586 : : TEST_CASE_ST(ut_setup, ut_teardown,
19587 : : test_auth_null_cipher_snow_test_case_1),
19588 : : TEST_CASE_ST(ut_setup, ut_teardown,
19589 : : test_verify_auth_null_cipher_snow_test_case_1),
19590 : : /** AUTH NULL + CIPHER ZUC */
19591 : : TEST_CASE_ST(ut_setup, ut_teardown,
19592 : : test_auth_null_cipher_zuc_test_case_1),
19593 : : TEST_CASE_ST(ut_setup, ut_teardown,
19594 : : test_verify_auth_null_cipher_zuc_test_case_1),
19595 : : /** AUTH SNOW3G + CIPHER NULL */
19596 : : TEST_CASE_ST(ut_setup, ut_teardown,
19597 : : test_auth_snow_cipher_null_test_case_1),
19598 : : TEST_CASE_ST(ut_setup, ut_teardown,
19599 : : test_verify_auth_snow_cipher_null_test_case_1),
19600 : : /** AUTH ZUC + CIPHER NULL */
19601 : : TEST_CASE_ST(ut_setup, ut_teardown,
19602 : : test_auth_zuc_cipher_null_test_case_1),
19603 : : TEST_CASE_ST(ut_setup, ut_teardown,
19604 : : test_verify_auth_zuc_cipher_null_test_case_1),
19605 : : /** AUTH NULL + CIPHER AES CTR */
19606 : : TEST_CASE_ST(ut_setup, ut_teardown,
19607 : : test_auth_null_cipher_aes_ctr_test_case_1),
19608 : : TEST_CASE_ST(ut_setup, ut_teardown,
19609 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
19610 : : /** AUTH AES CMAC + CIPHER NULL */
19611 : : TEST_CASE_ST(ut_setup, ut_teardown,
19612 : : test_auth_aes_cmac_cipher_null_test_case_1),
19613 : : TEST_CASE_ST(ut_setup, ut_teardown,
19614 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
19615 : : TEST_CASES_END()
19616 : : }
19617 : : };
19618 : :
19619 : : static int
19620 : 1 : run_cryptodev_testsuite(const char *pmd_name)
19621 : : {
19622 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
19623 : 1 : const enum blockcipher_test_type blk_suites[] = {
19624 : : BLKCIPHER_AES_CHAIN_TYPE,
19625 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
19626 : : BLKCIPHER_AES_DOCSIS_TYPE,
19627 : : BLKCIPHER_3DES_CHAIN_TYPE,
19628 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
19629 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
19630 : : BLKCIPHER_DES_DOCSIS_TYPE,
19631 : : BLKCIPHER_SM4_CHAIN_TYPE,
19632 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
19633 : : BLKCIPHER_AUTHONLY_TYPE};
19634 : 1 : struct unit_test_suite *static_suites[] = {
19635 : : &cryptodev_multi_session_testsuite,
19636 : : &cryptodev_null_testsuite,
19637 : : &cryptodev_aes_ccm_auth_testsuite,
19638 : : &cryptodev_aes_gcm_auth_testsuite,
19639 : : &cryptodev_aes_gmac_auth_testsuite,
19640 : : &cryptodev_snow3g_testsuite,
19641 : : &cryptodev_chacha20_poly1305_testsuite,
19642 : : &cryptodev_zuc_testsuite,
19643 : : &cryptodev_hmac_md5_auth_testsuite,
19644 : : &cryptodev_kasumi_testsuite,
19645 : : &cryptodev_esn_testsuite,
19646 : : &cryptodev_negative_aes_gcm_testsuite,
19647 : : &cryptodev_negative_aes_gmac_testsuite,
19648 : : &cryptodev_mixed_cipher_hash_testsuite,
19649 : : &cryptodev_negative_hmac_sha1_testsuite,
19650 : : &cryptodev_gen_testsuite,
19651 : : #ifdef RTE_LIB_SECURITY
19652 : : &ipsec_proto_testsuite,
19653 : : &pdcp_proto_testsuite,
19654 : : &docsis_proto_testsuite,
19655 : : &tls12_record_proto_testsuite,
19656 : : &dtls12_record_proto_testsuite,
19657 : : &tls13_record_proto_testsuite,
19658 : : #endif
19659 : : &end_testsuite
19660 : : };
19661 : : static struct unit_test_suite ts = {
19662 : : .suite_name = "Cryptodev Unit Test Suite",
19663 : : .setup = testsuite_setup,
19664 : : .teardown = testsuite_teardown,
19665 : : .unit_test_cases = {TEST_CASES_END()}
19666 : : };
19667 : :
19668 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
19669 : :
19670 [ - + ]: 1 : if (gbl_driver_id == -1) {
19671 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
19672 : 0 : return TEST_SKIPPED;
19673 : : }
19674 : :
19675 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19676 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
19677 : :
19678 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
19679 [ + + ]: 24 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19680 : 1 : ret = unit_test_suite_runner(&ts);
19681 : :
19682 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
19683 : 1 : free(ts.unit_test_suites);
19684 : 1 : return ret;
19685 : : }
19686 : :
19687 : : static int
19688 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
19689 : : {
19690 : : struct rte_cryptodev_info dev_info;
19691 : : uint8_t i, nb_devs;
19692 : : int driver_id;
19693 : :
19694 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
19695 [ # # ]: 0 : if (driver_id == -1) {
19696 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
19697 : 0 : return TEST_SKIPPED;
19698 : : }
19699 : :
19700 : 0 : nb_devs = rte_cryptodev_count();
19701 [ # # ]: 0 : if (nb_devs < 1) {
19702 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
19703 : 0 : return TEST_SKIPPED;
19704 : : }
19705 : :
19706 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
19707 : 0 : rte_cryptodev_info_get(i, &dev_info);
19708 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
19709 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
19710 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
19711 : : flag_name);
19712 : 0 : return TEST_SKIPPED;
19713 : : }
19714 : : return 0; /* found */
19715 : : }
19716 : : }
19717 : :
19718 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
19719 : 0 : return TEST_SKIPPED;
19720 : : }
19721 : :
19722 : : static int
19723 : 0 : test_cryptodev_qat(void)
19724 : : {
19725 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19726 : : }
19727 : :
19728 : : static int
19729 : 0 : test_cryptodev_uadk(void)
19730 : : {
19731 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
19732 : : }
19733 : :
19734 : : static int
19735 : 0 : test_cryptodev_virtio(void)
19736 : : {
19737 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
19738 : : }
19739 : :
19740 : : static int
19741 : 0 : test_cryptodev_aesni_mb(void)
19742 : : {
19743 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19744 : : }
19745 : :
19746 : : static int
19747 : 0 : test_cryptodev_cpu_aesni_mb(void)
19748 : : {
19749 : : int32_t rc;
19750 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19751 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19752 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19753 : 0 : gbl_action_type = at;
19754 : 0 : return rc;
19755 : : }
19756 : :
19757 : : static int
19758 : 0 : test_cryptodev_chacha_poly_mb(void)
19759 : : {
19760 : : int32_t rc;
19761 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19762 : 0 : rc = run_cryptodev_testsuite(
19763 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
19764 : 0 : gbl_action_type = at;
19765 : 0 : return rc;
19766 : : }
19767 : :
19768 : : static int
19769 : 1 : test_cryptodev_openssl(void)
19770 : : {
19771 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
19772 : : }
19773 : :
19774 : : static int
19775 : 0 : test_cryptodev_aesni_gcm(void)
19776 : : {
19777 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19778 : : }
19779 : :
19780 : : static int
19781 : 0 : test_cryptodev_cpu_aesni_gcm(void)
19782 : : {
19783 : : int32_t rc;
19784 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19785 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19786 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19787 : 0 : gbl_action_type = at;
19788 : 0 : return rc;
19789 : : }
19790 : :
19791 : : static int
19792 : 0 : test_cryptodev_mlx5(void)
19793 : : {
19794 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
19795 : : }
19796 : :
19797 : : static int
19798 : 0 : test_cryptodev_null(void)
19799 : : {
19800 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
19801 : : }
19802 : :
19803 : : static int
19804 : 0 : test_cryptodev_sw_snow3g(void)
19805 : : {
19806 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
19807 : : }
19808 : :
19809 : : static int
19810 : 0 : test_cryptodev_sw_kasumi(void)
19811 : : {
19812 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
19813 : : }
19814 : :
19815 : : static int
19816 : 0 : test_cryptodev_sw_zuc(void)
19817 : : {
19818 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
19819 : : }
19820 : :
19821 : : static int
19822 : 0 : test_cryptodev_armv8(void)
19823 : : {
19824 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
19825 : : }
19826 : :
19827 : : static int
19828 : 0 : test_cryptodev_mrvl(void)
19829 : : {
19830 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
19831 : : }
19832 : :
19833 : : #ifdef RTE_CRYPTO_SCHEDULER
19834 : :
19835 : : static int
19836 : 0 : test_cryptodev_scheduler(void)
19837 : : {
19838 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
19839 : 0 : const enum blockcipher_test_type blk_suites[] = {
19840 : : BLKCIPHER_AES_CHAIN_TYPE,
19841 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
19842 : : BLKCIPHER_AUTHONLY_TYPE
19843 : : };
19844 : : static struct unit_test_suite scheduler_multicore = {
19845 : : .suite_name = "Scheduler Multicore Unit Test Suite",
19846 : : .setup = scheduler_multicore_testsuite_setup,
19847 : : .teardown = scheduler_mode_testsuite_teardown,
19848 : : .unit_test_cases = {TEST_CASES_END()}
19849 : : };
19850 : : static struct unit_test_suite scheduler_round_robin = {
19851 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
19852 : : .setup = scheduler_roundrobin_testsuite_setup,
19853 : : .teardown = scheduler_mode_testsuite_teardown,
19854 : : .unit_test_cases = {TEST_CASES_END()}
19855 : : };
19856 : : static struct unit_test_suite scheduler_failover = {
19857 : : .suite_name = "Scheduler Failover Unit Test Suite",
19858 : : .setup = scheduler_failover_testsuite_setup,
19859 : : .teardown = scheduler_mode_testsuite_teardown,
19860 : : .unit_test_cases = {TEST_CASES_END()}
19861 : : };
19862 : : static struct unit_test_suite scheduler_pkt_size_distr = {
19863 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
19864 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
19865 : : .teardown = scheduler_mode_testsuite_teardown,
19866 : : .unit_test_cases = {TEST_CASES_END()}
19867 : : };
19868 : 0 : struct unit_test_suite *sched_mode_suites[] = {
19869 : : &scheduler_multicore,
19870 : : &scheduler_round_robin,
19871 : : &scheduler_failover,
19872 : : &scheduler_pkt_size_distr
19873 : : };
19874 : : static struct unit_test_suite scheduler_config = {
19875 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
19876 : : .unit_test_cases = {
19877 : : TEST_CASE(test_scheduler_attach_worker_op),
19878 : : TEST_CASE(test_scheduler_mode_multicore_op),
19879 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
19880 : : TEST_CASE(test_scheduler_mode_failover_op),
19881 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
19882 : : TEST_CASE(test_scheduler_detach_worker_op),
19883 : :
19884 : : TEST_CASES_END() /**< NULL terminate array */
19885 : : }
19886 : : };
19887 : 0 : struct unit_test_suite *static_suites[] = {
19888 : : &scheduler_config,
19889 : : &end_testsuite
19890 : : };
19891 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
19892 : : #ifdef RTE_LIB_SECURITY
19893 : : &docsis_proto_testsuite,
19894 : : #endif
19895 : : &end_testsuite
19896 : : };
19897 : : static struct unit_test_suite ts = {
19898 : : .suite_name = "Scheduler Unit Test Suite",
19899 : : .setup = scheduler_testsuite_setup,
19900 : : .teardown = testsuite_teardown,
19901 : : .unit_test_cases = {TEST_CASES_END()}
19902 : : };
19903 : :
19904 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
19905 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
19906 : :
19907 [ # # ]: 0 : if (gbl_driver_id == -1) {
19908 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
19909 : 0 : return TEST_SKIPPED;
19910 : : }
19911 : :
19912 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
19913 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
19914 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
19915 : 0 : return TEST_SKIPPED;
19916 : : }
19917 : :
19918 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19919 : : uint8_t blk_i = 0;
19920 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
19921 : : (struct unit_test_suite *) *
19922 : : (RTE_DIM(blk_suites) +
19923 : : RTE_DIM(sched_mode_static_suites) + 1));
19924 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19925 : : blk_suites, RTE_DIM(blk_suites));
19926 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19927 : : sched_mode_static_suites,
19928 : : RTE_DIM(sched_mode_static_suites));
19929 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
19930 : : }
19931 : :
19932 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19933 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
19934 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
19935 : : RTE_DIM(sched_mode_suites));
19936 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19937 : 0 : ret = unit_test_suite_runner(&ts);
19938 : :
19939 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19940 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
19941 : : (*sched_mode_suites[sched_i]),
19942 : : RTE_DIM(blk_suites));
19943 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
19944 : : }
19945 : 0 : free(ts.unit_test_suites);
19946 : 0 : return ret;
19947 : : }
19948 : :
19949 : 252 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
19950 : :
19951 : : #endif
19952 : :
19953 : : static int
19954 : 0 : test_cryptodev_dpaa2_sec(void)
19955 : : {
19956 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19957 : : }
19958 : :
19959 : : static int
19960 : 0 : test_cryptodev_dpaa_sec(void)
19961 : : {
19962 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19963 : : }
19964 : :
19965 : : static int
19966 : 0 : test_cryptodev_ccp(void)
19967 : : {
19968 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
19969 : : }
19970 : :
19971 : : static int
19972 : 0 : test_cryptodev_octeontx(void)
19973 : : {
19974 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
19975 : : }
19976 : :
19977 : : static int
19978 : 0 : test_cryptodev_caam_jr(void)
19979 : : {
19980 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
19981 : : }
19982 : :
19983 : : static int
19984 : 0 : test_cryptodev_nitrox(void)
19985 : : {
19986 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
19987 : : }
19988 : :
19989 : : static int
19990 : 0 : test_cryptodev_bcmfs(void)
19991 : : {
19992 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
19993 : : }
19994 : :
19995 : : static int
19996 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
19997 : : {
19998 : : int ret;
19999 : :
20000 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
20001 [ # # ]: 0 : if (ret)
20002 : : return ret;
20003 : :
20004 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
20005 : 0 : ret = run_cryptodev_testsuite(pmd_name);
20006 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
20007 : :
20008 : 0 : return ret;
20009 : : }
20010 : :
20011 : : static int
20012 : 0 : test_cryptodev_qat_raw_api(void)
20013 : : {
20014 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20015 : : }
20016 : :
20017 : : static int
20018 : 0 : test_cryptodev_cn9k(void)
20019 : : {
20020 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
20021 : : }
20022 : :
20023 : : static int
20024 : 0 : test_cryptodev_cn10k(void)
20025 : : {
20026 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20027 : : }
20028 : :
20029 : : static int
20030 : 0 : test_cryptodev_cn10k_raw_api(void)
20031 : : {
20032 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20033 : : }
20034 : :
20035 : : static int
20036 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
20037 : : {
20038 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20039 : : }
20040 : :
20041 : : static int
20042 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
20043 : : {
20044 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20045 : : }
20046 : :
20047 : 252 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
20048 : : test_cryptodev_cn10k_raw_api);
20049 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
20050 : : test_cryptodev_dpaa2_sec_raw_api);
20051 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
20052 : : test_cryptodev_dpaa_sec_raw_api);
20053 : 252 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
20054 : : test_cryptodev_qat_raw_api);
20055 : 252 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
20056 : 252 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
20057 : 252 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
20058 : : test_cryptodev_cpu_aesni_mb);
20059 : 252 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
20060 : : test_cryptodev_chacha_poly_mb);
20061 : 252 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
20062 : 252 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
20063 : 252 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
20064 : : test_cryptodev_cpu_aesni_gcm);
20065 : 252 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
20066 : 252 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
20067 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
20068 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
20069 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
20070 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
20071 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
20072 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
20073 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
20074 : 252 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
20075 : 252 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
20076 : 252 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
20077 : 252 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
20078 : 252 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
20079 : 252 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
20080 : 252 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
20081 : 252 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
20082 : 252 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
|