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 : : #include "test_cryptodev_nxan_test_vectors.h"
52 : : #ifdef RTE_LIB_SECURITY
53 : : #include "test_cryptodev_security_ipsec.h"
54 : : #include "test_cryptodev_security_ipsec_test_vectors.h"
55 : : #include "test_cryptodev_security_pdcp_test_vectors.h"
56 : : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
57 : : #include "test_cryptodev_security_pdcp_test_func.h"
58 : : #include "test_cryptodev_security_docsis_test_vectors.h"
59 : : #include "test_cryptodev_security_tls_record.h"
60 : : #include "test_security_proto.h"
61 : :
62 : : #define SDAP_DISABLED 0
63 : : #define SDAP_ENABLED 1
64 : : #endif
65 : :
66 : : #define VDEV_ARGS_SIZE 100
67 : : #define MAX_NB_SESSIONS 4
68 : :
69 : : #define MAX_RAW_DEQUEUE_COUNT 65535
70 : :
71 : : #define IN_PLACE 0
72 : : #define OUT_OF_PLACE 1
73 : :
74 : : #define QP_DRAIN_TIMEOUT 100
75 : : #define HW_ERR_RECOVER_TIMEOUT 500
76 : :
77 : : static int gbl_driver_id;
78 : :
79 : : enum rte_security_session_action_type gbl_action_type =
80 : : RTE_SECURITY_ACTION_TYPE_NONE;
81 : :
82 : : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
83 : :
84 : : struct crypto_unittest_params {
85 : : struct rte_crypto_sym_xform cipher_xform;
86 : : struct rte_crypto_sym_xform auth_xform;
87 : : struct rte_crypto_sym_xform aead_xform;
88 : : #ifdef RTE_LIB_SECURITY
89 : : struct rte_security_docsis_xform docsis_xform;
90 : : #endif
91 : :
92 : : union {
93 : : void *sess;
94 : : #ifdef RTE_LIB_SECURITY
95 : : void *sec_session;
96 : : #endif
97 : : };
98 : : #ifdef RTE_LIB_SECURITY
99 : : enum rte_security_session_action_type type;
100 : : #endif
101 : : struct rte_crypto_op *op;
102 : :
103 : : struct rte_mbuf *obuf, *ibuf;
104 : :
105 : : uint8_t *digest;
106 : : };
107 : :
108 : : #define ALIGN_POW2_ROUNDUP(num, align) \
109 : : (((num) + (align) - 1) & ~((align) - 1))
110 : :
111 : : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
112 : : for (j = 0; j < num_child_ts; index++, j++) \
113 : : parent_ts.unit_test_suites[index] = child_ts[j]
114 : :
115 : : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
116 : : for (j = 0; j < num_blk_types; index++, j++) \
117 : : parent_ts.unit_test_suites[index] = \
118 : : build_blockcipher_test_suite(blk_types[j])
119 : :
120 : : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
121 : : for (j = index; j < index + num_blk_types; j++) \
122 : : free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
123 : :
124 : : /*
125 : : * Forward declarations.
126 : : */
127 : : static int
128 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
129 : : struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
130 : : uint8_t *hmac_key);
131 : :
132 : : static int
133 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
134 : : struct crypto_unittest_params *ut_params,
135 : : struct crypto_testsuite_params *ts_param,
136 : : const uint8_t *cipher,
137 : : const uint8_t *digest,
138 : : const uint8_t *iv);
139 : :
140 : : static int
141 : : security_proto_supported(enum rte_security_session_action_type action,
142 : : enum rte_security_session_protocol proto);
143 : :
144 : : static int
145 : : dev_configure_and_start(uint64_t ff_disable);
146 : :
147 : : static int
148 : : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
149 : : const enum rte_crypto_cipher_algorithm cipher_algo,
150 : : const uint16_t key_size, const uint16_t iv_size);
151 : :
152 : : static int
153 : : check_auth_capability(const struct crypto_testsuite_params *ts_params,
154 : : const enum rte_crypto_auth_algorithm auth_algo,
155 : : const uint16_t key_size, const uint16_t iv_size,
156 : : const uint16_t tag_size);
157 : :
158 : : static struct rte_mbuf *
159 : 7 : setup_test_string(struct rte_mempool *mpool,
160 : : const char *string, size_t len, uint8_t blocksize)
161 : : {
162 : 7 : struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
163 [ - + ]: 7 : size_t t_len = len - (blocksize ? (len % blocksize) : 0);
164 : :
165 [ + - ]: 7 : if (m) {
166 : : char *dst;
167 : :
168 : 7 : memset(m->buf_addr, 0, m->buf_len);
169 : 7 : dst = rte_pktmbuf_append(m, t_len);
170 [ - + ]: 7 : if (!dst) {
171 : 0 : rte_pktmbuf_free(m);
172 : 0 : return NULL;
173 : : }
174 [ + - ]: 7 : if (string != NULL)
175 : : rte_memcpy(dst, string, t_len);
176 : : else
177 : : memset(dst, 0, t_len);
178 : : }
179 : :
180 : : return m;
181 : : }
182 : :
183 : : /* Get number of bytes in X bits (rounding up) */
184 : : static uint32_t
185 : : ceil_byte_length(uint32_t num_bits)
186 : : {
187 : 4 : if (num_bits % 8)
188 : 0 : return ((num_bits >> 3) + 1);
189 : : else
190 : 4 : return (num_bits >> 3);
191 : : }
192 : :
193 : : static void
194 : 0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
195 : : uint8_t is_op_success)
196 : : {
197 : : struct rte_crypto_op *op = user_data;
198 [ # # ]: 0 : op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
199 : : RTE_CRYPTO_OP_STATUS_ERROR;
200 : 0 : }
201 : :
202 : : static struct crypto_testsuite_params testsuite_params = { NULL };
203 : : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
204 : : static struct crypto_unittest_params unittest_params;
205 : : static bool enq_cb_called;
206 : : static bool deq_cb_called;
207 : :
208 : : enum cryptodev_err_state {
209 : : CRYPTODEV_ERR_CLEARED,
210 : : CRYPTODEV_ERR_TRIGGERED,
211 : : CRYPTODEV_ERR_UNRECOVERABLE,
212 : : };
213 : :
214 : : static enum cryptodev_err_state crypto_err = CRYPTODEV_ERR_CLEARED;
215 : :
216 : : static void
217 : 0 : test_cryptodev_error_cb(uint8_t dev_id, enum rte_cryptodev_event_type event, void *cb_arg)
218 : : {
219 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
220 : : uint16_t qp_id;
221 : : int ticks = 0;
222 : : int ret = 0;
223 : :
224 : : RTE_SET_USED(event);
225 : : RTE_SET_USED(cb_arg);
226 : :
227 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
228 : 0 : ret = rte_cryptodev_queue_pair_event_error_query(dev_id, qp_id);
229 [ # # ]: 0 : if (ret)
230 : : break;
231 : : }
232 [ # # ]: 0 : if (ret == 1) {
233 : : /* Wait for the queue to be completely drained */
234 [ # # # # ]: 0 : while (rte_cryptodev_qp_depth_used(dev_id, qp_id) != 0) {
235 : : rte_delay_ms(10);
236 : 0 : ticks++;
237 [ # # ]: 0 : if (ticks > QP_DRAIN_TIMEOUT) {
238 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
239 : 0 : return;
240 : : }
241 : : }
242 [ # # ]: 0 : if (rte_cryptodev_queue_pair_reset(dev_id, qp_id, NULL, 0)) {
243 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
244 : 0 : return;
245 : : }
246 : : }
247 : :
248 : 0 : crypto_err = CRYPTODEV_ERR_CLEARED;
249 : : }
250 : :
251 : : static struct rte_mbuf *
252 : 0 : create_mbuf_from_heap(int pkt_len, uint8_t pattern)
253 : : {
254 : : struct rte_mbuf *m = NULL;
255 : : uint8_t *dst;
256 : :
257 : 0 : m = calloc(1, MBUF_SIZE);
258 [ # # ]: 0 : if (m == NULL) {
259 : : printf("Cannot create mbuf from heap");
260 : 0 : return NULL;
261 : : }
262 : :
263 : : /* Set the default values to the mbuf */
264 : 0 : m->nb_segs = 1;
265 : 0 : m->port = RTE_MBUF_PORT_INVALID;
266 : 0 : m->buf_len = MBUF_SIZE - sizeof(struct rte_mbuf) - RTE_PKTMBUF_HEADROOM;
267 : : rte_pktmbuf_reset_headroom(m);
268 : : __rte_mbuf_sanity_check(m, 1);
269 : :
270 : 0 : m->buf_addr = (char *)m + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
271 : :
272 : 0 : memset(m->buf_addr, pattern, m->buf_len);
273 : 0 : dst = (uint8_t *)rte_pktmbuf_append(m, pkt_len);
274 [ # # ]: 0 : if (dst == NULL) {
275 : : printf("Cannot append %d bytes to the mbuf\n", pkt_len);
276 : 0 : free(m);
277 : 0 : return NULL;
278 : : }
279 : :
280 : : return m;
281 : : }
282 : :
283 : : int
284 : 0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
285 : : struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
286 : : uint8_t len_in_bits, uint8_t cipher_iv_len)
287 : : {
288 : 0 : struct rte_crypto_sym_op *sop = op->sym;
289 : 0 : struct rte_crypto_op *ret_op = NULL;
290 : : struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
291 : : struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
292 : : union rte_crypto_sym_ofs ofs;
293 : 0 : struct rte_crypto_sym_vec vec = {0};
294 : : struct rte_crypto_sgl sgl, dest_sgl;
295 : : uint32_t max_len;
296 : : union rte_cryptodev_session_ctx sess;
297 : : uint64_t auth_end_iova;
298 : : uint32_t count = 0;
299 : : struct rte_crypto_raw_dp_ctx *ctx;
300 : : uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
301 : : auth_len = 0;
302 : : int32_t n;
303 : : uint32_t n_success;
304 : : int ctx_service_size;
305 : 0 : int32_t status = 0;
306 : : int enqueue_status, dequeue_status;
307 : : struct crypto_unittest_params *ut_params = &unittest_params;
308 : 0 : int is_sgl = sop->m_src->nb_segs > 1;
309 : : int ret = TEST_SUCCESS, is_oop = 0;
310 : :
311 : 0 : ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
312 [ # # ]: 0 : if (ctx_service_size < 0)
313 : : return TEST_SKIPPED;
314 : :
315 : 0 : ctx = malloc(ctx_service_size);
316 [ # # ]: 0 : if (ctx == NULL)
317 : : return TEST_FAILED;
318 : :
319 : : /* Both are enums, setting crypto_sess will suit any session type */
320 : 0 : sess.crypto_sess = op->sym->session;
321 : :
322 : 0 : ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
323 [ # # ]: 0 : if (ret == -ENOTSUP) {
324 : : ret = TEST_SKIPPED;
325 : 0 : goto exit;
326 [ # # ]: 0 : } else if (ret) {
327 : : ret = TEST_FAILED;
328 : 0 : goto exit;
329 : : }
330 : :
331 : 0 : cipher_iv.iova = 0;
332 : 0 : cipher_iv.va = NULL;
333 : 0 : aad_auth_iv.iova = 0;
334 : 0 : aad_auth_iv.va = NULL;
335 : 0 : digest.iova = 0;
336 : 0 : digest.va = NULL;
337 : 0 : sgl.vec = data_vec;
338 : 0 : vec.num = 1;
339 : 0 : vec.src_sgl = &sgl;
340 : 0 : vec.iv = &cipher_iv;
341 : 0 : vec.digest = &digest;
342 : 0 : vec.aad = &aad_auth_iv;
343 : 0 : vec.status = &status;
344 : :
345 : 0 : ofs.raw = 0;
346 : :
347 [ # # # # ]: 0 : if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
348 : : is_oop = 1;
349 : :
350 [ # # ]: 0 : if (is_cipher && is_auth) {
351 : 0 : cipher_offset = sop->cipher.data.offset;
352 : 0 : cipher_len = sop->cipher.data.length;
353 : 0 : auth_offset = sop->auth.data.offset;
354 : 0 : auth_len = sop->auth.data.length;
355 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len,
356 : : auth_offset + auth_len);
357 [ # # ]: 0 : if (len_in_bits) {
358 : 0 : max_len = max_len >> 3;
359 : 0 : cipher_offset = cipher_offset >> 3;
360 : 0 : auth_offset = auth_offset >> 3;
361 : 0 : cipher_len = cipher_len >> 3;
362 : 0 : auth_len = auth_len >> 3;
363 : : }
364 : 0 : ofs.ofs.cipher.head = cipher_offset;
365 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
366 : 0 : ofs.ofs.auth.head = auth_offset;
367 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
368 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
369 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
370 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
371 : : op, void *, IV_OFFSET + cipher_iv_len);
372 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
373 : : cipher_iv_len);
374 : 0 : digest.va = (void *)sop->auth.digest.data;
375 : 0 : digest.iova = sop->auth.digest.phys_addr;
376 : :
377 [ # # ]: 0 : if (is_sgl) {
378 : 0 : uint32_t remaining_off = auth_offset + auth_len;
379 : 0 : struct rte_mbuf *sgl_buf = sop->m_src;
380 [ # # ]: 0 : if (is_oop)
381 : : sgl_buf = sop->m_dst;
382 : :
383 : 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
384 [ # # # # ]: 0 : && sgl_buf->next != NULL) {
385 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
386 : : sgl_buf = sgl_buf->next;
387 : : }
388 : :
389 : 0 : auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
390 : : sgl_buf, remaining_off);
391 : : } else {
392 : 0 : auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
393 : 0 : auth_offset + auth_len;
394 : : }
395 : : /* Then check if digest-encrypted conditions are met */
396 [ # # # # ]: 0 : if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
397 [ # # ]: 0 : (digest.iova == auth_end_iova) && is_sgl)
398 : 0 : max_len = RTE_MAX(max_len,
399 : : auth_offset + auth_len +
400 : : ut_params->auth_xform.auth.digest_length);
401 : :
402 [ # # ]: 0 : } else if (is_cipher) {
403 : 0 : cipher_offset = sop->cipher.data.offset;
404 : 0 : cipher_len = sop->cipher.data.length;
405 : 0 : max_len = cipher_len + cipher_offset;
406 [ # # ]: 0 : if (len_in_bits) {
407 : 0 : max_len = max_len >> 3;
408 : 0 : cipher_offset = cipher_offset >> 3;
409 : 0 : cipher_len = cipher_len >> 3;
410 : : }
411 : 0 : ofs.ofs.cipher.head = cipher_offset;
412 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
413 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
414 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
415 : :
416 [ # # ]: 0 : } else if (is_auth) {
417 : 0 : auth_offset = sop->auth.data.offset;
418 : 0 : auth_len = sop->auth.data.length;
419 : 0 : max_len = auth_len + auth_offset;
420 [ # # ]: 0 : if (len_in_bits) {
421 : 0 : max_len = max_len >> 3;
422 : 0 : auth_offset = auth_offset >> 3;
423 : 0 : auth_len = auth_len >> 3;
424 : : }
425 : 0 : ofs.ofs.auth.head = auth_offset;
426 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
427 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
428 : : op, void *, IV_OFFSET + cipher_iv_len);
429 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
430 : : cipher_iv_len);
431 : 0 : digest.va = (void *)sop->auth.digest.data;
432 : 0 : digest.iova = sop->auth.digest.phys_addr;
433 : :
434 : : } else { /* aead */
435 : 0 : cipher_offset = sop->aead.data.offset;
436 : 0 : cipher_len = sop->aead.data.length;
437 : 0 : max_len = cipher_len + cipher_offset;
438 [ # # ]: 0 : if (len_in_bits) {
439 : 0 : max_len = max_len >> 3;
440 : 0 : cipher_offset = cipher_offset >> 3;
441 : 0 : cipher_len = cipher_len >> 3;
442 : : }
443 : 0 : ofs.ofs.cipher.head = cipher_offset;
444 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
445 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
446 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
447 : 0 : aad_auth_iv.va = (void *)sop->aead.aad.data;
448 : 0 : aad_auth_iv.iova = sop->aead.aad.phys_addr;
449 : 0 : digest.va = (void *)sop->aead.digest.data;
450 : 0 : digest.iova = sop->aead.digest.phys_addr;
451 : : }
452 : :
453 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
454 : : data_vec, RTE_DIM(data_vec));
455 [ # # # # ]: 0 : if (n < 0 || n > sop->m_src->nb_segs) {
456 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
457 : 0 : goto exit;
458 : : }
459 : :
460 : 0 : sgl.num = n;
461 : : /* Out of place */
462 [ # # ]: 0 : if (is_oop) {
463 : 0 : dest_sgl.vec = dest_data_vec;
464 : 0 : vec.dest_sgl = &dest_sgl;
465 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
466 : : dest_data_vec, RTE_DIM(dest_data_vec));
467 [ # # # # ]: 0 : if (n < 0 || n > sop->m_dst->nb_segs) {
468 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
469 : 0 : goto exit;
470 : : }
471 : 0 : dest_sgl.num = n;
472 : : } else
473 : 0 : vec.dest_sgl = NULL;
474 : :
475 [ # # ]: 0 : if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
476 : : &enqueue_status) < 1) {
477 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
478 : 0 : goto exit;
479 : : }
480 : :
481 [ # # ]: 0 : if (enqueue_status == 0) {
482 : 0 : status = rte_cryptodev_raw_enqueue_done(ctx, 1);
483 [ # # ]: 0 : if (status < 0) {
484 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
485 : 0 : goto exit;
486 : : }
487 [ # # ]: 0 : } else if (enqueue_status < 0) {
488 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
489 : 0 : goto exit;
490 : : }
491 : :
492 : 0 : n = n_success = 0;
493 [ # # # # ]: 0 : while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
494 : 0 : n = rte_cryptodev_raw_dequeue_burst(ctx,
495 : : NULL, 1, post_process_raw_dp_op,
496 : : (void **)&ret_op, 0, &n_success,
497 : : &dequeue_status);
498 [ # # ]: 0 : if (dequeue_status < 0) {
499 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
500 : 0 : goto exit;
501 : : }
502 [ # # ]: 0 : if (n == 0)
503 : : rte_pause();
504 : : }
505 : :
506 [ # # # # ]: 0 : if (n == 1 && dequeue_status == 0) {
507 [ # # ]: 0 : if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
508 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
509 : 0 : goto exit;
510 : : }
511 : : }
512 : :
513 [ # # # # ]: 0 : op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
514 [ # # ]: 0 : ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
515 [ # # ]: 0 : n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
516 : : RTE_CRYPTO_OP_STATUS_SUCCESS;
517 : :
518 : 0 : exit:
519 : 0 : free(ctx);
520 : 0 : return ret;
521 : : }
522 : :
523 : : static void
524 : 0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
525 : : {
526 : : int32_t n, st;
527 : : struct rte_crypto_sym_op *sop;
528 : : union rte_crypto_sym_ofs ofs;
529 : : struct rte_crypto_sgl sgl;
530 : 0 : struct rte_crypto_sym_vec symvec = {0};
531 : : struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
532 : : struct rte_crypto_vec vec[UINT8_MAX];
533 : :
534 : : sop = op->sym;
535 : :
536 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
537 : : sop->aead.data.length, vec, RTE_DIM(vec));
538 : :
539 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
540 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
541 : 0 : return;
542 : : }
543 : :
544 : 0 : sgl.vec = vec;
545 : 0 : sgl.num = n;
546 : 0 : symvec.src_sgl = &sgl;
547 : 0 : symvec.iv = &iv_ptr;
548 : 0 : symvec.digest = &digest_ptr;
549 : 0 : symvec.aad = &aad_ptr;
550 : 0 : symvec.status = &st;
551 : 0 : symvec.num = 1;
552 : :
553 : : /* for CPU crypto the IOVA address is not required */
554 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
555 : 0 : digest_ptr.va = (void *)sop->aead.digest.data;
556 : 0 : aad_ptr.va = (void *)sop->aead.aad.data;
557 : :
558 : 0 : ofs.raw = 0;
559 : :
560 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
561 : : &symvec);
562 : :
563 [ # # ]: 0 : if (n != 1)
564 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
565 : : else
566 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
567 : : }
568 : :
569 : : static void
570 : 0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
571 : : {
572 : : int32_t n, st;
573 : : struct rte_crypto_sym_op *sop;
574 : : union rte_crypto_sym_ofs ofs;
575 : : struct rte_crypto_sgl sgl;
576 : 0 : struct rte_crypto_sym_vec symvec = {0};
577 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
578 : : struct rte_crypto_vec vec[UINT8_MAX];
579 : :
580 : : sop = op->sym;
581 : :
582 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
583 : : sop->auth.data.length, vec, RTE_DIM(vec));
584 : :
585 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
586 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
587 : 0 : return;
588 : : }
589 : :
590 : 0 : sgl.vec = vec;
591 : 0 : sgl.num = n;
592 : 0 : symvec.src_sgl = &sgl;
593 : 0 : symvec.iv = &iv_ptr;
594 : 0 : symvec.digest = &digest_ptr;
595 : 0 : symvec.status = &st;
596 : 0 : symvec.num = 1;
597 : :
598 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
599 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
600 : :
601 : 0 : ofs.raw = 0;
602 : 0 : ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
603 : 0 : ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
604 : 0 : (sop->cipher.data.offset + sop->cipher.data.length);
605 : :
606 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
607 : : &symvec);
608 : :
609 [ # # ]: 0 : if (n != 1)
610 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
611 : : else
612 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
613 : : }
614 : :
615 : : static struct rte_crypto_op *
616 : 118 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
617 : : {
618 : :
619 [ - + ]: 118 : RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
620 : :
621 [ - + ]: 118 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
622 : 0 : RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
623 : 0 : return NULL;
624 : : }
625 : :
626 : 118 : op = NULL;
627 : :
628 [ - + ]: 118 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
629 : : rte_pause();
630 : :
631 [ + + ]: 118 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
632 : 11 : RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
633 : 11 : return NULL;
634 : : }
635 : :
636 : : return op;
637 : : }
638 : :
639 : : static int
640 : 1 : testsuite_setup(void)
641 : : {
642 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
643 : : struct rte_cryptodev_info info;
644 : : uint32_t i = 0, nb_devs, dev_id;
645 : : uint16_t qp_id;
646 : :
647 : : memset(ts_params, 0, sizeof(*ts_params));
648 : :
649 : 1 : ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
650 [ + - ]: 1 : if (ts_params->mbuf_pool == NULL) {
651 : : /* Not already created so create */
652 : 1 : ts_params->mbuf_pool = rte_pktmbuf_pool_create(
653 : : "CRYPTO_MBUFPOOL",
654 : : NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
655 : 1 : rte_socket_id());
656 [ - + ]: 1 : if (ts_params->mbuf_pool == NULL) {
657 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
658 : 0 : return TEST_FAILED;
659 : : }
660 : : }
661 : :
662 : 1 : ts_params->large_mbuf_pool = rte_mempool_lookup(
663 : : "CRYPTO_LARGE_MBUFPOOL");
664 [ + - ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
665 : : /* Not already created so create */
666 : 1 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
667 : : "CRYPTO_LARGE_MBUFPOOL",
668 : : 1, 0, 0, LARGE_MBUF_SIZE,
669 : 1 : rte_socket_id());
670 [ - + ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
671 : 0 : RTE_LOG(ERR, USER1,
672 : : "Can't create CRYPTO_LARGE_MBUFPOOL\n");
673 : 0 : return TEST_FAILED;
674 : : }
675 : : }
676 : :
677 : 1 : ts_params->op_mpool = rte_crypto_op_pool_create(
678 : : "MBUF_CRYPTO_SYM_OP_POOL",
679 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC,
680 : : NUM_MBUFS, MBUF_CACHE_SIZE,
681 : : DEFAULT_NUM_XFORMS *
682 : : sizeof(struct rte_crypto_sym_xform) +
683 : : MAXIMUM_IV_LENGTH,
684 : 1 : rte_socket_id());
685 [ - + ]: 1 : if (ts_params->op_mpool == NULL) {
686 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
687 : 0 : return TEST_FAILED;
688 : : }
689 : :
690 : 1 : nb_devs = rte_cryptodev_count();
691 [ - + ]: 1 : if (nb_devs < 1) {
692 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
693 : 0 : return TEST_SKIPPED;
694 : : }
695 : :
696 [ - + ]: 1 : if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
697 : 0 : RTE_LOG(WARNING, USER1, "No %s devices found?\n",
698 : : rte_cryptodev_driver_name_get(gbl_driver_id));
699 : 0 : return TEST_SKIPPED;
700 : : }
701 : :
702 : : /* Create list of valid crypto devs */
703 [ + + ]: 2 : for (i = 0; i < nb_devs; i++) {
704 : 1 : rte_cryptodev_info_get(i, &info);
705 [ + - ]: 1 : if (info.driver_id == gbl_driver_id)
706 : 1 : ts_params->valid_devs[ts_params->valid_dev_count++] = i;
707 : : }
708 : :
709 [ + - ]: 1 : if (ts_params->valid_dev_count < 1)
710 : : return TEST_FAILED;
711 : :
712 : : /* Set up all the qps on the first of the valid devices found */
713 : :
714 : 1 : dev_id = ts_params->valid_devs[0];
715 : :
716 : 1 : rte_cryptodev_info_get(dev_id, &info);
717 : :
718 : 1 : ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
719 : 1 : ts_params->conf.socket_id = SOCKET_ID_ANY;
720 : 1 : ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
721 : :
722 : : unsigned int session_size =
723 : 1 : rte_cryptodev_sym_get_private_session_size(dev_id);
724 : :
725 : : #ifdef RTE_LIB_SECURITY
726 : 1 : unsigned int security_session_size = rte_security_session_get_size(
727 : : rte_cryptodev_get_sec_ctx(dev_id));
728 : :
729 : : if (session_size < security_session_size)
730 : : session_size = security_session_size;
731 : : #endif
732 : : /*
733 : : * Create mempool with maximum number of sessions.
734 : : */
735 [ - + ]: 1 : if (info.sym.max_nb_sessions != 0 &&
736 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
737 : 0 : RTE_LOG(ERR, USER1, "Device does not support "
738 : : "at least %u sessions\n",
739 : : MAX_NB_SESSIONS);
740 : 0 : return TEST_FAILED;
741 : : }
742 : :
743 : 1 : ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
744 : : "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
745 : : SOCKET_ID_ANY);
746 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
747 : : "session mempool allocation failed");
748 : :
749 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
750 : : &ts_params->conf),
751 : : "Failed to configure cryptodev %u with %u qps",
752 : : dev_id, ts_params->conf.nb_queue_pairs);
753 : :
754 : 1 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
755 : 1 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
756 : :
757 [ + + ]: 9 : for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
758 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
759 : : dev_id, qp_id, &ts_params->qp_conf,
760 : : rte_cryptodev_socket_id(dev_id)),
761 : : "Failed to setup queue pair %u on cryptodev %u",
762 : : qp_id, dev_id);
763 : : }
764 : :
765 : : return TEST_SUCCESS;
766 : : }
767 : :
768 : : static void
769 : 1 : testsuite_teardown(void)
770 : : {
771 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
772 : : int res;
773 : :
774 [ + - ]: 1 : if (ts_params->large_mbuf_pool != NULL) {
775 : 1 : rte_mempool_free(ts_params->large_mbuf_pool);
776 : 1 : ts_params->large_mbuf_pool = NULL;
777 : : }
778 : :
779 [ + - ]: 1 : if (ts_params->mbuf_pool != NULL) {
780 : 1 : rte_mempool_free(ts_params->mbuf_pool);
781 : 1 : ts_params->mbuf_pool = NULL;
782 : : }
783 : :
784 [ + - ]: 1 : if (ts_params->op_mpool != NULL) {
785 : 1 : rte_mempool_free(ts_params->op_mpool);
786 : 1 : ts_params->op_mpool = NULL;
787 : : }
788 : :
789 [ + - ]: 1 : if (ts_params->session_mpool != NULL) {
790 : 1 : rte_mempool_free(ts_params->session_mpool);
791 : 1 : ts_params->session_mpool = NULL;
792 : : }
793 : :
794 : 1 : res = rte_cryptodev_close(ts_params->valid_devs[0]);
795 [ - + ]: 1 : if (res)
796 : 0 : RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
797 : 1 : }
798 : :
799 : : static int
800 : 40 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
801 : : const int *algs, uint16_t num_algs)
802 : : {
803 : 40 : uint8_t dev_id = testsuite_params.valid_devs[0];
804 : : bool some_alg_supported = false;
805 : : uint16_t i;
806 : :
807 [ + + ]: 110 : for (i = 0; i < num_algs && !some_alg_supported; i++) {
808 : 70 : struct rte_cryptodev_sym_capability_idx alg = {
809 : 70 : type, {algs[i]}
810 : : };
811 [ + + ]: 70 : if (rte_cryptodev_sym_capability_get(dev_id,
812 : : &alg) != NULL)
813 : : some_alg_supported = true;
814 : : }
815 [ + + ]: 40 : if (!some_alg_supported)
816 : 23 : return TEST_SKIPPED;
817 : :
818 : : return 0;
819 : : }
820 : :
821 : : int
822 : 9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
823 : : uint16_t num_ciphers)
824 : : {
825 : 20 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
826 : : (const int *) ciphers, num_ciphers);
827 : : }
828 : :
829 : : int
830 : 2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
831 : : uint16_t num_auths)
832 : : {
833 : 12 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
834 : : (const int *) auths, num_auths);
835 : : }
836 : :
837 : : int
838 : 0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
839 : : uint16_t num_aeads)
840 : : {
841 : 8 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
842 : : (const int *) aeads, num_aeads);
843 : : }
844 : :
845 : : static int
846 : 1 : null_testsuite_setup(void)
847 : : {
848 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
849 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
850 : : struct rte_cryptodev_info dev_info;
851 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
852 : : RTE_CRYPTO_CIPHER_NULL
853 : : };
854 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
855 : : RTE_CRYPTO_AUTH_NULL
856 : : };
857 : :
858 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
859 : :
860 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
861 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
862 : : "testsuite not met\n");
863 : 0 : return TEST_SKIPPED;
864 : : }
865 : :
866 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
867 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
868 : : RTE_DIM(auths)) != 0) {
869 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for NULL "
870 : : "testsuite not met\n");
871 : 1 : return TEST_SKIPPED;
872 : : }
873 : :
874 : : return 0;
875 : : }
876 : :
877 : : static int
878 : 1 : crypto_gen_testsuite_setup(void)
879 : : {
880 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
881 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
882 : : struct rte_cryptodev_info dev_info;
883 : :
884 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
885 : :
886 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
887 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
888 : : "testsuite not met\n");
889 : 0 : return TEST_SKIPPED;
890 : : }
891 : :
892 : : return 0;
893 : : }
894 : :
895 : : #ifdef RTE_LIB_SECURITY
896 : : static int
897 : 4 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
898 : : {
899 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
900 : : struct crypto_unittest_params *ut_params = &unittest_params;
901 : : struct rte_cryptodev_info dev_info;
902 : : int ret = 0;
903 : :
904 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
905 : :
906 [ + - ]: 4 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
907 : 4 : RTE_LOG(INFO, USER1,
908 : : "Feature flag requirements for security protocol testsuite not met\n");
909 : 4 : return TEST_SKIPPED;
910 : : }
911 : :
912 : : /* Reconfigure to enable security */
913 : 0 : ret = dev_configure_and_start(0);
914 [ # # ]: 0 : if (ret != TEST_SUCCESS)
915 : : return ret;
916 : :
917 : : /* Set action type */
918 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
919 : :
920 [ # # ]: 0 : if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
921 : 0 : RTE_LOG(INFO, USER1,
922 : : "Capability requirements for security protocol test not met\n");
923 : : ret = TEST_SKIPPED;
924 : : }
925 : :
926 : 0 : test_sec_alg_list_populate();
927 : 0 : test_sec_auth_only_alg_list_populate();
928 : :
929 : : /*
930 : : * Stop the device. Device would be started again by individual test
931 : : * case setup routine.
932 : : */
933 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
934 : :
935 : 0 : return ret;
936 : : }
937 : :
938 : : static int
939 : 1 : ipsec_proto_testsuite_setup(void)
940 : : {
941 : 1 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
942 : : }
943 : :
944 : : static int
945 : 3 : tls_record_proto_testsuite_setup(void)
946 : : {
947 : 3 : test_sec_proto_pattern_generate();
948 : :
949 : 3 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
950 : : }
951 : :
952 : : static int
953 : 1 : pdcp_proto_testsuite_setup(void)
954 : : {
955 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
956 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
957 : : struct rte_cryptodev_info dev_info;
958 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
959 : : RTE_CRYPTO_CIPHER_NULL,
960 : : RTE_CRYPTO_CIPHER_AES_CTR,
961 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
962 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
963 : : };
964 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
965 : : RTE_CRYPTO_AUTH_NULL,
966 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
967 : : RTE_CRYPTO_AUTH_AES_CMAC,
968 : : RTE_CRYPTO_AUTH_ZUC_EIA3
969 : : };
970 : :
971 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
972 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
973 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
974 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
975 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
976 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
977 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
978 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
979 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
980 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
981 : :
982 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
983 : :
984 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
985 : : !(dev_info.feature_flags &
986 : : RTE_CRYPTODEV_FF_SECURITY)) {
987 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
988 : : "testsuite not met\n");
989 : 1 : return TEST_SKIPPED;
990 : : }
991 : :
992 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
993 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
994 : : RTE_DIM(auths)) != 0) {
995 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
996 : : "testsuite not met\n");
997 : 0 : return TEST_SKIPPED;
998 : : }
999 : :
1000 : : return 0;
1001 : : }
1002 : :
1003 : : static int
1004 : 1 : docsis_proto_testsuite_setup(void)
1005 : : {
1006 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1007 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1008 : : struct rte_cryptodev_info dev_info;
1009 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1010 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
1011 : : };
1012 : :
1013 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1014 : :
1015 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1016 : : !(dev_info.feature_flags &
1017 : : RTE_CRYPTODEV_FF_SECURITY)) {
1018 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
1019 : : "Proto testsuite not met\n");
1020 : 1 : return TEST_SKIPPED;
1021 : : }
1022 : :
1023 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1024 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
1025 : : "testsuite not met\n");
1026 : 0 : return TEST_SKIPPED;
1027 : : }
1028 : :
1029 : : return 0;
1030 : : }
1031 : : #endif
1032 : :
1033 : : static int
1034 : 1 : aes_ccm_auth_testsuite_setup(void)
1035 : : {
1036 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1037 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1038 : : struct rte_cryptodev_info dev_info;
1039 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1040 : : RTE_CRYPTO_AEAD_AES_CCM
1041 : : };
1042 : :
1043 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1044 : :
1045 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1046 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1047 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1048 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
1049 : : "testsuite not met\n");
1050 : 0 : return TEST_SKIPPED;
1051 : : }
1052 : :
1053 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1054 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
1055 : : "testsuite not met\n");
1056 : 0 : return TEST_SKIPPED;
1057 : : }
1058 : :
1059 : : return 0;
1060 : : }
1061 : :
1062 : : static int
1063 : 1 : aes_gcm_auth_testsuite_setup(void)
1064 : : {
1065 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1066 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1067 : : struct rte_cryptodev_info dev_info;
1068 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1069 : : RTE_CRYPTO_AEAD_AES_GCM
1070 : : };
1071 : :
1072 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1073 : :
1074 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1075 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
1076 : : "testsuite not met\n");
1077 : 0 : return TEST_SKIPPED;
1078 : : }
1079 : :
1080 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1081 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
1082 : : "testsuite not met\n");
1083 : 0 : return TEST_SKIPPED;
1084 : : }
1085 : :
1086 : : return 0;
1087 : : }
1088 : :
1089 : : static int
1090 : 1 : aes_gmac_auth_testsuite_setup(void)
1091 : : {
1092 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1093 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1094 : : struct rte_cryptodev_info dev_info;
1095 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1096 : : RTE_CRYPTO_AUTH_AES_GMAC
1097 : : };
1098 : :
1099 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1100 : :
1101 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1102 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1103 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1104 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1105 : : "testsuite not met\n");
1106 : 0 : return TEST_SKIPPED;
1107 : : }
1108 : :
1109 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1110 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1111 : : "testsuite not met\n");
1112 : 0 : return TEST_SKIPPED;
1113 : : }
1114 : :
1115 : : return 0;
1116 : : }
1117 : :
1118 : : static int
1119 : 1 : chacha20_poly1305_testsuite_setup(void)
1120 : : {
1121 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1122 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1123 : : struct rte_cryptodev_info dev_info;
1124 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1125 : : RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1126 : : };
1127 : :
1128 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1129 : :
1130 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1131 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1132 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1133 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1134 : : "Chacha20-Poly1305 testsuite not met\n");
1135 : 0 : return TEST_SKIPPED;
1136 : : }
1137 : :
1138 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1139 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1140 : : "Chacha20-Poly1305 testsuite not met\n");
1141 : 1 : return TEST_SKIPPED;
1142 : : }
1143 : :
1144 : : return 0;
1145 : : }
1146 : :
1147 : : static int
1148 : 1 : sm4_gcm_testsuite_setup(void)
1149 : : {
1150 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1151 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1152 : : struct rte_cryptodev_info dev_info;
1153 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1154 : : RTE_CRYPTO_AEAD_SM4_GCM
1155 : : };
1156 : :
1157 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1158 : :
1159 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1160 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1161 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1162 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1163 : : "SM4 GCM testsuite not met\n");
1164 : 0 : return TEST_SKIPPED;
1165 : : }
1166 : :
1167 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1168 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1169 : : "SM4 GCM testsuite not met\n");
1170 : 1 : return TEST_SKIPPED;
1171 : : }
1172 : :
1173 : : return 0;
1174 : : }
1175 : :
1176 : : static int
1177 : 1 : snow3g_testsuite_setup(void)
1178 : : {
1179 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1180 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1181 : : struct rte_cryptodev_info dev_info;
1182 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1183 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1184 : :
1185 : : };
1186 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1187 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2
1188 : : };
1189 : :
1190 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1191 : :
1192 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1193 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1194 : : "testsuite not met\n");
1195 : 0 : return TEST_SKIPPED;
1196 : : }
1197 : :
1198 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1199 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1200 : : RTE_DIM(auths)) != 0) {
1201 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1202 : : "testsuite not met\n");
1203 : 1 : return TEST_SKIPPED;
1204 : : }
1205 : :
1206 : : return 0;
1207 : : }
1208 : :
1209 : : static int
1210 : 1 : zuc_testsuite_setup(void)
1211 : : {
1212 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1213 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1214 : : struct rte_cryptodev_info dev_info;
1215 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1216 : : RTE_CRYPTO_CIPHER_ZUC_EEA3
1217 : : };
1218 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1219 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1220 : : };
1221 : :
1222 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1223 : :
1224 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1225 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1226 : : "testsuite not met\n");
1227 : 0 : return TEST_SKIPPED;
1228 : : }
1229 : :
1230 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1231 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1232 : : RTE_DIM(auths)) != 0) {
1233 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1234 : : "testsuite not met\n");
1235 : 1 : return TEST_SKIPPED;
1236 : : }
1237 : :
1238 : : return 0;
1239 : : }
1240 : :
1241 : : static int
1242 : 1 : hmac_md5_auth_testsuite_setup(void)
1243 : : {
1244 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1245 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1246 : : struct rte_cryptodev_info dev_info;
1247 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1248 : : RTE_CRYPTO_AUTH_MD5_HMAC
1249 : : };
1250 : :
1251 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1252 : :
1253 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1254 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1255 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1256 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1257 : : "Auth testsuite not met\n");
1258 : 0 : return TEST_SKIPPED;
1259 : : }
1260 : :
1261 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1262 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1263 : : "testsuite not met\n");
1264 : 0 : return TEST_SKIPPED;
1265 : : }
1266 : :
1267 : : return 0;
1268 : : }
1269 : :
1270 : : static int
1271 : 1 : kasumi_testsuite_setup(void)
1272 : : {
1273 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1274 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1275 : : struct rte_cryptodev_info dev_info;
1276 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1277 : : RTE_CRYPTO_CIPHER_KASUMI_F8
1278 : : };
1279 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1280 : : RTE_CRYPTO_AUTH_KASUMI_F9
1281 : : };
1282 : :
1283 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1284 : :
1285 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1286 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1287 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1288 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1289 : : "testsuite not met\n");
1290 : 0 : return TEST_SKIPPED;
1291 : : }
1292 : :
1293 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1294 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1295 : : RTE_DIM(auths)) != 0) {
1296 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1297 : : "testsuite not met\n");
1298 : 1 : return TEST_SKIPPED;
1299 : : }
1300 : :
1301 : : return 0;
1302 : : }
1303 : :
1304 : : static int
1305 : 1 : negative_aes_gcm_testsuite_setup(void)
1306 : : {
1307 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1308 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1309 : : struct rte_cryptodev_info dev_info;
1310 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1311 : : RTE_CRYPTO_AEAD_AES_GCM
1312 : : };
1313 : :
1314 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1315 : :
1316 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1317 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1318 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1319 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1320 : : "AES GCM testsuite not met\n");
1321 : 0 : return TEST_SKIPPED;
1322 : : }
1323 : :
1324 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1325 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1326 : : "AES GCM testsuite not met\n");
1327 : 0 : return TEST_SKIPPED;
1328 : : }
1329 : :
1330 : : return 0;
1331 : : }
1332 : :
1333 : : static int
1334 : 1 : negative_aes_gmac_testsuite_setup(void)
1335 : : {
1336 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1337 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1338 : : struct rte_cryptodev_info dev_info;
1339 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1340 : : RTE_CRYPTO_AUTH_AES_GMAC
1341 : : };
1342 : :
1343 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1344 : :
1345 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1346 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1347 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1348 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1349 : : "AES GMAC testsuite not met\n");
1350 : 0 : return TEST_SKIPPED;
1351 : : }
1352 : :
1353 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1354 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1355 : : "AES GMAC testsuite not met\n");
1356 : 0 : return TEST_SKIPPED;
1357 : : }
1358 : :
1359 : : return 0;
1360 : : }
1361 : :
1362 : : static int
1363 : 1 : mixed_cipher_hash_testsuite_setup(void)
1364 : : {
1365 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1366 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1367 : : struct rte_cryptodev_info dev_info;
1368 : : uint64_t feat_flags;
1369 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1370 : : RTE_CRYPTO_CIPHER_NULL,
1371 : : RTE_CRYPTO_CIPHER_AES_CTR,
1372 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
1373 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1374 : : };
1375 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1376 : : RTE_CRYPTO_AUTH_NULL,
1377 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1378 : : RTE_CRYPTO_AUTH_AES_CMAC,
1379 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1380 : : };
1381 : :
1382 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1383 : 1 : feat_flags = dev_info.feature_flags;
1384 : :
1385 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1386 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1387 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1388 : : "Cipher Hash testsuite not met\n");
1389 : 0 : return TEST_SKIPPED;
1390 : : }
1391 : :
1392 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1393 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1394 : : RTE_DIM(auths)) != 0) {
1395 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1396 : : "Cipher Hash testsuite not met\n");
1397 : 0 : return TEST_SKIPPED;
1398 : : }
1399 : :
1400 : : return 0;
1401 : : }
1402 : :
1403 : : static int
1404 : 1 : esn_testsuite_setup(void)
1405 : : {
1406 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1407 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1408 : : struct rte_cryptodev_info dev_info;
1409 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1410 : : RTE_CRYPTO_CIPHER_AES_CBC
1411 : : };
1412 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1413 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1414 : : };
1415 : :
1416 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1417 : :
1418 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1419 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1420 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1421 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1422 : : "testsuite not met\n");
1423 : 0 : return TEST_SKIPPED;
1424 : : }
1425 : :
1426 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1427 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1428 : : RTE_DIM(auths)) != 0) {
1429 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1430 : : "testsuite not met\n");
1431 : 0 : return TEST_SKIPPED;
1432 : : }
1433 : :
1434 : : return 0;
1435 : : }
1436 : :
1437 : : static int
1438 : 1 : multi_session_testsuite_setup(void)
1439 : : {
1440 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1441 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1442 : : struct rte_cryptodev_info dev_info;
1443 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1444 : : RTE_CRYPTO_CIPHER_AES_CBC
1445 : : };
1446 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1447 : : RTE_CRYPTO_AUTH_SHA512_HMAC
1448 : : };
1449 : :
1450 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1451 : :
1452 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1453 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1454 : : "Session testsuite not met\n");
1455 : 0 : return TEST_SKIPPED;
1456 : : }
1457 : :
1458 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1459 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1460 : : RTE_DIM(auths)) != 0) {
1461 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1462 : : "Session testsuite not met\n");
1463 : 0 : return TEST_SKIPPED;
1464 : : }
1465 : :
1466 : : return 0;
1467 : : }
1468 : :
1469 : : static int
1470 : 1 : negative_hmac_sha1_testsuite_setup(void)
1471 : : {
1472 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1473 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1474 : : struct rte_cryptodev_info dev_info;
1475 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1476 : : RTE_CRYPTO_CIPHER_AES_CBC
1477 : : };
1478 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1479 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1480 : : };
1481 : :
1482 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1483 : :
1484 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1485 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1486 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1487 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1488 : : "HMAC SHA1 testsuite not met\n");
1489 : 0 : return TEST_SKIPPED;
1490 : : }
1491 : :
1492 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1493 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1494 : : RTE_DIM(auths)) != 0) {
1495 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1496 : : "HMAC SHA1 testsuite not met\n");
1497 : 0 : return TEST_SKIPPED;
1498 : : }
1499 : :
1500 : : return 0;
1501 : : }
1502 : :
1503 : : static int
1504 : 440 : dev_configure_and_start(uint64_t ff_disable)
1505 : : {
1506 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1507 : : struct crypto_unittest_params *ut_params = &unittest_params;
1508 : :
1509 : : uint16_t qp_id;
1510 : :
1511 : : /* Clear unit test parameters before running test */
1512 : : memset(ut_params, 0, sizeof(*ut_params));
1513 : :
1514 : : /* Reconfigure device to default parameters */
1515 : 440 : ts_params->conf.socket_id = SOCKET_ID_ANY;
1516 : 440 : ts_params->conf.ff_disable = ff_disable;
1517 : 440 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1518 : 440 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
1519 : :
1520 [ - + ]: 440 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1521 : : &ts_params->conf),
1522 : : "Failed to configure cryptodev %u",
1523 : : ts_params->valid_devs[0]);
1524 : :
1525 [ + + ]: 3960 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1526 [ - + ]: 3520 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1527 : : ts_params->valid_devs[0], qp_id,
1528 : : &ts_params->qp_conf,
1529 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1530 : : "Failed to setup queue pair %u on cryptodev %u",
1531 : : qp_id, ts_params->valid_devs[0]);
1532 : : }
1533 : :
1534 : :
1535 : 440 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1536 : :
1537 : : /* Start the device */
1538 [ - + ]: 440 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1539 : : "Failed to start cryptodev %u",
1540 : : ts_params->valid_devs[0]);
1541 : :
1542 : : return TEST_SUCCESS;
1543 : : }
1544 : :
1545 : : int
1546 : 440 : ut_setup(void)
1547 : : {
1548 : : /* Configure and start the device with security feature disabled */
1549 : 440 : return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1550 : : }
1551 : :
1552 : : static int
1553 : 0 : ut_setup_security(void)
1554 : : {
1555 : : /* Configure and start the device with no features disabled */
1556 : 0 : return dev_configure_and_start(0);
1557 : : }
1558 : :
1559 : : static int
1560 : 0 : ut_setup_security_rx_inject(void)
1561 : : {
1562 : 0 : struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1563 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1564 : 0 : struct rte_eth_conf port_conf = {
1565 : : .rxmode = {
1566 : : .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1567 : : RTE_ETH_RX_OFFLOAD_SECURITY |
1568 : : RTE_ETH_RX_OFFLOAD_SCATTER,
1569 : : },
1570 : : .txmode = {
1571 : : .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1572 : : },
1573 : : .lpbk_mode = 1, /* Enable loopback */
1574 : : };
1575 : : struct rte_cryptodev_info dev_info;
1576 : 0 : struct rte_eth_rxconf rx_conf = {
1577 : : .rx_thresh = {
1578 : : .pthresh = 8,
1579 : : .hthresh = 8,
1580 : : .wthresh = 8,
1581 : : },
1582 : : .rx_free_thresh = 32,
1583 : : };
1584 : : uint16_t nb_ports;
1585 : : void *sec_ctx;
1586 : : int ret;
1587 : :
1588 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1589 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1590 : : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1591 : 0 : RTE_LOG(INFO, USER1,
1592 : : "Feature requirements for IPsec Rx inject test case not met\n");
1593 : 0 : return TEST_SKIPPED;
1594 : : }
1595 : :
1596 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1597 [ # # ]: 0 : if (sec_ctx == NULL)
1598 : : return TEST_SKIPPED;
1599 : :
1600 : 0 : nb_ports = rte_eth_dev_count_avail();
1601 [ # # ]: 0 : if (nb_ports == 0)
1602 : : return TEST_SKIPPED;
1603 : :
1604 : 0 : ret = rte_eth_dev_configure(0 /* port_id */,
1605 : : 1 /* nb_rx_queue */,
1606 : : 0 /* nb_tx_queue */,
1607 : : &port_conf);
1608 [ # # ]: 0 : if (ret) {
1609 : : printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1610 : 0 : return TEST_SKIPPED;
1611 : : }
1612 : :
1613 : : /* Rx queue setup */
1614 : 0 : ret = rte_eth_rx_queue_setup(0 /* port_id */,
1615 : : 0 /* rx_queue_id */,
1616 : : 1024 /* nb_rx_desc */,
1617 : : SOCKET_ID_ANY,
1618 : : &rx_conf,
1619 : : mbuf_pool);
1620 [ # # ]: 0 : if (ret) {
1621 : : printf("Could not setup eth port 0 queue 0\n");
1622 : 0 : return TEST_SKIPPED;
1623 : : }
1624 : :
1625 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1626 [ # # ]: 0 : if (ret) {
1627 : : printf("Could not enable Rx inject offload");
1628 : 0 : return TEST_SKIPPED;
1629 : : }
1630 : :
1631 : 0 : ret = rte_eth_dev_start(0);
1632 [ # # ]: 0 : if (ret) {
1633 : : printf("Could not start ethdev");
1634 : 0 : return TEST_SKIPPED;
1635 : : }
1636 : :
1637 : 0 : ret = rte_eth_promiscuous_enable(0);
1638 [ # # ]: 0 : if (ret) {
1639 : : printf("Could not enable promiscuous mode");
1640 : 0 : return TEST_SKIPPED;
1641 : : }
1642 : :
1643 : : /* Configure and start cryptodev with no features disabled */
1644 : 0 : return dev_configure_and_start(0);
1645 : : }
1646 : :
1647 : : static inline void
1648 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1649 : : {
1650 : 0 : }
1651 : :
1652 : : static inline void
1653 : 110 : ext_mbuf_memzone_free(int nb_segs)
1654 : : {
1655 : : int i;
1656 : :
1657 [ + + ]: 330 : for (i = 0; i <= nb_segs; i++) {
1658 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1659 : : const struct rte_memzone *memzone;
1660 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1661 : 220 : memzone = rte_memzone_lookup(mz_name);
1662 [ + + ]: 220 : if (memzone != NULL) {
1663 : 2 : rte_memzone_free(memzone);
1664 : : memzone = NULL;
1665 : : }
1666 : : }
1667 : 110 : }
1668 : :
1669 : : static inline struct rte_mbuf *
1670 : 2 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1671 : : int nb_segs, const void *input_text)
1672 : : {
1673 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
1674 : : size_t data_off = 0;
1675 : : uint8_t *dst;
1676 : : int i, size;
1677 : : int t_len;
1678 : :
1679 [ - + ]: 2 : if (pkt_len < 1) {
1680 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1681 : 0 : return NULL;
1682 : : }
1683 : :
1684 [ - + ]: 2 : if (nb_segs < 1) {
1685 : : printf("Number of segments must be 1 or more (is %d)\n",
1686 : : nb_segs);
1687 : 0 : return NULL;
1688 : : }
1689 : :
1690 [ + - ]: 2 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1691 : : size = pkt_len;
1692 : :
1693 : : /* Create chained mbuf_src with external buffer */
1694 [ + + ]: 4 : for (i = 0; size > 0; i++) {
1695 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1696 : 2 : uint16_t data_len = RTE_MIN(size, t_len);
1697 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1698 : : const struct rte_memzone *memzone;
1699 : : void *ext_buf_addr = NULL;
1700 : : rte_iova_t buf_iova;
1701 : 2 : bool freed = false;
1702 : : uint16_t buf_len;
1703 : :
1704 : 2 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1705 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
1706 : :
1707 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1708 : 2 : memzone = rte_memzone_lookup(mz_name);
1709 [ - + - - ]: 2 : if (memzone != NULL && memzone->len != buf_len) {
1710 : 0 : rte_memzone_free(memzone);
1711 : : memzone = NULL;
1712 : : }
1713 [ + - ]: 2 : if (memzone == NULL) {
1714 : 2 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1715 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1716 [ - + ]: 2 : if (memzone == NULL) {
1717 : : printf("Can't allocate memory zone %s\n", mz_name);
1718 : 0 : return NULL;
1719 : : }
1720 : : }
1721 : :
1722 : 2 : ext_buf_addr = memzone->addr;
1723 [ - + ]: 2 : if (input_text)
1724 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1725 : :
1726 : : /* Create buffer to hold rte_mbuf header */
1727 : 2 : m = rte_pktmbuf_alloc(mbuf_pool);
1728 [ + - ]: 2 : if (i == 0)
1729 : : mbuf = m;
1730 : :
1731 [ - + ]: 2 : if (m == NULL) {
1732 : : printf("Cannot create segment for source mbuf");
1733 : 0 : goto fail;
1734 : : }
1735 : :
1736 : : /* Save shared data (like callback function) in external buffer's end */
1737 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1738 : : ext_mbuf_callback_fn_free, &freed);
1739 : : if (ret_shinfo == NULL) {
1740 : : printf("Shared mem initialization failed!\n");
1741 : 0 : goto fail;
1742 : : }
1743 : :
1744 : 2 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
1745 : :
1746 : : /* Attach external buffer to mbuf */
1747 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1748 : : ret_shinfo);
1749 [ - + ]: 2 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1750 : : printf("External buffer is not attached to mbuf\n");
1751 : 0 : goto fail;
1752 : : }
1753 : :
1754 [ - + ]: 2 : if (input_text) {
1755 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1756 [ # # ]: 0 : if (dst == NULL) {
1757 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
1758 : 0 : goto fail;
1759 : : }
1760 : : }
1761 : :
1762 [ - + ]: 2 : if (mbuf != m)
1763 : : rte_pktmbuf_chain(mbuf, m);
1764 : :
1765 : 2 : size -= data_len;
1766 : 2 : data_off += data_len;
1767 : : }
1768 : :
1769 : : return mbuf;
1770 : :
1771 : : fail:
1772 : 0 : rte_pktmbuf_free(mbuf);
1773 : 0 : ext_mbuf_memzone_free(nb_segs);
1774 : 0 : return NULL;
1775 : : }
1776 : :
1777 : : void
1778 : 440 : ut_teardown(void)
1779 : : {
1780 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1781 : : struct crypto_unittest_params *ut_params = &unittest_params;
1782 : :
1783 : : /* free crypto session structure */
1784 : : #ifdef RTE_LIB_SECURITY
1785 [ - + ]: 440 : if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1786 [ # # ]: 0 : if (ut_params->sec_session) {
1787 : 0 : rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1788 : 0 : (ts_params->valid_devs[0]),
1789 : : ut_params->sec_session);
1790 : 0 : ut_params->sec_session = NULL;
1791 : : }
1792 : : } else
1793 : : #endif
1794 : : {
1795 [ + + ]: 440 : if (ut_params->sess) {
1796 : 111 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1797 : : ut_params->sess);
1798 : 111 : ut_params->sess = NULL;
1799 : : }
1800 : : }
1801 : :
1802 : : /* free crypto operation structure */
1803 : 440 : rte_crypto_op_free(ut_params->op);
1804 : :
1805 : : /*
1806 : : * free mbuf - both obuf and ibuf are usually the same,
1807 : : * so check if they point at the same address is necessary,
1808 : : * to avoid freeing the mbuf twice.
1809 : : */
1810 [ + + ]: 440 : if (ut_params->obuf) {
1811 : 6 : rte_pktmbuf_free(ut_params->obuf);
1812 [ + + ]: 6 : if (ut_params->ibuf == ut_params->obuf)
1813 : 3 : ut_params->ibuf = 0;
1814 : 6 : ut_params->obuf = 0;
1815 : : }
1816 [ + + ]: 440 : if (ut_params->ibuf) {
1817 : 110 : ext_mbuf_memzone_free(1);
1818 : 110 : rte_pktmbuf_free(ut_params->ibuf);
1819 : 110 : ut_params->ibuf = 0;
1820 : : }
1821 : :
1822 [ + - ]: 440 : if (ts_params->mbuf_pool != NULL)
1823 : 440 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1824 : : rte_mempool_avail_count(ts_params->mbuf_pool));
1825 : :
1826 : : /* Stop the device */
1827 : 440 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1828 : 440 : }
1829 : :
1830 : : static void
1831 : 0 : ut_teardown_rx_inject(void)
1832 : : {
1833 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1834 : : void *sec_ctx;
1835 : : int ret;
1836 : :
1837 [ # # ]: 0 : if (rte_eth_dev_count_avail() != 0) {
1838 : 0 : ret = rte_eth_dev_reset(0);
1839 [ # # ]: 0 : if (ret)
1840 : : printf("Could not reset eth port 0");
1841 : :
1842 : : }
1843 : :
1844 : 0 : ut_teardown();
1845 : :
1846 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1847 [ # # ]: 0 : if (sec_ctx == NULL)
1848 : : return;
1849 : :
1850 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1851 [ # # ]: 0 : if (ret) {
1852 : : printf("Could not disable Rx inject offload");
1853 : 0 : return;
1854 : : }
1855 : : }
1856 : :
1857 : : static int
1858 : 1 : test_device_configure_invalid_dev_id(void)
1859 : : {
1860 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1861 : : uint16_t dev_id, num_devs = 0;
1862 : :
1863 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1864 : : "Need at least %d devices for test", 1);
1865 : :
1866 : : /* valid dev_id values */
1867 : 1 : dev_id = ts_params->valid_devs[0];
1868 : :
1869 : : /* Stop the device in case it's started so it can be configured */
1870 : 1 : rte_cryptodev_stop(dev_id);
1871 : :
1872 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1873 : : "Failed test for rte_cryptodev_configure: "
1874 : : "invalid dev_num %u", dev_id);
1875 : :
1876 : : /* invalid dev_id values */
1877 : : dev_id = num_devs;
1878 : :
1879 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1880 : : "Failed test for rte_cryptodev_configure: "
1881 : : "invalid dev_num %u", dev_id);
1882 : :
1883 : : dev_id = 0xff;
1884 : :
1885 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1886 : : "Failed test for rte_cryptodev_configure:"
1887 : : "invalid dev_num %u", dev_id);
1888 : :
1889 : : return TEST_SUCCESS;
1890 : : }
1891 : :
1892 : : static int
1893 : 1 : test_device_configure_invalid_queue_pair_ids(void)
1894 : : {
1895 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1896 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1897 : :
1898 : : /* Stop the device in case it's started so it can be configured */
1899 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1900 : :
1901 : : /* valid - max value queue pairs */
1902 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1903 : :
1904 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1905 : : &ts_params->conf),
1906 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1907 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1908 : :
1909 : : /* valid - one queue pairs */
1910 : 1 : ts_params->conf.nb_queue_pairs = 1;
1911 : :
1912 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1913 : : &ts_params->conf),
1914 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1915 : : ts_params->valid_devs[0],
1916 : : ts_params->conf.nb_queue_pairs);
1917 : :
1918 : :
1919 : : /* invalid - zero queue pairs */
1920 : 1 : ts_params->conf.nb_queue_pairs = 0;
1921 : :
1922 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1923 : : &ts_params->conf),
1924 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1925 : : " invalid qps: %u",
1926 : : ts_params->valid_devs[0],
1927 : : ts_params->conf.nb_queue_pairs);
1928 : :
1929 : :
1930 : : /* invalid - max value supported by field queue pairs */
1931 : 1 : ts_params->conf.nb_queue_pairs = UINT16_MAX;
1932 : :
1933 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1934 : : &ts_params->conf),
1935 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1936 : : " invalid qps: %u",
1937 : : ts_params->valid_devs[0],
1938 : : ts_params->conf.nb_queue_pairs);
1939 : :
1940 : :
1941 : : /* invalid - max value + 1 queue pairs */
1942 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1943 : :
1944 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1945 : : &ts_params->conf),
1946 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1947 : : " invalid qps: %u",
1948 : : ts_params->valid_devs[0],
1949 : : ts_params->conf.nb_queue_pairs);
1950 : :
1951 : : /* revert to original testsuite value */
1952 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1953 : :
1954 : 1 : return TEST_SUCCESS;
1955 : : }
1956 : :
1957 : : static int
1958 : 1 : test_queue_pair_descriptor_setup(void)
1959 : : {
1960 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1961 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
1962 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1963 : : };
1964 : : uint16_t qp_id;
1965 : :
1966 : : /* Stop the device in case it's started so it can be configured */
1967 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1968 : :
1969 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1970 : : &ts_params->conf),
1971 : : "Failed to configure cryptodev %u",
1972 : : ts_params->valid_devs[0]);
1973 : :
1974 : : /*
1975 : : * Test various ring sizes on this device. memzones can't be
1976 : : * freed so are re-used if ring is released and re-created.
1977 : : */
1978 : 1 : qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1979 : 1 : qp_conf.mp_session = ts_params->session_mpool;
1980 : :
1981 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1982 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1983 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1984 : : rte_cryptodev_socket_id(
1985 : : ts_params->valid_devs[0])),
1986 : : "Failed test for "
1987 : : "rte_cryptodev_queue_pair_setup: num_inflights "
1988 : : "%u on qp %u on cryptodev %u",
1989 : : qp_conf.nb_descriptors, qp_id,
1990 : : ts_params->valid_devs[0]);
1991 : : }
1992 : :
1993 : 1 : qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1994 : :
1995 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1996 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1997 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1998 : : rte_cryptodev_socket_id(
1999 : : ts_params->valid_devs[0])),
2000 : : "Failed test for"
2001 : : " rte_cryptodev_queue_pair_setup: num_inflights"
2002 : : " %u on qp %u on cryptodev %u",
2003 : : qp_conf.nb_descriptors, qp_id,
2004 : : ts_params->valid_devs[0]);
2005 : : }
2006 : :
2007 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
2008 : :
2009 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
2010 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
2011 : : ts_params->valid_devs[0], qp_id, &qp_conf,
2012 : : rte_cryptodev_socket_id(
2013 : : ts_params->valid_devs[0])),
2014 : : "Failed test for "
2015 : : "rte_cryptodev_queue_pair_setup: num_inflights"
2016 : : " %u on qp %u on cryptodev %u",
2017 : : qp_conf.nb_descriptors, qp_id,
2018 : : ts_params->valid_devs[0]);
2019 : : }
2020 : :
2021 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
2022 : :
2023 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
2024 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
2025 : : ts_params->valid_devs[0], qp_id, &qp_conf,
2026 : : rte_cryptodev_socket_id(
2027 : : ts_params->valid_devs[0])),
2028 : : "Failed test for"
2029 : : " rte_cryptodev_queue_pair_setup:"
2030 : : "num_inflights %u on qp %u on cryptodev %u",
2031 : : qp_conf.nb_descriptors, qp_id,
2032 : : ts_params->valid_devs[0]);
2033 : : }
2034 : :
2035 : : /* test invalid queue pair id */
2036 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
2037 : :
2038 : : qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
2039 : :
2040 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2041 : : ts_params->valid_devs[0],
2042 : : qp_id, &qp_conf,
2043 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2044 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2045 : : "invalid qp %u on cryptodev %u",
2046 : : qp_id, ts_params->valid_devs[0]);
2047 : :
2048 : : qp_id = 0xffff; /*invalid*/
2049 : :
2050 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2051 : : ts_params->valid_devs[0],
2052 : : qp_id, &qp_conf,
2053 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2054 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2055 : : "invalid qp %u on cryptodev %u",
2056 : : qp_id, ts_params->valid_devs[0]);
2057 : :
2058 : : return TEST_SUCCESS;
2059 : : }
2060 : :
2061 : : /* ***** Plaintext data for tests ***** */
2062 : :
2063 : : const char catch_22_quote_1[] =
2064 : : "There was only one catch and that was Catch-22, which "
2065 : : "specified that a concern for one's safety in the face of "
2066 : : "dangers that were real and immediate was the process of a "
2067 : : "rational mind. Orr was crazy and could be grounded. All he "
2068 : : "had to do was ask; and as soon as he did, he would no longer "
2069 : : "be crazy and would have to fly more missions. Orr would be "
2070 : : "crazy to fly more missions and sane if he didn't, but if he "
2071 : : "was sane he had to fly them. If he flew them he was crazy "
2072 : : "and didn't have to; but if he didn't want to he was sane and "
2073 : : "had to. Yossarian was moved very deeply by the absolute "
2074 : : "simplicity of this clause of Catch-22 and let out a "
2075 : : "respectful whistle. \"That's some catch, that Catch-22\", he "
2076 : : "observed. \"It's the best there is,\" Doc Daneeka agreed.";
2077 : :
2078 : : const char catch_22_quote[] =
2079 : : "What a lousy earth! He wondered how many people were "
2080 : : "destitute that same night even in his own prosperous country, "
2081 : : "how many homes were shanties, how many husbands were drunk "
2082 : : "and wives socked, and how many children were bullied, abused, "
2083 : : "or abandoned. How many families hungered for food they could "
2084 : : "not afford to buy? How many hearts were broken? How many "
2085 : : "suicides would take place that same night, how many people "
2086 : : "would go insane? How many cockroaches and landlords would "
2087 : : "triumph? How many winners were losers, successes failures, "
2088 : : "and rich men poor men? How many wise guys were stupid? How "
2089 : : "many happy endings were unhappy endings? How many honest men "
2090 : : "were liars, brave men cowards, loyal men traitors, how many "
2091 : : "sainted men were corrupt, how many people in positions of "
2092 : : "trust had sold their souls to bodyguards, how many had never "
2093 : : "had souls? How many straight-and-narrow paths were crooked "
2094 : : "paths? How many best families were worst families and how "
2095 : : "many good people were bad people? When you added them all up "
2096 : : "and then subtracted, you might be left with only the children, "
2097 : : "and perhaps with Albert Einstein and an old violinist or "
2098 : : "sculptor somewhere.";
2099 : :
2100 : : #define QUOTE_480_BYTES (480)
2101 : : #define QUOTE_512_BYTES (512)
2102 : : #define QUOTE_768_BYTES (768)
2103 : : #define QUOTE_1024_BYTES (1024)
2104 : :
2105 : :
2106 : :
2107 : : /* ***** SHA1 Hash Tests ***** */
2108 : :
2109 : : #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
2110 : :
2111 : : static uint8_t hmac_sha1_key[] = {
2112 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
2113 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
2114 : : 0xDE, 0xF4, 0xDE, 0xAD };
2115 : :
2116 : : /* ***** SHA224 Hash Tests ***** */
2117 : :
2118 : : #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
2119 : :
2120 : :
2121 : : /* ***** AES-CBC Cipher Tests ***** */
2122 : :
2123 : : #define CIPHER_KEY_LENGTH_AES_CBC (16)
2124 : : #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
2125 : :
2126 : : static uint8_t aes_cbc_key[] = {
2127 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2128 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2129 : :
2130 : : static uint8_t aes_cbc_iv[] = {
2131 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2132 : : 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2133 : :
2134 : :
2135 : : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2136 : :
2137 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2138 : : 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2139 : : 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2140 : : 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2141 : : 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2142 : : 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2143 : : 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2144 : : 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2145 : : 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2146 : : 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2147 : : 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2148 : : 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2149 : : 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2150 : : 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2151 : : 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2152 : : 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2153 : : 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2154 : : 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2155 : : 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2156 : : 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2157 : : 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2158 : : 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2159 : : 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2160 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2161 : : 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2162 : : 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2163 : : 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2164 : : 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2165 : : 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2166 : : 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2167 : : 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2168 : : 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2169 : : 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2170 : : 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2171 : : 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2172 : : 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2173 : : 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2174 : : 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2175 : : 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2176 : : 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2177 : : 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2178 : : 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2179 : : 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2180 : : 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2181 : : 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2182 : : 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2183 : : 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2184 : : 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2185 : : 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2186 : : 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2187 : : 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2188 : : 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2189 : : 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2190 : : 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2191 : : 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2192 : : 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2193 : : 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2194 : : 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2195 : : 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2196 : : 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2197 : : 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2198 : : 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2199 : : 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2200 : : 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2201 : : 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2202 : : };
2203 : :
2204 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2205 : : 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2206 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2207 : : 0x18, 0x8c, 0x1d, 0x32
2208 : : };
2209 : :
2210 : :
2211 : : /* Multisession Vector context Test */
2212 : : /*Begin Session 0 */
2213 : : static uint8_t ms_aes_cbc_key0[] = {
2214 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2215 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2216 : : };
2217 : :
2218 : : static uint8_t ms_aes_cbc_iv0[] = {
2219 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2220 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2221 : : };
2222 : :
2223 : : static const uint8_t ms_aes_cbc_cipher0[] = {
2224 : : 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2225 : : 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2226 : : 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2227 : : 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2228 : : 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2229 : : 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2230 : : 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2231 : : 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2232 : : 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2233 : : 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2234 : : 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2235 : : 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2236 : : 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2237 : : 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2238 : : 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2239 : : 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2240 : : 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2241 : : 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2242 : : 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2243 : : 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2244 : : 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2245 : : 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2246 : : 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2247 : : 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2248 : : 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2249 : : 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2250 : : 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2251 : : 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2252 : : 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2253 : : 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2254 : : 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2255 : : 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2256 : : 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2257 : : 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2258 : : 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2259 : : 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2260 : : 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2261 : : 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2262 : : 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2263 : : 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2264 : : 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2265 : : 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2266 : : 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2267 : : 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2268 : : 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2269 : : 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2270 : : 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2271 : : 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2272 : : 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2273 : : 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2274 : : 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2275 : : 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2276 : : 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2277 : : 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2278 : : 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2279 : : 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2280 : : 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2281 : : 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2282 : : 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2283 : : 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2284 : : 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2285 : : 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2286 : : 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2287 : : 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2288 : : };
2289 : :
2290 : :
2291 : : static uint8_t ms_hmac_key0[] = {
2292 : : 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2293 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2294 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2295 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2296 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2297 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2298 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2299 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2300 : : };
2301 : :
2302 : : static const uint8_t ms_hmac_digest0[] = {
2303 : : 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2304 : : 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2305 : : 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2306 : : 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2307 : : 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2308 : : 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2309 : : 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2310 : : 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2311 : : };
2312 : :
2313 : : /* End Session 0 */
2314 : : /* Begin session 1 */
2315 : :
2316 : : static uint8_t ms_aes_cbc_key1[] = {
2317 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2318 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2319 : : };
2320 : :
2321 : : static uint8_t ms_aes_cbc_iv1[] = {
2322 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2323 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2324 : : };
2325 : :
2326 : : static const uint8_t ms_aes_cbc_cipher1[] = {
2327 : : 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2328 : : 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2329 : : 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2330 : : 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2331 : : 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2332 : : 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2333 : : 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2334 : : 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2335 : : 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2336 : : 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2337 : : 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2338 : : 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2339 : : 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2340 : : 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2341 : : 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2342 : : 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2343 : : 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2344 : : 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2345 : : 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2346 : : 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2347 : : 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2348 : : 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2349 : : 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2350 : : 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2351 : : 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2352 : : 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2353 : : 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2354 : : 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2355 : : 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2356 : : 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2357 : : 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2358 : : 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2359 : : 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2360 : : 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2361 : : 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2362 : : 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2363 : : 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2364 : : 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2365 : : 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2366 : : 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2367 : : 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2368 : : 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2369 : : 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2370 : : 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2371 : : 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2372 : : 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2373 : : 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2374 : : 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2375 : : 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2376 : : 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2377 : : 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2378 : : 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2379 : : 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2380 : : 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2381 : : 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2382 : : 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2383 : : 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2384 : : 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2385 : : 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2386 : : 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2387 : : 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2388 : : 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2389 : : 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2390 : : 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2391 : :
2392 : : };
2393 : :
2394 : : static uint8_t ms_hmac_key1[] = {
2395 : : 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2396 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2397 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2398 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2399 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2400 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2401 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2402 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2403 : : };
2404 : :
2405 : : static const uint8_t ms_hmac_digest1[] = {
2406 : : 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2407 : : 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2408 : : 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2409 : : 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2410 : : 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2411 : : 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2412 : : 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2413 : : 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2414 : : };
2415 : : /* End Session 1 */
2416 : : /* Begin Session 2 */
2417 : : static uint8_t ms_aes_cbc_key2[] = {
2418 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2419 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2420 : : };
2421 : :
2422 : : static uint8_t ms_aes_cbc_iv2[] = {
2423 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2424 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2425 : : };
2426 : :
2427 : : static const uint8_t ms_aes_cbc_cipher2[] = {
2428 : : 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2429 : : 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2430 : : 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2431 : : 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2432 : : 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2433 : : 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2434 : : 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2435 : : 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2436 : : 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2437 : : 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2438 : : 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2439 : : 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2440 : : 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2441 : : 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2442 : : 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2443 : : 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2444 : : 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2445 : : 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2446 : : 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2447 : : 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2448 : : 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2449 : : 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2450 : : 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2451 : : 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2452 : : 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2453 : : 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2454 : : 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2455 : : 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2456 : : 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2457 : : 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2458 : : 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2459 : : 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2460 : : 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2461 : : 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2462 : : 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2463 : : 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2464 : : 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2465 : : 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2466 : : 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2467 : : 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2468 : : 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2469 : : 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2470 : : 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2471 : : 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2472 : : 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2473 : : 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2474 : : 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2475 : : 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2476 : : 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2477 : : 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2478 : : 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2479 : : 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2480 : : 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2481 : : 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2482 : : 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2483 : : 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2484 : : 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2485 : : 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2486 : : 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2487 : : 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2488 : : 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2489 : : 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2490 : : 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2491 : : 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2492 : : };
2493 : :
2494 : : static uint8_t ms_hmac_key2[] = {
2495 : : 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2496 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2497 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2498 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2499 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2500 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2501 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2502 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2503 : : };
2504 : :
2505 : : static const uint8_t ms_hmac_digest2[] = {
2506 : : 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2507 : : 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2508 : : 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2509 : : 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2510 : : 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2511 : : 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2512 : : 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2513 : : 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2514 : : };
2515 : :
2516 : : /* End Session 2 */
2517 : :
2518 : : #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
2519 : : static int
2520 : 1 : test_queue_pair_descriptor_count(void)
2521 : : {
2522 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2523 : : struct crypto_unittest_params *ut_params = &unittest_params;
2524 : 1 : struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
2525 : 1 : struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
2526 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2527 : : int qp_depth = 0;
2528 : : int i;
2529 : :
2530 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2531 : : return TEST_SKIPPED;
2532 : :
2533 : : /* Verify if the queue pair depth API is supported by driver */
2534 [ + - ]: 1 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2535 [ # # ]: 0 : if (qp_depth == -ENOTSUP)
2536 : 1 : return TEST_SKIPPED;
2537 : :
2538 : : /* Verify the capabilities */
2539 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2540 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2541 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2542 : : return TEST_SKIPPED;
2543 : :
2544 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2545 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2546 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2547 : : return TEST_SKIPPED;
2548 : :
2549 : : /* Setup Cipher Parameters */
2550 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2551 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2552 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2553 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2554 : 0 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2555 : 0 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2556 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2557 : 0 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2558 : :
2559 : : /* Setup HMAC Parameters */
2560 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2561 : 0 : ut_params->auth_xform.next = NULL;
2562 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2563 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2564 : 0 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2565 : 0 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2566 : 0 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2567 : :
2568 : 0 : rte_errno = 0;
2569 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
2570 : : &ut_params->cipher_xform, ts_params->session_mpool);
2571 [ # # ]: 0 : if (rte_errno == ENOTSUP)
2572 : : return TEST_SKIPPED;
2573 : :
2574 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2575 : :
2576 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
2577 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
2578 : : MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
2579 : :
2580 : : /* Generate crypto op data structure */
2581 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2582 : : struct rte_mbuf *m;
2583 : : uint8_t *digest;
2584 : :
2585 : : /* Generate test mbuf data and space for digest */
2586 : 0 : m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
2587 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
2588 : :
2589 : : digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
2590 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
2591 : :
2592 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
2593 : :
2594 : : /* set crypto operation source mbuf */
2595 : 0 : ops[i]->sym->m_src = m;
2596 : :
2597 : : /* Set crypto operation authentication parameters */
2598 : 0 : ops[i]->sym->auth.digest.data = digest;
2599 : 0 : ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
2600 : :
2601 : 0 : ops[i]->sym->auth.data.offset = 0;
2602 : 0 : ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
2603 : :
2604 : : /* Copy IV at the end of the crypto operation */
2605 : 0 : memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
2606 : : CIPHER_IV_LENGTH_AES_CBC);
2607 : :
2608 : : /* Set crypto operation cipher parameters */
2609 : 0 : ops[i]->sym->cipher.data.offset = 0;
2610 : 0 : ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
2611 : :
2612 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
2613 : : &ops[i], 1), 1, "Error enqueuing");
2614 : : }
2615 : :
2616 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2617 [ # # ]: 0 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2618 [ # # ]: 0 : TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
2619 : : "Crypto queue pair depth used does not match with inflight ops");
2620 : :
2621 : 0 : while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
2622 [ # # ]: 0 : &ops_deq[i], 1) == 0)
2623 : : rte_pause();
2624 : :
2625 [ # # ]: 0 : TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2626 : : "crypto op processing failed");
2627 : :
2628 : 0 : rte_pktmbuf_free(ops_deq[i]->sym->m_src);
2629 : 0 : rte_crypto_op_free(ops_deq[i]);
2630 : 0 : ops_deq[i] = NULL;
2631 : : }
2632 : :
2633 : : return TEST_SUCCESS;
2634 : : }
2635 : :
2636 : : static int
2637 : 2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2638 : : {
2639 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2640 : : struct crypto_unittest_params *ut_params = &unittest_params;
2641 : : /* Verify the capabilities */
2642 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2643 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2644 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2645 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2646 : : &cap_idx) == NULL)
2647 : : return TEST_SKIPPED;
2648 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2649 : 2 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2650 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2651 : : &cap_idx) == NULL)
2652 : : return TEST_SKIPPED;
2653 : :
2654 : : /* Generate test mbuf data and space for digest */
2655 : 2 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2656 : : catch_22_quote, QUOTE_512_BYTES, 0);
2657 : :
2658 : 2 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2659 : : DIGEST_BYTE_LENGTH_SHA1);
2660 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2661 : :
2662 : : /* Setup Cipher Parameters */
2663 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2664 : 2 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2665 : :
2666 : 2 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2667 : 2 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2668 : 2 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2669 : 2 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2670 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2671 : 2 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2672 : :
2673 : : /* Setup HMAC Parameters */
2674 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2675 : :
2676 : 2 : ut_params->auth_xform.next = NULL;
2677 : :
2678 : 2 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2679 : 2 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2680 : 2 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2681 : 2 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2682 : 2 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2683 : :
2684 : 2 : rte_errno = 0;
2685 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(
2686 : 2 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2687 : : ts_params->session_mpool);
2688 [ + - ]: 2 : if (rte_errno == ENOTSUP)
2689 : : return TEST_SKIPPED;
2690 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2691 : :
2692 : : /* Generate crypto op data structure */
2693 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2694 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2695 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
2696 : : "Failed to allocate symmetric crypto operation struct");
2697 : :
2698 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2699 : :
2700 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2701 : :
2702 : : /* set crypto operation source mbuf */
2703 : 2 : sym_op->m_src = ut_params->ibuf;
2704 : :
2705 : : /* Set crypto operation authentication parameters */
2706 : 2 : sym_op->auth.digest.data = ut_params->digest;
2707 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2708 : : ut_params->ibuf, QUOTE_512_BYTES);
2709 : :
2710 : 2 : sym_op->auth.data.offset = 0;
2711 : 2 : sym_op->auth.data.length = QUOTE_512_BYTES;
2712 : :
2713 : : /* Copy IV at the end of the crypto operation */
2714 [ - + ]: 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2715 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2716 : :
2717 : : /* Set crypto operation cipher parameters */
2718 : 2 : sym_op->cipher.data.offset = 0;
2719 : 2 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2720 : :
2721 : : /* Process crypto operation */
2722 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2723 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2724 : : ut_params->op);
2725 : : else
2726 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
2727 : : process_crypto_request(ts_params->valid_devs[0],
2728 : : ut_params->op),
2729 : : "failed to process sym crypto op");
2730 : :
2731 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2732 : : "crypto op processing failed");
2733 : :
2734 : : /* Validate obuf */
2735 : 2 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2736 : : uint8_t *);
2737 : :
2738 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2739 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2740 : : QUOTE_512_BYTES,
2741 : : "ciphertext data not as expected");
2742 : :
2743 : 2 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2744 : :
2745 [ + - - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2746 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2747 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2748 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2749 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2750 : : DIGEST_BYTE_LENGTH_SHA1,
2751 : : "Generated digest data not as expected");
2752 : :
2753 : : return TEST_SUCCESS;
2754 : : }
2755 : :
2756 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2757 : :
2758 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2759 : :
2760 : : static uint8_t hmac_sha512_key[] = {
2761 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2762 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2763 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2764 : : 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2765 : : 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2766 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2767 : : 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2768 : : 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2769 : :
2770 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2771 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2772 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2773 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2774 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2775 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2776 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2777 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2778 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2779 : :
2780 : :
2781 : :
2782 : : static int
2783 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2784 : : struct crypto_unittest_params *ut_params,
2785 : : uint8_t *cipher_key,
2786 : : uint8_t *hmac_key);
2787 : :
2788 : : static int
2789 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2790 : : struct crypto_unittest_params *ut_params,
2791 : : struct crypto_testsuite_params *ts_params,
2792 : : const uint8_t *cipher,
2793 : : const uint8_t *digest,
2794 : : const uint8_t *iv);
2795 : :
2796 : :
2797 : : static int
2798 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2799 : : struct crypto_unittest_params *ut_params,
2800 : : uint8_t *cipher_key,
2801 : : uint8_t *hmac_key)
2802 : : {
2803 : :
2804 : : /* Setup Cipher Parameters */
2805 : 4 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2806 : 4 : ut_params->cipher_xform.next = NULL;
2807 : :
2808 : 4 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2809 : 4 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2810 : 4 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2811 : 4 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2812 : 4 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2813 : 4 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2814 : :
2815 : : /* Setup HMAC Parameters */
2816 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2817 : 4 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2818 : :
2819 : 4 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2820 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2821 : 4 : ut_params->auth_xform.auth.key.data = hmac_key;
2822 : 4 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2823 : 4 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2824 : :
2825 : : return TEST_SUCCESS;
2826 : : }
2827 : :
2828 : :
2829 : : static int
2830 : 5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2831 : : struct crypto_unittest_params *ut_params,
2832 : : struct crypto_testsuite_params *ts_params,
2833 : : const uint8_t *cipher,
2834 : : const uint8_t *digest,
2835 : : const uint8_t *iv)
2836 : : {
2837 : : int ret;
2838 : :
2839 : : /* Generate test mbuf data and digest */
2840 : 5 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2841 : : (const char *)
2842 : : cipher,
2843 : : QUOTE_512_BYTES, 0);
2844 : :
2845 : 5 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2846 : : DIGEST_BYTE_LENGTH_SHA512);
2847 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2848 : :
2849 : : rte_memcpy(ut_params->digest,
2850 : : digest,
2851 : : DIGEST_BYTE_LENGTH_SHA512);
2852 : :
2853 : : /* Generate Crypto op data structure */
2854 : 5 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2855 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2856 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->op,
2857 : : "Failed to allocate symmetric crypto operation struct");
2858 : :
2859 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2860 : :
2861 : 5 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2862 : :
2863 : : /* set crypto operation source mbuf */
2864 : 5 : sym_op->m_src = ut_params->ibuf;
2865 : :
2866 : 5 : sym_op->auth.digest.data = ut_params->digest;
2867 [ - + ]: 5 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2868 : : ut_params->ibuf, QUOTE_512_BYTES);
2869 : :
2870 : 5 : sym_op->auth.data.offset = 0;
2871 : 5 : sym_op->auth.data.length = QUOTE_512_BYTES;
2872 : :
2873 : : /* Copy IV at the end of the crypto operation */
2874 [ - + ]: 5 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2875 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2876 : :
2877 : 5 : sym_op->cipher.data.offset = 0;
2878 : 5 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2879 : :
2880 : : /* Process crypto operation */
2881 [ - + ]: 5 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2882 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2883 : : ut_params->op);
2884 [ - + ]: 5 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2885 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2886 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2887 : : return ret;
2888 : : } else
2889 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(
2890 : : process_crypto_request(ts_params->valid_devs[0],
2891 : : ut_params->op),
2892 : : "failed to process sym crypto op");
2893 : :
2894 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2895 : : "crypto op processing failed");
2896 : :
2897 : 5 : ut_params->obuf = ut_params->op->sym->m_src;
2898 : :
2899 : : /* Validate obuf */
2900 [ - + ]: 5 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2901 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2902 : : catch_22_quote,
2903 : : QUOTE_512_BYTES,
2904 : : "Plaintext data not as expected");
2905 : :
2906 : : /* Validate obuf */
2907 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2908 : : "Digest verification failed");
2909 : :
2910 : : return TEST_SUCCESS;
2911 : : }
2912 : :
2913 : : /* ***** SNOW 3G Tests ***** */
2914 : : static int
2915 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2916 : : const uint8_t *key, const uint8_t key_len,
2917 : : const uint8_t iv_len, const uint8_t auth_len,
2918 : : enum rte_crypto_auth_operation op,
2919 : : enum rte_crypto_auth_algorithm algo)
2920 : : {
2921 : 0 : uint8_t *hash_key = alloca(key_len);
2922 : :
2923 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2924 : : struct crypto_unittest_params *ut_params = &unittest_params;
2925 : :
2926 : : memcpy(hash_key, key, key_len);
2927 : :
2928 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2929 : :
2930 : : /* Setup Authentication Parameters */
2931 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2932 : 0 : ut_params->auth_xform.next = NULL;
2933 : :
2934 : 0 : ut_params->auth_xform.auth.op = op;
2935 : 0 : ut_params->auth_xform.auth.algo = algo;
2936 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2937 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2938 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2939 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2940 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2941 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2942 : : &ut_params->auth_xform, ts_params->session_mpool);
2943 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2944 : : return TEST_SKIPPED;
2945 : :
2946 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2947 : : return 0;
2948 : : }
2949 : :
2950 : : static int
2951 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2952 : : enum rte_crypto_cipher_operation op,
2953 : : enum rte_crypto_cipher_algorithm algo,
2954 : : const uint8_t *key, const uint8_t key_len,
2955 : : uint8_t iv_len)
2956 : : {
2957 : 0 : uint8_t *cipher_key = alloca(key_len);
2958 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2959 : : struct crypto_unittest_params *ut_params = &unittest_params;
2960 : :
2961 : : memcpy(cipher_key, key, key_len);
2962 : :
2963 : : /* Setup Cipher Parameters */
2964 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2965 : 0 : ut_params->cipher_xform.next = NULL;
2966 : :
2967 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2968 : 0 : ut_params->cipher_xform.cipher.op = op;
2969 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2970 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2971 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2972 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2973 : :
2974 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2975 : :
2976 : : /* Create Crypto session */
2977 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2978 : : &ut_params->cipher_xform, ts_params->session_mpool);
2979 : :
2980 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2981 : : return TEST_SKIPPED;
2982 : :
2983 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2984 : : return 0;
2985 : : }
2986 : :
2987 : : static int
2988 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2989 : : unsigned int cipher_len,
2990 : : unsigned int cipher_offset)
2991 : : {
2992 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2993 : : struct crypto_unittest_params *ut_params = &unittest_params;
2994 : :
2995 : : /* Generate Crypto op data structure */
2996 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2997 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2998 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2999 : : "Failed to allocate pktmbuf offload");
3000 : :
3001 : : /* Set crypto operation data parameters */
3002 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3003 : :
3004 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3005 : :
3006 : : /* set crypto operation source mbuf */
3007 : 0 : sym_op->m_src = ut_params->ibuf;
3008 : :
3009 : : /* iv */
3010 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3011 : : iv, iv_len);
3012 : 0 : sym_op->cipher.data.length = cipher_len;
3013 : 0 : sym_op->cipher.data.offset = cipher_offset;
3014 : 0 : return 0;
3015 : : }
3016 : :
3017 : : static int
3018 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
3019 : : unsigned int cipher_len,
3020 : : unsigned int cipher_offset)
3021 : : {
3022 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3023 : : struct crypto_unittest_params *ut_params = &unittest_params;
3024 : :
3025 : : /* Generate Crypto op data structure */
3026 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3027 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3028 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3029 : : "Failed to allocate pktmbuf offload");
3030 : :
3031 : : /* Set crypto operation data parameters */
3032 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3033 : :
3034 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3035 : :
3036 : : /* set crypto operation source mbuf */
3037 : 0 : sym_op->m_src = ut_params->ibuf;
3038 : 0 : sym_op->m_dst = ut_params->obuf;
3039 : :
3040 : : /* iv */
3041 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3042 : : iv, iv_len);
3043 : 0 : sym_op->cipher.data.length = cipher_len;
3044 : 0 : sym_op->cipher.data.offset = cipher_offset;
3045 : 0 : return 0;
3046 : : }
3047 : :
3048 : : static int
3049 : 1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
3050 : : enum rte_crypto_cipher_operation cipher_op,
3051 : : enum rte_crypto_auth_operation auth_op,
3052 : : enum rte_crypto_auth_algorithm auth_algo,
3053 : : enum rte_crypto_cipher_algorithm cipher_algo,
3054 : : const uint8_t *a_key, uint8_t a_key_len,
3055 : : const uint8_t *c_key, uint8_t c_key_len,
3056 : : uint8_t auth_iv_len, uint8_t auth_len,
3057 : : uint8_t cipher_iv_len)
3058 : :
3059 : : {
3060 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3061 : : struct crypto_unittest_params *ut_params = &unittest_params;
3062 : :
3063 : : /* Setup Authentication Parameters */
3064 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3065 : 1 : ut_params->auth_xform.next = NULL;
3066 : :
3067 : 1 : ut_params->auth_xform.auth.op = auth_op;
3068 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3069 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3070 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3071 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3072 : : /* Auth IV will be after cipher IV */
3073 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3074 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3075 : :
3076 : : /* Setup Cipher Parameters */
3077 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3078 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3079 : :
3080 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3081 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3082 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3083 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3084 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3085 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3086 : :
3087 : 1 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
3088 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3089 : :
3090 : : /* Create Crypto session*/
3091 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3092 : : &ut_params->cipher_xform, ts_params->session_mpool);
3093 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3094 : : return TEST_SKIPPED;
3095 : :
3096 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3097 : : return 0;
3098 : : }
3099 : :
3100 : : static int
3101 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
3102 : : enum rte_crypto_cipher_operation cipher_op,
3103 : : enum rte_crypto_auth_operation auth_op,
3104 : : enum rte_crypto_auth_algorithm auth_algo,
3105 : : enum rte_crypto_cipher_algorithm cipher_algo,
3106 : : const struct wireless_test_data *tdata)
3107 : : {
3108 : 0 : const uint8_t key_len = tdata->key.len;
3109 : 0 : uint8_t *cipher_auth_key = alloca(key_len);
3110 : :
3111 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3112 : : struct crypto_unittest_params *ut_params = &unittest_params;
3113 : 0 : const uint8_t *key = tdata->key.data;
3114 : 0 : const uint8_t auth_len = tdata->digest.len;
3115 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
3116 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
3117 : :
3118 : : memcpy(cipher_auth_key, key, key_len);
3119 : :
3120 : : /* Setup Authentication Parameters */
3121 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3122 : 0 : ut_params->auth_xform.next = NULL;
3123 : :
3124 : 0 : ut_params->auth_xform.auth.op = auth_op;
3125 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
3126 : 0 : ut_params->auth_xform.auth.key.length = key_len;
3127 : : /* Hash key = cipher key */
3128 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
3129 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
3130 : : /* Auth IV will be after cipher IV */
3131 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3132 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3133 : :
3134 : : /* Setup Cipher Parameters */
3135 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3136 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3137 : :
3138 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3139 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
3140 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
3141 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
3142 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3143 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3144 : :
3145 : :
3146 : 0 : debug_hexdump(stdout, "key:", key, key_len);
3147 : :
3148 : : /* Create Crypto session*/
3149 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3150 : : &ut_params->cipher_xform, ts_params->session_mpool);
3151 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3152 : : return TEST_SKIPPED;
3153 : :
3154 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3155 : : return 0;
3156 : : }
3157 : :
3158 : : static int
3159 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
3160 : : const struct wireless_test_data *tdata)
3161 : : {
3162 : 0 : return create_wireless_cipher_auth_session(dev_id,
3163 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3164 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
3165 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
3166 : : }
3167 : :
3168 : : static int
3169 : 1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
3170 : : enum rte_crypto_cipher_operation cipher_op,
3171 : : enum rte_crypto_auth_operation auth_op,
3172 : : enum rte_crypto_auth_algorithm auth_algo,
3173 : : enum rte_crypto_cipher_algorithm cipher_algo,
3174 : : const uint8_t *a_key, const uint8_t a_key_len,
3175 : : const uint8_t *c_key, const uint8_t c_key_len,
3176 : : uint8_t auth_iv_len, uint8_t auth_len,
3177 : : uint8_t cipher_iv_len)
3178 : : {
3179 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3180 : : struct crypto_unittest_params *ut_params = &unittest_params;
3181 : :
3182 : : /* Setup Authentication Parameters */
3183 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3184 : 1 : ut_params->auth_xform.auth.op = auth_op;
3185 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
3186 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3187 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3188 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3189 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3190 : : /* Auth IV will be after cipher IV */
3191 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3192 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3193 : :
3194 : : /* Setup Cipher Parameters */
3195 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3196 : 1 : ut_params->cipher_xform.next = NULL;
3197 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3198 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3199 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3200 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3201 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3202 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3203 : :
3204 : 1 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
3205 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3206 : :
3207 : : /* Create Crypto session*/
3208 [ - + ]: 1 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3209 : 0 : ut_params->auth_xform.next = NULL;
3210 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3211 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3212 : : &ut_params->cipher_xform, ts_params->session_mpool);
3213 : : } else
3214 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3215 : : &ut_params->auth_xform, ts_params->session_mpool);
3216 : :
3217 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3218 : : return TEST_SKIPPED;
3219 : :
3220 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3221 : :
3222 : : return 0;
3223 : : }
3224 : :
3225 : : static int
3226 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
3227 : : unsigned int auth_tag_len,
3228 : : const uint8_t *iv, unsigned int iv_len,
3229 : : unsigned int data_pad_len,
3230 : : enum rte_crypto_auth_operation op,
3231 : : unsigned int auth_len, unsigned int auth_offset)
3232 : : {
3233 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3234 : :
3235 : : struct crypto_unittest_params *ut_params = &unittest_params;
3236 : :
3237 : : /* Generate Crypto op data structure */
3238 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3239 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3240 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3241 : : "Failed to allocate pktmbuf offload");
3242 : :
3243 : : /* Set crypto operation data parameters */
3244 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3245 : :
3246 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3247 : :
3248 : : /* set crypto operation source mbuf */
3249 : 0 : sym_op->m_src = ut_params->ibuf;
3250 : :
3251 : : /* iv */
3252 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3253 : : iv, iv_len);
3254 : : /* digest */
3255 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3256 : : ut_params->ibuf, auth_tag_len);
3257 : :
3258 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3259 : : "no room to append auth tag");
3260 : 0 : ut_params->digest = sym_op->auth.digest.data;
3261 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3262 : : ut_params->ibuf, data_pad_len);
3263 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3264 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3265 : : else
3266 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3267 : :
3268 : 0 : debug_hexdump(stdout, "digest:",
3269 : 0 : sym_op->auth.digest.data,
3270 : : auth_tag_len);
3271 : :
3272 : 0 : sym_op->auth.data.length = auth_len;
3273 : 0 : sym_op->auth.data.offset = auth_offset;
3274 : :
3275 : 0 : return 0;
3276 : : }
3277 : :
3278 : : static int
3279 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3280 : : enum rte_crypto_auth_operation op)
3281 : : {
3282 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3283 : : struct crypto_unittest_params *ut_params = &unittest_params;
3284 : :
3285 : 0 : const uint8_t *auth_tag = tdata->digest.data;
3286 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
3287 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3288 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3289 : :
3290 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
3291 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3292 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
3293 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
3294 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3295 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
3296 : :
3297 : : /* Generate Crypto op data structure */
3298 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3299 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3300 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3301 : : "Failed to allocate pktmbuf offload");
3302 : : /* Set crypto operation data parameters */
3303 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3304 : :
3305 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3306 : :
3307 : : /* set crypto operation source mbuf */
3308 : 0 : sym_op->m_src = ut_params->ibuf;
3309 : :
3310 : : /* digest */
3311 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3312 : : ut_params->ibuf, auth_tag_len);
3313 : :
3314 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3315 : : "no room to append auth tag");
3316 : 0 : ut_params->digest = sym_op->auth.digest.data;
3317 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3318 : : ut_params->ibuf, data_pad_len);
3319 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3320 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3321 : : else
3322 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3323 : :
3324 : 0 : debug_hexdump(stdout, "digest:",
3325 : 0 : sym_op->auth.digest.data,
3326 : : auth_tag_len);
3327 : :
3328 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3329 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3330 : : IV_OFFSET);
3331 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3332 : 0 : iv_ptr += cipher_iv_len;
3333 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3334 : :
3335 : 0 : sym_op->cipher.data.length = cipher_len;
3336 : 0 : sym_op->cipher.data.offset = 0;
3337 : 0 : sym_op->auth.data.length = auth_len;
3338 : 0 : sym_op->auth.data.offset = 0;
3339 : :
3340 : 0 : return 0;
3341 : : }
3342 : :
3343 : : static int
3344 : : create_zuc_cipher_hash_generate_operation(
3345 : : const struct wireless_test_data *tdata)
3346 : : {
3347 : 0 : return create_wireless_cipher_hash_operation(tdata,
3348 : : RTE_CRYPTO_AUTH_OP_GENERATE);
3349 : : }
3350 : :
3351 : : static int
3352 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3353 : : const unsigned auth_tag_len,
3354 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3355 : : unsigned data_pad_len,
3356 : : enum rte_crypto_auth_operation op,
3357 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3358 : : const unsigned cipher_len, const unsigned cipher_offset,
3359 : : const unsigned auth_len, const unsigned auth_offset)
3360 : : {
3361 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3362 : : struct crypto_unittest_params *ut_params = &unittest_params;
3363 : :
3364 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
3365 : : ut_params->cipher_xform.cipher.algo;
3366 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3367 : : ut_params->auth_xform.auth.algo;
3368 : :
3369 : : /* Generate Crypto op data structure */
3370 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3371 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3372 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3373 : : "Failed to allocate pktmbuf offload");
3374 : : /* Set crypto operation data parameters */
3375 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3376 : :
3377 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3378 : :
3379 : : /* set crypto operation source mbuf */
3380 : 0 : sym_op->m_src = ut_params->ibuf;
3381 : :
3382 : : /* digest */
3383 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3384 : : ut_params->ibuf, auth_tag_len);
3385 : :
3386 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3387 : : "no room to append auth tag");
3388 : 0 : ut_params->digest = sym_op->auth.digest.data;
3389 : :
3390 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3391 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3392 : : ut_params->ibuf, data_pad_len);
3393 : : } else {
3394 : : struct rte_mbuf *m = ut_params->ibuf;
3395 : : unsigned int offset = data_pad_len;
3396 : :
3397 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3398 : 0 : offset -= m->data_len;
3399 : : m = m->next;
3400 : : }
3401 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3402 : : m, offset);
3403 : : }
3404 : :
3405 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3406 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3407 : : else
3408 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3409 : :
3410 : 0 : debug_hexdump(stdout, "digest:",
3411 : 0 : sym_op->auth.digest.data,
3412 : : auth_tag_len);
3413 : :
3414 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3415 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3416 : : IV_OFFSET);
3417 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3418 : 0 : iv_ptr += cipher_iv_len;
3419 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3420 : :
3421 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3422 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3423 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3424 : 0 : sym_op->cipher.data.length = cipher_len;
3425 : 0 : sym_op->cipher.data.offset = cipher_offset;
3426 : : } else {
3427 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3428 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3429 : : }
3430 : :
3431 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3432 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3433 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3434 : 0 : sym_op->auth.data.length = auth_len;
3435 : 0 : sym_op->auth.data.offset = auth_offset;
3436 : : } else {
3437 : 0 : sym_op->auth.data.length = auth_len >> 3;
3438 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3439 : : }
3440 : :
3441 : : return 0;
3442 : : }
3443 : :
3444 : : static int
3445 : 2 : create_wireless_algo_auth_cipher_operation(
3446 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3447 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3448 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3449 : : unsigned int data_pad_len,
3450 : : unsigned int cipher_len, unsigned int cipher_offset,
3451 : : unsigned int auth_len, unsigned int auth_offset,
3452 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3453 : : {
3454 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3455 : : struct crypto_unittest_params *ut_params = &unittest_params;
3456 : :
3457 : 2 : enum rte_crypto_cipher_algorithm cipher_algo =
3458 : : ut_params->cipher_xform.cipher.algo;
3459 : 2 : enum rte_crypto_auth_algorithm auth_algo =
3460 : : ut_params->auth_xform.auth.algo;
3461 : :
3462 : : /* Generate Crypto op data structure */
3463 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3464 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3465 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
3466 : : "Failed to allocate pktmbuf offload");
3467 : :
3468 : : /* Set crypto operation data parameters */
3469 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3470 : :
3471 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3472 : :
3473 : : /* set crypto operation mbufs */
3474 : 2 : sym_op->m_src = ut_params->ibuf;
3475 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE)
3476 : 0 : sym_op->m_dst = ut_params->obuf;
3477 : :
3478 : : /* digest */
3479 [ - + ]: 2 : if (!do_sgl) {
3480 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3481 : : (op_mode == IN_PLACE ?
3482 : : ut_params->ibuf : ut_params->obuf),
3483 : : uint8_t *, data_pad_len);
3484 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3485 : : (op_mode == IN_PLACE ?
3486 : : ut_params->ibuf : ut_params->obuf),
3487 : : data_pad_len);
3488 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3489 : : } else {
3490 : 2 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3491 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3492 [ - + ]: 2 : sym_op->m_src : sym_op->m_dst);
3493 : : struct rte_mbuf *sgl_buf_head = sgl_buf;
3494 : :
3495 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3496 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3497 : 30 : sgl_buf = sgl_buf->next;
3498 : : }
3499 : :
3500 : : /* The last segment should be large enough to hold full digest */
3501 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3502 : : uint16_t next_data_len = 0;
3503 [ # # ]: 0 : if (sgl_buf->next != NULL) {
3504 : 0 : next_data_len = sgl_buf->next->data_len;
3505 : :
3506 : 0 : rte_pktmbuf_free(sgl_buf->next);
3507 : 0 : sgl_buf->next = NULL;
3508 : 0 : sgl_buf_head->nb_segs -= 1;
3509 : 0 : sgl_buf_head->pkt_len -= next_data_len;
3510 : : }
3511 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(
3512 : : sgl_buf_head, auth_tag_len - sgl_buf->data_len),
3513 : : "No room to append auth tag");
3514 : : }
3515 : :
3516 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3517 : : uint8_t *, remaining_off);
3518 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3519 : : remaining_off);
3520 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3521 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3522 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3523 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3524 : 0 : sgl_buf = sgl_buf->next;
3525 : : }
3526 : : }
3527 : :
3528 : : /* Copy digest for the verification */
3529 [ + + ]: 2 : if (verify)
3530 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3531 : :
3532 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3533 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3534 : : ut_params->op, uint8_t *, IV_OFFSET);
3535 : :
3536 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3537 : 2 : iv_ptr += cipher_iv_len;
3538 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3539 : :
3540 : : /* Only copy over the offset data needed from src to dst in OOP,
3541 : : * if the auth and cipher offsets are not aligned
3542 : : */
3543 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3544 [ # # ]: 0 : if (cipher_offset > auth_offset)
3545 : 0 : rte_memcpy(
3546 : 0 : rte_pktmbuf_mtod_offset(
3547 : : sym_op->m_dst,
3548 : : uint8_t *, auth_offset >> 3),
3549 : 0 : rte_pktmbuf_mtod_offset(
3550 : : sym_op->m_src,
3551 : : uint8_t *, auth_offset >> 3),
3552 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3553 : : }
3554 : :
3555 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3556 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3557 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3558 : 0 : sym_op->cipher.data.length = cipher_len;
3559 : 0 : sym_op->cipher.data.offset = cipher_offset;
3560 : : } else {
3561 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3562 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3563 : : }
3564 : :
3565 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3566 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3567 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3568 : 0 : sym_op->auth.data.length = auth_len;
3569 : 0 : sym_op->auth.data.offset = auth_offset;
3570 : : } else {
3571 : 2 : sym_op->auth.data.length = auth_len >> 3;
3572 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3573 : : }
3574 : :
3575 : : return 0;
3576 : : }
3577 : :
3578 : : static int
3579 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3580 : : {
3581 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3582 : : struct crypto_unittest_params *ut_params = &unittest_params;
3583 : :
3584 : : int retval;
3585 : : unsigned plaintext_pad_len;
3586 : : unsigned plaintext_len;
3587 : : uint8_t *plaintext;
3588 : : struct rte_cryptodev_info dev_info;
3589 : :
3590 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3591 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3592 : :
3593 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3594 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3595 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3596 : 0 : return TEST_SKIPPED;
3597 : : }
3598 : :
3599 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3600 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3601 : : printf("Device doesn't support RAW data-path APIs.\n");
3602 : 0 : return TEST_SKIPPED;
3603 : : }
3604 : :
3605 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3606 : : return TEST_SKIPPED;
3607 : :
3608 : : /* Verify the capabilities */
3609 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3610 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3611 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3612 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3613 : : &cap_idx) == NULL)
3614 : : return TEST_SKIPPED;
3615 : :
3616 : : /* Create SNOW 3G session */
3617 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3618 : 0 : tdata->key.data, tdata->key.len,
3619 : 0 : tdata->auth_iv.len, tdata->digest.len,
3620 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3621 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3622 [ # # ]: 0 : if (retval < 0)
3623 : : return retval;
3624 : :
3625 : : /* alloc mbuf and set payload */
3626 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3627 : :
3628 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3629 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3630 : :
3631 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3632 : : /* Append data which is padded to a multiple of */
3633 : : /* the algorithms block size */
3634 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3635 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3636 : : plaintext_pad_len);
3637 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3638 : :
3639 : : /* Create SNOW 3G operation */
3640 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3641 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3642 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3643 : 0 : tdata->validAuthLenInBits.len,
3644 : : 0);
3645 [ # # ]: 0 : if (retval < 0)
3646 : : return retval;
3647 : :
3648 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3649 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3650 : : 0);
3651 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3652 : : return retval;
3653 : : } else
3654 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3655 : : ut_params->op);
3656 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3657 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3658 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3659 : : uint8_t *,
3660 : : plaintext_pad_len);
3661 : :
3662 : : /* Validate obuf */
3663 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3664 : : ut_params->digest,
3665 : : tdata->digest.data,
3666 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3667 : : "SNOW 3G Generated auth tag not as expected");
3668 : :
3669 : : return 0;
3670 : : }
3671 : :
3672 : : static int
3673 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3674 : : {
3675 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3676 : : struct crypto_unittest_params *ut_params = &unittest_params;
3677 : :
3678 : : int retval;
3679 : : unsigned plaintext_pad_len;
3680 : : unsigned plaintext_len;
3681 : : uint8_t *plaintext;
3682 : : struct rte_cryptodev_info dev_info;
3683 : :
3684 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3685 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3686 : :
3687 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3688 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3689 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3690 : 0 : return TEST_SKIPPED;
3691 : : }
3692 : :
3693 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3694 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3695 : : printf("Device doesn't support RAW data-path APIs.\n");
3696 : 0 : return TEST_SKIPPED;
3697 : : }
3698 : :
3699 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3700 : : return TEST_SKIPPED;
3701 : :
3702 : : /* Verify the capabilities */
3703 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3704 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3705 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3706 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3707 : : &cap_idx) == NULL)
3708 : : return TEST_SKIPPED;
3709 : :
3710 : : /* Create SNOW 3G session */
3711 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3712 : 0 : tdata->key.data, tdata->key.len,
3713 : 0 : tdata->auth_iv.len, tdata->digest.len,
3714 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3715 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3716 [ # # ]: 0 : if (retval < 0)
3717 : : return retval;
3718 : : /* alloc mbuf and set payload */
3719 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3720 : :
3721 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3722 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3723 : :
3724 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3725 : : /* Append data which is padded to a multiple of */
3726 : : /* the algorithms block size */
3727 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3728 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3729 : : plaintext_pad_len);
3730 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3731 : :
3732 : : /* Create SNOW 3G operation */
3733 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3734 : 0 : tdata->digest.len,
3735 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3736 : : plaintext_pad_len,
3737 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3738 : 0 : tdata->validAuthLenInBits.len,
3739 : : 0);
3740 [ # # ]: 0 : if (retval < 0)
3741 : : return retval;
3742 : :
3743 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3744 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3745 : : 0);
3746 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3747 : : return retval;
3748 : : } else
3749 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3750 : : ut_params->op);
3751 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3752 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3753 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3754 : : uint8_t *,
3755 : : plaintext_pad_len);
3756 : :
3757 : : /* Validate obuf */
3758 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3759 : : return 0;
3760 : : else
3761 : 0 : return -1;
3762 : :
3763 : : return 0;
3764 : : }
3765 : :
3766 : : static int
3767 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3768 : : {
3769 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3770 : : struct crypto_unittest_params *ut_params = &unittest_params;
3771 : :
3772 : : int retval;
3773 : : unsigned plaintext_pad_len;
3774 : : unsigned plaintext_len;
3775 : : uint8_t *plaintext;
3776 : : struct rte_cryptodev_info dev_info;
3777 : :
3778 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3779 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3780 : :
3781 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3782 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3783 : : printf("Device doesn't support RAW data-path APIs.\n");
3784 : 0 : return TEST_SKIPPED;
3785 : : }
3786 : :
3787 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3788 : : return TEST_SKIPPED;
3789 : :
3790 : : /* Verify the capabilities */
3791 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3792 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3793 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3794 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3795 : : &cap_idx) == NULL)
3796 : : return TEST_SKIPPED;
3797 : :
3798 : : /* Create KASUMI session */
3799 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3800 : 0 : tdata->key.data, tdata->key.len,
3801 : 0 : 0, tdata->digest.len,
3802 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3803 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3804 [ # # ]: 0 : if (retval < 0)
3805 : : return retval;
3806 : :
3807 : : /* alloc mbuf and set payload */
3808 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3809 : :
3810 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3811 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3812 : :
3813 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3814 : : /* Append data which is padded to a multiple of */
3815 : : /* the algorithms block size */
3816 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3817 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3818 : : plaintext_pad_len);
3819 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3820 : :
3821 : : /* Create KASUMI operation */
3822 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3823 : : NULL, 0,
3824 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3825 : 0 : tdata->plaintext.len,
3826 : : 0);
3827 [ # # ]: 0 : if (retval < 0)
3828 : : return retval;
3829 : :
3830 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3831 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3832 : : ut_params->op);
3833 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3834 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3835 : : 0);
3836 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3837 : : return retval;
3838 : : } else
3839 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3840 : : ut_params->op);
3841 : :
3842 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3843 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3844 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3845 : : uint8_t *,
3846 : : plaintext_pad_len);
3847 : :
3848 : : /* Validate obuf */
3849 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3850 : : ut_params->digest,
3851 : : tdata->digest.data,
3852 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3853 : : "KASUMI Generated auth tag not as expected");
3854 : :
3855 : : return 0;
3856 : : }
3857 : :
3858 : : static int
3859 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3860 : : {
3861 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3862 : : struct crypto_unittest_params *ut_params = &unittest_params;
3863 : :
3864 : : int retval;
3865 : : unsigned plaintext_pad_len;
3866 : : unsigned plaintext_len;
3867 : : uint8_t *plaintext;
3868 : : struct rte_cryptodev_info dev_info;
3869 : :
3870 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3871 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3872 : :
3873 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3874 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3875 : : printf("Device doesn't support RAW data-path APIs.\n");
3876 : 0 : return TEST_SKIPPED;
3877 : : }
3878 : :
3879 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3880 : : return TEST_SKIPPED;
3881 : :
3882 : : /* Verify the capabilities */
3883 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3884 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3885 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3886 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3887 : : &cap_idx) == NULL)
3888 : : return TEST_SKIPPED;
3889 : :
3890 : : /* Create KASUMI session */
3891 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3892 : 0 : tdata->key.data, tdata->key.len,
3893 : 0 : 0, tdata->digest.len,
3894 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3895 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3896 [ # # ]: 0 : if (retval < 0)
3897 : : return retval;
3898 : : /* alloc mbuf and set payload */
3899 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3900 : :
3901 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3902 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3903 : :
3904 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3905 : : /* Append data which is padded to a multiple */
3906 : : /* of the algorithms block size */
3907 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3908 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3909 : : plaintext_pad_len);
3910 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3911 : :
3912 : : /* Create KASUMI operation */
3913 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3914 : 0 : tdata->digest.len,
3915 : : NULL, 0,
3916 : : plaintext_pad_len,
3917 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3918 : 0 : tdata->plaintext.len,
3919 : : 0);
3920 [ # # ]: 0 : if (retval < 0)
3921 : : return retval;
3922 : :
3923 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3924 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3925 : : 0);
3926 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3927 : : return retval;
3928 : : } else
3929 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3930 : : ut_params->op);
3931 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3932 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3933 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3934 : : uint8_t *,
3935 : : plaintext_pad_len);
3936 : :
3937 : : /* Validate obuf */
3938 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3939 : : return 0;
3940 : : else
3941 : 0 : return -1;
3942 : :
3943 : : return 0;
3944 : : }
3945 : :
3946 : : static int
3947 : 0 : test_snow3g_hash_generate_test_case_1(void)
3948 : : {
3949 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3950 : : }
3951 : :
3952 : : static int
3953 : 0 : test_snow3g_hash_generate_test_case_2(void)
3954 : : {
3955 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3956 : : }
3957 : :
3958 : : static int
3959 : 0 : test_snow3g_hash_generate_test_case_3(void)
3960 : : {
3961 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3962 : : }
3963 : :
3964 : : static int
3965 : 0 : test_snow3g_hash_generate_test_case_4(void)
3966 : : {
3967 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3968 : : }
3969 : :
3970 : : static int
3971 : 0 : test_snow3g_hash_generate_test_case_5(void)
3972 : : {
3973 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3974 : : }
3975 : :
3976 : : static int
3977 : 0 : test_snow3g_hash_generate_test_case_6(void)
3978 : : {
3979 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3980 : : }
3981 : :
3982 : : static int
3983 : 0 : test_snow3g_hash_verify_test_case_1(void)
3984 : : {
3985 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3986 : :
3987 : : }
3988 : :
3989 : : static int
3990 : 0 : test_snow3g_hash_verify_test_case_2(void)
3991 : : {
3992 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3993 : : }
3994 : :
3995 : : static int
3996 : 0 : test_snow3g_hash_verify_test_case_3(void)
3997 : : {
3998 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3999 : : }
4000 : :
4001 : : static int
4002 : 0 : test_snow3g_hash_verify_test_case_4(void)
4003 : : {
4004 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
4005 : : }
4006 : :
4007 : : static int
4008 : 0 : test_snow3g_hash_verify_test_case_5(void)
4009 : : {
4010 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
4011 : : }
4012 : :
4013 : : static int
4014 : 0 : test_snow3g_hash_verify_test_case_6(void)
4015 : : {
4016 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
4017 : : }
4018 : :
4019 : : static int
4020 : 0 : test_kasumi_hash_generate_test_case_1(void)
4021 : : {
4022 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
4023 : : }
4024 : :
4025 : : static int
4026 : 0 : test_kasumi_hash_generate_test_case_2(void)
4027 : : {
4028 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
4029 : : }
4030 : :
4031 : : static int
4032 : 0 : test_kasumi_hash_generate_test_case_3(void)
4033 : : {
4034 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
4035 : : }
4036 : :
4037 : : static int
4038 : 0 : test_kasumi_hash_generate_test_case_4(void)
4039 : : {
4040 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
4041 : : }
4042 : :
4043 : : static int
4044 : 0 : test_kasumi_hash_generate_test_case_5(void)
4045 : : {
4046 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
4047 : : }
4048 : :
4049 : : static int
4050 : 0 : test_kasumi_hash_generate_test_case_6(void)
4051 : : {
4052 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
4053 : : }
4054 : :
4055 : : static int
4056 : 0 : test_kasumi_hash_verify_test_case_1(void)
4057 : : {
4058 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
4059 : : }
4060 : :
4061 : : static int
4062 : 0 : test_kasumi_hash_verify_test_case_2(void)
4063 : : {
4064 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
4065 : : }
4066 : :
4067 : : static int
4068 : 0 : test_kasumi_hash_verify_test_case_3(void)
4069 : : {
4070 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
4071 : : }
4072 : :
4073 : : static int
4074 : 0 : test_kasumi_hash_verify_test_case_4(void)
4075 : : {
4076 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
4077 : : }
4078 : :
4079 : : static int
4080 : 0 : test_kasumi_hash_verify_test_case_5(void)
4081 : : {
4082 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
4083 : : }
4084 : :
4085 : : static int
4086 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
4087 : : {
4088 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4089 : : struct crypto_unittest_params *ut_params = &unittest_params;
4090 : :
4091 : : int retval;
4092 : : uint8_t *plaintext, *ciphertext;
4093 : : unsigned plaintext_pad_len;
4094 : : unsigned plaintext_len;
4095 : : struct rte_cryptodev_info dev_info;
4096 : :
4097 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4098 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4099 : :
4100 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4101 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4102 : : printf("Device doesn't support RAW data-path APIs.\n");
4103 : 0 : return TEST_SKIPPED;
4104 : : }
4105 : :
4106 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4107 : : return TEST_SKIPPED;
4108 : :
4109 : : /* Verify the capabilities */
4110 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4111 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4112 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4113 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4114 : : &cap_idx) == NULL)
4115 : : return TEST_SKIPPED;
4116 : :
4117 : : /* Create KASUMI session */
4118 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4119 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4120 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4121 : 0 : tdata->key.data, tdata->key.len,
4122 : 0 : tdata->cipher_iv.len);
4123 [ # # ]: 0 : if (retval < 0)
4124 : : return retval;
4125 : :
4126 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4127 : :
4128 : : /* Clear mbuf payload */
4129 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4130 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4131 : :
4132 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4133 : : /* Append data which is padded to a multiple */
4134 : : /* of the algorithms block size */
4135 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4136 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4137 : : plaintext_pad_len);
4138 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4139 : :
4140 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4141 : :
4142 : : /* Create KASUMI operation */
4143 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4144 : 0 : tdata->cipher_iv.len,
4145 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4146 : 0 : tdata->validCipherOffsetInBits.len);
4147 [ # # ]: 0 : if (retval < 0)
4148 : : return retval;
4149 : :
4150 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4151 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4152 : 0 : tdata->cipher_iv.len);
4153 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4154 : : return retval;
4155 : : } else
4156 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4157 : : ut_params->op);
4158 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4159 : :
4160 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4161 [ # # ]: 0 : if (ut_params->obuf)
4162 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4163 : : else
4164 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4165 : :
4166 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4167 : :
4168 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4169 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4170 : : /* Validate obuf */
4171 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4172 : : ciphertext,
4173 : : reference_ciphertext,
4174 : : tdata->validCipherLenInBits.len,
4175 : : "KASUMI Ciphertext data not as expected");
4176 : : return 0;
4177 : : }
4178 : :
4179 : : static int
4180 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4181 : : {
4182 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4183 : : struct crypto_unittest_params *ut_params = &unittest_params;
4184 : :
4185 : : int retval;
4186 : :
4187 : : unsigned int plaintext_pad_len;
4188 : : unsigned int plaintext_len;
4189 : :
4190 : : uint8_t buffer[10000];
4191 : : const uint8_t *ciphertext;
4192 : :
4193 : : struct rte_cryptodev_info dev_info;
4194 : :
4195 : : /* Verify the capabilities */
4196 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4197 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4198 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4199 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4200 : : &cap_idx) == NULL)
4201 : : return TEST_SKIPPED;
4202 : :
4203 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4204 : :
4205 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4206 : :
4207 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4208 : : printf("Device doesn't support in-place scatter-gather. "
4209 : : "Test Skipped.\n");
4210 : 0 : return TEST_SKIPPED;
4211 : : }
4212 : :
4213 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4214 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4215 : : printf("Device doesn't support RAW data-path APIs.\n");
4216 : 0 : return TEST_SKIPPED;
4217 : : }
4218 : :
4219 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4220 : : return TEST_SKIPPED;
4221 : :
4222 : : /* Create KASUMI session */
4223 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4224 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4225 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4226 : 0 : tdata->key.data, tdata->key.len,
4227 : 0 : tdata->cipher_iv.len);
4228 [ # # ]: 0 : if (retval < 0)
4229 : : return retval;
4230 : :
4231 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4232 : :
4233 : :
4234 : : /* Append data which is padded to a multiple */
4235 : : /* of the algorithms block size */
4236 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4237 : :
4238 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4239 : : plaintext_pad_len, 10, 0);
4240 : :
4241 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4242 : :
4243 : : /* Create KASUMI operation */
4244 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4245 : 0 : tdata->cipher_iv.len,
4246 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4247 : 0 : tdata->validCipherOffsetInBits.len);
4248 [ # # ]: 0 : if (retval < 0)
4249 : : return retval;
4250 : :
4251 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4252 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4253 : 0 : tdata->cipher_iv.len);
4254 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4255 : : return retval;
4256 : : } else
4257 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4258 : : ut_params->op);
4259 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4260 : :
4261 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4262 : :
4263 [ # # ]: 0 : if (ut_params->obuf)
4264 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4265 : : plaintext_len, buffer);
4266 : : else
4267 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4268 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4269 : : plaintext_len, buffer);
4270 : :
4271 : : /* Validate obuf */
4272 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4273 : :
4274 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4275 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4276 : : /* Validate obuf */
4277 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4278 : : ciphertext,
4279 : : reference_ciphertext,
4280 : : tdata->validCipherLenInBits.len,
4281 : : "KASUMI Ciphertext data not as expected");
4282 : : return 0;
4283 : : }
4284 : :
4285 : : static int
4286 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4287 : : {
4288 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4289 : : struct crypto_unittest_params *ut_params = &unittest_params;
4290 : :
4291 : : int retval;
4292 : : uint8_t *plaintext, *ciphertext;
4293 : : unsigned plaintext_pad_len;
4294 : : unsigned plaintext_len;
4295 : :
4296 : : /* Verify the capabilities */
4297 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4298 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4299 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4300 : : /* Data-path service does not support OOP */
4301 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4302 : : &cap_idx) == NULL)
4303 : : return TEST_SKIPPED;
4304 : :
4305 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4306 : : return TEST_SKIPPED;
4307 : :
4308 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4309 : : return TEST_SKIPPED;
4310 : :
4311 : : /* Create KASUMI session */
4312 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4313 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4314 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4315 : 0 : tdata->key.data, tdata->key.len,
4316 : 0 : tdata->cipher_iv.len);
4317 [ # # ]: 0 : if (retval < 0)
4318 : : return retval;
4319 : :
4320 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4321 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4322 : :
4323 : : /* Clear mbuf payload */
4324 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4325 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4326 : :
4327 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4328 : : /* Append data which is padded to a multiple */
4329 : : /* of the algorithms block size */
4330 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4331 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4332 : : plaintext_pad_len);
4333 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4334 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4335 : :
4336 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4337 : :
4338 : : /* Create KASUMI operation */
4339 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4340 : 0 : tdata->cipher_iv.len,
4341 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4342 : 0 : tdata->validCipherOffsetInBits.len);
4343 [ # # ]: 0 : if (retval < 0)
4344 : : return retval;
4345 : :
4346 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4347 : : ut_params->op);
4348 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4349 : :
4350 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4351 [ # # ]: 0 : if (ut_params->obuf)
4352 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4353 : : else
4354 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4355 : :
4356 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4357 : :
4358 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4359 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4360 : : /* Validate obuf */
4361 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4362 : : ciphertext,
4363 : : reference_ciphertext,
4364 : : tdata->validCipherLenInBits.len,
4365 : : "KASUMI Ciphertext data not as expected");
4366 : : return 0;
4367 : : }
4368 : :
4369 : : static int
4370 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4371 : : {
4372 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4373 : : struct crypto_unittest_params *ut_params = &unittest_params;
4374 : :
4375 : : int retval;
4376 : : unsigned int plaintext_pad_len;
4377 : : unsigned int plaintext_len;
4378 : :
4379 : : const uint8_t *ciphertext;
4380 : : uint8_t buffer[2048];
4381 : :
4382 : : struct rte_cryptodev_info dev_info;
4383 : :
4384 : : /* Verify the capabilities */
4385 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4386 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4387 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4388 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4389 : : &cap_idx) == NULL)
4390 : : return TEST_SKIPPED;
4391 : :
4392 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4393 : : return TEST_SKIPPED;
4394 : :
4395 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4396 : : return TEST_SKIPPED;
4397 : :
4398 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4399 : :
4400 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4401 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4402 : : printf("Device doesn't support out-of-place scatter-gather "
4403 : : "in both input and output mbufs. "
4404 : : "Test Skipped.\n");
4405 : 0 : return TEST_SKIPPED;
4406 : : }
4407 : :
4408 : : /* Create KASUMI session */
4409 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4410 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4411 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4412 : 0 : tdata->key.data, tdata->key.len,
4413 : 0 : tdata->cipher_iv.len);
4414 [ # # ]: 0 : if (retval < 0)
4415 : : return retval;
4416 : :
4417 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4418 : : /* Append data which is padded to a multiple */
4419 : : /* of the algorithms block size */
4420 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4421 : :
4422 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4423 : : plaintext_pad_len, 10, 0);
4424 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4425 : : plaintext_pad_len, 3, 0);
4426 : :
4427 : : /* Append data which is padded to a multiple */
4428 : : /* of the algorithms block size */
4429 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4430 : :
4431 : : /* Create KASUMI operation */
4432 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4433 : 0 : tdata->cipher_iv.len,
4434 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4435 : 0 : tdata->validCipherOffsetInBits.len);
4436 [ # # ]: 0 : if (retval < 0)
4437 : : return retval;
4438 : :
4439 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4440 : : ut_params->op);
4441 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4442 : :
4443 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4444 [ # # ]: 0 : if (ut_params->obuf)
4445 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4446 : : plaintext_pad_len, buffer);
4447 : : else
4448 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4449 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4450 : : plaintext_pad_len, buffer);
4451 : :
4452 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4453 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4454 : : /* Validate obuf */
4455 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4456 : : ciphertext,
4457 : : reference_ciphertext,
4458 : : tdata->validCipherLenInBits.len,
4459 : : "KASUMI Ciphertext data not as expected");
4460 : : return 0;
4461 : : }
4462 : :
4463 : :
4464 : : static int
4465 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4466 : : {
4467 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4468 : : struct crypto_unittest_params *ut_params = &unittest_params;
4469 : :
4470 : : int retval;
4471 : : uint8_t *ciphertext, *plaintext;
4472 : : unsigned ciphertext_pad_len;
4473 : : unsigned ciphertext_len;
4474 : :
4475 : : /* Verify the capabilities */
4476 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4477 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4478 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4479 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4480 : : &cap_idx) == NULL)
4481 : : return TEST_SKIPPED;
4482 : :
4483 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4484 : : return TEST_SKIPPED;
4485 : :
4486 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4487 : : return TEST_SKIPPED;
4488 : :
4489 : : /* Create KASUMI session */
4490 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4491 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4492 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4493 : 0 : tdata->key.data, tdata->key.len,
4494 : 0 : tdata->cipher_iv.len);
4495 [ # # ]: 0 : if (retval < 0)
4496 : : return retval;
4497 : :
4498 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4499 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4500 : :
4501 : : /* Clear mbuf payload */
4502 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4503 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4504 : :
4505 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4506 : : /* Append data which is padded to a multiple */
4507 : : /* of the algorithms block size */
4508 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4509 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4510 : : ciphertext_pad_len);
4511 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4512 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4513 : :
4514 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4515 : :
4516 : : /* Create KASUMI operation */
4517 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4518 : 0 : tdata->cipher_iv.len,
4519 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4520 : 0 : tdata->validCipherOffsetInBits.len);
4521 [ # # ]: 0 : if (retval < 0)
4522 : : return retval;
4523 : :
4524 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4525 : : ut_params->op);
4526 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4527 : :
4528 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4529 [ # # ]: 0 : if (ut_params->obuf)
4530 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4531 : : else
4532 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4533 : :
4534 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4535 : :
4536 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4537 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4538 : : /* Validate obuf */
4539 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4540 : : plaintext,
4541 : : reference_plaintext,
4542 : : tdata->validCipherLenInBits.len,
4543 : : "KASUMI Plaintext data not as expected");
4544 : : return 0;
4545 : : }
4546 : :
4547 : : static int
4548 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4549 : : {
4550 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4551 : : struct crypto_unittest_params *ut_params = &unittest_params;
4552 : :
4553 : : int retval;
4554 : : uint8_t *ciphertext, *plaintext;
4555 : : unsigned ciphertext_pad_len;
4556 : : unsigned ciphertext_len;
4557 : : struct rte_cryptodev_info dev_info;
4558 : :
4559 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4560 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4561 : :
4562 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4563 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4564 : : printf("Device doesn't support RAW data-path APIs.\n");
4565 : 0 : return TEST_SKIPPED;
4566 : : }
4567 : :
4568 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4569 : : return TEST_SKIPPED;
4570 : :
4571 : : /* Verify the capabilities */
4572 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4573 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4574 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4575 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4576 : : &cap_idx) == NULL)
4577 : : return TEST_SKIPPED;
4578 : :
4579 : : /* Create KASUMI session */
4580 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4581 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4582 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4583 : 0 : tdata->key.data, tdata->key.len,
4584 : 0 : tdata->cipher_iv.len);
4585 [ # # ]: 0 : if (retval < 0)
4586 : : return retval;
4587 : :
4588 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4589 : :
4590 : : /* Clear mbuf payload */
4591 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4592 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4593 : :
4594 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4595 : : /* Append data which is padded to a multiple */
4596 : : /* of the algorithms block size */
4597 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4598 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4599 : : ciphertext_pad_len);
4600 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4601 : :
4602 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4603 : :
4604 : : /* Create KASUMI operation */
4605 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4606 : 0 : tdata->cipher_iv.len,
4607 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4608 : 0 : tdata->validCipherOffsetInBits.len);
4609 [ # # ]: 0 : if (retval < 0)
4610 : : return retval;
4611 : :
4612 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4613 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4614 : : 0);
4615 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4616 : : return retval;
4617 : : } else
4618 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4619 : : ut_params->op);
4620 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4621 : :
4622 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4623 [ # # ]: 0 : if (ut_params->obuf)
4624 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4625 : : else
4626 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4627 : :
4628 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4629 : :
4630 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4631 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4632 : : /* Validate obuf */
4633 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4634 : : plaintext,
4635 : : reference_plaintext,
4636 : : tdata->validCipherLenInBits.len,
4637 : : "KASUMI Plaintext data not as expected");
4638 : : return 0;
4639 : : }
4640 : :
4641 : : static int
4642 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4643 : : {
4644 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4645 : : struct crypto_unittest_params *ut_params = &unittest_params;
4646 : :
4647 : : int retval;
4648 : : uint8_t *plaintext, *ciphertext;
4649 : : unsigned plaintext_pad_len;
4650 : : unsigned plaintext_len;
4651 : : struct rte_cryptodev_info dev_info;
4652 : :
4653 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4654 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4655 : :
4656 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4657 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4658 : : printf("Device doesn't support RAW data-path APIs.\n");
4659 : 0 : return TEST_SKIPPED;
4660 : : }
4661 : :
4662 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4663 : : return TEST_SKIPPED;
4664 : :
4665 : : /* Verify the capabilities */
4666 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4667 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4668 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4669 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4670 : : &cap_idx) == NULL)
4671 : : return TEST_SKIPPED;
4672 : :
4673 : : /* Create SNOW 3G session */
4674 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4675 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4676 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4677 : 0 : tdata->key.data, tdata->key.len,
4678 : 0 : tdata->cipher_iv.len);
4679 [ # # ]: 0 : if (retval < 0)
4680 : : return retval;
4681 : :
4682 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4683 : :
4684 : : /* Clear mbuf payload */
4685 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4686 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4687 : :
4688 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4689 : : /* Append data which is padded to a multiple of */
4690 : : /* the algorithms block size */
4691 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4692 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4693 : : plaintext_pad_len);
4694 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4695 : :
4696 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4697 : :
4698 : : /* Create SNOW 3G operation */
4699 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4700 : 0 : tdata->cipher_iv.len,
4701 : 0 : tdata->validCipherLenInBits.len,
4702 : : 0);
4703 [ # # ]: 0 : if (retval < 0)
4704 : : return retval;
4705 : :
4706 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4707 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4708 : 0 : tdata->cipher_iv.len);
4709 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4710 : : return retval;
4711 : : } else
4712 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4713 : : ut_params->op);
4714 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4715 : :
4716 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4717 [ # # ]: 0 : if (ut_params->obuf)
4718 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4719 : : else
4720 : : ciphertext = plaintext;
4721 : :
4722 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4723 : :
4724 : : /* Validate obuf */
4725 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4726 : : ciphertext,
4727 : : tdata->ciphertext.data,
4728 : : tdata->validDataLenInBits.len,
4729 : : "SNOW 3G Ciphertext data not as expected");
4730 : : return 0;
4731 : : }
4732 : :
4733 : :
4734 : : static int
4735 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4736 : : {
4737 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4738 : : struct crypto_unittest_params *ut_params = &unittest_params;
4739 : : uint8_t *plaintext, *ciphertext;
4740 : :
4741 : : int retval;
4742 : : unsigned plaintext_pad_len;
4743 : : unsigned plaintext_len;
4744 : : struct rte_cryptodev_info dev_info;
4745 : :
4746 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4747 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4748 : :
4749 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4750 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4751 : : printf("Device does not support RAW data-path APIs.\n");
4752 : 0 : return -ENOTSUP;
4753 : : }
4754 : :
4755 : : /* Verify the capabilities */
4756 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4757 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4758 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4759 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4760 : : &cap_idx) == NULL)
4761 : : return TEST_SKIPPED;
4762 : :
4763 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4764 : : return TEST_SKIPPED;
4765 : :
4766 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4767 : : return TEST_SKIPPED;
4768 : :
4769 : : /* Create SNOW 3G session */
4770 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4771 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4772 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4773 : 0 : tdata->key.data, tdata->key.len,
4774 : 0 : tdata->cipher_iv.len);
4775 [ # # ]: 0 : if (retval < 0)
4776 : : return retval;
4777 : :
4778 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4779 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4780 : :
4781 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4782 : : "Failed to allocate input buffer in mempool");
4783 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4784 : : "Failed to allocate output buffer in mempool");
4785 : :
4786 : : /* Clear mbuf payload */
4787 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4788 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4789 : :
4790 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4791 : : /* Append data which is padded to a multiple of */
4792 : : /* the algorithms block size */
4793 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4794 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4795 : : plaintext_pad_len);
4796 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4797 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4798 : :
4799 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4800 : :
4801 : : /* Create SNOW 3G operation */
4802 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4803 : 0 : tdata->cipher_iv.len,
4804 : 0 : tdata->validCipherLenInBits.len,
4805 : : 0);
4806 [ # # ]: 0 : if (retval < 0)
4807 : : return retval;
4808 : :
4809 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4810 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4811 : 0 : tdata->cipher_iv.len);
4812 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4813 : : return retval;
4814 : : } else
4815 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4816 : : ut_params->op);
4817 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4818 : :
4819 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4820 [ # # ]: 0 : if (ut_params->obuf)
4821 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4822 : : else
4823 : : ciphertext = plaintext;
4824 : :
4825 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4826 : :
4827 : : /* Validate obuf */
4828 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4829 : : ciphertext,
4830 : : tdata->ciphertext.data,
4831 : : tdata->validDataLenInBits.len,
4832 : : "SNOW 3G Ciphertext data not as expected");
4833 : : return 0;
4834 : : }
4835 : :
4836 : : static int
4837 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4838 : : uint8_t sgl_in, uint8_t sgl_out)
4839 : : {
4840 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4841 : : struct crypto_unittest_params *ut_params = &unittest_params;
4842 : :
4843 : : int retval;
4844 : : unsigned int plaintext_pad_len;
4845 : : unsigned int plaintext_len;
4846 : : uint8_t buffer[10000];
4847 : : const uint8_t *ciphertext;
4848 : :
4849 : : struct rte_cryptodev_info dev_info;
4850 : :
4851 : : /* Verify the capabilities */
4852 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4853 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4854 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4855 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4856 : : &cap_idx) == NULL)
4857 : : return TEST_SKIPPED;
4858 : :
4859 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4860 : : return TEST_SKIPPED;
4861 : :
4862 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4863 : : return TEST_SKIPPED;
4864 : :
4865 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4866 : :
4867 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4868 : :
4869 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4870 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4871 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4872 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4873 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4874 : : printf("Device doesn't support out-of-place scatter gather type. "
4875 : : "Test Skipped.\n");
4876 : 0 : return TEST_SKIPPED;
4877 : : }
4878 : :
4879 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4880 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4881 : : printf("Device does not support RAW data-path APIs.\n");
4882 : 0 : return -ENOTSUP;
4883 : : }
4884 : :
4885 : : /* Create SNOW 3G session */
4886 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4887 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4888 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4889 : 0 : tdata->key.data, tdata->key.len,
4890 : 0 : tdata->cipher_iv.len);
4891 [ # # ]: 0 : if (retval < 0)
4892 : : return retval;
4893 : :
4894 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4895 : : /* Append data which is padded to a multiple of */
4896 : : /* the algorithms block size */
4897 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4898 : :
4899 [ # # ]: 0 : if (sgl_in)
4900 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4901 : : plaintext_pad_len, 10, 0);
4902 : : else {
4903 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4904 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4905 : : }
4906 : :
4907 [ # # ]: 0 : if (sgl_out)
4908 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4909 : : plaintext_pad_len, 3, 0);
4910 : : else {
4911 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4912 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4913 : : }
4914 : :
4915 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4916 : : "Failed to allocate input buffer in mempool");
4917 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4918 : : "Failed to allocate output buffer in mempool");
4919 : :
4920 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4921 : :
4922 : : /* Create SNOW 3G operation */
4923 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4924 : 0 : tdata->cipher_iv.len,
4925 : 0 : tdata->validCipherLenInBits.len,
4926 : : 0);
4927 [ # # ]: 0 : if (retval < 0)
4928 : : return retval;
4929 : :
4930 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4931 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4932 : 0 : tdata->cipher_iv.len);
4933 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4934 : : return retval;
4935 : : } else
4936 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4937 : : ut_params->op);
4938 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4939 : :
4940 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4941 [ # # ]: 0 : if (ut_params->obuf)
4942 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4943 : : plaintext_len, buffer);
4944 : : else
4945 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4946 : : plaintext_len, buffer);
4947 : :
4948 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4949 : :
4950 : : /* Validate obuf */
4951 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4952 : : ciphertext,
4953 : : tdata->ciphertext.data,
4954 : : tdata->validDataLenInBits.len,
4955 : : "SNOW 3G Ciphertext data not as expected");
4956 : :
4957 : : return 0;
4958 : : }
4959 : :
4960 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4961 : : static void
4962 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4963 : : {
4964 : : uint8_t curr_byte, prev_byte;
4965 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4966 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4967 : : unsigned i;
4968 : :
4969 : 0 : prev_byte = buffer[0];
4970 : 0 : buffer[0] >>= offset;
4971 : :
4972 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4973 : 0 : curr_byte = buffer[i];
4974 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4975 : 0 : (curr_byte >> offset);
4976 : : prev_byte = curr_byte;
4977 : : }
4978 : 0 : }
4979 : :
4980 : : static int
4981 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4982 : : {
4983 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4984 : : struct crypto_unittest_params *ut_params = &unittest_params;
4985 : : uint8_t *plaintext, *ciphertext;
4986 : : int retval;
4987 : : uint32_t plaintext_len;
4988 : : uint32_t plaintext_pad_len;
4989 : : uint8_t extra_offset = 4;
4990 : : uint8_t *expected_ciphertext_shifted;
4991 : : struct rte_cryptodev_info dev_info;
4992 : :
4993 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4994 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4995 : :
4996 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4997 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4998 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4999 : 0 : return TEST_SKIPPED;
5000 : : }
5001 : :
5002 : : /* Verify the capabilities */
5003 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5004 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5005 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5006 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5007 : : &cap_idx) == NULL)
5008 : : return TEST_SKIPPED;
5009 : :
5010 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5011 : : return TEST_SKIPPED;
5012 : :
5013 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5014 : : return TEST_SKIPPED;
5015 : :
5016 : : /* Create SNOW 3G session */
5017 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5018 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5019 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5020 : 0 : tdata->key.data, tdata->key.len,
5021 : 0 : tdata->cipher_iv.len);
5022 [ # # ]: 0 : if (retval < 0)
5023 : : return retval;
5024 : :
5025 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5026 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5027 : :
5028 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5029 : : "Failed to allocate input buffer in mempool");
5030 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5031 : : "Failed to allocate output buffer in mempool");
5032 : :
5033 : : /* Clear mbuf payload */
5034 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5035 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5036 : :
5037 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
5038 : : /*
5039 : : * Append data which is padded to a
5040 : : * multiple of the algorithms block size
5041 : : */
5042 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5043 : :
5044 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
5045 : : plaintext_pad_len);
5046 : :
5047 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5048 : :
5049 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
5050 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
5051 : :
5052 : : #ifdef RTE_APP_TEST_DEBUG
5053 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
5054 : : #endif
5055 : : /* Create SNOW 3G operation */
5056 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5057 : 0 : tdata->cipher_iv.len,
5058 : 0 : tdata->validCipherLenInBits.len,
5059 : : extra_offset);
5060 [ # # ]: 0 : if (retval < 0)
5061 : : return retval;
5062 : :
5063 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5064 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5065 : 0 : tdata->cipher_iv.len);
5066 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5067 : : return retval;
5068 : : } else
5069 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5070 : : ut_params->op);
5071 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5072 : :
5073 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5074 [ # # ]: 0 : if (ut_params->obuf)
5075 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5076 : : else
5077 : : ciphertext = plaintext;
5078 : :
5079 : : #ifdef RTE_APP_TEST_DEBUG
5080 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5081 : : #endif
5082 : :
5083 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
5084 : :
5085 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
5086 : : "failed to reserve memory for ciphertext shifted\n");
5087 : :
5088 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
5089 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
5090 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
5091 : : extra_offset);
5092 : : /* Validate obuf */
5093 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5094 : : ciphertext,
5095 : : expected_ciphertext_shifted,
5096 : : tdata->validDataLenInBits.len,
5097 : : extra_offset,
5098 : : "SNOW 3G Ciphertext data not as expected");
5099 : : return 0;
5100 : : }
5101 : :
5102 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
5103 : : {
5104 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5105 : : struct crypto_unittest_params *ut_params = &unittest_params;
5106 : :
5107 : : int retval;
5108 : :
5109 : : uint8_t *plaintext, *ciphertext;
5110 : : unsigned ciphertext_pad_len;
5111 : : unsigned ciphertext_len;
5112 : : struct rte_cryptodev_info dev_info;
5113 : :
5114 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5115 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5116 : :
5117 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5118 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5119 : : printf("Device doesn't support RAW data-path APIs.\n");
5120 : 0 : return TEST_SKIPPED;
5121 : : }
5122 : :
5123 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5124 : : return TEST_SKIPPED;
5125 : :
5126 : : /* Verify the capabilities */
5127 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5128 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5129 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5130 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5131 : : &cap_idx) == NULL)
5132 : : return TEST_SKIPPED;
5133 : :
5134 : : /* Create SNOW 3G session */
5135 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5136 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5137 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5138 : 0 : tdata->key.data, tdata->key.len,
5139 : 0 : tdata->cipher_iv.len);
5140 [ # # ]: 0 : if (retval < 0)
5141 : : return retval;
5142 : :
5143 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5144 : :
5145 : : /* Clear mbuf payload */
5146 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5147 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5148 : :
5149 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5150 : : /* Append data which is padded to a multiple of */
5151 : : /* the algorithms block size */
5152 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5153 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5154 : : ciphertext_pad_len);
5155 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5156 : :
5157 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5158 : :
5159 : : /* Create SNOW 3G operation */
5160 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5161 : 0 : tdata->cipher_iv.len,
5162 : 0 : tdata->validCipherLenInBits.len,
5163 : 0 : tdata->cipher.offset_bits);
5164 [ # # ]: 0 : if (retval < 0)
5165 : : return retval;
5166 : :
5167 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5168 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5169 : 0 : tdata->cipher_iv.len);
5170 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5171 : : return retval;
5172 : : } else
5173 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5174 : : ut_params->op);
5175 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5176 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5177 [ # # ]: 0 : if (ut_params->obuf)
5178 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5179 : : else
5180 : : plaintext = ciphertext;
5181 : :
5182 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5183 : :
5184 : : /* Validate obuf */
5185 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5186 : : tdata->plaintext.data,
5187 : : tdata->validDataLenInBits.len,
5188 : : "SNOW 3G Plaintext data not as expected");
5189 : : return 0;
5190 : : }
5191 : :
5192 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5193 : : {
5194 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5195 : : struct crypto_unittest_params *ut_params = &unittest_params;
5196 : :
5197 : : int retval;
5198 : :
5199 : : uint8_t *plaintext, *ciphertext;
5200 : : unsigned ciphertext_pad_len;
5201 : : unsigned ciphertext_len;
5202 : : struct rte_cryptodev_info dev_info;
5203 : :
5204 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5205 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5206 : :
5207 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5208 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5209 : : printf("Device does not support RAW data-path APIs.\n");
5210 : 0 : return -ENOTSUP;
5211 : : }
5212 : : /* Verify the capabilities */
5213 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5214 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5215 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5216 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5217 : : &cap_idx) == NULL)
5218 : : return TEST_SKIPPED;
5219 : :
5220 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5221 : : return TEST_SKIPPED;
5222 : :
5223 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5224 : : return TEST_SKIPPED;
5225 : :
5226 : : /* Create SNOW 3G session */
5227 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5228 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5229 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5230 : 0 : tdata->key.data, tdata->key.len,
5231 : 0 : tdata->cipher_iv.len);
5232 [ # # ]: 0 : if (retval < 0)
5233 : : return retval;
5234 : :
5235 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5236 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5237 : :
5238 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5239 : : "Failed to allocate input buffer");
5240 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5241 : : "Failed to allocate output buffer");
5242 : :
5243 : : /* Clear mbuf payload */
5244 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5245 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5246 : :
5247 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5248 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5249 : :
5250 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5251 : : /* Append data which is padded to a multiple of */
5252 : : /* the algorithms block size */
5253 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5254 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5255 : : ciphertext_pad_len);
5256 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5257 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5258 : :
5259 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5260 : :
5261 : : /* Create SNOW 3G operation */
5262 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5263 : 0 : tdata->cipher_iv.len,
5264 : 0 : tdata->validCipherLenInBits.len,
5265 : : 0);
5266 [ # # ]: 0 : if (retval < 0)
5267 : : return retval;
5268 : :
5269 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5270 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5271 : 0 : tdata->cipher_iv.len);
5272 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5273 : : return retval;
5274 : : } else
5275 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5276 : : ut_params->op);
5277 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5278 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5279 [ # # ]: 0 : if (ut_params->obuf)
5280 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5281 : : else
5282 : : plaintext = ciphertext;
5283 : :
5284 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5285 : :
5286 : : /* Validate obuf */
5287 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5288 : : tdata->plaintext.data,
5289 : : tdata->validDataLenInBits.len,
5290 : : "SNOW 3G Plaintext data not as expected");
5291 : : return 0;
5292 : : }
5293 : :
5294 : : static int
5295 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5296 : : {
5297 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5298 : : struct crypto_unittest_params *ut_params = &unittest_params;
5299 : :
5300 : : int retval;
5301 : :
5302 : : uint8_t *plaintext, *ciphertext;
5303 : : unsigned int plaintext_pad_len;
5304 : : unsigned int plaintext_len;
5305 : :
5306 : : struct rte_cryptodev_info dev_info;
5307 : :
5308 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5309 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5310 : :
5311 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5312 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
5313 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
5314 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
5315 : 0 : return TEST_SKIPPED;
5316 : : }
5317 : :
5318 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5319 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5320 : : printf("Device doesn't support RAW data-path APIs.\n");
5321 : 0 : return TEST_SKIPPED;
5322 : : }
5323 : :
5324 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5325 : : return TEST_SKIPPED;
5326 : :
5327 : : /* Check if device supports ZUC EEA3 */
5328 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5329 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
5330 : : return TEST_SKIPPED;
5331 : :
5332 : : /* Check if device supports ZUC EIA3 */
5333 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5334 : 0 : tdata->key.len, tdata->auth_iv.len,
5335 : 0 : tdata->digest.len) < 0)
5336 : : return TEST_SKIPPED;
5337 : :
5338 : : /* Create ZUC session */
5339 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
5340 : 0 : ts_params->valid_devs[0],
5341 : : tdata);
5342 [ # # ]: 0 : if (retval != 0)
5343 : : return retval;
5344 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5345 : :
5346 : : /* clear mbuf payload */
5347 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5348 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5349 : :
5350 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5351 : : /* Append data which is padded to a multiple of */
5352 : : /* the algorithms block size */
5353 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5354 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5355 : : plaintext_pad_len);
5356 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5357 : :
5358 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5359 : :
5360 : : /* Create ZUC operation */
5361 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
5362 [ # # ]: 0 : if (retval < 0)
5363 : : return retval;
5364 : :
5365 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5366 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5367 : 0 : tdata->cipher_iv.len);
5368 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5369 : : return retval;
5370 : : } else
5371 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5372 : : ut_params->op);
5373 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5374 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5375 [ # # ]: 0 : if (ut_params->obuf)
5376 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5377 : : else
5378 : : ciphertext = plaintext;
5379 : :
5380 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5381 : : /* Validate obuf */
5382 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5383 : : ciphertext,
5384 : : tdata->ciphertext.data,
5385 : : tdata->validDataLenInBits.len,
5386 : : "ZUC Ciphertext data not as expected");
5387 : :
5388 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5389 : : uint8_t *,
5390 : : plaintext_pad_len);
5391 : :
5392 : : /* Validate obuf */
5393 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5394 : : ut_params->digest,
5395 : : tdata->digest.data,
5396 : : tdata->digest.len,
5397 : : "ZUC Generated auth tag not as expected");
5398 : : return 0;
5399 : : }
5400 : :
5401 : : static int
5402 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5403 : : {
5404 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5405 : : struct crypto_unittest_params *ut_params = &unittest_params;
5406 : :
5407 : : int retval;
5408 : :
5409 : : uint8_t *plaintext, *ciphertext;
5410 : : unsigned plaintext_pad_len;
5411 : : unsigned plaintext_len;
5412 : : struct rte_cryptodev_info dev_info;
5413 : :
5414 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5415 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5416 : :
5417 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5418 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5419 : : printf("Device doesn't support RAW data-path APIs.\n");
5420 : 0 : return TEST_SKIPPED;
5421 : : }
5422 : :
5423 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5424 : : return TEST_SKIPPED;
5425 : :
5426 : : /* Verify the capabilities */
5427 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5428 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5429 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5430 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5431 : : &cap_idx) == NULL)
5432 : : return TEST_SKIPPED;
5433 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5434 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5435 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5436 : : &cap_idx) == NULL)
5437 : : return TEST_SKIPPED;
5438 : :
5439 : : /* Create SNOW 3G session */
5440 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5441 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5442 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5443 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5444 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5445 : : tdata->key.data, tdata->key.len,
5446 : 0 : tdata->key.data, tdata->key.len,
5447 : 0 : tdata->auth_iv.len, tdata->digest.len,
5448 : 0 : tdata->cipher_iv.len);
5449 [ # # ]: 0 : if (retval != 0)
5450 : : return retval;
5451 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5452 : :
5453 : : /* clear mbuf payload */
5454 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5455 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5456 : :
5457 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5458 : : /* Append data which is padded to a multiple of */
5459 : : /* the algorithms block size */
5460 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5461 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5462 : : plaintext_pad_len);
5463 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5464 : :
5465 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5466 : :
5467 : : /* Create SNOW 3G operation */
5468 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5469 : 0 : tdata->digest.len, tdata->auth_iv.data,
5470 : 0 : tdata->auth_iv.len,
5471 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5472 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5473 : 0 : tdata->validCipherLenInBits.len,
5474 : : 0,
5475 : 0 : tdata->validAuthLenInBits.len,
5476 : : 0
5477 : : );
5478 [ # # ]: 0 : if (retval < 0)
5479 : : return retval;
5480 : :
5481 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5482 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5483 : 0 : tdata->cipher_iv.len);
5484 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5485 : : return retval;
5486 : : } else
5487 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5488 : : ut_params->op);
5489 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5490 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5491 [ # # ]: 0 : if (ut_params->obuf)
5492 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5493 : : else
5494 : : ciphertext = plaintext;
5495 : :
5496 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5497 : : /* Validate obuf */
5498 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5499 : : ciphertext,
5500 : : tdata->ciphertext.data,
5501 : : tdata->validDataLenInBits.len,
5502 : : "SNOW 3G Ciphertext data not as expected");
5503 : :
5504 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5505 : : uint8_t *,
5506 : : plaintext_pad_len);
5507 : :
5508 : : /* Validate obuf */
5509 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5510 : : ut_params->digest,
5511 : : tdata->digest.data,
5512 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5513 : : "SNOW 3G Generated auth tag not as expected");
5514 : : return 0;
5515 : : }
5516 : :
5517 : : static int
5518 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5519 : : uint8_t op_mode, uint8_t verify)
5520 : : {
5521 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5522 : : struct crypto_unittest_params *ut_params = &unittest_params;
5523 : :
5524 : : int retval;
5525 : :
5526 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5527 : : unsigned int plaintext_pad_len;
5528 : : unsigned int plaintext_len;
5529 : : unsigned int ciphertext_pad_len;
5530 : : unsigned int ciphertext_len;
5531 : : unsigned int digest_offset;
5532 : :
5533 : : struct rte_cryptodev_info dev_info;
5534 : :
5535 : : /* Verify the capabilities */
5536 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5537 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5538 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5539 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5540 : : &cap_idx) == NULL)
5541 : : return TEST_SKIPPED;
5542 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5543 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5544 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5545 : : &cap_idx) == NULL)
5546 : : return TEST_SKIPPED;
5547 : :
5548 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5549 : : return TEST_SKIPPED;
5550 : :
5551 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5552 : :
5553 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5554 : :
5555 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5556 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5557 : : printf("Device doesn't support digest encrypted.\n");
5558 : 0 : return TEST_SKIPPED;
5559 : : }
5560 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5561 : : return TEST_SKIPPED;
5562 : : }
5563 : :
5564 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5565 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5566 : : printf("Device doesn't support RAW data-path APIs.\n");
5567 : 0 : return TEST_SKIPPED;
5568 : : }
5569 : :
5570 : : /* Create SNOW 3G session */
5571 : 0 : retval = create_wireless_algo_auth_cipher_session(
5572 : 0 : ts_params->valid_devs[0],
5573 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5574 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5575 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5576 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5577 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5578 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5579 : : tdata->key.data, tdata->key.len,
5580 : 0 : tdata->key.data, tdata->key.len,
5581 : 0 : tdata->auth_iv.len, tdata->digest.len,
5582 : 0 : tdata->cipher_iv.len);
5583 [ # # ]: 0 : if (retval != 0)
5584 : : return retval;
5585 : :
5586 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5587 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5588 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5589 : :
5590 : : /* clear mbuf payload */
5591 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5592 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5593 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5594 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5595 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5596 : :
5597 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5598 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5599 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5600 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5601 : :
5602 [ # # ]: 0 : if (verify) {
5603 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5604 : : ciphertext_pad_len);
5605 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5606 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5607 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5608 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5609 : : ciphertext_len);
5610 : : } else {
5611 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5612 : : plaintext_pad_len);
5613 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5614 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5615 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5616 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5617 : : }
5618 : :
5619 : : /* Create SNOW 3G operation */
5620 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5621 : 0 : tdata->digest.data, tdata->digest.len,
5622 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5623 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5624 : 0 : (tdata->digest.offset_bytes == 0 ?
5625 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5626 : : : tdata->digest.offset_bytes),
5627 : 0 : tdata->validCipherLenInBits.len,
5628 : 0 : tdata->cipher.offset_bits,
5629 : 0 : tdata->validAuthLenInBits.len,
5630 [ # # ]: 0 : tdata->auth.offset_bits,
5631 : : op_mode, 0, verify);
5632 : :
5633 [ # # ]: 0 : if (retval < 0)
5634 : : return retval;
5635 : :
5636 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5637 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5638 : 0 : tdata->cipher_iv.len);
5639 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5640 : : return retval;
5641 : : } else
5642 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5643 : : ut_params->op);
5644 : :
5645 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5646 : :
5647 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5648 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5649 : :
5650 [ # # ]: 0 : if (verify) {
5651 [ # # ]: 0 : if (ut_params->obuf)
5652 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5653 : : uint8_t *);
5654 : : else
5655 : 0 : plaintext = ciphertext +
5656 : 0 : (tdata->cipher.offset_bits >> 3);
5657 : :
5658 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5659 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5660 : 0 : debug_hexdump(stdout, "plaintext expected:",
5661 : 0 : tdata->plaintext.data,
5662 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5663 : : } else {
5664 [ # # ]: 0 : if (ut_params->obuf)
5665 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5666 : : uint8_t *);
5667 : : else
5668 : : ciphertext = plaintext;
5669 : :
5670 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5671 : : ciphertext_len);
5672 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5673 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5674 : :
5675 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5676 : : digest_offset = plaintext_pad_len;
5677 : : else
5678 : : digest_offset = tdata->digest.offset_bytes;
5679 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5680 : : uint8_t *, digest_offset);
5681 : :
5682 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5683 : 0 : tdata->digest.len);
5684 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5685 : 0 : tdata->digest.len);
5686 : : }
5687 : :
5688 : : /* Validate obuf */
5689 [ # # ]: 0 : if (verify) {
5690 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5691 : : plaintext,
5692 : : tdata->plaintext.data,
5693 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5694 : : (tdata->digest.len << 3)),
5695 : : tdata->cipher.offset_bits,
5696 : : "SNOW 3G Plaintext data not as expected");
5697 : : } else {
5698 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5699 : : ciphertext,
5700 : : tdata->ciphertext.data,
5701 : : (tdata->validDataLenInBits.len -
5702 : : tdata->cipher.offset_bits),
5703 : : tdata->cipher.offset_bits,
5704 : : "SNOW 3G Ciphertext data not as expected");
5705 : :
5706 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5707 : : ut_params->digest,
5708 : : tdata->digest.data,
5709 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5710 : : "SNOW 3G Generated auth tag not as expected");
5711 : : }
5712 : : return 0;
5713 : : }
5714 : :
5715 : : static int
5716 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5717 : : uint8_t op_mode, uint8_t verify)
5718 : : {
5719 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5720 : : struct crypto_unittest_params *ut_params = &unittest_params;
5721 : :
5722 : : int retval;
5723 : :
5724 : : const uint8_t *plaintext = NULL;
5725 : : const uint8_t *ciphertext = NULL;
5726 : : const uint8_t *digest = NULL;
5727 : : unsigned int plaintext_pad_len;
5728 : : unsigned int plaintext_len;
5729 : : unsigned int ciphertext_pad_len;
5730 : : unsigned int ciphertext_len;
5731 : : uint8_t buffer[10000];
5732 : : uint8_t digest_buffer[10000];
5733 : :
5734 : : struct rte_cryptodev_info dev_info;
5735 : :
5736 : : /* Verify the capabilities */
5737 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5738 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5739 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5740 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5741 : : &cap_idx) == NULL)
5742 : : return TEST_SKIPPED;
5743 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5744 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5745 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5746 : : &cap_idx) == NULL)
5747 : : return TEST_SKIPPED;
5748 : :
5749 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5750 : : return TEST_SKIPPED;
5751 : :
5752 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5753 : :
5754 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5755 : :
5756 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5757 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5758 : : printf("Device doesn't support in-place scatter-gather "
5759 : : "in both input and output mbufs.\n");
5760 : 0 : return TEST_SKIPPED;
5761 : : }
5762 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5763 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5764 : : printf("Device doesn't support RAW data-path APIs.\n");
5765 : 0 : return TEST_SKIPPED;
5766 : : }
5767 : : } else {
5768 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5769 : : return TEST_SKIPPED;
5770 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5771 : : printf("Device doesn't support out-of-place scatter-gather "
5772 : : "in both input and output mbufs.\n");
5773 : 0 : return TEST_SKIPPED;
5774 : : }
5775 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5776 : : printf("Device doesn't support digest encrypted.\n");
5777 : 0 : return TEST_SKIPPED;
5778 : : }
5779 : : }
5780 : :
5781 : : /* Create SNOW 3G session */
5782 : 0 : retval = create_wireless_algo_auth_cipher_session(
5783 : 0 : ts_params->valid_devs[0],
5784 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5785 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5786 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5787 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5788 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5789 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5790 : : tdata->key.data, tdata->key.len,
5791 : 0 : tdata->key.data, tdata->key.len,
5792 : 0 : tdata->auth_iv.len, tdata->digest.len,
5793 : 0 : tdata->cipher_iv.len);
5794 : :
5795 [ # # ]: 0 : if (retval != 0)
5796 : : return retval;
5797 : :
5798 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5799 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5800 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5801 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5802 : :
5803 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5804 : : plaintext_pad_len, 15, 0);
5805 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5806 : : "Failed to allocate input buffer in mempool");
5807 : :
5808 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5809 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5810 : : plaintext_pad_len, 15, 0);
5811 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5812 : : "Failed to allocate output buffer in mempool");
5813 : : }
5814 : :
5815 [ # # ]: 0 : if (verify) {
5816 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5817 : 0 : tdata->ciphertext.data);
5818 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5819 : : ciphertext_len, buffer);
5820 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5821 : : ciphertext_len);
5822 : : } else {
5823 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5824 : 0 : tdata->plaintext.data);
5825 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5826 : : plaintext_len, buffer);
5827 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5828 : : plaintext_len);
5829 : : }
5830 : : memset(buffer, 0, sizeof(buffer));
5831 : :
5832 : : /* Create SNOW 3G operation */
5833 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5834 : 0 : tdata->digest.data, tdata->digest.len,
5835 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5836 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5837 : 0 : (tdata->digest.offset_bytes == 0 ?
5838 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5839 : : : tdata->digest.offset_bytes),
5840 : 0 : tdata->validCipherLenInBits.len,
5841 : 0 : tdata->cipher.offset_bits,
5842 : 0 : tdata->validAuthLenInBits.len,
5843 [ # # ]: 0 : tdata->auth.offset_bits,
5844 : : op_mode, 1, verify);
5845 : :
5846 [ # # ]: 0 : if (retval < 0)
5847 : : return retval;
5848 : :
5849 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5850 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5851 : 0 : tdata->cipher_iv.len);
5852 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5853 : : return retval;
5854 : : } else
5855 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5856 : : ut_params->op);
5857 : :
5858 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5859 : :
5860 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5861 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5862 : :
5863 [ # # ]: 0 : if (verify) {
5864 [ # # ]: 0 : if (ut_params->obuf)
5865 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5866 : : plaintext_len, buffer);
5867 : : else
5868 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5869 : : plaintext_len, buffer);
5870 : :
5871 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5872 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5873 : 0 : debug_hexdump(stdout, "plaintext expected:",
5874 : 0 : tdata->plaintext.data,
5875 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5876 : : } else {
5877 [ # # ]: 0 : if (ut_params->obuf)
5878 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5879 : : ciphertext_len, buffer);
5880 : : else
5881 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5882 : : ciphertext_len, buffer);
5883 : :
5884 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5885 : : ciphertext_len);
5886 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5887 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5888 : :
5889 [ # # ]: 0 : if (ut_params->obuf)
5890 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5891 : 0 : (tdata->digest.offset_bytes == 0 ?
5892 : : plaintext_pad_len : tdata->digest.offset_bytes),
5893 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5894 : : else
5895 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5896 : 0 : (tdata->digest.offset_bytes == 0 ?
5897 : : plaintext_pad_len : tdata->digest.offset_bytes),
5898 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5899 : :
5900 : 0 : debug_hexdump(stdout, "digest:", digest,
5901 : 0 : tdata->digest.len);
5902 : 0 : debug_hexdump(stdout, "digest expected:",
5903 : 0 : tdata->digest.data, tdata->digest.len);
5904 : : }
5905 : :
5906 : : /* Validate obuf */
5907 [ # # ]: 0 : if (verify) {
5908 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5909 : : plaintext,
5910 : : tdata->plaintext.data,
5911 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5912 : : (tdata->digest.len << 3)),
5913 : : tdata->cipher.offset_bits,
5914 : : "SNOW 3G Plaintext data not as expected");
5915 : : } else {
5916 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5917 : : ciphertext,
5918 : : tdata->ciphertext.data,
5919 : : (tdata->validDataLenInBits.len -
5920 : : tdata->cipher.offset_bits),
5921 : : tdata->cipher.offset_bits,
5922 : : "SNOW 3G Ciphertext data not as expected");
5923 : :
5924 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5925 : : digest,
5926 : : tdata->digest.data,
5927 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5928 : : "SNOW 3G Generated auth tag not as expected");
5929 : : }
5930 : : return 0;
5931 : : }
5932 : :
5933 : : static int
5934 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5935 : : uint8_t op_mode, uint8_t verify)
5936 : : {
5937 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5938 : : struct crypto_unittest_params *ut_params = &unittest_params;
5939 : :
5940 : : int retval;
5941 : :
5942 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5943 : : unsigned int plaintext_pad_len;
5944 : : unsigned int plaintext_len;
5945 : : unsigned int ciphertext_pad_len;
5946 : : unsigned int ciphertext_len;
5947 : : unsigned int digest_offset;
5948 : :
5949 : : struct rte_cryptodev_info dev_info;
5950 : :
5951 : : /* Verify the capabilities */
5952 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5953 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5954 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5955 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5956 : : &cap_idx) == NULL)
5957 : : return TEST_SKIPPED;
5958 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5959 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5960 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5961 : : &cap_idx) == NULL)
5962 : : return TEST_SKIPPED;
5963 : :
5964 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5965 : :
5966 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5967 : :
5968 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5969 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5970 : : printf("Device doesn't support RAW data-path APIs.\n");
5971 : 0 : return TEST_SKIPPED;
5972 : : }
5973 : :
5974 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5975 : : return TEST_SKIPPED;
5976 : :
5977 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5978 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5979 : : return TEST_SKIPPED;
5980 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5981 : : printf("Device doesn't support digest encrypted.\n");
5982 : 0 : return TEST_SKIPPED;
5983 : : }
5984 : : }
5985 : :
5986 : : /* Create KASUMI session */
5987 : 0 : retval = create_wireless_algo_auth_cipher_session(
5988 : 0 : ts_params->valid_devs[0],
5989 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5990 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5991 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5992 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5993 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5994 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5995 : : tdata->key.data, tdata->key.len,
5996 : 0 : tdata->key.data, tdata->key.len,
5997 : 0 : 0, tdata->digest.len,
5998 : 0 : tdata->cipher_iv.len);
5999 : :
6000 [ # # ]: 0 : if (retval != 0)
6001 : : return retval;
6002 : :
6003 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6004 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6005 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6006 : :
6007 : : /* clear mbuf payload */
6008 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6009 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6010 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6011 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6012 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6013 : :
6014 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6015 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6016 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6017 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6018 : :
6019 [ # # ]: 0 : if (verify) {
6020 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6021 : : ciphertext_pad_len);
6022 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6023 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6024 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6025 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6026 : : ciphertext_len);
6027 : : } else {
6028 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6029 : : plaintext_pad_len);
6030 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6031 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6032 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6033 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6034 : : plaintext_len);
6035 : : }
6036 : :
6037 : : /* Create KASUMI operation */
6038 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6039 : 0 : tdata->digest.data, tdata->digest.len,
6040 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6041 : : NULL, 0,
6042 : 0 : (tdata->digest.offset_bytes == 0 ?
6043 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6044 : : : tdata->digest.offset_bytes),
6045 : 0 : tdata->validCipherLenInBits.len,
6046 : 0 : tdata->validCipherOffsetInBits.len,
6047 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6048 : : 0,
6049 : : op_mode, 0, verify);
6050 : :
6051 [ # # ]: 0 : if (retval < 0)
6052 : : return retval;
6053 : :
6054 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6055 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6056 : 0 : tdata->cipher_iv.len);
6057 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6058 : : return retval;
6059 : : } else
6060 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6061 : : ut_params->op);
6062 : :
6063 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6064 : :
6065 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6066 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6067 : :
6068 : :
6069 [ # # ]: 0 : if (verify) {
6070 [ # # ]: 0 : if (ut_params->obuf)
6071 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6072 : : uint8_t *);
6073 : : else
6074 : : plaintext = ciphertext;
6075 : :
6076 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6077 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6078 : 0 : debug_hexdump(stdout, "plaintext expected:",
6079 : 0 : tdata->plaintext.data,
6080 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6081 : : } else {
6082 [ # # ]: 0 : if (ut_params->obuf)
6083 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6084 : : uint8_t *);
6085 : : else
6086 : : ciphertext = plaintext;
6087 : :
6088 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6089 : : ciphertext_len);
6090 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6091 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6092 : :
6093 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6094 : : digest_offset = plaintext_pad_len;
6095 : : else
6096 : : digest_offset = tdata->digest.offset_bytes;
6097 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6098 : : uint8_t *, digest_offset);
6099 : :
6100 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6101 : 0 : tdata->digest.len);
6102 : 0 : debug_hexdump(stdout, "digest expected:",
6103 : 0 : tdata->digest.data, tdata->digest.len);
6104 : : }
6105 : :
6106 : : /* Validate obuf */
6107 [ # # ]: 0 : if (verify) {
6108 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6109 : : plaintext,
6110 : : tdata->plaintext.data,
6111 : : tdata->plaintext.len >> 3,
6112 : : "KASUMI Plaintext data not as expected");
6113 : : } else {
6114 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6115 : : ciphertext,
6116 : : tdata->ciphertext.data,
6117 : : tdata->ciphertext.len >> 3,
6118 : : "KASUMI Ciphertext data not as expected");
6119 : :
6120 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6121 : : ut_params->digest,
6122 : : tdata->digest.data,
6123 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6124 : : "KASUMI Generated auth tag not as expected");
6125 : : }
6126 : : return 0;
6127 : : }
6128 : :
6129 : : static int
6130 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6131 : : uint8_t op_mode, uint8_t verify)
6132 : : {
6133 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6134 : : struct crypto_unittest_params *ut_params = &unittest_params;
6135 : :
6136 : : int retval;
6137 : :
6138 : : const uint8_t *plaintext = NULL;
6139 : : const uint8_t *ciphertext = NULL;
6140 : : const uint8_t *digest = NULL;
6141 : : unsigned int plaintext_pad_len;
6142 : : unsigned int plaintext_len;
6143 : : unsigned int ciphertext_pad_len;
6144 : : unsigned int ciphertext_len;
6145 : : uint8_t buffer[10000];
6146 : : uint8_t digest_buffer[10000];
6147 : :
6148 : : struct rte_cryptodev_info dev_info;
6149 : :
6150 : : /* Verify the capabilities */
6151 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6152 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6153 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6154 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6155 : : &cap_idx) == NULL)
6156 : : return TEST_SKIPPED;
6157 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6158 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6159 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6160 : : &cap_idx) == NULL)
6161 : : return TEST_SKIPPED;
6162 : :
6163 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6164 : : return TEST_SKIPPED;
6165 : :
6166 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6167 : :
6168 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6169 : :
6170 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6171 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6172 : : printf("Device doesn't support in-place scatter-gather "
6173 : : "in both input and output mbufs.\n");
6174 : 0 : return TEST_SKIPPED;
6175 : : }
6176 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6177 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6178 : : printf("Device doesn't support RAW data-path APIs.\n");
6179 : 0 : return TEST_SKIPPED;
6180 : : }
6181 : : } else {
6182 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6183 : : return TEST_SKIPPED;
6184 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6185 : : printf("Device doesn't support out-of-place scatter-gather "
6186 : : "in both input and output mbufs.\n");
6187 : 0 : return TEST_SKIPPED;
6188 : : }
6189 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6190 : : printf("Device doesn't support digest encrypted.\n");
6191 : 0 : return TEST_SKIPPED;
6192 : : }
6193 : : }
6194 : :
6195 : : /* Create KASUMI session */
6196 : 0 : retval = create_wireless_algo_auth_cipher_session(
6197 : 0 : ts_params->valid_devs[0],
6198 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6199 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6200 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6201 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6202 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6203 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6204 : : tdata->key.data, tdata->key.len,
6205 : 0 : tdata->key.data, tdata->key.len,
6206 : 0 : 0, tdata->digest.len,
6207 : 0 : tdata->cipher_iv.len);
6208 : :
6209 [ # # ]: 0 : if (retval != 0)
6210 : : return retval;
6211 : :
6212 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6213 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6214 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6215 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6216 : :
6217 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6218 : : plaintext_pad_len, 15, 0);
6219 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6220 : : "Failed to allocate input buffer in mempool");
6221 : :
6222 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6223 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6224 : : plaintext_pad_len, 15, 0);
6225 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6226 : : "Failed to allocate output buffer in mempool");
6227 : : }
6228 : :
6229 [ # # ]: 0 : if (verify) {
6230 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6231 : 0 : tdata->ciphertext.data);
6232 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6233 : : ciphertext_len, buffer);
6234 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6235 : : ciphertext_len);
6236 : : } else {
6237 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6238 : 0 : tdata->plaintext.data);
6239 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6240 : : plaintext_len, buffer);
6241 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6242 : : plaintext_len);
6243 : : }
6244 : : memset(buffer, 0, sizeof(buffer));
6245 : :
6246 : : /* Create KASUMI operation */
6247 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6248 : 0 : tdata->digest.data, tdata->digest.len,
6249 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6250 : : NULL, 0,
6251 : 0 : (tdata->digest.offset_bytes == 0 ?
6252 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6253 : : : tdata->digest.offset_bytes),
6254 : 0 : tdata->validCipherLenInBits.len,
6255 : 0 : tdata->validCipherOffsetInBits.len,
6256 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6257 : : 0,
6258 : : op_mode, 1, verify);
6259 : :
6260 [ # # ]: 0 : if (retval < 0)
6261 : : return retval;
6262 : :
6263 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6264 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6265 : 0 : tdata->cipher_iv.len);
6266 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6267 : : return retval;
6268 : : } else
6269 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6270 : : ut_params->op);
6271 : :
6272 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6273 : :
6274 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6275 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6276 : :
6277 [ # # ]: 0 : if (verify) {
6278 [ # # ]: 0 : if (ut_params->obuf)
6279 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6280 : : plaintext_len, buffer);
6281 : : else
6282 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6283 : : plaintext_len, buffer);
6284 : :
6285 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6286 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6287 : 0 : debug_hexdump(stdout, "plaintext expected:",
6288 : 0 : tdata->plaintext.data,
6289 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6290 : : } else {
6291 [ # # ]: 0 : if (ut_params->obuf)
6292 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6293 : : ciphertext_len, buffer);
6294 : : else
6295 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6296 : : ciphertext_len, buffer);
6297 : :
6298 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6299 : : ciphertext_len);
6300 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6301 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6302 : :
6303 [ # # ]: 0 : if (ut_params->obuf)
6304 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6305 : 0 : (tdata->digest.offset_bytes == 0 ?
6306 : : plaintext_pad_len : tdata->digest.offset_bytes),
6307 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6308 : : else
6309 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6310 : 0 : (tdata->digest.offset_bytes == 0 ?
6311 : : plaintext_pad_len : tdata->digest.offset_bytes),
6312 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6313 : :
6314 : 0 : debug_hexdump(stdout, "digest:", digest,
6315 : 0 : tdata->digest.len);
6316 : 0 : debug_hexdump(stdout, "digest expected:",
6317 : 0 : tdata->digest.data, tdata->digest.len);
6318 : : }
6319 : :
6320 : : /* Validate obuf */
6321 [ # # ]: 0 : if (verify) {
6322 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6323 : : plaintext,
6324 : : tdata->plaintext.data,
6325 : : tdata->plaintext.len >> 3,
6326 : : "KASUMI Plaintext data not as expected");
6327 : : } else {
6328 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6329 : : ciphertext,
6330 : : tdata->ciphertext.data,
6331 : : tdata->validDataLenInBits.len,
6332 : : "KASUMI Ciphertext data not as expected");
6333 : :
6334 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6335 : : digest,
6336 : : tdata->digest.data,
6337 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6338 : : "KASUMI Generated auth tag not as expected");
6339 : : }
6340 : : return 0;
6341 : : }
6342 : :
6343 : : static int
6344 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6345 : : {
6346 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6347 : : struct crypto_unittest_params *ut_params = &unittest_params;
6348 : :
6349 : : int retval;
6350 : :
6351 : : uint8_t *plaintext, *ciphertext;
6352 : : unsigned plaintext_pad_len;
6353 : : unsigned plaintext_len;
6354 : : struct rte_cryptodev_info dev_info;
6355 : :
6356 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6357 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6358 : :
6359 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6360 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6361 : : printf("Device doesn't support RAW data-path APIs.\n");
6362 : 0 : return TEST_SKIPPED;
6363 : : }
6364 : :
6365 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6366 : : return TEST_SKIPPED;
6367 : :
6368 : : /* Verify the capabilities */
6369 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6370 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6371 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6372 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6373 : : &cap_idx) == NULL)
6374 : : return TEST_SKIPPED;
6375 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6376 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6377 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6378 : : &cap_idx) == NULL)
6379 : : return TEST_SKIPPED;
6380 : :
6381 : : /* Create KASUMI session */
6382 : 0 : retval = create_wireless_algo_cipher_auth_session(
6383 : 0 : ts_params->valid_devs[0],
6384 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6385 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6386 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6387 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6388 : : tdata->key.data, tdata->key.len,
6389 : 0 : tdata->key.data, tdata->key.len,
6390 : 0 : 0, tdata->digest.len,
6391 : 0 : tdata->cipher_iv.len);
6392 [ # # ]: 0 : if (retval != 0)
6393 : : return retval;
6394 : :
6395 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6396 : :
6397 : : /* clear mbuf payload */
6398 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6399 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6400 : :
6401 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6402 : : /* Append data which is padded to a multiple of */
6403 : : /* the algorithms block size */
6404 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6405 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6406 : : plaintext_pad_len);
6407 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6408 : :
6409 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6410 : :
6411 : : /* Create KASUMI operation */
6412 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6413 : 0 : tdata->digest.len, NULL, 0,
6414 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6415 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6416 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6417 : 0 : tdata->validCipherOffsetInBits.len,
6418 : 0 : tdata->validAuthLenInBits.len,
6419 : : 0
6420 : : );
6421 [ # # ]: 0 : if (retval < 0)
6422 : : return retval;
6423 : :
6424 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6425 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6426 : 0 : tdata->cipher_iv.len);
6427 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6428 : : return retval;
6429 : : } else
6430 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6431 : : ut_params->op);
6432 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6433 : :
6434 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6435 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6436 : : else
6437 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6438 : :
6439 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6440 : : tdata->validCipherOffsetInBits.len >> 3);
6441 : :
6442 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6443 : : uint8_t *,
6444 : : plaintext_pad_len);
6445 : :
6446 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6447 : : (tdata->validCipherOffsetInBits.len >> 3);
6448 : : /* Validate obuf */
6449 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6450 : : ciphertext,
6451 : : reference_ciphertext,
6452 : : tdata->validCipherLenInBits.len,
6453 : : "KASUMI Ciphertext data not as expected");
6454 : :
6455 : : /* Validate obuf */
6456 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6457 : : ut_params->digest,
6458 : : tdata->digest.data,
6459 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6460 : : "KASUMI Generated auth tag not as expected");
6461 : : return 0;
6462 : : }
6463 : :
6464 : : static int
6465 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6466 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6467 : : const uint16_t key_size, const uint16_t iv_size)
6468 : : {
6469 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6470 : : const struct rte_cryptodev_symmetric_capability *cap;
6471 : :
6472 : : /* Check if device supports the algorithm */
6473 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6474 : 0 : cap_idx.algo.cipher = cipher_algo;
6475 : :
6476 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6477 : : &cap_idx);
6478 : :
6479 [ # # ]: 0 : if (cap == NULL)
6480 : : return -1;
6481 : :
6482 : : /* Check if device supports key size and IV size */
6483 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6484 : : iv_size) < 0) {
6485 : 0 : return -1;
6486 : : }
6487 : :
6488 : : return 0;
6489 : : }
6490 : :
6491 : : static int
6492 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6493 : : const enum rte_crypto_auth_algorithm auth_algo,
6494 : : const uint16_t key_size, const uint16_t iv_size,
6495 : : const uint16_t tag_size)
6496 : : {
6497 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6498 : : const struct rte_cryptodev_symmetric_capability *cap;
6499 : :
6500 : : /* Check if device supports the algorithm */
6501 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6502 : 0 : cap_idx.algo.auth = auth_algo;
6503 : :
6504 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6505 : : &cap_idx);
6506 : :
6507 [ # # ]: 0 : if (cap == NULL)
6508 : : return -1;
6509 : :
6510 : : /* Check if device supports key size and IV size */
6511 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6512 : : tag_size, iv_size) < 0) {
6513 : 0 : return -1;
6514 : : }
6515 : :
6516 : : return 0;
6517 : : }
6518 : :
6519 : : static int
6520 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6521 : : enum rte_crypto_cipher_operation direction)
6522 : : {
6523 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6524 : : struct crypto_unittest_params *ut_params = &unittest_params;
6525 : :
6526 : : int retval;
6527 : : uint8_t *plaintext = NULL;
6528 : : uint8_t *ciphertext = NULL;
6529 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6530 : : unsigned int plaintext_len = 0;
6531 : : unsigned int ciphertext_len = 0;
6532 : : struct rte_cryptodev_info dev_info;
6533 : :
6534 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6535 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6536 : :
6537 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6538 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6539 : : printf("Device doesn't support RAW data-path APIs.\n");
6540 : 0 : return TEST_SKIPPED;
6541 : : }
6542 : :
6543 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6544 : : return TEST_SKIPPED;
6545 : :
6546 : : /* Check if device supports ZUC EEA3 */
6547 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6548 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6549 : : return TEST_SKIPPED;
6550 : :
6551 : : /* Create ZUC session */
6552 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6553 : : direction,
6554 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6555 : 0 : tdata->key.data, tdata->key.len,
6556 : 0 : tdata->cipher_iv.len);
6557 [ # # ]: 0 : if (retval != 0)
6558 : : return retval;
6559 : :
6560 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6561 : :
6562 : : /* Clear mbuf payload */
6563 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6564 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6565 : :
6566 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6567 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6568 : : /* Append data which is padded to a multiple */
6569 : : /* of the algorithms block size */
6570 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6571 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6572 : : plaintext_pad_len);
6573 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6574 : :
6575 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6576 : : } else {
6577 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6578 : : /* Append data which is padded to a multiple */
6579 : : /* of the algorithms block size */
6580 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6581 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6582 : : ciphertext_pad_len);
6583 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6584 : :
6585 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6586 : : }
6587 : :
6588 : : /* Create ZUC operation */
6589 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6590 : 0 : tdata->cipher_iv.len,
6591 : 0 : tdata->plaintext.len,
6592 : 0 : tdata->validCipherOffsetInBits.len);
6593 [ # # ]: 0 : if (retval < 0)
6594 : : return retval;
6595 : :
6596 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6597 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6598 : 0 : tdata->cipher_iv.len);
6599 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6600 : : return retval;
6601 : : } else
6602 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6603 : : ut_params->op);
6604 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6605 : :
6606 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6607 : :
6608 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6609 [ # # ]: 0 : if (ut_params->obuf)
6610 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6611 : : else
6612 : : ciphertext = plaintext;
6613 : :
6614 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6615 : :
6616 : : /* Validate obuf */
6617 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6618 : : ciphertext,
6619 : : tdata->ciphertext.data,
6620 : : tdata->validCipherLenInBits.len,
6621 : : "ZUC Ciphertext data not as expected");
6622 : : } else {
6623 [ # # ]: 0 : if (ut_params->obuf)
6624 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6625 : : else
6626 : : plaintext = ciphertext;
6627 : :
6628 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6629 : :
6630 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6631 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6632 : :
6633 : : /* Validate obuf */
6634 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6635 : : plaintext,
6636 : : reference_plaintext,
6637 : : tdata->validCipherLenInBits.len,
6638 : : "ZUC Plaintext data not as expected");
6639 : : }
6640 : :
6641 : : return 0;
6642 : : }
6643 : :
6644 : : static int
6645 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6646 : : enum rte_crypto_cipher_operation direction)
6647 : : {
6648 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6649 : : struct crypto_unittest_params *ut_params = &unittest_params;
6650 : :
6651 : : int retval;
6652 : :
6653 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6654 : : unsigned int plaintext_len = 0;
6655 : : unsigned int ciphertext_len = 0;
6656 : : const uint8_t *ciphertext, *plaintext;
6657 : : uint8_t buffer[2048];
6658 : : struct rte_cryptodev_info dev_info;
6659 : :
6660 : : /* Check if device supports ZUC EEA3 */
6661 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6662 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6663 : : return TEST_SKIPPED;
6664 : :
6665 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6666 : : return TEST_SKIPPED;
6667 : :
6668 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6669 : :
6670 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6671 : :
6672 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6673 : : printf("Device doesn't support in-place scatter-gather. "
6674 : : "Test Skipped.\n");
6675 : 0 : return TEST_SKIPPED;
6676 : : }
6677 : :
6678 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6679 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6680 : : printf("Device doesn't support RAW data-path APIs.\n");
6681 : 0 : return TEST_SKIPPED;
6682 : : }
6683 : :
6684 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6685 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6686 : :
6687 : : /* Append data which is padded to a multiple */
6688 : : /* of the algorithms block size */
6689 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6690 : :
6691 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6692 : : plaintext_pad_len, 10, 0);
6693 : :
6694 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6695 : 0 : tdata->plaintext.data);
6696 : : } else {
6697 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6698 : :
6699 : : /* Append data which is padded to a multiple */
6700 : : /* of the algorithms block size */
6701 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6702 : :
6703 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6704 : : ciphertext_pad_len, 10, 0);
6705 : :
6706 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6707 : 0 : tdata->ciphertext.data);
6708 : :
6709 : : }
6710 : :
6711 : : /* Create ZUC session */
6712 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6713 : : direction,
6714 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6715 : 0 : tdata->key.data, tdata->key.len,
6716 : 0 : tdata->cipher_iv.len);
6717 [ # # ]: 0 : if (retval < 0)
6718 : : return retval;
6719 : :
6720 : : /* Clear mbuf payload */
6721 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6722 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6723 : : else
6724 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6725 : :
6726 : : /* Create ZUC operation */
6727 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6728 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6729 : 0 : tdata->validCipherOffsetInBits.len);
6730 [ # # ]: 0 : if (retval < 0)
6731 : : return retval;
6732 : :
6733 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6734 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6735 : 0 : tdata->cipher_iv.len);
6736 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6737 : : return retval;
6738 : : } else
6739 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6740 : : ut_params->op);
6741 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6742 : :
6743 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6744 : :
6745 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6746 [ # # ]: 0 : if (ut_params->obuf)
6747 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6748 : : 0, plaintext_len, buffer);
6749 : : else
6750 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6751 : : 0, plaintext_len, buffer);
6752 : :
6753 : : /* Validate obuf */
6754 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6755 : :
6756 : : /* Validate obuf */
6757 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6758 : : ciphertext,
6759 : : tdata->ciphertext.data,
6760 : : tdata->validCipherLenInBits.len,
6761 : : "ZUC Ciphertext data not as expected");
6762 : : } else {
6763 [ # # ]: 0 : if (ut_params->obuf)
6764 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6765 : : 0, ciphertext_len, buffer);
6766 : : else
6767 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6768 : : 0, ciphertext_len, buffer);
6769 : :
6770 : : /* Validate obuf */
6771 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6772 : :
6773 : : /* Validate obuf */
6774 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6775 : : plaintext,
6776 : : tdata->plaintext.data,
6777 : : tdata->validCipherLenInBits.len,
6778 : : "ZUC Plaintext data not as expected");
6779 : : }
6780 : :
6781 : : return 0;
6782 : : }
6783 : :
6784 : : static int
6785 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6786 : : enum rte_crypto_auth_operation auth_op)
6787 : : {
6788 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6789 : : struct crypto_unittest_params *ut_params = &unittest_params;
6790 : :
6791 : : int retval;
6792 : : unsigned plaintext_pad_len;
6793 : : unsigned plaintext_len;
6794 : : uint8_t *plaintext;
6795 : :
6796 : : struct rte_cryptodev_info dev_info;
6797 : :
6798 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6799 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6800 : :
6801 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6802 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6803 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6804 : 0 : return TEST_SKIPPED;
6805 : : }
6806 : :
6807 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6808 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6809 : : printf("Device doesn't support RAW data-path APIs.\n");
6810 : 0 : return TEST_SKIPPED;
6811 : : }
6812 : :
6813 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6814 : : return TEST_SKIPPED;
6815 : :
6816 : : /* Check if device supports ZUC EIA3 */
6817 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6818 : 0 : tdata->key.len, tdata->auth_iv.len,
6819 : 0 : tdata->digest.len) < 0)
6820 : : return TEST_SKIPPED;
6821 : :
6822 : : /* Create ZUC session */
6823 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6824 : 0 : tdata->key.data, tdata->key.len,
6825 : 0 : tdata->auth_iv.len, tdata->digest.len,
6826 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6827 [ # # ]: 0 : if (retval != 0)
6828 : : return retval;
6829 : :
6830 : : /* alloc mbuf and set payload */
6831 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6832 : :
6833 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6834 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6835 : :
6836 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6837 : : /* Append data which is padded to a multiple of */
6838 : : /* the algorithms block size */
6839 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6840 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6841 : : plaintext_pad_len);
6842 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6843 : :
6844 : : /* Create ZUC operation */
6845 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6846 : 0 : tdata->digest.len,
6847 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6848 : : plaintext_pad_len,
6849 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6850 [ # # ]: 0 : if (retval < 0)
6851 : : return retval;
6852 : :
6853 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6854 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6855 : : 0);
6856 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6857 : : return retval;
6858 : : } else
6859 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6860 : : ut_params->op);
6861 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6862 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6863 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6864 : : uint8_t *,
6865 : : plaintext_pad_len);
6866 : :
6867 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6868 : : /* Validate obuf */
6869 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6870 : : ut_params->digest,
6871 : : tdata->digest.data,
6872 : : tdata->digest.len,
6873 : : "ZUC Generated auth tag not as expected");
6874 : : return 0;
6875 : : }
6876 : :
6877 : : /* Validate obuf */
6878 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6879 : : return 0;
6880 : : else
6881 : 0 : return -1;
6882 : :
6883 : : return 0;
6884 : : }
6885 : :
6886 : : static int
6887 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6888 : : uint8_t op_mode, uint8_t verify)
6889 : : {
6890 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6891 : : struct crypto_unittest_params *ut_params = &unittest_params;
6892 : :
6893 : : int retval;
6894 : :
6895 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6896 : : unsigned int plaintext_pad_len;
6897 : : unsigned int plaintext_len;
6898 : : unsigned int ciphertext_pad_len;
6899 : : unsigned int ciphertext_len;
6900 : : unsigned int digest_offset;
6901 : :
6902 : : struct rte_cryptodev_info dev_info;
6903 : :
6904 : : /* Check if device supports ZUC EEA3 */
6905 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6906 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6907 : : return TEST_SKIPPED;
6908 : :
6909 : : /* Check if device supports ZUC EIA3 */
6910 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6911 : 0 : tdata->key.len, tdata->auth_iv.len,
6912 : 0 : tdata->digest.len) < 0)
6913 : : return TEST_SKIPPED;
6914 : :
6915 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6916 : : return TEST_SKIPPED;
6917 : :
6918 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6919 : :
6920 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6921 : :
6922 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6923 : : printf("Device doesn't support digest encrypted.\n");
6924 : 0 : return TEST_SKIPPED;
6925 : : }
6926 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6927 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6928 : : printf("Device doesn't support in-place scatter-gather "
6929 : : "in both input and output mbufs.\n");
6930 : 0 : return TEST_SKIPPED;
6931 : : }
6932 : :
6933 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6934 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6935 : : printf("Device doesn't support RAW data-path APIs.\n");
6936 : 0 : return TEST_SKIPPED;
6937 : : }
6938 : : } else {
6939 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6940 : : return TEST_SKIPPED;
6941 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6942 : : printf("Device doesn't support out-of-place scatter-gather "
6943 : : "in both input and output mbufs.\n");
6944 : 0 : return TEST_SKIPPED;
6945 : : }
6946 : : }
6947 : :
6948 : : /* Create ZUC session */
6949 : 0 : retval = create_wireless_algo_auth_cipher_session(
6950 : 0 : ts_params->valid_devs[0],
6951 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6952 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6953 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6954 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6955 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6956 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6957 : : tdata->key.data, tdata->key.len,
6958 : 0 : tdata->key.data, tdata->key.len,
6959 : 0 : tdata->auth_iv.len, tdata->digest.len,
6960 : 0 : tdata->cipher_iv.len);
6961 : :
6962 [ # # ]: 0 : if (retval != 0)
6963 : : return retval;
6964 : :
6965 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6966 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6967 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6968 : :
6969 : : /* clear mbuf payload */
6970 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6971 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6972 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6973 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6974 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6975 : :
6976 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6977 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6978 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6979 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6980 : :
6981 [ # # ]: 0 : if (verify) {
6982 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6983 : : ciphertext_pad_len);
6984 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6985 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6986 : : ciphertext_len);
6987 : : } else {
6988 : : /* make sure enough space to cover partial digest verify case */
6989 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6990 : : ciphertext_pad_len);
6991 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6992 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6993 : : plaintext_len);
6994 : : }
6995 : :
6996 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6997 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6998 : :
6999 : : /* Create ZUC operation */
7000 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7001 : 0 : tdata->digest.data, tdata->digest.len,
7002 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7003 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7004 : 0 : (tdata->digest.offset_bytes == 0 ?
7005 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7006 : : : tdata->digest.offset_bytes),
7007 : 0 : tdata->validCipherLenInBits.len,
7008 : 0 : tdata->validCipherOffsetInBits.len,
7009 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7010 : : 0,
7011 : : op_mode, 0, verify);
7012 : :
7013 [ # # ]: 0 : if (retval < 0)
7014 : : return retval;
7015 : :
7016 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7017 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7018 : 0 : tdata->cipher_iv.len);
7019 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7020 : : return retval;
7021 : : } else
7022 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7023 : : ut_params->op);
7024 : :
7025 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7026 : :
7027 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7028 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7029 : :
7030 : :
7031 [ # # ]: 0 : if (verify) {
7032 [ # # ]: 0 : if (ut_params->obuf)
7033 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7034 : : uint8_t *);
7035 : : else
7036 : : plaintext = ciphertext;
7037 : :
7038 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7039 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7040 : 0 : debug_hexdump(stdout, "plaintext expected:",
7041 : 0 : tdata->plaintext.data,
7042 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7043 : : } else {
7044 [ # # ]: 0 : if (ut_params->obuf)
7045 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7046 : : uint8_t *);
7047 : : else
7048 : : ciphertext = plaintext;
7049 : :
7050 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7051 : : ciphertext_len);
7052 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7053 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7054 : :
7055 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
7056 : : digest_offset = plaintext_pad_len;
7057 : : else
7058 : : digest_offset = tdata->digest.offset_bytes;
7059 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
7060 : : uint8_t *, digest_offset);
7061 : :
7062 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
7063 : 0 : tdata->digest.len);
7064 : 0 : debug_hexdump(stdout, "digest expected:",
7065 : 0 : tdata->digest.data, tdata->digest.len);
7066 : : }
7067 : :
7068 : : /* Validate obuf */
7069 [ # # ]: 0 : if (verify) {
7070 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7071 : : plaintext,
7072 : : tdata->plaintext.data,
7073 : : tdata->plaintext.len >> 3,
7074 : : "ZUC Plaintext data not as expected");
7075 : : } else {
7076 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7077 : : ciphertext,
7078 : : tdata->ciphertext.data,
7079 : : tdata->ciphertext.len >> 3,
7080 : : "ZUC Ciphertext data not as expected");
7081 : :
7082 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7083 : : ut_params->digest,
7084 : : tdata->digest.data,
7085 : : tdata->digest.len,
7086 : : "ZUC Generated auth tag not as expected");
7087 : : }
7088 : : return 0;
7089 : : }
7090 : :
7091 : : static int
7092 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
7093 : : uint8_t op_mode, uint8_t verify)
7094 : : {
7095 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7096 : : struct crypto_unittest_params *ut_params = &unittest_params;
7097 : :
7098 : : int retval;
7099 : :
7100 : : const uint8_t *plaintext = NULL;
7101 : : const uint8_t *ciphertext = NULL;
7102 : : const uint8_t *digest = NULL;
7103 : : unsigned int plaintext_pad_len;
7104 : : unsigned int plaintext_len;
7105 : : unsigned int ciphertext_pad_len;
7106 : : unsigned int ciphertext_len;
7107 : : uint8_t buffer[10000];
7108 : : uint8_t digest_buffer[10000];
7109 : :
7110 : : struct rte_cryptodev_info dev_info;
7111 : :
7112 : : /* Check if device supports ZUC EEA3 */
7113 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
7114 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
7115 : : return TEST_SKIPPED;
7116 : :
7117 : : /* Check if device supports ZUC EIA3 */
7118 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
7119 : 0 : tdata->key.len, tdata->auth_iv.len,
7120 : 0 : tdata->digest.len) < 0)
7121 : : return TEST_SKIPPED;
7122 : :
7123 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7124 : : return TEST_SKIPPED;
7125 : :
7126 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7127 : :
7128 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7129 : :
7130 [ # # ]: 0 : if (op_mode == IN_PLACE) {
7131 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7132 : : printf("Device doesn't support in-place scatter-gather "
7133 : : "in both input and output mbufs.\n");
7134 : 0 : return TEST_SKIPPED;
7135 : : }
7136 : :
7137 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7138 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7139 : : printf("Device doesn't support RAW data-path APIs.\n");
7140 : 0 : return TEST_SKIPPED;
7141 : : }
7142 : : } else {
7143 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7144 : : return TEST_SKIPPED;
7145 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7146 : : printf("Device doesn't support out-of-place scatter-gather "
7147 : : "in both input and output mbufs.\n");
7148 : 0 : return TEST_SKIPPED;
7149 : : }
7150 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7151 : : printf("Device doesn't support digest encrypted.\n");
7152 : 0 : return TEST_SKIPPED;
7153 : : }
7154 : : }
7155 : :
7156 : : /* Create ZUC session */
7157 : 0 : retval = create_wireless_algo_auth_cipher_session(
7158 : 0 : ts_params->valid_devs[0],
7159 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7160 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7161 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7162 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
7163 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
7164 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
7165 : : tdata->key.data, tdata->key.len,
7166 : 0 : tdata->key.data, tdata->key.len,
7167 : 0 : tdata->auth_iv.len, tdata->digest.len,
7168 : 0 : tdata->cipher_iv.len);
7169 : :
7170 [ # # ]: 0 : if (retval != 0)
7171 : : return retval;
7172 : :
7173 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7174 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
7175 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7176 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7177 : :
7178 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7179 : : plaintext_pad_len, 15, 0);
7180 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7181 : : "Failed to allocate input buffer in mempool");
7182 : :
7183 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
7184 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7185 : : plaintext_pad_len, 15, 0);
7186 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
7187 : : "Failed to allocate output buffer in mempool");
7188 : : }
7189 : :
7190 [ # # ]: 0 : if (verify) {
7191 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7192 : 0 : tdata->ciphertext.data);
7193 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7194 : : ciphertext_len, buffer);
7195 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7196 : : ciphertext_len);
7197 : : } else {
7198 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7199 : 0 : tdata->plaintext.data);
7200 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7201 : : plaintext_len, buffer);
7202 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7203 : : plaintext_len);
7204 : : }
7205 : : memset(buffer, 0, sizeof(buffer));
7206 : :
7207 : : /* Create ZUC operation */
7208 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7209 : 0 : tdata->digest.data, tdata->digest.len,
7210 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7211 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7212 : 0 : (tdata->digest.offset_bytes == 0 ?
7213 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7214 : : : tdata->digest.offset_bytes),
7215 : 0 : tdata->validCipherLenInBits.len,
7216 : 0 : tdata->validCipherOffsetInBits.len,
7217 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7218 : : 0,
7219 : : op_mode, 1, verify);
7220 : :
7221 [ # # ]: 0 : if (retval < 0)
7222 : : return retval;
7223 : :
7224 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7225 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7226 : 0 : tdata->cipher_iv.len);
7227 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7228 : : return retval;
7229 : : } else
7230 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7231 : : ut_params->op);
7232 : :
7233 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7234 : :
7235 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7236 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7237 : :
7238 [ # # ]: 0 : if (verify) {
7239 [ # # ]: 0 : if (ut_params->obuf)
7240 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7241 : : plaintext_len, buffer);
7242 : : else
7243 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7244 : : plaintext_len, buffer);
7245 : :
7246 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7247 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7248 : 0 : debug_hexdump(stdout, "plaintext expected:",
7249 : 0 : tdata->plaintext.data,
7250 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7251 : : } else {
7252 [ # # ]: 0 : if (ut_params->obuf)
7253 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7254 : : ciphertext_len, buffer);
7255 : : else
7256 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7257 : : ciphertext_len, buffer);
7258 : :
7259 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7260 : : ciphertext_len);
7261 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7262 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7263 : :
7264 [ # # ]: 0 : if (ut_params->obuf)
7265 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
7266 : 0 : (tdata->digest.offset_bytes == 0 ?
7267 : : plaintext_pad_len : tdata->digest.offset_bytes),
7268 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7269 : : else
7270 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
7271 : 0 : (tdata->digest.offset_bytes == 0 ?
7272 : : plaintext_pad_len : tdata->digest.offset_bytes),
7273 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7274 : :
7275 : 0 : debug_hexdump(stdout, "digest:", digest,
7276 : 0 : tdata->digest.len);
7277 : 0 : debug_hexdump(stdout, "digest expected:",
7278 : 0 : tdata->digest.data, tdata->digest.len);
7279 : : }
7280 : :
7281 : : /* Validate obuf */
7282 [ # # ]: 0 : if (verify) {
7283 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7284 : : plaintext,
7285 : : tdata->plaintext.data,
7286 : : tdata->plaintext.len >> 3,
7287 : : "ZUC Plaintext data not as expected");
7288 : : } else {
7289 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7290 : : ciphertext,
7291 : : tdata->ciphertext.data,
7292 : : tdata->validDataLenInBits.len,
7293 : : "ZUC Ciphertext data not as expected");
7294 : :
7295 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7296 : : digest,
7297 : : tdata->digest.data,
7298 : : tdata->digest.len,
7299 : : "ZUC Generated auth tag not as expected");
7300 : : }
7301 : : return 0;
7302 : : }
7303 : :
7304 : : static int
7305 : 0 : test_kasumi_encryption_test_case_1(void)
7306 : : {
7307 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
7308 : : }
7309 : :
7310 : : static int
7311 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
7312 : : {
7313 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7314 : : }
7315 : :
7316 : : static int
7317 : 0 : test_kasumi_encryption_test_case_1_oop(void)
7318 : : {
7319 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
7320 : : }
7321 : :
7322 : : static int
7323 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
7324 : : {
7325 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7326 : : }
7327 : :
7328 : : static int
7329 : 0 : test_kasumi_encryption_test_case_2(void)
7330 : : {
7331 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
7332 : : }
7333 : :
7334 : : static int
7335 : 0 : test_kasumi_encryption_test_case_3(void)
7336 : : {
7337 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
7338 : : }
7339 : :
7340 : : static int
7341 : 0 : test_kasumi_encryption_test_case_4(void)
7342 : : {
7343 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
7344 : : }
7345 : :
7346 : : static int
7347 : 0 : test_kasumi_encryption_test_case_5(void)
7348 : : {
7349 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
7350 : : }
7351 : :
7352 : : static int
7353 : 0 : test_kasumi_decryption_test_case_1(void)
7354 : : {
7355 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
7356 : : }
7357 : :
7358 : : static int
7359 : 0 : test_kasumi_decryption_test_case_1_oop(void)
7360 : : {
7361 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
7362 : : }
7363 : :
7364 : : static int
7365 : 0 : test_kasumi_decryption_test_case_2(void)
7366 : : {
7367 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
7368 : : }
7369 : :
7370 : : static int
7371 : 0 : test_kasumi_decryption_test_case_3(void)
7372 : : {
7373 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7374 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7375 : : return TEST_SKIPPED;
7376 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7377 : : }
7378 : :
7379 : : static int
7380 : 0 : test_kasumi_decryption_test_case_4(void)
7381 : : {
7382 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7383 : : }
7384 : :
7385 : : static int
7386 : 0 : test_kasumi_decryption_test_case_5(void)
7387 : : {
7388 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7389 : : }
7390 : : static int
7391 : 0 : test_snow3g_encryption_test_case_1(void)
7392 : : {
7393 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7394 : : }
7395 : :
7396 : : static int
7397 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7398 : : {
7399 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7400 : : }
7401 : :
7402 : : static int
7403 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7404 : : {
7405 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7406 : : }
7407 : :
7408 : : static int
7409 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7410 : : {
7411 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7412 : : }
7413 : :
7414 : : static int
7415 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7416 : : {
7417 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7418 : : }
7419 : :
7420 : : static int
7421 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7422 : : {
7423 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7424 : : }
7425 : :
7426 : : static int
7427 : 0 : test_snow3g_encryption_test_case_2(void)
7428 : : {
7429 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7430 : : }
7431 : :
7432 : : static int
7433 : 0 : test_snow3g_encryption_test_case_3(void)
7434 : : {
7435 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7436 : : }
7437 : :
7438 : : static int
7439 : 0 : test_snow3g_encryption_test_case_4(void)
7440 : : {
7441 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7442 : : }
7443 : :
7444 : : static int
7445 : 0 : test_snow3g_encryption_test_case_5(void)
7446 : : {
7447 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7448 : : }
7449 : :
7450 : : static int
7451 : 0 : test_snow3g_decryption_test_case_1(void)
7452 : : {
7453 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7454 : : }
7455 : :
7456 : : static int
7457 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7458 : : {
7459 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7460 : : }
7461 : :
7462 : : static int
7463 : 0 : test_snow3g_decryption_test_case_2(void)
7464 : : {
7465 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7466 : : }
7467 : :
7468 : : static int
7469 : 0 : test_snow3g_decryption_test_case_3(void)
7470 : : {
7471 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7472 : : }
7473 : :
7474 : : static int
7475 : 0 : test_snow3g_decryption_test_case_4(void)
7476 : : {
7477 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7478 : : }
7479 : :
7480 : : static int
7481 : 0 : test_snow3g_decryption_test_case_5(void)
7482 : : {
7483 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7484 : : }
7485 : :
7486 : : /*
7487 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7488 : : * Pattern digest from snow3g_test_data must be allocated as
7489 : : * 4 last bytes in plaintext.
7490 : : */
7491 : : static void
7492 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7493 : : struct snow3g_hash_test_data *output)
7494 : : {
7495 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7496 : 0 : output->key.len = pattern->key.len;
7497 : :
7498 : 0 : memcpy(output->key.data,
7499 : 0 : pattern->key.data, pattern->key.len);
7500 : :
7501 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7502 : :
7503 : 0 : memcpy(output->auth_iv.data,
7504 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7505 : :
7506 : 0 : output->plaintext.len = pattern->plaintext.len;
7507 : :
7508 : 0 : memcpy(output->plaintext.data,
7509 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7510 : :
7511 : 0 : output->digest.len = pattern->digest.len;
7512 : :
7513 : 0 : memcpy(output->digest.data,
7514 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7515 : : pattern->digest.len);
7516 : :
7517 : 0 : output->validAuthLenInBits.len =
7518 : 0 : pattern->validAuthLenInBits.len;
7519 : : }
7520 : 0 : }
7521 : :
7522 : : /*
7523 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7524 : : */
7525 : : static int
7526 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7527 : : {
7528 : : int ret;
7529 : : struct snow3g_hash_test_data snow3g_hash_data;
7530 : : struct rte_cryptodev_info dev_info;
7531 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7532 : :
7533 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7534 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7535 : :
7536 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7537 : : printf("Device doesn't support encrypted digest operations.\n");
7538 : 0 : return TEST_SKIPPED;
7539 : : }
7540 : :
7541 : : /*
7542 : : * Function prepare data for hash verification test case.
7543 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7544 : : */
7545 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7546 : :
7547 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7548 [ # # ]: 0 : if (ret != 0)
7549 : : return ret;
7550 : :
7551 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7552 : : }
7553 : :
7554 : : static int
7555 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7556 : : {
7557 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7558 : : }
7559 : :
7560 : : static int
7561 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7562 : : {
7563 : 0 : return test_snow3g_auth_cipher(
7564 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7565 : : }
7566 : :
7567 : : static int
7568 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7569 : : {
7570 : 0 : return test_snow3g_auth_cipher(
7571 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7572 : : }
7573 : :
7574 : : static int
7575 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7576 : : {
7577 : 0 : return test_snow3g_auth_cipher(
7578 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7579 : : }
7580 : :
7581 : : static int
7582 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7583 : : {
7584 : 0 : return test_snow3g_auth_cipher(
7585 : : &snow3g_auth_cipher_partial_digest_encryption,
7586 : : IN_PLACE, 0);
7587 : : }
7588 : :
7589 : : static int
7590 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7591 : : {
7592 : 0 : return test_snow3g_auth_cipher(
7593 : : &snow3g_auth_cipher_partial_digest_encryption,
7594 : : OUT_OF_PLACE, 0);
7595 : : }
7596 : :
7597 : : static int
7598 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7599 : : {
7600 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7601 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7602 : : return TEST_SKIPPED;
7603 : 0 : return test_snow3g_auth_cipher_sgl(
7604 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7605 : : }
7606 : :
7607 : : static int
7608 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7609 : : {
7610 : 0 : return test_snow3g_auth_cipher_sgl(
7611 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7612 : : }
7613 : :
7614 : : static int
7615 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7616 : : {
7617 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7618 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7619 : : return TEST_SKIPPED;
7620 : 0 : return test_snow3g_auth_cipher_sgl(
7621 : : &snow3g_auth_cipher_partial_digest_encryption,
7622 : : IN_PLACE, 0);
7623 : : }
7624 : :
7625 : : static int
7626 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7627 : : {
7628 : 0 : return test_snow3g_auth_cipher_sgl(
7629 : : &snow3g_auth_cipher_partial_digest_encryption,
7630 : : OUT_OF_PLACE, 0);
7631 : : }
7632 : :
7633 : : static int
7634 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7635 : : {
7636 : 0 : return test_snow3g_auth_cipher(
7637 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7638 : : }
7639 : :
7640 : : static int
7641 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7642 : : {
7643 : 0 : return test_snow3g_auth_cipher(
7644 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7645 : : }
7646 : :
7647 : : static int
7648 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7649 : : {
7650 : 0 : return test_snow3g_auth_cipher_sgl(
7651 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7652 : : }
7653 : :
7654 : : static int
7655 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7656 : : {
7657 : 0 : return test_snow3g_auth_cipher_sgl(
7658 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7659 : : }
7660 : :
7661 : : static int
7662 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7663 : : {
7664 : 0 : return test_snow3g_auth_cipher(
7665 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7666 : : }
7667 : :
7668 : : static int
7669 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7670 : : {
7671 : 0 : return test_snow3g_auth_cipher(
7672 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7673 : : }
7674 : :
7675 : : static int
7676 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7677 : : {
7678 : 0 : return test_snow3g_auth_cipher(
7679 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7680 : : }
7681 : :
7682 : : static int
7683 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7684 : : {
7685 : 0 : return test_snow3g_auth_cipher(
7686 : : &snow3g_auth_cipher_partial_digest_encryption,
7687 : : IN_PLACE, 1);
7688 : : }
7689 : :
7690 : : static int
7691 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7692 : : {
7693 : 0 : return test_snow3g_auth_cipher(
7694 : : &snow3g_auth_cipher_partial_digest_encryption,
7695 : : OUT_OF_PLACE, 1);
7696 : : }
7697 : :
7698 : : static int
7699 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7700 : : {
7701 : 0 : return test_snow3g_auth_cipher_sgl(
7702 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7703 : : }
7704 : :
7705 : : static int
7706 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7707 : : {
7708 : 0 : return test_snow3g_auth_cipher_sgl(
7709 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7710 : : }
7711 : :
7712 : : static int
7713 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7714 : : {
7715 : 0 : return test_snow3g_auth_cipher_sgl(
7716 : : &snow3g_auth_cipher_partial_digest_encryption,
7717 : : IN_PLACE, 1);
7718 : : }
7719 : :
7720 : : static int
7721 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7722 : : {
7723 : 0 : return test_snow3g_auth_cipher_sgl(
7724 : : &snow3g_auth_cipher_partial_digest_encryption,
7725 : : OUT_OF_PLACE, 1);
7726 : : }
7727 : :
7728 : : static int
7729 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7730 : : {
7731 : 0 : return test_snow3g_auth_cipher(
7732 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7733 : : }
7734 : :
7735 : : static int
7736 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7737 : : {
7738 : 0 : return test_snow3g_auth_cipher(
7739 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7740 : : }
7741 : :
7742 : : static int
7743 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7744 : : {
7745 : 0 : return test_snow3g_auth_cipher_sgl(
7746 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7747 : : }
7748 : :
7749 : : static int
7750 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7751 : : {
7752 : 0 : return test_snow3g_auth_cipher_sgl(
7753 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7754 : : }
7755 : :
7756 : : static int
7757 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7758 : : {
7759 : 0 : return test_snow3g_auth_cipher(
7760 : : &snow3g_test_case_7, IN_PLACE, 0);
7761 : : }
7762 : :
7763 : : static int
7764 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7765 : : {
7766 : 0 : return test_kasumi_auth_cipher(
7767 : : &kasumi_test_case_3, IN_PLACE, 0);
7768 : : }
7769 : :
7770 : : static int
7771 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7772 : : {
7773 : 0 : return test_kasumi_auth_cipher(
7774 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7775 : : }
7776 : :
7777 : : static int
7778 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7779 : : {
7780 : 0 : return test_kasumi_auth_cipher(
7781 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7782 : : }
7783 : :
7784 : : static int
7785 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7786 : : {
7787 : 0 : return test_kasumi_auth_cipher_sgl(
7788 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7789 : : }
7790 : :
7791 : : static int
7792 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7793 : : {
7794 : 0 : return test_kasumi_auth_cipher_sgl(
7795 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7796 : : }
7797 : :
7798 : : static int
7799 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7800 : : {
7801 : 0 : return test_kasumi_auth_cipher(
7802 : : &kasumi_test_case_3, IN_PLACE, 1);
7803 : : }
7804 : :
7805 : : static int
7806 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7807 : : {
7808 : 0 : return test_kasumi_auth_cipher(
7809 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7810 : : }
7811 : :
7812 : : static int
7813 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7814 : : {
7815 : 0 : return test_kasumi_auth_cipher(
7816 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7817 : : }
7818 : :
7819 : : static int
7820 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7821 : : {
7822 : 0 : return test_kasumi_auth_cipher_sgl(
7823 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7824 : : }
7825 : :
7826 : : static int
7827 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7828 : : {
7829 : 0 : return test_kasumi_auth_cipher_sgl(
7830 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7831 : : }
7832 : :
7833 : : static int
7834 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7835 : : {
7836 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7837 : : }
7838 : :
7839 : : static int
7840 : 0 : test_zuc_encryption_test_case_1(void)
7841 : : {
7842 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7843 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7844 : : }
7845 : :
7846 : : static int
7847 : 0 : test_zuc_encryption_test_case_2(void)
7848 : : {
7849 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7850 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7851 : : }
7852 : :
7853 : : static int
7854 : 0 : test_zuc_encryption_test_case_3(void)
7855 : : {
7856 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7857 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7858 : : }
7859 : :
7860 : : static int
7861 : 0 : test_zuc_encryption_test_case_4(void)
7862 : : {
7863 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7864 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7865 : : }
7866 : :
7867 : : static int
7868 : 0 : test_zuc_encryption_test_case_5(void)
7869 : : {
7870 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7871 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7872 : : }
7873 : :
7874 : : static int
7875 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7876 : : {
7877 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7878 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7879 : : }
7880 : :
7881 : : static int
7882 : 0 : test_zuc_decryption_test_case_1(void)
7883 : : {
7884 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7885 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7886 : : }
7887 : :
7888 : : static int
7889 : 0 : test_zuc_decryption_test_case_2(void)
7890 : : {
7891 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7892 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7893 : : }
7894 : :
7895 : : static int
7896 : 0 : test_zuc_decryption_test_case_3(void)
7897 : : {
7898 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7899 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7900 : : }
7901 : :
7902 : : static int
7903 : 0 : test_zuc_decryption_test_case_4(void)
7904 : : {
7905 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7906 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7907 : : }
7908 : :
7909 : : static int
7910 : 0 : test_zuc_decryption_test_case_5(void)
7911 : : {
7912 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7913 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7914 : : }
7915 : :
7916 : : static int
7917 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7918 : : {
7919 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7920 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7921 : : }
7922 : :
7923 : : static int
7924 : 0 : test_zuc_hash_generate_test_case_1(void)
7925 : : {
7926 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7927 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7928 : : }
7929 : :
7930 : : static int
7931 : 0 : test_zuc_hash_generate_test_case_2(void)
7932 : : {
7933 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7934 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7935 : : }
7936 : :
7937 : : static int
7938 : 0 : test_zuc_hash_generate_test_case_3(void)
7939 : : {
7940 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7941 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7942 : : }
7943 : :
7944 : : static int
7945 : 0 : test_zuc_hash_generate_test_case_4(void)
7946 : : {
7947 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7948 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7949 : : }
7950 : :
7951 : : static int
7952 : 0 : test_zuc_hash_generate_test_case_5(void)
7953 : : {
7954 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7955 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7956 : : }
7957 : :
7958 : : static int
7959 : 0 : test_zuc_hash_generate_test_case_6(void)
7960 : : {
7961 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7962 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7963 : : }
7964 : :
7965 : : static int
7966 : 0 : test_zuc_hash_generate_test_case_7(void)
7967 : : {
7968 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7969 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7970 : : }
7971 : :
7972 : : static int
7973 : 0 : test_zuc_hash_generate_test_case_8(void)
7974 : : {
7975 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7976 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7977 : : }
7978 : :
7979 : : static int
7980 : 0 : test_zuc_hash_verify_test_case_1(void)
7981 : : {
7982 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7983 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7984 : : }
7985 : :
7986 : : static int
7987 : 0 : test_zuc_hash_verify_test_case_2(void)
7988 : : {
7989 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7990 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7991 : : }
7992 : :
7993 : : static int
7994 : 0 : test_zuc_hash_verify_test_case_3(void)
7995 : : {
7996 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7997 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7998 : : }
7999 : :
8000 : : static int
8001 : 0 : test_zuc_hash_verify_test_case_4(void)
8002 : : {
8003 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
8004 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8005 : : }
8006 : :
8007 : : static int
8008 : 0 : test_zuc_hash_verify_test_case_5(void)
8009 : : {
8010 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
8011 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8012 : : }
8013 : :
8014 : : static int
8015 : 0 : test_zuc_hash_verify_test_case_6(void)
8016 : : {
8017 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
8018 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8019 : : }
8020 : :
8021 : : static int
8022 : 0 : test_zuc_hash_verify_test_case_7(void)
8023 : : {
8024 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
8025 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8026 : : }
8027 : :
8028 : : static int
8029 : 0 : test_zuc_hash_verify_test_case_8(void)
8030 : : {
8031 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
8032 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8033 : : }
8034 : :
8035 : : static int
8036 : 0 : test_zuc_cipher_auth_test_case_1(void)
8037 : : {
8038 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
8039 : : }
8040 : :
8041 : : static int
8042 : 0 : test_zuc_cipher_auth_test_case_2(void)
8043 : : {
8044 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
8045 : : }
8046 : :
8047 : : static int
8048 : 0 : test_zuc_auth_cipher_test_case_1(void)
8049 : : {
8050 : 0 : return test_zuc_auth_cipher(
8051 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8052 : : }
8053 : :
8054 : : static int
8055 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
8056 : : {
8057 : 0 : return test_zuc_auth_cipher(
8058 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8059 : : }
8060 : :
8061 : : static int
8062 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
8063 : : {
8064 : 0 : return test_zuc_auth_cipher_sgl(
8065 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8066 : : }
8067 : :
8068 : : static int
8069 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
8070 : : {
8071 : 0 : return test_zuc_auth_cipher_sgl(
8072 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8073 : : }
8074 : :
8075 : : static int
8076 : 0 : test_zuc_auth_cipher_test_case_2(void)
8077 : : {
8078 : 0 : return test_zuc_auth_cipher(
8079 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
8080 : : }
8081 : :
8082 : : static int
8083 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
8084 : : {
8085 : 0 : return test_zuc_auth_cipher(
8086 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
8087 : : }
8088 : :
8089 : : static int
8090 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
8091 : : {
8092 : 0 : return test_zuc_auth_cipher(
8093 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8094 : : }
8095 : :
8096 : : static int
8097 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
8098 : : {
8099 : 0 : return test_zuc_auth_cipher(
8100 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8101 : : }
8102 : :
8103 : : static int
8104 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
8105 : : {
8106 : 0 : return test_zuc_auth_cipher_sgl(
8107 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8108 : : }
8109 : :
8110 : : static int
8111 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
8112 : : {
8113 : 0 : return test_zuc_auth_cipher_sgl(
8114 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8115 : : }
8116 : :
8117 : : static int
8118 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
8119 : : {
8120 : 0 : return test_zuc_auth_cipher(
8121 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
8122 : : }
8123 : :
8124 : : static int
8125 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
8126 : : {
8127 : 0 : return test_zuc_auth_cipher(
8128 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8129 : : }
8130 : :
8131 : : static int
8132 : 0 : test_zuc256_encryption_test_case_1(void)
8133 : : {
8134 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8135 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8136 : : }
8137 : :
8138 : : static int
8139 : 0 : test_zuc256_encryption_test_case_2(void)
8140 : : {
8141 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8142 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8143 : : }
8144 : :
8145 : : static int
8146 : 0 : test_zuc256_decryption_test_case_1(void)
8147 : : {
8148 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8149 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8150 : : }
8151 : :
8152 : : static int
8153 : 0 : test_zuc256_decryption_test_case_2(void)
8154 : : {
8155 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8156 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8157 : : }
8158 : :
8159 : : static int
8160 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
8161 : : {
8162 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8163 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8164 : : }
8165 : :
8166 : : static int
8167 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
8168 : : {
8169 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8170 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8171 : : }
8172 : :
8173 : : static int
8174 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
8175 : : {
8176 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8177 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8178 : : }
8179 : :
8180 : : static int
8181 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
8182 : : {
8183 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8184 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8185 : : }
8186 : :
8187 : : static int
8188 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
8189 : : {
8190 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8191 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8192 : : }
8193 : :
8194 : : static int
8195 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
8196 : : {
8197 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8198 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8199 : : }
8200 : :
8201 : : static int
8202 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
8203 : : {
8204 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8205 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8206 : : }
8207 : :
8208 : : static int
8209 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
8210 : : {
8211 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8212 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8213 : : }
8214 : :
8215 : : static int
8216 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
8217 : : {
8218 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8219 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8220 : : }
8221 : :
8222 : : static int
8223 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
8224 : : {
8225 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8226 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8227 : : }
8228 : :
8229 : : static int
8230 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8231 : : {
8232 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8233 : : }
8234 : :
8235 : : static int
8236 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8237 : : {
8238 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8239 : : }
8240 : :
8241 : : static int
8242 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8243 : : {
8244 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8245 : : }
8246 : :
8247 : : static int
8248 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8249 : : {
8250 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8251 : : }
8252 : :
8253 : : static int
8254 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8255 : : {
8256 : 0 : return test_zuc_auth_cipher(
8257 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8258 : : }
8259 : :
8260 : : static int
8261 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8262 : : {
8263 : 0 : return test_zuc_auth_cipher(
8264 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8265 : : }
8266 : :
8267 : : static int
8268 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8269 : : {
8270 : 0 : return test_zuc_auth_cipher(
8271 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8272 : : }
8273 : :
8274 : : static int
8275 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8276 : : {
8277 : 0 : return test_zuc_auth_cipher(
8278 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8279 : : }
8280 : :
8281 : : static int
8282 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8283 : : {
8284 : 0 : return test_zuc_auth_cipher(
8285 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8286 : : }
8287 : :
8288 : : static int
8289 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8290 : : {
8291 : 0 : return test_zuc_auth_cipher(
8292 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8293 : : }
8294 : :
8295 : : static int
8296 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8297 : : {
8298 : 0 : return test_zuc_auth_cipher(
8299 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8300 : : }
8301 : :
8302 : : static int
8303 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8304 : : {
8305 : 0 : return test_zuc_auth_cipher(
8306 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8307 : : }
8308 : :
8309 : : static int
8310 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8311 : : {
8312 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
8313 : :
8314 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8315 : :
8316 : : /* Check if device supports particular cipher algorithm */
8317 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8318 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
8319 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8320 : : return TEST_SKIPPED;
8321 : :
8322 : : /* Check if device supports particular hash algorithm */
8323 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8324 : 24 : cap_idx.algo.auth = tdata->auth_algo;
8325 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8326 : 12 : return TEST_SKIPPED;
8327 : :
8328 : : return 0;
8329 : : }
8330 : :
8331 : : static int
8332 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8333 : : uint8_t op_mode, uint8_t verify)
8334 : : {
8335 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8336 : : struct crypto_unittest_params *ut_params = &unittest_params;
8337 : :
8338 : : int retval;
8339 : :
8340 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
8341 : : unsigned int plaintext_pad_len;
8342 : : unsigned int plaintext_len;
8343 : : unsigned int ciphertext_pad_len;
8344 : : unsigned int ciphertext_len;
8345 : : unsigned int digest_offset;
8346 : :
8347 : : struct rte_cryptodev_info dev_info;
8348 : : struct rte_crypto_op *op;
8349 : :
8350 : : /* Check if device supports particular algorithms separately */
8351 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
8352 : : return TEST_SKIPPED;
8353 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8354 : : return TEST_SKIPPED;
8355 : :
8356 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8357 : : return TEST_SKIPPED;
8358 : :
8359 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8360 : :
8361 : 8 : uint64_t feat_flags = dev_info.feature_flags;
8362 : :
8363 [ - + ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING)) {
8364 : : printf("Device doesn't support operation chaining.\n");
8365 : 0 : return TEST_SKIPPED;
8366 : : }
8367 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8368 : : printf("Device doesn't support digest encrypted.\n");
8369 : 8 : return TEST_SKIPPED;
8370 : : }
8371 : :
8372 : : /* Create the session */
8373 [ # # ]: 0 : if (verify)
8374 : 0 : retval = create_wireless_algo_cipher_auth_session(
8375 : 0 : ts_params->valid_devs[0],
8376 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8377 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8378 : 0 : tdata->auth_algo,
8379 : 0 : tdata->cipher_algo,
8380 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8381 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8382 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8383 : 0 : tdata->cipher_iv.len);
8384 : : else
8385 : 0 : retval = create_wireless_algo_auth_cipher_session(
8386 : 0 : ts_params->valid_devs[0],
8387 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8388 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8389 : 0 : tdata->auth_algo,
8390 : 0 : tdata->cipher_algo,
8391 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8392 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8393 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8394 : 0 : tdata->cipher_iv.len);
8395 [ # # ]: 0 : if (retval != 0)
8396 : : return retval;
8397 : :
8398 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8399 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8400 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8401 : :
8402 : : /* clear mbuf payload */
8403 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8404 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8405 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8406 : :
8407 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8408 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8409 : : }
8410 : :
8411 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8412 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8413 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8414 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8415 : :
8416 [ # # ]: 0 : if (verify) {
8417 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8418 : : ciphertext_pad_len);
8419 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8420 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8421 : : ciphertext_len);
8422 : : } else {
8423 : : /* make sure enough space to cover partial digest verify case */
8424 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8425 : : ciphertext_pad_len);
8426 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8427 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8428 : : }
8429 : :
8430 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8431 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8432 : :
8433 : : /* Create the operation */
8434 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8435 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8436 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8437 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8438 : 0 : (tdata->digest_enc.offset == 0 ?
8439 : : plaintext_pad_len
8440 : : : tdata->digest_enc.offset),
8441 : 0 : tdata->validCipherLen.len_bits,
8442 : 0 : tdata->cipher.offset_bits,
8443 : 0 : tdata->validAuthLen.len_bits,
8444 [ # # ]: 0 : tdata->auth.offset_bits,
8445 : : op_mode, 0, verify);
8446 : :
8447 [ # # ]: 0 : if (retval < 0)
8448 : : return retval;
8449 : :
8450 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8451 : :
8452 : : /* Check if the op failed because the device doesn't */
8453 : : /* support this particular combination of algorithms */
8454 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8455 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8456 : : printf("Device doesn't support this mixed combination. "
8457 : : "Test Skipped.\n");
8458 : 0 : return TEST_SKIPPED;
8459 : : }
8460 : 0 : ut_params->op = op;
8461 : :
8462 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8463 : :
8464 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8465 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8466 : :
8467 [ # # ]: 0 : if (verify) {
8468 [ # # ]: 0 : if (ut_params->obuf)
8469 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8470 : : uint8_t *);
8471 : : else
8472 : 0 : plaintext = ciphertext +
8473 : 0 : (tdata->cipher.offset_bits >> 3);
8474 : :
8475 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8476 : 0 : tdata->plaintext.len_bits >> 3);
8477 : 0 : debug_hexdump(stdout, "plaintext expected:",
8478 : 0 : tdata->plaintext.data,
8479 : 0 : tdata->plaintext.len_bits >> 3);
8480 : : } else {
8481 [ # # ]: 0 : if (ut_params->obuf)
8482 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8483 : : uint8_t *);
8484 : : else
8485 : : ciphertext = plaintext;
8486 : :
8487 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8488 : : ciphertext_len);
8489 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8490 : 0 : tdata->ciphertext.data,
8491 : 0 : tdata->ciphertext.len_bits >> 3);
8492 : :
8493 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8494 : : digest_offset = plaintext_pad_len;
8495 : : else
8496 : : digest_offset = tdata->digest_enc.offset;
8497 : :
8498 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8499 : : uint8_t *, digest_offset);
8500 : :
8501 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8502 : 0 : tdata->digest_enc.len);
8503 : 0 : debug_hexdump(stdout, "digest expected:",
8504 : : tdata->digest_enc.data,
8505 : 0 : tdata->digest_enc.len);
8506 : : }
8507 : :
8508 [ # # ]: 0 : if (!verify) {
8509 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8510 : : ut_params->digest,
8511 : : tdata->digest_enc.data,
8512 : : tdata->digest_enc.len,
8513 : : "Generated auth tag not as expected");
8514 : : }
8515 : :
8516 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8517 [ # # ]: 0 : if (verify) {
8518 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8519 : : plaintext,
8520 : : tdata->plaintext.data,
8521 : : tdata->plaintext.len_bits >> 3,
8522 : : "Plaintext data not as expected");
8523 : : } else {
8524 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8525 : : ciphertext,
8526 : : tdata->ciphertext.data,
8527 : : tdata->validDataLen.len_bits,
8528 : : "Ciphertext data not as expected");
8529 : : }
8530 : : }
8531 : :
8532 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8533 : : "crypto op processing failed");
8534 : :
8535 : : return 0;
8536 : : }
8537 : :
8538 : : static int
8539 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8540 : : uint8_t op_mode, uint8_t verify)
8541 : : {
8542 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8543 : : struct crypto_unittest_params *ut_params = &unittest_params;
8544 : :
8545 : : int retval;
8546 : :
8547 : : const uint8_t *plaintext = NULL;
8548 : : const uint8_t *ciphertext = NULL;
8549 : : const uint8_t *digest = NULL;
8550 : : unsigned int plaintext_pad_len;
8551 : : unsigned int plaintext_len;
8552 : : unsigned int ciphertext_pad_len;
8553 : : unsigned int ciphertext_len;
8554 : : uint8_t buffer[10000];
8555 : : uint8_t digest_buffer[10000];
8556 : :
8557 : : struct rte_cryptodev_info dev_info;
8558 : : struct rte_crypto_op *op;
8559 : :
8560 : : /* Check if device supports particular algorithms */
8561 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8562 : : return TEST_SKIPPED;
8563 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8564 : : return TEST_SKIPPED;
8565 : :
8566 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8567 : :
8568 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8569 : :
8570 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8571 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8572 : : printf("Device doesn't support in-place scatter-gather "
8573 : : "in both input and output mbufs.\n");
8574 : 0 : return TEST_SKIPPED;
8575 : : }
8576 : : } else {
8577 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8578 : : printf("Device doesn't support out-of-place scatter-gather "
8579 : : "in both input and output mbufs.\n");
8580 : 2 : return TEST_SKIPPED;
8581 : : }
8582 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8583 : : printf("Device doesn't support digest encrypted.\n");
8584 : 0 : return TEST_SKIPPED;
8585 : : }
8586 : : }
8587 : :
8588 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8589 : : return TEST_SKIPPED;
8590 : :
8591 : : /* Create the session */
8592 [ + + ]: 2 : if (verify)
8593 : 1 : retval = create_wireless_algo_cipher_auth_session(
8594 : 1 : ts_params->valid_devs[0],
8595 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8596 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8597 : 1 : tdata->auth_algo,
8598 : 1 : tdata->cipher_algo,
8599 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8600 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8601 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8602 : 1 : tdata->cipher_iv.len);
8603 : : else
8604 : 1 : retval = create_wireless_algo_auth_cipher_session(
8605 : 1 : ts_params->valid_devs[0],
8606 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8607 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8608 : 1 : tdata->auth_algo,
8609 : 1 : tdata->cipher_algo,
8610 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8611 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8612 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8613 : 1 : tdata->cipher_iv.len);
8614 [ + - ]: 2 : if (retval != 0)
8615 : : return retval;
8616 : :
8617 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8618 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8619 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8620 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8621 : :
8622 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8623 : : ciphertext_pad_len, 15, 0);
8624 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8625 : : "Failed to allocate input buffer in mempool");
8626 : :
8627 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8628 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8629 : : plaintext_pad_len, 15, 0);
8630 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8631 : : "Failed to allocate output buffer in mempool");
8632 : : }
8633 : :
8634 [ + + ]: 2 : if (verify) {
8635 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8636 : 1 : tdata->ciphertext.data);
8637 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8638 : : ciphertext_len, buffer);
8639 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8640 : : ciphertext_len);
8641 : : } else {
8642 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8643 : 1 : tdata->plaintext.data);
8644 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8645 : : plaintext_len, buffer);
8646 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8647 : : plaintext_len);
8648 : : }
8649 : : memset(buffer, 0, sizeof(buffer));
8650 : :
8651 : : /* Create the operation */
8652 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8653 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8654 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8655 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8656 : 2 : (tdata->digest_enc.offset == 0 ?
8657 : : plaintext_pad_len
8658 : : : tdata->digest_enc.offset),
8659 : 2 : tdata->validCipherLen.len_bits,
8660 : 2 : tdata->cipher.offset_bits,
8661 : 2 : tdata->validAuthLen.len_bits,
8662 [ + - ]: 2 : tdata->auth.offset_bits,
8663 : : op_mode, 1, verify);
8664 : :
8665 [ + - ]: 2 : if (retval < 0)
8666 : : return retval;
8667 : :
8668 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8669 : :
8670 : : /* Check if the op failed because the device doesn't */
8671 : : /* support this particular combination of algorithms */
8672 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8673 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8674 : : printf("Device doesn't support this mixed combination. "
8675 : : "Test Skipped.\n");
8676 : 0 : return TEST_SKIPPED;
8677 : : }
8678 : 2 : ut_params->op = op;
8679 : :
8680 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8681 : :
8682 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8683 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8684 : :
8685 [ + + ]: 2 : if (verify) {
8686 [ + - ]: 1 : if (ut_params->obuf)
8687 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8688 : : plaintext_len, buffer);
8689 : : else
8690 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8691 : : plaintext_len, buffer);
8692 : :
8693 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8694 : 1 : (tdata->plaintext.len_bits >> 3) -
8695 : 1 : tdata->digest_enc.len);
8696 : 1 : debug_hexdump(stdout, "plaintext expected:",
8697 : 1 : tdata->plaintext.data,
8698 : 1 : (tdata->plaintext.len_bits >> 3) -
8699 : 1 : tdata->digest_enc.len);
8700 : : } else {
8701 [ + - ]: 1 : if (ut_params->obuf)
8702 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8703 : : ciphertext_len, buffer);
8704 : : else
8705 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8706 : : ciphertext_len, buffer);
8707 : :
8708 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8709 : : ciphertext_len);
8710 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8711 : 1 : tdata->ciphertext.data,
8712 : 1 : tdata->ciphertext.len_bits >> 3);
8713 : :
8714 [ + - ]: 1 : if (ut_params->obuf)
8715 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8716 : 1 : (tdata->digest_enc.offset == 0 ?
8717 : : plaintext_pad_len :
8718 : : tdata->digest_enc.offset),
8719 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8720 : : else
8721 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8722 : 0 : (tdata->digest_enc.offset == 0 ?
8723 : : plaintext_pad_len :
8724 : : tdata->digest_enc.offset),
8725 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8726 : :
8727 : 1 : debug_hexdump(stdout, "digest:", digest,
8728 : 1 : tdata->digest_enc.len);
8729 : 1 : debug_hexdump(stdout, "digest expected:",
8730 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8731 : : }
8732 : :
8733 [ + + ]: 2 : if (!verify) {
8734 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8735 : : digest,
8736 : : tdata->digest_enc.data,
8737 : : tdata->digest_enc.len,
8738 : : "Generated auth tag not as expected");
8739 : : }
8740 : :
8741 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8742 [ + + ]: 2 : if (verify) {
8743 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8744 : : plaintext,
8745 : : tdata->plaintext.data,
8746 : : tdata->plaintext.len_bits >> 3,
8747 : : "Plaintext data not as expected");
8748 : : } else {
8749 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8750 : : ciphertext,
8751 : : tdata->ciphertext.data,
8752 : : tdata->validDataLen.len_bits,
8753 : : "Ciphertext data not as expected");
8754 : : }
8755 : : }
8756 : :
8757 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8758 : : "crypto op processing failed");
8759 : :
8760 : : return 0;
8761 : : }
8762 : :
8763 : : /** AUTH AES CMAC + CIPHER AES CTR */
8764 : :
8765 : : static int
8766 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8767 : : {
8768 : 1 : return test_mixed_auth_cipher(
8769 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8770 : : }
8771 : :
8772 : : static int
8773 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8774 : : {
8775 : 1 : return test_mixed_auth_cipher(
8776 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8777 : : }
8778 : :
8779 : : static int
8780 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8781 : : {
8782 : 1 : return test_mixed_auth_cipher_sgl(
8783 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8784 : : }
8785 : :
8786 : : static int
8787 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8788 : : {
8789 : 1 : return test_mixed_auth_cipher_sgl(
8790 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8791 : : }
8792 : :
8793 : : static int
8794 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8795 : : {
8796 : 1 : return test_mixed_auth_cipher(
8797 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8798 : : }
8799 : :
8800 : : static int
8801 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8802 : : {
8803 : 1 : return test_mixed_auth_cipher(
8804 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8805 : : }
8806 : :
8807 : : static int
8808 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8809 : : {
8810 : 1 : return test_mixed_auth_cipher(
8811 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8812 : : }
8813 : :
8814 : : static int
8815 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8816 : : {
8817 : 1 : return test_mixed_auth_cipher(
8818 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8819 : : }
8820 : :
8821 : : static int
8822 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8823 : : {
8824 : 1 : return test_mixed_auth_cipher(
8825 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8826 : : }
8827 : :
8828 : : static int
8829 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8830 : : {
8831 : 1 : return test_mixed_auth_cipher_sgl(
8832 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8833 : : }
8834 : :
8835 : : static int
8836 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8837 : : {
8838 : 1 : return test_mixed_auth_cipher_sgl(
8839 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8840 : : }
8841 : :
8842 : : static int
8843 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8844 : : {
8845 : 1 : return test_mixed_auth_cipher(
8846 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8847 : : }
8848 : :
8849 : : /** MIXED AUTH + CIPHER */
8850 : :
8851 : : static int
8852 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8853 : : {
8854 : 1 : return test_mixed_auth_cipher(
8855 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8856 : : }
8857 : :
8858 : : static int
8859 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8860 : : {
8861 : 1 : return test_mixed_auth_cipher(
8862 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8863 : : }
8864 : :
8865 : : static int
8866 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8867 : : {
8868 : 1 : return test_mixed_auth_cipher(
8869 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8870 : : }
8871 : :
8872 : : static int
8873 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8874 : : {
8875 : 1 : return test_mixed_auth_cipher(
8876 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8877 : : }
8878 : :
8879 : :
8880 : : static int
8881 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8882 : : {
8883 : 1 : return test_mixed_auth_cipher(
8884 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8885 : : }
8886 : :
8887 : : static int
8888 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8889 : : {
8890 : 1 : return test_mixed_auth_cipher(
8891 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8892 : : }
8893 : :
8894 : : static int
8895 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8896 : : {
8897 : 1 : return test_mixed_auth_cipher(
8898 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8899 : : }
8900 : :
8901 : : static int
8902 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8903 : : {
8904 : 1 : return test_mixed_auth_cipher(
8905 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8906 : : }
8907 : :
8908 : : static int
8909 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8910 : : {
8911 : 1 : return test_mixed_auth_cipher(
8912 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8913 : : }
8914 : :
8915 : : static int
8916 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8917 : : {
8918 : 1 : return test_mixed_auth_cipher(
8919 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8920 : : }
8921 : :
8922 : : static int
8923 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8924 : : {
8925 : 1 : return test_mixed_auth_cipher(
8926 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8927 : : }
8928 : :
8929 : : static int
8930 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8931 : : {
8932 : 1 : return test_mixed_auth_cipher(
8933 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8934 : : }
8935 : :
8936 : : static int
8937 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8938 : : {
8939 : 1 : return test_mixed_auth_cipher(
8940 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8941 : : }
8942 : :
8943 : : static int
8944 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8945 : : {
8946 : 1 : return test_mixed_auth_cipher(
8947 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8948 : : }
8949 : :
8950 : : static int
8951 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8952 : : {
8953 : 1 : return test_mixed_auth_cipher_sgl(
8954 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8955 : : }
8956 : :
8957 : : static int
8958 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8959 : : {
8960 : 1 : return test_mixed_auth_cipher(
8961 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8962 : : }
8963 : :
8964 : : static int
8965 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8966 : : {
8967 : 1 : return test_mixed_auth_cipher_sgl(
8968 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8969 : : }
8970 : :
8971 : : static int
8972 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8973 : : {
8974 : 1 : return test_mixed_auth_cipher(
8975 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8976 : : }
8977 : :
8978 : : static int
8979 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8980 : : {
8981 : 1 : return test_mixed_auth_cipher(
8982 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8983 : : }
8984 : :
8985 : : static int
8986 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8987 : : {
8988 : 1 : return test_mixed_auth_cipher(
8989 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8990 : : }
8991 : :
8992 : : static int
8993 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8994 : : {
8995 : 1 : return test_mixed_auth_cipher(
8996 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8997 : : }
8998 : :
8999 : : static int
9000 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
9001 : : {
9002 : 1 : return test_mixed_auth_cipher(
9003 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
9004 : : }
9005 : :
9006 : : static int
9007 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
9008 : : {
9009 : 1 : return test_mixed_auth_cipher(
9010 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9011 : : }
9012 : :
9013 : : static int
9014 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
9015 : : {
9016 : 1 : return test_mixed_auth_cipher(
9017 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9018 : : }
9019 : : static int
9020 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9021 : : {
9022 : 1 : return test_mixed_auth_cipher(
9023 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
9024 : : }
9025 : :
9026 : : static int
9027 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9028 : : {
9029 : 1 : return test_mixed_auth_cipher(
9030 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
9031 : : }
9032 : :
9033 : : static int
9034 : 1 : test_auth_null_cipher_snow_test_case_1(void)
9035 : : {
9036 : 1 : return test_mixed_auth_cipher(
9037 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
9038 : : }
9039 : :
9040 : : static int
9041 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
9042 : : {
9043 : 1 : return test_mixed_auth_cipher(
9044 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
9045 : : }
9046 : :
9047 : : static int
9048 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
9049 : : {
9050 : 1 : return test_mixed_auth_cipher(
9051 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9052 : : }
9053 : :
9054 : : static int
9055 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
9056 : : {
9057 : 1 : return test_mixed_auth_cipher(
9058 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9059 : : }
9060 : :
9061 : : static int
9062 : 1 : test_auth_snow_cipher_null_test_case_1(void)
9063 : : {
9064 : 1 : return test_mixed_auth_cipher(
9065 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9066 : : }
9067 : :
9068 : : static int
9069 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
9070 : : {
9071 : 1 : return test_mixed_auth_cipher(
9072 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9073 : : }
9074 : :
9075 : : static int
9076 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
9077 : : {
9078 : 1 : return test_mixed_auth_cipher(
9079 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9080 : : }
9081 : :
9082 : : static int
9083 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
9084 : : {
9085 : 1 : return test_mixed_auth_cipher(
9086 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9087 : : }
9088 : :
9089 : : static int
9090 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
9091 : : {
9092 : 1 : return test_mixed_auth_cipher(
9093 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
9094 : : }
9095 : :
9096 : : static int
9097 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
9098 : : {
9099 : 1 : return test_mixed_auth_cipher(
9100 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
9101 : : }
9102 : :
9103 : : static int
9104 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
9105 : : {
9106 : 1 : return test_mixed_auth_cipher(
9107 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9108 : : }
9109 : :
9110 : : static int
9111 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
9112 : : {
9113 : 1 : return test_mixed_auth_cipher(
9114 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9115 : : }
9116 : :
9117 : : /* ***** AEAD algorithm Tests ***** */
9118 : :
9119 : : static int
9120 : 87 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
9121 : : enum rte_crypto_aead_operation op,
9122 : : const uint8_t *key, const uint8_t key_len,
9123 : : const uint16_t aad_len, const uint8_t auth_len,
9124 : : uint8_t iv_len)
9125 : : {
9126 : 87 : uint8_t *aead_key = alloca(key_len);
9127 : :
9128 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9129 : : struct crypto_unittest_params *ut_params = &unittest_params;
9130 : :
9131 : : memcpy(aead_key, key, key_len);
9132 : :
9133 : : /* Setup AEAD Parameters */
9134 : 87 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9135 : 87 : ut_params->aead_xform.next = NULL;
9136 : 87 : ut_params->aead_xform.aead.algo = algo;
9137 : 87 : ut_params->aead_xform.aead.op = op;
9138 : 87 : ut_params->aead_xform.aead.key.data = aead_key;
9139 : 87 : ut_params->aead_xform.aead.key.length = key_len;
9140 : 87 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9141 : 87 : ut_params->aead_xform.aead.iv.length = iv_len;
9142 : 87 : ut_params->aead_xform.aead.digest_length = auth_len;
9143 : 87 : ut_params->aead_xform.aead.aad_length = aad_len;
9144 : :
9145 : 87 : debug_hexdump(stdout, "key:", key, key_len);
9146 : :
9147 : : /* Create Crypto session*/
9148 : 87 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9149 : : &ut_params->aead_xform, ts_params->session_mpool);
9150 [ - + - - ]: 87 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9151 : : return TEST_SKIPPED;
9152 [ - + ]: 87 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9153 : : return 0;
9154 : : }
9155 : :
9156 : : static int
9157 : 2 : create_aead_xform(struct rte_crypto_op *op,
9158 : : enum rte_crypto_aead_algorithm algo,
9159 : : enum rte_crypto_aead_operation aead_op,
9160 : : uint8_t *key, const uint8_t key_len,
9161 : : const uint8_t aad_len, const uint8_t auth_len,
9162 : : uint8_t iv_len)
9163 : : {
9164 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9165 : : "failed to allocate space for crypto transform");
9166 : :
9167 : : struct rte_crypto_sym_op *sym_op = op->sym;
9168 : :
9169 : : /* Setup AEAD Parameters */
9170 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9171 : 2 : sym_op->xform->next = NULL;
9172 : 2 : sym_op->xform->aead.algo = algo;
9173 : 2 : sym_op->xform->aead.op = aead_op;
9174 : 2 : sym_op->xform->aead.key.data = key;
9175 : 2 : sym_op->xform->aead.key.length = key_len;
9176 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
9177 : 2 : sym_op->xform->aead.iv.length = iv_len;
9178 : 2 : sym_op->xform->aead.digest_length = auth_len;
9179 : 2 : sym_op->xform->aead.aad_length = aad_len;
9180 : :
9181 : 2 : debug_hexdump(stdout, "key:", key, key_len);
9182 : :
9183 : : return 0;
9184 : : }
9185 : :
9186 : : static int
9187 : 88 : create_aead_operation(enum rte_crypto_aead_operation op,
9188 : : const struct aead_test_data *tdata)
9189 : : {
9190 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9191 : : struct crypto_unittest_params *ut_params = &unittest_params;
9192 : :
9193 : : uint8_t *plaintext, *ciphertext;
9194 : : unsigned int aad_pad_len, plaintext_pad_len;
9195 : :
9196 : : /* Generate Crypto op data structure */
9197 : 88 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9198 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9199 [ - + ]: 88 : TEST_ASSERT_NOT_NULL(ut_params->op,
9200 : : "Failed to allocate symmetric crypto operation struct");
9201 : :
9202 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9203 : :
9204 : : /* Append aad data */
9205 [ + + ]: 88 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9206 : 20 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9207 : 20 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9208 : : aad_pad_len);
9209 [ - + ]: 20 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9210 : : "no room to append aad");
9211 : :
9212 : 20 : sym_op->aead.aad.phys_addr =
9213 : 20 : rte_pktmbuf_iova(ut_params->ibuf);
9214 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9215 : 20 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9216 : 20 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9217 : 20 : tdata->aad.len);
9218 : :
9219 : : /* Append IV at the end of the crypto operation*/
9220 : 20 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9221 : : uint8_t *, IV_OFFSET);
9222 : :
9223 : : /* Copy IV 1 byte after the IV pointer, according to the API */
9224 [ + - ]: 20 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9225 : 20 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
9226 : 20 : tdata->iv.len);
9227 : : } else {
9228 : 68 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9229 : 68 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9230 : : aad_pad_len);
9231 [ - + ]: 68 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9232 : : "no room to append aad");
9233 : :
9234 : 68 : sym_op->aead.aad.phys_addr =
9235 : 68 : rte_pktmbuf_iova(ut_params->ibuf);
9236 : 68 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9237 : 68 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9238 : 68 : tdata->aad.len);
9239 : :
9240 : : /* Append IV at the end of the crypto operation*/
9241 : 68 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9242 : : uint8_t *, IV_OFFSET);
9243 : :
9244 [ - + ]: 68 : if (tdata->iv.len == 0) {
9245 : : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9246 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
9247 : : AES_GCM_J0_LENGTH);
9248 : : } else {
9249 [ + - ]: 68 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9250 : 68 : debug_hexdump(stdout, "iv:", iv_ptr,
9251 : 68 : tdata->iv.len);
9252 : : }
9253 : : }
9254 : :
9255 : : /* Append plaintext/ciphertext */
9256 [ + + ]: 88 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9257 : 44 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9258 : 44 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9259 : : plaintext_pad_len);
9260 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9261 : :
9262 : 44 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9263 : 44 : debug_hexdump(stdout, "plaintext:", plaintext,
9264 : 44 : tdata->plaintext.len);
9265 : :
9266 [ + + ]: 44 : if (ut_params->obuf) {
9267 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
9268 : : ut_params->obuf,
9269 : 1 : plaintext_pad_len + aad_pad_len);
9270 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
9271 : : "no room to append ciphertext");
9272 : :
9273 : 1 : memset(ciphertext + aad_pad_len, 0,
9274 : 1 : tdata->ciphertext.len);
9275 : : }
9276 : : } else {
9277 : 44 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9278 : 44 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9279 : : plaintext_pad_len);
9280 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(ciphertext,
9281 : : "no room to append ciphertext");
9282 : :
9283 : 44 : memcpy(ciphertext, tdata->ciphertext.data,
9284 : 44 : tdata->ciphertext.len);
9285 : 44 : debug_hexdump(stdout, "ciphertext:", ciphertext,
9286 : 44 : tdata->ciphertext.len);
9287 : :
9288 [ + + ]: 44 : if (ut_params->obuf) {
9289 : : plaintext = (uint8_t *)rte_pktmbuf_append(
9290 : : ut_params->obuf,
9291 : 1 : plaintext_pad_len + aad_pad_len);
9292 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
9293 : : "no room to append plaintext");
9294 : :
9295 : 1 : memset(plaintext + aad_pad_len, 0,
9296 : 1 : tdata->plaintext.len);
9297 : : }
9298 : : }
9299 : :
9300 : : /* Append digest data */
9301 [ + + ]: 88 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9302 : 43 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9303 : 44 : ut_params->obuf ? ut_params->obuf :
9304 : : ut_params->ibuf,
9305 [ + + ]: 44 : tdata->auth_tag.len);
9306 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9307 : : "no room to append digest");
9308 [ + + ]: 44 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9309 [ + + ]: 44 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9310 : : ut_params->obuf ? ut_params->obuf :
9311 : : ut_params->ibuf,
9312 : : plaintext_pad_len +
9313 : : aad_pad_len);
9314 : : } else {
9315 : 88 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9316 : 44 : ut_params->ibuf, tdata->auth_tag.len);
9317 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9318 : : "no room to append digest");
9319 [ + + ]: 44 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9320 : : ut_params->ibuf,
9321 : : plaintext_pad_len + aad_pad_len);
9322 : :
9323 : 44 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9324 [ + + ]: 44 : tdata->auth_tag.len);
9325 : 44 : debug_hexdump(stdout, "digest:",
9326 : 44 : sym_op->aead.digest.data,
9327 : 44 : tdata->auth_tag.len);
9328 : : }
9329 : :
9330 : 88 : sym_op->aead.data.length = tdata->plaintext.len;
9331 : 88 : sym_op->aead.data.offset = aad_pad_len;
9332 : :
9333 : 88 : return 0;
9334 : : }
9335 : :
9336 : : static int
9337 : 43 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9338 : : {
9339 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9340 : : struct crypto_unittest_params *ut_params = &unittest_params;
9341 : :
9342 : : int retval;
9343 : : uint8_t *ciphertext, *auth_tag;
9344 : : uint16_t plaintext_pad_len;
9345 : : uint32_t i;
9346 : : struct rte_cryptodev_info dev_info;
9347 : :
9348 : 43 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9349 : 43 : uint64_t feat_flags = dev_info.feature_flags;
9350 : :
9351 [ - + ]: 43 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9352 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9353 : : printf("Device doesn't support RAW data-path APIs.\n");
9354 : 0 : return TEST_SKIPPED;
9355 : : }
9356 : :
9357 : : /* Verify the capabilities */
9358 : : struct rte_cryptodev_sym_capability_idx cap_idx;
9359 : : const struct rte_cryptodev_symmetric_capability *capability;
9360 : 43 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9361 : 43 : cap_idx.algo.aead = tdata->algo;
9362 : 43 : capability = rte_cryptodev_sym_capability_get(
9363 : 43 : ts_params->valid_devs[0], &cap_idx);
9364 [ + - ]: 43 : if (capability == NULL)
9365 : : return TEST_SKIPPED;
9366 [ + + ]: 43 : if (rte_cryptodev_sym_capability_check_aead(
9367 : 43 : capability, tdata->key.len, tdata->auth_tag.len,
9368 : 43 : tdata->aad.len, tdata->iv.len))
9369 : : return TEST_SKIPPED;
9370 : :
9371 : : /* Create AEAD session */
9372 : 42 : retval = create_aead_session(ts_params->valid_devs[0],
9373 : 42 : tdata->algo,
9374 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
9375 : 42 : tdata->key.data, tdata->key.len,
9376 : 42 : tdata->aad.len, tdata->auth_tag.len,
9377 : 42 : tdata->iv.len);
9378 [ + - ]: 42 : if (retval != TEST_SUCCESS)
9379 : : return retval;
9380 : :
9381 [ + + ]: 42 : if (tdata->aad.len > MBUF_SIZE) {
9382 [ - + ]: 2 : if (use_ext_mbuf) {
9383 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9384 : : AEAD_TEXT_MAX_LENGTH,
9385 : : 1 /* nb_segs */,
9386 : : NULL);
9387 : : } else {
9388 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9389 : : }
9390 : : /* Populate full size of add data */
9391 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9392 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9393 : : } else {
9394 [ + + ]: 40 : if (use_ext_mbuf) {
9395 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9396 : : AEAD_TEXT_MAX_LENGTH,
9397 : : 1 /* nb_segs */,
9398 : : NULL);
9399 : : } else {
9400 : 39 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9401 : : }
9402 : : }
9403 : :
9404 : : /* clear mbuf payload */
9405 : 42 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9406 : 42 : rte_pktmbuf_tailroom(ut_params->ibuf));
9407 : :
9408 : : /* Create AEAD operation */
9409 : 42 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9410 [ + - ]: 42 : if (retval < 0)
9411 : : return retval;
9412 : :
9413 [ + - ]: 42 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9414 : :
9415 : 42 : ut_params->op->sym->m_src = ut_params->ibuf;
9416 : :
9417 : : /* Process crypto operation */
9418 [ - + ]: 42 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9419 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9420 [ - + ]: 42 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9421 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9422 : : 0);
9423 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9424 : : return retval;
9425 : : } else
9426 [ - + ]: 42 : TEST_ASSERT_NOT_NULL(
9427 : : process_crypto_request(ts_params->valid_devs[0],
9428 : : ut_params->op), "failed to process sym crypto op");
9429 : :
9430 [ - + ]: 42 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9431 : : "crypto op processing failed");
9432 : :
9433 : 42 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9434 : :
9435 [ - + ]: 42 : if (ut_params->op->sym->m_dst) {
9436 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9437 : : uint8_t *);
9438 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9439 : : uint8_t *, plaintext_pad_len);
9440 : : } else {
9441 : 42 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9442 : : uint8_t *,
9443 : : ut_params->op->sym->cipher.data.offset);
9444 : 42 : auth_tag = ciphertext + plaintext_pad_len;
9445 : : }
9446 : :
9447 : 42 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9448 : 42 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9449 : :
9450 : : /* Validate obuf */
9451 [ + + ]: 45 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9452 : : ciphertext,
9453 : : tdata->ciphertext.data,
9454 : : tdata->ciphertext.len,
9455 : : "Ciphertext data not as expected");
9456 : :
9457 [ + + ]: 42 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9458 : : auth_tag,
9459 : : tdata->auth_tag.data,
9460 : : tdata->auth_tag.len,
9461 : : "Generated auth tag not as expected");
9462 : :
9463 : : return 0;
9464 : :
9465 : : }
9466 : :
9467 : : static int
9468 : : test_authenticated_encryption(const struct aead_test_data *tdata)
9469 : : {
9470 : 42 : return test_authenticated_encryption_helper(tdata, false);
9471 : : }
9472 : :
9473 : : #ifdef RTE_LIB_SECURITY
9474 : : static int
9475 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9476 : : enum rte_security_session_protocol proto)
9477 : : {
9478 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9479 : :
9480 : : const struct rte_security_capability *capabilities;
9481 : : const struct rte_security_capability *capability;
9482 : : uint16_t i = 0;
9483 : :
9484 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9485 : :
9486 : :
9487 : 0 : capabilities = rte_security_capabilities_get(ctx);
9488 : :
9489 [ # # ]: 0 : if (capabilities == NULL)
9490 : : return -ENOTSUP;
9491 : :
9492 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9493 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9494 [ # # ]: 0 : if (capability->action == action &&
9495 [ # # ]: 0 : capability->protocol == proto)
9496 : : return 0;
9497 : : }
9498 : :
9499 : : return -ENOTSUP;
9500 : : }
9501 : :
9502 : : /* Basic algorithm run function for async inplace mode.
9503 : : * Creates a session from input parameters and runs one operation
9504 : : * on input_vec. Checks the output of the crypto operation against
9505 : : * output_vec.
9506 : : */
9507 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9508 : : enum rte_crypto_auth_operation opa,
9509 : : const uint8_t *input_vec, unsigned int input_vec_len,
9510 : : const uint8_t *output_vec,
9511 : : unsigned int output_vec_len,
9512 : : enum rte_crypto_cipher_algorithm cipher_alg,
9513 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9514 : : enum rte_crypto_auth_algorithm auth_alg,
9515 : : const uint8_t *auth_key, uint32_t auth_key_len,
9516 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9517 : : uint8_t packet_direction, uint8_t sn_size,
9518 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9519 : : {
9520 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9521 : : struct crypto_unittest_params *ut_params = &unittest_params;
9522 : : uint8_t *plaintext;
9523 : : int ret = TEST_SUCCESS;
9524 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9525 : : struct rte_cryptodev_info dev_info;
9526 : : uint64_t feat_flags;
9527 : :
9528 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9529 : 0 : feat_flags = dev_info.feature_flags;
9530 : :
9531 : : /* Verify the capabilities */
9532 : : struct rte_security_capability_idx sec_cap_idx;
9533 : :
9534 : 0 : sec_cap_idx.action = ut_params->type;
9535 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9536 : 0 : sec_cap_idx.pdcp.domain = domain;
9537 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9538 : : return TEST_SKIPPED;
9539 : :
9540 : : /* Generate test mbuf data */
9541 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9542 : :
9543 : : /* clear mbuf payload */
9544 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9545 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9546 : :
9547 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9548 : : input_vec_len);
9549 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9550 : :
9551 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9552 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9553 : : printf("Device does not support RAW data-path APIs.\n");
9554 : 0 : return TEST_SKIPPED;
9555 : : }
9556 : : /* Out of place support */
9557 [ # # ]: 0 : if (oop) {
9558 : : /*
9559 : : * For out-of-place we need to alloc another mbuf
9560 : : */
9561 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9562 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9563 : : }
9564 : :
9565 : : /* Setup Cipher Parameters */
9566 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9567 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9568 : 0 : ut_params->cipher_xform.cipher.op = opc;
9569 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9570 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9571 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9572 : : packet_direction ? 4 : 0;
9573 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9574 : :
9575 : : /* Setup HMAC Parameters if ICV header is required */
9576 [ # # ]: 0 : if (auth_alg != 0) {
9577 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9578 : 0 : ut_params->auth_xform.next = NULL;
9579 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9580 : 0 : ut_params->auth_xform.auth.op = opa;
9581 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9582 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9583 : :
9584 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9585 : : } else {
9586 : 0 : ut_params->cipher_xform.next = NULL;
9587 : : }
9588 : :
9589 : 0 : struct rte_security_session_conf sess_conf = {
9590 : 0 : .action_type = ut_params->type,
9591 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9592 : : {.pdcp = {
9593 : : .bearer = bearer,
9594 : : .domain = domain,
9595 : : .pkt_dir = packet_direction,
9596 : : .sn_size = sn_size,
9597 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9598 : : /**
9599 : : * hfn can be set as pdcp_test_hfn[i]
9600 : : * if hfn_ovrd is not set. Here, PDCP
9601 : : * packet direction is just used to
9602 : : * run half of the cases with session
9603 : : * HFN and other half with per packet
9604 : : * HFN.
9605 : : */
9606 : : .hfn_threshold = hfn_threshold,
9607 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9608 : : .sdap_enabled = sdap,
9609 : : } },
9610 : : .crypto_xform = &ut_params->cipher_xform
9611 : : };
9612 : :
9613 : : /* Create security session */
9614 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9615 : : &sess_conf, ts_params->session_mpool);
9616 : :
9617 [ # # ]: 0 : if (!ut_params->sec_session) {
9618 : : printf("TestCase %s()-%d line %d failed %s: ",
9619 : : __func__, i, __LINE__, "Failed to allocate session");
9620 : : ret = TEST_FAILED;
9621 : 0 : goto on_err;
9622 : : }
9623 : :
9624 : : /* Generate crypto op data structure */
9625 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9626 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9627 [ # # ]: 0 : if (!ut_params->op) {
9628 : : printf("TestCase %s()-%d line %d failed %s: ",
9629 : : __func__, i, __LINE__,
9630 : : "Failed to allocate symmetric crypto operation struct");
9631 : : ret = TEST_FAILED;
9632 : 0 : goto on_err;
9633 : : }
9634 : :
9635 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9636 : : uint32_t *, IV_OFFSET);
9637 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9638 : :
9639 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9640 : :
9641 : : /* set crypto operation source mbuf */
9642 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9643 [ # # ]: 0 : if (oop)
9644 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9645 : :
9646 : : /* Process crypto operation */
9647 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9648 : : /* filling lengths */
9649 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9650 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9651 : :
9652 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9653 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9654 : : return ret;
9655 : : } else {
9656 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9657 : : }
9658 [ # # ]: 0 : if (ut_params->op == NULL) {
9659 : : printf("TestCase %s()-%d line %d failed %s: ",
9660 : : __func__, i, __LINE__,
9661 : : "failed to process sym crypto op");
9662 : : ret = TEST_FAILED;
9663 : 0 : goto on_err;
9664 : : }
9665 : :
9666 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9667 : : printf("TestCase %s()-%d line %d failed %s: ",
9668 : : __func__, i, __LINE__, "crypto op processing failed");
9669 : : ret = TEST_FAILED;
9670 : 0 : goto on_err;
9671 : : }
9672 : :
9673 : : /* Validate obuf */
9674 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9675 : : uint8_t *);
9676 [ # # ]: 0 : if (oop) {
9677 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9678 : : uint8_t *);
9679 : : }
9680 : :
9681 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9682 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9683 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9684 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9685 : : ret = TEST_FAILED;
9686 : 0 : goto on_err;
9687 : : }
9688 : :
9689 : 0 : on_err:
9690 : 0 : rte_crypto_op_free(ut_params->op);
9691 : 0 : ut_params->op = NULL;
9692 : :
9693 [ # # ]: 0 : if (ut_params->sec_session)
9694 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9695 : 0 : ut_params->sec_session = NULL;
9696 : :
9697 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9698 : 0 : ut_params->ibuf = NULL;
9699 [ # # ]: 0 : if (oop) {
9700 : 0 : rte_pktmbuf_free(ut_params->obuf);
9701 : 0 : ut_params->obuf = NULL;
9702 : : }
9703 : :
9704 : : return ret;
9705 : : }
9706 : :
9707 : : static int
9708 : 0 : test_pdcp_proto_SGL(int i, int oop,
9709 : : enum rte_crypto_cipher_operation opc,
9710 : : enum rte_crypto_auth_operation opa,
9711 : : uint8_t *input_vec,
9712 : : unsigned int input_vec_len,
9713 : : uint8_t *output_vec,
9714 : : unsigned int output_vec_len,
9715 : : uint32_t fragsz,
9716 : : uint32_t fragsz_oop)
9717 : : {
9718 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9719 : : struct crypto_unittest_params *ut_params = &unittest_params;
9720 : : uint8_t *plaintext;
9721 : : struct rte_mbuf *buf, *buf_oop = NULL;
9722 : : int ret = TEST_SUCCESS;
9723 : : int to_trn = 0;
9724 : : int to_trn_tbl[16];
9725 : : unsigned int trn_data = 0;
9726 : : struct rte_cryptodev_info dev_info;
9727 : : uint64_t feat_flags;
9728 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9729 : : struct rte_mbuf *temp_mbuf;
9730 : :
9731 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9732 : 0 : feat_flags = dev_info.feature_flags;
9733 : :
9734 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9735 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9736 : : printf("Device does not support RAW data-path APIs.\n");
9737 : 0 : return -ENOTSUP;
9738 : : }
9739 : : /* Verify the capabilities */
9740 : : struct rte_security_capability_idx sec_cap_idx;
9741 : :
9742 : 0 : sec_cap_idx.action = ut_params->type;
9743 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9744 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9745 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9746 : : return TEST_SKIPPED;
9747 : :
9748 : : if (fragsz > input_vec_len)
9749 : : fragsz = input_vec_len;
9750 : :
9751 : 0 : uint16_t plaintext_len = fragsz;
9752 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9753 : :
9754 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9755 : 0 : frag_size_oop = output_vec_len;
9756 : :
9757 : : int ecx = 0;
9758 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9759 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9760 : : return 1;
9761 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9762 : : return 1;
9763 : :
9764 : : /* Out of place support */
9765 [ # # ]: 0 : if (oop) {
9766 : : /*
9767 : : * For out-of-place we need to alloc another mbuf
9768 : : */
9769 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9770 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9771 : 0 : buf_oop = ut_params->obuf;
9772 : : }
9773 : :
9774 : : /* Generate test mbuf data */
9775 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9776 : :
9777 : : /* clear mbuf payload */
9778 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9779 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9780 : :
9781 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9782 : : plaintext_len);
9783 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9784 : : trn_data += plaintext_len;
9785 : :
9786 : 0 : buf = ut_params->ibuf;
9787 : :
9788 : : /*
9789 : : * Loop until no more fragments
9790 : : */
9791 : :
9792 [ # # ]: 0 : while (trn_data < input_vec_len) {
9793 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9794 : 0 : (input_vec_len - trn_data) : fragsz;
9795 : :
9796 : 0 : to_trn_tbl[ecx++] = to_trn;
9797 : :
9798 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9799 : : buf = buf->next;
9800 [ # # ]: 0 : ut_params->ibuf->nb_segs++;
9801 : :
9802 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9803 : : rte_pktmbuf_tailroom(buf));
9804 : :
9805 : : /* OOP */
9806 [ # # ]: 0 : if (oop && !fragsz_oop) {
9807 : 0 : buf_oop->next =
9808 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9809 : : buf_oop = buf_oop->next;
9810 [ # # ]: 0 : ut_params->obuf->nb_segs++;
9811 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9812 : : 0, rte_pktmbuf_tailroom(buf_oop));
9813 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "Output buffer not initialized");
9814 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
9815 : : }
9816 : :
9817 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9818 : : to_trn);
9819 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
9820 : :
9821 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9822 : 0 : trn_data += to_trn;
9823 : : }
9824 : :
9825 [ # # ]: 0 : if (fragsz_oop && oop) {
9826 : : to_trn = 0;
9827 : : ecx = 0;
9828 : :
9829 : 0 : trn_data = frag_size_oop;
9830 [ # # ]: 0 : while (trn_data < output_vec_len) {
9831 : 0 : to_trn =
9832 : 0 : (output_vec_len - trn_data <
9833 : : frag_size_oop) ?
9834 : 0 : (output_vec_len - trn_data) :
9835 : : frag_size_oop;
9836 : :
9837 : 0 : to_trn_tbl[ecx++] = to_trn;
9838 : :
9839 : 0 : buf_oop->next =
9840 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9841 : : buf_oop = buf_oop->next;
9842 : 0 : ut_params->obuf->nb_segs++;
9843 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9844 : : 0, rte_pktmbuf_tailroom(buf_oop));
9845 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
9846 : :
9847 : 0 : trn_data += to_trn;
9848 : : }
9849 : : }
9850 : :
9851 : : /* Setup Cipher Parameters */
9852 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9853 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9854 : 0 : ut_params->cipher_xform.cipher.op = opc;
9855 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9856 : 0 : ut_params->cipher_xform.cipher.key.length =
9857 : 0 : pdcp_test_params[i].cipher_key_len;
9858 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9859 : :
9860 : : /* Setup HMAC Parameters if ICV header is required */
9861 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9862 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9863 : 0 : ut_params->auth_xform.next = NULL;
9864 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9865 : 0 : ut_params->auth_xform.auth.op = opa;
9866 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9867 : 0 : ut_params->auth_xform.auth.key.length =
9868 : 0 : pdcp_test_params[i].auth_key_len;
9869 : :
9870 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9871 : : } else {
9872 : 0 : ut_params->cipher_xform.next = NULL;
9873 : : }
9874 : :
9875 : 0 : struct rte_security_session_conf sess_conf = {
9876 : 0 : .action_type = ut_params->type,
9877 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9878 : : {.pdcp = {
9879 : 0 : .bearer = pdcp_test_bearer[i],
9880 : 0 : .domain = pdcp_test_params[i].domain,
9881 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9882 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9883 : 0 : .hfn = pdcp_test_hfn[i],
9884 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9885 : : .hfn_ovrd = 0,
9886 : : } },
9887 : : .crypto_xform = &ut_params->cipher_xform
9888 : : };
9889 : :
9890 : : /* Create security session */
9891 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9892 : : &sess_conf, ts_params->session_mpool);
9893 : :
9894 [ # # ]: 0 : if (!ut_params->sec_session) {
9895 : : printf("TestCase %s()-%d line %d failed %s: ",
9896 : : __func__, i, __LINE__, "Failed to allocate session");
9897 : : ret = TEST_FAILED;
9898 : 0 : goto on_err;
9899 : : }
9900 : :
9901 : : /* Generate crypto op data structure */
9902 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9903 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9904 [ # # ]: 0 : if (!ut_params->op) {
9905 : : printf("TestCase %s()-%d line %d failed %s: ",
9906 : : __func__, i, __LINE__,
9907 : : "Failed to allocate symmetric crypto operation struct");
9908 : : ret = TEST_FAILED;
9909 : 0 : goto on_err;
9910 : : }
9911 : :
9912 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9913 : :
9914 : : /* set crypto operation source mbuf */
9915 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9916 [ # # ]: 0 : if (oop)
9917 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9918 : :
9919 : : /* Process crypto operation */
9920 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9921 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9922 : : /* filling lengths */
9923 [ # # ]: 0 : while (temp_mbuf) {
9924 : 0 : ut_params->op->sym->cipher.data.length
9925 : 0 : += temp_mbuf->pkt_len;
9926 : 0 : ut_params->op->sym->auth.data.length
9927 : 0 : += temp_mbuf->pkt_len;
9928 : 0 : temp_mbuf = temp_mbuf->next;
9929 : : }
9930 : :
9931 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9932 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9933 : : return ret;
9934 : : } else {
9935 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9936 : : ut_params->op);
9937 : : }
9938 [ # # ]: 0 : if (ut_params->op == NULL) {
9939 : : printf("TestCase %s()-%d line %d failed %s: ",
9940 : : __func__, i, __LINE__,
9941 : : "failed to process sym crypto op");
9942 : : ret = TEST_FAILED;
9943 : 0 : goto on_err;
9944 : : }
9945 : :
9946 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9947 : : printf("TestCase %s()-%d line %d failed %s: ",
9948 : : __func__, i, __LINE__, "crypto op processing failed");
9949 : : ret = TEST_FAILED;
9950 : 0 : goto on_err;
9951 : : }
9952 : :
9953 : : /* Validate obuf */
9954 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9955 : : uint8_t *);
9956 [ # # ]: 0 : if (oop) {
9957 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9958 : : uint8_t *);
9959 : : }
9960 [ # # ]: 0 : if (fragsz_oop)
9961 : 0 : fragsz = frag_size_oop;
9962 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9963 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9964 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9965 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9966 : : ret = TEST_FAILED;
9967 : 0 : goto on_err;
9968 : : }
9969 : :
9970 : 0 : buf = ut_params->op->sym->m_src->next;
9971 [ # # ]: 0 : if (oop)
9972 : 0 : buf = ut_params->op->sym->m_dst->next;
9973 : :
9974 : : unsigned int off = fragsz;
9975 : :
9976 : : ecx = 0;
9977 [ # # ]: 0 : while (buf) {
9978 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9979 : : uint8_t *);
9980 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9981 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9982 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9983 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9984 : : to_trn_tbl[ecx]);
9985 : : ret = TEST_FAILED;
9986 : 0 : goto on_err;
9987 : : }
9988 : 0 : off += to_trn_tbl[ecx++];
9989 : 0 : buf = buf->next;
9990 : : }
9991 : 0 : on_err:
9992 : 0 : rte_crypto_op_free(ut_params->op);
9993 : 0 : ut_params->op = NULL;
9994 : :
9995 [ # # ]: 0 : if (ut_params->sec_session)
9996 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9997 : 0 : ut_params->sec_session = NULL;
9998 : :
9999 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10000 : 0 : ut_params->ibuf = NULL;
10001 [ # # ]: 0 : if (oop) {
10002 : 0 : rte_pktmbuf_free(ut_params->obuf);
10003 : 0 : ut_params->obuf = NULL;
10004 : : }
10005 : :
10006 : : return ret;
10007 : : }
10008 : :
10009 : : int
10010 : 0 : test_pdcp_proto_cplane_encap(int i)
10011 : : {
10012 : 0 : return test_pdcp_proto(
10013 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10014 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10015 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10016 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10017 : 0 : pdcp_test_params[i].cipher_key_len,
10018 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10019 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10020 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10021 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10022 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10023 : : }
10024 : :
10025 : : int
10026 : 0 : test_pdcp_proto_uplane_encap(int i)
10027 : : {
10028 : 0 : return test_pdcp_proto(
10029 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10030 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10031 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10032 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10033 : 0 : pdcp_test_params[i].cipher_key_len,
10034 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10035 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10036 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10037 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10038 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10039 : : }
10040 : :
10041 : : int
10042 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
10043 : : {
10044 : 0 : return test_pdcp_proto(
10045 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10046 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10047 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10048 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10049 : 0 : pdcp_test_params[i].cipher_key_len,
10050 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10051 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10052 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10053 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10054 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10055 : : }
10056 : :
10057 : : int
10058 : 0 : test_pdcp_proto_cplane_decap(int i)
10059 : : {
10060 : 0 : return test_pdcp_proto(
10061 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10062 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10063 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10064 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10065 : 0 : pdcp_test_params[i].cipher_key_len,
10066 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10067 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10068 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10069 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10070 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10071 : : }
10072 : :
10073 : : int
10074 : 0 : test_pdcp_proto_uplane_decap(int i)
10075 : : {
10076 : 0 : return test_pdcp_proto(
10077 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10078 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10079 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10080 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10081 : 0 : pdcp_test_params[i].cipher_key_len,
10082 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10083 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10084 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10085 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10086 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10087 : : }
10088 : :
10089 : : int
10090 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
10091 : : {
10092 : 0 : return test_pdcp_proto(
10093 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10094 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10095 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10096 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10097 : 0 : pdcp_test_params[i].cipher_key_len,
10098 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10099 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10100 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10101 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10102 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10103 : : }
10104 : :
10105 : : static int
10106 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
10107 : : {
10108 : : /* i can be used for running any PDCP case
10109 : : * In this case it is uplane 12-bit AES-SNOW DL encap
10110 : : */
10111 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
10112 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
10113 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10114 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10115 : : pdcp_test_data_in[i],
10116 : : pdcp_test_data_in_len[i],
10117 : : pdcp_test_data_out[i],
10118 : 0 : pdcp_test_data_in_len[i]+4,
10119 : : 32, 0);
10120 : : }
10121 : : static int
10122 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
10123 : : {
10124 : : /* i can be used for running any PDCP case
10125 : : * In this case it is uplane 18-bit NULL-NULL DL encap
10126 : : */
10127 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10128 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10129 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10130 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10131 : : pdcp_test_data_in[i],
10132 : : pdcp_test_data_in_len[i],
10133 : : pdcp_test_data_out[i],
10134 : 0 : pdcp_test_data_in_len[i]+4,
10135 : : 32, 128);
10136 : : }
10137 : : static int
10138 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
10139 : : {
10140 : : /* i can be used for running any PDCP case
10141 : : * In this case it is uplane 18-bit AES DL encap
10142 : : */
10143 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10144 : : + DOWNLINK;
10145 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10146 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10147 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10148 : : pdcp_test_data_in[i],
10149 : : pdcp_test_data_in_len[i],
10150 : : pdcp_test_data_out[i],
10151 : : pdcp_test_data_in_len[i],
10152 : : 32, 40);
10153 : : }
10154 : : static int
10155 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
10156 : : {
10157 : : /* i can be used for running any PDCP case
10158 : : * In this case it is cplane 12-bit AES-ZUC DL encap
10159 : : */
10160 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10161 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10162 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10163 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10164 : : pdcp_test_data_in[i],
10165 : : pdcp_test_data_in_len[i],
10166 : : pdcp_test_data_out[i],
10167 : 0 : pdcp_test_data_in_len[i]+4,
10168 : : 128, 32);
10169 : : }
10170 : :
10171 : : static int
10172 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
10173 : : {
10174 : : int i = 0, size = 0;
10175 : : int err, all_err = TEST_SUCCESS;
10176 : : const struct pdcp_sdap_test *cur_test;
10177 : :
10178 : : size = RTE_DIM(list_pdcp_sdap_tests);
10179 : :
10180 [ # # ]: 0 : for (i = 0; i < size; i++) {
10181 : : cur_test = &list_pdcp_sdap_tests[i];
10182 : 0 : err = test_pdcp_proto(
10183 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10184 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10185 : 0 : cur_test->in_len, cur_test->data_out,
10186 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10187 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
10188 : 0 : cur_test->param.cipher_key_len,
10189 : 0 : cur_test->param.auth_alg,
10190 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10191 : 0 : cur_test->bearer, cur_test->param.domain,
10192 : 0 : cur_test->packet_direction, cur_test->sn_size,
10193 : 0 : cur_test->hfn,
10194 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10195 [ # # ]: 0 : if (err) {
10196 : : printf("\t%d) %s: Encapsulation failed\n",
10197 : 0 : cur_test->test_idx,
10198 : 0 : cur_test->param.name);
10199 : : err = TEST_FAILED;
10200 : : } else {
10201 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10202 : 0 : cur_test->param.name);
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 : : static int
10214 : 0 : test_PDCP_PROTO_short_mac(void)
10215 : : {
10216 : : int i = 0, size = 0;
10217 : : int err, all_err = TEST_SUCCESS;
10218 : : const struct pdcp_short_mac_test *cur_test;
10219 : :
10220 : : size = RTE_DIM(list_pdcp_smac_tests);
10221 : :
10222 [ # # ]: 0 : for (i = 0; i < size; i++) {
10223 : : cur_test = &list_pdcp_smac_tests[i];
10224 : 0 : err = test_pdcp_proto(
10225 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10226 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10227 : 0 : cur_test->in_len, cur_test->data_out,
10228 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10229 : : RTE_CRYPTO_CIPHER_NULL, NULL,
10230 : 0 : 0, cur_test->param.auth_alg,
10231 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10232 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
10233 : : 0, 0, 0);
10234 [ # # ]: 0 : if (err) {
10235 : : printf("\t%d) %s: Short MAC test failed\n",
10236 : 0 : cur_test->test_idx,
10237 : 0 : cur_test->param.name);
10238 : : err = TEST_FAILED;
10239 : : } else {
10240 : : printf("\t%d) %s: Short MAC test PASS\n",
10241 : 0 : cur_test->test_idx,
10242 : 0 : cur_test->param.name);
10243 : 0 : rte_hexdump(stdout, "MAC I",
10244 : 0 : cur_test->data_out + cur_test->in_len + 2,
10245 : : 2);
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 : :
10257 : : static int
10258 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
10259 : : {
10260 : : int i = 0, size = 0;
10261 : : int err, all_err = TEST_SUCCESS;
10262 : : const struct pdcp_sdap_test *cur_test;
10263 : :
10264 : : size = RTE_DIM(list_pdcp_sdap_tests);
10265 : :
10266 [ # # ]: 0 : for (i = 0; i < size; i++) {
10267 : : cur_test = &list_pdcp_sdap_tests[i];
10268 : 0 : err = test_pdcp_proto(
10269 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10270 : : RTE_CRYPTO_AUTH_OP_VERIFY,
10271 : 0 : cur_test->data_out,
10272 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10273 : 0 : cur_test->data_in, cur_test->in_len,
10274 : 0 : cur_test->param.cipher_alg,
10275 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
10276 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
10277 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
10278 : 0 : cur_test->param.domain, cur_test->packet_direction,
10279 : 0 : cur_test->sn_size, cur_test->hfn,
10280 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10281 [ # # ]: 0 : if (err) {
10282 : : printf("\t%d) %s: Decapsulation failed\n",
10283 : 0 : cur_test->test_idx,
10284 : 0 : cur_test->param.name);
10285 : : err = TEST_FAILED;
10286 : : } else {
10287 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10288 : 0 : cur_test->param.name);
10289 : : err = TEST_SUCCESS;
10290 : : }
10291 : 0 : all_err += err;
10292 : : }
10293 : :
10294 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10295 : :
10296 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10297 : : }
10298 : :
10299 : : static int
10300 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10301 : : struct crypto_unittest_params *ut_params,
10302 : : struct rte_security_ipsec_xform *ipsec_xform,
10303 : : const struct ipsec_test_data *td,
10304 : : const struct ipsec_test_flags *flags,
10305 : : int pkt_num)
10306 : : {
10307 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10308 : : enum rte_security_ipsec_sa_direction dir;
10309 : : int ret;
10310 : :
10311 : 0 : dir = ipsec_xform->direction;
10312 : :
10313 : : /* Generate crypto op data structure */
10314 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10315 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10316 [ # # ]: 0 : if (!ut_params->op) {
10317 : : printf("Could not allocate crypto op");
10318 : 0 : return TEST_FAILED;
10319 : : }
10320 : :
10321 : : /* Attach session to operation */
10322 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10323 : :
10324 : : /* Set crypto operation mbufs */
10325 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10326 : 0 : ut_params->op->sym->m_dst = NULL;
10327 : :
10328 : : /* Copy IV in crypto operation when IV generation is disabled */
10329 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10330 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10331 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10332 : : uint8_t *,
10333 : : IV_OFFSET);
10334 : : int len;
10335 : :
10336 [ # # ]: 0 : if (td->aead)
10337 : 0 : len = td->xform.aead.aead.iv.length;
10338 [ # # ]: 0 : else if (td->aes_gmac)
10339 : 0 : len = td->xform.chain.auth.auth.iv.length;
10340 : : else
10341 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10342 : :
10343 : 0 : memcpy(iv, td->iv.data, len);
10344 : : }
10345 : :
10346 : : /* Process crypto operation */
10347 : 0 : process_crypto_request(dev_id, ut_params->op);
10348 : :
10349 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10350 : :
10351 : 0 : rte_crypto_op_free(ut_params->op);
10352 : 0 : ut_params->op = NULL;
10353 : :
10354 : 0 : return ret;
10355 : : }
10356 : :
10357 : : static int
10358 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10359 : : struct crypto_unittest_params *ut_params,
10360 : : void *ctx)
10361 : : {
10362 : : uint64_t timeout, userdata;
10363 : : struct rte_ether_hdr *hdr;
10364 : : struct rte_mbuf *m;
10365 : : void **sec_sess;
10366 : : int ret;
10367 : :
10368 : : RTE_SET_USED(ts_params);
10369 : :
10370 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10371 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10372 : :
10373 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10374 : 0 : ut_params->ibuf->port = 0;
10375 : :
10376 : 0 : sec_sess = &ut_params->sec_session;
10377 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10378 : :
10379 [ # # ]: 0 : if (ret != 1)
10380 : : return TEST_FAILED;
10381 : :
10382 : 0 : ut_params->ibuf = NULL;
10383 : :
10384 : : /* Add a timeout for 1 s */
10385 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10386 : :
10387 : : do {
10388 : : /* Get packet from port 0, queue 0 */
10389 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10390 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10391 : :
10392 [ # # ]: 0 : if (ret == 0) {
10393 : : printf("Could not receive packets from ethdev\n");
10394 : 0 : return TEST_FAILED;
10395 : : }
10396 : :
10397 [ # # ]: 0 : if (m == NULL) {
10398 : : printf("Received mbuf is NULL\n");
10399 : 0 : return TEST_FAILED;
10400 : : }
10401 : :
10402 : 0 : ut_params->ibuf = m;
10403 : :
10404 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10405 : : printf("Received packet is not Rx security processed\n");
10406 : 0 : return TEST_FAILED;
10407 : : }
10408 : :
10409 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10410 : : printf("Received packet has failed Rx security processing\n");
10411 : 0 : return TEST_FAILED;
10412 : : }
10413 : :
10414 : : /*
10415 : : * 'ut_params' is set as userdata. Verify that the field is returned
10416 : : * correctly.
10417 : : */
10418 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10419 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10420 : : printf("Userdata retrieved not matching expected\n");
10421 : 0 : return TEST_FAILED;
10422 : : }
10423 : :
10424 : : /* Trim L2 header */
10425 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10426 : :
10427 : : return TEST_SUCCESS;
10428 : : }
10429 : :
10430 : : static int
10431 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10432 : : struct ipsec_test_data res_d[],
10433 : : int nb_td,
10434 : : bool silent,
10435 : : const struct ipsec_test_flags *flags)
10436 : : {
10437 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10438 : : 0x0000, 0x001a};
10439 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10440 : : 0xe82c, 0x4887};
10441 : : const struct rte_ipv4_hdr *ipv4 =
10442 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10443 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10444 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10445 : : struct crypto_unittest_params *ut_params = &unittest_params;
10446 : : struct rte_security_capability_idx sec_cap_idx;
10447 : : const struct rte_security_capability *sec_cap;
10448 : : struct rte_security_ipsec_xform ipsec_xform;
10449 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10450 : : enum rte_security_ipsec_sa_direction dir;
10451 : : struct ipsec_test_data *res_d_tmp = NULL;
10452 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10453 : : int salt_len, i, ret = TEST_SUCCESS;
10454 : : void *ctx;
10455 : : uint32_t src, dst;
10456 : : uint32_t verify;
10457 : :
10458 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10459 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10460 : :
10461 : : /* Use first test data to create session */
10462 : :
10463 : : /* Copy IPsec xform */
10464 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10465 : :
10466 : 0 : dir = ipsec_xform.direction;
10467 : 0 : verify = flags->tunnel_hdr_verify;
10468 : :
10469 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10470 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10471 : :
10472 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10473 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10474 : 0 : src += 1;
10475 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10476 : 0 : dst += 1;
10477 : : }
10478 : :
10479 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10480 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10481 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10482 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10483 : : sizeof(src));
10484 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10485 : : sizeof(dst));
10486 : :
10487 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10488 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10489 : :
10490 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10491 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10492 : :
10493 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10494 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10495 : :
10496 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10497 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10498 : : TEST_IPSEC_DSCP_VAL;
10499 : :
10500 : : } else {
10501 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10502 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10503 : :
10504 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10505 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10506 : : TEST_IPSEC_DSCP_VAL;
10507 : :
10508 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10509 : : sizeof(v6_src));
10510 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10511 : : sizeof(v6_dst));
10512 : : }
10513 : : }
10514 : :
10515 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10516 : :
10517 : 0 : sec_cap_idx.action = ut_params->type;
10518 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10519 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10520 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10521 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10522 : :
10523 [ # # ]: 0 : if (flags->udp_encap)
10524 : 0 : ipsec_xform.options.udp_encap = 1;
10525 : :
10526 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10527 [ # # ]: 0 : if (sec_cap == NULL)
10528 : : return TEST_SKIPPED;
10529 : :
10530 : : /* Copy cipher session parameters */
10531 [ # # ]: 0 : if (td[0].aead) {
10532 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10533 : : sizeof(ut_params->aead_xform));
10534 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10535 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10536 : :
10537 : : /* Verify crypto capabilities */
10538 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10539 [ # # ]: 0 : if (!silent)
10540 : 0 : RTE_LOG(INFO, USER1,
10541 : : "Crypto capabilities not supported\n");
10542 : 0 : return TEST_SKIPPED;
10543 : : }
10544 [ # # ]: 0 : } else if (td[0].auth_only) {
10545 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10546 : : sizeof(ut_params->auth_xform));
10547 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10548 : :
10549 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10550 [ # # ]: 0 : if (!silent)
10551 : 0 : RTE_LOG(INFO, USER1,
10552 : : "Auth crypto capabilities not supported\n");
10553 : 0 : return TEST_SKIPPED;
10554 : : }
10555 : : } else {
10556 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10557 : : sizeof(ut_params->cipher_xform));
10558 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10559 : : sizeof(ut_params->auth_xform));
10560 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10561 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10562 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10563 : :
10564 : : /* Verify crypto capabilities */
10565 : :
10566 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10567 [ # # ]: 0 : if (!silent)
10568 : 0 : RTE_LOG(INFO, USER1,
10569 : : "Cipher crypto capabilities not supported\n");
10570 : 0 : return TEST_SKIPPED;
10571 : : }
10572 : :
10573 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10574 [ # # ]: 0 : if (!silent)
10575 : 0 : RTE_LOG(INFO, USER1,
10576 : : "Auth crypto capabilities not supported\n");
10577 : 0 : return TEST_SKIPPED;
10578 : : }
10579 : : }
10580 : :
10581 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10582 : : return TEST_SKIPPED;
10583 : :
10584 : 0 : struct rte_security_session_conf sess_conf = {
10585 : 0 : .action_type = ut_params->type,
10586 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10587 : : };
10588 : :
10589 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac ||
10590 [ # # ]: 0 : (td[0].xform.chain.cipher.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR)) {
10591 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10592 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10593 : : }
10594 : :
10595 [ # # ]: 0 : if (td[0].aead) {
10596 : 0 : sess_conf.ipsec = ipsec_xform;
10597 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10598 [ # # ]: 0 : } else if (td[0].auth_only) {
10599 : 0 : sess_conf.ipsec = ipsec_xform;
10600 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10601 : : } else {
10602 : 0 : sess_conf.ipsec = ipsec_xform;
10603 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10604 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10605 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10606 : : } else {
10607 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10608 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10609 : : }
10610 : : }
10611 : :
10612 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10613 : 0 : sess_conf.userdata = ut_params;
10614 : :
10615 : : /* Create security session */
10616 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10617 : : ts_params->session_mpool);
10618 : :
10619 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10620 : : return TEST_SKIPPED;
10621 : :
10622 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10623 [ # # # # ]: 0 : if (flags->antireplay &&
10624 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10625 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10626 : 0 : ret = rte_security_session_update(ctx,
10627 : : ut_params->sec_session, &sess_conf);
10628 [ # # ]: 0 : if (ret) {
10629 : : printf("Could not update sequence number in "
10630 : : "session\n");
10631 : 0 : return TEST_SKIPPED;
10632 : : }
10633 : : }
10634 : :
10635 : : /* Copy test data before modification */
10636 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10637 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10638 : : ret = TEST_FAILED;
10639 : 0 : goto mbuf_free;
10640 : : }
10641 : :
10642 : : /* Setup source mbuf payload */
10643 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10644 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10645 : 0 : td[i].input_text.len, nb_segs, input_text);
10646 : : } else {
10647 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10648 : 0 : td[i].input_text.len, nb_segs, 0);
10649 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10650 : : }
10651 : :
10652 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10653 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10654 : : ctx);
10655 : : else
10656 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10657 : : ut_params,
10658 : : &ipsec_xform,
10659 : : &td[i], flags,
10660 : : i + 1);
10661 : :
10662 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10663 : 0 : goto mbuf_free;
10664 : :
10665 [ # # ]: 0 : if (res_d != NULL)
10666 : 0 : res_d_tmp = &res_d[i];
10667 : :
10668 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10669 : : res_d_tmp, silent, flags);
10670 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10671 : 0 : goto mbuf_free;
10672 : :
10673 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10674 : : flags, dir);
10675 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10676 : 0 : goto mbuf_free;
10677 : :
10678 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10679 : 0 : ut_params->ibuf = NULL;
10680 : : }
10681 : :
10682 : 0 : mbuf_free:
10683 [ # # ]: 0 : if (flags->use_ext_mbuf)
10684 : 0 : ext_mbuf_memzone_free(nb_segs);
10685 : :
10686 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10687 : 0 : ut_params->ibuf = NULL;
10688 : :
10689 [ # # ]: 0 : if (ut_params->sec_session)
10690 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10691 : 0 : ut_params->sec_session = NULL;
10692 : :
10693 : 0 : return ret;
10694 : : }
10695 : :
10696 : : static int
10697 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10698 : : {
10699 : : struct ipsec_test_data td_outb;
10700 : : struct ipsec_test_flags flags;
10701 : :
10702 : : memset(&flags, 0, sizeof(flags));
10703 : :
10704 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10705 : :
10706 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10707 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10708 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10709 : : /* Disable IV gen to be able to test with known vectors */
10710 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10711 : : }
10712 : :
10713 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10714 : : }
10715 : :
10716 : : static int
10717 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10718 : : {
10719 : : struct ipsec_test_data td_outb;
10720 : : struct ipsec_test_flags flags;
10721 : :
10722 : : memset(&flags, 0, sizeof(flags));
10723 [ # # ]: 0 : flags.use_ext_mbuf = true;
10724 : :
10725 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10726 : :
10727 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10728 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10729 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10730 : : /* Disable IV gen to be able to test with known vectors */
10731 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10732 : : }
10733 : :
10734 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10735 : : }
10736 : :
10737 : : static int
10738 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10739 : : {
10740 : : const struct ipsec_test_data *td = test_data;
10741 : : struct ipsec_test_flags flags;
10742 : : struct ipsec_test_data td_inb;
10743 : :
10744 : : memset(&flags, 0, sizeof(flags));
10745 : :
10746 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10747 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10748 : : else
10749 : : memcpy(&td_inb, td, sizeof(td_inb));
10750 : :
10751 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10752 : : }
10753 : :
10754 : : static int
10755 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10756 : : {
10757 : : struct ipsec_test_data td_outb;
10758 : : struct ipsec_test_flags flags;
10759 : :
10760 : : memset(&flags, 0, sizeof(flags));
10761 : 0 : flags.fragment = true;
10762 : :
10763 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10764 : :
10765 : : /* Disable IV gen to be able to test with known vectors */
10766 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10767 : :
10768 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10769 : : }
10770 : :
10771 : : static int
10772 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10773 : : {
10774 : : const struct ipsec_test_data *td = test_data;
10775 : : struct ipsec_test_flags flags;
10776 : : struct ipsec_test_data td_inb;
10777 : :
10778 : : memset(&flags, 0, sizeof(flags));
10779 : 0 : flags.rx_inject = true;
10780 : :
10781 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10782 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10783 : : else
10784 : : memcpy(&td_inb, td, sizeof(td_inb));
10785 : :
10786 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10787 : : }
10788 : :
10789 : : static int
10790 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject_multi_seg(const void *test_data)
10791 : : {
10792 : : const struct ipsec_test_data *td = test_data;
10793 : : struct ipsec_test_flags flags;
10794 : : struct ipsec_test_data td_inb;
10795 : :
10796 : : memset(&flags, 0, sizeof(flags));
10797 : 0 : flags.rx_inject = true;
10798 : 0 : flags.nb_segs_in_mbuf = 4;
10799 : :
10800 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10801 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10802 : : else
10803 : : memcpy(&td_inb, td, sizeof(td_inb));
10804 : :
10805 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10806 : : }
10807 : :
10808 : : static int
10809 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10810 : : {
10811 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10812 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10813 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10814 : : int ret;
10815 : :
10816 [ # # ]: 0 : if (flags->iv_gen ||
10817 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10818 : : flags->sa_expiry_pkts_hard)
10819 : : nb_pkts = TEST_SEC_PKTS_MAX;
10820 : :
10821 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10822 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10823 : : sec_alg_list[i].param2,
10824 : : flags,
10825 : : td_outb,
10826 : : nb_pkts);
10827 : :
10828 [ # # ]: 0 : if (!td_outb->aead) {
10829 : : enum rte_crypto_cipher_algorithm cipher_alg;
10830 : : enum rte_crypto_auth_algorithm auth_alg;
10831 : :
10832 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10833 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10834 : :
10835 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10836 : 0 : continue;
10837 : :
10838 : : /* ICV is not applicable for NULL auth */
10839 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10840 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10841 : 0 : continue;
10842 : :
10843 : : /* IV is not applicable for NULL cipher */
10844 [ # # # # ]: 0 : if (flags->iv_gen &&
10845 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10846 : 0 : continue;
10847 : : }
10848 : :
10849 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10850 : : flags);
10851 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10852 : 0 : continue;
10853 : :
10854 [ # # ]: 0 : if (ret == TEST_FAILED)
10855 : : return TEST_FAILED;
10856 : :
10857 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10858 : :
10859 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10860 : : flags);
10861 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10862 : 0 : continue;
10863 : :
10864 [ # # ]: 0 : if (ret == TEST_FAILED)
10865 : : return TEST_FAILED;
10866 : :
10867 [ # # ]: 0 : if (flags->display_alg)
10868 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10869 : :
10870 : 0 : pass_cnt++;
10871 : : }
10872 : :
10873 [ # # ]: 0 : if (pass_cnt > 0)
10874 : : return TEST_SUCCESS;
10875 : : else
10876 : 0 : return TEST_SKIPPED;
10877 : : }
10878 : :
10879 : : static int
10880 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10881 : : {
10882 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10883 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10884 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10885 : : int ret;
10886 : :
10887 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10888 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10889 : : sec_auth_only_alg_list[i].param2,
10890 : : flags,
10891 : : td_outb,
10892 : : nb_pkts);
10893 : :
10894 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10895 : : flags);
10896 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10897 : 0 : continue;
10898 : :
10899 [ # # ]: 0 : if (ret == TEST_FAILED)
10900 : : return TEST_FAILED;
10901 : :
10902 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10903 : :
10904 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10905 : : flags);
10906 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10907 : 0 : continue;
10908 : :
10909 [ # # ]: 0 : if (ret == TEST_FAILED)
10910 : : return TEST_FAILED;
10911 : :
10912 [ # # ]: 0 : if (flags->display_alg)
10913 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10914 : : sec_auth_only_alg_list[i].param2);
10915 : :
10916 : 0 : pass_cnt++;
10917 : : }
10918 : :
10919 [ # # ]: 0 : if (pass_cnt > 0)
10920 : : return TEST_SUCCESS;
10921 : : else
10922 : 0 : return TEST_SKIPPED;
10923 : : }
10924 : :
10925 : : static int
10926 : 0 : test_ipsec_proto_display_list(void)
10927 : : {
10928 : : struct ipsec_test_flags flags;
10929 : :
10930 : : memset(&flags, 0, sizeof(flags));
10931 : :
10932 : 0 : flags.display_alg = true;
10933 : :
10934 : 0 : return test_ipsec_proto_all(&flags);
10935 : : }
10936 : :
10937 : : static int
10938 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10939 : : {
10940 : : struct ipsec_test_flags flags;
10941 : :
10942 : : memset(&flags, 0, sizeof(flags));
10943 : :
10944 : 0 : flags.ah = true;
10945 : 0 : flags.display_alg = true;
10946 : :
10947 : 0 : return test_ipsec_ah_proto_all(&flags);
10948 : : }
10949 : :
10950 : : static int
10951 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10952 : : {
10953 : : struct ipsec_test_flags flags;
10954 : :
10955 : : memset(&flags, 0, sizeof(flags));
10956 : :
10957 : 0 : flags.ah = true;
10958 : 0 : flags.transport = true;
10959 : :
10960 : 0 : return test_ipsec_ah_proto_all(&flags);
10961 : : }
10962 : :
10963 : : static int
10964 : 0 : test_ipsec_proto_iv_gen(void)
10965 : : {
10966 : : struct ipsec_test_flags flags;
10967 : :
10968 : : memset(&flags, 0, sizeof(flags));
10969 : :
10970 : 0 : flags.iv_gen = true;
10971 : :
10972 : 0 : return test_ipsec_proto_all(&flags);
10973 : : }
10974 : :
10975 : : static int
10976 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10977 : : {
10978 : : struct ipsec_test_flags flags;
10979 : :
10980 : : memset(&flags, 0, sizeof(flags));
10981 : :
10982 : 0 : flags.sa_expiry_pkts_soft = true;
10983 : :
10984 : 0 : return test_ipsec_proto_all(&flags);
10985 : : }
10986 : :
10987 : : static int
10988 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10989 : : {
10990 : : struct ipsec_test_flags flags;
10991 : :
10992 : : memset(&flags, 0, sizeof(flags));
10993 : :
10994 : 0 : flags.sa_expiry_pkts_hard = true;
10995 : :
10996 : 0 : return test_ipsec_proto_all(&flags);
10997 : : }
10998 : :
10999 : : static int
11000 : 0 : test_ipsec_proto_err_icv_corrupt(void)
11001 : : {
11002 : : struct ipsec_test_flags flags;
11003 : :
11004 : : memset(&flags, 0, sizeof(flags));
11005 : :
11006 : 0 : flags.icv_corrupt = true;
11007 : :
11008 : 0 : return test_ipsec_proto_all(&flags);
11009 : : }
11010 : :
11011 : : static int
11012 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
11013 : : {
11014 : : struct ipsec_test_flags flags;
11015 : :
11016 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11017 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
11018 : : return TEST_SKIPPED;
11019 : :
11020 : : memset(&flags, 0, sizeof(flags));
11021 : :
11022 : 0 : flags.udp_encap = true;
11023 : 0 : flags.udp_encap_custom_ports = true;
11024 : :
11025 : 0 : return test_ipsec_proto_all(&flags);
11026 : : }
11027 : :
11028 : : static int
11029 : 0 : test_ipsec_proto_udp_encap(void)
11030 : : {
11031 : : struct ipsec_test_flags flags;
11032 : :
11033 : : memset(&flags, 0, sizeof(flags));
11034 : :
11035 : 0 : flags.udp_encap = true;
11036 : :
11037 : 0 : return test_ipsec_proto_all(&flags);
11038 : : }
11039 : :
11040 : : static int
11041 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
11042 : : {
11043 : : struct ipsec_test_flags flags;
11044 : :
11045 : : memset(&flags, 0, sizeof(flags));
11046 : :
11047 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
11048 : :
11049 : 0 : return test_ipsec_proto_all(&flags);
11050 : : }
11051 : :
11052 : : static int
11053 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
11054 : : {
11055 : : struct ipsec_test_flags flags;
11056 : :
11057 : : memset(&flags, 0, sizeof(flags));
11058 : :
11059 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
11060 : :
11061 : 0 : return test_ipsec_proto_all(&flags);
11062 : : }
11063 : :
11064 : : static int
11065 : 0 : test_ipsec_proto_udp_ports_verify(void)
11066 : : {
11067 : : struct ipsec_test_flags flags;
11068 : :
11069 : : memset(&flags, 0, sizeof(flags));
11070 : :
11071 : 0 : flags.udp_encap = true;
11072 : 0 : flags.udp_ports_verify = true;
11073 : :
11074 : 0 : return test_ipsec_proto_all(&flags);
11075 : : }
11076 : :
11077 : : static int
11078 : 0 : test_ipsec_proto_inner_ip_csum(void)
11079 : : {
11080 : : struct ipsec_test_flags flags;
11081 : :
11082 : : memset(&flags, 0, sizeof(flags));
11083 : :
11084 : 0 : flags.ip_csum = true;
11085 : :
11086 : 0 : return test_ipsec_proto_all(&flags);
11087 : : }
11088 : :
11089 : : static int
11090 : 0 : test_ipsec_proto_inner_l4_csum(void)
11091 : : {
11092 : : struct ipsec_test_flags flags;
11093 : :
11094 : : memset(&flags, 0, sizeof(flags));
11095 : :
11096 : 0 : flags.l4_csum = true;
11097 : :
11098 : 0 : return test_ipsec_proto_all(&flags);
11099 : : }
11100 : :
11101 : : static int
11102 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
11103 : : {
11104 : : struct ipsec_test_flags flags;
11105 : :
11106 : : memset(&flags, 0, sizeof(flags));
11107 : :
11108 : : flags.ipv6 = false;
11109 : : flags.tunnel_ipv6 = false;
11110 : :
11111 : 0 : return test_ipsec_proto_all(&flags);
11112 : : }
11113 : :
11114 : : static int
11115 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
11116 : : {
11117 : : struct ipsec_test_flags flags;
11118 : :
11119 : : memset(&flags, 0, sizeof(flags));
11120 : :
11121 : 0 : flags.ipv6 = true;
11122 : 0 : flags.tunnel_ipv6 = true;
11123 : :
11124 : 0 : return test_ipsec_proto_all(&flags);
11125 : : }
11126 : :
11127 : : static int
11128 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
11129 : : {
11130 : : struct ipsec_test_flags flags;
11131 : :
11132 : : memset(&flags, 0, sizeof(flags));
11133 : :
11134 : : flags.ipv6 = false;
11135 : 0 : flags.tunnel_ipv6 = true;
11136 : :
11137 : 0 : return test_ipsec_proto_all(&flags);
11138 : : }
11139 : :
11140 : : static int
11141 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
11142 : : {
11143 : : struct ipsec_test_flags flags;
11144 : :
11145 : : memset(&flags, 0, sizeof(flags));
11146 : :
11147 : 0 : flags.ipv6 = true;
11148 : : flags.tunnel_ipv6 = false;
11149 : :
11150 : 0 : return test_ipsec_proto_all(&flags);
11151 : : }
11152 : :
11153 : : static int
11154 : 0 : test_ipsec_proto_transport_v4(void)
11155 : : {
11156 : : struct ipsec_test_flags flags;
11157 : :
11158 : : memset(&flags, 0, sizeof(flags));
11159 : :
11160 : : flags.ipv6 = false;
11161 : 0 : flags.transport = true;
11162 : :
11163 : 0 : return test_ipsec_proto_all(&flags);
11164 : : }
11165 : :
11166 : : static int
11167 : 0 : test_ipsec_proto_transport_l4_csum(void)
11168 : : {
11169 : 0 : struct ipsec_test_flags flags = {
11170 : : .l4_csum = true,
11171 : : .transport = true,
11172 : : };
11173 : :
11174 : 0 : return test_ipsec_proto_all(&flags);
11175 : : }
11176 : :
11177 : : static int
11178 : 0 : test_ipsec_proto_stats(void)
11179 : : {
11180 : : struct ipsec_test_flags flags;
11181 : :
11182 : : memset(&flags, 0, sizeof(flags));
11183 : :
11184 : 0 : flags.stats_success = true;
11185 : :
11186 : 0 : return test_ipsec_proto_all(&flags);
11187 : : }
11188 : :
11189 : : static int
11190 : 0 : test_ipsec_proto_pkt_fragment(void)
11191 : : {
11192 : : struct ipsec_test_flags flags;
11193 : :
11194 : : memset(&flags, 0, sizeof(flags));
11195 : :
11196 : 0 : flags.fragment = true;
11197 : :
11198 : 0 : return test_ipsec_proto_all(&flags);
11199 : :
11200 : : }
11201 : :
11202 : : static int
11203 : 0 : test_ipsec_proto_copy_df_inner_0(void)
11204 : : {
11205 : : struct ipsec_test_flags flags;
11206 : :
11207 : : memset(&flags, 0, sizeof(flags));
11208 : :
11209 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11210 : :
11211 : 0 : return test_ipsec_proto_all(&flags);
11212 : : }
11213 : :
11214 : : static int
11215 : 0 : test_ipsec_proto_copy_df_inner_1(void)
11216 : : {
11217 : : struct ipsec_test_flags flags;
11218 : :
11219 : : memset(&flags, 0, sizeof(flags));
11220 : :
11221 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11222 : :
11223 : 0 : return test_ipsec_proto_all(&flags);
11224 : : }
11225 : :
11226 : : static int
11227 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
11228 : : {
11229 : : struct ipsec_test_flags flags;
11230 : :
11231 : : memset(&flags, 0, sizeof(flags));
11232 : :
11233 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11234 : :
11235 : 0 : return test_ipsec_proto_all(&flags);
11236 : : }
11237 : :
11238 : : static int
11239 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
11240 : : {
11241 : : struct ipsec_test_flags flags;
11242 : :
11243 : : memset(&flags, 0, sizeof(flags));
11244 : :
11245 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11246 : :
11247 : 0 : return test_ipsec_proto_all(&flags);
11248 : : }
11249 : :
11250 : : static int
11251 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11252 : : {
11253 : : struct ipsec_test_flags flags;
11254 : :
11255 : : memset(&flags, 0, sizeof(flags));
11256 : :
11257 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11258 : :
11259 : 0 : return test_ipsec_proto_all(&flags);
11260 : : }
11261 : :
11262 : : static int
11263 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11264 : : {
11265 : : struct ipsec_test_flags flags;
11266 : :
11267 : : memset(&flags, 0, sizeof(flags));
11268 : :
11269 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11270 : :
11271 : 0 : return test_ipsec_proto_all(&flags);
11272 : : }
11273 : :
11274 : : static int
11275 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11276 : : {
11277 : : struct ipsec_test_flags flags;
11278 : :
11279 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11280 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11281 : : return TEST_SKIPPED;
11282 : :
11283 : : memset(&flags, 0, sizeof(flags));
11284 : :
11285 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11286 : :
11287 : 0 : return test_ipsec_proto_all(&flags);
11288 : : }
11289 : :
11290 : : static int
11291 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11292 : : {
11293 : : struct ipsec_test_flags flags;
11294 : :
11295 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11296 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11297 : : return TEST_SKIPPED;
11298 : :
11299 : : memset(&flags, 0, sizeof(flags));
11300 : :
11301 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11302 : :
11303 : 0 : return test_ipsec_proto_all(&flags);
11304 : : }
11305 : :
11306 : : static int
11307 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11308 : : {
11309 : : struct ipsec_test_flags flags;
11310 : :
11311 : : memset(&flags, 0, sizeof(flags));
11312 : :
11313 : 0 : flags.ipv6 = true;
11314 : 0 : flags.tunnel_ipv6 = true;
11315 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11316 : :
11317 : 0 : return test_ipsec_proto_all(&flags);
11318 : : }
11319 : :
11320 : : static int
11321 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11322 : : {
11323 : : struct ipsec_test_flags flags;
11324 : :
11325 : : memset(&flags, 0, sizeof(flags));
11326 : :
11327 : 0 : flags.ipv6 = true;
11328 : 0 : flags.tunnel_ipv6 = true;
11329 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11330 : :
11331 : 0 : return test_ipsec_proto_all(&flags);
11332 : : }
11333 : :
11334 : : static int
11335 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11336 : : {
11337 : : struct ipsec_test_flags flags;
11338 : :
11339 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11340 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11341 : : return TEST_SKIPPED;
11342 : :
11343 : : memset(&flags, 0, sizeof(flags));
11344 : :
11345 : 0 : flags.ipv6 = true;
11346 : 0 : flags.tunnel_ipv6 = true;
11347 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11348 : :
11349 : 0 : return test_ipsec_proto_all(&flags);
11350 : : }
11351 : :
11352 : : static int
11353 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11354 : : {
11355 : : struct ipsec_test_flags flags;
11356 : :
11357 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11358 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11359 : : return TEST_SKIPPED;
11360 : :
11361 : : memset(&flags, 0, sizeof(flags));
11362 : :
11363 : 0 : flags.ipv6 = true;
11364 : 0 : flags.tunnel_ipv6 = true;
11365 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11366 : :
11367 : 0 : return test_ipsec_proto_all(&flags);
11368 : : }
11369 : :
11370 : : static int
11371 : 0 : test_ipsec_proto_sgl(void)
11372 : : {
11373 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11374 : : struct rte_cryptodev_info dev_info;
11375 : :
11376 : 0 : struct ipsec_test_flags flags = {
11377 : : .nb_segs_in_mbuf = 5
11378 : : };
11379 : :
11380 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11381 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11382 : : printf("Device doesn't support in-place scatter-gather. "
11383 : : "Test Skipped.\n");
11384 : 0 : return TEST_SKIPPED;
11385 : : }
11386 : :
11387 : 0 : return test_ipsec_proto_all(&flags);
11388 : : }
11389 : :
11390 : : static int
11391 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11392 : : {
11393 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11394 : : struct rte_cryptodev_info dev_info;
11395 : :
11396 : 0 : struct ipsec_test_flags flags = {
11397 : : .nb_segs_in_mbuf = 5,
11398 : : .use_ext_mbuf = 1
11399 : : };
11400 : :
11401 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11402 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11403 : : printf("Device doesn't support in-place scatter-gather. "
11404 : : "Test Skipped.\n");
11405 : 0 : return TEST_SKIPPED;
11406 : : }
11407 : :
11408 : 0 : return test_ipsec_proto_all(&flags);
11409 : : }
11410 : :
11411 : : static int
11412 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11413 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11414 : : uint64_t winsz)
11415 : : {
11416 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11417 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11418 : : struct ipsec_test_flags flags;
11419 : : uint32_t i = 0, ret = 0;
11420 : :
11421 [ # # ]: 0 : if (nb_pkts == 0)
11422 : : return TEST_FAILED;
11423 : :
11424 : : memset(&flags, 0, sizeof(flags));
11425 : 0 : flags.antireplay = true;
11426 : :
11427 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11428 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11429 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11430 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11431 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11432 : : }
11433 : :
11434 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11435 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11436 : :
11437 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11438 : : &flags);
11439 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11440 : : return ret;
11441 : :
11442 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11443 : :
11444 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11445 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11446 : : /* Set antireplay flag for packets to be dropped */
11447 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11448 : : }
11449 : :
11450 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11451 : : &flags);
11452 : :
11453 : 0 : return ret;
11454 : : }
11455 : :
11456 : : static int
11457 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11458 : : {
11459 : :
11460 : : uint32_t nb_pkts = 5;
11461 : : bool replayed_pkt[5];
11462 : : uint64_t esn[5];
11463 : :
11464 : : /* 1. Advance the TOP of the window to WS * 2 */
11465 : 0 : esn[0] = winsz * 2;
11466 : : /* 2. Test sequence number within the new window(WS + 1) */
11467 : 0 : esn[1] = winsz + 1;
11468 : : /* 3. Test sequence number less than the window BOTTOM */
11469 : 0 : esn[2] = winsz;
11470 : : /* 4. Test sequence number in the middle of the window */
11471 : 0 : esn[3] = winsz + (winsz / 2);
11472 : : /* 5. Test replay of the packet in the middle of the window */
11473 : 0 : esn[4] = winsz + (winsz / 2);
11474 : :
11475 : 0 : replayed_pkt[0] = false;
11476 : 0 : replayed_pkt[1] = false;
11477 : 0 : replayed_pkt[2] = true;
11478 : 0 : replayed_pkt[3] = false;
11479 : 0 : replayed_pkt[4] = true;
11480 : :
11481 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11482 : : false, winsz);
11483 : : }
11484 : :
11485 : : static int
11486 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11487 : : {
11488 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11489 : : }
11490 : :
11491 : : static int
11492 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11493 : : {
11494 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11495 : : }
11496 : :
11497 : : static int
11498 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11499 : : {
11500 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11501 : : }
11502 : :
11503 : : static int
11504 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11505 : : {
11506 : :
11507 : : uint32_t nb_pkts = 7;
11508 : : bool replayed_pkt[7];
11509 : : uint64_t esn[7];
11510 : :
11511 : : /* Set the initial sequence number */
11512 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11513 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11514 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11515 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11516 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11517 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11518 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11519 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11520 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11521 : : /* 5. Test with duplicate sequence number within
11522 : : * new window (1<<32 - 1)
11523 : : */
11524 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11525 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11526 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11527 : :
11528 : 0 : replayed_pkt[0] = false;
11529 : 0 : replayed_pkt[1] = false;
11530 : 0 : replayed_pkt[2] = false;
11531 : 0 : replayed_pkt[3] = false;
11532 : 0 : replayed_pkt[4] = false;
11533 : 0 : replayed_pkt[5] = true;
11534 : 0 : replayed_pkt[6] = true;
11535 : :
11536 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11537 : : true, winsz);
11538 : : }
11539 : :
11540 : : static int
11541 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11542 : : {
11543 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11544 : : }
11545 : :
11546 : : static int
11547 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11548 : : {
11549 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11550 : : }
11551 : :
11552 : : static int
11553 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11554 : : {
11555 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11556 : : }
11557 : :
11558 : : static int
11559 : 0 : test_PDCP_PROTO_all(void)
11560 : : {
11561 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11562 : : struct crypto_unittest_params *ut_params = &unittest_params;
11563 : : struct rte_cryptodev_info dev_info;
11564 : : int status;
11565 : :
11566 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11567 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11568 : :
11569 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11570 : : return TEST_SKIPPED;
11571 : :
11572 : : /* Set action type */
11573 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11574 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11575 : : gbl_action_type;
11576 : :
11577 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11578 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11579 : : return TEST_SKIPPED;
11580 : :
11581 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11582 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11583 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11584 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11585 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11586 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11587 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11588 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11589 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11590 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11591 : 0 : status += test_PDCP_PROTO_short_mac();
11592 : :
11593 [ # # ]: 0 : if (status)
11594 : : return TEST_FAILED;
11595 : : else
11596 : 0 : return TEST_SUCCESS;
11597 : : }
11598 : :
11599 : : static int
11600 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11601 : : {
11602 : 0 : struct ipsec_test_flags flags = {
11603 : : .dec_ttl_or_hop_limit = true
11604 : : };
11605 : :
11606 : 0 : return test_ipsec_proto_all(&flags);
11607 : : }
11608 : :
11609 : : static int
11610 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11611 : : {
11612 : 0 : struct ipsec_test_flags flags = {
11613 : : .ipv6 = true,
11614 : : .dec_ttl_or_hop_limit = true
11615 : : };
11616 : :
11617 : 0 : return test_ipsec_proto_all(&flags);
11618 : : }
11619 : :
11620 : : static int
11621 : 0 : test_docsis_proto_uplink(const void *data)
11622 : : {
11623 : : const struct docsis_test_data *d_td = data;
11624 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11625 : : struct crypto_unittest_params *ut_params = &unittest_params;
11626 : : uint8_t *plaintext = NULL;
11627 : : uint8_t *ciphertext = NULL;
11628 : : uint8_t *iv_ptr;
11629 : : int32_t cipher_len, crc_len;
11630 : : uint32_t crc_data_len;
11631 : : int ret = TEST_SUCCESS;
11632 : :
11633 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11634 : :
11635 : : /* Verify the capabilities */
11636 : : struct rte_security_capability_idx sec_cap_idx;
11637 : : const struct rte_security_capability *sec_cap;
11638 : : const struct rte_cryptodev_capabilities *crypto_cap;
11639 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11640 : : int j = 0;
11641 : :
11642 : : /* Set action type */
11643 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11644 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11645 : : gbl_action_type;
11646 : :
11647 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11648 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11649 : : return TEST_SKIPPED;
11650 : :
11651 : 0 : sec_cap_idx.action = ut_params->type;
11652 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11653 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11654 : :
11655 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11656 [ # # ]: 0 : if (sec_cap == NULL)
11657 : : return TEST_SKIPPED;
11658 : :
11659 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11660 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11661 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11662 : : crypto_cap->sym.xform_type ==
11663 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11664 : : crypto_cap->sym.cipher.algo ==
11665 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11666 : 0 : sym_cap = &crypto_cap->sym;
11667 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11668 : 0 : d_td->key.len,
11669 : 0 : d_td->iv.len) == 0)
11670 : : break;
11671 : : }
11672 : : }
11673 : :
11674 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11675 : : return TEST_SKIPPED;
11676 : :
11677 : : /* Setup source mbuf payload */
11678 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11679 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11680 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11681 : :
11682 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11683 : 0 : d_td->ciphertext.len);
11684 : :
11685 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11686 : :
11687 : : /* Setup cipher session parameters */
11688 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11689 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11690 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11691 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11692 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11693 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11694 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11695 : 0 : ut_params->cipher_xform.next = NULL;
11696 : :
11697 : : /* Setup DOCSIS session parameters */
11698 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11699 : :
11700 : 0 : struct rte_security_session_conf sess_conf = {
11701 : 0 : .action_type = ut_params->type,
11702 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11703 : : .docsis = ut_params->docsis_xform,
11704 : : .crypto_xform = &ut_params->cipher_xform,
11705 : : };
11706 : :
11707 : : /* Create security session */
11708 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11709 : : ts_params->session_mpool);
11710 : :
11711 [ # # ]: 0 : if (!ut_params->sec_session) {
11712 : : printf("Test function %s line %u: failed to allocate session\n",
11713 : : __func__, __LINE__);
11714 : : ret = TEST_FAILED;
11715 : 0 : goto on_err;
11716 : : }
11717 : :
11718 : : /* Generate crypto op data structure */
11719 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11720 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11721 [ # # ]: 0 : if (!ut_params->op) {
11722 : : printf("Test function %s line %u: failed to allocate symmetric "
11723 : : "crypto operation\n", __func__, __LINE__);
11724 : : ret = TEST_FAILED;
11725 : 0 : goto on_err;
11726 : : }
11727 : :
11728 : : /* Setup CRC operation parameters */
11729 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11730 : 0 : (d_td->ciphertext.len -
11731 : 0 : d_td->ciphertext.crc_offset -
11732 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11733 : : 0;
11734 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11735 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11736 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11737 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11738 : :
11739 : : /* Setup cipher operation parameters */
11740 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11741 : 0 : (d_td->ciphertext.len -
11742 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11743 : : 0;
11744 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11745 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11746 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11747 : :
11748 : : /* Setup cipher IV */
11749 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11750 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11751 : :
11752 : : /* Attach session to operation */
11753 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11754 : :
11755 : : /* Set crypto operation mbufs */
11756 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11757 : 0 : ut_params->op->sym->m_dst = NULL;
11758 : :
11759 : : /* Process crypto operation */
11760 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11761 : : NULL) {
11762 : : printf("Test function %s line %u: failed to process security "
11763 : : "crypto op\n", __func__, __LINE__);
11764 : : ret = TEST_FAILED;
11765 : 0 : goto on_err;
11766 : : }
11767 : :
11768 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11769 : : printf("Test function %s line %u: failed to process crypto op\n",
11770 : : __func__, __LINE__);
11771 : : ret = TEST_FAILED;
11772 : 0 : goto on_err;
11773 : : }
11774 : :
11775 : : /* Validate plaintext */
11776 : : plaintext = ciphertext;
11777 : :
11778 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11779 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11780 : : printf("Test function %s line %u: plaintext not as expected\n",
11781 : : __func__, __LINE__);
11782 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11783 : 0 : d_td->plaintext.len);
11784 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11785 : : ret = TEST_FAILED;
11786 : 0 : goto on_err;
11787 : : }
11788 : :
11789 : 0 : on_err:
11790 : 0 : rte_crypto_op_free(ut_params->op);
11791 : 0 : ut_params->op = NULL;
11792 : :
11793 [ # # ]: 0 : if (ut_params->sec_session)
11794 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11795 : 0 : ut_params->sec_session = NULL;
11796 : :
11797 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11798 : 0 : ut_params->ibuf = NULL;
11799 : :
11800 : 0 : return ret;
11801 : : }
11802 : :
11803 : : static int
11804 : 0 : test_docsis_proto_downlink(const void *data)
11805 : : {
11806 : : const struct docsis_test_data *d_td = data;
11807 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11808 : : struct crypto_unittest_params *ut_params = &unittest_params;
11809 : : uint8_t *plaintext = NULL;
11810 : : uint8_t *ciphertext = NULL;
11811 : : uint8_t *iv_ptr;
11812 : : int32_t cipher_len, crc_len;
11813 : : int ret = TEST_SUCCESS;
11814 : :
11815 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11816 : :
11817 : : /* Verify the capabilities */
11818 : : struct rte_security_capability_idx sec_cap_idx;
11819 : : const struct rte_security_capability *sec_cap;
11820 : : const struct rte_cryptodev_capabilities *crypto_cap;
11821 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11822 : : int j = 0;
11823 : :
11824 : : /* Set action type */
11825 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11826 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11827 : : gbl_action_type;
11828 : :
11829 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11830 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11831 : : return TEST_SKIPPED;
11832 : :
11833 : 0 : sec_cap_idx.action = ut_params->type;
11834 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11835 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11836 : :
11837 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11838 [ # # ]: 0 : if (sec_cap == NULL)
11839 : : return TEST_SKIPPED;
11840 : :
11841 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11842 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11843 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11844 : : crypto_cap->sym.xform_type ==
11845 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11846 : : crypto_cap->sym.cipher.algo ==
11847 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11848 : 0 : sym_cap = &crypto_cap->sym;
11849 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11850 : 0 : d_td->key.len,
11851 : 0 : d_td->iv.len) == 0)
11852 : : break;
11853 : : }
11854 : : }
11855 : :
11856 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11857 : : return TEST_SKIPPED;
11858 : :
11859 : : /* Setup source mbuf payload */
11860 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11861 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11862 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11863 : :
11864 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11865 : 0 : d_td->plaintext.len);
11866 : :
11867 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11868 : :
11869 : : /* Setup cipher session parameters */
11870 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11871 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11872 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11873 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11874 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11875 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11876 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11877 : 0 : ut_params->cipher_xform.next = NULL;
11878 : :
11879 : : /* Setup DOCSIS session parameters */
11880 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11881 : :
11882 : 0 : struct rte_security_session_conf sess_conf = {
11883 : 0 : .action_type = ut_params->type,
11884 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11885 : : .docsis = ut_params->docsis_xform,
11886 : : .crypto_xform = &ut_params->cipher_xform,
11887 : : };
11888 : :
11889 : : /* Create security session */
11890 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11891 : : ts_params->session_mpool);
11892 : :
11893 [ # # ]: 0 : if (!ut_params->sec_session) {
11894 : : printf("Test function %s line %u: failed to allocate session\n",
11895 : : __func__, __LINE__);
11896 : : ret = TEST_FAILED;
11897 : 0 : goto on_err;
11898 : : }
11899 : :
11900 : : /* Generate crypto op data structure */
11901 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11902 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11903 [ # # ]: 0 : if (!ut_params->op) {
11904 : : printf("Test function %s line %u: failed to allocate symmetric "
11905 : : "crypto operation\n", __func__, __LINE__);
11906 : : ret = TEST_FAILED;
11907 : 0 : goto on_err;
11908 : : }
11909 : :
11910 : : /* Setup CRC operation parameters */
11911 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11912 : 0 : (d_td->plaintext.len -
11913 : 0 : d_td->plaintext.crc_offset -
11914 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11915 : : 0;
11916 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11917 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11918 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11919 : :
11920 : : /* Setup cipher operation parameters */
11921 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11922 : 0 : (d_td->plaintext.len -
11923 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11924 : : 0;
11925 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11926 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11927 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11928 : :
11929 : : /* Setup cipher IV */
11930 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11931 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11932 : :
11933 : : /* Attach session to operation */
11934 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11935 : :
11936 : : /* Set crypto operation mbufs */
11937 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11938 : 0 : ut_params->op->sym->m_dst = NULL;
11939 : :
11940 : : /* Process crypto operation */
11941 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11942 : : NULL) {
11943 : : printf("Test function %s line %u: failed to process crypto op\n",
11944 : : __func__, __LINE__);
11945 : : ret = TEST_FAILED;
11946 : 0 : goto on_err;
11947 : : }
11948 : :
11949 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11950 : : printf("Test function %s line %u: crypto op processing failed\n",
11951 : : __func__, __LINE__);
11952 : : ret = TEST_FAILED;
11953 : 0 : goto on_err;
11954 : : }
11955 : :
11956 : : /* Validate ciphertext */
11957 : : ciphertext = plaintext;
11958 : :
11959 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11960 : : printf("Test function %s line %u: plaintext not as expected\n",
11961 : : __func__, __LINE__);
11962 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11963 : 0 : d_td->ciphertext.len);
11964 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11965 : : ret = TEST_FAILED;
11966 : 0 : goto on_err;
11967 : : }
11968 : :
11969 : 0 : on_err:
11970 : 0 : rte_crypto_op_free(ut_params->op);
11971 : 0 : ut_params->op = NULL;
11972 : :
11973 [ # # ]: 0 : if (ut_params->sec_session)
11974 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11975 : 0 : ut_params->sec_session = NULL;
11976 : :
11977 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11978 : 0 : ut_params->ibuf = NULL;
11979 : :
11980 : 0 : return ret;
11981 : : }
11982 : :
11983 : : static void
11984 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11985 : : struct rte_security_tls_record_xform *tls_record_xform)
11986 : : {
11987 : : unsigned int imp_nonce_len;
11988 : : uint8_t *imp_nonce;
11989 : :
11990 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11991 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11992 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11993 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11994 : 0 : break;
11995 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11996 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11997 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11998 : 0 : break;
11999 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
12000 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
12001 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
12002 : 0 : break;
12003 : : default:
12004 : : return;
12005 : : }
12006 : :
12007 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
12008 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
12009 : : }
12010 : :
12011 : : static int
12012 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
12013 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
12014 : : const struct tls_record_test_flags *flags)
12015 : : {
12016 : 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
12017 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12018 : : struct crypto_unittest_params *ut_params = &unittest_params;
12019 : : struct rte_security_tls_record_xform tls_record_xform;
12020 : : struct rte_security_capability_idx sec_cap_idx;
12021 : : const struct rte_security_capability *sec_cap;
12022 : : struct tls_record_test_data *res_d_tmp = NULL;
12023 : : enum rte_security_tls_sess_type sess_type;
12024 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
12025 : : struct rte_security_ctx *ctx;
12026 : : int i, ret = TEST_SUCCESS;
12027 : :
12028 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
12029 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
12030 : :
12031 : : /* Use first test data to create session */
12032 : :
12033 : : /* Copy TLS record xform */
12034 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
12035 : :
12036 : 0 : sess_type = tls_record_xform.type;
12037 : :
12038 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12039 : :
12040 : 0 : sec_cap_idx.action = ut_params->type;
12041 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
12042 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
12043 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
12044 : :
12045 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
12046 [ # # ]: 0 : if (sec_cap == NULL)
12047 : : return TEST_SKIPPED;
12048 : :
12049 : : /* Copy cipher session parameters */
12050 [ # # ]: 0 : if (td[0].aead) {
12051 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
12052 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
12053 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
12054 : :
12055 : : /* Verify crypto capabilities */
12056 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
12057 [ # # ]: 0 : if (!silent)
12058 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
12059 : 0 : return TEST_SKIPPED;
12060 : : }
12061 : : } else {
12062 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
12063 : : sizeof(ut_params->cipher_xform));
12064 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
12065 : : sizeof(ut_params->auth_xform));
12066 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
12067 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12068 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
12069 : :
12070 : : /* Verify crypto capabilities */
12071 : :
12072 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
12073 [ # # ]: 0 : if (!silent)
12074 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
12075 : 0 : return TEST_SKIPPED;
12076 : : }
12077 : :
12078 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
12079 [ # # ]: 0 : if (!silent)
12080 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
12081 : 0 : return TEST_SKIPPED;
12082 : : }
12083 : : }
12084 : :
12085 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
12086 : : return TEST_SKIPPED;
12087 : :
12088 : 0 : struct rte_security_session_conf sess_conf = {
12089 : 0 : .action_type = ut_params->type,
12090 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
12091 : : };
12092 : :
12093 : : if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
12094 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
12095 : : sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
12096 : :
12097 [ # # ]: 0 : if (td[0].aead)
12098 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
12099 : :
12100 [ # # ]: 0 : if (flags->opt_padding)
12101 : 0 : tls_record_xform.options.extra_padding_enable = 1;
12102 : :
12103 : 0 : sess_conf.tls_record = tls_record_xform;
12104 : :
12105 [ # # ]: 0 : if (td[0].aead) {
12106 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
12107 : : } else {
12108 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
12109 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
12110 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
12111 : : } else {
12112 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
12113 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
12114 : : }
12115 : : }
12116 : :
12117 [ # # ]: 0 : if (ut_params->sec_session == NULL) {
12118 : : /* Create security session */
12119 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
12120 : : ts_params->session_mpool);
12121 : : }
12122 : :
12123 [ # # ]: 0 : if (ut_params->sec_session == NULL)
12124 : : return TEST_SKIPPED;
12125 : :
12126 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
12127 [ # # # # ]: 0 : if (flags->ar_win_size &&
12128 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
12129 : 0 : sess_conf.tls_record.dtls_1_2.seq_no =
12130 : 0 : td[i].tls_record_xform.dtls_1_2.seq_no;
12131 : 0 : ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
12132 [ # # ]: 0 : if (ret) {
12133 : : printf("Could not update sequence number in session\n");
12134 : 0 : return TEST_SKIPPED;
12135 : : }
12136 : : }
12137 : :
12138 : : /* Setup source mbuf payload */
12139 : 0 : ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12140 : 0 : ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
12141 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
12142 [ # # ]: 0 : if (flags->out_of_place)
12143 : 0 : ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12144 : 0 : ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
12145 : : 0);
12146 : : else
12147 : 0 : ut_params->obuf = NULL;
12148 : :
12149 : : /* Generate crypto op data structure */
12150 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12151 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12152 [ # # ]: 0 : if (ut_params->op == NULL) {
12153 : : printf("Could not allocate crypto op");
12154 : : ret = TEST_FAILED;
12155 : 0 : goto crypto_op_free;
12156 : : }
12157 : :
12158 : : /* Attach session to operation */
12159 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
12160 : :
12161 : : /* Set crypto operation mbufs */
12162 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12163 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12164 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
12165 : :
12166 [ # # ]: 0 : if (flags->opt_padding)
12167 : 0 : ut_params->op->aux_flags = flags->opt_padding;
12168 : :
12169 : : /* Copy IV in crypto operation when IV generation is disabled */
12170 [ # # ]: 0 : if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12171 [ # # ]: 0 : (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12172 [ # # ]: 0 : (tls_record_xform.options.iv_gen_disable == 1)) {
12173 : : uint8_t *iv;
12174 : : int len;
12175 : :
12176 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12177 [ # # ]: 0 : if (td[i].aead)
12178 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
12179 : : else
12180 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
12181 : 0 : memcpy(iv, td[i].iv.data, len);
12182 : : }
12183 : :
12184 : : /* Process crypto operation */
12185 : 0 : process_crypto_request(dev_id, ut_params->op);
12186 : :
12187 : 0 : ret = test_tls_record_status_check(ut_params->op, &td[i]);
12188 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12189 : 0 : goto crypto_op_free;
12190 : :
12191 [ # # ]: 0 : if (res_d != NULL)
12192 : 0 : res_d_tmp = &res_d[i];
12193 : :
12194 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12195 [ # # ]: 0 : struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12196 : : ut_params->ibuf;
12197 : :
12198 : 0 : ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12199 : : silent, flags);
12200 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12201 : 0 : goto crypto_op_free;
12202 : : }
12203 : :
12204 : 0 : rte_crypto_op_free(ut_params->op);
12205 : 0 : ut_params->op = NULL;
12206 : :
12207 [ # # ]: 0 : if (flags->out_of_place) {
12208 : 0 : rte_pktmbuf_free(ut_params->obuf);
12209 : 0 : ut_params->obuf = NULL;
12210 : : }
12211 : :
12212 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12213 : 0 : ut_params->ibuf = NULL;
12214 : : }
12215 : :
12216 : 0 : crypto_op_free:
12217 : 0 : rte_crypto_op_free(ut_params->op);
12218 : 0 : ut_params->op = NULL;
12219 : :
12220 [ # # ]: 0 : if (flags->out_of_place) {
12221 : 0 : rte_pktmbuf_free(ut_params->obuf);
12222 : 0 : ut_params->obuf = NULL;
12223 : : }
12224 : :
12225 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12226 : 0 : ut_params->ibuf = NULL;
12227 : :
12228 [ # # # # ]: 0 : if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12229 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
12230 : 0 : ut_params->sec_session = NULL;
12231 : : }
12232 : :
12233 : : RTE_SET_USED(flags);
12234 : :
12235 : : return ret;
12236 : : }
12237 : :
12238 : : static int
12239 : 0 : test_tls_record_proto_known_vec(const void *test_data)
12240 : : {
12241 : : struct tls_record_test_data td_write;
12242 : : struct tls_record_test_flags flags;
12243 : :
12244 : : memset(&flags, 0, sizeof(flags));
12245 : :
12246 : : memcpy(&td_write, test_data, sizeof(td_write));
12247 : :
12248 : : /* Disable IV gen to be able to test with known vectors */
12249 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
12250 : :
12251 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12252 : : }
12253 : :
12254 : : static int
12255 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
12256 : : {
12257 : : const struct tls_record_test_data *td = test_data;
12258 : : struct tls_record_test_flags flags;
12259 : : struct tls_record_test_data td_inb;
12260 : :
12261 : : memset(&flags, 0, sizeof(flags));
12262 : :
12263 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12264 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
12265 : : else
12266 : : memcpy(&td_inb, td, sizeof(td_inb));
12267 : :
12268 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12269 : : }
12270 : :
12271 : : static int
12272 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12273 : : {
12274 : : unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12275 : : struct crypto_unittest_params *ut_params = &unittest_params;
12276 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12277 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12278 : : void *sec_session_outb = NULL;
12279 : : void *sec_session_inb = NULL;
12280 : : int ret;
12281 : :
12282 [ # # # ]: 0 : switch (flags->tls_version) {
12283 : : case RTE_SECURITY_VERSION_TLS_1_2:
12284 : : max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12285 : : break;
12286 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
12287 : : max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12288 : 0 : break;
12289 : : case RTE_SECURITY_VERSION_DTLS_1_2:
12290 : : max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12291 : : break;
12292 : 0 : default:
12293 : : max_payload_len = 0;
12294 : : }
12295 : :
12296 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12297 : : payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12298 [ # # ]: 0 : if (flags->nb_segs_in_mbuf)
12299 : 0 : payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12300 : :
12301 [ # # ]: 0 : if (flags->zero_len)
12302 : : payload_len = 0;
12303 : 0 : again:
12304 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12305 : : flags, td_outb, nb_pkts, payload_len);
12306 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12307 : 0 : continue;
12308 : :
12309 [ # # ]: 0 : if (flags->skip_sess_destroy)
12310 : 0 : ut_params->sec_session = sec_session_outb;
12311 : :
12312 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12313 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12314 : 0 : continue;
12315 : :
12316 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_outb == NULL)
12317 : 0 : sec_session_outb = ut_params->sec_session;
12318 : :
12319 [ # # # # ]: 0 : if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
12320 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12321 : : return TEST_FAILED;
12322 : 0 : goto skip_decrypt;
12323 [ # # ]: 0 : } else if (ret == TEST_FAILED) {
12324 : : return TEST_FAILED;
12325 : : }
12326 : :
12327 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12328 : :
12329 [ # # ]: 0 : if (flags->skip_sess_destroy)
12330 : 0 : ut_params->sec_session = sec_session_inb;
12331 : :
12332 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12333 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12334 : 0 : continue;
12335 : :
12336 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_inb == NULL)
12337 : 0 : sec_session_inb = ut_params->sec_session;
12338 : :
12339 [ # # # # ]: 0 : if (flags->pkt_corruption || flags->padding_corruption) {
12340 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12341 : : return TEST_FAILED;
12342 : : } else {
12343 [ # # ]: 0 : if (ret == TEST_FAILED)
12344 : : return TEST_FAILED;
12345 : : }
12346 : :
12347 : 0 : skip_decrypt:
12348 [ # # # # ]: 0 : if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12349 : 0 : goto again;
12350 : :
12351 [ # # ]: 0 : if (flags->display_alg)
12352 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12353 : :
12354 [ # # ]: 0 : if (flags->skip_sess_destroy) {
12355 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
12356 : : struct rte_security_ctx *ctx;
12357 : :
12358 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12359 [ # # ]: 0 : if (sec_session_inb != NULL) {
12360 : 0 : rte_security_session_destroy(ctx, sec_session_inb);
12361 : : sec_session_inb = NULL;
12362 : : }
12363 [ # # ]: 0 : if (sec_session_outb != NULL) {
12364 : 0 : rte_security_session_destroy(ctx, sec_session_outb);
12365 : : sec_session_outb = NULL;
12366 : : }
12367 : 0 : ut_params->sec_session = NULL;
12368 : : }
12369 : :
12370 : 0 : pass_cnt++;
12371 : : }
12372 : :
12373 [ # # ]: 0 : if (flags->data_walkthrough)
12374 : : printf("\t Min payload size: %d, Max payload size: %d\n",
12375 : : TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
12376 : :
12377 [ # # ]: 0 : if (pass_cnt > 0)
12378 : : return TEST_SUCCESS;
12379 : : else
12380 : 0 : return TEST_SKIPPED;
12381 : : }
12382 : :
12383 : : static int
12384 : 0 : test_tls_1_2_record_proto_data_walkthrough(void)
12385 : : {
12386 : : struct tls_record_test_flags flags;
12387 : :
12388 : : memset(&flags, 0, sizeof(flags));
12389 : :
12390 : 0 : flags.data_walkthrough = true;
12391 : 0 : flags.skip_sess_destroy = true;
12392 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12393 : :
12394 : 0 : return test_tls_record_proto_all(&flags);
12395 : : }
12396 : :
12397 : : static int
12398 : 0 : test_tls_1_2_record_proto_display_list(void)
12399 : : {
12400 : : struct tls_record_test_flags flags;
12401 : :
12402 : : memset(&flags, 0, sizeof(flags));
12403 : :
12404 : 0 : flags.display_alg = true;
12405 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12406 : :
12407 : 0 : return test_tls_record_proto_all(&flags);
12408 : : }
12409 : :
12410 : : static int
12411 : 0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12412 : : {
12413 : 0 : struct tls_record_test_flags flags = {
12414 : : .nb_segs_in_mbuf = 5,
12415 : : .tls_version = tls_version
12416 : : };
12417 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12418 : : struct rte_cryptodev_info dev_info;
12419 : :
12420 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12421 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12422 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12423 : 0 : return TEST_SKIPPED;
12424 : : }
12425 : :
12426 : 0 : return test_tls_record_proto_all(&flags);
12427 : : }
12428 : :
12429 : : static int
12430 : 0 : test_tls_1_2_record_proto_sgl(void)
12431 : : {
12432 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12433 : : }
12434 : :
12435 : : static int
12436 : 0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12437 : : {
12438 : 0 : struct tls_record_test_flags flags = {
12439 : : .nb_segs_in_mbuf = 5,
12440 : : .tls_version = tls_version,
12441 : : .skip_sess_destroy = true,
12442 : : .data_walkthrough = true
12443 : : };
12444 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12445 : : struct rte_cryptodev_info dev_info;
12446 : :
12447 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12448 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12449 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12450 : 0 : return TEST_SKIPPED;
12451 : : }
12452 : :
12453 : 0 : return test_tls_record_proto_all(&flags);
12454 : : }
12455 : :
12456 : : static int
12457 : 0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12458 : : {
12459 : 0 : struct tls_record_test_flags flags = {
12460 : : .nb_segs_in_mbuf = 5,
12461 : : .out_of_place = true,
12462 : : .tls_version = tls_version
12463 : : };
12464 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12465 : : struct rte_cryptodev_info dev_info;
12466 : :
12467 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12468 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12469 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12470 : 0 : return TEST_SKIPPED;
12471 : : }
12472 : :
12473 : 0 : return test_tls_record_proto_all(&flags);
12474 : : }
12475 : :
12476 : : static int
12477 : 0 : test_tls_1_2_record_proto_sgl_oop(void)
12478 : : {
12479 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12480 : : }
12481 : :
12482 : : static int
12483 : 0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12484 : : {
12485 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12486 : : }
12487 : :
12488 : : static int
12489 : 0 : test_tls_record_proto_corrupt_pkt(void)
12490 : : {
12491 : 0 : struct tls_record_test_flags flags = {
12492 : : .pkt_corruption = 1
12493 : : };
12494 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12495 : : struct rte_cryptodev_info dev_info;
12496 : :
12497 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12498 : :
12499 : 0 : return test_tls_record_proto_all(&flags);
12500 : : }
12501 : :
12502 : : static int
12503 : 0 : test_tls_record_proto_custom_content_type(void)
12504 : : {
12505 : 0 : struct tls_record_test_flags flags = {
12506 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12507 : : };
12508 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12509 : : struct rte_cryptodev_info dev_info;
12510 : :
12511 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12512 : :
12513 : 0 : return test_tls_record_proto_all(&flags);
12514 : : }
12515 : :
12516 : : static int
12517 : 0 : test_tls_record_proto_zero_len(void)
12518 : : {
12519 : 0 : struct tls_record_test_flags flags = {
12520 : : .zero_len = 1
12521 : : };
12522 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12523 : : struct rte_cryptodev_info dev_info;
12524 : :
12525 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12526 : :
12527 : 0 : return test_tls_record_proto_all(&flags);
12528 : : }
12529 : :
12530 : : static int
12531 : 0 : test_tls_record_proto_zero_len_non_app(void)
12532 : : {
12533 : 0 : struct tls_record_test_flags flags = {
12534 : : .zero_len = 1,
12535 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12536 : : };
12537 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12538 : : struct rte_cryptodev_info dev_info;
12539 : :
12540 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12541 : :
12542 : 0 : return test_tls_record_proto_all(&flags);
12543 : : }
12544 : :
12545 : : static int
12546 : 0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12547 : : enum rte_security_tls_version tls_version)
12548 : : {
12549 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12550 : : struct rte_cryptodev_info dev_info;
12551 : 0 : struct tls_record_test_flags flags = {
12552 : : .nb_segs_in_mbuf = num_segs,
12553 : : .tls_version = tls_version,
12554 : : .opt_padding = padding
12555 : : };
12556 : :
12557 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12558 : :
12559 : 0 : return test_tls_record_proto_all(&flags);
12560 : : }
12561 : :
12562 : : static int
12563 : 0 : test_tls_record_proto_dm_opt_padding(void)
12564 : : {
12565 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12566 : : }
12567 : :
12568 : : static int
12569 : 0 : test_tls_record_proto_dm_opt_padding_1(void)
12570 : : {
12571 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12572 : : }
12573 : :
12574 : : static int
12575 : 0 : test_tls_record_proto_sg_opt_padding(void)
12576 : : {
12577 : 0 : return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12578 : : }
12579 : :
12580 : : static int
12581 : 0 : test_tls_record_proto_sg_opt_padding_1(void)
12582 : : {
12583 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12584 : : }
12585 : :
12586 : : static int
12587 : 0 : test_tls_record_proto_sg_opt_padding_2(void)
12588 : : {
12589 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12590 : : }
12591 : :
12592 : : static int
12593 : 0 : test_tls_record_proto_sg_opt_padding_max(void)
12594 : : {
12595 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12596 : : }
12597 : :
12598 : : static int
12599 : 0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
12600 : : {
12601 : 0 : struct tls_record_test_flags flags = {
12602 : : .opt_padding = 8,
12603 : : .padding_corruption = true,
12604 : : .nb_segs_in_mbuf = 4,
12605 : : };
12606 : :
12607 : 0 : return test_tls_record_proto_all(&flags);
12608 : : }
12609 : :
12610 : : static int
12611 : 0 : test_dtls_1_2_record_proto_data_walkthrough(void)
12612 : : {
12613 : : struct tls_record_test_flags flags;
12614 : :
12615 : : memset(&flags, 0, sizeof(flags));
12616 : :
12617 : 0 : flags.data_walkthrough = true;
12618 : 0 : flags.skip_sess_destroy = true;
12619 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12620 : :
12621 : 0 : return test_tls_record_proto_all(&flags);
12622 : : }
12623 : :
12624 : : static int
12625 : 0 : test_dtls_1_2_record_proto_display_list(void)
12626 : : {
12627 : : struct tls_record_test_flags flags;
12628 : :
12629 : : memset(&flags, 0, sizeof(flags));
12630 : :
12631 : 0 : flags.display_alg = true;
12632 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12633 : :
12634 : 0 : return test_tls_record_proto_all(&flags);
12635 : : }
12636 : :
12637 : : static int
12638 : 0 : test_dtls_pkt_replay(const uint64_t seq_no[],
12639 : : bool replayed_pkt[], uint32_t nb_pkts,
12640 : : struct tls_record_test_flags *flags)
12641 : : {
12642 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12643 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12644 : : unsigned int i, idx, pass_cnt = 0;
12645 : : int ret;
12646 : :
12647 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12648 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12649 : : flags, td_outb, nb_pkts, 0);
12650 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12651 : 0 : continue;
12652 : :
12653 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++)
12654 : 0 : td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12655 : :
12656 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12657 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12658 : 0 : continue;
12659 : :
12660 [ # # ]: 0 : if (ret == TEST_FAILED)
12661 : : return TEST_FAILED;
12662 : :
12663 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12664 : :
12665 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
12666 : 0 : td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12667 : : /* Set antireplay flag for packets to be dropped */
12668 : 0 : td_inb[idx].ar_packet = replayed_pkt[idx];
12669 : : }
12670 : :
12671 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12672 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12673 : 0 : continue;
12674 : :
12675 [ # # ]: 0 : if (ret == TEST_FAILED)
12676 : : return TEST_FAILED;
12677 : :
12678 [ # # ]: 0 : if (flags->display_alg)
12679 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12680 : :
12681 : 0 : pass_cnt++;
12682 : : }
12683 : :
12684 [ # # ]: 0 : if (pass_cnt > 0)
12685 : : return TEST_SUCCESS;
12686 : : else
12687 : 0 : return TEST_SKIPPED;
12688 : : }
12689 : :
12690 : : static int
12691 : 0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12692 : : {
12693 : : struct tls_record_test_flags flags;
12694 : : uint32_t nb_pkts = 5;
12695 : : bool replayed_pkt[5];
12696 : : uint64_t seq_no[5];
12697 : :
12698 : : memset(&flags, 0, sizeof(flags));
12699 : :
12700 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12701 : 0 : flags.ar_win_size = winsz;
12702 : :
12703 : : /* 1. Advance the TOP of the window to WS * 2 */
12704 : 0 : seq_no[0] = winsz * 2;
12705 : : /* 2. Test sequence number within the new window(WS + 1) */
12706 : 0 : seq_no[1] = winsz + 1;
12707 : : /* 3. Test sequence number less than the window BOTTOM */
12708 : 0 : seq_no[2] = winsz;
12709 : : /* 4. Test sequence number in the middle of the window */
12710 : 0 : seq_no[3] = winsz + (winsz / 2);
12711 : : /* 5. Test replay of the packet in the middle of the window */
12712 : 0 : seq_no[4] = winsz + (winsz / 2);
12713 : :
12714 : 0 : replayed_pkt[0] = false;
12715 : 0 : replayed_pkt[1] = false;
12716 : 0 : replayed_pkt[2] = true;
12717 : 0 : replayed_pkt[3] = false;
12718 : 0 : replayed_pkt[4] = true;
12719 : :
12720 : 0 : return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12721 : : }
12722 : :
12723 : : static int
12724 : 0 : test_dtls_1_2_record_proto_antireplay64(void)
12725 : : {
12726 : 0 : return test_dtls_1_2_record_proto_antireplay(64);
12727 : : }
12728 : :
12729 : : static int
12730 : 0 : test_dtls_1_2_record_proto_antireplay128(void)
12731 : : {
12732 : 0 : return test_dtls_1_2_record_proto_antireplay(128);
12733 : : }
12734 : :
12735 : : static int
12736 : 0 : test_dtls_1_2_record_proto_antireplay256(void)
12737 : : {
12738 : 0 : return test_dtls_1_2_record_proto_antireplay(256);
12739 : : }
12740 : :
12741 : : static int
12742 : 0 : test_dtls_1_2_record_proto_antireplay512(void)
12743 : : {
12744 : 0 : return test_dtls_1_2_record_proto_antireplay(512);
12745 : : }
12746 : :
12747 : : static int
12748 : 0 : test_dtls_1_2_record_proto_antireplay1024(void)
12749 : : {
12750 : 0 : return test_dtls_1_2_record_proto_antireplay(1024);
12751 : : }
12752 : :
12753 : : static int
12754 : 0 : test_dtls_1_2_record_proto_antireplay2048(void)
12755 : : {
12756 : 0 : return test_dtls_1_2_record_proto_antireplay(2048);
12757 : : }
12758 : :
12759 : : static int
12760 : 0 : test_dtls_1_2_record_proto_antireplay4096(void)
12761 : : {
12762 : 0 : return test_dtls_1_2_record_proto_antireplay(4096);
12763 : : }
12764 : :
12765 : : static int
12766 : 0 : test_dtls_1_2_record_proto_sgl(void)
12767 : : {
12768 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12769 : : }
12770 : :
12771 : : static int
12772 : 0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12773 : : {
12774 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12775 : : }
12776 : :
12777 : : static int
12778 : 0 : test_dtls_1_2_record_proto_sgl_oop(void)
12779 : : {
12780 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12781 : : }
12782 : :
12783 : : static int
12784 : 0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
12785 : : {
12786 : 0 : struct tls_record_test_flags flags = {
12787 : : .pkt_corruption = 1,
12788 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12789 : : };
12790 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12791 : : struct rte_cryptodev_info dev_info;
12792 : :
12793 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12794 : :
12795 : 0 : return test_tls_record_proto_all(&flags);
12796 : : }
12797 : :
12798 : : static int
12799 : 0 : test_dtls_1_2_record_proto_custom_content_type(void)
12800 : : {
12801 : 0 : struct tls_record_test_flags flags = {
12802 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12803 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12804 : : };
12805 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12806 : : struct rte_cryptodev_info dev_info;
12807 : :
12808 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12809 : :
12810 : 0 : return test_tls_record_proto_all(&flags);
12811 : : }
12812 : :
12813 : : static int
12814 : 0 : test_dtls_1_2_record_proto_zero_len(void)
12815 : : {
12816 : 0 : struct tls_record_test_flags flags = {
12817 : : .zero_len = 1,
12818 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12819 : : };
12820 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12821 : : struct rte_cryptodev_info dev_info;
12822 : :
12823 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12824 : :
12825 : 0 : return test_tls_record_proto_all(&flags);
12826 : : }
12827 : :
12828 : : static int
12829 : 0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
12830 : : {
12831 : 0 : struct tls_record_test_flags flags = {
12832 : : .zero_len = 1,
12833 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12834 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12835 : : };
12836 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12837 : : struct rte_cryptodev_info dev_info;
12838 : :
12839 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12840 : :
12841 : 0 : return test_tls_record_proto_all(&flags);
12842 : : }
12843 : :
12844 : : static int
12845 : 0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
12846 : : {
12847 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12848 : : }
12849 : :
12850 : : static int
12851 : 0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12852 : : {
12853 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12854 : : }
12855 : :
12856 : : static int
12857 : 0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
12858 : : {
12859 : 0 : return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12860 : : }
12861 : :
12862 : : static int
12863 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12864 : : {
12865 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12866 : : }
12867 : :
12868 : : static int
12869 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12870 : : {
12871 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12872 : : }
12873 : :
12874 : : static int
12875 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12876 : : {
12877 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12878 : : }
12879 : :
12880 : : static int
12881 : 0 : test_tls_1_3_record_proto_display_list(void)
12882 : : {
12883 : : struct tls_record_test_flags flags;
12884 : :
12885 : : memset(&flags, 0, sizeof(flags));
12886 : :
12887 : 0 : flags.display_alg = true;
12888 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12889 : :
12890 : 0 : return test_tls_record_proto_all(&flags);
12891 : : }
12892 : :
12893 : : static int
12894 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12895 : : {
12896 : 0 : struct tls_record_test_flags flags = {
12897 : : .opt_padding = 8,
12898 : : .padding_corruption = true,
12899 : : .nb_segs_in_mbuf = 4,
12900 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12901 : : };
12902 : :
12903 : 0 : return test_tls_record_proto_all(&flags);
12904 : : }
12905 : :
12906 : : static int
12907 : 0 : test_tls_1_3_record_proto_corrupt_pkt(void)
12908 : : {
12909 : 0 : struct tls_record_test_flags flags = {
12910 : : .pkt_corruption = 1,
12911 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12912 : : };
12913 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12914 : : struct rte_cryptodev_info dev_info;
12915 : :
12916 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12917 : :
12918 : 0 : return test_tls_record_proto_all(&flags);
12919 : : }
12920 : :
12921 : : static int
12922 : 0 : test_tls_1_3_record_proto_custom_content_type(void)
12923 : : {
12924 : 0 : struct tls_record_test_flags flags = {
12925 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12926 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12927 : : };
12928 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12929 : : struct rte_cryptodev_info dev_info;
12930 : :
12931 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12932 : :
12933 : 0 : return test_tls_record_proto_all(&flags);
12934 : : }
12935 : :
12936 : : static int
12937 : 0 : test_tls_1_3_record_proto_zero_len(void)
12938 : : {
12939 : 0 : struct tls_record_test_flags flags = {
12940 : : .zero_len = 1,
12941 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12942 : : };
12943 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12944 : : struct rte_cryptodev_info dev_info;
12945 : :
12946 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12947 : :
12948 : 0 : return test_tls_record_proto_all(&flags);
12949 : : }
12950 : :
12951 : : static int
12952 : 0 : test_tls_1_3_record_proto_zero_len_non_app(void)
12953 : : {
12954 : 0 : struct tls_record_test_flags flags = {
12955 : : .zero_len = 1,
12956 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12957 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12958 : : };
12959 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12960 : : struct rte_cryptodev_info dev_info;
12961 : :
12962 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12963 : :
12964 : 0 : return test_tls_record_proto_all(&flags);
12965 : : }
12966 : :
12967 : : static int
12968 : 0 : test_tls_1_3_record_proto_dm_opt_padding(void)
12969 : : {
12970 : 0 : return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12971 : : }
12972 : :
12973 : : static int
12974 : 0 : test_tls_1_3_record_proto_sg_opt_padding(void)
12975 : : {
12976 : 0 : return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12977 : : }
12978 : :
12979 : : static int
12980 : 0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
12981 : : {
12982 : 0 : return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12983 : : }
12984 : :
12985 : : static int
12986 : 0 : test_tls_1_3_record_proto_data_walkthrough(void)
12987 : : {
12988 : : struct tls_record_test_flags flags;
12989 : :
12990 : : memset(&flags, 0, sizeof(flags));
12991 : :
12992 : 0 : flags.data_walkthrough = true;
12993 : 0 : flags.skip_sess_destroy = true;
12994 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12995 : :
12996 : 0 : return test_tls_record_proto_all(&flags);
12997 : : }
12998 : :
12999 : : static int
13000 : 0 : test_tls_1_3_record_proto_sgl(void)
13001 : : {
13002 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
13003 : : }
13004 : :
13005 : : static int
13006 : 0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
13007 : : {
13008 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
13009 : : }
13010 : :
13011 : : static int
13012 : 0 : test_tls_1_3_record_proto_sgl_oop(void)
13013 : : {
13014 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
13015 : : }
13016 : :
13017 : : #endif
13018 : :
13019 : : static int
13020 : 1 : test_cryptodev_error_recover_helper_check(void)
13021 : : {
13022 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13023 : : struct rte_cryptodev_info dev_info;
13024 : : uint64_t feat_flags;
13025 : : int ret;
13026 : :
13027 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13028 : 1 : feat_flags = dev_info.feature_flags;
13029 : :
13030 : : /* Skip the test if queue pair reset is not supported */
13031 : 1 : ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
13032 [ - + ]: 1 : if (ret == -ENOTSUP)
13033 : : return TEST_SKIPPED;
13034 : :
13035 [ # # ]: 0 : ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
13036 [ # # ]: 0 : if (ret == -ENOTSUP)
13037 : 0 : return TEST_SKIPPED;
13038 : :
13039 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
13040 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13041 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13042 : 0 : RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
13043 : 0 : return TEST_SKIPPED;
13044 : : }
13045 : :
13046 : : return 0;
13047 : : }
13048 : :
13049 : : static int
13050 : 0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
13051 : : {
13052 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13053 : : struct crypto_unittest_params *ut_params = &unittest_params;
13054 : : const struct blockcipher_test_data *tdata = test_data;
13055 : 0 : uint8_t *cipher_key = alloca(tdata->cipher_key.len);
13056 : : struct rte_crypto_sym_op *sym_op = NULL;
13057 : : struct rte_crypto_op *op = NULL;
13058 : : char *dst;
13059 : :
13060 : 0 : memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
13061 : 0 : ut_params->cipher_xform.next = NULL;
13062 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13063 : 0 : ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
13064 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13065 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
13066 : 0 : ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
13067 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13068 : 0 : ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
13069 : :
13070 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
13071 : : ts_params->session_mpool);
13072 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13073 : : return TEST_SKIPPED;
13074 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13075 : :
13076 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13077 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
13078 : :
13079 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
13080 [ # # ]: 0 : tdata->iv.len);
13081 : : sym_op = ut_params->op->sym;
13082 : 0 : sym_op->cipher.data.offset = tdata->cipher_offset;
13083 : 0 : sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
13084 : :
13085 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13086 : :
13087 [ # # ]: 0 : if (generate_err) {
13088 : 0 : ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
13089 [ # # ]: 0 : if (ut_params->ibuf == NULL)
13090 : : return TEST_FAILED;
13091 : 0 : crypto_err = CRYPTODEV_ERR_TRIGGERED;
13092 : : } else {
13093 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13094 : : }
13095 : :
13096 : : /* clear mbuf payload */
13097 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13098 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
13099 : :
13100 : 0 : dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
13101 : 0 : memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
13102 : :
13103 : 0 : sym_op->m_src = ut_params->ibuf;
13104 : 0 : sym_op->m_dst = NULL;
13105 : :
13106 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
13107 : :
13108 [ # # ]: 0 : if (generate_err) {
13109 : 0 : free(ut_params->ibuf);
13110 : 0 : ut_params->ibuf = NULL;
13111 [ # # ]: 0 : if (op == NULL) {
13112 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13113 : 0 : ut_params->sess = NULL;
13114 : 0 : return TEST_SUCCESS;
13115 : : } else {
13116 : : return TEST_FAILED;
13117 : : }
13118 : : }
13119 : :
13120 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13121 : : "crypto op processing failed");
13122 : :
13123 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
13124 : : tdata->ciphertext.len - tdata->cipher_offset,
13125 : : "Data not as expected");
13126 : :
13127 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13128 : 0 : ut_params->sess = NULL;
13129 : :
13130 : 0 : return TEST_SUCCESS;
13131 : : }
13132 : :
13133 : : /*
13134 : : * This unit test verifies the recovery of the cryptodev from any fatal error.
13135 : : * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
13136 : : * for every call to helper function.
13137 : : *
13138 : : * When the flag is set to 0, the helper function verifies the test data without generating any
13139 : : * errors, i.e: verifies the default behaviour of the cryptodev.
13140 : : *
13141 : : * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
13142 : : * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
13143 : : * is generated, it waits till the cryptodev is recoverd from the error.
13144 : : *
13145 : : * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
13146 : : * of cryptodev after the recovery.
13147 : : */
13148 : : static int
13149 : 1 : test_cryptodev_verify_error_recover(const void *test_data)
13150 : : {
13151 : : int ret = TEST_FAILED;
13152 : : int i, num_itr = 5;
13153 : :
13154 : 1 : ret = test_cryptodev_error_recover_helper_check();
13155 [ - + ]: 1 : if (ret)
13156 : : return ret;
13157 : :
13158 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
13159 : : RTE_CRYPTODEV_EVENT_ERROR,
13160 : : test_cryptodev_error_cb, NULL),
13161 : : "Failed to register Cryptodev callback");
13162 : :
13163 [ # # ]: 0 : for (i = 0; i < num_itr; i++) {
13164 : : int ticks = 0;
13165 : :
13166 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13167 : : test_data, false);
13168 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13169 : :
13170 : : /* Generate Error */
13171 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13172 : : test_data, true);
13173 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13174 : :
13175 : : /* Wait till cryptodev recovered from error */
13176 [ # # ]: 0 : while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
13177 : : rte_delay_ms(10);
13178 [ # # ]: 0 : if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
13179 : : return TEST_FAILED;
13180 : : }
13181 : : }
13182 [ # # ]: 0 : TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
13183 : :
13184 : : return ret;
13185 : : }
13186 : :
13187 : : static int
13188 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
13189 : : {
13190 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
13191 : : }
13192 : :
13193 : : static int
13194 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
13195 : : {
13196 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
13197 : : }
13198 : :
13199 : : static int
13200 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
13201 : : {
13202 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
13203 : : }
13204 : :
13205 : : static int
13206 : 1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
13207 : : {
13208 : 1 : return test_authenticated_encryption_helper(&gcm_test_case_3, true);
13209 : : }
13210 : :
13211 : : static int
13212 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
13213 : : {
13214 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
13215 : : }
13216 : :
13217 : : static int
13218 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
13219 : : {
13220 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
13221 : : }
13222 : :
13223 : : static int
13224 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
13225 : : {
13226 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
13227 : : }
13228 : :
13229 : : static int
13230 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
13231 : : {
13232 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
13233 : : }
13234 : :
13235 : : static int
13236 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
13237 : : {
13238 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
13239 : : }
13240 : :
13241 : : static int
13242 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
13243 : : {
13244 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
13245 : : }
13246 : :
13247 : : static int
13248 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
13249 : : {
13250 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
13251 : : }
13252 : :
13253 : : static int
13254 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
13255 : : {
13256 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
13257 : : }
13258 : :
13259 : : static int
13260 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
13261 : : {
13262 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
13263 : : }
13264 : :
13265 : : static int
13266 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
13267 : : {
13268 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
13269 : : }
13270 : :
13271 : : static int
13272 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
13273 : : {
13274 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
13275 : : }
13276 : :
13277 : : static int
13278 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
13279 : : {
13280 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
13281 : : }
13282 : :
13283 : : static int
13284 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
13285 : : {
13286 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
13287 : : }
13288 : :
13289 : : static int
13290 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
13291 : : {
13292 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
13293 : : }
13294 : :
13295 : : static int
13296 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
13297 : : {
13298 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
13299 : : }
13300 : :
13301 : : static int
13302 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
13303 : : {
13304 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
13305 : : }
13306 : :
13307 : : static int
13308 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
13309 : : {
13310 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
13311 : : }
13312 : :
13313 : : static int
13314 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
13315 : : {
13316 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
13317 : : }
13318 : :
13319 : : static int
13320 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
13321 : : {
13322 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
13323 : : }
13324 : :
13325 : : static int
13326 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
13327 : : {
13328 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
13329 : : }
13330 : :
13331 : : static int
13332 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
13333 : : {
13334 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
13335 : : }
13336 : :
13337 : : static int
13338 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
13339 : : {
13340 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
13341 : : }
13342 : :
13343 : : static int
13344 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13345 : : {
13346 : : struct aead_test_data tdata;
13347 : : int res;
13348 : :
13349 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13350 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13351 : 1 : tdata.iv.data[0] += 1;
13352 : : res = test_authenticated_encryption(&tdata);
13353 [ + - ]: 1 : if (res == TEST_SKIPPED)
13354 : : return res;
13355 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13356 : : return TEST_SUCCESS;
13357 : : }
13358 : :
13359 : : static int
13360 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13361 : : {
13362 : : struct aead_test_data tdata;
13363 : : int res;
13364 : :
13365 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13366 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13367 : 1 : tdata.plaintext.data[0] += 1;
13368 : : res = test_authenticated_encryption(&tdata);
13369 [ + - ]: 1 : if (res == TEST_SKIPPED)
13370 : : return res;
13371 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13372 : : return TEST_SUCCESS;
13373 : : }
13374 : :
13375 : : static int
13376 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13377 : : {
13378 : : struct aead_test_data tdata;
13379 : : int res;
13380 : :
13381 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13382 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13383 : 1 : tdata.ciphertext.data[0] += 1;
13384 : : res = test_authenticated_encryption(&tdata);
13385 [ + - ]: 1 : if (res == TEST_SKIPPED)
13386 : : return res;
13387 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13388 : : return TEST_SUCCESS;
13389 : : }
13390 : :
13391 : : static int
13392 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13393 : : {
13394 : : struct aead_test_data tdata;
13395 : : int res;
13396 : :
13397 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13398 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13399 : 1 : tdata.aad.len += 1;
13400 : : res = test_authenticated_encryption(&tdata);
13401 [ + - ]: 1 : if (res == TEST_SKIPPED)
13402 : : return res;
13403 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13404 : : return TEST_SUCCESS;
13405 : : }
13406 : :
13407 : : static int
13408 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13409 : : {
13410 : : struct aead_test_data tdata;
13411 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13412 : : int res;
13413 : :
13414 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13415 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13416 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13417 : 1 : aad[0] += 1;
13418 : 1 : tdata.aad.data = aad;
13419 : : res = test_authenticated_encryption(&tdata);
13420 [ + - ]: 1 : if (res == TEST_SKIPPED)
13421 : : return res;
13422 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13423 : : return TEST_SUCCESS;
13424 : : }
13425 : :
13426 : : static int
13427 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13428 : : {
13429 : : struct aead_test_data tdata;
13430 : : int res;
13431 : :
13432 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13433 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13434 : 1 : tdata.auth_tag.data[0] += 1;
13435 : : res = test_authenticated_encryption(&tdata);
13436 [ + - ]: 1 : if (res == TEST_SKIPPED)
13437 : : return res;
13438 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13439 : : return TEST_SUCCESS;
13440 : : }
13441 : :
13442 : : static int
13443 : 43 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13444 : : {
13445 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13446 : : struct crypto_unittest_params *ut_params = &unittest_params;
13447 : :
13448 : : int retval;
13449 : : uint8_t *plaintext;
13450 : : uint32_t i;
13451 : : struct rte_cryptodev_info dev_info;
13452 : :
13453 : 43 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13454 : 43 : uint64_t feat_flags = dev_info.feature_flags;
13455 : :
13456 [ - + ]: 43 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13457 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13458 : : printf("Device doesn't support RAW data-path APIs.\n");
13459 : 0 : return TEST_SKIPPED;
13460 : : }
13461 : :
13462 : : /* Verify the capabilities */
13463 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13464 : : const struct rte_cryptodev_symmetric_capability *capability;
13465 : 43 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13466 : 43 : cap_idx.algo.aead = tdata->algo;
13467 : 43 : capability = rte_cryptodev_sym_capability_get(
13468 : 43 : ts_params->valid_devs[0], &cap_idx);
13469 [ + - ]: 43 : if (capability == NULL)
13470 : : return TEST_SKIPPED;
13471 [ + + ]: 43 : if (rte_cryptodev_sym_capability_check_aead(
13472 : 43 : capability, tdata->key.len, tdata->auth_tag.len,
13473 : 43 : tdata->aad.len, tdata->iv.len))
13474 : : return TEST_SKIPPED;
13475 : :
13476 : : /* Create AEAD session */
13477 : 42 : retval = create_aead_session(ts_params->valid_devs[0],
13478 : 42 : tdata->algo,
13479 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13480 : 42 : tdata->key.data, tdata->key.len,
13481 : 42 : tdata->aad.len, tdata->auth_tag.len,
13482 : 42 : tdata->iv.len);
13483 [ + - ]: 42 : if (retval != TEST_SUCCESS)
13484 : : return retval;
13485 : :
13486 : : /* alloc mbuf and set payload */
13487 [ + + ]: 42 : if (tdata->aad.len > MBUF_SIZE) {
13488 [ - + ]: 2 : if (use_ext_mbuf) {
13489 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13490 : : AEAD_TEXT_MAX_LENGTH,
13491 : : 1 /* nb_segs */,
13492 : : NULL);
13493 : : } else {
13494 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13495 : : }
13496 : : /* Populate full size of add data */
13497 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13498 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13499 : : } else {
13500 [ + + ]: 40 : if (use_ext_mbuf) {
13501 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13502 : : AEAD_TEXT_MAX_LENGTH,
13503 : : 1 /* nb_segs */,
13504 : : NULL);
13505 : : } else {
13506 : 39 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13507 : : }
13508 : : }
13509 : 42 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13510 : 42 : rte_pktmbuf_tailroom(ut_params->ibuf));
13511 : :
13512 : : /* Create AEAD operation */
13513 : 42 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13514 [ + - ]: 42 : if (retval < 0)
13515 : : return retval;
13516 : :
13517 [ + - ]: 42 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13518 : :
13519 : 42 : ut_params->op->sym->m_src = ut_params->ibuf;
13520 : :
13521 : : /* Process crypto operation */
13522 [ - + ]: 42 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13523 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13524 [ - + ]: 42 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13525 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13526 : : 0);
13527 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13528 : : return retval;
13529 : : } else
13530 [ + + ]: 42 : TEST_ASSERT_NOT_NULL(
13531 : : process_crypto_request(ts_params->valid_devs[0],
13532 : : ut_params->op), "failed to process sym crypto op");
13533 : :
13534 [ - + ]: 37 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13535 : : "crypto op processing failed");
13536 : :
13537 [ - + ]: 37 : if (ut_params->op->sym->m_dst)
13538 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13539 : : uint8_t *);
13540 : : else
13541 : 37 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13542 : : uint8_t *,
13543 : : ut_params->op->sym->cipher.data.offset);
13544 : :
13545 : 37 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13546 : :
13547 : : /* Validate obuf */
13548 [ + + ]: 38 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13549 : : plaintext,
13550 : : tdata->plaintext.data,
13551 : : tdata->plaintext.len,
13552 : : "Plaintext data not as expected");
13553 : :
13554 [ - + ]: 36 : TEST_ASSERT_EQUAL(ut_params->op->status,
13555 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13556 : : "Authentication failed");
13557 : :
13558 : : return 0;
13559 : : }
13560 : :
13561 : : static int
13562 : : test_authenticated_decryption(const struct aead_test_data *tdata)
13563 : : {
13564 : 42 : return test_authenticated_decryption_helper(tdata, false);
13565 : : }
13566 : :
13567 : : static int
13568 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
13569 : : {
13570 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
13571 : : }
13572 : :
13573 : : static int
13574 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
13575 : : {
13576 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
13577 : : }
13578 : :
13579 : : static int
13580 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
13581 : : {
13582 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
13583 : : }
13584 : :
13585 : : static int
13586 : 1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13587 : : {
13588 : 1 : return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13589 : : }
13590 : :
13591 : : static int
13592 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
13593 : : {
13594 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
13595 : : }
13596 : :
13597 : : static int
13598 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
13599 : : {
13600 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
13601 : : }
13602 : :
13603 : : static int
13604 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
13605 : : {
13606 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
13607 : : }
13608 : :
13609 : : static int
13610 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
13611 : : {
13612 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
13613 : : }
13614 : :
13615 : : static int
13616 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
13617 : : {
13618 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
13619 : : }
13620 : :
13621 : : static int
13622 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13623 : : {
13624 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
13625 : : }
13626 : :
13627 : : static int
13628 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
13629 : : {
13630 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
13631 : : }
13632 : :
13633 : : static int
13634 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
13635 : : {
13636 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
13637 : : }
13638 : :
13639 : : static int
13640 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
13641 : : {
13642 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
13643 : : }
13644 : :
13645 : : static int
13646 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
13647 : : {
13648 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
13649 : : }
13650 : :
13651 : : static int
13652 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
13653 : : {
13654 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
13655 : : }
13656 : :
13657 : : static int
13658 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
13659 : : {
13660 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
13661 : : }
13662 : :
13663 : : static int
13664 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
13665 : : {
13666 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
13667 : : }
13668 : :
13669 : : static int
13670 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
13671 : : {
13672 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
13673 : : }
13674 : :
13675 : : static int
13676 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
13677 : : {
13678 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
13679 : : }
13680 : :
13681 : : static int
13682 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
13683 : : {
13684 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
13685 : : }
13686 : :
13687 : : static int
13688 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
13689 : : {
13690 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
13691 : : }
13692 : :
13693 : : static int
13694 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
13695 : : {
13696 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
13697 : : }
13698 : :
13699 : : static int
13700 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
13701 : : {
13702 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
13703 : : }
13704 : :
13705 : : static int
13706 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
13707 : : {
13708 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
13709 : : }
13710 : :
13711 : : static int
13712 : 1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
13713 : : {
13714 : 1 : return test_authenticated_decryption(&gcm_test_case_256_8);
13715 : : }
13716 : :
13717 : : static int
13718 : 1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
13719 : : {
13720 : 1 : return test_authenticated_encryption(&gcm_test_case_256_8);
13721 : : }
13722 : :
13723 : : static int
13724 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
13725 : : {
13726 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
13727 : : }
13728 : :
13729 : : static int
13730 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
13731 : : {
13732 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
13733 : : }
13734 : :
13735 : : static int
13736 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13737 : : {
13738 : : struct aead_test_data tdata;
13739 : : int res;
13740 : :
13741 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13742 : 1 : tdata.iv.data[0] += 1;
13743 : : res = test_authenticated_decryption(&tdata);
13744 [ + - ]: 1 : if (res == TEST_SKIPPED)
13745 : : return res;
13746 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13747 : : return TEST_SUCCESS;
13748 : : }
13749 : :
13750 : : static int
13751 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13752 : : {
13753 : : struct aead_test_data tdata;
13754 : : int res;
13755 : :
13756 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13757 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13758 : 1 : tdata.plaintext.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, "decryption not failed");
13763 : : return TEST_SUCCESS;
13764 : : }
13765 : :
13766 : : static int
13767 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13768 : : {
13769 : : struct aead_test_data tdata;
13770 : : int res;
13771 : :
13772 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13773 : 1 : tdata.ciphertext.data[0] += 1;
13774 : : res = test_authenticated_decryption(&tdata);
13775 [ + - ]: 1 : if (res == TEST_SKIPPED)
13776 : : return res;
13777 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13778 : : return TEST_SUCCESS;
13779 : : }
13780 : :
13781 : : static int
13782 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13783 : : {
13784 : : struct aead_test_data tdata;
13785 : : int res;
13786 : :
13787 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13788 : 1 : tdata.aad.len += 1;
13789 : : res = test_authenticated_decryption(&tdata);
13790 [ + - ]: 1 : if (res == TEST_SKIPPED)
13791 : : return res;
13792 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13793 : : return TEST_SUCCESS;
13794 : : }
13795 : :
13796 : : static int
13797 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13798 : : {
13799 : : struct aead_test_data tdata;
13800 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13801 : : int res;
13802 : :
13803 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13804 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13805 : 1 : aad[0] += 1;
13806 : 1 : tdata.aad.data = aad;
13807 : : res = test_authenticated_decryption(&tdata);
13808 [ + - ]: 1 : if (res == TEST_SKIPPED)
13809 : : return res;
13810 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13811 : : return TEST_SUCCESS;
13812 : : }
13813 : :
13814 : : static int
13815 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13816 : : {
13817 : : struct aead_test_data tdata;
13818 : : int res;
13819 : :
13820 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13821 : 1 : tdata.auth_tag.data[0] += 1;
13822 : : res = test_authenticated_decryption(&tdata);
13823 [ + - ]: 1 : if (res == TEST_SKIPPED)
13824 : : return res;
13825 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13826 : : return TEST_SUCCESS;
13827 : : }
13828 : :
13829 : : static int
13830 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13831 : : {
13832 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13833 : : struct crypto_unittest_params *ut_params = &unittest_params;
13834 : :
13835 : : uint32_t i;
13836 : : int retval;
13837 : : uint8_t *ciphertext, *auth_tag, *buffer_oop;
13838 : : uint16_t plaintext_pad_len;
13839 : : struct rte_cryptodev_info dev_info;
13840 : :
13841 : : /* Verify the capabilities */
13842 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13843 : : const struct rte_cryptodev_symmetric_capability *capability;
13844 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13845 : 1 : cap_idx.algo.aead = tdata->algo;
13846 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13847 [ + - ]: 1 : if (capability == NULL)
13848 : : return TEST_SKIPPED;
13849 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(
13850 : 1 : capability, tdata->key.len, tdata->auth_tag.len,
13851 : 1 : tdata->aad.len, tdata->iv.len))
13852 : : return TEST_SKIPPED;
13853 : :
13854 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13855 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13856 : :
13857 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13858 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13859 : : return TEST_SKIPPED;
13860 : :
13861 : : /* not supported with CPU crypto */
13862 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13863 : : return TEST_SKIPPED;
13864 : :
13865 : : /* Create AEAD session */
13866 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13867 : 1 : tdata->algo,
13868 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13869 : 1 : tdata->key.data, tdata->key.len,
13870 : 1 : tdata->aad.len, tdata->auth_tag.len,
13871 : 1 : tdata->iv.len);
13872 [ + - ]: 1 : if (retval < 0)
13873 : : return retval;
13874 : :
13875 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13876 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13877 : :
13878 : : /* clear mbuf payload */
13879 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13880 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13881 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13882 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13883 : :
13884 : : /* Create AEAD operation */
13885 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13886 [ + - ]: 1 : if (retval < 0)
13887 : : return retval;
13888 : :
13889 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13890 : :
13891 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13892 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13893 : :
13894 : : /* Process crypto operation */
13895 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13896 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13897 : : 0);
13898 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13899 : : return retval;
13900 : : } else
13901 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13902 : : ut_params->op), "failed to process sym crypto op");
13903 : :
13904 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13905 : : "crypto op processing failed");
13906 : :
13907 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13908 : :
13909 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13910 : : ut_params->op->sym->cipher.data.offset);
13911 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13912 : :
13913 : : /* Check if the data within the offset range is not overwritten in the OOP */
13914 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
13915 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
13916 [ - + ]: 16 : if (buffer_oop[i]) {
13917 : 0 : RTE_LOG(ERR, USER1,
13918 : : "Incorrect value of the output buffer header\n");
13919 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
13920 : 0 : ut_params->op->sym->cipher.data.offset);
13921 : 0 : return TEST_FAILED;
13922 : : }
13923 : : }
13924 : :
13925 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13926 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13927 : :
13928 : : /* Validate obuf */
13929 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13930 : : ciphertext,
13931 : : tdata->ciphertext.data,
13932 : : tdata->ciphertext.len,
13933 : : "Ciphertext data not as expected");
13934 : :
13935 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13936 : : auth_tag,
13937 : : tdata->auth_tag.data,
13938 : : tdata->auth_tag.len,
13939 : : "Generated auth tag not as expected");
13940 : :
13941 : : return 0;
13942 : :
13943 : : }
13944 : :
13945 : : static int
13946 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13947 : : {
13948 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
13949 : : }
13950 : :
13951 : : static int
13952 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13953 : : {
13954 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13955 : : struct crypto_unittest_params *ut_params = &unittest_params;
13956 : :
13957 : : uint32_t i;
13958 : : int retval;
13959 : : uint8_t *plaintext, *buffer_oop;
13960 : : struct rte_cryptodev_info dev_info;
13961 : :
13962 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13963 : : uint64_t feat_flags = dev_info.feature_flags;
13964 : :
13965 : : /* Verify the capabilities */
13966 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13967 : : const struct rte_cryptodev_symmetric_capability *capability;
13968 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13969 : 1 : cap_idx.algo.aead = tdata->algo;
13970 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13971 : :
13972 [ + - ]: 1 : if (capability == NULL)
13973 : : return TEST_SKIPPED;
13974 : :
13975 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13976 : 1 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13977 : : return TEST_SKIPPED;
13978 : :
13979 : : /* not supported with CPU crypto and raw data-path APIs*/
13980 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13981 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
13982 : : return TEST_SKIPPED;
13983 : :
13984 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13985 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13986 : : printf("Device does not support RAW data-path APIs.\n");
13987 : : return TEST_SKIPPED;
13988 : : }
13989 : :
13990 : : /* Create AEAD session */
13991 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13992 : 1 : tdata->algo,
13993 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13994 : 1 : tdata->key.data, tdata->key.len,
13995 : 1 : tdata->aad.len, tdata->auth_tag.len,
13996 : 1 : tdata->iv.len);
13997 [ + - ]: 1 : if (retval < 0)
13998 : : return retval;
13999 : :
14000 : : /* alloc mbuf and set payload */
14001 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14002 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14003 : :
14004 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14005 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
14006 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
14007 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
14008 : :
14009 : : /* Create AEAD operation */
14010 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14011 [ + - ]: 1 : if (retval < 0)
14012 : : return retval;
14013 : :
14014 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14015 : :
14016 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14017 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
14018 : :
14019 : : /* Process crypto operation */
14020 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14021 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14022 : : 0);
14023 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14024 : : return retval;
14025 : : } else
14026 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14027 : : ut_params->op), "failed to process sym crypto op");
14028 : :
14029 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14030 : : "crypto op processing failed");
14031 : :
14032 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
14033 : : ut_params->op->sym->cipher.data.offset);
14034 : :
14035 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14036 : :
14037 : : /* Check if the data within the offset range is not overwritten in the OOP */
14038 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
14039 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
14040 [ - + ]: 16 : if (buffer_oop[i]) {
14041 : 0 : RTE_LOG(ERR, USER1,
14042 : : "Incorrect value of the output buffer header\n");
14043 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
14044 : 0 : ut_params->op->sym->cipher.data.offset);
14045 : 0 : return TEST_FAILED;
14046 : : }
14047 : : }
14048 : : /* Validate obuf */
14049 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14050 : : plaintext,
14051 : : tdata->plaintext.data,
14052 : : tdata->plaintext.len,
14053 : : "Plaintext data not as expected");
14054 : :
14055 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14056 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14057 : : "Authentication failed");
14058 : : return 0;
14059 : : }
14060 : :
14061 : : static int
14062 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
14063 : : {
14064 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
14065 : : }
14066 : :
14067 : : static int
14068 : 1 : test_authenticated_encryption_sessionless(
14069 : : const struct aead_test_data *tdata)
14070 : : {
14071 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14072 : : struct crypto_unittest_params *ut_params = &unittest_params;
14073 : :
14074 : : int retval;
14075 : : uint8_t *ciphertext, *auth_tag;
14076 : : uint16_t plaintext_pad_len;
14077 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14078 : : struct rte_cryptodev_info dev_info;
14079 : :
14080 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14081 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14082 : :
14083 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14084 : : printf("Device doesn't support Sessionless ops.\n");
14085 : 0 : return TEST_SKIPPED;
14086 : : }
14087 : :
14088 : : /* not supported with CPU crypto */
14089 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14090 : : return TEST_SKIPPED;
14091 : :
14092 : : /* Verify the capabilities */
14093 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14094 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14095 : 1 : cap_idx.algo.aead = tdata->algo;
14096 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14097 : : &cap_idx) == NULL)
14098 : : return TEST_SKIPPED;
14099 : :
14100 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14101 : :
14102 : : /* clear mbuf payload */
14103 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14104 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14105 : :
14106 : : /* Create AEAD operation */
14107 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
14108 [ + - ]: 1 : if (retval < 0)
14109 : : return retval;
14110 : :
14111 : : /* Create GCM xform */
14112 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14113 : 1 : retval = create_aead_xform(ut_params->op,
14114 : 1 : tdata->algo,
14115 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
14116 : : key, tdata->key.len,
14117 : 1 : tdata->aad.len, tdata->auth_tag.len,
14118 : 1 : tdata->iv.len);
14119 [ + - ]: 1 : if (retval < 0)
14120 : : return retval;
14121 : :
14122 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14123 : :
14124 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14125 : : RTE_CRYPTO_OP_SESSIONLESS,
14126 : : "crypto op session type not sessionless");
14127 : :
14128 : : /* Process crypto operation */
14129 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14130 : : ut_params->op), "failed to process sym crypto op");
14131 : :
14132 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14133 : :
14134 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14135 : : "crypto op status not success");
14136 : :
14137 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14138 : :
14139 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14140 : : ut_params->op->sym->cipher.data.offset);
14141 : 1 : auth_tag = ciphertext + plaintext_pad_len;
14142 : :
14143 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
14144 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
14145 : :
14146 : : /* Validate obuf */
14147 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14148 : : ciphertext,
14149 : : tdata->ciphertext.data,
14150 : : tdata->ciphertext.len,
14151 : : "Ciphertext data not as expected");
14152 : :
14153 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14154 : : auth_tag,
14155 : : tdata->auth_tag.data,
14156 : : tdata->auth_tag.len,
14157 : : "Generated auth tag not as expected");
14158 : :
14159 : : return 0;
14160 : :
14161 : : }
14162 : :
14163 : : static int
14164 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
14165 : : {
14166 : 1 : return test_authenticated_encryption_sessionless(
14167 : : &gcm_test_case_5);
14168 : : }
14169 : :
14170 : : static int
14171 : 1 : test_authenticated_decryption_sessionless(
14172 : : const struct aead_test_data *tdata)
14173 : : {
14174 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14175 : : struct crypto_unittest_params *ut_params = &unittest_params;
14176 : :
14177 : : int retval;
14178 : : uint8_t *plaintext;
14179 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14180 : : struct rte_cryptodev_info dev_info;
14181 : :
14182 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14183 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14184 : :
14185 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14186 : : printf("Device doesn't support Sessionless ops.\n");
14187 : 0 : return TEST_SKIPPED;
14188 : : }
14189 : :
14190 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14191 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14192 : : printf("Device doesn't support RAW data-path APIs.\n");
14193 : 0 : return TEST_SKIPPED;
14194 : : }
14195 : :
14196 : : /* not supported with CPU crypto */
14197 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14198 : : return TEST_SKIPPED;
14199 : :
14200 : : /* Verify the capabilities */
14201 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14202 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14203 : 1 : cap_idx.algo.aead = tdata->algo;
14204 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14205 : : &cap_idx) == NULL)
14206 : : return TEST_SKIPPED;
14207 : :
14208 : : /* alloc mbuf and set payload */
14209 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14210 : :
14211 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14212 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14213 : :
14214 : : /* Create AEAD operation */
14215 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14216 [ + - ]: 1 : if (retval < 0)
14217 : : return retval;
14218 : :
14219 : : /* Create AEAD xform */
14220 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14221 : 1 : retval = create_aead_xform(ut_params->op,
14222 : 1 : tdata->algo,
14223 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
14224 : : key, tdata->key.len,
14225 : 1 : tdata->aad.len, tdata->auth_tag.len,
14226 : 1 : tdata->iv.len);
14227 [ + - ]: 1 : if (retval < 0)
14228 : : return retval;
14229 : :
14230 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14231 : :
14232 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14233 : : RTE_CRYPTO_OP_SESSIONLESS,
14234 : : "crypto op session type not sessionless");
14235 : :
14236 : : /* Process crypto operation */
14237 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14238 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14239 : : 0);
14240 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14241 : : return retval;
14242 : : } else
14243 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
14244 : : ts_params->valid_devs[0], ut_params->op),
14245 : : "failed to process sym crypto op");
14246 : :
14247 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14248 : :
14249 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14250 : : "crypto op status not success");
14251 : :
14252 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14253 : : ut_params->op->sym->cipher.data.offset);
14254 : :
14255 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14256 : :
14257 : : /* Validate obuf */
14258 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14259 : : plaintext,
14260 : : tdata->plaintext.data,
14261 : : tdata->plaintext.len,
14262 : : "Plaintext data not as expected");
14263 : :
14264 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14265 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14266 : : "Authentication failed");
14267 : : return 0;
14268 : : }
14269 : :
14270 : : static int
14271 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
14272 : : {
14273 : 1 : return test_authenticated_decryption_sessionless(
14274 : : &gcm_test_case_5);
14275 : : }
14276 : :
14277 : : static int
14278 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
14279 : : {
14280 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
14281 : : }
14282 : :
14283 : : static int
14284 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
14285 : : {
14286 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
14287 : : }
14288 : :
14289 : : static int
14290 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
14291 : : {
14292 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
14293 : : }
14294 : :
14295 : : static int
14296 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_4(void)
14297 : : {
14298 : 1 : return test_authenticated_encryption(&ccm_test_case_128_4);
14299 : : }
14300 : :
14301 : : static int
14302 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
14303 : : {
14304 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
14305 : : }
14306 : :
14307 : : static int
14308 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
14309 : : {
14310 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
14311 : : }
14312 : :
14313 : : static int
14314 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
14315 : : {
14316 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
14317 : : }
14318 : :
14319 : : static int
14320 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_4(void)
14321 : : {
14322 : 1 : return test_authenticated_decryption(&ccm_test_case_128_4);
14323 : : }
14324 : :
14325 : : static int
14326 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
14327 : : {
14328 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
14329 : : }
14330 : :
14331 : : static int
14332 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
14333 : : {
14334 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
14335 : : }
14336 : :
14337 : : static int
14338 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
14339 : : {
14340 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
14341 : : }
14342 : :
14343 : : static int
14344 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
14345 : : {
14346 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
14347 : : }
14348 : :
14349 : : static int
14350 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
14351 : : {
14352 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
14353 : : }
14354 : :
14355 : : static int
14356 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14357 : : {
14358 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
14359 : : }
14360 : :
14361 : : static int
14362 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14363 : : {
14364 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
14365 : : }
14366 : :
14367 : : static int
14368 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14369 : : {
14370 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
14371 : : }
14372 : :
14373 : : static int
14374 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14375 : : {
14376 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
14377 : : }
14378 : :
14379 : : static int
14380 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14381 : : {
14382 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
14383 : : }
14384 : :
14385 : : static int
14386 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14387 : : {
14388 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
14389 : : }
14390 : :
14391 : : static int
14392 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14393 : : {
14394 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
14395 : : }
14396 : :
14397 : : static int
14398 : 1 : test_stats(void)
14399 : : {
14400 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14401 : : struct rte_cryptodev_stats stats;
14402 : :
14403 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14404 : : return TEST_SKIPPED;
14405 : :
14406 : : /* Verify the capabilities */
14407 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14408 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14409 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14410 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14411 : : &cap_idx) == NULL)
14412 : : return TEST_SKIPPED;
14413 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14414 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14415 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14416 : : &cap_idx) == NULL)
14417 : : return TEST_SKIPPED;
14418 : :
14419 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14420 : : == -ENOTSUP)
14421 : : return TEST_SKIPPED;
14422 : :
14423 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14424 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14425 : : &stats) == -ENODEV),
14426 : : "rte_cryptodev_stats_get invalid dev failed");
14427 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14428 : : "rte_cryptodev_stats_get invalid Param failed");
14429 : :
14430 : : /* Test expected values */
14431 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
14432 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14433 : : &stats),
14434 : : "rte_cryptodev_stats_get failed");
14435 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14436 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
14437 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
14438 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
14439 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
14440 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14441 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
14442 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14443 : :
14444 : : /* invalid device but should ignore and not reset device stats*/
14445 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14446 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14447 : : &stats),
14448 : : "rte_cryptodev_stats_get failed");
14449 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14450 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14451 : :
14452 : : /* check that a valid reset clears stats */
14453 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14454 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14455 : : &stats),
14456 : : "rte_cryptodev_stats_get failed");
14457 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
14458 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14459 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
14460 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14461 : :
14462 : : return TEST_SUCCESS;
14463 : : }
14464 : :
14465 : : static int
14466 : 1 : test_device_reconfigure(void)
14467 : : {
14468 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14469 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14470 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14471 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14472 : 1 : .mp_session = ts_params->session_mpool
14473 : : };
14474 : : uint16_t qp_id, dev_id, num_devs = 0;
14475 : :
14476 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14477 : : "Need at least %d devices for test", 1);
14478 : :
14479 : 1 : dev_id = ts_params->valid_devs[0];
14480 : :
14481 : : /* Stop the device in case it's started so it can be configured */
14482 : 1 : rte_cryptodev_stop(dev_id);
14483 : :
14484 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14485 : : "Failed test for rte_cryptodev_configure: "
14486 : : "dev_num %u", dev_id);
14487 : :
14488 : : /* Reconfigure with same configure params */
14489 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14490 : : "Failed test for rte_cryptodev_configure: "
14491 : : "dev_num %u", dev_id);
14492 : :
14493 : : /* Reconfigure with just one queue pair */
14494 : 1 : ts_params->conf.nb_queue_pairs = 1;
14495 : :
14496 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14497 : : &ts_params->conf),
14498 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14499 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14500 : :
14501 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14502 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14503 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14504 : : rte_cryptodev_socket_id(
14505 : : ts_params->valid_devs[0])),
14506 : : "Failed test for "
14507 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14508 : : "%u on qp %u on cryptodev %u",
14509 : : qp_conf.nb_descriptors, qp_id,
14510 : : ts_params->valid_devs[0]);
14511 : : }
14512 : :
14513 : : /* Reconfigure with max number of queue pairs */
14514 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
14515 : :
14516 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14517 : : &ts_params->conf),
14518 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14519 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14520 : :
14521 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14522 : :
14523 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14524 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14525 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14526 : : rte_cryptodev_socket_id(
14527 : : ts_params->valid_devs[0])),
14528 : : "Failed test for "
14529 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14530 : : "%u on qp %u on cryptodev %u",
14531 : : qp_conf.nb_descriptors, qp_id,
14532 : : ts_params->valid_devs[0]);
14533 : : }
14534 : :
14535 : : /* Start the device */
14536 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14537 : : "Failed to start cryptodev %u",
14538 : : ts_params->valid_devs[0]);
14539 : :
14540 : : /* Test expected values */
14541 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14542 : : }
14543 : :
14544 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14545 : : struct crypto_unittest_params *ut_params,
14546 : : enum rte_crypto_auth_operation op,
14547 : : const struct HMAC_MD5_vector *test_case)
14548 : : {
14549 : : uint8_t key[64];
14550 : :
14551 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
14552 : :
14553 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14554 : 4 : ut_params->auth_xform.next = NULL;
14555 : 4 : ut_params->auth_xform.auth.op = op;
14556 : :
14557 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14558 : :
14559 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14560 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
14561 : 4 : ut_params->auth_xform.auth.key.data = key;
14562 : :
14563 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
14564 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14565 : : ts_params->session_mpool);
14566 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14567 : : return TEST_SKIPPED;
14568 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14569 : :
14570 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14571 : :
14572 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14573 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14574 : :
14575 : 4 : return 0;
14576 : : }
14577 : :
14578 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14579 : : const struct HMAC_MD5_vector *test_case,
14580 : : uint8_t **plaintext)
14581 : : {
14582 : : uint16_t plaintext_pad_len;
14583 : :
14584 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14585 : :
14586 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14587 : : 16);
14588 : :
14589 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14590 : : plaintext_pad_len);
14591 : 4 : memcpy(*plaintext, test_case->plaintext.data,
14592 : 4 : test_case->plaintext.len);
14593 : :
14594 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14595 : : ut_params->ibuf, MD5_DIGEST_LEN);
14596 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14597 : : "no room to append digest");
14598 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14599 : : ut_params->ibuf, plaintext_pad_len);
14600 : :
14601 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14602 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14603 [ - + ]: 2 : test_case->auth_tag.len);
14604 : : }
14605 : :
14606 : 4 : sym_op->auth.data.offset = 0;
14607 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
14608 : :
14609 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14610 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14611 : :
14612 : 4 : return 0;
14613 : : }
14614 : :
14615 : : static int
14616 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14617 : : {
14618 : : uint16_t plaintext_pad_len;
14619 : : uint8_t *plaintext, *auth_tag;
14620 : : int ret;
14621 : :
14622 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14623 : : struct crypto_unittest_params *ut_params = &unittest_params;
14624 : : struct rte_cryptodev_info dev_info;
14625 : :
14626 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14627 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14628 : :
14629 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14630 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14631 : : printf("Device doesn't support RAW data-path APIs.\n");
14632 : 0 : return TEST_SKIPPED;
14633 : : }
14634 : :
14635 : : /* Verify the capabilities */
14636 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14637 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14638 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14639 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14640 : : &cap_idx) == NULL)
14641 : : return TEST_SKIPPED;
14642 : :
14643 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14644 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14645 : : return TEST_FAILED;
14646 : :
14647 : : /* Generate Crypto op data structure */
14648 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14649 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14650 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14651 : : "Failed to allocate symmetric crypto operation struct");
14652 : :
14653 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14654 : : 16);
14655 : :
14656 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14657 : : return TEST_FAILED;
14658 : :
14659 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14660 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14661 : : ut_params->op);
14662 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14663 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14664 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14665 : : return ret;
14666 : : } else
14667 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14668 : : process_crypto_request(ts_params->valid_devs[0],
14669 : : ut_params->op),
14670 : : "failed to process sym crypto op");
14671 : :
14672 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14673 : : "crypto op processing failed");
14674 : :
14675 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
14676 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14677 : : uint8_t *, plaintext_pad_len);
14678 : : } else {
14679 : 2 : auth_tag = plaintext + plaintext_pad_len;
14680 : : }
14681 : :
14682 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14683 : : auth_tag,
14684 : : test_case->auth_tag.data,
14685 : : test_case->auth_tag.len,
14686 : : "HMAC_MD5 generated tag not as expected");
14687 : :
14688 : : return TEST_SUCCESS;
14689 : : }
14690 : :
14691 : : static int
14692 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14693 : : {
14694 : : uint8_t *plaintext;
14695 : : int ret;
14696 : :
14697 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14698 : : struct crypto_unittest_params *ut_params = &unittest_params;
14699 : : struct rte_cryptodev_info dev_info;
14700 : :
14701 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14702 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14703 : :
14704 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14705 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14706 : : printf("Device doesn't support RAW data-path APIs.\n");
14707 : 0 : return TEST_SKIPPED;
14708 : : }
14709 : :
14710 : : /* Verify the capabilities */
14711 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14712 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14713 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14714 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14715 : : &cap_idx) == NULL)
14716 : : return TEST_SKIPPED;
14717 : :
14718 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14719 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14720 : : return TEST_FAILED;
14721 : : }
14722 : :
14723 : : /* Generate Crypto op data structure */
14724 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14725 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14726 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14727 : : "Failed to allocate symmetric crypto operation struct");
14728 : :
14729 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14730 : : return TEST_FAILED;
14731 : :
14732 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14733 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14734 : : ut_params->op);
14735 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14736 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14737 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14738 : : return ret;
14739 : : } else
14740 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14741 : : process_crypto_request(ts_params->valid_devs[0],
14742 : : ut_params->op),
14743 : : "failed to process sym crypto op");
14744 : :
14745 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14746 : : "HMAC_MD5 crypto op processing failed");
14747 : :
14748 : : return TEST_SUCCESS;
14749 : : }
14750 : :
14751 : : static int
14752 : 1 : test_MD5_HMAC_generate_case_1(void)
14753 : : {
14754 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14755 : : }
14756 : :
14757 : : static int
14758 : 1 : test_MD5_HMAC_verify_case_1(void)
14759 : : {
14760 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14761 : : }
14762 : :
14763 : : static int
14764 : 1 : test_MD5_HMAC_generate_case_2(void)
14765 : : {
14766 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14767 : : }
14768 : :
14769 : : static int
14770 : 1 : test_MD5_HMAC_verify_case_2(void)
14771 : : {
14772 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14773 : : }
14774 : :
14775 : : static int
14776 : 1 : test_multi_session(void)
14777 : : {
14778 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14779 : : struct crypto_unittest_params *ut_params = &unittest_params;
14780 : : struct rte_cryptodev_info dev_info;
14781 : : int i, nb_sess, ret = TEST_SUCCESS;
14782 : : void **sessions;
14783 : :
14784 : : /* Verify the capabilities */
14785 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14786 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14787 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14788 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14789 : : &cap_idx) == NULL)
14790 : : return TEST_SKIPPED;
14791 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14792 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14793 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14794 : : &cap_idx) == NULL)
14795 : : return TEST_SKIPPED;
14796 : :
14797 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14798 : : aes_cbc_key, hmac_sha512_key);
14799 : :
14800 : :
14801 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14802 : :
14803 : 1 : sessions = rte_malloc(NULL,
14804 : : sizeof(void *) *
14805 : : (MAX_NB_SESSIONS + 1), 0);
14806 : :
14807 : : /* Create multiple crypto sessions*/
14808 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
14809 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
14810 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14811 : : ts_params->session_mpool);
14812 [ - + ]: 4 : if (sessions[i] == NULL) {
14813 : : nb_sess = i;
14814 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14815 : : ret = TEST_SKIPPED;
14816 : : else {
14817 : : ret = TEST_FAILED;
14818 : : printf("TestCase %s() line %d failed : "
14819 : : "Session creation failed at session number %u",
14820 : : __func__, __LINE__, i);
14821 : : }
14822 : : break;
14823 : : }
14824 : :
14825 : :
14826 : : /* Attempt to send a request on each session */
14827 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14828 : : sessions[i],
14829 : : ut_params,
14830 : : ts_params,
14831 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14832 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14833 : : aes_cbc_iv);
14834 : :
14835 : : /* free crypto operation structure */
14836 : 4 : rte_crypto_op_free(ut_params->op);
14837 : 4 : ut_params->op = NULL;
14838 : :
14839 : : /*
14840 : : * free mbuf - both obuf and ibuf are usually the same,
14841 : : * so check if they point at the same address is necessary,
14842 : : * to avoid freeing the mbuf twice.
14843 : : */
14844 [ + - ]: 4 : if (ut_params->obuf) {
14845 : 4 : rte_pktmbuf_free(ut_params->obuf);
14846 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
14847 : 4 : ut_params->ibuf = 0;
14848 : 4 : ut_params->obuf = 0;
14849 : : }
14850 [ - + ]: 4 : if (ut_params->ibuf) {
14851 : 0 : rte_pktmbuf_free(ut_params->ibuf);
14852 : 0 : ut_params->ibuf = 0;
14853 : : }
14854 : :
14855 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
14856 : 0 : i++;
14857 : 0 : break;
14858 : : }
14859 : : }
14860 : :
14861 : : nb_sess = i;
14862 : :
14863 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
14864 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14865 : 4 : sessions[i]);
14866 : : }
14867 : :
14868 : 1 : rte_free(sessions);
14869 : :
14870 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14871 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14872 : :
14873 : : return ret;
14874 : : }
14875 : :
14876 : : struct multi_session_params {
14877 : : struct crypto_unittest_params ut_params;
14878 : : uint8_t *cipher_key;
14879 : : uint8_t *hmac_key;
14880 : : const uint8_t *cipher;
14881 : : const uint8_t *digest;
14882 : : uint8_t *iv;
14883 : : };
14884 : :
14885 : : #define MB_SESSION_NUMBER 3
14886 : :
14887 : : static int
14888 : 1 : test_multi_session_random_usage(void)
14889 : : {
14890 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14891 : : struct rte_cryptodev_info dev_info;
14892 : : int index = 0, ret = TEST_SUCCESS;
14893 : : uint32_t nb_sess, i, j;
14894 : : void **sessions;
14895 : 1 : struct multi_session_params ut_paramz[] = {
14896 : :
14897 : : {
14898 : : .cipher_key = ms_aes_cbc_key0,
14899 : : .hmac_key = ms_hmac_key0,
14900 : : .cipher = ms_aes_cbc_cipher0,
14901 : : .digest = ms_hmac_digest0,
14902 : : .iv = ms_aes_cbc_iv0
14903 : : },
14904 : : {
14905 : : .cipher_key = ms_aes_cbc_key1,
14906 : : .hmac_key = ms_hmac_key1,
14907 : : .cipher = ms_aes_cbc_cipher1,
14908 : : .digest = ms_hmac_digest1,
14909 : : .iv = ms_aes_cbc_iv1
14910 : : },
14911 : : {
14912 : : .cipher_key = ms_aes_cbc_key2,
14913 : : .hmac_key = ms_hmac_key2,
14914 : : .cipher = ms_aes_cbc_cipher2,
14915 : : .digest = ms_hmac_digest2,
14916 : : .iv = ms_aes_cbc_iv2
14917 : : },
14918 : :
14919 : : };
14920 : :
14921 : : /* Verify the capabilities */
14922 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14923 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14924 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14925 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14926 : : &cap_idx) == NULL)
14927 : : return TEST_SKIPPED;
14928 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14929 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14930 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14931 : : &cap_idx) == NULL)
14932 : : return TEST_SKIPPED;
14933 : :
14934 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14935 : :
14936 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
14937 : : * MAX_NB_SESSIONS) + 1, 0);
14938 : :
14939 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
14940 : :
14941 : 3 : ut_paramz[i].ut_params = unittest_params;
14942 : :
14943 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14944 : : &ut_paramz[i].ut_params,
14945 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14946 : :
14947 : : /* Create multiple crypto sessions*/
14948 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
14949 : 3 : ts_params->valid_devs[0],
14950 : : &ut_paramz[i].ut_params.auth_xform,
14951 : : ts_params->session_mpool);
14952 [ - + ]: 3 : if (sessions[i] == NULL) {
14953 : : nb_sess = i;
14954 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14955 : : ret = TEST_SKIPPED;
14956 : : else {
14957 : : ret = TEST_FAILED;
14958 : : printf("TestCase %s() line %d failed : "
14959 : : "Session creation failed at session number %u",
14960 : : __func__, __LINE__, i);
14961 : : }
14962 : 0 : goto session_clear;
14963 : : }
14964 : :
14965 : : }
14966 : :
14967 : : nb_sess = i;
14968 : :
14969 : 1 : srand(time(NULL));
14970 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
14971 : :
14972 : 1 : j = rand() % MB_SESSION_NUMBER;
14973 : :
14974 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14975 : 1 : sessions[j],
14976 : : &ut_paramz[j].ut_params,
14977 : : ts_params, ut_paramz[j].cipher,
14978 : : ut_paramz[j].digest,
14979 : 1 : ut_paramz[j].iv);
14980 : :
14981 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
14982 : 1 : ut_paramz[j].ut_params.op = NULL;
14983 : :
14984 : : /*
14985 : : * free mbuf - both obuf and ibuf are usually the same,
14986 : : * so check if they point at the same address is necessary,
14987 : : * to avoid freeing the mbuf twice.
14988 : : */
14989 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
14990 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14991 : 1 : if (ut_paramz[j].ut_params.ibuf
14992 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
14993 : 1 : ut_paramz[j].ut_params.ibuf = 0;
14994 : 1 : ut_paramz[j].ut_params.obuf = 0;
14995 : : }
14996 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
14997 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14998 : 0 : ut_paramz[j].ut_params.ibuf = 0;
14999 : : }
15000 : :
15001 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
15002 : 1 : index = i;
15003 : 1 : break;
15004 : : }
15005 : : }
15006 : :
15007 : 0 : session_clear:
15008 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
15009 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
15010 : 3 : sessions[i]);
15011 : : }
15012 : :
15013 : 1 : rte_free(sessions);
15014 : :
15015 [ + - ]: 1 : if (ret != TEST_SKIPPED)
15016 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
15017 : :
15018 : : return TEST_SUCCESS;
15019 : : }
15020 : :
15021 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
15022 : : 0xab, 0xab, 0xab, 0xab,
15023 : : 0xab, 0xab, 0xab, 0xab,
15024 : : 0xab, 0xab, 0xab, 0xab};
15025 : :
15026 : : static int
15027 : 0 : test_null_invalid_operation(void)
15028 : : {
15029 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15030 : : struct crypto_unittest_params *ut_params = &unittest_params;
15031 : :
15032 : : /* This test is for NULL PMD only */
15033 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15034 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15035 : : return TEST_SKIPPED;
15036 : :
15037 : : /* Setup Cipher Parameters */
15038 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15039 : 0 : ut_params->cipher_xform.next = NULL;
15040 : :
15041 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
15042 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15043 : :
15044 : : /* Create Crypto session*/
15045 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15046 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15047 : : ts_params->session_mpool);
15048 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15049 : : return TEST_SKIPPED;
15050 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15051 : : "Session creation succeeded unexpectedly");
15052 : :
15053 : : /* Setup HMAC Parameters */
15054 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15055 : 0 : ut_params->auth_xform.next = NULL;
15056 : :
15057 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
15058 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15059 : :
15060 : : /* Create Crypto session*/
15061 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15062 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
15063 : : ts_params->session_mpool);
15064 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15065 : : return TEST_SKIPPED;
15066 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15067 : : "Session creation succeeded unexpectedly");
15068 : :
15069 : : return TEST_SUCCESS;
15070 : : }
15071 : :
15072 : :
15073 : : #define NULL_BURST_LENGTH (32)
15074 : :
15075 : : static int
15076 : 0 : test_null_burst_operation(void)
15077 : : {
15078 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15079 : : struct crypto_unittest_params *ut_params = &unittest_params;
15080 : :
15081 : : unsigned i, burst_len = NULL_BURST_LENGTH;
15082 : :
15083 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
15084 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
15085 : :
15086 : : /* This test is for NULL PMD only */
15087 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15088 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15089 : : return TEST_SKIPPED;
15090 : :
15091 : : /* Setup Cipher Parameters */
15092 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15093 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15094 : :
15095 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15096 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15097 : :
15098 : : /* Setup HMAC Parameters */
15099 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15100 : 0 : ut_params->auth_xform.next = NULL;
15101 : :
15102 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15103 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15104 : :
15105 : : /* Create Crypto session*/
15106 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15107 : 0 : ts_params->valid_devs[0],
15108 : : &ut_params->auth_xform,
15109 : : ts_params->session_mpool);
15110 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15111 : : return TEST_SKIPPED;
15112 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15113 : :
15114 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
15115 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
15116 : : burst_len, "failed to generate burst of crypto ops");
15117 : :
15118 : : /* Generate an operation for each mbuf in burst */
15119 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15120 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15121 : :
15122 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
15123 : :
15124 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
15125 : : sizeof(unsigned));
15126 : 0 : *data = i;
15127 : :
15128 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
15129 : :
15130 : 0 : burst[i]->sym->m_src = m;
15131 : : }
15132 : :
15133 : : /* Process crypto operation */
15134 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
15135 : : 0, burst, burst_len),
15136 : : burst_len,
15137 : : "Error enqueuing burst");
15138 : :
15139 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
15140 : : 0, burst_dequeued, burst_len),
15141 : : burst_len,
15142 : : "Error dequeuing burst");
15143 : :
15144 : :
15145 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15146 [ # # ]: 0 : TEST_ASSERT_EQUAL(
15147 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
15148 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
15149 : : uint32_t *),
15150 : : "data not as expected");
15151 : :
15152 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
15153 : 0 : rte_crypto_op_free(burst[i]);
15154 : : }
15155 : :
15156 : : return TEST_SUCCESS;
15157 : : }
15158 : :
15159 : : static uint16_t
15160 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15161 : : uint16_t nb_ops, void *user_param)
15162 : : {
15163 : : RTE_SET_USED(dev_id);
15164 : : RTE_SET_USED(qp_id);
15165 : : RTE_SET_USED(ops);
15166 : : RTE_SET_USED(user_param);
15167 : :
15168 : 0 : enq_cb_called = true;
15169 : : printf("crypto enqueue callback called\n");
15170 : 0 : return nb_ops;
15171 : : }
15172 : :
15173 : : static uint16_t
15174 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15175 : : uint16_t nb_ops, void *user_param)
15176 : : {
15177 : : RTE_SET_USED(dev_id);
15178 : : RTE_SET_USED(qp_id);
15179 : : RTE_SET_USED(ops);
15180 : : RTE_SET_USED(user_param);
15181 : :
15182 : 0 : deq_cb_called = true;
15183 : : printf("crypto dequeue callback called\n");
15184 : 0 : return nb_ops;
15185 : : }
15186 : :
15187 : : /*
15188 : : * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
15189 : : */
15190 : : static int
15191 : 0 : test_enqdeq_callback_null_cipher(void)
15192 : : {
15193 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15194 : : struct crypto_unittest_params *ut_params = &unittest_params;
15195 : :
15196 : : /* Setup Cipher Parameters */
15197 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15198 : 0 : ut_params->cipher_xform.next = NULL;
15199 : :
15200 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15201 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15202 : :
15203 : : /* Create Crypto session */
15204 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
15205 : : &ut_params->cipher_xform, ts_params->session_mpool);
15206 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15207 : : return TEST_SKIPPED;
15208 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15209 : :
15210 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15211 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
15212 : :
15213 : : /* Allocate mbuf */
15214 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15215 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
15216 : :
15217 : : /* Append some random data */
15218 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
15219 : : "no room to append data");
15220 : :
15221 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15222 : :
15223 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15224 : :
15225 : : /* Process crypto operation */
15226 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
15227 : : "failed to process sym crypto op");
15228 : :
15229 : : return 0;
15230 : : }
15231 : :
15232 : : static int
15233 : 1 : test_enq_callback_setup(void)
15234 : : {
15235 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15236 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15237 : : struct rte_cryptodev_info dev_info;
15238 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15239 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15240 : : };
15241 : :
15242 : : struct rte_cryptodev_cb *cb;
15243 : : uint16_t qp_id = 0;
15244 : : int j = 0;
15245 : :
15246 : : /* Skip test if synchronous API is used */
15247 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15248 : : return TEST_SKIPPED;
15249 : :
15250 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15251 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15252 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15253 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15254 : : &cap_idx) == NULL)
15255 : : return TEST_SKIPPED;
15256 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15257 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15258 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15259 : : &cap_idx) == NULL)
15260 : : return TEST_SKIPPED;
15261 : :
15262 : : /* Stop the device in case it's started so it can be configured */
15263 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15264 : :
15265 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15266 : :
15267 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15268 : : &ts_params->conf),
15269 : : "Failed to configure cryptodev %u",
15270 : : ts_params->valid_devs[0]);
15271 : :
15272 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15273 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15274 : :
15275 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15276 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15277 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15278 : : "Failed test for "
15279 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15280 : : "%u on qp %u on cryptodev %u",
15281 : : qp_conf.nb_descriptors, qp_id,
15282 : : ts_params->valid_devs[0]);
15283 : :
15284 : 0 : enq_cb_called = false;
15285 : : /* Test with invalid crypto device */
15286 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
15287 : : qp_id, test_enq_callback, NULL);
15288 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15289 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15290 : : "rte_cryptodev_add_enq_callback() "
15291 : : "Not supported, skipped\n", __func__, __LINE__);
15292 : 0 : return TEST_SKIPPED;
15293 : : }
15294 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15295 : : "cryptodev %u did not fail",
15296 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15297 : :
15298 : : /* Test with invalid queue pair */
15299 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15300 : 0 : dev_info.max_nb_queue_pairs + 1,
15301 : : test_enq_callback, NULL);
15302 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15303 : : "cryptodev %u did not fail",
15304 : : dev_info.max_nb_queue_pairs + 1,
15305 : : ts_params->valid_devs[0]);
15306 : :
15307 : : /* Test with NULL callback */
15308 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15309 : : qp_id, NULL, NULL);
15310 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15311 : : "cryptodev %u did not fail",
15312 : : qp_id, ts_params->valid_devs[0]);
15313 : :
15314 : : /* Test with valid configuration */
15315 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15316 : : qp_id, test_enq_callback, NULL);
15317 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15318 : : "qp %u on cryptodev %u",
15319 : : qp_id, ts_params->valid_devs[0]);
15320 : :
15321 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15322 : :
15323 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
15324 : :
15325 : : /* Wait until callback not called. */
15326 [ # # # # ]: 0 : while (!enq_cb_called && (j++ < 10))
15327 : : rte_delay_ms(10);
15328 : :
15329 : : /* Test with invalid crypto device */
15330 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15331 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15332 : : "Expected call to fail as crypto device is invalid");
15333 : :
15334 : : /* Test with invalid queue pair */
15335 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15336 : : ts_params->valid_devs[0],
15337 : : dev_info.max_nb_queue_pairs + 1, cb),
15338 : : "Expected call to fail as queue pair is invalid");
15339 : :
15340 : : /* Test with NULL callback */
15341 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15342 : : ts_params->valid_devs[0], qp_id, NULL),
15343 : : "Expected call to fail as callback is NULL");
15344 : :
15345 : : /* Test with valid configuration */
15346 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
15347 : : ts_params->valid_devs[0], qp_id, cb),
15348 : : "Failed test to remove callback on "
15349 : : "qp %u on cryptodev %u",
15350 : : qp_id, ts_params->valid_devs[0]);
15351 : :
15352 [ # # ]: 0 : TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
15353 : :
15354 : : return TEST_SUCCESS;
15355 : : }
15356 : :
15357 : : static int
15358 : 1 : test_deq_callback_setup(void)
15359 : : {
15360 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15361 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15362 : : struct rte_cryptodev_info dev_info;
15363 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15364 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15365 : : };
15366 : :
15367 : : struct rte_cryptodev_cb *cb;
15368 : : uint16_t qp_id = 0;
15369 : : int j = 0;
15370 : :
15371 : : /* Skip test if synchronous API is used */
15372 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15373 : : return TEST_SKIPPED;
15374 : :
15375 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15376 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15377 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15378 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15379 : : &cap_idx) == NULL)
15380 : : return TEST_SKIPPED;
15381 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15382 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15383 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15384 : : &cap_idx) == NULL)
15385 : : return TEST_SKIPPED;
15386 : :
15387 : : /* Stop the device in case it's started so it can be configured */
15388 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15389 : :
15390 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15391 : :
15392 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15393 : : &ts_params->conf),
15394 : : "Failed to configure cryptodev %u",
15395 : : ts_params->valid_devs[0]);
15396 : :
15397 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15398 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15399 : :
15400 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15401 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15402 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15403 : : "Failed test for "
15404 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15405 : : "%u on qp %u on cryptodev %u",
15406 : : qp_conf.nb_descriptors, qp_id,
15407 : : ts_params->valid_devs[0]);
15408 : :
15409 : 0 : deq_cb_called = false;
15410 : : /* Test with invalid crypto device */
15411 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15412 : : qp_id, test_deq_callback, NULL);
15413 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15414 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15415 : : "rte_cryptodev_add_deq_callback() "
15416 : : "Not supported, skipped\n", __func__, __LINE__);
15417 : 0 : return TEST_SKIPPED;
15418 : : }
15419 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15420 : : "cryptodev %u did not fail",
15421 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15422 : :
15423 : : /* Test with invalid queue pair */
15424 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15425 : 0 : dev_info.max_nb_queue_pairs + 1,
15426 : : test_deq_callback, NULL);
15427 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15428 : : "cryptodev %u did not fail",
15429 : : dev_info.max_nb_queue_pairs + 1,
15430 : : ts_params->valid_devs[0]);
15431 : :
15432 : : /* Test with NULL callback */
15433 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15434 : : qp_id, NULL, NULL);
15435 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15436 : : "cryptodev %u did not fail",
15437 : : qp_id, ts_params->valid_devs[0]);
15438 : :
15439 : : /* Test with valid configuration */
15440 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15441 : : qp_id, test_deq_callback, NULL);
15442 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15443 : : "qp %u on cryptodev %u",
15444 : : qp_id, ts_params->valid_devs[0]);
15445 : :
15446 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15447 : :
15448 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15449 : :
15450 : : /* Wait until callback not called. */
15451 [ # # # # ]: 0 : while (!deq_cb_called && (j++ < 10))
15452 : : rte_delay_ms(10);
15453 : :
15454 : : /* Test with invalid crypto device */
15455 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15456 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15457 : : "Expected call to fail as crypto device is invalid");
15458 : :
15459 : : /* Test with invalid queue pair */
15460 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15461 : : ts_params->valid_devs[0],
15462 : : dev_info.max_nb_queue_pairs + 1, cb),
15463 : : "Expected call to fail as queue pair is invalid");
15464 : :
15465 : : /* Test with NULL callback */
15466 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15467 : : ts_params->valid_devs[0], qp_id, NULL),
15468 : : "Expected call to fail as callback is NULL");
15469 : :
15470 : : /* Test with valid configuration */
15471 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15472 : : ts_params->valid_devs[0], qp_id, cb),
15473 : : "Failed test to remove callback on "
15474 : : "qp %u on cryptodev %u",
15475 : : qp_id, ts_params->valid_devs[0]);
15476 : :
15477 [ # # ]: 0 : TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15478 : :
15479 : : return TEST_SUCCESS;
15480 : : }
15481 : :
15482 : : static void
15483 : : generate_gmac_large_plaintext(uint8_t *data)
15484 : : {
15485 : : uint16_t i;
15486 : :
15487 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15488 : 4082 : memcpy(&data[i], &data[0], 32);
15489 : : }
15490 : :
15491 : : static int
15492 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
15493 : : const struct gmac_test_data *tdata)
15494 : : {
15495 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15496 : : struct crypto_unittest_params *ut_params = &unittest_params;
15497 : : struct rte_crypto_sym_op *sym_op;
15498 : :
15499 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15500 : :
15501 : : /* Generate Crypto op data structure */
15502 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15503 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15504 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
15505 : : "Failed to allocate symmetric crypto operation struct");
15506 : :
15507 : : sym_op = ut_params->op->sym;
15508 : :
15509 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15510 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
15511 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15512 : : "no room to append digest");
15513 : :
15514 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15515 : : ut_params->ibuf, plaintext_pad_len);
15516 : :
15517 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15518 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15519 [ - + ]: 4 : tdata->gmac_tag.len);
15520 : 4 : debug_hexdump(stdout, "digest:",
15521 : 4 : sym_op->auth.digest.data,
15522 : 4 : tdata->gmac_tag.len);
15523 : : }
15524 : :
15525 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15526 : : uint8_t *, IV_OFFSET);
15527 : :
15528 [ + - ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15529 : :
15530 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15531 : :
15532 : 8 : sym_op->cipher.data.length = 0;
15533 : 8 : sym_op->cipher.data.offset = 0;
15534 : :
15535 : 8 : sym_op->auth.data.offset = 0;
15536 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
15537 : :
15538 : 8 : return 0;
15539 : : }
15540 : :
15541 : : static int
15542 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15543 : : const struct gmac_test_data *tdata,
15544 : : void *digest_mem, uint64_t digest_phys)
15545 : : {
15546 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15547 : : struct crypto_unittest_params *ut_params = &unittest_params;
15548 : : struct rte_crypto_sym_op *sym_op;
15549 : :
15550 : : /* Generate Crypto op data structure */
15551 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15552 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15553 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15554 : : "Failed to allocate symmetric crypto operation struct");
15555 : :
15556 : : sym_op = ut_params->op->sym;
15557 : :
15558 : 0 : sym_op->auth.digest.data = digest_mem;
15559 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15560 : : "no room to append digest");
15561 : :
15562 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
15563 : :
15564 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15565 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15566 [ # # ]: 0 : tdata->gmac_tag.len);
15567 : 0 : debug_hexdump(stdout, "digest:",
15568 : 0 : sym_op->auth.digest.data,
15569 : 0 : tdata->gmac_tag.len);
15570 : : }
15571 : :
15572 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15573 : : uint8_t *, IV_OFFSET);
15574 : :
15575 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15576 : :
15577 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15578 : :
15579 : 0 : sym_op->cipher.data.length = 0;
15580 : 0 : sym_op->cipher.data.offset = 0;
15581 : :
15582 : 0 : sym_op->auth.data.offset = 0;
15583 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
15584 : :
15585 : 0 : return 0;
15586 : : }
15587 : :
15588 : 8 : static int create_gmac_session(uint8_t dev_id,
15589 : : const struct gmac_test_data *tdata,
15590 : : enum rte_crypto_auth_operation auth_op)
15591 : : {
15592 : 8 : uint8_t *auth_key = alloca(tdata->key.len);
15593 : :
15594 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15595 : : struct crypto_unittest_params *ut_params = &unittest_params;
15596 : :
15597 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
15598 : :
15599 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15600 : 8 : ut_params->auth_xform.next = NULL;
15601 : :
15602 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15603 : 8 : ut_params->auth_xform.auth.op = auth_op;
15604 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15605 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
15606 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
15607 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15608 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15609 : :
15610 : :
15611 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15612 : : &ut_params->auth_xform, ts_params->session_mpool);
15613 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15614 : : return TEST_SKIPPED;
15615 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15616 : :
15617 : : return 0;
15618 : : }
15619 : :
15620 : : static int
15621 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15622 : : {
15623 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15624 : : struct crypto_unittest_params *ut_params = &unittest_params;
15625 : : struct rte_cryptodev_info dev_info;
15626 : :
15627 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15628 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15629 : :
15630 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15631 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15632 : : printf("Device doesn't support RAW data-path APIs.\n");
15633 : 0 : return TEST_SKIPPED;
15634 : : }
15635 : :
15636 : : int retval;
15637 : :
15638 : : uint8_t *auth_tag, *plaintext;
15639 : : uint16_t plaintext_pad_len;
15640 : :
15641 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15642 : : "No GMAC length in the source data");
15643 : :
15644 : : /* Verify the capabilities */
15645 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15646 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15647 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15648 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15649 : : &cap_idx) == NULL)
15650 : : return TEST_SKIPPED;
15651 : :
15652 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15653 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15654 : :
15655 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15656 : : return TEST_SKIPPED;
15657 [ + - ]: 4 : if (retval < 0)
15658 : : return retval;
15659 : :
15660 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15661 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15662 : : else
15663 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15664 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15665 : : "Failed to allocate input buffer in mempool");
15666 : :
15667 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15668 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15669 : :
15670 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15671 : : /*
15672 : : * Runtime generate the large plain text instead of use hard code
15673 : : * plain text vector. It is done to avoid create huge source file
15674 : : * with the test vector.
15675 : : */
15676 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15677 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15678 : :
15679 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15680 : : plaintext_pad_len);
15681 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15682 : :
15683 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15684 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15685 : 4 : tdata->plaintext.len);
15686 : :
15687 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15688 : : tdata);
15689 : :
15690 [ + - ]: 4 : if (retval < 0)
15691 : : return retval;
15692 : :
15693 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15694 : :
15695 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15696 : :
15697 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15698 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15699 : : ut_params->op);
15700 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15701 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15702 : : 0);
15703 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15704 : : return retval;
15705 : : } else
15706 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15707 : : process_crypto_request(ts_params->valid_devs[0],
15708 : : ut_params->op), "failed to process sym crypto op");
15709 : :
15710 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15711 : : "crypto op processing failed");
15712 : :
15713 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
15714 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15715 : : uint8_t *, plaintext_pad_len);
15716 : : } else {
15717 : 4 : auth_tag = plaintext + plaintext_pad_len;
15718 : : }
15719 : :
15720 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15721 : :
15722 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15723 : : auth_tag,
15724 : : tdata->gmac_tag.data,
15725 : : tdata->gmac_tag.len,
15726 : : "GMAC Generated auth tag not as expected");
15727 : :
15728 : : return 0;
15729 : : }
15730 : :
15731 : : static int
15732 : 1 : test_AES_GMAC_authentication_test_case_1(void)
15733 : : {
15734 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
15735 : : }
15736 : :
15737 : : static int
15738 : 1 : test_AES_GMAC_authentication_test_case_2(void)
15739 : : {
15740 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
15741 : : }
15742 : :
15743 : : static int
15744 : 1 : test_AES_GMAC_authentication_test_case_3(void)
15745 : : {
15746 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
15747 : : }
15748 : :
15749 : : static int
15750 : 1 : test_AES_GMAC_authentication_test_case_4(void)
15751 : : {
15752 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
15753 : : }
15754 : :
15755 : : static int
15756 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15757 : : {
15758 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15759 : : struct crypto_unittest_params *ut_params = &unittest_params;
15760 : : int retval;
15761 : : uint32_t plaintext_pad_len;
15762 : : uint8_t *plaintext;
15763 : : struct rte_cryptodev_info dev_info;
15764 : :
15765 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15766 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15767 : :
15768 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15769 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15770 : : printf("Device doesn't support RAW data-path APIs.\n");
15771 : 0 : return TEST_SKIPPED;
15772 : : }
15773 : :
15774 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15775 : : "No GMAC length in the source data");
15776 : :
15777 : : /* Verify the capabilities */
15778 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15779 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15780 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15781 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15782 : : &cap_idx) == NULL)
15783 : : return TEST_SKIPPED;
15784 : :
15785 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15786 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15787 : :
15788 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15789 : : return TEST_SKIPPED;
15790 [ + - ]: 4 : if (retval < 0)
15791 : : return retval;
15792 : :
15793 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15794 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15795 : : else
15796 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15797 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15798 : : "Failed to allocate input buffer in mempool");
15799 : :
15800 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15801 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15802 : :
15803 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15804 : :
15805 : : /*
15806 : : * Runtime generate the large plain text instead of use hard code
15807 : : * plain text vector. It is done to avoid create huge source file
15808 : : * with the test vector.
15809 : : */
15810 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15811 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15812 : :
15813 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15814 : : plaintext_pad_len);
15815 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15816 : :
15817 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15818 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15819 : 4 : tdata->plaintext.len);
15820 : :
15821 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15822 : : tdata);
15823 : :
15824 [ + - ]: 4 : if (retval < 0)
15825 : : return retval;
15826 : :
15827 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15828 : :
15829 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15830 : :
15831 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15832 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15833 : : ut_params->op);
15834 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15835 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15836 : : 0);
15837 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15838 : : return retval;
15839 : : } else
15840 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15841 : : process_crypto_request(ts_params->valid_devs[0],
15842 : : ut_params->op), "failed to process sym crypto op");
15843 : :
15844 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15845 : : "crypto op processing failed");
15846 : :
15847 : : return 0;
15848 : :
15849 : : }
15850 : :
15851 : : static int
15852 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
15853 : : {
15854 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15855 : : }
15856 : :
15857 : : static int
15858 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
15859 : : {
15860 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15861 : : }
15862 : :
15863 : : static int
15864 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
15865 : : {
15866 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15867 : : }
15868 : :
15869 : : static int
15870 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
15871 : : {
15872 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15873 : : }
15874 : :
15875 : : static int
15876 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15877 : : uint32_t fragsz)
15878 : : {
15879 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15880 : : struct crypto_unittest_params *ut_params = &unittest_params;
15881 : : struct rte_cryptodev_info dev_info;
15882 : : uint64_t feature_flags;
15883 : : unsigned int trn_data = 0;
15884 : : void *digest_mem = NULL;
15885 : : unsigned int to_trn = 0;
15886 : : struct rte_mbuf *buf = NULL;
15887 : : uint8_t *auth_tag, *plaintext;
15888 : : int retval;
15889 : :
15890 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15891 : : "No GMAC length in the source data");
15892 : :
15893 : : /* Verify the capabilities */
15894 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15895 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15896 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15897 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15898 : : &cap_idx) == NULL)
15899 : : return TEST_SKIPPED;
15900 : :
15901 : : /* Check for any input SGL support */
15902 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15903 : 4 : feature_flags = dev_info.feature_flags;
15904 : :
15905 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15906 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15907 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15908 : : return TEST_SKIPPED;
15909 : :
15910 : 0 : if (fragsz > tdata->plaintext.len)
15911 : : fragsz = tdata->plaintext.len;
15912 : :
15913 : 0 : uint16_t plaintext_len = fragsz;
15914 : :
15915 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
15916 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15917 : :
15918 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15919 : : return TEST_SKIPPED;
15920 [ # # ]: 0 : if (retval < 0)
15921 : : return retval;
15922 : :
15923 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15924 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15925 : : "Failed to allocate input buffer in mempool");
15926 : :
15927 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15928 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15929 : :
15930 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15931 : : plaintext_len);
15932 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15933 : :
15934 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15935 : :
15936 : : trn_data += plaintext_len;
15937 : :
15938 : 0 : buf = ut_params->ibuf;
15939 : :
15940 : : /*
15941 : : * Loop until no more fragments
15942 : : */
15943 : :
15944 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15945 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15946 : : (tdata->plaintext.len - trn_data) : fragsz;
15947 : :
15948 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15949 : : buf = buf->next;
15950 : 0 : ut_params->ibuf->nb_segs++;
15951 : :
15952 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15953 : : rte_pktmbuf_tailroom(buf));
15954 : :
15955 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15956 : : to_trn);
15957 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
15958 : :
15959 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15960 : : to_trn);
15961 : 0 : trn_data += to_trn;
15962 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15963 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15964 : 0 : tdata->gmac_tag.len);
15965 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append digest data");
15966 : : }
15967 : : }
15968 : :
15969 : : /*
15970 : : * Place digest at the end of the last buffer
15971 : : */
15972 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15973 : :
15974 [ # # ]: 0 : if (!digest_mem) {
15975 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15976 : 0 : + tdata->gmac_tag.len);
15977 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15978 : : tdata->plaintext.len);
15979 : : }
15980 : :
15981 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15982 : : tdata, digest_mem, digest_phys);
15983 : :
15984 [ # # ]: 0 : if (retval < 0)
15985 : : return retval;
15986 : :
15987 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15988 : :
15989 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15990 : :
15991 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15992 : : return TEST_SKIPPED;
15993 : :
15994 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15995 : : process_crypto_request(ts_params->valid_devs[0],
15996 : : ut_params->op), "failed to process sym crypto op");
15997 : :
15998 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15999 : : "crypto op processing failed");
16000 : :
16001 : : auth_tag = digest_mem;
16002 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
16003 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16004 : : auth_tag,
16005 : : tdata->gmac_tag.data,
16006 : : tdata->gmac_tag.len,
16007 : : "GMAC Generated auth tag not as expected");
16008 : :
16009 : : return 0;
16010 : : }
16011 : :
16012 : : /* Segment size not multiple of block size (16B) */
16013 : : static int
16014 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
16015 : : {
16016 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
16017 : : }
16018 : :
16019 : : static int
16020 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
16021 : : {
16022 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
16023 : : }
16024 : :
16025 : : static int
16026 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
16027 : : {
16028 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
16029 : : }
16030 : :
16031 : : /* Segment size not multiple of block size (16B) */
16032 : : static int
16033 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
16034 : : {
16035 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
16036 : : }
16037 : :
16038 : : struct test_crypto_vector {
16039 : : enum rte_crypto_cipher_algorithm crypto_algo;
16040 : : unsigned int cipher_offset;
16041 : : unsigned int cipher_len;
16042 : :
16043 : : struct {
16044 : : uint8_t data[64];
16045 : : unsigned int len;
16046 : : } cipher_key;
16047 : :
16048 : : struct {
16049 : : uint8_t data[64];
16050 : : unsigned int len;
16051 : : } iv;
16052 : :
16053 : : struct {
16054 : : const uint8_t *data;
16055 : : unsigned int len;
16056 : : } plaintext;
16057 : :
16058 : : struct {
16059 : : const uint8_t *data;
16060 : : unsigned int len;
16061 : : } ciphertext;
16062 : :
16063 : : enum rte_crypto_auth_algorithm auth_algo;
16064 : : unsigned int auth_offset;
16065 : :
16066 : : struct {
16067 : : uint8_t data[128];
16068 : : unsigned int len;
16069 : : } auth_key;
16070 : :
16071 : : struct {
16072 : : const uint8_t *data;
16073 : : unsigned int len;
16074 : : } aad;
16075 : :
16076 : : struct {
16077 : : uint8_t data[128];
16078 : : unsigned int len;
16079 : : } digest;
16080 : : };
16081 : :
16082 : : static const struct test_crypto_vector
16083 : : hmac_sha1_test_crypto_vector = {
16084 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16085 : : .plaintext = {
16086 : : .data = plaintext_hash,
16087 : : .len = 512
16088 : : },
16089 : : .auth_key = {
16090 : : .data = {
16091 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16092 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16093 : : 0xDE, 0xF4, 0xDE, 0xAD
16094 : : },
16095 : : .len = 20
16096 : : },
16097 : : .digest = {
16098 : : .data = {
16099 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
16100 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
16101 : : 0x3F, 0x91, 0x64, 0x59
16102 : : },
16103 : : .len = 20
16104 : : }
16105 : : };
16106 : :
16107 : : static const struct test_crypto_vector
16108 : : aes128_gmac_test_vector = {
16109 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
16110 : : .plaintext = {
16111 : : .data = plaintext_hash,
16112 : : .len = 512
16113 : : },
16114 : : .iv = {
16115 : : .data = {
16116 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16117 : : 0x08, 0x09, 0x0A, 0x0B
16118 : : },
16119 : : .len = 12
16120 : : },
16121 : : .auth_key = {
16122 : : .data = {
16123 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16124 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
16125 : : },
16126 : : .len = 16
16127 : : },
16128 : : .digest = {
16129 : : .data = {
16130 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
16131 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
16132 : : },
16133 : : .len = 16
16134 : : }
16135 : : };
16136 : :
16137 : : static const struct test_crypto_vector
16138 : : aes128cbc_hmac_sha1_test_vector = {
16139 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16140 : : .cipher_offset = 0,
16141 : : .cipher_len = 512,
16142 : : .cipher_key = {
16143 : : .data = {
16144 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16145 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16146 : : },
16147 : : .len = 16
16148 : : },
16149 : : .iv = {
16150 : : .data = {
16151 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16152 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16153 : : },
16154 : : .len = 16
16155 : : },
16156 : : .plaintext = {
16157 : : .data = plaintext_hash,
16158 : : .len = 512
16159 : : },
16160 : : .ciphertext = {
16161 : : .data = ciphertext512_aes128cbc,
16162 : : .len = 512
16163 : : },
16164 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16165 : : .auth_offset = 0,
16166 : : .auth_key = {
16167 : : .data = {
16168 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16169 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16170 : : 0xDE, 0xF4, 0xDE, 0xAD
16171 : : },
16172 : : .len = 20
16173 : : },
16174 : : .digest = {
16175 : : .data = {
16176 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
16177 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16178 : : 0x18, 0x8C, 0x1D, 0x32
16179 : : },
16180 : : .len = 20
16181 : : }
16182 : : };
16183 : :
16184 : : static const struct test_crypto_vector
16185 : : aes128cbc_hmac_sha1_aad_test_vector = {
16186 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16187 : : .cipher_offset = 8,
16188 : : .cipher_len = 496,
16189 : : .cipher_key = {
16190 : : .data = {
16191 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16192 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16193 : : },
16194 : : .len = 16
16195 : : },
16196 : : .iv = {
16197 : : .data = {
16198 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16199 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16200 : : },
16201 : : .len = 16
16202 : : },
16203 : : .plaintext = {
16204 : : .data = plaintext_hash,
16205 : : .len = 512
16206 : : },
16207 : : .ciphertext = {
16208 : : .data = ciphertext512_aes128cbc_aad,
16209 : : .len = 512
16210 : : },
16211 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16212 : : .auth_offset = 0,
16213 : : .auth_key = {
16214 : : .data = {
16215 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16216 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16217 : : 0xDE, 0xF4, 0xDE, 0xAD
16218 : : },
16219 : : .len = 20
16220 : : },
16221 : : .digest = {
16222 : : .data = {
16223 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
16224 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
16225 : : 0x62, 0x0F, 0xFB, 0x10
16226 : : },
16227 : : .len = 20
16228 : : }
16229 : : };
16230 : :
16231 : : static void
16232 : : data_corruption(uint8_t *data)
16233 : : {
16234 : 3 : data[0] += 1;
16235 : 3 : }
16236 : :
16237 : : static void
16238 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
16239 : : {
16240 : 3 : data[tag_offset] += 1;
16241 : 3 : }
16242 : :
16243 : : static int
16244 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
16245 : : uint8_t dev_id,
16246 : : const struct test_crypto_vector *reference,
16247 : : enum rte_crypto_auth_operation auth_op)
16248 : : {
16249 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16250 : 2 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16251 : :
16252 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16253 : :
16254 : : /* Setup Authentication Parameters */
16255 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16256 : 2 : ut_params->auth_xform.auth.op = auth_op;
16257 : 2 : ut_params->auth_xform.next = NULL;
16258 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16259 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16260 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
16261 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16262 : :
16263 : : /* Create Crypto session*/
16264 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16265 : : &ut_params->auth_xform,
16266 : : ts_params->session_mpool);
16267 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16268 : : return TEST_SKIPPED;
16269 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16270 : :
16271 : : return 0;
16272 : : }
16273 : :
16274 : : static int
16275 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
16276 : : uint8_t dev_id,
16277 : : const struct test_crypto_vector *reference,
16278 : : enum rte_crypto_auth_operation auth_op,
16279 : : enum rte_crypto_cipher_operation cipher_op)
16280 : : {
16281 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16282 : 4 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16283 : 4 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16284 : :
16285 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
16286 : : reference->cipher_key.len);
16287 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16288 : :
16289 : : /* Setup Authentication Parameters */
16290 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16291 : 4 : ut_params->auth_xform.auth.op = auth_op;
16292 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16293 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16294 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
16295 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16296 : :
16297 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
16298 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
16299 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
16300 : : } else {
16301 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16302 : :
16303 : : /* Setup Cipher Parameters */
16304 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16305 : 2 : ut_params->cipher_xform.next = NULL;
16306 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16307 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
16308 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16309 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16310 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16311 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16312 : : }
16313 : :
16314 : : /* Create Crypto session*/
16315 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16316 : : &ut_params->auth_xform,
16317 : : ts_params->session_mpool);
16318 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16319 : : return TEST_SKIPPED;
16320 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16321 : :
16322 : : return 0;
16323 : : }
16324 : :
16325 : : static int
16326 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
16327 : : struct crypto_unittest_params *ut_params,
16328 : : const struct test_crypto_vector *reference,
16329 : : unsigned int auth_generate)
16330 : : {
16331 : : /* Generate Crypto op data structure */
16332 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16333 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16334 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16335 : : "Failed to allocate pktmbuf offload");
16336 : :
16337 : : /* Set crypto operation data parameters */
16338 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16339 : :
16340 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16341 : :
16342 : : /* set crypto operation source mbuf */
16343 : 2 : sym_op->m_src = ut_params->ibuf;
16344 : :
16345 : : /* digest */
16346 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16347 : 2 : ut_params->ibuf, reference->digest.len);
16348 : :
16349 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16350 : : "no room to append auth tag");
16351 : :
16352 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16353 : : ut_params->ibuf, reference->plaintext.len);
16354 : :
16355 [ - + ]: 2 : if (auth_generate)
16356 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16357 : : else
16358 : 2 : memcpy(sym_op->auth.digest.data,
16359 : 2 : reference->digest.data,
16360 : 2 : reference->digest.len);
16361 : :
16362 : 2 : debug_hexdump(stdout, "digest:",
16363 : 2 : sym_op->auth.digest.data,
16364 : 2 : reference->digest.len);
16365 : :
16366 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16367 : 2 : sym_op->auth.data.offset = 0;
16368 : :
16369 : 2 : return 0;
16370 : : }
16371 : :
16372 : : static int
16373 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16374 : : struct crypto_unittest_params *ut_params,
16375 : : const struct test_crypto_vector *reference,
16376 : : unsigned int auth_generate)
16377 : : {
16378 : : /* Generate Crypto op data structure */
16379 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16380 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16381 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16382 : : "Failed to allocate pktmbuf offload");
16383 : :
16384 : : /* Set crypto operation data parameters */
16385 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16386 : :
16387 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16388 : :
16389 : : /* set crypto operation source mbuf */
16390 : 2 : sym_op->m_src = ut_params->ibuf;
16391 : :
16392 : : /* digest */
16393 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16394 : 2 : ut_params->ibuf, reference->digest.len);
16395 : :
16396 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16397 : : "no room to append auth tag");
16398 : :
16399 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16400 : : ut_params->ibuf, reference->ciphertext.len);
16401 : :
16402 [ - + ]: 2 : if (auth_generate)
16403 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16404 : : else
16405 : 2 : memcpy(sym_op->auth.digest.data,
16406 : 2 : reference->digest.data,
16407 : 2 : reference->digest.len);
16408 : :
16409 : 2 : debug_hexdump(stdout, "digest:",
16410 : 2 : sym_op->auth.digest.data,
16411 : 2 : reference->digest.len);
16412 : :
16413 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16414 [ + - ]: 2 : reference->iv.data, reference->iv.len);
16415 : :
16416 : 2 : sym_op->cipher.data.length = 0;
16417 : 2 : sym_op->cipher.data.offset = 0;
16418 : :
16419 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16420 : 2 : sym_op->auth.data.offset = 0;
16421 : :
16422 : 2 : return 0;
16423 : : }
16424 : :
16425 : : static int
16426 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16427 : : struct crypto_unittest_params *ut_params,
16428 : : const struct test_crypto_vector *reference,
16429 : : unsigned int auth_generate)
16430 : : {
16431 : : /* Generate Crypto op data structure */
16432 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16433 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16434 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
16435 : : "Failed to allocate pktmbuf offload");
16436 : :
16437 : : /* Set crypto operation data parameters */
16438 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16439 : :
16440 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16441 : :
16442 : : /* set crypto operation source mbuf */
16443 : 4 : sym_op->m_src = ut_params->ibuf;
16444 : :
16445 : : /* digest */
16446 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16447 : 4 : ut_params->ibuf, reference->digest.len);
16448 : :
16449 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16450 : : "no room to append auth tag");
16451 : :
16452 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16453 : : ut_params->ibuf, reference->ciphertext.len);
16454 : :
16455 [ - + ]: 4 : if (auth_generate)
16456 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16457 : : else
16458 : 4 : memcpy(sym_op->auth.digest.data,
16459 : 4 : reference->digest.data,
16460 : 4 : reference->digest.len);
16461 : :
16462 : 4 : debug_hexdump(stdout, "digest:",
16463 : 4 : sym_op->auth.digest.data,
16464 : 4 : reference->digest.len);
16465 : :
16466 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16467 [ - + ]: 4 : reference->iv.data, reference->iv.len);
16468 : :
16469 : 4 : sym_op->cipher.data.length = reference->cipher_len;
16470 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
16471 : :
16472 : 4 : sym_op->auth.data.length = reference->plaintext.len;
16473 : 4 : sym_op->auth.data.offset = reference->auth_offset;
16474 : :
16475 : 4 : return 0;
16476 : : }
16477 : :
16478 : : static int
16479 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16480 : : struct crypto_unittest_params *ut_params,
16481 : : const struct test_crypto_vector *reference)
16482 : : {
16483 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
16484 : : }
16485 : :
16486 : : static int
16487 : : create_auth_verify_GMAC_operation(
16488 : : struct crypto_testsuite_params *ts_params,
16489 : : struct crypto_unittest_params *ut_params,
16490 : : const struct test_crypto_vector *reference)
16491 : : {
16492 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16493 : : }
16494 : :
16495 : : static int
16496 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16497 : : struct crypto_unittest_params *ut_params,
16498 : : const struct test_crypto_vector *reference)
16499 : : {
16500 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16501 : : }
16502 : :
16503 : : static int
16504 : 2 : test_authentication_verify_fail_when_data_corruption(
16505 : : struct crypto_testsuite_params *ts_params,
16506 : : struct crypto_unittest_params *ut_params,
16507 : : const struct test_crypto_vector *reference,
16508 : : unsigned int data_corrupted)
16509 : : {
16510 : : int retval;
16511 : :
16512 : : uint8_t *plaintext;
16513 : : struct rte_cryptodev_info dev_info;
16514 : :
16515 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16516 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16517 : :
16518 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16519 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16520 : : printf("Device doesn't support RAW data-path APIs.\n");
16521 : 0 : return TEST_SKIPPED;
16522 : : }
16523 : :
16524 : : /* Verify the capabilities */
16525 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16526 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16527 : 2 : cap_idx.algo.auth = reference->auth_algo;
16528 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16529 : : &cap_idx) == NULL)
16530 : : return TEST_SKIPPED;
16531 : :
16532 : :
16533 : : /* Create session */
16534 : 2 : retval = create_auth_session(ut_params,
16535 : 2 : ts_params->valid_devs[0],
16536 : : reference,
16537 : : RTE_CRYPTO_AUTH_OP_VERIFY);
16538 : :
16539 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16540 : : return TEST_SKIPPED;
16541 [ + - ]: 2 : if (retval < 0)
16542 : : return retval;
16543 : :
16544 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16545 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16546 : : "Failed to allocate input buffer in mempool");
16547 : :
16548 : : /* clear mbuf payload */
16549 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16550 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16551 : :
16552 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16553 : 2 : reference->plaintext.len);
16554 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16555 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16556 : :
16557 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16558 : 2 : reference->plaintext.len);
16559 : :
16560 : : /* Create operation */
16561 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
16562 : :
16563 [ + - ]: 2 : if (retval < 0)
16564 : : return retval;
16565 : :
16566 [ + + ]: 2 : if (data_corrupted)
16567 : : data_corruption(plaintext);
16568 : : else
16569 : 1 : tag_corruption(plaintext, reference->plaintext.len);
16570 : :
16571 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16572 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16573 : : ut_params->op);
16574 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16575 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16576 : : "authentication not failed");
16577 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16578 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16579 : : 0);
16580 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16581 : : return retval;
16582 : : } else {
16583 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16584 : : ut_params->op);
16585 : : }
16586 [ - + ]: 2 : if (ut_params->op == NULL)
16587 : : return 0;
16588 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16589 : 0 : return 0;
16590 : :
16591 : : return -1;
16592 : : }
16593 : :
16594 : : static int
16595 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
16596 : : struct crypto_testsuite_params *ts_params,
16597 : : struct crypto_unittest_params *ut_params,
16598 : : const struct test_crypto_vector *reference,
16599 : : unsigned int data_corrupted)
16600 : : {
16601 : : int retval;
16602 : : uint8_t *plaintext;
16603 : : struct rte_cryptodev_info dev_info;
16604 : :
16605 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16606 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16607 : :
16608 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16609 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16610 : : printf("Device doesn't support RAW data-path APIs.\n");
16611 : 0 : return TEST_SKIPPED;
16612 : : }
16613 : :
16614 : : /* Verify the capabilities */
16615 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16616 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16617 : 2 : cap_idx.algo.auth = reference->auth_algo;
16618 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16619 : : &cap_idx) == NULL)
16620 : : return TEST_SKIPPED;
16621 : :
16622 : : /* Create session */
16623 : 2 : retval = create_auth_cipher_session(ut_params,
16624 : 2 : ts_params->valid_devs[0],
16625 : : reference,
16626 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16627 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16628 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16629 : : return TEST_SKIPPED;
16630 [ + - ]: 2 : if (retval < 0)
16631 : : return retval;
16632 : :
16633 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16634 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16635 : : "Failed to allocate input buffer in mempool");
16636 : :
16637 : : /* clear mbuf payload */
16638 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16639 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16640 : :
16641 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16642 : 2 : reference->plaintext.len);
16643 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16644 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16645 : :
16646 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16647 : 2 : reference->plaintext.len);
16648 : :
16649 : : /* Create operation */
16650 : : retval = create_auth_verify_GMAC_operation(ts_params,
16651 : : ut_params,
16652 : : reference);
16653 : :
16654 [ + - ]: 2 : if (retval < 0)
16655 : : return retval;
16656 : :
16657 [ + + ]: 2 : if (data_corrupted)
16658 : : data_corruption(plaintext);
16659 : : else
16660 : 1 : tag_corruption(plaintext, reference->aad.len);
16661 : :
16662 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16663 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16664 : : ut_params->op);
16665 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16666 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16667 : : "authentication not failed");
16668 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16669 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16670 : : 0);
16671 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16672 : 0 : return retval;
16673 : : } else {
16674 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16675 : : ut_params->op);
16676 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16677 : : }
16678 : :
16679 : : return 0;
16680 : : }
16681 : :
16682 : : static int
16683 : 2 : test_authenticated_decryption_fail_when_corruption(
16684 : : struct crypto_testsuite_params *ts_params,
16685 : : struct crypto_unittest_params *ut_params,
16686 : : const struct test_crypto_vector *reference,
16687 : : unsigned int data_corrupted)
16688 : : {
16689 : : int retval;
16690 : :
16691 : : uint8_t *ciphertext;
16692 : : struct rte_cryptodev_info dev_info;
16693 : :
16694 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16695 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16696 : :
16697 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16698 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16699 : : printf("Device doesn't support RAW data-path APIs.\n");
16700 : 0 : return TEST_SKIPPED;
16701 : : }
16702 : :
16703 : : /* Verify the capabilities */
16704 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16705 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16706 : 2 : cap_idx.algo.auth = reference->auth_algo;
16707 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16708 : : &cap_idx) == NULL)
16709 : : return TEST_SKIPPED;
16710 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16711 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
16712 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16713 : : &cap_idx) == NULL)
16714 : : return TEST_SKIPPED;
16715 : :
16716 : : /* Create session */
16717 : 2 : retval = create_auth_cipher_session(ut_params,
16718 : 2 : ts_params->valid_devs[0],
16719 : : reference,
16720 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16721 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16722 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16723 : : return TEST_SKIPPED;
16724 [ + - ]: 2 : if (retval < 0)
16725 : : return retval;
16726 : :
16727 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16728 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16729 : : "Failed to allocate input buffer in mempool");
16730 : :
16731 : : /* clear mbuf payload */
16732 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16733 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16734 : :
16735 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16736 : 2 : reference->ciphertext.len);
16737 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16738 : 2 : memcpy(ciphertext, reference->ciphertext.data,
16739 : 2 : reference->ciphertext.len);
16740 : :
16741 : : /* Create operation */
16742 : : retval = create_cipher_auth_verify_operation(ts_params,
16743 : : ut_params,
16744 : : reference);
16745 : :
16746 [ + - ]: 2 : if (retval < 0)
16747 : : return retval;
16748 : :
16749 [ + + ]: 2 : if (data_corrupted)
16750 : : data_corruption(ciphertext);
16751 : : else
16752 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
16753 : :
16754 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16755 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16756 : : ut_params->op);
16757 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16758 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16759 : : "authentication not failed");
16760 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16761 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16762 : : 0);
16763 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16764 : 0 : return retval;
16765 : : } else {
16766 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16767 : : ut_params->op);
16768 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16769 : : }
16770 : :
16771 : : return 0;
16772 : : }
16773 : :
16774 : : static int
16775 : 1 : test_authenticated_encrypt_with_esn(
16776 : : struct crypto_testsuite_params *ts_params,
16777 : : struct crypto_unittest_params *ut_params,
16778 : : const struct test_crypto_vector *reference)
16779 : : {
16780 : : int retval;
16781 : :
16782 : : uint8_t *authciphertext, *plaintext, *auth_tag;
16783 : : uint16_t plaintext_pad_len;
16784 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16785 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16786 : : struct rte_cryptodev_info dev_info;
16787 : :
16788 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16789 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16790 : :
16791 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16792 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16793 : : printf("Device doesn't support RAW data-path APIs.\n");
16794 : 0 : return TEST_SKIPPED;
16795 : : }
16796 : :
16797 : : /* Verify the capabilities */
16798 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16799 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16800 : 1 : cap_idx.algo.auth = reference->auth_algo;
16801 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16802 : : &cap_idx) == NULL)
16803 : : return TEST_SKIPPED;
16804 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16805 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16806 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16807 : : &cap_idx) == NULL)
16808 : : return TEST_SKIPPED;
16809 : :
16810 : : /* Create session */
16811 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16812 : 1 : reference->cipher_key.len);
16813 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16814 : :
16815 : : /* Setup Cipher Parameters */
16816 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16817 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16818 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16819 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16820 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16821 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16822 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16823 : :
16824 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
16825 : :
16826 : : /* Setup Authentication Parameters */
16827 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16828 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16829 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16830 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16831 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16832 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16833 : 1 : ut_params->auth_xform.next = NULL;
16834 : :
16835 : : /* Create Crypto session*/
16836 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16837 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
16838 : : ts_params->session_mpool);
16839 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16840 : : return TEST_SKIPPED;
16841 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16842 : :
16843 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16844 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16845 : : "Failed to allocate input buffer in mempool");
16846 : :
16847 : : /* clear mbuf payload */
16848 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16849 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16850 : :
16851 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16852 : 1 : reference->plaintext.len);
16853 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16854 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16855 : :
16856 : : /* Create operation */
16857 : 1 : retval = create_cipher_auth_operation(ts_params,
16858 : : ut_params,
16859 : : reference, 0);
16860 : :
16861 [ + - ]: 1 : if (retval < 0)
16862 : : return retval;
16863 : :
16864 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16865 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16866 : : ut_params->op);
16867 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16868 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16869 : : 0);
16870 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16871 : : return retval;
16872 : : } else
16873 : 1 : ut_params->op = process_crypto_request(
16874 : 1 : ts_params->valid_devs[0], ut_params->op);
16875 : :
16876 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16877 : :
16878 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16879 : : "crypto op processing failed");
16880 : :
16881 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16882 : :
16883 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16884 : : ut_params->op->sym->auth.data.offset);
16885 : 1 : auth_tag = authciphertext + plaintext_pad_len;
16886 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
16887 : 1 : reference->ciphertext.len);
16888 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16889 : :
16890 : : /* Validate obuf */
16891 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16892 : : authciphertext,
16893 : : reference->ciphertext.data,
16894 : : reference->ciphertext.len,
16895 : : "Ciphertext data not as expected");
16896 : :
16897 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16898 : : auth_tag,
16899 : : reference->digest.data,
16900 : : reference->digest.len,
16901 : : "Generated digest not as expected");
16902 : :
16903 : : return TEST_SUCCESS;
16904 : :
16905 : : }
16906 : :
16907 : : static int
16908 : 1 : test_authenticated_decrypt_with_esn(
16909 : : struct crypto_testsuite_params *ts_params,
16910 : : struct crypto_unittest_params *ut_params,
16911 : : const struct test_crypto_vector *reference)
16912 : : {
16913 : : int retval;
16914 : :
16915 : : uint8_t *ciphertext;
16916 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16917 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16918 : : struct rte_cryptodev_info dev_info;
16919 : :
16920 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16921 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16922 : :
16923 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16924 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16925 : : printf("Device doesn't support RAW data-path APIs.\n");
16926 : 0 : return TEST_SKIPPED;
16927 : : }
16928 : :
16929 : : /* Verify the capabilities */
16930 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16931 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16932 : 1 : cap_idx.algo.auth = reference->auth_algo;
16933 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16934 : : &cap_idx) == NULL)
16935 : : return TEST_SKIPPED;
16936 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16937 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16938 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16939 : : &cap_idx) == NULL)
16940 : : return TEST_SKIPPED;
16941 : :
16942 : : /* Create session */
16943 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16944 : 1 : reference->cipher_key.len);
16945 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16946 : :
16947 : : /* Setup Authentication Parameters */
16948 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16949 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16950 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16951 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16952 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16953 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16954 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16955 : :
16956 : : /* Setup Cipher Parameters */
16957 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16958 : 1 : ut_params->cipher_xform.next = NULL;
16959 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16960 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16961 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16962 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16963 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16964 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16965 : :
16966 : : /* Create Crypto session*/
16967 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16968 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
16969 : : ts_params->session_mpool);
16970 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16971 : : return TEST_SKIPPED;
16972 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16973 : :
16974 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16975 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16976 : : "Failed to allocate input buffer in mempool");
16977 : :
16978 : : /* clear mbuf payload */
16979 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16980 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16981 : :
16982 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16983 : 1 : reference->ciphertext.len);
16984 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16985 : 1 : memcpy(ciphertext, reference->ciphertext.data,
16986 : 1 : reference->ciphertext.len);
16987 : :
16988 : : /* Create operation */
16989 : : retval = create_cipher_auth_verify_operation(ts_params,
16990 : : ut_params,
16991 : : reference);
16992 : :
16993 [ + - ]: 1 : if (retval < 0)
16994 : : return retval;
16995 : :
16996 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16997 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16998 : : ut_params->op);
16999 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17000 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
17001 : : 0);
17002 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17003 : : return retval;
17004 : : } else
17005 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
17006 : : ut_params->op);
17007 : :
17008 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
17009 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
17010 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
17011 : : "crypto op processing passed");
17012 : :
17013 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
17014 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
17015 : :
17016 : : return 0;
17017 : : }
17018 : :
17019 : : static int
17020 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
17021 : : const struct aead_test_data *tdata,
17022 : : void *digest_mem, uint64_t digest_phys)
17023 : : {
17024 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17025 : : struct crypto_unittest_params *ut_params = &unittest_params;
17026 : :
17027 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
17028 : 1 : const unsigned int iv_len = tdata->iv.len;
17029 : 1 : unsigned int aad_len = tdata->aad.len;
17030 : : unsigned int aad_len_pad = 0;
17031 : :
17032 : : /* Generate Crypto op data structure */
17033 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
17034 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
17035 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
17036 : : "Failed to allocate symmetric crypto operation struct");
17037 : :
17038 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
17039 : :
17040 : 1 : sym_op->aead.digest.data = digest_mem;
17041 : :
17042 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
17043 : : "no room to append digest");
17044 : :
17045 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
17046 : :
17047 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
17048 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
17049 : : auth_tag_len);
17050 : 0 : debug_hexdump(stdout, "digest:",
17051 : 0 : sym_op->aead.digest.data,
17052 : : auth_tag_len);
17053 : : }
17054 : :
17055 : : /* Append aad data */
17056 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
17057 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17058 : : uint8_t *, IV_OFFSET);
17059 : :
17060 : : /* Copy IV 1 byte after the IV pointer, according to the API */
17061 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
17062 : :
17063 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
17064 : :
17065 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17066 : : ut_params->ibuf, aad_len);
17067 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17068 : : "no room to prepend aad");
17069 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17070 : : ut_params->ibuf);
17071 : :
17072 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
17073 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
17074 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17075 : :
17076 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17077 : 0 : debug_hexdump(stdout, "aad:",
17078 : 0 : sym_op->aead.aad.data, aad_len);
17079 : : } else {
17080 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17081 : : uint8_t *, IV_OFFSET);
17082 : :
17083 [ + - ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
17084 : :
17085 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
17086 : :
17087 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17088 : : ut_params->ibuf, aad_len_pad);
17089 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17090 : : "no room to prepend aad");
17091 [ + - ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17092 : : ut_params->ibuf);
17093 : :
17094 [ + - ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
17095 [ + - ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17096 : :
17097 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17098 : 1 : debug_hexdump(stdout, "aad:",
17099 : 1 : sym_op->aead.aad.data, aad_len);
17100 : : }
17101 : :
17102 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
17103 : 1 : sym_op->aead.data.offset = aad_len_pad;
17104 : :
17105 : 1 : return 0;
17106 : : }
17107 : :
17108 : : #define SGL_MAX_NO 16
17109 : :
17110 : : static int
17111 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
17112 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
17113 : : {
17114 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17115 : : struct crypto_unittest_params *ut_params = &unittest_params;
17116 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
17117 : : int retval;
17118 : : int to_trn = 0;
17119 : : int to_trn_tbl[SGL_MAX_NO];
17120 : : unsigned int trn_data = 0;
17121 : : uint8_t *plaintext, *ciphertext, *auth_tag;
17122 : : struct rte_cryptodev_info dev_info;
17123 : :
17124 : : /* Verify the capabilities */
17125 : : struct rte_cryptodev_sym_capability_idx cap_idx;
17126 : : const struct rte_cryptodev_symmetric_capability *capability;
17127 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
17128 : 3 : cap_idx.algo.aead = tdata->algo;
17129 : 3 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
17130 [ + - ]: 3 : if (capability == NULL)
17131 : : return TEST_SKIPPED;
17132 [ + - ]: 3 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
17133 : 3 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
17134 : : return TEST_SKIPPED;
17135 : :
17136 : : /*
17137 : : * SGL not supported on AESNI_MB PMD CPU crypto,
17138 : : * OOP not supported on AESNI_GCM CPU crypto
17139 : : */
17140 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
17141 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
17142 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
17143 : : return TEST_SKIPPED;
17144 : :
17145 : : /* Detailed check for the particular SGL support flag */
17146 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
17147 [ - + ]: 3 : if (!oop) {
17148 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17149 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
17150 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
17151 : : return TEST_SKIPPED;
17152 : :
17153 : 0 : uint64_t feat_flags = dev_info.feature_flags;
17154 : :
17155 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
17156 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
17157 : : printf("Device doesn't support RAW data-path APIs.\n");
17158 : 0 : return TEST_SKIPPED;
17159 : : }
17160 : : } else {
17161 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17162 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
17163 : : tdata->plaintext.len;
17164 : : /* Raw data path API does not support OOP */
17165 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
17166 : : return TEST_SKIPPED;
17167 [ + + ]: 3 : if (sgl_in && !sgl_out) {
17168 [ + - ]: 1 : if (!(dev_info.feature_flags &
17169 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
17170 : : return TEST_SKIPPED;
17171 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
17172 [ # # ]: 0 : if (!(dev_info.feature_flags &
17173 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
17174 : : return TEST_SKIPPED;
17175 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
17176 [ - + ]: 2 : if (!(dev_info.feature_flags &
17177 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
17178 : : return TEST_SKIPPED;
17179 : : }
17180 : : }
17181 : :
17182 : 1 : if (fragsz > tdata->plaintext.len)
17183 : : fragsz = tdata->plaintext.len;
17184 : :
17185 : 1 : uint16_t plaintext_len = fragsz;
17186 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
17187 : :
17188 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
17189 : 0 : frag_size_oop = tdata->plaintext.len;
17190 : :
17191 : : int ecx = 0;
17192 : : void *digest_mem = NULL;
17193 : :
17194 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
17195 : :
17196 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
17197 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
17198 : : return 1;
17199 : : } else {
17200 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
17201 : : return 1;
17202 : : }
17203 : :
17204 : : /*
17205 : : * For out-of-place we need to alloc another mbuf
17206 : : */
17207 [ + - ]: 1 : if (oop) {
17208 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17209 : : rte_pktmbuf_append(ut_params->obuf,
17210 : 1 : frag_size_oop + prepend_len);
17211 : 1 : buf_oop = ut_params->obuf;
17212 : : }
17213 : :
17214 : : /* Create AEAD session */
17215 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
17216 : 1 : tdata->algo,
17217 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
17218 : 1 : tdata->key.data, tdata->key.len,
17219 : 1 : tdata->aad.len, tdata->auth_tag.len,
17220 : 1 : tdata->iv.len);
17221 [ + - ]: 1 : if (retval < 0)
17222 : : return retval;
17223 : :
17224 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17225 : :
17226 : : /* clear mbuf payload */
17227 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
17228 : : rte_pktmbuf_tailroom(ut_params->ibuf));
17229 : :
17230 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17231 : : plaintext_len);
17232 : :
17233 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
17234 : :
17235 : : trn_data += plaintext_len;
17236 : :
17237 : 1 : buf = ut_params->ibuf;
17238 : :
17239 : : /*
17240 : : * Loop until no more fragments
17241 : : */
17242 : :
17243 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
17244 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
17245 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
17246 : :
17247 : 5 : to_trn_tbl[ecx++] = to_trn;
17248 : :
17249 : 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17250 : : buf = buf->next;
17251 [ - + ]: 5 : ut_params->ibuf->nb_segs++;
17252 : :
17253 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
17254 : : rte_pktmbuf_tailroom(buf));
17255 : :
17256 : : /* OOP */
17257 [ - + ]: 5 : if (oop && !fragsz_oop) {
17258 : 0 : buf_last_oop = buf_oop->next =
17259 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17260 : : buf_oop = buf_oop->next;
17261 : 0 : ut_params->obuf->nb_segs++;
17262 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17263 : : 0, rte_pktmbuf_tailroom(buf_oop));
17264 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
17265 : : }
17266 : :
17267 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17268 : : to_trn);
17269 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
17270 : :
17271 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
17272 : : to_trn);
17273 : 5 : trn_data += to_trn;
17274 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
17275 [ + - ]: 1 : if (oop) {
17276 [ - + ]: 1 : if (!fragsz_oop) {
17277 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17278 : 0 : tdata->auth_tag.len);
17279 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17280 : : }
17281 : : } else {
17282 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17283 : 0 : tdata->auth_tag.len);
17284 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17285 : : }
17286 : : }
17287 : : }
17288 : :
17289 : : uint64_t digest_phys = 0;
17290 : :
17291 [ + - ]: 1 : if (fragsz_oop && oop) {
17292 : : to_trn = 0;
17293 : : ecx = 0;
17294 : :
17295 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
17296 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17297 : 1 : tdata->auth_tag.len);
17298 : :
17299 : 1 : digest_phys = rte_pktmbuf_iova_offset(
17300 : : ut_params->obuf,
17301 : : tdata->plaintext.len + prepend_len);
17302 : : }
17303 : :
17304 : : trn_data = frag_size_oop;
17305 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
17306 : 0 : to_trn =
17307 : 0 : (tdata->plaintext.len - trn_data <
17308 : : frag_size_oop) ?
17309 : 0 : (tdata->plaintext.len - trn_data) :
17310 : : frag_size_oop;
17311 : :
17312 : 0 : to_trn_tbl[ecx++] = to_trn;
17313 : :
17314 : 0 : buf_last_oop = buf_oop->next =
17315 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17316 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(buf_oop->next, "Unexpected end of chain");
17317 : 0 : ut_params->obuf->nb_segs++;
17318 : 0 : buf_oop = buf_oop->next;
17319 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17320 : : 0, rte_pktmbuf_tailroom(buf_oop));
17321 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
17322 : :
17323 : 0 : trn_data += to_trn;
17324 : :
17325 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
17326 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17327 : 0 : tdata->auth_tag.len);
17328 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17329 : : }
17330 : : }
17331 : : }
17332 : :
17333 : : /*
17334 : : * Place digest at the end of the last buffer
17335 : : */
17336 [ - + ]: 1 : if (!digest_phys)
17337 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
17338 [ - + ]: 1 : if (oop && buf_last_oop)
17339 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
17340 : :
17341 [ - + ]: 1 : if (!digest_mem && !oop) {
17342 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17343 : 0 : + tdata->auth_tag.len);
17344 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
17345 : : tdata->plaintext.len);
17346 : : }
17347 : :
17348 : : /* Create AEAD operation */
17349 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
17350 : : tdata, digest_mem, digest_phys);
17351 : :
17352 [ + - ]: 1 : if (retval < 0)
17353 : : return retval;
17354 : :
17355 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
17356 : :
17357 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
17358 [ + - ]: 1 : if (oop)
17359 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
17360 : :
17361 : : /* Process crypto operation */
17362 [ - + ]: 1 : if (oop == IN_PLACE &&
17363 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17364 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
17365 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17366 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
17367 : : 0);
17368 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17369 : : return retval;
17370 : : } else
17371 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
17372 : : process_crypto_request(ts_params->valid_devs[0],
17373 : : ut_params->op), "failed to process sym crypto op");
17374 : :
17375 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17376 : : "crypto op processing failed");
17377 : :
17378 : :
17379 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17380 : : uint8_t *, prepend_len);
17381 [ + - ]: 1 : if (oop) {
17382 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17383 : : uint8_t *, prepend_len);
17384 : : }
17385 : :
17386 [ + - ]: 1 : if (fragsz_oop)
17387 : : fragsz = fragsz_oop;
17388 : :
17389 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17390 : : ciphertext,
17391 : : tdata->ciphertext.data,
17392 : : fragsz,
17393 : : "Ciphertext data not as expected");
17394 : :
17395 : 1 : buf = ut_params->op->sym->m_src->next;
17396 [ + - ]: 1 : if (oop)
17397 : 1 : buf = ut_params->op->sym->m_dst->next;
17398 : :
17399 : : unsigned int off = fragsz;
17400 : :
17401 : : ecx = 0;
17402 [ - + ]: 1 : while (buf) {
17403 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
17404 : : uint8_t *);
17405 : :
17406 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17407 : : ciphertext,
17408 : : tdata->ciphertext.data + off,
17409 : : to_trn_tbl[ecx],
17410 : : "Ciphertext data not as expected");
17411 : :
17412 : 0 : off += to_trn_tbl[ecx++];
17413 : 0 : buf = buf->next;
17414 : : }
17415 : :
17416 : : auth_tag = digest_mem;
17417 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17418 : : auth_tag,
17419 : : tdata->auth_tag.data,
17420 : : tdata->auth_tag.len,
17421 : : "Generated auth tag not as expected");
17422 : :
17423 : : return 0;
17424 : : }
17425 : :
17426 : : static int
17427 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17428 : : {
17429 : 1 : return test_authenticated_encryption_SGL(
17430 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17431 : : }
17432 : :
17433 : : static int
17434 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17435 : : {
17436 : 1 : return test_authenticated_encryption_SGL(
17437 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17438 : : }
17439 : :
17440 : : static int
17441 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17442 : : {
17443 : 1 : return test_authenticated_encryption_SGL(
17444 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
17445 : : gcm_test_case_8.plaintext.len);
17446 : : }
17447 : :
17448 : : static int
17449 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17450 : : {
17451 : : /* This test is not for OPENSSL PMD */
17452 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17453 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17454 : : return TEST_SKIPPED;
17455 : :
17456 : 0 : return test_authenticated_encryption_SGL(
17457 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17458 : : }
17459 : :
17460 : : static int
17461 : : test_authentication_verify_fail_when_data_corrupted(
17462 : : struct crypto_testsuite_params *ts_params,
17463 : : struct crypto_unittest_params *ut_params,
17464 : : const struct test_crypto_vector *reference)
17465 : : {
17466 : 1 : return test_authentication_verify_fail_when_data_corruption(
17467 : : ts_params, ut_params, reference, 1);
17468 : : }
17469 : :
17470 : : static int
17471 : : test_authentication_verify_fail_when_tag_corrupted(
17472 : : struct crypto_testsuite_params *ts_params,
17473 : : struct crypto_unittest_params *ut_params,
17474 : : const struct test_crypto_vector *reference)
17475 : : {
17476 : 1 : return test_authentication_verify_fail_when_data_corruption(
17477 : : ts_params, ut_params, reference, 0);
17478 : : }
17479 : :
17480 : : static int
17481 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
17482 : : struct crypto_testsuite_params *ts_params,
17483 : : struct crypto_unittest_params *ut_params,
17484 : : const struct test_crypto_vector *reference)
17485 : : {
17486 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17487 : : ts_params, ut_params, reference, 1);
17488 : : }
17489 : :
17490 : : static int
17491 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
17492 : : struct crypto_testsuite_params *ts_params,
17493 : : struct crypto_unittest_params *ut_params,
17494 : : const struct test_crypto_vector *reference)
17495 : : {
17496 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17497 : : ts_params, ut_params, reference, 0);
17498 : : }
17499 : :
17500 : : static int
17501 : : test_authenticated_decryption_fail_when_data_corrupted(
17502 : : struct crypto_testsuite_params *ts_params,
17503 : : struct crypto_unittest_params *ut_params,
17504 : : const struct test_crypto_vector *reference)
17505 : : {
17506 : 1 : return test_authenticated_decryption_fail_when_corruption(
17507 : : ts_params, ut_params, reference, 1);
17508 : : }
17509 : :
17510 : : static int
17511 : : test_authenticated_decryption_fail_when_tag_corrupted(
17512 : : struct crypto_testsuite_params *ts_params,
17513 : : struct crypto_unittest_params *ut_params,
17514 : : const struct test_crypto_vector *reference)
17515 : : {
17516 : 1 : return test_authenticated_decryption_fail_when_corruption(
17517 : : ts_params, ut_params, reference, 0);
17518 : : }
17519 : :
17520 : : static int
17521 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17522 : : {
17523 : 1 : return test_authentication_verify_fail_when_data_corrupted(
17524 : : &testsuite_params, &unittest_params,
17525 : : &hmac_sha1_test_crypto_vector);
17526 : : }
17527 : :
17528 : : static int
17529 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17530 : : {
17531 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
17532 : : &testsuite_params, &unittest_params,
17533 : : &hmac_sha1_test_crypto_vector);
17534 : : }
17535 : :
17536 : : static int
17537 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17538 : : {
17539 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
17540 : : &testsuite_params, &unittest_params,
17541 : : &aes128_gmac_test_vector);
17542 : : }
17543 : :
17544 : : static int
17545 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17546 : : {
17547 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17548 : : &testsuite_params, &unittest_params,
17549 : : &aes128_gmac_test_vector);
17550 : : }
17551 : :
17552 : : static int
17553 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17554 : : {
17555 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
17556 : : &testsuite_params,
17557 : : &unittest_params,
17558 : : &aes128cbc_hmac_sha1_test_vector);
17559 : : }
17560 : :
17561 : : static int
17562 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17563 : : {
17564 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
17565 : : &testsuite_params,
17566 : : &unittest_params,
17567 : : &aes128cbc_hmac_sha1_test_vector);
17568 : : }
17569 : :
17570 : : static int
17571 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17572 : : {
17573 : 1 : return test_authenticated_encrypt_with_esn(
17574 : : &testsuite_params,
17575 : : &unittest_params,
17576 : : &aes128cbc_hmac_sha1_aad_test_vector);
17577 : : }
17578 : :
17579 : : static int
17580 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17581 : : {
17582 : 1 : return test_authenticated_decrypt_with_esn(
17583 : : &testsuite_params,
17584 : : &unittest_params,
17585 : : &aes128cbc_hmac_sha1_aad_test_vector);
17586 : : }
17587 : :
17588 : : static int
17589 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17590 : : {
17591 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17592 : : }
17593 : :
17594 : : static int
17595 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17596 : : {
17597 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17598 : : }
17599 : :
17600 : : static int
17601 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17602 : : {
17603 : 0 : return test_authenticated_encryption_SGL(
17604 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17605 : : chacha20_poly1305_case_2.plaintext.len);
17606 : : }
17607 : :
17608 : : static int
17609 : 0 : test_SM4_GCM_case_1(void)
17610 : : {
17611 : 0 : return test_authenticated_encryption(&sm4_gcm_case_1);
17612 : : }
17613 : :
17614 : : static int
17615 : 0 : test_SM4_GCM_case_2(void)
17616 : : {
17617 : 0 : return test_authenticated_encryption(&sm4_gcm_case_2);
17618 : : }
17619 : :
17620 : : static int
17621 : 0 : test_SM4_GCM_case_3(void)
17622 : : {
17623 : 0 : return test_authenticated_encryption(&sm4_gcm_case_3);
17624 : : }
17625 : :
17626 : : static int
17627 : 0 : test_SM4_GCM_case_4(void)
17628 : : {
17629 : 0 : return test_authenticated_encryption(&sm4_gcm_case_4);
17630 : : }
17631 : :
17632 : : static int
17633 : 0 : test_SM4_GCM_case_5(void)
17634 : : {
17635 : 0 : return test_authenticated_encryption(&sm4_gcm_case_5);
17636 : : }
17637 : :
17638 : : static int
17639 : 0 : test_SM4_GCM_case_6(void)
17640 : : {
17641 : 0 : return test_authenticated_encryption(&sm4_gcm_case_6);
17642 : : }
17643 : :
17644 : : static int
17645 : 0 : test_SM4_GCM_case_7(void)
17646 : : {
17647 : 0 : return test_authenticated_encryption(&sm4_gcm_case_7);
17648 : : }
17649 : :
17650 : : static int
17651 : 0 : test_SM4_GCM_case_8(void)
17652 : : {
17653 : 0 : return test_authenticated_encryption(&sm4_gcm_case_8);
17654 : : }
17655 : :
17656 : : static int
17657 : 0 : test_SM4_GCM_case_9(void)
17658 : : {
17659 : 0 : return test_authenticated_encryption(&sm4_gcm_case_9);
17660 : : }
17661 : :
17662 : : static int
17663 : 0 : test_SM4_GCM_case_10(void)
17664 : : {
17665 : 0 : return test_authenticated_encryption(&sm4_gcm_case_10);
17666 : : }
17667 : :
17668 : : static int
17669 : 0 : test_SM4_GCM_case_11(void)
17670 : : {
17671 : 0 : return test_authenticated_encryption(&sm4_gcm_case_11);
17672 : : }
17673 : :
17674 : : static int
17675 : 0 : test_SM4_GCM_case_12(void)
17676 : : {
17677 : 0 : return test_authenticated_encryption(&sm4_gcm_case_12);
17678 : : }
17679 : :
17680 : : static int
17681 : 0 : test_SM4_GCM_case_13(void)
17682 : : {
17683 : 0 : return test_authenticated_encryption(&sm4_gcm_case_13);
17684 : : }
17685 : :
17686 : : static int
17687 : 0 : test_SM4_GCM_case_14(void)
17688 : : {
17689 : 0 : return test_authenticated_encryption(&sm4_gcm_case_14);
17690 : : }
17691 : :
17692 : : static int
17693 : 0 : test_SM4_GCM_case_15(void)
17694 : : {
17695 : 0 : return test_authenticated_encryption(&sm4_gcm_case_15);
17696 : : }
17697 : :
17698 : : #ifdef RTE_CRYPTO_SCHEDULER
17699 : :
17700 : : /* global AESNI worker IDs for the scheduler test */
17701 : : uint8_t aesni_ids[2];
17702 : :
17703 : : static int
17704 : 0 : scheduler_testsuite_setup(void)
17705 : : {
17706 : : uint32_t i = 0;
17707 : : int32_t nb_devs, ret;
17708 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
17709 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17710 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
17711 : : uint16_t worker_core_count = 0;
17712 : : uint16_t socket_id = 0;
17713 : :
17714 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17715 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17716 : :
17717 : : /* Identify the Worker Cores
17718 : : * Use 2 worker cores for the device args
17719 : : */
17720 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
17721 [ # # ]: 0 : if (worker_core_count > 1)
17722 : : break;
17723 : : ret = snprintf(vdev_args, sizeof(vdev_args), "%s%d", temp_str, i);
17724 : :
17725 : : /* If too many args the result will have been truncated */
17726 [ # # ]: 0 : if (ret >= VDEV_ARGS_SIZE) {
17727 : 0 : RTE_LOG(ERR, USER1,
17728 : : "Cryptodev scheduler test vdev arg size exceeded\n");
17729 : 0 : return TEST_FAILED;
17730 : : }
17731 : :
17732 : : strcpy(temp_str, vdev_args);
17733 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
17734 : 0 : worker_core_count++;
17735 : 0 : socket_id = rte_lcore_to_socket_id(i);
17736 : : }
17737 [ # # ]: 0 : if (worker_core_count != 2) {
17738 : 0 : RTE_LOG(ERR, USER1,
17739 : : "Cryptodev scheduler test require at least "
17740 : : "two worker cores to run. "
17741 : : "Please use the correct coremask.\n");
17742 : 0 : return TEST_FAILED;
17743 : : }
17744 : : strcpy(temp_str, vdev_args);
17745 [ # # ]: 0 : ret = snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d", temp_str,
17746 : : socket_id);
17747 [ # # ]: 0 : if (ret >= VDEV_ARGS_SIZE) {
17748 : 0 : RTE_LOG(ERR, USER1,
17749 : : "Cryptodev scheduler test vdev arg size exceeded\n");
17750 : 0 : return TEST_FAILED;
17751 : : }
17752 : :
17753 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17754 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
17755 : 0 : rte_cryptodev_driver_id_get(
17756 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17757 [ # # ]: 0 : if (nb_devs < 1) {
17758 : 0 : ret = rte_vdev_init(
17759 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17760 : : vdev_args);
17761 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17762 : : "Failed to create instance %u of pmd : %s",
17763 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17764 : : }
17765 : : }
17766 : 0 : return testsuite_setup();
17767 : : }
17768 : :
17769 : : static int
17770 : 0 : test_scheduler_attach_worker_op(void)
17771 : : {
17772 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17773 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17774 : : uint32_t i, nb_devs_attached = 0;
17775 : : int ret;
17776 : : char vdev_name[32];
17777 : 0 : unsigned int count = rte_cryptodev_count();
17778 : :
17779 : : /* create 2 AESNI_MB vdevs on top of existing devices */
17780 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17781 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17782 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17783 : : i);
17784 : 0 : ret = rte_vdev_init(vdev_name, NULL);
17785 : :
17786 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17787 : : "Failed to create instance %u of"
17788 : : " pmd : %s",
17789 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17790 : :
17791 : : if (ret < 0) {
17792 : : RTE_LOG(ERR, USER1,
17793 : : "Failed to create 2 AESNI MB PMDs.\n");
17794 : : return TEST_SKIPPED;
17795 : : }
17796 : : }
17797 : :
17798 : : /* attach 2 AESNI_MB cdevs */
17799 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17800 : : struct rte_cryptodev_info info;
17801 : : unsigned int session_size;
17802 : :
17803 : 0 : rte_cryptodev_info_get(i, &info);
17804 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
17805 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17806 : 0 : continue;
17807 : :
17808 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
17809 : : /*
17810 : : * Create the session mempool again, since now there are new devices
17811 : : * to use the mempool.
17812 : : */
17813 [ # # ]: 0 : if (ts_params->session_mpool) {
17814 : 0 : rte_mempool_free(ts_params->session_mpool);
17815 : 0 : ts_params->session_mpool = NULL;
17816 : : }
17817 : :
17818 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
17819 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17820 : 0 : RTE_LOG(ERR, USER1,
17821 : : "Device does not support "
17822 : : "at least %u sessions\n",
17823 : : MAX_NB_SESSIONS);
17824 : 0 : return TEST_FAILED;
17825 : : }
17826 : : /*
17827 : : * Create mempool with maximum number of sessions,
17828 : : * to include the session headers
17829 : : */
17830 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
17831 : 0 : ts_params->session_mpool =
17832 : 0 : rte_cryptodev_sym_session_pool_create(
17833 : : "test_sess_mp",
17834 : : MAX_NB_SESSIONS, session_size,
17835 : : 0, 0, SOCKET_ID_ANY);
17836 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17837 : : "session mempool allocation failed");
17838 : : }
17839 : :
17840 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
17841 : :
17842 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17843 : : (uint8_t)i);
17844 : :
17845 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17846 : : "Failed to attach device %u of pmd : %s", i,
17847 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17848 : :
17849 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
17850 : :
17851 : 0 : nb_devs_attached++;
17852 : : }
17853 : :
17854 : : return 0;
17855 : : }
17856 : :
17857 : : static int
17858 : 0 : test_scheduler_detach_worker_op(void)
17859 : : {
17860 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17861 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17862 : : uint32_t i;
17863 : : int ret;
17864 : :
17865 [ # # ]: 0 : for (i = 0; i < 2; i++) {
17866 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17867 : 0 : aesni_ids[i]);
17868 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17869 : : "Failed to detach device %u", aesni_ids[i]);
17870 : : }
17871 : :
17872 : : return 0;
17873 : : }
17874 : :
17875 : : static int
17876 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17877 : : {
17878 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17879 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17880 : : /* set mode */
17881 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
17882 : : scheduler_mode);
17883 : : }
17884 : :
17885 : : static int
17886 : 0 : test_scheduler_mode_roundrobin_op(void)
17887 : : {
17888 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17889 : : 0, "Failed to set roundrobin mode");
17890 : : return 0;
17891 : :
17892 : : }
17893 : :
17894 : : static int
17895 : 0 : test_scheduler_mode_multicore_op(void)
17896 : : {
17897 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17898 : : 0, "Failed to set multicore mode");
17899 : :
17900 : : return 0;
17901 : : }
17902 : :
17903 : : static int
17904 : 0 : test_scheduler_mode_failover_op(void)
17905 : : {
17906 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17907 : : 0, "Failed to set failover mode");
17908 : :
17909 : : return 0;
17910 : : }
17911 : :
17912 : : static int
17913 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
17914 : : {
17915 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17916 : : 0, "Failed to set pktsize mode");
17917 : :
17918 : : return 0;
17919 : : }
17920 : :
17921 : : static int
17922 : 0 : scheduler_multicore_testsuite_setup(void)
17923 : : {
17924 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17925 : : return TEST_SKIPPED;
17926 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17927 : 0 : return TEST_SKIPPED;
17928 : : return 0;
17929 : : }
17930 : :
17931 : : static int
17932 : 0 : scheduler_roundrobin_testsuite_setup(void)
17933 : : {
17934 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17935 : : return TEST_SKIPPED;
17936 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17937 : 0 : return TEST_SKIPPED;
17938 : : return 0;
17939 : : }
17940 : :
17941 : : static int
17942 : 0 : scheduler_failover_testsuite_setup(void)
17943 : : {
17944 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17945 : : return TEST_SKIPPED;
17946 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17947 : 0 : return TEST_SKIPPED;
17948 : : return 0;
17949 : : }
17950 : :
17951 : : static int
17952 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
17953 : : {
17954 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17955 : : return TEST_SKIPPED;
17956 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17957 : 0 : return TEST_SKIPPED;
17958 : : return 0;
17959 : : }
17960 : :
17961 : : static void
17962 : 0 : scheduler_mode_testsuite_teardown(void)
17963 : : {
17964 : 0 : test_scheduler_detach_worker_op();
17965 : 0 : }
17966 : :
17967 : : #endif /* RTE_CRYPTO_SCHEDULER */
17968 : :
17969 : : static struct unit_test_suite end_testsuite = {
17970 : : .suite_name = NULL,
17971 : : .setup = NULL,
17972 : : .teardown = NULL,
17973 : : .unit_test_suites = NULL
17974 : : };
17975 : :
17976 : : #ifdef RTE_LIB_SECURITY
17977 : : static struct unit_test_suite ipsec_proto_testsuite = {
17978 : : .suite_name = "IPsec Proto Unit Test Suite",
17979 : : .setup = ipsec_proto_testsuite_setup,
17980 : : .unit_test_cases = {
17981 : : TEST_CASE_NAMED_WITH_DATA(
17982 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17983 : : ut_setup_security, ut_teardown,
17984 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17985 : : TEST_CASE_NAMED_WITH_DATA(
17986 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17987 : : ut_setup_security, ut_teardown,
17988 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17989 : : TEST_CASE_NAMED_WITH_DATA(
17990 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17991 : : ut_setup_security, ut_teardown,
17992 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17993 : : TEST_CASE_NAMED_WITH_DATA(
17994 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17995 : : ut_setup_security, ut_teardown,
17996 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17997 : : TEST_CASE_NAMED_WITH_DATA(
17998 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17999 : : ut_setup_security, ut_teardown,
18000 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
18001 : : TEST_CASE_NAMED_WITH_DATA(
18002 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
18003 : : ut_setup_security, ut_teardown,
18004 : : test_ipsec_proto_known_vec,
18005 : : &pkt_aes_128_cbc_md5),
18006 : : TEST_CASE_NAMED_WITH_DATA(
18007 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
18008 : : ut_setup_security, ut_teardown,
18009 : : test_ipsec_proto_known_vec,
18010 : : &pkt_aes_128_ctr_hmac_sha256),
18011 : : TEST_CASE_NAMED_WITH_DATA(
18012 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
18013 : : ut_setup_security, ut_teardown,
18014 : : test_ipsec_proto_known_vec,
18015 : : &pkt_aes_128_ctr_hmac_sha384),
18016 : : TEST_CASE_NAMED_WITH_DATA(
18017 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
18018 : : ut_setup_security, ut_teardown,
18019 : : test_ipsec_proto_known_vec,
18020 : : &pkt_aes_128_ctr_hmac_sha512),
18021 : : TEST_CASE_NAMED_WITH_DATA(
18022 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
18023 : : ut_setup_security, ut_teardown,
18024 : : test_ipsec_proto_known_vec_inb,
18025 : : &pkt_aes_128_ctr_hmac_sha256),
18026 : : TEST_CASE_NAMED_WITH_DATA(
18027 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
18028 : : ut_setup_security, ut_teardown,
18029 : : test_ipsec_proto_known_vec_inb,
18030 : : &pkt_aes_128_ctr_hmac_sha384),
18031 : : TEST_CASE_NAMED_WITH_DATA(
18032 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
18033 : : ut_setup_security, ut_teardown,
18034 : : test_ipsec_proto_known_vec_inb,
18035 : : &pkt_aes_128_ctr_hmac_sha512),
18036 : : TEST_CASE_NAMED_WITH_DATA(
18037 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18038 : : ut_setup_security, ut_teardown,
18039 : : test_ipsec_proto_known_vec,
18040 : : &pkt_aes_128_cbc_hmac_sha256),
18041 : : TEST_CASE_NAMED_WITH_DATA(
18042 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18043 : : ut_setup_security, ut_teardown,
18044 : : test_ipsec_proto_known_vec,
18045 : : &pkt_aes_128_cbc_hmac_sha384),
18046 : : TEST_CASE_NAMED_WITH_DATA(
18047 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18048 : : ut_setup_security, ut_teardown,
18049 : : test_ipsec_proto_known_vec,
18050 : : &pkt_aes_128_cbc_hmac_sha512),
18051 : : TEST_CASE_NAMED_WITH_DATA(
18052 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18053 : : ut_setup_security, ut_teardown,
18054 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
18055 : : TEST_CASE_NAMED_WITH_DATA(
18056 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18057 : : ut_setup_security, ut_teardown,
18058 : : test_ipsec_proto_known_vec,
18059 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18060 : : TEST_CASE_NAMED_WITH_DATA(
18061 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18062 : : ut_setup_security, ut_teardown,
18063 : : test_ipsec_proto_known_vec,
18064 : : &pkt_null_aes_xcbc),
18065 : : TEST_CASE_NAMED_WITH_DATA(
18066 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18067 : : ut_setup_security, ut_teardown,
18068 : : test_ipsec_proto_known_vec,
18069 : : &pkt_des_cbc_hmac_sha256),
18070 : : TEST_CASE_NAMED_WITH_DATA(
18071 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18072 : : ut_setup_security, ut_teardown,
18073 : : test_ipsec_proto_known_vec,
18074 : : &pkt_des_cbc_hmac_sha384),
18075 : : TEST_CASE_NAMED_WITH_DATA(
18076 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18077 : : ut_setup_security, ut_teardown,
18078 : : test_ipsec_proto_known_vec,
18079 : : &pkt_des_cbc_hmac_sha512),
18080 : : TEST_CASE_NAMED_WITH_DATA(
18081 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18082 : : ut_setup_security, ut_teardown,
18083 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
18084 : : TEST_CASE_NAMED_WITH_DATA(
18085 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18086 : : ut_setup_security, ut_teardown,
18087 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
18088 : : TEST_CASE_NAMED_WITH_DATA(
18089 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18090 : : ut_setup_security, ut_teardown,
18091 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
18092 : : TEST_CASE_NAMED_WITH_DATA(
18093 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18094 : : ut_setup_security, ut_teardown,
18095 : : test_ipsec_proto_known_vec,
18096 : : &pkt_des_cbc_hmac_sha256_v6),
18097 : : TEST_CASE_NAMED_WITH_DATA(
18098 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18099 : : ut_setup_security, ut_teardown,
18100 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
18101 : : TEST_CASE_NAMED_WITH_DATA(
18102 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18103 : : ut_setup_security, ut_teardown,
18104 : : test_ipsec_proto_known_vec,
18105 : : &pkt_ah_tunnel_sha256),
18106 : : TEST_CASE_NAMED_WITH_DATA(
18107 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18108 : : ut_setup_security, ut_teardown,
18109 : : test_ipsec_proto_known_vec,
18110 : : &pkt_ah_transport_sha256),
18111 : : TEST_CASE_NAMED_WITH_DATA(
18112 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18113 : : ut_setup_security, ut_teardown,
18114 : : test_ipsec_proto_known_vec,
18115 : : &pkt_ah_ipv4_aes_gmac_128),
18116 : : TEST_CASE_NAMED_WITH_DATA(
18117 : : "Outbound fragmented packet",
18118 : : ut_setup_security, ut_teardown,
18119 : : test_ipsec_proto_known_vec_fragmented,
18120 : : &pkt_aes_128_gcm_frag),
18121 : : TEST_CASE_NAMED_WITH_DATA(
18122 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
18123 : : ut_setup_security, ut_teardown,
18124 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
18125 : : TEST_CASE_NAMED_WITH_DATA(
18126 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
18127 : : ut_setup_security, ut_teardown,
18128 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
18129 : : TEST_CASE_NAMED_WITH_DATA(
18130 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
18131 : : ut_setup_security, ut_teardown,
18132 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
18133 : : TEST_CASE_NAMED_WITH_DATA(
18134 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
18135 : : ut_setup_security, ut_teardown,
18136 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
18137 : : TEST_CASE_NAMED_WITH_DATA(
18138 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
18139 : : ut_setup_security, ut_teardown,
18140 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
18141 : : TEST_CASE_NAMED_WITH_DATA(
18142 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
18143 : : ut_setup_security, ut_teardown,
18144 : : test_ipsec_proto_known_vec_inb,
18145 : : &pkt_aes_128_cbc_md5),
18146 : : TEST_CASE_NAMED_WITH_DATA(
18147 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18148 : : ut_setup_security, ut_teardown,
18149 : : test_ipsec_proto_known_vec_inb,
18150 : : &pkt_aes_128_cbc_hmac_sha256),
18151 : : TEST_CASE_NAMED_WITH_DATA(
18152 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18153 : : ut_setup_security, ut_teardown,
18154 : : test_ipsec_proto_known_vec_inb,
18155 : : &pkt_aes_128_cbc_hmac_sha384),
18156 : : TEST_CASE_NAMED_WITH_DATA(
18157 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18158 : : ut_setup_security, ut_teardown,
18159 : : test_ipsec_proto_known_vec_inb,
18160 : : &pkt_aes_128_cbc_hmac_sha512),
18161 : : TEST_CASE_NAMED_WITH_DATA(
18162 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18163 : : ut_setup_security, ut_teardown,
18164 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
18165 : : TEST_CASE_NAMED_WITH_DATA(
18166 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18167 : : ut_setup_security, ut_teardown,
18168 : : test_ipsec_proto_known_vec_inb,
18169 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18170 : : TEST_CASE_NAMED_WITH_DATA(
18171 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18172 : : ut_setup_security, ut_teardown,
18173 : : test_ipsec_proto_known_vec_inb,
18174 : : &pkt_null_aes_xcbc),
18175 : : TEST_CASE_NAMED_WITH_DATA(
18176 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18177 : : ut_setup_security, ut_teardown,
18178 : : test_ipsec_proto_known_vec_inb,
18179 : : &pkt_des_cbc_hmac_sha256),
18180 : : TEST_CASE_NAMED_WITH_DATA(
18181 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18182 : : ut_setup_security, ut_teardown,
18183 : : test_ipsec_proto_known_vec_inb,
18184 : : &pkt_des_cbc_hmac_sha384),
18185 : : TEST_CASE_NAMED_WITH_DATA(
18186 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18187 : : ut_setup_security, ut_teardown,
18188 : : test_ipsec_proto_known_vec_inb,
18189 : : &pkt_des_cbc_hmac_sha512),
18190 : : TEST_CASE_NAMED_WITH_DATA(
18191 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18192 : : ut_setup_security, ut_teardown,
18193 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
18194 : : TEST_CASE_NAMED_WITH_DATA(
18195 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18196 : : ut_setup_security, ut_teardown,
18197 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
18198 : : TEST_CASE_NAMED_WITH_DATA(
18199 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18200 : : ut_setup_security, ut_teardown,
18201 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
18202 : : TEST_CASE_NAMED_WITH_DATA(
18203 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18204 : : ut_setup_security, ut_teardown,
18205 : : test_ipsec_proto_known_vec_inb,
18206 : : &pkt_des_cbc_hmac_sha256_v6),
18207 : : TEST_CASE_NAMED_WITH_DATA(
18208 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18209 : : ut_setup_security, ut_teardown,
18210 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
18211 : : TEST_CASE_NAMED_WITH_DATA(
18212 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18213 : : ut_setup_security, ut_teardown,
18214 : : test_ipsec_proto_known_vec_inb,
18215 : : &pkt_ah_tunnel_sha256),
18216 : : TEST_CASE_NAMED_WITH_DATA(
18217 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18218 : : ut_setup_security, ut_teardown,
18219 : : test_ipsec_proto_known_vec_inb,
18220 : : &pkt_ah_transport_sha256),
18221 : : TEST_CASE_NAMED_WITH_DATA(
18222 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18223 : : ut_setup_security, ut_teardown,
18224 : : test_ipsec_proto_known_vec_inb,
18225 : : &pkt_ah_ipv4_aes_gmac_128),
18226 : : TEST_CASE_NAMED_ST(
18227 : : "Combined test alg list",
18228 : : ut_setup_security, ut_teardown,
18229 : : test_ipsec_proto_display_list),
18230 : : TEST_CASE_NAMED_ST(
18231 : : "Combined test alg list (AH)",
18232 : : ut_setup_security, ut_teardown,
18233 : : test_ipsec_proto_ah_tunnel_ipv4),
18234 : : TEST_CASE_NAMED_ST(
18235 : : "IV generation",
18236 : : ut_setup_security, ut_teardown,
18237 : : test_ipsec_proto_iv_gen),
18238 : : TEST_CASE_NAMED_ST(
18239 : : "UDP encapsulation",
18240 : : ut_setup_security, ut_teardown,
18241 : : test_ipsec_proto_udp_encap),
18242 : : TEST_CASE_NAMED_ST(
18243 : : "UDP encapsulation with custom ports",
18244 : : ut_setup_security, ut_teardown,
18245 : : test_ipsec_proto_udp_encap_custom_ports),
18246 : : TEST_CASE_NAMED_ST(
18247 : : "UDP encapsulation ports verification test",
18248 : : ut_setup_security, ut_teardown,
18249 : : test_ipsec_proto_udp_ports_verify),
18250 : : TEST_CASE_NAMED_ST(
18251 : : "SA expiry packets soft",
18252 : : ut_setup_security, ut_teardown,
18253 : : test_ipsec_proto_sa_exp_pkts_soft),
18254 : : TEST_CASE_NAMED_ST(
18255 : : "SA expiry packets hard",
18256 : : ut_setup_security, ut_teardown,
18257 : : test_ipsec_proto_sa_exp_pkts_hard),
18258 : : TEST_CASE_NAMED_ST(
18259 : : "Negative test: ICV corruption",
18260 : : ut_setup_security, ut_teardown,
18261 : : test_ipsec_proto_err_icv_corrupt),
18262 : : TEST_CASE_NAMED_ST(
18263 : : "Tunnel dst addr verification",
18264 : : ut_setup_security, ut_teardown,
18265 : : test_ipsec_proto_tunnel_dst_addr_verify),
18266 : : TEST_CASE_NAMED_ST(
18267 : : "Tunnel src and dst addr verification",
18268 : : ut_setup_security, ut_teardown,
18269 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
18270 : : TEST_CASE_NAMED_ST(
18271 : : "Inner IP checksum",
18272 : : ut_setup_security, ut_teardown,
18273 : : test_ipsec_proto_inner_ip_csum),
18274 : : TEST_CASE_NAMED_ST(
18275 : : "Inner L4 checksum",
18276 : : ut_setup_security, ut_teardown,
18277 : : test_ipsec_proto_inner_l4_csum),
18278 : : TEST_CASE_NAMED_ST(
18279 : : "Tunnel IPv4 in IPv4",
18280 : : ut_setup_security, ut_teardown,
18281 : : test_ipsec_proto_tunnel_v4_in_v4),
18282 : : TEST_CASE_NAMED_ST(
18283 : : "Tunnel IPv6 in IPv6",
18284 : : ut_setup_security, ut_teardown,
18285 : : test_ipsec_proto_tunnel_v6_in_v6),
18286 : : TEST_CASE_NAMED_ST(
18287 : : "Tunnel IPv4 in IPv6",
18288 : : ut_setup_security, ut_teardown,
18289 : : test_ipsec_proto_tunnel_v4_in_v6),
18290 : : TEST_CASE_NAMED_ST(
18291 : : "Tunnel IPv6 in IPv4",
18292 : : ut_setup_security, ut_teardown,
18293 : : test_ipsec_proto_tunnel_v6_in_v4),
18294 : : TEST_CASE_NAMED_ST(
18295 : : "Transport IPv4",
18296 : : ut_setup_security, ut_teardown,
18297 : : test_ipsec_proto_transport_v4),
18298 : : TEST_CASE_NAMED_ST(
18299 : : "AH transport IPv4",
18300 : : ut_setup_security, ut_teardown,
18301 : : test_ipsec_proto_ah_transport_ipv4),
18302 : : TEST_CASE_NAMED_ST(
18303 : : "Transport l4 checksum",
18304 : : ut_setup_security, ut_teardown,
18305 : : test_ipsec_proto_transport_l4_csum),
18306 : : TEST_CASE_NAMED_ST(
18307 : : "Statistics: success",
18308 : : ut_setup_security, ut_teardown,
18309 : : test_ipsec_proto_stats),
18310 : : TEST_CASE_NAMED_ST(
18311 : : "Fragmented packet",
18312 : : ut_setup_security, ut_teardown,
18313 : : test_ipsec_proto_pkt_fragment),
18314 : : TEST_CASE_NAMED_ST(
18315 : : "Tunnel header copy DF (inner 0)",
18316 : : ut_setup_security, ut_teardown,
18317 : : test_ipsec_proto_copy_df_inner_0),
18318 : : TEST_CASE_NAMED_ST(
18319 : : "Tunnel header copy DF (inner 1)",
18320 : : ut_setup_security, ut_teardown,
18321 : : test_ipsec_proto_copy_df_inner_1),
18322 : : TEST_CASE_NAMED_ST(
18323 : : "Tunnel header set DF 0 (inner 1)",
18324 : : ut_setup_security, ut_teardown,
18325 : : test_ipsec_proto_set_df_0_inner_1),
18326 : : TEST_CASE_NAMED_ST(
18327 : : "Tunnel header set DF 1 (inner 0)",
18328 : : ut_setup_security, ut_teardown,
18329 : : test_ipsec_proto_set_df_1_inner_0),
18330 : : TEST_CASE_NAMED_ST(
18331 : : "Tunnel header IPv4 copy DSCP (inner 0)",
18332 : : ut_setup_security, ut_teardown,
18333 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
18334 : : TEST_CASE_NAMED_ST(
18335 : : "Tunnel header IPv4 copy DSCP (inner 1)",
18336 : : ut_setup_security, ut_teardown,
18337 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
18338 : : TEST_CASE_NAMED_ST(
18339 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
18340 : : ut_setup_security, ut_teardown,
18341 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
18342 : : TEST_CASE_NAMED_ST(
18343 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
18344 : : ut_setup_security, ut_teardown,
18345 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
18346 : : TEST_CASE_NAMED_ST(
18347 : : "Tunnel header IPv6 copy DSCP (inner 0)",
18348 : : ut_setup_security, ut_teardown,
18349 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
18350 : : TEST_CASE_NAMED_ST(
18351 : : "Tunnel header IPv6 copy DSCP (inner 1)",
18352 : : ut_setup_security, ut_teardown,
18353 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
18354 : : TEST_CASE_NAMED_ST(
18355 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
18356 : : ut_setup_security, ut_teardown,
18357 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
18358 : : TEST_CASE_NAMED_ST(
18359 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
18360 : : ut_setup_security, ut_teardown,
18361 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
18362 : : TEST_CASE_NAMED_WITH_DATA(
18363 : : "Antireplay with window size 1024",
18364 : : ut_setup_security, ut_teardown,
18365 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
18366 : : TEST_CASE_NAMED_WITH_DATA(
18367 : : "Antireplay with window size 2048",
18368 : : ut_setup_security, ut_teardown,
18369 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
18370 : : TEST_CASE_NAMED_WITH_DATA(
18371 : : "Antireplay with window size 4096",
18372 : : ut_setup_security, ut_teardown,
18373 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
18374 : : TEST_CASE_NAMED_WITH_DATA(
18375 : : "ESN and Antireplay with window size 1024",
18376 : : ut_setup_security, ut_teardown,
18377 : : test_ipsec_proto_pkt_esn_antireplay1024,
18378 : : &pkt_aes_128_gcm),
18379 : : TEST_CASE_NAMED_WITH_DATA(
18380 : : "ESN and Antireplay with window size 2048",
18381 : : ut_setup_security, ut_teardown,
18382 : : test_ipsec_proto_pkt_esn_antireplay2048,
18383 : : &pkt_aes_128_gcm),
18384 : : TEST_CASE_NAMED_WITH_DATA(
18385 : : "ESN and Antireplay with window size 4096",
18386 : : ut_setup_security, ut_teardown,
18387 : : test_ipsec_proto_pkt_esn_antireplay4096,
18388 : : &pkt_aes_128_gcm),
18389 : : TEST_CASE_NAMED_ST(
18390 : : "Tunnel header IPv4 decrement inner TTL",
18391 : : ut_setup_security, ut_teardown,
18392 : : test_ipsec_proto_ipv4_ttl_decrement),
18393 : : TEST_CASE_NAMED_ST(
18394 : : "Tunnel header IPv6 decrement inner hop limit",
18395 : : ut_setup_security, ut_teardown,
18396 : : test_ipsec_proto_ipv6_hop_limit_decrement),
18397 : : TEST_CASE_NAMED_ST(
18398 : : "Multi-segmented mode",
18399 : : ut_setup_security, ut_teardown,
18400 : : test_ipsec_proto_sgl),
18401 : : TEST_CASE_NAMED_ST(
18402 : : "Multi-segmented external mbuf mode",
18403 : : ut_setup_security, ut_teardown,
18404 : : test_ipsec_proto_sgl_ext_mbuf),
18405 : : TEST_CASE_NAMED_WITH_DATA(
18406 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
18407 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18408 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
18409 : : TEST_CASE_NAMED_WITH_DATA(
18410 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject multi seg",
18411 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18412 : : test_ipsec_proto_known_vec_inb_rx_inject_multi_seg, &pkt_aes_128_gcm),
18413 : :
18414 : : TEST_CASES_END() /**< NULL terminate unit test array */
18415 : : }
18416 : : };
18417 : :
18418 : : static struct unit_test_suite pdcp_proto_testsuite = {
18419 : : .suite_name = "PDCP Proto Unit Test Suite",
18420 : : .setup = pdcp_proto_testsuite_setup,
18421 : : .unit_test_cases = {
18422 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
18423 : : test_PDCP_PROTO_all),
18424 : : TEST_CASES_END() /**< NULL terminate unit test array */
18425 : : }
18426 : : };
18427 : :
18428 : : static struct unit_test_suite tls12_record_proto_testsuite = {
18429 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
18430 : : .setup = tls_record_proto_testsuite_setup,
18431 : : .unit_test_cases = {
18432 : : TEST_CASE_NAMED_WITH_DATA(
18433 : : "Write record known vector AES-GCM-128 (vector 1)",
18434 : : ut_setup_security, ut_teardown,
18435 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
18436 : : TEST_CASE_NAMED_WITH_DATA(
18437 : : "Write record known vector AES-GCM-128 (vector 2)",
18438 : : ut_setup_security, ut_teardown,
18439 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
18440 : : TEST_CASE_NAMED_WITH_DATA(
18441 : : "Write record known vector AES-GCM-256",
18442 : : ut_setup_security, ut_teardown,
18443 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
18444 : : TEST_CASE_NAMED_WITH_DATA(
18445 : : "Write record known vector AES-CBC-128-SHA1",
18446 : : ut_setup_security, ut_teardown,
18447 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
18448 : : TEST_CASE_NAMED_WITH_DATA(
18449 : : "Write record known vector AES-128-CBC-SHA256",
18450 : : ut_setup_security, ut_teardown,
18451 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
18452 : : TEST_CASE_NAMED_WITH_DATA(
18453 : : "Write record known vector AES-256-CBC-SHA1",
18454 : : ut_setup_security, ut_teardown,
18455 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
18456 : : TEST_CASE_NAMED_WITH_DATA(
18457 : : "Write record known vector AES-256-CBC-SHA256",
18458 : : ut_setup_security, ut_teardown,
18459 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
18460 : : TEST_CASE_NAMED_WITH_DATA(
18461 : : "Write record known vector AES-256-CBC-SHA384",
18462 : : ut_setup_security, ut_teardown,
18463 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
18464 : : TEST_CASE_NAMED_WITH_DATA(
18465 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18466 : : ut_setup_security, ut_teardown,
18467 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
18468 : : TEST_CASE_NAMED_WITH_DATA(
18469 : : "Write record known vector NULL-SHA1-HMAC",
18470 : : ut_setup_security, ut_teardown,
18471 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
18472 : : TEST_CASE_NAMED_WITH_DATA(
18473 : : "Write record known vector CHACHA20-POLY1305",
18474 : : ut_setup_security, ut_teardown,
18475 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
18476 : :
18477 : : TEST_CASE_NAMED_WITH_DATA(
18478 : : "Read record known vector AES-GCM-128 (vector 1)",
18479 : : ut_setup_security, ut_teardown,
18480 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
18481 : : TEST_CASE_NAMED_WITH_DATA(
18482 : : "Read record known vector AES-GCM-128 (vector 2)",
18483 : : ut_setup_security, ut_teardown,
18484 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
18485 : : TEST_CASE_NAMED_WITH_DATA(
18486 : : "Read record known vector AES-GCM-256",
18487 : : ut_setup_security, ut_teardown,
18488 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
18489 : : TEST_CASE_NAMED_WITH_DATA(
18490 : : "Read record known vector AES-128-CBC-SHA1",
18491 : : ut_setup_security, ut_teardown,
18492 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
18493 : : TEST_CASE_NAMED_WITH_DATA(
18494 : : "Read record known vector AES-128-CBC-SHA256",
18495 : : ut_setup_security, ut_teardown,
18496 : : test_tls_record_proto_known_vec_read,
18497 : : &tls_test_data_aes_128_cbc_sha256_hmac),
18498 : : TEST_CASE_NAMED_WITH_DATA(
18499 : : "Read record known vector AES-256-CBC-SHA1",
18500 : : ut_setup_security, ut_teardown,
18501 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
18502 : : TEST_CASE_NAMED_WITH_DATA(
18503 : : "Read record known vector AES-256-CBC-SHA256",
18504 : : ut_setup_security, ut_teardown,
18505 : : test_tls_record_proto_known_vec_read,
18506 : : &tls_test_data_aes_256_cbc_sha256_hmac),
18507 : : TEST_CASE_NAMED_WITH_DATA(
18508 : : "Read record known vector AES-256-CBC-SHA384",
18509 : : ut_setup_security, ut_teardown,
18510 : : test_tls_record_proto_known_vec_read,
18511 : : &tls_test_data_aes_256_cbc_sha384_hmac),
18512 : : TEST_CASE_NAMED_WITH_DATA(
18513 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18514 : : ut_setup_security, ut_teardown,
18515 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18516 : : TEST_CASE_NAMED_WITH_DATA(
18517 : : "Read record known vector NULL-SHA1-HMAC",
18518 : : ut_setup_security, ut_teardown,
18519 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18520 : : TEST_CASE_NAMED_WITH_DATA(
18521 : : "Read record known vector CHACHA20-POLY1305",
18522 : : ut_setup_security, ut_teardown,
18523 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18524 : :
18525 : : TEST_CASE_NAMED_ST(
18526 : : "Combined test alg list",
18527 : : ut_setup_security, ut_teardown,
18528 : : test_tls_1_2_record_proto_display_list),
18529 : : TEST_CASE_NAMED_ST(
18530 : : "Data walkthrough combined test alg list",
18531 : : ut_setup_security, ut_teardown,
18532 : : test_tls_1_2_record_proto_data_walkthrough),
18533 : : TEST_CASE_NAMED_ST(
18534 : : "Multi-segmented mode",
18535 : : ut_setup_security, ut_teardown,
18536 : : test_tls_1_2_record_proto_sgl),
18537 : : TEST_CASE_NAMED_ST(
18538 : : "Multi-segmented mode data walkthrough",
18539 : : ut_setup_security, ut_teardown,
18540 : : test_tls_1_2_record_proto_sgl_data_walkthrough),
18541 : : TEST_CASE_NAMED_ST(
18542 : : "Multi-segmented mode out of place",
18543 : : ut_setup_security, ut_teardown,
18544 : : test_tls_1_2_record_proto_sgl_oop),
18545 : : TEST_CASE_NAMED_ST(
18546 : : "TLS packet header corruption",
18547 : : ut_setup_security, ut_teardown,
18548 : : test_tls_record_proto_corrupt_pkt),
18549 : : TEST_CASE_NAMED_ST(
18550 : : "Custom content type",
18551 : : ut_setup_security, ut_teardown,
18552 : : test_tls_record_proto_custom_content_type),
18553 : : TEST_CASE_NAMED_ST(
18554 : : "Zero len TLS record with content type as app",
18555 : : ut_setup_security, ut_teardown,
18556 : : test_tls_record_proto_zero_len),
18557 : : TEST_CASE_NAMED_ST(
18558 : : "Zero len TLS record with content type as ctrl",
18559 : : ut_setup_security, ut_teardown,
18560 : : test_tls_record_proto_zero_len_non_app),
18561 : : TEST_CASE_NAMED_ST(
18562 : : "TLS record DM mode with optional padding < 2 blocks",
18563 : : ut_setup_security, ut_teardown,
18564 : : test_tls_record_proto_dm_opt_padding),
18565 : : TEST_CASE_NAMED_ST(
18566 : : "TLS record DM mode with optional padding > 2 blocks",
18567 : : ut_setup_security, ut_teardown,
18568 : : test_tls_record_proto_dm_opt_padding_1),
18569 : : TEST_CASE_NAMED_ST(
18570 : : "TLS record SG mode with optional padding < 2 blocks",
18571 : : ut_setup_security, ut_teardown,
18572 : : test_tls_record_proto_sg_opt_padding),
18573 : : TEST_CASE_NAMED_ST(
18574 : : "TLS record SG mode with optional padding > 2 blocks",
18575 : : ut_setup_security, ut_teardown,
18576 : : test_tls_record_proto_sg_opt_padding_1),
18577 : : TEST_CASE_NAMED_ST(
18578 : : "TLS record SG mode with optional padding > 2 blocks",
18579 : : ut_setup_security, ut_teardown,
18580 : : test_tls_record_proto_sg_opt_padding_2),
18581 : : TEST_CASE_NAMED_ST(
18582 : : "TLS record SG mode with optional padding > max range",
18583 : : ut_setup_security, ut_teardown,
18584 : : test_tls_record_proto_sg_opt_padding_max),
18585 : : TEST_CASE_NAMED_ST(
18586 : : "TLS record SG mode with padding corruption",
18587 : : ut_setup_security, ut_teardown,
18588 : : test_tls_record_proto_sg_opt_padding_corrupt),
18589 : : TEST_CASES_END() /**< NULL terminate unit test array */
18590 : : }
18591 : : };
18592 : :
18593 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
18594 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18595 : : .setup = tls_record_proto_testsuite_setup,
18596 : : .unit_test_cases = {
18597 : : TEST_CASE_NAMED_WITH_DATA(
18598 : : "Write record known vector AES-GCM-128",
18599 : : ut_setup_security, ut_teardown,
18600 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18601 : : TEST_CASE_NAMED_WITH_DATA(
18602 : : "Write record known vector AES-GCM-256",
18603 : : ut_setup_security, ut_teardown,
18604 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18605 : : TEST_CASE_NAMED_WITH_DATA(
18606 : : "Write record known vector AES-128-CBC-SHA1",
18607 : : ut_setup_security, ut_teardown,
18608 : : test_tls_record_proto_known_vec,
18609 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18610 : : TEST_CASE_NAMED_WITH_DATA(
18611 : : "Write record known vector AES-128-CBC-SHA256",
18612 : : ut_setup_security, ut_teardown,
18613 : : test_tls_record_proto_known_vec,
18614 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18615 : : TEST_CASE_NAMED_WITH_DATA(
18616 : : "Write record known vector AES-256-CBC-SHA1",
18617 : : ut_setup_security, ut_teardown,
18618 : : test_tls_record_proto_known_vec,
18619 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18620 : : TEST_CASE_NAMED_WITH_DATA(
18621 : : "Write record known vector AES-256-CBC-SHA256",
18622 : : ut_setup_security, ut_teardown,
18623 : : test_tls_record_proto_known_vec,
18624 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18625 : : TEST_CASE_NAMED_WITH_DATA(
18626 : : "Write record known vector AES-256-CBC-SHA384",
18627 : : ut_setup_security, ut_teardown,
18628 : : test_tls_record_proto_known_vec,
18629 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18630 : : TEST_CASE_NAMED_WITH_DATA(
18631 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18632 : : ut_setup_security, ut_teardown,
18633 : : test_tls_record_proto_known_vec,
18634 : : &dtls_test_data_3des_cbc_sha1_hmac),
18635 : : TEST_CASE_NAMED_WITH_DATA(
18636 : : "Write record known vector NULL-SHA1-HMAC",
18637 : : ut_setup_security, ut_teardown,
18638 : : test_tls_record_proto_known_vec,
18639 : : &dtls_test_data_null_cipher_sha1_hmac),
18640 : : TEST_CASE_NAMED_WITH_DATA(
18641 : : "Write record known vector CHACHA20-POLY1305",
18642 : : ut_setup_security, ut_teardown,
18643 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18644 : : TEST_CASE_NAMED_WITH_DATA(
18645 : : "Read record known vector AES-GCM-128",
18646 : : ut_setup_security, ut_teardown,
18647 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18648 : : TEST_CASE_NAMED_WITH_DATA(
18649 : : "Read record known vector AES-GCM-256",
18650 : : ut_setup_security, ut_teardown,
18651 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18652 : : TEST_CASE_NAMED_WITH_DATA(
18653 : : "Read record known vector AES-128-CBC-SHA1",
18654 : : ut_setup_security, ut_teardown,
18655 : : test_tls_record_proto_known_vec_read,
18656 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18657 : : TEST_CASE_NAMED_WITH_DATA(
18658 : : "Read record known vector AES-128-CBC-SHA256",
18659 : : ut_setup_security, ut_teardown,
18660 : : test_tls_record_proto_known_vec_read,
18661 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18662 : : TEST_CASE_NAMED_WITH_DATA(
18663 : : "Read record known vector AES-256-CBC-SHA1",
18664 : : ut_setup_security, ut_teardown,
18665 : : test_tls_record_proto_known_vec_read,
18666 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18667 : : TEST_CASE_NAMED_WITH_DATA(
18668 : : "Read record known vector AES-256-CBC-SHA256",
18669 : : ut_setup_security, ut_teardown,
18670 : : test_tls_record_proto_known_vec_read,
18671 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18672 : : TEST_CASE_NAMED_WITH_DATA(
18673 : : "Read record known vector AES-256-CBC-SHA384",
18674 : : ut_setup_security, ut_teardown,
18675 : : test_tls_record_proto_known_vec_read,
18676 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18677 : : TEST_CASE_NAMED_WITH_DATA(
18678 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18679 : : ut_setup_security, ut_teardown,
18680 : : test_tls_record_proto_known_vec_read,
18681 : : &dtls_test_data_3des_cbc_sha1_hmac),
18682 : : TEST_CASE_NAMED_WITH_DATA(
18683 : : "Read record known vector NULL-SHA1-HMAC",
18684 : : ut_setup_security, ut_teardown,
18685 : : test_tls_record_proto_known_vec_read,
18686 : : &dtls_test_data_null_cipher_sha1_hmac),
18687 : : TEST_CASE_NAMED_WITH_DATA(
18688 : : "Read record known vector CHACHA20-POLY1305",
18689 : : ut_setup_security, ut_teardown,
18690 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18691 : :
18692 : : TEST_CASE_NAMED_ST(
18693 : : "Combined test alg list",
18694 : : ut_setup_security, ut_teardown,
18695 : : test_dtls_1_2_record_proto_display_list),
18696 : : TEST_CASE_NAMED_ST(
18697 : : "Data walkthrough combined test alg list",
18698 : : ut_setup_security, ut_teardown,
18699 : : test_dtls_1_2_record_proto_data_walkthrough),
18700 : : TEST_CASE_NAMED_ST(
18701 : : "Multi-segmented mode",
18702 : : ut_setup_security, ut_teardown,
18703 : : test_dtls_1_2_record_proto_sgl),
18704 : : TEST_CASE_NAMED_ST(
18705 : : "Multi-segmented mode data walkthrough",
18706 : : ut_setup_security, ut_teardown,
18707 : : test_dtls_1_2_record_proto_sgl_data_walkthrough),
18708 : : TEST_CASE_NAMED_ST(
18709 : : "Multi-segmented mode out of place",
18710 : : ut_setup_security, ut_teardown,
18711 : : test_dtls_1_2_record_proto_sgl_oop),
18712 : : TEST_CASE_NAMED_ST(
18713 : : "Packet corruption",
18714 : : ut_setup_security, ut_teardown,
18715 : : test_dtls_1_2_record_proto_corrupt_pkt),
18716 : : TEST_CASE_NAMED_ST(
18717 : : "Custom content type",
18718 : : ut_setup_security, ut_teardown,
18719 : : test_dtls_1_2_record_proto_custom_content_type),
18720 : : TEST_CASE_NAMED_ST(
18721 : : "Zero len DTLS record with content type as app",
18722 : : ut_setup_security, ut_teardown,
18723 : : test_dtls_1_2_record_proto_zero_len),
18724 : : TEST_CASE_NAMED_ST(
18725 : : "Zero len DTLS record with content type as ctrl",
18726 : : ut_setup_security, ut_teardown,
18727 : : test_dtls_1_2_record_proto_zero_len_non_app),
18728 : : TEST_CASE_NAMED_ST(
18729 : : "Antireplay with window size 64",
18730 : : ut_setup_security, ut_teardown,
18731 : : test_dtls_1_2_record_proto_antireplay64),
18732 : : TEST_CASE_NAMED_ST(
18733 : : "Antireplay with window size 128",
18734 : : ut_setup_security, ut_teardown,
18735 : : test_dtls_1_2_record_proto_antireplay128),
18736 : : TEST_CASE_NAMED_ST(
18737 : : "Antireplay with window size 256",
18738 : : ut_setup_security, ut_teardown,
18739 : : test_dtls_1_2_record_proto_antireplay256),
18740 : : TEST_CASE_NAMED_ST(
18741 : : "Antireplay with window size 512",
18742 : : ut_setup_security, ut_teardown,
18743 : : test_dtls_1_2_record_proto_antireplay512),
18744 : : TEST_CASE_NAMED_ST(
18745 : : "Antireplay with window size 1024",
18746 : : ut_setup_security, ut_teardown,
18747 : : test_dtls_1_2_record_proto_antireplay1024),
18748 : : TEST_CASE_NAMED_ST(
18749 : : "Antireplay with window size 2048",
18750 : : ut_setup_security, ut_teardown,
18751 : : test_dtls_1_2_record_proto_antireplay2048),
18752 : : TEST_CASE_NAMED_ST(
18753 : : "Antireplay with window size 4096",
18754 : : ut_setup_security, ut_teardown,
18755 : : test_dtls_1_2_record_proto_antireplay4096),
18756 : : TEST_CASE_NAMED_ST(
18757 : : "DTLS record DM mode with optional padding < 2 blocks",
18758 : : ut_setup_security, ut_teardown,
18759 : : test_dtls_1_2_record_proto_dm_opt_padding),
18760 : : TEST_CASE_NAMED_ST(
18761 : : "DTLS record DM mode with optional padding > 2 blocks",
18762 : : ut_setup_security, ut_teardown,
18763 : : test_dtls_1_2_record_proto_dm_opt_padding_1),
18764 : : TEST_CASE_NAMED_ST(
18765 : : "DTLS record SG mode with optional padding < 2 blocks",
18766 : : ut_setup_security, ut_teardown,
18767 : : test_dtls_1_2_record_proto_sg_opt_padding),
18768 : : TEST_CASE_NAMED_ST(
18769 : : "DTLS record SG mode with optional padding > 2 blocks",
18770 : : ut_setup_security, ut_teardown,
18771 : : test_dtls_1_2_record_proto_sg_opt_padding_1),
18772 : : TEST_CASE_NAMED_ST(
18773 : : "DTLS record SG mode with optional padding > 2 blocks",
18774 : : ut_setup_security, ut_teardown,
18775 : : test_dtls_1_2_record_proto_sg_opt_padding_2),
18776 : : TEST_CASE_NAMED_ST(
18777 : : "DTLS record SG mode with optional padding > max range",
18778 : : ut_setup_security, ut_teardown,
18779 : : test_dtls_1_2_record_proto_sg_opt_padding_max),
18780 : : TEST_CASE_NAMED_ST(
18781 : : "DTLS record SG mode with padding corruption",
18782 : : ut_setup_security, ut_teardown,
18783 : : test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18784 : : TEST_CASES_END() /**< NULL terminate unit test array */
18785 : : }
18786 : : };
18787 : :
18788 : : static struct unit_test_suite tls13_record_proto_testsuite = {
18789 : : .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18790 : : .setup = tls_record_proto_testsuite_setup,
18791 : : .unit_test_cases = {
18792 : : TEST_CASE_NAMED_WITH_DATA(
18793 : : "Write record known vector AES-GCM-128",
18794 : : ut_setup_security, ut_teardown,
18795 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18796 : : TEST_CASE_NAMED_WITH_DATA(
18797 : : "Write record known vector AES-GCM-256",
18798 : : ut_setup_security, ut_teardown,
18799 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18800 : : TEST_CASE_NAMED_WITH_DATA(
18801 : : "Write record known vector CHACHA20-POLY1305",
18802 : : ut_setup_security, ut_teardown,
18803 : : test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18804 : :
18805 : : TEST_CASE_NAMED_WITH_DATA(
18806 : : "Read record known vector AES-GCM-128",
18807 : : ut_setup_security, ut_teardown,
18808 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18809 : : TEST_CASE_NAMED_WITH_DATA(
18810 : : "Read record known vector AES-GCM-256",
18811 : : ut_setup_security, ut_teardown,
18812 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18813 : : TEST_CASE_NAMED_WITH_DATA(
18814 : : "Read record known vector CHACHA20-POLY1305",
18815 : : ut_setup_security, ut_teardown,
18816 : : test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18817 : : TEST_CASE_NAMED_ST(
18818 : : "TLS-1.3 record header corruption",
18819 : : ut_setup_security, ut_teardown,
18820 : : test_tls_1_3_record_proto_corrupt_pkt),
18821 : : TEST_CASE_NAMED_ST(
18822 : : "TLS-1.3 record header with custom content type",
18823 : : ut_setup_security, ut_teardown,
18824 : : test_tls_1_3_record_proto_custom_content_type),
18825 : : TEST_CASE_NAMED_ST(
18826 : : "TLS-1.3 record with zero len and content type as app",
18827 : : ut_setup_security, ut_teardown,
18828 : : test_tls_1_3_record_proto_zero_len),
18829 : : TEST_CASE_NAMED_ST(
18830 : : "TLS-1.3 record with zero len and content type as ctrl",
18831 : : ut_setup_security, ut_teardown,
18832 : : test_tls_1_3_record_proto_zero_len_non_app),
18833 : : TEST_CASE_NAMED_ST(
18834 : : "TLS-1.3 record DM mode with optional padding",
18835 : : ut_setup_security, ut_teardown,
18836 : : test_tls_1_3_record_proto_dm_opt_padding),
18837 : : TEST_CASE_NAMED_ST(
18838 : : "TLS-1.3 record SG mode with optional padding - 1",
18839 : : ut_setup_security, ut_teardown,
18840 : : test_tls_1_3_record_proto_sg_opt_padding),
18841 : : TEST_CASE_NAMED_ST(
18842 : : "TLS-1.3 record SG mode with optional padding",
18843 : : ut_setup_security, ut_teardown,
18844 : : test_tls_1_3_record_proto_sg_opt_padding_1),
18845 : : TEST_CASE_NAMED_ST(
18846 : : "Combined test alg list",
18847 : : ut_setup_security, ut_teardown,
18848 : : test_tls_1_3_record_proto_display_list),
18849 : : TEST_CASE_NAMED_ST(
18850 : : "Data walkthrough combined test alg list",
18851 : : ut_setup_security, ut_teardown,
18852 : : test_tls_1_3_record_proto_data_walkthrough),
18853 : : TEST_CASE_NAMED_ST(
18854 : : "Multi-segmented mode",
18855 : : ut_setup_security, ut_teardown,
18856 : : test_tls_1_3_record_proto_sgl),
18857 : : TEST_CASE_NAMED_ST(
18858 : : "Multi-segmented mode data walkthrough",
18859 : : ut_setup_security, ut_teardown,
18860 : : test_tls_1_3_record_proto_sgl_data_walkthrough),
18861 : : TEST_CASE_NAMED_ST(
18862 : : "Multi-segmented mode out of place",
18863 : : ut_setup_security, ut_teardown,
18864 : : test_tls_1_3_record_proto_sgl_oop),
18865 : : TEST_CASES_END() /**< NULL terminate unit test array */
18866 : : }
18867 : : };
18868 : :
18869 : : #define ADD_UPLINK_TESTCASE(data) \
18870 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
18871 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
18872 : :
18873 : : #define ADD_DOWNLINK_TESTCASE(data) \
18874 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
18875 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
18876 : :
18877 : : static struct unit_test_suite docsis_proto_testsuite = {
18878 : : .suite_name = "DOCSIS Proto Unit Test Suite",
18879 : : .setup = docsis_proto_testsuite_setup,
18880 : : .unit_test_cases = {
18881 : : /* Uplink */
18882 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
18883 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
18884 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
18885 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
18886 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
18887 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
18888 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
18889 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
18890 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
18891 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
18892 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
18893 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
18894 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
18895 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
18896 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
18897 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
18898 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
18899 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
18900 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
18901 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
18902 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
18903 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
18904 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
18905 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
18906 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
18907 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
18908 : : /* Downlink */
18909 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18910 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18911 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18912 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18913 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18914 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18915 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18916 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18917 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18918 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18919 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18920 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18921 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18922 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18923 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18924 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18925 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18926 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18927 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18928 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18929 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18930 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18931 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18932 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18933 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18934 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18935 : : TEST_CASES_END() /**< NULL terminate unit test array */
18936 : : }
18937 : : };
18938 : : #endif
18939 : :
18940 : : static struct unit_test_suite cryptodev_gen_testsuite = {
18941 : : .suite_name = "Crypto General Unit Test Suite",
18942 : : .setup = crypto_gen_testsuite_setup,
18943 : : .unit_test_cases = {
18944 : : TEST_CASE_ST(ut_setup, ut_teardown,
18945 : : test_device_reconfigure),
18946 : : TEST_CASE_ST(ut_setup, ut_teardown,
18947 : : test_device_configure_invalid_dev_id),
18948 : : TEST_CASE_ST(ut_setup, ut_teardown,
18949 : : test_queue_pair_descriptor_setup),
18950 : : TEST_CASE_ST(ut_setup, ut_teardown,
18951 : : test_device_configure_invalid_queue_pair_ids),
18952 : : TEST_CASE_ST(ut_setup, ut_teardown,
18953 : : test_queue_pair_descriptor_count),
18954 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18955 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18956 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18957 : : TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
18958 : : test_cryptodev_verify_error_recover, &aes_test_data_4),
18959 : : TEST_CASES_END() /**< NULL terminate unit test array */
18960 : : }
18961 : : };
18962 : :
18963 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18964 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
18965 : : .setup = negative_hmac_sha1_testsuite_setup,
18966 : : .unit_test_cases = {
18967 : : /** Negative tests */
18968 : : TEST_CASE_ST(ut_setup, ut_teardown,
18969 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
18970 : : TEST_CASE_ST(ut_setup, ut_teardown,
18971 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18972 : : TEST_CASE_ST(ut_setup, ut_teardown,
18973 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18974 : : TEST_CASE_ST(ut_setup, ut_teardown,
18975 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18976 : :
18977 : : TEST_CASES_END() /**< NULL terminate unit test array */
18978 : : }
18979 : : };
18980 : :
18981 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
18982 : : .suite_name = "Multi Session Unit Test Suite",
18983 : : .setup = multi_session_testsuite_setup,
18984 : : .unit_test_cases = {
18985 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18986 : : TEST_CASE_ST(ut_setup, ut_teardown,
18987 : : test_multi_session_random_usage),
18988 : :
18989 : : TEST_CASES_END() /**< NULL terminate unit test array */
18990 : : }
18991 : : };
18992 : :
18993 : : static struct unit_test_suite cryptodev_null_testsuite = {
18994 : : .suite_name = "NULL Test Suite",
18995 : : .setup = null_testsuite_setup,
18996 : : .unit_test_cases = {
18997 : : TEST_CASE_ST(ut_setup, ut_teardown,
18998 : : test_null_invalid_operation),
18999 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
19000 : : TEST_CASES_END()
19001 : : }
19002 : : };
19003 : :
19004 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
19005 : : .suite_name = "AES CCM Authenticated Test Suite",
19006 : : .setup = aes_ccm_auth_testsuite_setup,
19007 : : .unit_test_cases = {
19008 : : /** AES CCM Authenticated Encryption 128 bits key*/
19009 : : TEST_CASE_ST(ut_setup, ut_teardown,
19010 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
19011 : : TEST_CASE_ST(ut_setup, ut_teardown,
19012 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
19013 : : TEST_CASE_ST(ut_setup, ut_teardown,
19014 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
19015 : : TEST_CASE_ST(ut_setup, ut_teardown,
19016 : : test_AES_CCM_authenticated_encryption_test_case_128_4),
19017 : :
19018 : : /** AES CCM Authenticated Decryption 128 bits key*/
19019 : : TEST_CASE_ST(ut_setup, ut_teardown,
19020 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
19021 : : TEST_CASE_ST(ut_setup, ut_teardown,
19022 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
19023 : : TEST_CASE_ST(ut_setup, ut_teardown,
19024 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
19025 : : TEST_CASE_ST(ut_setup, ut_teardown,
19026 : : test_AES_CCM_authenticated_decryption_test_case_128_4),
19027 : :
19028 : : /** AES CCM Authenticated Encryption 192 bits key */
19029 : : TEST_CASE_ST(ut_setup, ut_teardown,
19030 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
19031 : : TEST_CASE_ST(ut_setup, ut_teardown,
19032 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
19033 : : TEST_CASE_ST(ut_setup, ut_teardown,
19034 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
19035 : :
19036 : : /** AES CCM Authenticated Decryption 192 bits key*/
19037 : : TEST_CASE_ST(ut_setup, ut_teardown,
19038 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
19039 : : TEST_CASE_ST(ut_setup, ut_teardown,
19040 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
19041 : : TEST_CASE_ST(ut_setup, ut_teardown,
19042 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
19043 : :
19044 : : /** AES CCM Authenticated Encryption 256 bits key */
19045 : : TEST_CASE_ST(ut_setup, ut_teardown,
19046 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
19047 : : TEST_CASE_ST(ut_setup, ut_teardown,
19048 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
19049 : : TEST_CASE_ST(ut_setup, ut_teardown,
19050 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
19051 : :
19052 : : /** AES CCM Authenticated Decryption 256 bits key*/
19053 : : TEST_CASE_ST(ut_setup, ut_teardown,
19054 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
19055 : : TEST_CASE_ST(ut_setup, ut_teardown,
19056 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
19057 : : TEST_CASE_ST(ut_setup, ut_teardown,
19058 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
19059 : : TEST_CASES_END()
19060 : : }
19061 : : };
19062 : :
19063 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
19064 : : .suite_name = "AES GCM Authenticated Test Suite",
19065 : : .setup = aes_gcm_auth_testsuite_setup,
19066 : : .unit_test_cases = {
19067 : : /** AES GCM Authenticated Encryption */
19068 : : TEST_CASE_ST(ut_setup, ut_teardown,
19069 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
19070 : : TEST_CASE_ST(ut_setup, ut_teardown,
19071 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
19072 : : TEST_CASE_ST(ut_setup, ut_teardown,
19073 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
19074 : : TEST_CASE_ST(ut_setup, ut_teardown,
19075 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
19076 : : TEST_CASE_ST(ut_setup, ut_teardown,
19077 : : test_AES_GCM_authenticated_encryption_test_case_1),
19078 : : TEST_CASE_ST(ut_setup, ut_teardown,
19079 : : test_AES_GCM_authenticated_encryption_test_case_2),
19080 : : TEST_CASE_ST(ut_setup, ut_teardown,
19081 : : test_AES_GCM_authenticated_encryption_test_case_3),
19082 : : TEST_CASE_ST(ut_setup, ut_teardown,
19083 : : test_AES_GCM_authenticated_encryption_test_case_4),
19084 : : TEST_CASE_ST(ut_setup, ut_teardown,
19085 : : test_AES_GCM_authenticated_encryption_test_case_5),
19086 : : TEST_CASE_ST(ut_setup, ut_teardown,
19087 : : test_AES_GCM_authenticated_encryption_test_case_6),
19088 : : TEST_CASE_ST(ut_setup, ut_teardown,
19089 : : test_AES_GCM_authenticated_encryption_test_case_7),
19090 : : TEST_CASE_ST(ut_setup, ut_teardown,
19091 : : test_AES_GCM_authenticated_encryption_test_case_8),
19092 : : TEST_CASE_ST(ut_setup, ut_teardown,
19093 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
19094 : :
19095 : : /** AES GCM Authenticated Decryption */
19096 : : TEST_CASE_ST(ut_setup, ut_teardown,
19097 : : test_AES_GCM_authenticated_decryption_test_case_1),
19098 : : TEST_CASE_ST(ut_setup, ut_teardown,
19099 : : test_AES_GCM_authenticated_decryption_test_case_2),
19100 : : TEST_CASE_ST(ut_setup, ut_teardown,
19101 : : test_AES_GCM_authenticated_decryption_test_case_3),
19102 : : TEST_CASE_ST(ut_setup, ut_teardown,
19103 : : test_AES_GCM_authenticated_decryption_test_case_4),
19104 : : TEST_CASE_ST(ut_setup, ut_teardown,
19105 : : test_AES_GCM_authenticated_decryption_test_case_5),
19106 : : TEST_CASE_ST(ut_setup, ut_teardown,
19107 : : test_AES_GCM_authenticated_decryption_test_case_6),
19108 : : TEST_CASE_ST(ut_setup, ut_teardown,
19109 : : test_AES_GCM_authenticated_decryption_test_case_7),
19110 : : TEST_CASE_ST(ut_setup, ut_teardown,
19111 : : test_AES_GCM_authenticated_decryption_test_case_8),
19112 : : TEST_CASE_ST(ut_setup, ut_teardown,
19113 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
19114 : :
19115 : : /** AES GCM Authenticated Encryption 192 bits key */
19116 : : TEST_CASE_ST(ut_setup, ut_teardown,
19117 : : test_AES_GCM_auth_encryption_test_case_192_1),
19118 : : TEST_CASE_ST(ut_setup, ut_teardown,
19119 : : test_AES_GCM_auth_encryption_test_case_192_2),
19120 : : TEST_CASE_ST(ut_setup, ut_teardown,
19121 : : test_AES_GCM_auth_encryption_test_case_192_3),
19122 : : TEST_CASE_ST(ut_setup, ut_teardown,
19123 : : test_AES_GCM_auth_encryption_test_case_192_4),
19124 : : TEST_CASE_ST(ut_setup, ut_teardown,
19125 : : test_AES_GCM_auth_encryption_test_case_192_5),
19126 : : TEST_CASE_ST(ut_setup, ut_teardown,
19127 : : test_AES_GCM_auth_encryption_test_case_192_6),
19128 : : TEST_CASE_ST(ut_setup, ut_teardown,
19129 : : test_AES_GCM_auth_encryption_test_case_192_7),
19130 : :
19131 : : /** AES GCM Authenticated Decryption 192 bits key */
19132 : : TEST_CASE_ST(ut_setup, ut_teardown,
19133 : : test_AES_GCM_auth_decryption_test_case_192_1),
19134 : : TEST_CASE_ST(ut_setup, ut_teardown,
19135 : : test_AES_GCM_auth_decryption_test_case_192_2),
19136 : : TEST_CASE_ST(ut_setup, ut_teardown,
19137 : : test_AES_GCM_auth_decryption_test_case_192_3),
19138 : : TEST_CASE_ST(ut_setup, ut_teardown,
19139 : : test_AES_GCM_auth_decryption_test_case_192_4),
19140 : : TEST_CASE_ST(ut_setup, ut_teardown,
19141 : : test_AES_GCM_auth_decryption_test_case_192_5),
19142 : : TEST_CASE_ST(ut_setup, ut_teardown,
19143 : : test_AES_GCM_auth_decryption_test_case_192_6),
19144 : : TEST_CASE_ST(ut_setup, ut_teardown,
19145 : : test_AES_GCM_auth_decryption_test_case_192_7),
19146 : :
19147 : : /** AES GCM Authenticated Encryption 256 bits key */
19148 : : TEST_CASE_ST(ut_setup, ut_teardown,
19149 : : test_AES_GCM_auth_encryption_test_case_256_1),
19150 : : TEST_CASE_ST(ut_setup, ut_teardown,
19151 : : test_AES_GCM_auth_encryption_test_case_256_2),
19152 : : TEST_CASE_ST(ut_setup, ut_teardown,
19153 : : test_AES_GCM_auth_encryption_test_case_256_3),
19154 : : TEST_CASE_ST(ut_setup, ut_teardown,
19155 : : test_AES_GCM_auth_encryption_test_case_256_4),
19156 : : TEST_CASE_ST(ut_setup, ut_teardown,
19157 : : test_AES_GCM_auth_encryption_test_case_256_5),
19158 : : TEST_CASE_ST(ut_setup, ut_teardown,
19159 : : test_AES_GCM_auth_encryption_test_case_256_6),
19160 : : TEST_CASE_ST(ut_setup, ut_teardown,
19161 : : test_AES_GCM_auth_encryption_test_case_256_7),
19162 : : TEST_CASE_ST(ut_setup, ut_teardown,
19163 : : test_AES_GCM_auth_encryption_test_case_256_8),
19164 : :
19165 : : /** AES GCM Authenticated Decryption 256 bits key */
19166 : : TEST_CASE_ST(ut_setup, ut_teardown,
19167 : : test_AES_GCM_auth_decryption_test_case_256_1),
19168 : : TEST_CASE_ST(ut_setup, ut_teardown,
19169 : : test_AES_GCM_auth_decryption_test_case_256_2),
19170 : : TEST_CASE_ST(ut_setup, ut_teardown,
19171 : : test_AES_GCM_auth_decryption_test_case_256_3),
19172 : : TEST_CASE_ST(ut_setup, ut_teardown,
19173 : : test_AES_GCM_auth_decryption_test_case_256_4),
19174 : : TEST_CASE_ST(ut_setup, ut_teardown,
19175 : : test_AES_GCM_auth_decryption_test_case_256_5),
19176 : : TEST_CASE_ST(ut_setup, ut_teardown,
19177 : : test_AES_GCM_auth_decryption_test_case_256_6),
19178 : : TEST_CASE_ST(ut_setup, ut_teardown,
19179 : : test_AES_GCM_auth_decryption_test_case_256_7),
19180 : : TEST_CASE_ST(ut_setup, ut_teardown,
19181 : : test_AES_GCM_auth_decryption_test_case_256_8),
19182 : :
19183 : : /** AES GCM Authenticated Encryption big aad size */
19184 : : TEST_CASE_ST(ut_setup, ut_teardown,
19185 : : test_AES_GCM_auth_encryption_test_case_aad_1),
19186 : : TEST_CASE_ST(ut_setup, ut_teardown,
19187 : : test_AES_GCM_auth_encryption_test_case_aad_2),
19188 : :
19189 : : /** AES GCM Authenticated Decryption big aad size */
19190 : : TEST_CASE_ST(ut_setup, ut_teardown,
19191 : : test_AES_GCM_auth_decryption_test_case_aad_1),
19192 : : TEST_CASE_ST(ut_setup, ut_teardown,
19193 : : test_AES_GCM_auth_decryption_test_case_aad_2),
19194 : :
19195 : : /** Out of place tests */
19196 : : TEST_CASE_ST(ut_setup, ut_teardown,
19197 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
19198 : : TEST_CASE_ST(ut_setup, ut_teardown,
19199 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
19200 : :
19201 : : /** Session-less tests */
19202 : : TEST_CASE_ST(ut_setup, ut_teardown,
19203 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
19204 : : TEST_CASE_ST(ut_setup, ut_teardown,
19205 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
19206 : :
19207 : : /** AES GCM external mbuf tests */
19208 : : TEST_CASE_ST(ut_setup, ut_teardown,
19209 : : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
19210 : : TEST_CASE_ST(ut_setup, ut_teardown,
19211 : : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
19212 : :
19213 : : TEST_CASES_END()
19214 : : }
19215 : : };
19216 : :
19217 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
19218 : : .suite_name = "AES GMAC Authentication Test Suite",
19219 : : .setup = aes_gmac_auth_testsuite_setup,
19220 : : .unit_test_cases = {
19221 : : TEST_CASE_ST(ut_setup, ut_teardown,
19222 : : test_AES_GMAC_authentication_test_case_1),
19223 : : TEST_CASE_ST(ut_setup, ut_teardown,
19224 : : test_AES_GMAC_authentication_verify_test_case_1),
19225 : : TEST_CASE_ST(ut_setup, ut_teardown,
19226 : : test_AES_GMAC_authentication_test_case_2),
19227 : : TEST_CASE_ST(ut_setup, ut_teardown,
19228 : : test_AES_GMAC_authentication_verify_test_case_2),
19229 : : TEST_CASE_ST(ut_setup, ut_teardown,
19230 : : test_AES_GMAC_authentication_test_case_3),
19231 : : TEST_CASE_ST(ut_setup, ut_teardown,
19232 : : test_AES_GMAC_authentication_verify_test_case_3),
19233 : : TEST_CASE_ST(ut_setup, ut_teardown,
19234 : : test_AES_GMAC_authentication_test_case_4),
19235 : : TEST_CASE_ST(ut_setup, ut_teardown,
19236 : : test_AES_GMAC_authentication_verify_test_case_4),
19237 : : TEST_CASE_ST(ut_setup, ut_teardown,
19238 : : test_AES_GMAC_authentication_SGL_40B),
19239 : : TEST_CASE_ST(ut_setup, ut_teardown,
19240 : : test_AES_GMAC_authentication_SGL_80B),
19241 : : TEST_CASE_ST(ut_setup, ut_teardown,
19242 : : test_AES_GMAC_authentication_SGL_2048B),
19243 : : TEST_CASE_ST(ut_setup, ut_teardown,
19244 : : test_AES_GMAC_authentication_SGL_2047B),
19245 : :
19246 : : TEST_CASES_END()
19247 : : }
19248 : : };
19249 : :
19250 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
19251 : : .suite_name = "Chacha20-Poly1305 Test Suite",
19252 : : .setup = chacha20_poly1305_testsuite_setup,
19253 : : .unit_test_cases = {
19254 : : TEST_CASE_ST(ut_setup, ut_teardown,
19255 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
19256 : : TEST_CASE_ST(ut_setup, ut_teardown,
19257 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
19258 : : TEST_CASE_ST(ut_setup, ut_teardown,
19259 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
19260 : : TEST_CASES_END()
19261 : : }
19262 : : };
19263 : :
19264 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
19265 : : .suite_name = "SNOW 3G Test Suite",
19266 : : .setup = snow3g_testsuite_setup,
19267 : : .unit_test_cases = {
19268 : : /** SNOW 3G encrypt only (UEA2) */
19269 : : TEST_CASE_ST(ut_setup, ut_teardown,
19270 : : test_snow3g_encryption_test_case_1),
19271 : : TEST_CASE_ST(ut_setup, ut_teardown,
19272 : : test_snow3g_encryption_test_case_2),
19273 : : TEST_CASE_ST(ut_setup, ut_teardown,
19274 : : test_snow3g_encryption_test_case_3),
19275 : : TEST_CASE_ST(ut_setup, ut_teardown,
19276 : : test_snow3g_encryption_test_case_4),
19277 : : TEST_CASE_ST(ut_setup, ut_teardown,
19278 : : test_snow3g_encryption_test_case_5),
19279 : :
19280 : : TEST_CASE_ST(ut_setup, ut_teardown,
19281 : : test_snow3g_encryption_test_case_1_oop),
19282 : : TEST_CASE_ST(ut_setup, ut_teardown,
19283 : : test_snow3g_encryption_test_case_1_oop_sgl),
19284 : : TEST_CASE_ST(ut_setup, ut_teardown,
19285 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
19286 : : TEST_CASE_ST(ut_setup, ut_teardown,
19287 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
19288 : : TEST_CASE_ST(ut_setup, ut_teardown,
19289 : : test_snow3g_encryption_test_case_1_offset_oop),
19290 : : TEST_CASE_ST(ut_setup, ut_teardown,
19291 : : test_snow3g_decryption_test_case_1_oop),
19292 : :
19293 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
19294 : : TEST_CASE_ST(ut_setup, ut_teardown,
19295 : : test_snow3g_auth_cipher_test_case_1),
19296 : : TEST_CASE_ST(ut_setup, ut_teardown,
19297 : : test_snow3g_auth_cipher_test_case_2),
19298 : : TEST_CASE_ST(ut_setup, ut_teardown,
19299 : : test_snow3g_auth_cipher_test_case_2_oop),
19300 : : TEST_CASE_ST(ut_setup, ut_teardown,
19301 : : test_snow3g_auth_cipher_part_digest_enc),
19302 : : TEST_CASE_ST(ut_setup, ut_teardown,
19303 : : test_snow3g_auth_cipher_part_digest_enc_oop),
19304 : : TEST_CASE_ST(ut_setup, ut_teardown,
19305 : : test_snow3g_auth_cipher_test_case_3_sgl),
19306 : : TEST_CASE_ST(ut_setup, ut_teardown,
19307 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
19308 : : TEST_CASE_ST(ut_setup, ut_teardown,
19309 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
19310 : : TEST_CASE_ST(ut_setup, ut_teardown,
19311 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
19312 : : TEST_CASE_ST(ut_setup, ut_teardown,
19313 : : test_snow3g_auth_cipher_total_digest_enc_1),
19314 : : TEST_CASE_ST(ut_setup, ut_teardown,
19315 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
19316 : : TEST_CASE_ST(ut_setup, ut_teardown,
19317 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
19318 : : TEST_CASE_ST(ut_setup, ut_teardown,
19319 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
19320 : :
19321 : : /** SNOW 3G decrypt (UEA2), then verify auth */
19322 : : TEST_CASE_ST(ut_setup, ut_teardown,
19323 : : test_snow3g_auth_cipher_verify_test_case_1),
19324 : : TEST_CASE_ST(ut_setup, ut_teardown,
19325 : : test_snow3g_auth_cipher_verify_test_case_2),
19326 : : TEST_CASE_ST(ut_setup, ut_teardown,
19327 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
19328 : : TEST_CASE_ST(ut_setup, ut_teardown,
19329 : : test_snow3g_auth_cipher_verify_part_digest_enc),
19330 : : TEST_CASE_ST(ut_setup, ut_teardown,
19331 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
19332 : : TEST_CASE_ST(ut_setup, ut_teardown,
19333 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
19334 : : TEST_CASE_ST(ut_setup, ut_teardown,
19335 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
19336 : : TEST_CASE_ST(ut_setup, ut_teardown,
19337 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
19338 : : TEST_CASE_ST(ut_setup, ut_teardown,
19339 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
19340 : : TEST_CASE_ST(ut_setup, ut_teardown,
19341 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
19342 : : TEST_CASE_ST(ut_setup, ut_teardown,
19343 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
19344 : : TEST_CASE_ST(ut_setup, ut_teardown,
19345 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
19346 : : TEST_CASE_ST(ut_setup, ut_teardown,
19347 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
19348 : :
19349 : : /** SNOW 3G decrypt only (UEA2) */
19350 : : TEST_CASE_ST(ut_setup, ut_teardown,
19351 : : test_snow3g_decryption_test_case_1),
19352 : : TEST_CASE_ST(ut_setup, ut_teardown,
19353 : : test_snow3g_decryption_test_case_2),
19354 : : TEST_CASE_ST(ut_setup, ut_teardown,
19355 : : test_snow3g_decryption_test_case_3),
19356 : : TEST_CASE_ST(ut_setup, ut_teardown,
19357 : : test_snow3g_decryption_test_case_4),
19358 : : TEST_CASE_ST(ut_setup, ut_teardown,
19359 : : test_snow3g_decryption_test_case_5),
19360 : : TEST_CASE_ST(ut_setup, ut_teardown,
19361 : : test_snow3g_decryption_with_digest_test_case_1),
19362 : : TEST_CASE_ST(ut_setup, ut_teardown,
19363 : : test_snow3g_hash_generate_test_case_1),
19364 : : TEST_CASE_ST(ut_setup, ut_teardown,
19365 : : test_snow3g_hash_generate_test_case_2),
19366 : : TEST_CASE_ST(ut_setup, ut_teardown,
19367 : : test_snow3g_hash_generate_test_case_3),
19368 : :
19369 : : /* Tests with buffers which length is not byte-aligned */
19370 : : TEST_CASE_ST(ut_setup, ut_teardown,
19371 : : test_snow3g_hash_generate_test_case_4),
19372 : : TEST_CASE_ST(ut_setup, ut_teardown,
19373 : : test_snow3g_hash_generate_test_case_5),
19374 : : TEST_CASE_ST(ut_setup, ut_teardown,
19375 : : test_snow3g_hash_generate_test_case_6),
19376 : : TEST_CASE_ST(ut_setup, ut_teardown,
19377 : : test_snow3g_hash_verify_test_case_1),
19378 : : TEST_CASE_ST(ut_setup, ut_teardown,
19379 : : test_snow3g_hash_verify_test_case_2),
19380 : : TEST_CASE_ST(ut_setup, ut_teardown,
19381 : : test_snow3g_hash_verify_test_case_3),
19382 : :
19383 : : /* Tests with buffers which length is not byte-aligned */
19384 : : TEST_CASE_ST(ut_setup, ut_teardown,
19385 : : test_snow3g_hash_verify_test_case_4),
19386 : : TEST_CASE_ST(ut_setup, ut_teardown,
19387 : : test_snow3g_hash_verify_test_case_5),
19388 : : TEST_CASE_ST(ut_setup, ut_teardown,
19389 : : test_snow3g_hash_verify_test_case_6),
19390 : : TEST_CASE_ST(ut_setup, ut_teardown,
19391 : : test_snow3g_cipher_auth_test_case_1),
19392 : : TEST_CASE_ST(ut_setup, ut_teardown,
19393 : : test_snow3g_auth_cipher_with_digest_test_case_1),
19394 : : TEST_CASES_END()
19395 : : }
19396 : : };
19397 : :
19398 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
19399 : : .suite_name = "ZUC Test Suite",
19400 : : .setup = zuc_testsuite_setup,
19401 : : .unit_test_cases = {
19402 : : /** ZUC encrypt only (EEA3) */
19403 : : TEST_CASE_ST(ut_setup, ut_teardown,
19404 : : test_zuc_encryption_test_case_1),
19405 : : TEST_CASE_ST(ut_setup, ut_teardown,
19406 : : test_zuc_encryption_test_case_2),
19407 : : TEST_CASE_ST(ut_setup, ut_teardown,
19408 : : test_zuc_encryption_test_case_3),
19409 : : TEST_CASE_ST(ut_setup, ut_teardown,
19410 : : test_zuc_encryption_test_case_4),
19411 : : TEST_CASE_ST(ut_setup, ut_teardown,
19412 : : test_zuc_encryption_test_case_5),
19413 : : TEST_CASE_ST(ut_setup, ut_teardown,
19414 : : test_zuc_encryption_test_case_6_sgl),
19415 : :
19416 : : /** ZUC decrypt only (EEA3) */
19417 : : TEST_CASE_ST(ut_setup, ut_teardown,
19418 : : test_zuc_decryption_test_case_1),
19419 : : TEST_CASE_ST(ut_setup, ut_teardown,
19420 : : test_zuc_decryption_test_case_2),
19421 : : TEST_CASE_ST(ut_setup, ut_teardown,
19422 : : test_zuc_decryption_test_case_3),
19423 : : TEST_CASE_ST(ut_setup, ut_teardown,
19424 : : test_zuc_decryption_test_case_4),
19425 : : TEST_CASE_ST(ut_setup, ut_teardown,
19426 : : test_zuc_decryption_test_case_5),
19427 : : TEST_CASE_ST(ut_setup, ut_teardown,
19428 : : test_zuc_decryption_test_case_6_sgl),
19429 : :
19430 : : /** ZUC authenticate (EIA3) */
19431 : : TEST_CASE_ST(ut_setup, ut_teardown,
19432 : : test_zuc_hash_generate_test_case_1),
19433 : : TEST_CASE_ST(ut_setup, ut_teardown,
19434 : : test_zuc_hash_generate_test_case_2),
19435 : : TEST_CASE_ST(ut_setup, ut_teardown,
19436 : : test_zuc_hash_generate_test_case_3),
19437 : : TEST_CASE_ST(ut_setup, ut_teardown,
19438 : : test_zuc_hash_generate_test_case_4),
19439 : : TEST_CASE_ST(ut_setup, ut_teardown,
19440 : : test_zuc_hash_generate_test_case_5),
19441 : : TEST_CASE_ST(ut_setup, ut_teardown,
19442 : : test_zuc_hash_generate_test_case_6),
19443 : : TEST_CASE_ST(ut_setup, ut_teardown,
19444 : : test_zuc_hash_generate_test_case_7),
19445 : : TEST_CASE_ST(ut_setup, ut_teardown,
19446 : : test_zuc_hash_generate_test_case_8),
19447 : :
19448 : : /** ZUC verify (EIA3) */
19449 : : TEST_CASE_ST(ut_setup, ut_teardown,
19450 : : test_zuc_hash_verify_test_case_1),
19451 : : TEST_CASE_ST(ut_setup, ut_teardown,
19452 : : test_zuc_hash_verify_test_case_2),
19453 : : TEST_CASE_ST(ut_setup, ut_teardown,
19454 : : test_zuc_hash_verify_test_case_3),
19455 : : TEST_CASE_ST(ut_setup, ut_teardown,
19456 : : test_zuc_hash_verify_test_case_4),
19457 : : TEST_CASE_ST(ut_setup, ut_teardown,
19458 : : test_zuc_hash_verify_test_case_5),
19459 : : TEST_CASE_ST(ut_setup, ut_teardown,
19460 : : test_zuc_hash_verify_test_case_6),
19461 : : TEST_CASE_ST(ut_setup, ut_teardown,
19462 : : test_zuc_hash_verify_test_case_7),
19463 : : TEST_CASE_ST(ut_setup, ut_teardown,
19464 : : test_zuc_hash_verify_test_case_8),
19465 : :
19466 : : /** ZUC alg-chain (EEA3/EIA3) */
19467 : : TEST_CASE_ST(ut_setup, ut_teardown,
19468 : : test_zuc_cipher_auth_test_case_1),
19469 : : TEST_CASE_ST(ut_setup, ut_teardown,
19470 : : test_zuc_cipher_auth_test_case_2),
19471 : :
19472 : : /** ZUC generate auth, then encrypt (EEA3) */
19473 : : TEST_CASE_ST(ut_setup, ut_teardown,
19474 : : test_zuc_auth_cipher_test_case_1),
19475 : : TEST_CASE_ST(ut_setup, ut_teardown,
19476 : : test_zuc_auth_cipher_test_case_1_oop),
19477 : : TEST_CASE_ST(ut_setup, ut_teardown,
19478 : : test_zuc_auth_cipher_test_case_1_sgl),
19479 : : TEST_CASE_ST(ut_setup, ut_teardown,
19480 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
19481 : : TEST_CASE_ST(ut_setup, ut_teardown,
19482 : : test_zuc_auth_cipher_test_case_2),
19483 : : TEST_CASE_ST(ut_setup, ut_teardown,
19484 : : test_zuc_auth_cipher_test_case_2_oop),
19485 : :
19486 : : /** ZUC decrypt (EEA3), then verify auth */
19487 : : TEST_CASE_ST(ut_setup, ut_teardown,
19488 : : test_zuc_auth_cipher_verify_test_case_1),
19489 : : TEST_CASE_ST(ut_setup, ut_teardown,
19490 : : test_zuc_auth_cipher_verify_test_case_1_oop),
19491 : : TEST_CASE_ST(ut_setup, ut_teardown,
19492 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
19493 : : TEST_CASE_ST(ut_setup, ut_teardown,
19494 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
19495 : : TEST_CASE_ST(ut_setup, ut_teardown,
19496 : : test_zuc_auth_cipher_verify_test_case_2),
19497 : : TEST_CASE_ST(ut_setup, ut_teardown,
19498 : : test_zuc_auth_cipher_verify_test_case_2_oop),
19499 : :
19500 : : /** ZUC-256 encrypt only **/
19501 : : TEST_CASE_ST(ut_setup, ut_teardown,
19502 : : test_zuc256_encryption_test_case_1),
19503 : : TEST_CASE_ST(ut_setup, ut_teardown,
19504 : : test_zuc256_encryption_test_case_2),
19505 : :
19506 : : /** ZUC-256 decrypt only **/
19507 : : TEST_CASE_ST(ut_setup, ut_teardown,
19508 : : test_zuc256_decryption_test_case_1),
19509 : : TEST_CASE_ST(ut_setup, ut_teardown,
19510 : : test_zuc256_decryption_test_case_2),
19511 : :
19512 : : /** ZUC-256 authentication only **/
19513 : : TEST_CASE_ST(ut_setup, ut_teardown,
19514 : : test_zuc256_hash_generate_4b_tag_test_case_1),
19515 : : TEST_CASE_ST(ut_setup, ut_teardown,
19516 : : test_zuc256_hash_generate_4b_tag_test_case_2),
19517 : : TEST_CASE_ST(ut_setup, ut_teardown,
19518 : : test_zuc256_hash_generate_4b_tag_test_case_3),
19519 : : TEST_CASE_ST(ut_setup, ut_teardown,
19520 : : test_zuc256_hash_generate_8b_tag_test_case_1),
19521 : : TEST_CASE_ST(ut_setup, ut_teardown,
19522 : : test_zuc256_hash_generate_16b_tag_test_case_1),
19523 : :
19524 : : /** ZUC-256 authentication verify only **/
19525 : : TEST_CASE_ST(ut_setup, ut_teardown,
19526 : : test_zuc256_hash_verify_4b_tag_test_case_1),
19527 : : TEST_CASE_ST(ut_setup, ut_teardown,
19528 : : test_zuc256_hash_verify_4b_tag_test_case_2),
19529 : : TEST_CASE_ST(ut_setup, ut_teardown,
19530 : : test_zuc256_hash_verify_4b_tag_test_case_3),
19531 : : TEST_CASE_ST(ut_setup, ut_teardown,
19532 : : test_zuc256_hash_verify_8b_tag_test_case_1),
19533 : : TEST_CASE_ST(ut_setup, ut_teardown,
19534 : : test_zuc256_hash_verify_16b_tag_test_case_1),
19535 : :
19536 : : /** ZUC-256 encrypt and authenticate **/
19537 : : TEST_CASE_ST(ut_setup, ut_teardown,
19538 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
19539 : : TEST_CASE_ST(ut_setup, ut_teardown,
19540 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
19541 : : TEST_CASE_ST(ut_setup, ut_teardown,
19542 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
19543 : : TEST_CASE_ST(ut_setup, ut_teardown,
19544 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
19545 : :
19546 : : /** ZUC-256 generate auth, then encrypt */
19547 : : TEST_CASE_ST(ut_setup, ut_teardown,
19548 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
19549 : : TEST_CASE_ST(ut_setup, ut_teardown,
19550 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
19551 : : TEST_CASE_ST(ut_setup, ut_teardown,
19552 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
19553 : : TEST_CASE_ST(ut_setup, ut_teardown,
19554 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
19555 : :
19556 : : /** ZUC-256 decrypt, then verify auth */
19557 : : TEST_CASE_ST(ut_setup, ut_teardown,
19558 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19559 : : TEST_CASE_ST(ut_setup, ut_teardown,
19560 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19561 : : TEST_CASE_ST(ut_setup, ut_teardown,
19562 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19563 : : TEST_CASE_ST(ut_setup, ut_teardown,
19564 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19565 : :
19566 : : TEST_CASES_END()
19567 : : }
19568 : : };
19569 : :
19570 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
19571 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
19572 : : .setup = hmac_md5_auth_testsuite_setup,
19573 : : .unit_test_cases = {
19574 : : TEST_CASE_ST(ut_setup, ut_teardown,
19575 : : test_MD5_HMAC_generate_case_1),
19576 : : TEST_CASE_ST(ut_setup, ut_teardown,
19577 : : test_MD5_HMAC_verify_case_1),
19578 : : TEST_CASE_ST(ut_setup, ut_teardown,
19579 : : test_MD5_HMAC_generate_case_2),
19580 : : TEST_CASE_ST(ut_setup, ut_teardown,
19581 : : test_MD5_HMAC_verify_case_2),
19582 : : TEST_CASES_END()
19583 : : }
19584 : : };
19585 : :
19586 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
19587 : : .suite_name = "Kasumi Test Suite",
19588 : : .setup = kasumi_testsuite_setup,
19589 : : .unit_test_cases = {
19590 : : /** KASUMI hash only (UIA1) */
19591 : : TEST_CASE_ST(ut_setup, ut_teardown,
19592 : : test_kasumi_hash_generate_test_case_1),
19593 : : TEST_CASE_ST(ut_setup, ut_teardown,
19594 : : test_kasumi_hash_generate_test_case_2),
19595 : : TEST_CASE_ST(ut_setup, ut_teardown,
19596 : : test_kasumi_hash_generate_test_case_3),
19597 : : TEST_CASE_ST(ut_setup, ut_teardown,
19598 : : test_kasumi_hash_generate_test_case_4),
19599 : : TEST_CASE_ST(ut_setup, ut_teardown,
19600 : : test_kasumi_hash_generate_test_case_5),
19601 : : TEST_CASE_ST(ut_setup, ut_teardown,
19602 : : test_kasumi_hash_generate_test_case_6),
19603 : :
19604 : : TEST_CASE_ST(ut_setup, ut_teardown,
19605 : : test_kasumi_hash_verify_test_case_1),
19606 : : TEST_CASE_ST(ut_setup, ut_teardown,
19607 : : test_kasumi_hash_verify_test_case_2),
19608 : : TEST_CASE_ST(ut_setup, ut_teardown,
19609 : : test_kasumi_hash_verify_test_case_3),
19610 : : TEST_CASE_ST(ut_setup, ut_teardown,
19611 : : test_kasumi_hash_verify_test_case_4),
19612 : : TEST_CASE_ST(ut_setup, ut_teardown,
19613 : : test_kasumi_hash_verify_test_case_5),
19614 : :
19615 : : /** KASUMI encrypt only (UEA1) */
19616 : : TEST_CASE_ST(ut_setup, ut_teardown,
19617 : : test_kasumi_encryption_test_case_1),
19618 : : TEST_CASE_ST(ut_setup, ut_teardown,
19619 : : test_kasumi_encryption_test_case_1_sgl),
19620 : : TEST_CASE_ST(ut_setup, ut_teardown,
19621 : : test_kasumi_encryption_test_case_1_oop),
19622 : : TEST_CASE_ST(ut_setup, ut_teardown,
19623 : : test_kasumi_encryption_test_case_1_oop_sgl),
19624 : : TEST_CASE_ST(ut_setup, ut_teardown,
19625 : : test_kasumi_encryption_test_case_2),
19626 : : TEST_CASE_ST(ut_setup, ut_teardown,
19627 : : test_kasumi_encryption_test_case_3),
19628 : : TEST_CASE_ST(ut_setup, ut_teardown,
19629 : : test_kasumi_encryption_test_case_4),
19630 : : TEST_CASE_ST(ut_setup, ut_teardown,
19631 : : test_kasumi_encryption_test_case_5),
19632 : :
19633 : : /** KASUMI decrypt only (UEA1) */
19634 : : TEST_CASE_ST(ut_setup, ut_teardown,
19635 : : test_kasumi_decryption_test_case_1),
19636 : : TEST_CASE_ST(ut_setup, ut_teardown,
19637 : : test_kasumi_decryption_test_case_2),
19638 : : TEST_CASE_ST(ut_setup, ut_teardown,
19639 : : test_kasumi_decryption_test_case_3),
19640 : : TEST_CASE_ST(ut_setup, ut_teardown,
19641 : : test_kasumi_decryption_test_case_4),
19642 : : TEST_CASE_ST(ut_setup, ut_teardown,
19643 : : test_kasumi_decryption_test_case_5),
19644 : : TEST_CASE_ST(ut_setup, ut_teardown,
19645 : : test_kasumi_decryption_test_case_1_oop),
19646 : : TEST_CASE_ST(ut_setup, ut_teardown,
19647 : : test_kasumi_cipher_auth_test_case_1),
19648 : :
19649 : : /** KASUMI generate auth, then encrypt (F8) */
19650 : : TEST_CASE_ST(ut_setup, ut_teardown,
19651 : : test_kasumi_auth_cipher_test_case_1),
19652 : : TEST_CASE_ST(ut_setup, ut_teardown,
19653 : : test_kasumi_auth_cipher_test_case_2),
19654 : : TEST_CASE_ST(ut_setup, ut_teardown,
19655 : : test_kasumi_auth_cipher_test_case_2_oop),
19656 : : TEST_CASE_ST(ut_setup, ut_teardown,
19657 : : test_kasumi_auth_cipher_test_case_2_sgl),
19658 : : TEST_CASE_ST(ut_setup, ut_teardown,
19659 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
19660 : :
19661 : : /** KASUMI decrypt (F8), then verify auth */
19662 : : TEST_CASE_ST(ut_setup, ut_teardown,
19663 : : test_kasumi_auth_cipher_verify_test_case_1),
19664 : : TEST_CASE_ST(ut_setup, ut_teardown,
19665 : : test_kasumi_auth_cipher_verify_test_case_2),
19666 : : TEST_CASE_ST(ut_setup, ut_teardown,
19667 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
19668 : : TEST_CASE_ST(ut_setup, ut_teardown,
19669 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
19670 : : TEST_CASE_ST(ut_setup, ut_teardown,
19671 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19672 : :
19673 : : TEST_CASES_END()
19674 : : }
19675 : : };
19676 : :
19677 : : static struct unit_test_suite cryptodev_esn_testsuite = {
19678 : : .suite_name = "ESN Test Suite",
19679 : : .setup = esn_testsuite_setup,
19680 : : .unit_test_cases = {
19681 : : TEST_CASE_ST(ut_setup, ut_teardown,
19682 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19683 : : TEST_CASE_ST(ut_setup, ut_teardown,
19684 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19685 : : TEST_CASES_END()
19686 : : }
19687 : : };
19688 : :
19689 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
19690 : : .suite_name = "Negative AES GCM Test Suite",
19691 : : .setup = negative_aes_gcm_testsuite_setup,
19692 : : .unit_test_cases = {
19693 : : TEST_CASE_ST(ut_setup, ut_teardown,
19694 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
19695 : : TEST_CASE_ST(ut_setup, ut_teardown,
19696 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19697 : : TEST_CASE_ST(ut_setup, ut_teardown,
19698 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19699 : : TEST_CASE_ST(ut_setup, ut_teardown,
19700 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19701 : : TEST_CASE_ST(ut_setup, ut_teardown,
19702 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
19703 : : TEST_CASE_ST(ut_setup, ut_teardown,
19704 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
19705 : : TEST_CASE_ST(ut_setup, ut_teardown,
19706 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
19707 : : TEST_CASE_ST(ut_setup, ut_teardown,
19708 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19709 : : TEST_CASE_ST(ut_setup, ut_teardown,
19710 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19711 : : TEST_CASE_ST(ut_setup, ut_teardown,
19712 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19713 : : TEST_CASE_ST(ut_setup, ut_teardown,
19714 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
19715 : : TEST_CASE_ST(ut_setup, ut_teardown,
19716 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
19717 : :
19718 : : TEST_CASES_END()
19719 : : }
19720 : : };
19721 : :
19722 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
19723 : : .suite_name = "Negative AES GMAC Test Suite",
19724 : : .setup = negative_aes_gmac_testsuite_setup,
19725 : : .unit_test_cases = {
19726 : : TEST_CASE_ST(ut_setup, ut_teardown,
19727 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
19728 : : TEST_CASE_ST(ut_setup, ut_teardown,
19729 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
19730 : :
19731 : : TEST_CASES_END()
19732 : : }
19733 : : };
19734 : :
19735 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
19736 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19737 : : .setup = mixed_cipher_hash_testsuite_setup,
19738 : : .unit_test_cases = {
19739 : : /** AUTH AES CMAC + CIPHER AES CTR */
19740 : : TEST_CASE_ST(ut_setup, ut_teardown,
19741 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19742 : : TEST_CASE_ST(ut_setup, ut_teardown,
19743 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19744 : : TEST_CASE_ST(ut_setup, ut_teardown,
19745 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19746 : : TEST_CASE_ST(ut_setup, ut_teardown,
19747 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19748 : : TEST_CASE_ST(ut_setup, ut_teardown,
19749 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19750 : : TEST_CASE_ST(ut_setup, ut_teardown,
19751 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19752 : : TEST_CASE_ST(ut_setup, ut_teardown,
19753 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19754 : : TEST_CASE_ST(ut_setup, ut_teardown,
19755 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19756 : : TEST_CASE_ST(ut_setup, ut_teardown,
19757 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19758 : : TEST_CASE_ST(ut_setup, ut_teardown,
19759 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19760 : : TEST_CASE_ST(ut_setup, ut_teardown,
19761 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19762 : : TEST_CASE_ST(ut_setup, ut_teardown,
19763 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19764 : :
19765 : : /** AUTH ZUC + CIPHER SNOW3G */
19766 : : TEST_CASE_ST(ut_setup, ut_teardown,
19767 : : test_auth_zuc_cipher_snow_test_case_1),
19768 : : TEST_CASE_ST(ut_setup, ut_teardown,
19769 : : test_verify_auth_zuc_cipher_snow_test_case_1),
19770 : : TEST_CASE_ST(ut_setup, ut_teardown,
19771 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
19772 : : TEST_CASE_ST(ut_setup, ut_teardown,
19773 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19774 : : /** AUTH AES CMAC + CIPHER SNOW3G */
19775 : : TEST_CASE_ST(ut_setup, ut_teardown,
19776 : : test_auth_aes_cmac_cipher_snow_test_case_1),
19777 : : TEST_CASE_ST(ut_setup, ut_teardown,
19778 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19779 : : TEST_CASE_ST(ut_setup, ut_teardown,
19780 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19781 : : TEST_CASE_ST(ut_setup, ut_teardown,
19782 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19783 : : /** AUTH ZUC + CIPHER AES CTR */
19784 : : TEST_CASE_ST(ut_setup, ut_teardown,
19785 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
19786 : : TEST_CASE_ST(ut_setup, ut_teardown,
19787 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19788 : : TEST_CASE_ST(ut_setup, ut_teardown,
19789 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19790 : : TEST_CASE_ST(ut_setup, ut_teardown,
19791 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19792 : : /** AUTH SNOW3G + CIPHER AES CTR */
19793 : : TEST_CASE_ST(ut_setup, ut_teardown,
19794 : : test_auth_snow_cipher_aes_ctr_test_case_1),
19795 : : TEST_CASE_ST(ut_setup, ut_teardown,
19796 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19797 : : TEST_CASE_ST(ut_setup, ut_teardown,
19798 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19799 : : TEST_CASE_ST(ut_setup, ut_teardown,
19800 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19801 : : TEST_CASE_ST(ut_setup, ut_teardown,
19802 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19803 : : TEST_CASE_ST(ut_setup, ut_teardown,
19804 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19805 : : /** AUTH SNOW3G + CIPHER ZUC */
19806 : : TEST_CASE_ST(ut_setup, ut_teardown,
19807 : : test_auth_snow_cipher_zuc_test_case_1),
19808 : : TEST_CASE_ST(ut_setup, ut_teardown,
19809 : : test_verify_auth_snow_cipher_zuc_test_case_1),
19810 : : TEST_CASE_ST(ut_setup, ut_teardown,
19811 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
19812 : : TEST_CASE_ST(ut_setup, ut_teardown,
19813 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19814 : : /** AUTH AES CMAC + CIPHER ZUC */
19815 : : TEST_CASE_ST(ut_setup, ut_teardown,
19816 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
19817 : : TEST_CASE_ST(ut_setup, ut_teardown,
19818 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19819 : : TEST_CASE_ST(ut_setup, ut_teardown,
19820 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19821 : : TEST_CASE_ST(ut_setup, ut_teardown,
19822 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19823 : :
19824 : : /** AUTH NULL + CIPHER SNOW3G */
19825 : : TEST_CASE_ST(ut_setup, ut_teardown,
19826 : : test_auth_null_cipher_snow_test_case_1),
19827 : : TEST_CASE_ST(ut_setup, ut_teardown,
19828 : : test_verify_auth_null_cipher_snow_test_case_1),
19829 : : /** AUTH NULL + CIPHER ZUC */
19830 : : TEST_CASE_ST(ut_setup, ut_teardown,
19831 : : test_auth_null_cipher_zuc_test_case_1),
19832 : : TEST_CASE_ST(ut_setup, ut_teardown,
19833 : : test_verify_auth_null_cipher_zuc_test_case_1),
19834 : : /** AUTH SNOW3G + CIPHER NULL */
19835 : : TEST_CASE_ST(ut_setup, ut_teardown,
19836 : : test_auth_snow_cipher_null_test_case_1),
19837 : : TEST_CASE_ST(ut_setup, ut_teardown,
19838 : : test_verify_auth_snow_cipher_null_test_case_1),
19839 : : /** AUTH ZUC + CIPHER NULL */
19840 : : TEST_CASE_ST(ut_setup, ut_teardown,
19841 : : test_auth_zuc_cipher_null_test_case_1),
19842 : : TEST_CASE_ST(ut_setup, ut_teardown,
19843 : : test_verify_auth_zuc_cipher_null_test_case_1),
19844 : : /** AUTH NULL + CIPHER AES CTR */
19845 : : TEST_CASE_ST(ut_setup, ut_teardown,
19846 : : test_auth_null_cipher_aes_ctr_test_case_1),
19847 : : TEST_CASE_ST(ut_setup, ut_teardown,
19848 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
19849 : : /** AUTH AES CMAC + CIPHER NULL */
19850 : : TEST_CASE_ST(ut_setup, ut_teardown,
19851 : : test_auth_aes_cmac_cipher_null_test_case_1),
19852 : : TEST_CASE_ST(ut_setup, ut_teardown,
19853 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
19854 : : TEST_CASES_END()
19855 : : }
19856 : : };
19857 : :
19858 : : static struct unit_test_suite cryptodev_sm4_gcm_testsuite = {
19859 : : .suite_name = "SM4 GCM Test Suite",
19860 : : .setup = sm4_gcm_testsuite_setup,
19861 : : .unit_test_cases = {
19862 : : TEST_CASE_ST(ut_setup, ut_teardown,
19863 : : test_SM4_GCM_case_1),
19864 : : TEST_CASE_ST(ut_setup, ut_teardown,
19865 : : test_SM4_GCM_case_2),
19866 : : TEST_CASE_ST(ut_setup, ut_teardown,
19867 : : test_SM4_GCM_case_3),
19868 : : TEST_CASE_ST(ut_setup, ut_teardown,
19869 : : test_SM4_GCM_case_4),
19870 : : TEST_CASE_ST(ut_setup, ut_teardown,
19871 : : test_SM4_GCM_case_5),
19872 : : TEST_CASE_ST(ut_setup, ut_teardown,
19873 : : test_SM4_GCM_case_6),
19874 : : TEST_CASE_ST(ut_setup, ut_teardown,
19875 : : test_SM4_GCM_case_7),
19876 : : TEST_CASE_ST(ut_setup, ut_teardown,
19877 : : test_SM4_GCM_case_8),
19878 : : TEST_CASE_ST(ut_setup, ut_teardown,
19879 : : test_SM4_GCM_case_9),
19880 : : TEST_CASE_ST(ut_setup, ut_teardown,
19881 : : test_SM4_GCM_case_10),
19882 : : TEST_CASE_ST(ut_setup, ut_teardown,
19883 : : test_SM4_GCM_case_11),
19884 : : TEST_CASE_ST(ut_setup, ut_teardown,
19885 : : test_SM4_GCM_case_12),
19886 : : TEST_CASE_ST(ut_setup, ut_teardown,
19887 : : test_SM4_GCM_case_13),
19888 : : TEST_CASE_ST(ut_setup, ut_teardown,
19889 : : test_SM4_GCM_case_14),
19890 : : TEST_CASE_ST(ut_setup, ut_teardown,
19891 : : test_SM4_GCM_case_15),
19892 : : TEST_CASES_END()
19893 : : }
19894 : : };
19895 : :
19896 : : static int
19897 : 9 : nxan_testsuite_setup(enum rte_crypto_sym_xform_type xform_type)
19898 : : {
19899 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
19900 : 9 : uint8_t dev_id = ts_params->valid_devs[0];
19901 : : struct rte_cryptodev_info dev_info;
19902 : 9 : const enum rte_crypto_cipher_algorithm ciphers[] = {
19903 : : RTE_CRYPTO_CIPHER_SNOW5G_NEA4,
19904 : : RTE_CRYPTO_CIPHER_AES_NEA5,
19905 : : RTE_CRYPTO_CIPHER_ZUC_NEA6
19906 : : };
19907 : 9 : const enum rte_crypto_auth_algorithm auths[] = {
19908 : : RTE_CRYPTO_AUTH_SNOW5G_NIA4,
19909 : : RTE_CRYPTO_AUTH_AES_NIA5,
19910 : : RTE_CRYPTO_AUTH_ZUC_NIA6
19911 : : };
19912 : 9 : const enum rte_crypto_aead_algorithm aeads[] = {
19913 : : RTE_CRYPTO_AEAD_SNOW5G_NCA4,
19914 : : RTE_CRYPTO_AEAD_AES_NCA5,
19915 : : RTE_CRYPTO_AEAD_ZUC_NCA6
19916 : : };
19917 : :
19918 : 9 : rte_cryptodev_info_get(dev_id, &dev_info);
19919 : :
19920 [ + - ]: 9 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
19921 [ - + ]: 9 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
19922 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
19923 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NxA4/5/6 "
19924 : : "testsuite not met\n");
19925 : 0 : return TEST_SKIPPED;
19926 : : }
19927 : :
19928 [ + + - + ]: 12 : if ((xform_type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
19929 [ + + ]: 6 : check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) ||
19930 [ - + ]: 3 : (xform_type == RTE_CRYPTO_SYM_XFORM_AUTH &&
19931 [ + - ]: 3 : check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) ||
19932 [ + - ]: 3 : (xform_type == RTE_CRYPTO_SYM_XFORM_AEAD &&
19933 : : check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0)) {
19934 : 9 : RTE_LOG(INFO, USER1, "Capability requirements for NxA4/5/6 "
19935 : : "testsuite not met\n");
19936 : 9 : return TEST_SKIPPED;
19937 : : }
19938 : :
19939 : : return 0;
19940 : : }
19941 : :
19942 : : static int
19943 : 3 : nea_testsuite_setup(void)
19944 : : {
19945 : 3 : return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_CIPHER);
19946 : : }
19947 : :
19948 : : static int
19949 : 3 : nia_testsuite_setup(void)
19950 : : {
19951 : 3 : return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_AUTH);
19952 : : }
19953 : :
19954 : : static int
19955 : 3 : nca_testsuite_setup(void)
19956 : : {
19957 : 3 : return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_AEAD);
19958 : : }
19959 : :
19960 : : static int
19961 : 0 : test_NEA_helper(
19962 : : const struct nxa_256_test_data *tdata,
19963 : : enum rte_crypto_cipher_operation op)
19964 : : {
19965 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
19966 : : struct crypto_unittest_params *ut_params = &unittest_params;
19967 : :
19968 : : int retval;
19969 : : uint8_t *input, *output;
19970 : : uint32_t pad_len;
19971 : : uint32_t len;
19972 : : bool is_enc = (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT);
19973 : :
19974 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
19975 : : return TEST_SKIPPED;
19976 : :
19977 : : /* Create session */
19978 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
19979 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
19980 : 0 : tdata->cipher_algo, tdata->key, 32, 16);
19981 [ # # ]: 0 : if (retval != 0)
19982 : : return retval;
19983 : :
19984 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
19985 : :
19986 : : /* Clear mbuf payload */
19987 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
19988 : : rte_pktmbuf_tailroom(ut_params->ibuf));
19989 : :
19990 [ # # ]: 0 : len = ceil_byte_length(tdata->msg_size);
19991 : : /* Append data which is padded to a multiple */
19992 : : /* of the algorithms block size */
19993 : 0 : pad_len = RTE_ALIGN_CEIL(len, 8);
19994 : 0 : input = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
19995 : : pad_len);
19996 [ # # ]: 0 : memcpy(input, is_enc ? tdata->plaintext : tdata->ciphertext, len);
19997 : 0 : debug_hexdump(stdout, "input:", input, len);
19998 : :
19999 : : /* Create operation */
20000 : 0 : retval = create_wireless_algo_cipher_operation(tdata->iv,
20001 : 0 : 16, RTE_ALIGN_CEIL(tdata->msg_size, 8), 0);
20002 [ # # ]: 0 : if (retval != 0)
20003 : : return retval;
20004 : :
20005 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
20006 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
20007 : : 16);
20008 [ # # ]: 0 : if (retval != TEST_SUCCESS)
20009 : : return retval;
20010 : : } else
20011 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
20012 : : ut_params->op);
20013 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
20014 : :
20015 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
20016 [ # # ]: 0 : if (ut_params->obuf)
20017 : 0 : output = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
20018 : : else
20019 : : output = input;
20020 : :
20021 : 0 : debug_hexdump(stdout, "output:", output, len);
20022 : : const uint8_t *reference_output =
20023 [ # # ]: 0 : is_enc ? tdata->ciphertext : tdata->plaintext;
20024 : : /* Validate obuf */
20025 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
20026 : : output,
20027 : : reference_output,
20028 : : tdata->msg_size,
20029 : : "Output data not as expected");
20030 : : return 0;
20031 : : }
20032 : :
20033 : : static int
20034 : 0 : test_NIA_helper(const void *td)
20035 : : {
20036 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
20037 : : struct crypto_unittest_params *ut_params = &unittest_params;
20038 : : const struct nxa_256_test_data *tdata = td;
20039 : :
20040 : : int retval;
20041 : : uint32_t plaintext_pad_len;
20042 : : uint32_t plaintext_len;
20043 : : uint8_t *plaintext;
20044 : :
20045 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
20046 : : return TEST_SKIPPED;
20047 : :
20048 : : /* Create auth session */
20049 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
20050 : 0 : tdata->key, 32,
20051 : 0 : 16, tdata->tag_size >> 3,
20052 : : RTE_CRYPTO_AUTH_OP_VERIFY,
20053 : 0 : tdata->auth_algo);
20054 [ # # ]: 0 : if (retval != 0)
20055 : : return retval;
20056 : : /* alloc mbuf and set payload */
20057 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
20058 : :
20059 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
20060 : : rte_pktmbuf_tailroom(ut_params->ibuf));
20061 : :
20062 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->msg_size);
20063 : : /* Append data which is padded to a multiple */
20064 : : /* of the algorithms block size */
20065 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
20066 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
20067 : : plaintext_pad_len);
20068 : 0 : memcpy(plaintext, tdata->plaintext, plaintext_len);
20069 : :
20070 : : /* Create auth operation */
20071 : 0 : retval = create_wireless_algo_hash_operation(tdata->tag,
20072 : 0 : tdata->tag_size >> 3,
20073 : 0 : tdata->iv, 16,
20074 : : plaintext_pad_len,
20075 : : RTE_CRYPTO_AUTH_OP_VERIFY,
20076 : 0 : tdata->msg_size,
20077 : : 0);
20078 [ # # ]: 0 : if (retval != 0)
20079 : : return retval;
20080 : :
20081 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
20082 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
20083 : : 0);
20084 [ # # ]: 0 : if (retval != TEST_SUCCESS)
20085 : : return retval;
20086 : : } else
20087 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
20088 : : ut_params->op);
20089 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Crypto request failed");
20090 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
20091 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
20092 : : uint8_t *,
20093 : : plaintext_pad_len);
20094 : :
20095 : : /* Validate obuf */
20096 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
20097 : : return 0;
20098 : : else
20099 : 0 : return -1;
20100 : :
20101 : : return 0;
20102 : : }
20103 : :
20104 : : static int
20105 : 0 : test_NCA_helper(
20106 : : const struct nxa_256_test_data *tdata,
20107 : : enum rte_crypto_cipher_operation op)
20108 : : {
20109 : 0 : struct aead_test_data aead_tdata = {
20110 : 0 : .algo = tdata->aead_algo,
20111 : : .key = {
20112 : : .len = 32,
20113 : : },
20114 : : .iv = {
20115 : : .len = 16,
20116 : : },
20117 : : .aad = {
20118 : 0 : .data = (uint8_t *)(uintptr_t)tdata->aad,
20119 : 0 : .len = tdata->aad_size >> 3,
20120 : : },
20121 : : .plaintext = {
20122 : 0 : .len = tdata->msg_size >> 3,
20123 : : },
20124 : : .ciphertext = {
20125 : : .len = tdata->msg_size >> 3,
20126 : : },
20127 : : .auth_tag = {
20128 : 0 : .len = tdata->tag_size >> 3,
20129 : : },
20130 : : };
20131 : :
20132 [ # # ]: 0 : memcpy(aead_tdata.key.data, tdata->key, 32);
20133 : : memcpy(aead_tdata.iv.data, tdata->iv, 16);
20134 : 0 : memcpy(aead_tdata.plaintext.data, tdata->plaintext,
20135 : : tdata->msg_size >> 3);
20136 : 0 : memcpy(aead_tdata.ciphertext.data, tdata->ciphertext,
20137 : : tdata->msg_size >> 3);
20138 : 0 : memcpy(aead_tdata.auth_tag.data, tdata->tag,
20139 : : tdata->tag_size >> 3);
20140 : :
20141 [ # # ]: 0 : if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
20142 : 0 : return test_authenticated_encryption_helper(&aead_tdata, false);
20143 : : else
20144 : 0 : return test_authenticated_decryption_helper(&aead_tdata, false);
20145 : : }
20146 : :
20147 : :
20148 : 0 : static int test_case_NEA_encrypt(const void *tdata)
20149 : : {
20150 : 0 : return test_NEA_helper(tdata, RTE_CRYPTO_CIPHER_OP_ENCRYPT);
20151 : : }
20152 : :
20153 : 0 : static int test_case_NEA_decrypt(const void *tdata)
20154 : : {
20155 : 0 : return test_NEA_helper(tdata, RTE_CRYPTO_CIPHER_OP_DECRYPT);
20156 : : }
20157 : :
20158 : : static struct unit_test_suite cryptodev_256_NEA4_testsuite = {
20159 : : .suite_name = "256 NEA4 (SNOW 5G) Test Suite",
20160 : : .setup = nea_testsuite_setup,
20161 : : .unit_test_cases = {
20162 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20163 : : test_case_NEA_encrypt, &nea4_test_1),
20164 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20165 : : test_case_NEA_decrypt, &nea4_test_1),
20166 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20167 : : test_case_NEA_encrypt, &nea4_test_2),
20168 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20169 : : test_case_NEA_decrypt, &nea4_test_2),
20170 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20171 : : test_case_NEA_encrypt, &nea4_test_3),
20172 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20173 : : test_case_NEA_decrypt, &nea4_test_3),
20174 : :
20175 : : TEST_CASES_END()
20176 : : }
20177 : : };
20178 : :
20179 : : static struct unit_test_suite cryptodev_256_NEA5_testsuite = {
20180 : : .suite_name = "256 NEA5 (AES 256) Test Suite",
20181 : : .setup = nea_testsuite_setup,
20182 : : .unit_test_cases = {
20183 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20184 : : test_case_NEA_encrypt, &nea5_test_1),
20185 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20186 : : test_case_NEA_decrypt, &nea5_test_1),
20187 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20188 : : test_case_NEA_encrypt, &nea5_test_2),
20189 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20190 : : test_case_NEA_decrypt, &nea5_test_2),
20191 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20192 : : test_case_NEA_encrypt, &nea5_test_3),
20193 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20194 : : test_case_NEA_decrypt, &nea5_test_3),
20195 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20196 : : test_case_NEA_encrypt, &nea5_test_4),
20197 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20198 : : test_case_NEA_decrypt, &nea5_test_4),
20199 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20200 : : test_case_NEA_encrypt, &nea5_test_5),
20201 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20202 : : test_case_NEA_decrypt, &nea5_test_5),
20203 : :
20204 : : TEST_CASES_END()
20205 : : }
20206 : : };
20207 : :
20208 : : static struct unit_test_suite cryptodev_256_NEA6_testsuite = {
20209 : : .suite_name = "256 NEA6 (ZUC 256) Test Suite",
20210 : : .setup = nea_testsuite_setup,
20211 : : .unit_test_cases = {
20212 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20213 : : test_case_NEA_encrypt, &nea6_test_1),
20214 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20215 : : test_case_NEA_decrypt, &nea6_test_1),
20216 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20217 : : test_case_NEA_encrypt, &nea6_test_2),
20218 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20219 : : test_case_NEA_decrypt, &nea6_test_2),
20220 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20221 : : test_case_NEA_encrypt, &nea6_test_3),
20222 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20223 : : test_case_NEA_decrypt, &nea6_test_3),
20224 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20225 : : test_case_NEA_encrypt, &nea6_test_4),
20226 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20227 : : test_case_NEA_decrypt, &nea6_test_4),
20228 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20229 : : test_case_NEA_encrypt, &nea6_test_5),
20230 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20231 : : test_case_NEA_decrypt, &nea6_test_5),
20232 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20233 : : test_case_NEA_encrypt, &nea6_test_6),
20234 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20235 : : test_case_NEA_decrypt, &nea6_test_6),
20236 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20237 : : test_case_NEA_encrypt, &nea6_test_7),
20238 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20239 : : test_case_NEA_decrypt, &nea6_test_7),
20240 : :
20241 : : TEST_CASES_END()
20242 : : }
20243 : : };
20244 : :
20245 : :
20246 : : static struct unit_test_suite cryptodev_256_NIA4_testsuite = {
20247 : : .suite_name = "256 NIA4 (SNOW 5G) Test Suite",
20248 : : .setup = nia_testsuite_setup,
20249 : : .unit_test_cases = {
20250 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20251 : : test_NIA_helper, &nia4_test_1),
20252 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20253 : : test_NIA_helper, &nia4_test_2),
20254 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20255 : : test_NIA_helper, &nia4_test_3),
20256 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20257 : : test_NIA_helper, &nia4_test_4),
20258 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20259 : : test_NIA_helper, &nia4_test_5),
20260 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20261 : : test_NIA_helper, &nia4_test_6),
20262 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20263 : : test_NIA_helper, &nia4_test_7),
20264 : :
20265 : : TEST_CASES_END()
20266 : : }
20267 : : };
20268 : :
20269 : : static struct unit_test_suite cryptodev_256_NIA5_testsuite = {
20270 : : .suite_name = "256 NIA5 (AES 256) Test Suite",
20271 : : .setup = nia_testsuite_setup,
20272 : : .unit_test_cases = {
20273 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20274 : : test_NIA_helper, &nia5_test_1),
20275 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20276 : : test_NIA_helper, &nia5_test_2),
20277 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20278 : : test_NIA_helper, &nia5_test_3),
20279 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20280 : : test_NIA_helper, &nia5_test_4),
20281 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20282 : : test_NIA_helper, &nia5_test_5),
20283 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20284 : : test_NIA_helper, &nia5_test_6),
20285 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20286 : : test_NIA_helper, &nia5_test_7),
20287 : :
20288 : : TEST_CASES_END()
20289 : : }
20290 : : };
20291 : :
20292 : : static struct unit_test_suite cryptodev_256_NIA6_testsuite = {
20293 : : .suite_name = "256 NIA6 (ZUC 256) Test Suite",
20294 : : .setup = nia_testsuite_setup,
20295 : : .unit_test_cases = {
20296 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20297 : : test_NIA_helper, &nia6_test_1),
20298 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20299 : : test_NIA_helper, &nia6_test_2),
20300 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20301 : : test_NIA_helper, &nia6_test_3),
20302 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20303 : : test_NIA_helper, &nia6_test_4),
20304 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20305 : : test_NIA_helper, &nia6_test_5),
20306 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20307 : : test_NIA_helper, &nia6_test_6),
20308 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20309 : : test_NIA_helper, &nia6_test_7),
20310 : :
20311 : : TEST_CASES_END()
20312 : : }
20313 : : };
20314 : :
20315 : :
20316 : 0 : static int test_case_NCA_encrypt(const void *tdata)
20317 : : {
20318 : 0 : return test_NCA_helper(tdata, RTE_CRYPTO_CIPHER_OP_ENCRYPT);
20319 : : }
20320 : :
20321 : 0 : static int test_case_NCA_decrypt(const void *tdata)
20322 : : {
20323 : 0 : return test_NCA_helper(tdata, RTE_CRYPTO_CIPHER_OP_DECRYPT);
20324 : : }
20325 : :
20326 : : static struct unit_test_suite cryptodev_256_NCA4_testsuite = {
20327 : : .suite_name = "256 NCA4 (SNOW 5G) Test Suite",
20328 : : .setup = nca_testsuite_setup,
20329 : : .unit_test_cases = {
20330 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20331 : : test_case_NCA_encrypt, &nca4_test_1),
20332 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20333 : : test_case_NCA_decrypt, &nca4_test_1),
20334 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20335 : : test_case_NCA_encrypt, &nca4_test_2),
20336 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20337 : : test_case_NCA_decrypt, &nca4_test_2),
20338 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20339 : : test_case_NCA_encrypt, &nca4_test_3),
20340 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20341 : : test_case_NCA_decrypt, &nca4_test_3),
20342 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20343 : : test_case_NCA_encrypt, &nca4_test_4),
20344 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20345 : : test_case_NCA_decrypt, &nca4_test_4),
20346 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20347 : : test_case_NCA_encrypt, &nca4_test_5),
20348 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20349 : : test_case_NCA_decrypt, &nca4_test_5),
20350 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20351 : : test_case_NCA_encrypt, &nca4_test_6),
20352 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20353 : : test_case_NCA_decrypt, &nca4_test_6),
20354 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20355 : : test_case_NCA_encrypt, &nca4_test_7),
20356 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20357 : : test_case_NCA_decrypt, &nca4_test_7),
20358 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20359 : : test_case_NCA_encrypt, &nca4_test_8),
20360 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20361 : : test_case_NCA_decrypt, &nca4_test_8),
20362 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20363 : : test_case_NCA_encrypt, &nca4_test_9),
20364 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20365 : : test_case_NCA_decrypt, &nca4_test_9),
20366 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20367 : : test_case_NCA_encrypt, &nca4_test_10),
20368 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20369 : : test_case_NCA_decrypt, &nca4_test_10),
20370 : :
20371 : : TEST_CASES_END()
20372 : : }
20373 : : };
20374 : :
20375 : : static struct unit_test_suite cryptodev_256_NCA5_testsuite = {
20376 : : .suite_name = "256 NCA5 (AES 256) Test Suite",
20377 : : .setup = nca_testsuite_setup,
20378 : : .unit_test_cases = {
20379 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20380 : : test_case_NCA_encrypt, &nca5_test_1),
20381 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20382 : : test_case_NCA_decrypt, &nca5_test_1),
20383 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20384 : : test_case_NCA_encrypt, &nca5_test_2),
20385 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20386 : : test_case_NCA_decrypt, &nca5_test_2),
20387 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20388 : : test_case_NCA_encrypt, &nca5_test_3),
20389 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20390 : : test_case_NCA_decrypt, &nca5_test_3),
20391 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20392 : : test_case_NCA_encrypt, &nca5_test_4),
20393 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20394 : : test_case_NCA_decrypt, &nca5_test_4),
20395 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20396 : : test_case_NCA_encrypt, &nca5_test_5),
20397 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20398 : : test_case_NCA_decrypt, &nca5_test_5),
20399 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20400 : : test_case_NCA_encrypt, &nca5_test_6),
20401 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20402 : : test_case_NCA_decrypt, &nca5_test_6),
20403 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20404 : : test_case_NCA_encrypt, &nca5_test_7),
20405 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20406 : : test_case_NCA_decrypt, &nca5_test_7),
20407 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20408 : : test_case_NCA_encrypt, &nca5_test_8),
20409 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20410 : : test_case_NCA_decrypt, &nca5_test_8),
20411 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20412 : : test_case_NCA_encrypt, &nca5_test_9),
20413 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20414 : : test_case_NCA_decrypt, &nca5_test_9),
20415 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20416 : : test_case_NCA_encrypt, &nca5_test_10),
20417 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20418 : : test_case_NCA_decrypt, &nca5_test_10),
20419 : :
20420 : : TEST_CASES_END()
20421 : : }
20422 : : };
20423 : :
20424 : : static struct unit_test_suite cryptodev_256_NCA6_testsuite = {
20425 : : .suite_name = "256 NCA6 (ZUC 256) Test Suite",
20426 : : .setup = nca_testsuite_setup,
20427 : : .unit_test_cases = {
20428 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20429 : : test_case_NCA_encrypt, &nca6_test_1),
20430 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20431 : : test_case_NCA_decrypt, &nca6_test_1),
20432 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20433 : : test_case_NCA_encrypt, &nca6_test_2),
20434 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20435 : : test_case_NCA_decrypt, &nca6_test_2),
20436 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20437 : : test_case_NCA_encrypt, &nca6_test_3),
20438 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20439 : : test_case_NCA_decrypt, &nca6_test_3),
20440 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20441 : : test_case_NCA_encrypt, &nca6_test_4),
20442 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20443 : : test_case_NCA_decrypt, &nca6_test_4),
20444 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20445 : : test_case_NCA_encrypt, &nca6_test_5),
20446 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20447 : : test_case_NCA_decrypt, &nca6_test_5),
20448 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20449 : : test_case_NCA_encrypt, &nca6_test_6),
20450 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20451 : : test_case_NCA_decrypt, &nca6_test_6),
20452 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20453 : : test_case_NCA_encrypt, &nca6_test_7),
20454 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20455 : : test_case_NCA_decrypt, &nca6_test_7),
20456 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20457 : : test_case_NCA_encrypt, &nca6_test_8),
20458 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20459 : : test_case_NCA_decrypt, &nca6_test_8),
20460 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20461 : : test_case_NCA_encrypt, &nca6_test_9),
20462 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20463 : : test_case_NCA_decrypt, &nca6_test_9),
20464 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20465 : : test_case_NCA_encrypt, &nca6_test_10),
20466 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20467 : : test_case_NCA_decrypt, &nca6_test_10),
20468 : :
20469 : : TEST_CASES_END()
20470 : : }
20471 : : };
20472 : :
20473 : : static int
20474 : 1 : run_cryptodev_testsuite(const char *pmd_name)
20475 : : {
20476 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
20477 : 1 : const enum blockcipher_test_type blk_suites[] = {
20478 : : BLKCIPHER_AES_CHAIN_TYPE,
20479 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
20480 : : BLKCIPHER_AES_DOCSIS_TYPE,
20481 : : BLKCIPHER_3DES_CHAIN_TYPE,
20482 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
20483 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
20484 : : BLKCIPHER_DES_DOCSIS_TYPE,
20485 : : BLKCIPHER_SM4_CHAIN_TYPE,
20486 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
20487 : : BLKCIPHER_AUTHONLY_TYPE};
20488 : 1 : struct unit_test_suite *static_suites[] = {
20489 : : &cryptodev_multi_session_testsuite,
20490 : : &cryptodev_null_testsuite,
20491 : : &cryptodev_aes_ccm_auth_testsuite,
20492 : : &cryptodev_aes_gcm_auth_testsuite,
20493 : : &cryptodev_aes_gmac_auth_testsuite,
20494 : : &cryptodev_snow3g_testsuite,
20495 : : &cryptodev_chacha20_poly1305_testsuite,
20496 : : &cryptodev_zuc_testsuite,
20497 : : &cryptodev_hmac_md5_auth_testsuite,
20498 : : &cryptodev_kasumi_testsuite,
20499 : : &cryptodev_esn_testsuite,
20500 : : &cryptodev_negative_aes_gcm_testsuite,
20501 : : &cryptodev_negative_aes_gmac_testsuite,
20502 : : &cryptodev_mixed_cipher_hash_testsuite,
20503 : : &cryptodev_negative_hmac_sha1_testsuite,
20504 : : &cryptodev_gen_testsuite,
20505 : : &cryptodev_sm4_gcm_testsuite,
20506 : : &cryptodev_256_NEA4_testsuite,
20507 : : &cryptodev_256_NEA5_testsuite,
20508 : : &cryptodev_256_NEA6_testsuite,
20509 : : &cryptodev_256_NIA4_testsuite,
20510 : : &cryptodev_256_NIA5_testsuite,
20511 : : &cryptodev_256_NIA6_testsuite,
20512 : : &cryptodev_256_NCA4_testsuite,
20513 : : &cryptodev_256_NCA5_testsuite,
20514 : : &cryptodev_256_NCA6_testsuite,
20515 : : #ifdef RTE_LIB_SECURITY
20516 : : &ipsec_proto_testsuite,
20517 : : &pdcp_proto_testsuite,
20518 : : &docsis_proto_testsuite,
20519 : : &tls12_record_proto_testsuite,
20520 : : &dtls12_record_proto_testsuite,
20521 : : &tls13_record_proto_testsuite,
20522 : : #endif
20523 : : &end_testsuite
20524 : : };
20525 : : static struct unit_test_suite ts = {
20526 : : .suite_name = "Cryptodev Unit Test Suite",
20527 : : .setup = testsuite_setup,
20528 : : .teardown = testsuite_teardown,
20529 : : .unit_test_cases = {TEST_CASES_END()}
20530 : : };
20531 : :
20532 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
20533 : :
20534 [ - + ]: 1 : if (gbl_driver_id == -1) {
20535 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
20536 : 0 : return TEST_SKIPPED;
20537 : : }
20538 : :
20539 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
20540 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
20541 : :
20542 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
20543 [ + + ]: 34 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
20544 : 1 : ret = unit_test_suite_runner(&ts);
20545 : :
20546 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
20547 : 1 : free(ts.unit_test_suites);
20548 : 1 : return ret;
20549 : : }
20550 : :
20551 : : static int
20552 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
20553 : : {
20554 : : struct rte_cryptodev_info dev_info;
20555 : : uint8_t i, nb_devs;
20556 : : int driver_id;
20557 : :
20558 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
20559 [ # # ]: 0 : if (driver_id == -1) {
20560 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
20561 : 0 : return TEST_SKIPPED;
20562 : : }
20563 : :
20564 : 0 : nb_devs = rte_cryptodev_count();
20565 [ # # ]: 0 : if (nb_devs < 1) {
20566 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
20567 : 0 : return TEST_SKIPPED;
20568 : : }
20569 : :
20570 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
20571 : 0 : rte_cryptodev_info_get(i, &dev_info);
20572 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
20573 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
20574 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
20575 : : flag_name);
20576 : 0 : return TEST_SKIPPED;
20577 : : }
20578 : : return 0; /* found */
20579 : : }
20580 : : }
20581 : :
20582 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
20583 : 0 : return TEST_SKIPPED;
20584 : : }
20585 : :
20586 : : static int
20587 : 0 : test_cryptodev_qat(void)
20588 : : {
20589 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20590 : : }
20591 : :
20592 : : static int
20593 : 0 : test_cryptodev_uadk(void)
20594 : : {
20595 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
20596 : : }
20597 : :
20598 : : static int
20599 : 0 : test_cryptodev_virtio(void)
20600 : : {
20601 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
20602 : : }
20603 : :
20604 : : static int
20605 : 0 : test_cryptodev_virtio_user(void)
20606 : : {
20607 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_USER_PMD));
20608 : : }
20609 : :
20610 : : static int
20611 : 0 : test_cryptodev_aesni_mb(void)
20612 : : {
20613 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
20614 : : }
20615 : :
20616 : : static int
20617 : 0 : test_cryptodev_cpu_aesni_mb(void)
20618 : : {
20619 : : int32_t rc;
20620 : 0 : enum rte_security_session_action_type at = gbl_action_type;
20621 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
20622 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
20623 : 0 : gbl_action_type = at;
20624 : 0 : return rc;
20625 : : }
20626 : :
20627 : : static int
20628 : 1 : test_cryptodev_openssl(void)
20629 : : {
20630 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
20631 : : }
20632 : :
20633 : : static int
20634 : 0 : test_cryptodev_aesni_gcm(void)
20635 : : {
20636 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20637 : : }
20638 : :
20639 : : static int
20640 : 0 : test_cryptodev_cpu_aesni_gcm(void)
20641 : : {
20642 : : int32_t rc;
20643 : 0 : enum rte_security_session_action_type at = gbl_action_type;
20644 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
20645 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20646 : 0 : gbl_action_type = at;
20647 : 0 : return rc;
20648 : : }
20649 : :
20650 : : static int
20651 : 0 : test_cryptodev_mlx5(void)
20652 : : {
20653 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
20654 : : }
20655 : :
20656 : : static int
20657 : 0 : test_cryptodev_null(void)
20658 : : {
20659 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
20660 : : }
20661 : :
20662 : : static int
20663 : 0 : test_cryptodev_sw_snow3g(void)
20664 : : {
20665 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
20666 : : }
20667 : :
20668 : : static int
20669 : 0 : test_cryptodev_sw_zuc(void)
20670 : : {
20671 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
20672 : : }
20673 : :
20674 : : static int
20675 : 0 : test_cryptodev_armv8(void)
20676 : : {
20677 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
20678 : : }
20679 : :
20680 : : static int
20681 : 0 : test_cryptodev_mrvl(void)
20682 : : {
20683 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
20684 : : }
20685 : :
20686 : : #ifdef RTE_CRYPTO_SCHEDULER
20687 : :
20688 : : static int
20689 : 0 : test_cryptodev_scheduler(void)
20690 : : {
20691 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
20692 : 0 : const enum blockcipher_test_type blk_suites[] = {
20693 : : BLKCIPHER_AES_CHAIN_TYPE,
20694 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
20695 : : BLKCIPHER_AUTHONLY_TYPE
20696 : : };
20697 : : static struct unit_test_suite scheduler_multicore = {
20698 : : .suite_name = "Scheduler Multicore Unit Test Suite",
20699 : : .setup = scheduler_multicore_testsuite_setup,
20700 : : .teardown = scheduler_mode_testsuite_teardown,
20701 : : .unit_test_cases = {TEST_CASES_END()}
20702 : : };
20703 : : static struct unit_test_suite scheduler_round_robin = {
20704 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
20705 : : .setup = scheduler_roundrobin_testsuite_setup,
20706 : : .teardown = scheduler_mode_testsuite_teardown,
20707 : : .unit_test_cases = {TEST_CASES_END()}
20708 : : };
20709 : : static struct unit_test_suite scheduler_failover = {
20710 : : .suite_name = "Scheduler Failover Unit Test Suite",
20711 : : .setup = scheduler_failover_testsuite_setup,
20712 : : .teardown = scheduler_mode_testsuite_teardown,
20713 : : .unit_test_cases = {TEST_CASES_END()}
20714 : : };
20715 : : static struct unit_test_suite scheduler_pkt_size_distr = {
20716 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
20717 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
20718 : : .teardown = scheduler_mode_testsuite_teardown,
20719 : : .unit_test_cases = {TEST_CASES_END()}
20720 : : };
20721 : 0 : struct unit_test_suite *sched_mode_suites[] = {
20722 : : &scheduler_multicore,
20723 : : &scheduler_round_robin,
20724 : : &scheduler_failover,
20725 : : &scheduler_pkt_size_distr
20726 : : };
20727 : : static struct unit_test_suite scheduler_config = {
20728 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
20729 : : .unit_test_cases = {
20730 : : TEST_CASE(test_scheduler_attach_worker_op),
20731 : : TEST_CASE(test_scheduler_mode_multicore_op),
20732 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
20733 : : TEST_CASE(test_scheduler_mode_failover_op),
20734 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
20735 : : TEST_CASE(test_scheduler_detach_worker_op),
20736 : :
20737 : : TEST_CASES_END() /**< NULL terminate array */
20738 : : }
20739 : : };
20740 : 0 : struct unit_test_suite *static_suites[] = {
20741 : : &scheduler_config,
20742 : : &end_testsuite
20743 : : };
20744 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
20745 : : #ifdef RTE_LIB_SECURITY
20746 : : &docsis_proto_testsuite,
20747 : : #endif
20748 : : &end_testsuite
20749 : : };
20750 : : static struct unit_test_suite ts = {
20751 : : .suite_name = "Scheduler Unit Test Suite",
20752 : : .setup = scheduler_testsuite_setup,
20753 : : .teardown = testsuite_teardown,
20754 : : .unit_test_cases = {TEST_CASES_END()}
20755 : : };
20756 : :
20757 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
20758 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
20759 : :
20760 [ # # ]: 0 : if (gbl_driver_id == -1) {
20761 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
20762 : 0 : return TEST_SKIPPED;
20763 : : }
20764 : :
20765 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
20766 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
20767 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
20768 : 0 : return TEST_SKIPPED;
20769 : : }
20770 : :
20771 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20772 : : uint8_t blk_i = 0;
20773 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
20774 : : (struct unit_test_suite *) *
20775 : : (RTE_DIM(blk_suites) +
20776 : : RTE_DIM(sched_mode_static_suites) + 1));
20777 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20778 : : blk_suites, RTE_DIM(blk_suites));
20779 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20780 : : sched_mode_static_suites,
20781 : : RTE_DIM(sched_mode_static_suites));
20782 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
20783 : : }
20784 : :
20785 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
20786 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
20787 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
20788 : : RTE_DIM(sched_mode_suites));
20789 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
20790 : 0 : ret = unit_test_suite_runner(&ts);
20791 : :
20792 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20793 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
20794 : : (*sched_mode_suites[sched_i]),
20795 : : RTE_DIM(blk_suites));
20796 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
20797 : : }
20798 : 0 : free(ts.unit_test_suites);
20799 : 0 : return ret;
20800 : : }
20801 : :
20802 : 306 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
20803 : :
20804 : : #endif
20805 : :
20806 : : static int
20807 : 0 : test_cryptodev_dpaa2_sec(void)
20808 : : {
20809 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20810 : : }
20811 : :
20812 : : static int
20813 : 0 : test_cryptodev_dpaa_sec(void)
20814 : : {
20815 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20816 : : }
20817 : :
20818 : : static int
20819 : 0 : test_cryptodev_ccp(void)
20820 : : {
20821 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
20822 : : }
20823 : :
20824 : : static int
20825 : 0 : test_cryptodev_octeontx(void)
20826 : : {
20827 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
20828 : : }
20829 : :
20830 : : static int
20831 : 0 : test_cryptodev_caam_jr(void)
20832 : : {
20833 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
20834 : : }
20835 : :
20836 : : static int
20837 : 0 : test_cryptodev_nitrox(void)
20838 : : {
20839 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
20840 : : }
20841 : :
20842 : : static int
20843 : 0 : test_cryptodev_bcmfs(void)
20844 : : {
20845 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
20846 : : }
20847 : :
20848 : : static int
20849 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
20850 : : {
20851 : : int ret;
20852 : :
20853 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
20854 [ # # ]: 0 : if (ret)
20855 : : return ret;
20856 : :
20857 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
20858 : 0 : ret = run_cryptodev_testsuite(pmd_name);
20859 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
20860 : :
20861 : 0 : return ret;
20862 : : }
20863 : :
20864 : : static int
20865 : 0 : test_cryptodev_qat_raw_api(void)
20866 : : {
20867 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20868 : : }
20869 : :
20870 : : static int
20871 : 0 : test_cryptodev_cn9k(void)
20872 : : {
20873 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
20874 : : }
20875 : :
20876 : : static int
20877 : 0 : test_cryptodev_cn10k(void)
20878 : : {
20879 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20880 : : }
20881 : :
20882 : : static int
20883 : 0 : test_cryptodev_cn10k_raw_api(void)
20884 : : {
20885 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20886 : : }
20887 : :
20888 : : static int
20889 : 0 : test_cryptodev_cn20k(void)
20890 : : {
20891 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN20K_PMD));
20892 : : }
20893 : :
20894 : : static int
20895 : 0 : test_cryptodev_cn20k_raw_api(void)
20896 : : {
20897 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN20K_PMD));
20898 : : }
20899 : :
20900 : : static int
20901 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
20902 : : {
20903 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20904 : : }
20905 : :
20906 : : static int
20907 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
20908 : : {
20909 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20910 : : }
20911 : :
20912 : : static int
20913 : 0 : test_cryptodev_zsda(void)
20914 : : {
20915 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZSDA_SYM_PMD));
20916 : : }
20917 : :
20918 : 306 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
20919 : : test_cryptodev_cn10k_raw_api);
20920 : 306 : REGISTER_DRIVER_TEST(cryptodev_cn20k_raw_api_autotest,
20921 : : test_cryptodev_cn20k_raw_api);
20922 : 306 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
20923 : : test_cryptodev_dpaa2_sec_raw_api);
20924 : 306 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
20925 : : test_cryptodev_dpaa_sec_raw_api);
20926 : 306 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
20927 : : test_cryptodev_qat_raw_api);
20928 : 306 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
20929 : 306 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
20930 : 306 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
20931 : : test_cryptodev_cpu_aesni_mb);
20932 : 306 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
20933 : 306 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
20934 : 306 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
20935 : : test_cryptodev_cpu_aesni_gcm);
20936 : 306 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
20937 : 306 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
20938 : 306 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
20939 : 306 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
20940 : 306 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
20941 : 306 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
20942 : 306 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
20943 : 306 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
20944 : 306 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
20945 : 306 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
20946 : 306 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
20947 : 306 : REGISTER_DRIVER_TEST(cryptodev_virtio_user_autotest, test_cryptodev_virtio_user);
20948 : 306 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
20949 : 306 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
20950 : 306 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
20951 : 306 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
20952 : 306 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
20953 : 306 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
20954 : 306 : REGISTER_DRIVER_TEST(cryptodev_cn20k_autotest, test_cryptodev_cn20k);
20955 : 306 : REGISTER_DRIVER_TEST(cryptodev_zsda_autotest, test_cryptodev_zsda);
|