Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2015-2020 Intel Corporation
3 : : * Copyright 2020 NXP
4 : : */
5 : :
6 : : #include <stdbool.h>
7 : : #include <time.h>
8 : :
9 : : #include <rte_common.h>
10 : : #include <rte_hexdump.h>
11 : : #include <rte_mbuf.h>
12 : : #include <rte_malloc.h>
13 : : #include <rte_memcpy.h>
14 : : #include <rte_pause.h>
15 : : #include <rte_bus_vdev.h>
16 : : #include <rte_ether.h>
17 : : #include <rte_errno.h>
18 : :
19 : : #include <rte_crypto.h>
20 : : #include <rte_cryptodev.h>
21 : : #include <rte_ethdev.h>
22 : : #include <rte_ip.h>
23 : : #include <rte_string_fns.h>
24 : : #include <rte_tcp.h>
25 : : #include <rte_tls.h>
26 : : #include <rte_udp.h>
27 : :
28 : : #ifdef RTE_CRYPTO_SCHEDULER
29 : : #include <rte_cryptodev_scheduler.h>
30 : : #include <rte_cryptodev_scheduler_operations.h>
31 : : #endif
32 : :
33 : : #include <rte_lcore.h>
34 : :
35 : : #include "test.h"
36 : : #include "test_cryptodev.h"
37 : :
38 : : #include "test_cryptodev_blockcipher.h"
39 : : #include "test_cryptodev_aes_test_vectors.h"
40 : : #include "test_cryptodev_des_test_vectors.h"
41 : : #include "test_cryptodev_hash_test_vectors.h"
42 : : #include "test_cryptodev_kasumi_test_vectors.h"
43 : : #include "test_cryptodev_kasumi_hash_test_vectors.h"
44 : : #include "test_cryptodev_snow3g_test_vectors.h"
45 : : #include "test_cryptodev_snow3g_hash_test_vectors.h"
46 : : #include "test_cryptodev_zuc_test_vectors.h"
47 : : #include "test_cryptodev_aead_test_vectors.h"
48 : : #include "test_cryptodev_hmac_test_vectors.h"
49 : : #include "test_cryptodev_mixed_test_vectors.h"
50 : : #include "test_cryptodev_sm4_test_vectors.h"
51 : : #ifdef RTE_LIB_SECURITY
52 : : #include "test_cryptodev_security_ipsec.h"
53 : : #include "test_cryptodev_security_ipsec_test_vectors.h"
54 : : #include "test_cryptodev_security_pdcp_test_vectors.h"
55 : : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
56 : : #include "test_cryptodev_security_pdcp_test_func.h"
57 : : #include "test_cryptodev_security_docsis_test_vectors.h"
58 : : #include "test_cryptodev_security_tls_record.h"
59 : : #include "test_security_proto.h"
60 : :
61 : : #define SDAP_DISABLED 0
62 : : #define SDAP_ENABLED 1
63 : : #endif
64 : :
65 : : #define VDEV_ARGS_SIZE 100
66 : : #define MAX_NB_SESSIONS 4
67 : :
68 : : #define MAX_RAW_DEQUEUE_COUNT 65535
69 : :
70 : : #define IN_PLACE 0
71 : : #define OUT_OF_PLACE 1
72 : :
73 : : #define QP_DRAIN_TIMEOUT 100
74 : : #define HW_ERR_RECOVER_TIMEOUT 500
75 : :
76 : : static int gbl_driver_id;
77 : :
78 : : static enum rte_security_session_action_type gbl_action_type =
79 : : RTE_SECURITY_ACTION_TYPE_NONE;
80 : :
81 : : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
82 : :
83 : : struct crypto_unittest_params {
84 : : struct rte_crypto_sym_xform cipher_xform;
85 : : struct rte_crypto_sym_xform auth_xform;
86 : : struct rte_crypto_sym_xform aead_xform;
87 : : #ifdef RTE_LIB_SECURITY
88 : : struct rte_security_docsis_xform docsis_xform;
89 : : #endif
90 : :
91 : : union {
92 : : void *sess;
93 : : #ifdef RTE_LIB_SECURITY
94 : : void *sec_session;
95 : : #endif
96 : : };
97 : : #ifdef RTE_LIB_SECURITY
98 : : enum rte_security_session_action_type type;
99 : : #endif
100 : : struct rte_crypto_op *op;
101 : :
102 : : struct rte_mbuf *obuf, *ibuf;
103 : :
104 : : uint8_t *digest;
105 : : };
106 : :
107 : : #define ALIGN_POW2_ROUNDUP(num, align) \
108 : : (((num) + (align) - 1) & ~((align) - 1))
109 : :
110 : : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
111 : : for (j = 0; j < num_child_ts; index++, j++) \
112 : : parent_ts.unit_test_suites[index] = child_ts[j]
113 : :
114 : : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
115 : : for (j = 0; j < num_blk_types; index++, j++) \
116 : : parent_ts.unit_test_suites[index] = \
117 : : build_blockcipher_test_suite(blk_types[j])
118 : :
119 : : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
120 : : for (j = index; j < index + num_blk_types; j++) \
121 : : free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
122 : :
123 : : /*
124 : : * Forward declarations.
125 : : */
126 : : static int
127 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
128 : : struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
129 : : uint8_t *hmac_key);
130 : :
131 : : static int
132 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
133 : : struct crypto_unittest_params *ut_params,
134 : : struct crypto_testsuite_params *ts_param,
135 : : const uint8_t *cipher,
136 : : const uint8_t *digest,
137 : : const uint8_t *iv);
138 : :
139 : : static int
140 : : security_proto_supported(enum rte_security_session_action_type action,
141 : : enum rte_security_session_protocol proto);
142 : :
143 : : static int
144 : : dev_configure_and_start(uint64_t ff_disable);
145 : :
146 : : static int
147 : : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
148 : : const enum rte_crypto_cipher_algorithm cipher_algo,
149 : : const uint16_t key_size, const uint16_t iv_size);
150 : :
151 : : static int
152 : : check_auth_capability(const struct crypto_testsuite_params *ts_params,
153 : : const enum rte_crypto_auth_algorithm auth_algo,
154 : : const uint16_t key_size, const uint16_t iv_size,
155 : : const uint16_t tag_size);
156 : :
157 : : static struct rte_mbuf *
158 : 7 : setup_test_string(struct rte_mempool *mpool,
159 : : const char *string, size_t len, uint8_t blocksize)
160 : : {
161 : 7 : struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
162 [ - + ]: 7 : size_t t_len = len - (blocksize ? (len % blocksize) : 0);
163 : :
164 [ + - ]: 7 : if (m) {
165 : : char *dst;
166 : :
167 : 7 : memset(m->buf_addr, 0, m->buf_len);
168 : 7 : dst = rte_pktmbuf_append(m, t_len);
169 [ - + ]: 7 : if (!dst) {
170 : 0 : rte_pktmbuf_free(m);
171 : 0 : return NULL;
172 : : }
173 [ + - ]: 7 : if (string != NULL)
174 : : rte_memcpy(dst, string, t_len);
175 : : else
176 : : memset(dst, 0, t_len);
177 : : }
178 : :
179 : : return m;
180 : : }
181 : :
182 : : /* Get number of bytes in X bits (rounding up) */
183 : : static uint32_t
184 : : ceil_byte_length(uint32_t num_bits)
185 : : {
186 : 4 : if (num_bits % 8)
187 : 0 : return ((num_bits >> 3) + 1);
188 : : else
189 : 4 : return (num_bits >> 3);
190 : : }
191 : :
192 : : static void
193 : 0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
194 : : uint8_t is_op_success)
195 : : {
196 : : struct rte_crypto_op *op = user_data;
197 [ # # ]: 0 : op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
198 : : RTE_CRYPTO_OP_STATUS_ERROR;
199 : 0 : }
200 : :
201 : : static struct crypto_testsuite_params testsuite_params = { NULL };
202 : : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
203 : : static struct crypto_unittest_params unittest_params;
204 : : static bool enq_cb_called;
205 : : static bool deq_cb_called;
206 : :
207 : : enum cryptodev_err_state {
208 : : CRYPTODEV_ERR_CLEARED,
209 : : CRYPTODEV_ERR_TRIGGERED,
210 : : CRYPTODEV_ERR_UNRECOVERABLE,
211 : : };
212 : :
213 : : static enum cryptodev_err_state crypto_err = CRYPTODEV_ERR_CLEARED;
214 : :
215 : : static void
216 : 0 : test_cryptodev_error_cb(uint8_t dev_id, enum rte_cryptodev_event_type event, void *cb_arg)
217 : : {
218 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
219 : : uint16_t qp_id;
220 : : int ticks = 0;
221 : : int ret = 0;
222 : :
223 : : RTE_SET_USED(event);
224 : : RTE_SET_USED(cb_arg);
225 : :
226 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
227 : 0 : ret = rte_cryptodev_queue_pair_event_error_query(dev_id, qp_id);
228 [ # # ]: 0 : if (ret)
229 : : break;
230 : : }
231 [ # # ]: 0 : if (ret == 1) {
232 : : /* Wait for the queue to be completely drained */
233 [ # # # # ]: 0 : while (rte_cryptodev_qp_depth_used(dev_id, qp_id) != 0) {
234 : : rte_delay_ms(10);
235 : 0 : ticks++;
236 [ # # ]: 0 : if (ticks > QP_DRAIN_TIMEOUT) {
237 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
238 : 0 : return;
239 : : }
240 : : }
241 [ # # ]: 0 : if (rte_cryptodev_queue_pair_reset(dev_id, qp_id, NULL, 0)) {
242 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
243 : 0 : return;
244 : : }
245 : : }
246 : :
247 : 0 : crypto_err = CRYPTODEV_ERR_CLEARED;
248 : : }
249 : :
250 : : static struct rte_mbuf *
251 : 0 : create_mbuf_from_heap(int pkt_len, uint8_t pattern)
252 : : {
253 : : struct rte_mbuf *m = NULL;
254 : : uint8_t *dst;
255 : :
256 : 0 : m = calloc(1, MBUF_SIZE);
257 [ # # ]: 0 : if (m == NULL) {
258 : : printf("Cannot create mbuf from heap");
259 : 0 : return NULL;
260 : : }
261 : :
262 : : /* Set the default values to the mbuf */
263 : 0 : m->nb_segs = 1;
264 : 0 : m->port = RTE_MBUF_PORT_INVALID;
265 : 0 : m->buf_len = MBUF_SIZE - sizeof(struct rte_mbuf) - RTE_PKTMBUF_HEADROOM;
266 : : rte_pktmbuf_reset_headroom(m);
267 : : __rte_mbuf_sanity_check(m, 1);
268 : :
269 : 0 : m->buf_addr = (char *)m + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
270 : :
271 : 0 : memset(m->buf_addr, pattern, m->buf_len);
272 : 0 : dst = (uint8_t *)rte_pktmbuf_append(m, pkt_len);
273 [ # # ]: 0 : if (dst == NULL) {
274 : : printf("Cannot append %d bytes to the mbuf\n", pkt_len);
275 : 0 : free(m);
276 : 0 : return NULL;
277 : : }
278 : :
279 : : return m;
280 : : }
281 : :
282 : : int
283 : 0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
284 : : struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
285 : : uint8_t len_in_bits, uint8_t cipher_iv_len)
286 : : {
287 : 0 : struct rte_crypto_sym_op *sop = op->sym;
288 : 0 : struct rte_crypto_op *ret_op = NULL;
289 : : struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
290 : : struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
291 : : union rte_crypto_sym_ofs ofs;
292 : : struct rte_crypto_sym_vec vec;
293 : : struct rte_crypto_sgl sgl, dest_sgl;
294 : : uint32_t max_len;
295 : : union rte_cryptodev_session_ctx sess;
296 : : uint64_t auth_end_iova;
297 : : uint32_t count = 0;
298 : : struct rte_crypto_raw_dp_ctx *ctx;
299 : : uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
300 : : auth_len = 0;
301 : : int32_t n;
302 : : uint32_t n_success;
303 : : int ctx_service_size;
304 : 0 : int32_t status = 0;
305 : : int enqueue_status, dequeue_status;
306 : : struct crypto_unittest_params *ut_params = &unittest_params;
307 : 0 : int is_sgl = sop->m_src->nb_segs > 1;
308 : : int ret = TEST_SUCCESS, is_oop = 0;
309 : :
310 : 0 : ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
311 [ # # ]: 0 : if (ctx_service_size < 0)
312 : : return TEST_SKIPPED;
313 : :
314 : 0 : ctx = malloc(ctx_service_size);
315 [ # # ]: 0 : if (ctx == NULL)
316 : : return TEST_FAILED;
317 : :
318 : : /* Both are enums, setting crypto_sess will suit any session type */
319 : 0 : sess.crypto_sess = op->sym->session;
320 : :
321 : 0 : ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
322 [ # # ]: 0 : if (ret == -ENOTSUP) {
323 : : ret = TEST_SKIPPED;
324 : 0 : goto exit;
325 [ # # ]: 0 : } else if (ret) {
326 : : ret = TEST_FAILED;
327 : 0 : goto exit;
328 : : }
329 : :
330 : 0 : cipher_iv.iova = 0;
331 : 0 : cipher_iv.va = NULL;
332 : 0 : aad_auth_iv.iova = 0;
333 : 0 : aad_auth_iv.va = NULL;
334 : 0 : digest.iova = 0;
335 : 0 : digest.va = NULL;
336 : 0 : sgl.vec = data_vec;
337 : 0 : vec.num = 1;
338 : 0 : vec.src_sgl = &sgl;
339 : 0 : vec.iv = &cipher_iv;
340 : 0 : vec.digest = &digest;
341 : 0 : vec.aad = &aad_auth_iv;
342 : 0 : vec.status = &status;
343 : :
344 : 0 : ofs.raw = 0;
345 : :
346 [ # # # # ]: 0 : if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
347 : : is_oop = 1;
348 : :
349 [ # # ]: 0 : if (is_cipher && is_auth) {
350 : 0 : cipher_offset = sop->cipher.data.offset;
351 : 0 : cipher_len = sop->cipher.data.length;
352 : 0 : auth_offset = sop->auth.data.offset;
353 : 0 : auth_len = sop->auth.data.length;
354 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len,
355 : : auth_offset + auth_len);
356 [ # # ]: 0 : if (len_in_bits) {
357 : 0 : max_len = max_len >> 3;
358 : 0 : cipher_offset = cipher_offset >> 3;
359 : 0 : auth_offset = auth_offset >> 3;
360 : 0 : cipher_len = cipher_len >> 3;
361 : 0 : auth_len = auth_len >> 3;
362 : : }
363 : 0 : ofs.ofs.cipher.head = cipher_offset;
364 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
365 : 0 : ofs.ofs.auth.head = auth_offset;
366 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
367 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
368 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
369 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
370 : : op, void *, IV_OFFSET + cipher_iv_len);
371 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
372 : : cipher_iv_len);
373 : 0 : digest.va = (void *)sop->auth.digest.data;
374 : 0 : digest.iova = sop->auth.digest.phys_addr;
375 : :
376 [ # # ]: 0 : if (is_sgl) {
377 : 0 : uint32_t remaining_off = auth_offset + auth_len;
378 : 0 : struct rte_mbuf *sgl_buf = sop->m_src;
379 [ # # ]: 0 : if (is_oop)
380 : : sgl_buf = sop->m_dst;
381 : :
382 : 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
383 [ # # # # ]: 0 : && sgl_buf->next != NULL) {
384 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
385 : : sgl_buf = sgl_buf->next;
386 : : }
387 : :
388 : 0 : auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
389 : : sgl_buf, remaining_off);
390 : : } else {
391 : 0 : auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
392 : 0 : auth_offset + auth_len;
393 : : }
394 : : /* Then check if digest-encrypted conditions are met */
395 [ # # # # ]: 0 : if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
396 [ # # ]: 0 : (digest.iova == auth_end_iova) && is_sgl)
397 : 0 : max_len = RTE_MAX(max_len,
398 : : auth_offset + auth_len +
399 : : ut_params->auth_xform.auth.digest_length);
400 : :
401 [ # # ]: 0 : } else if (is_cipher) {
402 : 0 : cipher_offset = sop->cipher.data.offset;
403 : 0 : cipher_len = sop->cipher.data.length;
404 : 0 : max_len = cipher_len + cipher_offset;
405 [ # # ]: 0 : if (len_in_bits) {
406 : 0 : max_len = max_len >> 3;
407 : 0 : cipher_offset = cipher_offset >> 3;
408 : 0 : cipher_len = cipher_len >> 3;
409 : : }
410 : 0 : ofs.ofs.cipher.head = cipher_offset;
411 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
412 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
413 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
414 : :
415 [ # # ]: 0 : } else if (is_auth) {
416 : 0 : auth_offset = sop->auth.data.offset;
417 : 0 : auth_len = sop->auth.data.length;
418 : 0 : max_len = auth_len + auth_offset;
419 [ # # ]: 0 : if (len_in_bits) {
420 : 0 : max_len = max_len >> 3;
421 : 0 : auth_offset = auth_offset >> 3;
422 : 0 : auth_len = auth_len >> 3;
423 : : }
424 : 0 : ofs.ofs.auth.head = auth_offset;
425 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
426 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
427 : : op, void *, IV_OFFSET + cipher_iv_len);
428 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
429 : : cipher_iv_len);
430 : 0 : digest.va = (void *)sop->auth.digest.data;
431 : 0 : digest.iova = sop->auth.digest.phys_addr;
432 : :
433 : : } else { /* aead */
434 : 0 : cipher_offset = sop->aead.data.offset;
435 : 0 : cipher_len = sop->aead.data.length;
436 : 0 : max_len = cipher_len + cipher_offset;
437 [ # # ]: 0 : if (len_in_bits) {
438 : 0 : max_len = max_len >> 3;
439 : 0 : cipher_offset = cipher_offset >> 3;
440 : 0 : cipher_len = cipher_len >> 3;
441 : : }
442 : 0 : ofs.ofs.cipher.head = cipher_offset;
443 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
444 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
445 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
446 : 0 : aad_auth_iv.va = (void *)sop->aead.aad.data;
447 : 0 : aad_auth_iv.iova = sop->aead.aad.phys_addr;
448 : 0 : digest.va = (void *)sop->aead.digest.data;
449 : 0 : digest.iova = sop->aead.digest.phys_addr;
450 : : }
451 : :
452 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
453 : : data_vec, RTE_DIM(data_vec));
454 [ # # # # ]: 0 : if (n < 0 || n > sop->m_src->nb_segs) {
455 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
456 : 0 : goto exit;
457 : : }
458 : :
459 : 0 : sgl.num = n;
460 : : /* Out of place */
461 [ # # ]: 0 : if (is_oop) {
462 : 0 : dest_sgl.vec = dest_data_vec;
463 : 0 : vec.dest_sgl = &dest_sgl;
464 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
465 : : dest_data_vec, RTE_DIM(dest_data_vec));
466 [ # # # # ]: 0 : if (n < 0 || n > sop->m_dst->nb_segs) {
467 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
468 : 0 : goto exit;
469 : : }
470 : 0 : dest_sgl.num = n;
471 : : } else
472 : 0 : vec.dest_sgl = NULL;
473 : :
474 [ # # ]: 0 : if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
475 : : &enqueue_status) < 1) {
476 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
477 : 0 : goto exit;
478 : : }
479 : :
480 [ # # ]: 0 : if (enqueue_status == 0) {
481 : 0 : status = rte_cryptodev_raw_enqueue_done(ctx, 1);
482 [ # # ]: 0 : if (status < 0) {
483 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
484 : 0 : goto exit;
485 : : }
486 [ # # ]: 0 : } else if (enqueue_status < 0) {
487 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
488 : 0 : goto exit;
489 : : }
490 : :
491 : 0 : n = n_success = 0;
492 [ # # # # ]: 0 : while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
493 : 0 : n = rte_cryptodev_raw_dequeue_burst(ctx,
494 : : NULL, 1, post_process_raw_dp_op,
495 : : (void **)&ret_op, 0, &n_success,
496 : : &dequeue_status);
497 [ # # ]: 0 : if (dequeue_status < 0) {
498 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
499 : 0 : goto exit;
500 : : }
501 [ # # ]: 0 : if (n == 0)
502 : : rte_pause();
503 : : }
504 : :
505 [ # # # # ]: 0 : if (n == 1 && dequeue_status == 0) {
506 [ # # ]: 0 : if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
507 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
508 : 0 : goto exit;
509 : : }
510 : : }
511 : :
512 [ # # # # ]: 0 : op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
513 [ # # ]: 0 : ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
514 [ # # ]: 0 : n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
515 : : RTE_CRYPTO_OP_STATUS_SUCCESS;
516 : :
517 : 0 : exit:
518 : 0 : free(ctx);
519 : 0 : return ret;
520 : : }
521 : :
522 : : static void
523 : 0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
524 : : {
525 : : int32_t n, st;
526 : : struct rte_crypto_sym_op *sop;
527 : : union rte_crypto_sym_ofs ofs;
528 : : struct rte_crypto_sgl sgl;
529 : : struct rte_crypto_sym_vec symvec;
530 : : struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
531 : : struct rte_crypto_vec vec[UINT8_MAX];
532 : :
533 : : sop = op->sym;
534 : :
535 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
536 : : sop->aead.data.length, vec, RTE_DIM(vec));
537 : :
538 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
539 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
540 : 0 : return;
541 : : }
542 : :
543 : 0 : sgl.vec = vec;
544 : 0 : sgl.num = n;
545 : 0 : symvec.src_sgl = &sgl;
546 : 0 : symvec.iv = &iv_ptr;
547 : 0 : symvec.digest = &digest_ptr;
548 : 0 : symvec.aad = &aad_ptr;
549 : 0 : symvec.status = &st;
550 : 0 : symvec.num = 1;
551 : :
552 : : /* for CPU crypto the IOVA address is not required */
553 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
554 : 0 : digest_ptr.va = (void *)sop->aead.digest.data;
555 : 0 : aad_ptr.va = (void *)sop->aead.aad.data;
556 : :
557 : 0 : ofs.raw = 0;
558 : :
559 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
560 : : &symvec);
561 : :
562 [ # # ]: 0 : if (n != 1)
563 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
564 : : else
565 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
566 : : }
567 : :
568 : : static void
569 : 0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
570 : : {
571 : : int32_t n, st;
572 : : struct rte_crypto_sym_op *sop;
573 : : union rte_crypto_sym_ofs ofs;
574 : : struct rte_crypto_sgl sgl;
575 : : struct rte_crypto_sym_vec symvec;
576 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
577 : : struct rte_crypto_vec vec[UINT8_MAX];
578 : :
579 : : sop = op->sym;
580 : :
581 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
582 : : sop->auth.data.length, vec, RTE_DIM(vec));
583 : :
584 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
585 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
586 : 0 : return;
587 : : }
588 : :
589 : 0 : sgl.vec = vec;
590 : 0 : sgl.num = n;
591 : 0 : symvec.src_sgl = &sgl;
592 : 0 : symvec.iv = &iv_ptr;
593 : 0 : symvec.digest = &digest_ptr;
594 : 0 : symvec.status = &st;
595 : 0 : symvec.num = 1;
596 : :
597 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
598 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
599 : :
600 : 0 : ofs.raw = 0;
601 : 0 : ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
602 : 0 : ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
603 : 0 : (sop->cipher.data.offset + sop->cipher.data.length);
604 : :
605 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
606 : : &symvec);
607 : :
608 [ # # ]: 0 : if (n != 1)
609 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
610 : : else
611 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
612 : : }
613 : :
614 : : static struct rte_crypto_op *
615 : 116 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
616 : : {
617 : :
618 [ - + ]: 116 : RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
619 : :
620 [ - + ]: 116 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
621 : 0 : RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
622 : 0 : return NULL;
623 : : }
624 : :
625 : 116 : op = NULL;
626 : :
627 [ - + ]: 116 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
628 : : rte_pause();
629 : :
630 [ + + ]: 116 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
631 : 11 : RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
632 : 11 : return NULL;
633 : : }
634 : :
635 : : return op;
636 : : }
637 : :
638 : : static int
639 : 1 : testsuite_setup(void)
640 : : {
641 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
642 : : struct rte_cryptodev_info info;
643 : : uint32_t i = 0, nb_devs, dev_id;
644 : : uint16_t qp_id;
645 : :
646 : : memset(ts_params, 0, sizeof(*ts_params));
647 : :
648 : 1 : ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
649 [ + - ]: 1 : if (ts_params->mbuf_pool == NULL) {
650 : : /* Not already created so create */
651 : 1 : ts_params->mbuf_pool = rte_pktmbuf_pool_create(
652 : : "CRYPTO_MBUFPOOL",
653 : : NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
654 : 1 : rte_socket_id());
655 [ - + ]: 1 : if (ts_params->mbuf_pool == NULL) {
656 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
657 : 0 : return TEST_FAILED;
658 : : }
659 : : }
660 : :
661 : 1 : ts_params->large_mbuf_pool = rte_mempool_lookup(
662 : : "CRYPTO_LARGE_MBUFPOOL");
663 [ + - ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
664 : : /* Not already created so create */
665 : 1 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
666 : : "CRYPTO_LARGE_MBUFPOOL",
667 : : 1, 0, 0, LARGE_MBUF_SIZE,
668 : 1 : rte_socket_id());
669 [ - + ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
670 : 0 : RTE_LOG(ERR, USER1,
671 : : "Can't create CRYPTO_LARGE_MBUFPOOL\n");
672 : 0 : return TEST_FAILED;
673 : : }
674 : : }
675 : :
676 : 1 : ts_params->op_mpool = rte_crypto_op_pool_create(
677 : : "MBUF_CRYPTO_SYM_OP_POOL",
678 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC,
679 : : NUM_MBUFS, MBUF_CACHE_SIZE,
680 : : DEFAULT_NUM_XFORMS *
681 : : sizeof(struct rte_crypto_sym_xform) +
682 : : MAXIMUM_IV_LENGTH,
683 : 1 : rte_socket_id());
684 [ - + ]: 1 : if (ts_params->op_mpool == NULL) {
685 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
686 : 0 : return TEST_FAILED;
687 : : }
688 : :
689 : 1 : nb_devs = rte_cryptodev_count();
690 [ - + ]: 1 : if (nb_devs < 1) {
691 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
692 : 0 : return TEST_SKIPPED;
693 : : }
694 : :
695 [ - + ]: 1 : if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
696 : 0 : RTE_LOG(WARNING, USER1, "No %s devices found?\n",
697 : : rte_cryptodev_driver_name_get(gbl_driver_id));
698 : 0 : return TEST_SKIPPED;
699 : : }
700 : :
701 : : /* Create list of valid crypto devs */
702 [ + + ]: 2 : for (i = 0; i < nb_devs; i++) {
703 : 1 : rte_cryptodev_info_get(i, &info);
704 [ + - ]: 1 : if (info.driver_id == gbl_driver_id)
705 : 1 : ts_params->valid_devs[ts_params->valid_dev_count++] = i;
706 : : }
707 : :
708 [ + - ]: 1 : if (ts_params->valid_dev_count < 1)
709 : : return TEST_FAILED;
710 : :
711 : : /* Set up all the qps on the first of the valid devices found */
712 : :
713 : 1 : dev_id = ts_params->valid_devs[0];
714 : :
715 : 1 : rte_cryptodev_info_get(dev_id, &info);
716 : :
717 : 1 : ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
718 : 1 : ts_params->conf.socket_id = SOCKET_ID_ANY;
719 : 1 : ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
720 : :
721 : : unsigned int session_size =
722 : 1 : rte_cryptodev_sym_get_private_session_size(dev_id);
723 : :
724 : : #ifdef RTE_LIB_SECURITY
725 : 1 : unsigned int security_session_size = rte_security_session_get_size(
726 : : rte_cryptodev_get_sec_ctx(dev_id));
727 : :
728 : : if (session_size < security_session_size)
729 : : session_size = security_session_size;
730 : : #endif
731 : : /*
732 : : * Create mempool with maximum number of sessions.
733 : : */
734 [ - + ]: 1 : if (info.sym.max_nb_sessions != 0 &&
735 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
736 : 0 : RTE_LOG(ERR, USER1, "Device does not support "
737 : : "at least %u sessions\n",
738 : : MAX_NB_SESSIONS);
739 : 0 : return TEST_FAILED;
740 : : }
741 : :
742 : 1 : ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
743 : : "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
744 : : SOCKET_ID_ANY);
745 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
746 : : "session mempool allocation failed");
747 : :
748 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
749 : : &ts_params->conf),
750 : : "Failed to configure cryptodev %u with %u qps",
751 : : dev_id, ts_params->conf.nb_queue_pairs);
752 : :
753 : 1 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
754 : 1 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
755 : :
756 [ + + ]: 9 : for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
757 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
758 : : dev_id, qp_id, &ts_params->qp_conf,
759 : : rte_cryptodev_socket_id(dev_id)),
760 : : "Failed to setup queue pair %u on cryptodev %u",
761 : : qp_id, dev_id);
762 : : }
763 : :
764 : : return TEST_SUCCESS;
765 : : }
766 : :
767 : : static void
768 : 1 : testsuite_teardown(void)
769 : : {
770 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
771 : : int res;
772 : :
773 [ + - ]: 1 : if (ts_params->large_mbuf_pool != NULL) {
774 : 1 : rte_mempool_free(ts_params->large_mbuf_pool);
775 : 1 : ts_params->large_mbuf_pool = NULL;
776 : : }
777 : :
778 [ + - ]: 1 : if (ts_params->mbuf_pool != NULL) {
779 : 1 : rte_mempool_free(ts_params->mbuf_pool);
780 : 1 : ts_params->mbuf_pool = NULL;
781 : : }
782 : :
783 [ + - ]: 1 : if (ts_params->op_mpool != NULL) {
784 : 1 : rte_mempool_free(ts_params->op_mpool);
785 : 1 : ts_params->op_mpool = NULL;
786 : : }
787 : :
788 [ + - ]: 1 : if (ts_params->session_mpool != NULL) {
789 : 1 : rte_mempool_free(ts_params->session_mpool);
790 : 1 : ts_params->session_mpool = NULL;
791 : : }
792 : :
793 : 1 : res = rte_cryptodev_close(ts_params->valid_devs[0]);
794 [ - + ]: 1 : if (res)
795 : 0 : RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
796 : 1 : }
797 : :
798 : : static int
799 : 31 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
800 : : const int *algs, uint16_t num_algs)
801 : : {
802 : 31 : uint8_t dev_id = testsuite_params.valid_devs[0];
803 : : bool some_alg_supported = false;
804 : : uint16_t i;
805 : :
806 [ + + ]: 74 : for (i = 0; i < num_algs && !some_alg_supported; i++) {
807 : 43 : struct rte_cryptodev_sym_capability_idx alg = {
808 : 43 : type, {algs[i]}
809 : : };
810 [ + + ]: 43 : if (rte_cryptodev_sym_capability_get(dev_id,
811 : : &alg) != NULL)
812 : : some_alg_supported = true;
813 : : }
814 [ + + ]: 31 : if (!some_alg_supported)
815 : 14 : return TEST_SKIPPED;
816 : :
817 : : return 0;
818 : : }
819 : :
820 : : int
821 : 9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
822 : : uint16_t num_ciphers)
823 : : {
824 : 17 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
825 : : (const int *) ciphers, num_ciphers);
826 : : }
827 : :
828 : : int
829 : 2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
830 : : uint16_t num_auths)
831 : : {
832 : 9 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
833 : : (const int *) auths, num_auths);
834 : : }
835 : :
836 : : int
837 : 0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
838 : : uint16_t num_aeads)
839 : : {
840 : 5 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
841 : : (const int *) aeads, num_aeads);
842 : : }
843 : :
844 : : static int
845 : 1 : null_testsuite_setup(void)
846 : : {
847 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
848 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
849 : : struct rte_cryptodev_info dev_info;
850 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
851 : : RTE_CRYPTO_CIPHER_NULL
852 : : };
853 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
854 : : RTE_CRYPTO_AUTH_NULL
855 : : };
856 : :
857 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
858 : :
859 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
860 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
861 : : "testsuite not met\n");
862 : 0 : return TEST_SKIPPED;
863 : : }
864 : :
865 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
866 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
867 : : RTE_DIM(auths)) != 0) {
868 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for NULL "
869 : : "testsuite not met\n");
870 : 1 : return TEST_SKIPPED;
871 : : }
872 : :
873 : : return 0;
874 : : }
875 : :
876 : : static int
877 : 1 : crypto_gen_testsuite_setup(void)
878 : : {
879 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
880 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
881 : : struct rte_cryptodev_info dev_info;
882 : :
883 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
884 : :
885 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
886 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
887 : : "testsuite not met\n");
888 : 0 : return TEST_SKIPPED;
889 : : }
890 : :
891 : : return 0;
892 : : }
893 : :
894 : : #ifdef RTE_LIB_SECURITY
895 : : static int
896 : 4 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
897 : : {
898 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
899 : : struct crypto_unittest_params *ut_params = &unittest_params;
900 : : struct rte_cryptodev_info dev_info;
901 : : int ret = 0;
902 : :
903 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
904 : :
905 [ + - ]: 4 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
906 : 4 : RTE_LOG(INFO, USER1,
907 : : "Feature flag requirements for security protocol testsuite not met\n");
908 : 4 : return TEST_SKIPPED;
909 : : }
910 : :
911 : : /* Reconfigure to enable security */
912 : 0 : ret = dev_configure_and_start(0);
913 [ # # ]: 0 : if (ret != TEST_SUCCESS)
914 : : return ret;
915 : :
916 : : /* Set action type */
917 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
918 : :
919 [ # # ]: 0 : if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
920 : 0 : RTE_LOG(INFO, USER1,
921 : : "Capability requirements for security protocol test not met\n");
922 : : ret = TEST_SKIPPED;
923 : : }
924 : :
925 : 0 : test_sec_alg_list_populate();
926 : 0 : test_sec_auth_only_alg_list_populate();
927 : :
928 : : /*
929 : : * Stop the device. Device would be started again by individual test
930 : : * case setup routine.
931 : : */
932 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
933 : :
934 : 0 : return ret;
935 : : }
936 : :
937 : : static int
938 : 1 : ipsec_proto_testsuite_setup(void)
939 : : {
940 : 1 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
941 : : }
942 : :
943 : : static int
944 : 3 : tls_record_proto_testsuite_setup(void)
945 : : {
946 : 3 : test_sec_proto_pattern_generate();
947 : :
948 : 3 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
949 : : }
950 : :
951 : : static int
952 : 1 : pdcp_proto_testsuite_setup(void)
953 : : {
954 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
955 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
956 : : struct rte_cryptodev_info dev_info;
957 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
958 : : RTE_CRYPTO_CIPHER_NULL,
959 : : RTE_CRYPTO_CIPHER_AES_CTR,
960 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
961 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
962 : : };
963 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
964 : : RTE_CRYPTO_AUTH_NULL,
965 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
966 : : RTE_CRYPTO_AUTH_AES_CMAC,
967 : : RTE_CRYPTO_AUTH_ZUC_EIA3
968 : : };
969 : :
970 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
971 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
972 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
973 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
974 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
975 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
976 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
977 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
978 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
979 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
980 : :
981 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
982 : :
983 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
984 : : !(dev_info.feature_flags &
985 : : RTE_CRYPTODEV_FF_SECURITY)) {
986 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
987 : : "testsuite not met\n");
988 : 1 : return TEST_SKIPPED;
989 : : }
990 : :
991 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
992 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
993 : : RTE_DIM(auths)) != 0) {
994 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
995 : : "testsuite not met\n");
996 : 0 : return TEST_SKIPPED;
997 : : }
998 : :
999 : : return 0;
1000 : : }
1001 : :
1002 : : static int
1003 : 1 : docsis_proto_testsuite_setup(void)
1004 : : {
1005 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1006 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1007 : : struct rte_cryptodev_info dev_info;
1008 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1009 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
1010 : : };
1011 : :
1012 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1013 : :
1014 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1015 : : !(dev_info.feature_flags &
1016 : : RTE_CRYPTODEV_FF_SECURITY)) {
1017 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
1018 : : "Proto testsuite not met\n");
1019 : 1 : return TEST_SKIPPED;
1020 : : }
1021 : :
1022 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1023 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
1024 : : "testsuite not met\n");
1025 : 0 : return TEST_SKIPPED;
1026 : : }
1027 : :
1028 : : return 0;
1029 : : }
1030 : : #endif
1031 : :
1032 : : static int
1033 : 1 : aes_ccm_auth_testsuite_setup(void)
1034 : : {
1035 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1036 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1037 : : struct rte_cryptodev_info dev_info;
1038 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1039 : : RTE_CRYPTO_AEAD_AES_CCM
1040 : : };
1041 : :
1042 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1043 : :
1044 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1045 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1046 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1047 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
1048 : : "testsuite not met\n");
1049 : 0 : return TEST_SKIPPED;
1050 : : }
1051 : :
1052 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1053 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
1054 : : "testsuite not met\n");
1055 : 0 : return TEST_SKIPPED;
1056 : : }
1057 : :
1058 : : return 0;
1059 : : }
1060 : :
1061 : : static int
1062 : 1 : aes_gcm_auth_testsuite_setup(void)
1063 : : {
1064 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1065 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1066 : : struct rte_cryptodev_info dev_info;
1067 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1068 : : RTE_CRYPTO_AEAD_AES_GCM
1069 : : };
1070 : :
1071 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1072 : :
1073 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1074 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
1075 : : "testsuite not met\n");
1076 : 0 : return TEST_SKIPPED;
1077 : : }
1078 : :
1079 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1080 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
1081 : : "testsuite not met\n");
1082 : 0 : return TEST_SKIPPED;
1083 : : }
1084 : :
1085 : : return 0;
1086 : : }
1087 : :
1088 : : static int
1089 : 1 : aes_gmac_auth_testsuite_setup(void)
1090 : : {
1091 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1092 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1093 : : struct rte_cryptodev_info dev_info;
1094 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1095 : : RTE_CRYPTO_AUTH_AES_GMAC
1096 : : };
1097 : :
1098 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1099 : :
1100 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1101 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1102 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1103 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1104 : : "testsuite not met\n");
1105 : 0 : return TEST_SKIPPED;
1106 : : }
1107 : :
1108 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1109 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1110 : : "testsuite not met\n");
1111 : 0 : return TEST_SKIPPED;
1112 : : }
1113 : :
1114 : : return 0;
1115 : : }
1116 : :
1117 : : static int
1118 : 1 : chacha20_poly1305_testsuite_setup(void)
1119 : : {
1120 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1121 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1122 : : struct rte_cryptodev_info dev_info;
1123 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1124 : : RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1125 : : };
1126 : :
1127 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1128 : :
1129 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1130 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1131 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1132 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1133 : : "Chacha20-Poly1305 testsuite not met\n");
1134 : 0 : return TEST_SKIPPED;
1135 : : }
1136 : :
1137 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1138 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1139 : : "Chacha20-Poly1305 testsuite not met\n");
1140 : 1 : return TEST_SKIPPED;
1141 : : }
1142 : :
1143 : : return 0;
1144 : : }
1145 : :
1146 : : static int
1147 : 1 : sm4_gcm_testsuite_setup(void)
1148 : : {
1149 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1150 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1151 : : struct rte_cryptodev_info dev_info;
1152 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1153 : : RTE_CRYPTO_AEAD_SM4_GCM
1154 : : };
1155 : :
1156 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1157 : :
1158 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1159 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1160 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1161 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1162 : : "SM4 GCM testsuite not met\n");
1163 : 0 : return TEST_SKIPPED;
1164 : : }
1165 : :
1166 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1167 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1168 : : "SM4 GCM testsuite not met\n");
1169 : 1 : return TEST_SKIPPED;
1170 : : }
1171 : :
1172 : : return 0;
1173 : : }
1174 : :
1175 : : static int
1176 : 1 : snow3g_testsuite_setup(void)
1177 : : {
1178 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1179 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1180 : : struct rte_cryptodev_info dev_info;
1181 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1182 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1183 : :
1184 : : };
1185 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1186 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2
1187 : : };
1188 : :
1189 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1190 : :
1191 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1192 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1193 : : "testsuite not met\n");
1194 : 0 : return TEST_SKIPPED;
1195 : : }
1196 : :
1197 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1198 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1199 : : RTE_DIM(auths)) != 0) {
1200 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1201 : : "testsuite not met\n");
1202 : 1 : return TEST_SKIPPED;
1203 : : }
1204 : :
1205 : : return 0;
1206 : : }
1207 : :
1208 : : static int
1209 : 1 : zuc_testsuite_setup(void)
1210 : : {
1211 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1212 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1213 : : struct rte_cryptodev_info dev_info;
1214 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1215 : : RTE_CRYPTO_CIPHER_ZUC_EEA3
1216 : : };
1217 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1218 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1219 : : };
1220 : :
1221 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1222 : :
1223 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1224 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1225 : : "testsuite not met\n");
1226 : 0 : return TEST_SKIPPED;
1227 : : }
1228 : :
1229 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1230 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1231 : : RTE_DIM(auths)) != 0) {
1232 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1233 : : "testsuite not met\n");
1234 : 1 : return TEST_SKIPPED;
1235 : : }
1236 : :
1237 : : return 0;
1238 : : }
1239 : :
1240 : : static int
1241 : 1 : hmac_md5_auth_testsuite_setup(void)
1242 : : {
1243 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1244 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1245 : : struct rte_cryptodev_info dev_info;
1246 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1247 : : RTE_CRYPTO_AUTH_MD5_HMAC
1248 : : };
1249 : :
1250 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1251 : :
1252 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1253 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1254 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1255 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1256 : : "Auth testsuite not met\n");
1257 : 0 : return TEST_SKIPPED;
1258 : : }
1259 : :
1260 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1261 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1262 : : "testsuite not met\n");
1263 : 0 : return TEST_SKIPPED;
1264 : : }
1265 : :
1266 : : return 0;
1267 : : }
1268 : :
1269 : : static int
1270 : 1 : kasumi_testsuite_setup(void)
1271 : : {
1272 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1273 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1274 : : struct rte_cryptodev_info dev_info;
1275 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1276 : : RTE_CRYPTO_CIPHER_KASUMI_F8
1277 : : };
1278 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1279 : : RTE_CRYPTO_AUTH_KASUMI_F9
1280 : : };
1281 : :
1282 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1283 : :
1284 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1285 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1286 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1287 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1288 : : "testsuite not met\n");
1289 : 0 : return TEST_SKIPPED;
1290 : : }
1291 : :
1292 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1293 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1294 : : RTE_DIM(auths)) != 0) {
1295 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1296 : : "testsuite not met\n");
1297 : 1 : return TEST_SKIPPED;
1298 : : }
1299 : :
1300 : : return 0;
1301 : : }
1302 : :
1303 : : static int
1304 : 1 : negative_aes_gcm_testsuite_setup(void)
1305 : : {
1306 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1307 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1308 : : struct rte_cryptodev_info dev_info;
1309 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1310 : : RTE_CRYPTO_AEAD_AES_GCM
1311 : : };
1312 : :
1313 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1314 : :
1315 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1316 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1317 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1318 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1319 : : "AES GCM testsuite not met\n");
1320 : 0 : return TEST_SKIPPED;
1321 : : }
1322 : :
1323 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1324 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1325 : : "AES GCM testsuite not met\n");
1326 : 0 : return TEST_SKIPPED;
1327 : : }
1328 : :
1329 : : return 0;
1330 : : }
1331 : :
1332 : : static int
1333 : 1 : negative_aes_gmac_testsuite_setup(void)
1334 : : {
1335 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1336 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1337 : : struct rte_cryptodev_info dev_info;
1338 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1339 : : RTE_CRYPTO_AUTH_AES_GMAC
1340 : : };
1341 : :
1342 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1343 : :
1344 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1345 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1346 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1347 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1348 : : "AES GMAC testsuite not met\n");
1349 : 0 : return TEST_SKIPPED;
1350 : : }
1351 : :
1352 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1353 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1354 : : "AES GMAC testsuite not met\n");
1355 : 0 : return TEST_SKIPPED;
1356 : : }
1357 : :
1358 : : return 0;
1359 : : }
1360 : :
1361 : : static int
1362 : 1 : mixed_cipher_hash_testsuite_setup(void)
1363 : : {
1364 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1365 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1366 : : struct rte_cryptodev_info dev_info;
1367 : : uint64_t feat_flags;
1368 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1369 : : RTE_CRYPTO_CIPHER_NULL,
1370 : : RTE_CRYPTO_CIPHER_AES_CTR,
1371 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
1372 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1373 : : };
1374 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1375 : : RTE_CRYPTO_AUTH_NULL,
1376 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1377 : : RTE_CRYPTO_AUTH_AES_CMAC,
1378 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1379 : : };
1380 : :
1381 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1382 : 1 : feat_flags = dev_info.feature_flags;
1383 : :
1384 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1385 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1386 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1387 : : "Cipher Hash testsuite not met\n");
1388 : 0 : return TEST_SKIPPED;
1389 : : }
1390 : :
1391 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1392 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1393 : : RTE_DIM(auths)) != 0) {
1394 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1395 : : "Cipher Hash testsuite not met\n");
1396 : 0 : return TEST_SKIPPED;
1397 : : }
1398 : :
1399 : : return 0;
1400 : : }
1401 : :
1402 : : static int
1403 : 1 : esn_testsuite_setup(void)
1404 : : {
1405 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1406 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1407 : : struct rte_cryptodev_info dev_info;
1408 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1409 : : RTE_CRYPTO_CIPHER_AES_CBC
1410 : : };
1411 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1412 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1413 : : };
1414 : :
1415 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1416 : :
1417 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1418 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1419 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1420 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1421 : : "testsuite not met\n");
1422 : 0 : return TEST_SKIPPED;
1423 : : }
1424 : :
1425 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1426 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1427 : : RTE_DIM(auths)) != 0) {
1428 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1429 : : "testsuite not met\n");
1430 : 0 : return TEST_SKIPPED;
1431 : : }
1432 : :
1433 : : return 0;
1434 : : }
1435 : :
1436 : : static int
1437 : 1 : multi_session_testsuite_setup(void)
1438 : : {
1439 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1440 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1441 : : struct rte_cryptodev_info dev_info;
1442 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1443 : : RTE_CRYPTO_CIPHER_AES_CBC
1444 : : };
1445 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1446 : : RTE_CRYPTO_AUTH_SHA512_HMAC
1447 : : };
1448 : :
1449 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1450 : :
1451 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1452 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1453 : : "Session testsuite not met\n");
1454 : 0 : return TEST_SKIPPED;
1455 : : }
1456 : :
1457 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1458 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1459 : : RTE_DIM(auths)) != 0) {
1460 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1461 : : "Session testsuite not met\n");
1462 : 0 : return TEST_SKIPPED;
1463 : : }
1464 : :
1465 : : return 0;
1466 : : }
1467 : :
1468 : : static int
1469 : 1 : negative_hmac_sha1_testsuite_setup(void)
1470 : : {
1471 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1472 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1473 : : struct rte_cryptodev_info dev_info;
1474 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1475 : : RTE_CRYPTO_CIPHER_AES_CBC
1476 : : };
1477 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1478 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1479 : : };
1480 : :
1481 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1482 : :
1483 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1484 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1485 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1486 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1487 : : "HMAC SHA1 testsuite not met\n");
1488 : 0 : return TEST_SKIPPED;
1489 : : }
1490 : :
1491 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1492 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1493 : : RTE_DIM(auths)) != 0) {
1494 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1495 : : "HMAC SHA1 testsuite not met\n");
1496 : 0 : return TEST_SKIPPED;
1497 : : }
1498 : :
1499 : : return 0;
1500 : : }
1501 : :
1502 : : static int
1503 : 432 : dev_configure_and_start(uint64_t ff_disable)
1504 : : {
1505 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1506 : : struct crypto_unittest_params *ut_params = &unittest_params;
1507 : :
1508 : : uint16_t qp_id;
1509 : :
1510 : : /* Clear unit test parameters before running test */
1511 : : memset(ut_params, 0, sizeof(*ut_params));
1512 : :
1513 : : /* Reconfigure device to default parameters */
1514 : 432 : ts_params->conf.socket_id = SOCKET_ID_ANY;
1515 : 432 : ts_params->conf.ff_disable = ff_disable;
1516 : 432 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1517 : 432 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
1518 : :
1519 [ - + ]: 432 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1520 : : &ts_params->conf),
1521 : : "Failed to configure cryptodev %u",
1522 : : ts_params->valid_devs[0]);
1523 : :
1524 [ + + ]: 3888 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1525 [ - + ]: 3456 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1526 : : ts_params->valid_devs[0], qp_id,
1527 : : &ts_params->qp_conf,
1528 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1529 : : "Failed to setup queue pair %u on cryptodev %u",
1530 : : qp_id, ts_params->valid_devs[0]);
1531 : : }
1532 : :
1533 : :
1534 : 432 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1535 : :
1536 : : /* Start the device */
1537 [ - + ]: 432 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1538 : : "Failed to start cryptodev %u",
1539 : : ts_params->valid_devs[0]);
1540 : :
1541 : : return TEST_SUCCESS;
1542 : : }
1543 : :
1544 : : int
1545 : 432 : ut_setup(void)
1546 : : {
1547 : : /* Configure and start the device with security feature disabled */
1548 : 432 : return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1549 : : }
1550 : :
1551 : : static int
1552 : 0 : ut_setup_security(void)
1553 : : {
1554 : : /* Configure and start the device with no features disabled */
1555 : 0 : return dev_configure_and_start(0);
1556 : : }
1557 : :
1558 : : static int
1559 : 0 : ut_setup_security_rx_inject(void)
1560 : : {
1561 : 0 : struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1562 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1563 : 0 : struct rte_eth_conf port_conf = {
1564 : : .rxmode = {
1565 : : .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1566 : : RTE_ETH_RX_OFFLOAD_SECURITY,
1567 : : },
1568 : : .txmode = {
1569 : : .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1570 : : },
1571 : : .lpbk_mode = 1, /* Enable loopback */
1572 : : };
1573 : : struct rte_cryptodev_info dev_info;
1574 : 0 : struct rte_eth_rxconf rx_conf = {
1575 : : .rx_thresh = {
1576 : : .pthresh = 8,
1577 : : .hthresh = 8,
1578 : : .wthresh = 8,
1579 : : },
1580 : : .rx_free_thresh = 32,
1581 : : };
1582 : : uint16_t nb_ports;
1583 : : void *sec_ctx;
1584 : : int ret;
1585 : :
1586 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1587 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1588 : : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1589 : 0 : RTE_LOG(INFO, USER1,
1590 : : "Feature requirements for IPsec Rx inject test case not met\n");
1591 : 0 : return TEST_SKIPPED;
1592 : : }
1593 : :
1594 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1595 [ # # ]: 0 : if (sec_ctx == NULL)
1596 : : return TEST_SKIPPED;
1597 : :
1598 : 0 : nb_ports = rte_eth_dev_count_avail();
1599 [ # # ]: 0 : if (nb_ports == 0)
1600 : : return TEST_SKIPPED;
1601 : :
1602 : 0 : ret = rte_eth_dev_configure(0 /* port_id */,
1603 : : 1 /* nb_rx_queue */,
1604 : : 0 /* nb_tx_queue */,
1605 : : &port_conf);
1606 [ # # ]: 0 : if (ret) {
1607 : : printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1608 : 0 : return TEST_SKIPPED;
1609 : : }
1610 : :
1611 : : /* Rx queue setup */
1612 : 0 : ret = rte_eth_rx_queue_setup(0 /* port_id */,
1613 : : 0 /* rx_queue_id */,
1614 : : 1024 /* nb_rx_desc */,
1615 : : SOCKET_ID_ANY,
1616 : : &rx_conf,
1617 : : mbuf_pool);
1618 [ # # ]: 0 : if (ret) {
1619 : : printf("Could not setup eth port 0 queue 0\n");
1620 : 0 : return TEST_SKIPPED;
1621 : : }
1622 : :
1623 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1624 [ # # ]: 0 : if (ret) {
1625 : : printf("Could not enable Rx inject offload");
1626 : 0 : return TEST_SKIPPED;
1627 : : }
1628 : :
1629 : 0 : ret = rte_eth_dev_start(0);
1630 [ # # ]: 0 : if (ret) {
1631 : : printf("Could not start ethdev");
1632 : 0 : return TEST_SKIPPED;
1633 : : }
1634 : :
1635 : 0 : ret = rte_eth_promiscuous_enable(0);
1636 [ # # ]: 0 : if (ret) {
1637 : : printf("Could not enable promiscuous mode");
1638 : 0 : return TEST_SKIPPED;
1639 : : }
1640 : :
1641 : : /* Configure and start cryptodev with no features disabled */
1642 : 0 : return dev_configure_and_start(0);
1643 : : }
1644 : :
1645 : : static inline void
1646 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1647 : : {
1648 : 0 : }
1649 : :
1650 : : static inline void
1651 : 108 : ext_mbuf_memzone_free(int nb_segs)
1652 : : {
1653 : : int i;
1654 : :
1655 [ + + ]: 324 : for (i = 0; i <= nb_segs; i++) {
1656 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1657 : : const struct rte_memzone *memzone;
1658 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1659 : 216 : memzone = rte_memzone_lookup(mz_name);
1660 [ + + ]: 216 : if (memzone != NULL) {
1661 : 2 : rte_memzone_free(memzone);
1662 : : memzone = NULL;
1663 : : }
1664 : : }
1665 : 108 : }
1666 : :
1667 : : static inline struct rte_mbuf *
1668 : 2 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1669 : : int nb_segs, const void *input_text)
1670 : : {
1671 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
1672 : : size_t data_off = 0;
1673 : : uint8_t *dst;
1674 : : int i, size;
1675 : : int t_len;
1676 : :
1677 [ - + ]: 2 : if (pkt_len < 1) {
1678 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1679 : 0 : return NULL;
1680 : : }
1681 : :
1682 [ - + ]: 2 : if (nb_segs < 1) {
1683 : : printf("Number of segments must be 1 or more (is %d)\n",
1684 : : nb_segs);
1685 : 0 : return NULL;
1686 : : }
1687 : :
1688 [ + - ]: 2 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1689 : : size = pkt_len;
1690 : :
1691 : : /* Create chained mbuf_src with external buffer */
1692 [ + + ]: 4 : for (i = 0; size > 0; i++) {
1693 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1694 : 2 : uint16_t data_len = RTE_MIN(size, t_len);
1695 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1696 : : const struct rte_memzone *memzone;
1697 : : void *ext_buf_addr = NULL;
1698 : : rte_iova_t buf_iova;
1699 : 2 : bool freed = false;
1700 : : uint16_t buf_len;
1701 : :
1702 : 2 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1703 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
1704 : :
1705 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1706 : 2 : memzone = rte_memzone_lookup(mz_name);
1707 [ - + - - ]: 2 : if (memzone != NULL && memzone->len != buf_len) {
1708 : 0 : rte_memzone_free(memzone);
1709 : : memzone = NULL;
1710 : : }
1711 [ + - ]: 2 : if (memzone == NULL) {
1712 : 2 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1713 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1714 [ - + ]: 2 : if (memzone == NULL) {
1715 : : printf("Can't allocate memory zone %s\n", mz_name);
1716 : 0 : return NULL;
1717 : : }
1718 : : }
1719 : :
1720 : 2 : ext_buf_addr = memzone->addr;
1721 [ - + ]: 2 : if (input_text)
1722 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1723 : :
1724 : : /* Create buffer to hold rte_mbuf header */
1725 : 2 : m = rte_pktmbuf_alloc(mbuf_pool);
1726 [ + - ]: 2 : if (i == 0)
1727 : : mbuf = m;
1728 : :
1729 [ - + ]: 2 : if (m == NULL) {
1730 : : printf("Cannot create segment for source mbuf");
1731 : 0 : goto fail;
1732 : : }
1733 : :
1734 : : /* Save shared data (like callback function) in external buffer's end */
1735 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1736 : : ext_mbuf_callback_fn_free, &freed);
1737 : : if (ret_shinfo == NULL) {
1738 : : printf("Shared mem initialization failed!\n");
1739 : 0 : goto fail;
1740 : : }
1741 : :
1742 : 2 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
1743 : :
1744 : : /* Attach external buffer to mbuf */
1745 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1746 : : ret_shinfo);
1747 [ - + ]: 2 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1748 : : printf("External buffer is not attached to mbuf\n");
1749 : 0 : goto fail;
1750 : : }
1751 : :
1752 [ - + ]: 2 : if (input_text) {
1753 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1754 [ # # ]: 0 : if (dst == NULL) {
1755 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
1756 : 0 : goto fail;
1757 : : }
1758 : : }
1759 : :
1760 [ - + ]: 2 : if (mbuf != m)
1761 : : rte_pktmbuf_chain(mbuf, m);
1762 : :
1763 : 2 : size -= data_len;
1764 : 2 : data_off += data_len;
1765 : : }
1766 : :
1767 : : return mbuf;
1768 : :
1769 : : fail:
1770 : 0 : rte_pktmbuf_free(mbuf);
1771 : 0 : ext_mbuf_memzone_free(nb_segs);
1772 : 0 : return NULL;
1773 : : }
1774 : :
1775 : : void
1776 : 432 : ut_teardown(void)
1777 : : {
1778 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1779 : : struct crypto_unittest_params *ut_params = &unittest_params;
1780 : :
1781 : : /* free crypto session structure */
1782 : : #ifdef RTE_LIB_SECURITY
1783 [ - + ]: 432 : if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1784 [ # # ]: 0 : if (ut_params->sec_session) {
1785 : 0 : rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1786 : 0 : (ts_params->valid_devs[0]),
1787 : : ut_params->sec_session);
1788 : 0 : ut_params->sec_session = NULL;
1789 : : }
1790 : : } else
1791 : : #endif
1792 : : {
1793 [ + + ]: 432 : if (ut_params->sess) {
1794 : 109 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1795 : : ut_params->sess);
1796 : 109 : ut_params->sess = NULL;
1797 : : }
1798 : : }
1799 : :
1800 : : /* free crypto operation structure */
1801 : 432 : rte_crypto_op_free(ut_params->op);
1802 : :
1803 : : /*
1804 : : * free mbuf - both obuf and ibuf are usually the same,
1805 : : * so check if they point at the same address is necessary,
1806 : : * to avoid freeing the mbuf twice.
1807 : : */
1808 [ + + ]: 432 : if (ut_params->obuf) {
1809 : 6 : rte_pktmbuf_free(ut_params->obuf);
1810 [ + + ]: 6 : if (ut_params->ibuf == ut_params->obuf)
1811 : 3 : ut_params->ibuf = 0;
1812 : 6 : ut_params->obuf = 0;
1813 : : }
1814 [ + + ]: 432 : if (ut_params->ibuf) {
1815 : 108 : ext_mbuf_memzone_free(1);
1816 : 108 : rte_pktmbuf_free(ut_params->ibuf);
1817 : 108 : ut_params->ibuf = 0;
1818 : : }
1819 : :
1820 [ + - ]: 432 : if (ts_params->mbuf_pool != NULL)
1821 : 432 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1822 : : rte_mempool_avail_count(ts_params->mbuf_pool));
1823 : :
1824 : : /* Stop the device */
1825 : 432 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1826 : 432 : }
1827 : :
1828 : : static void
1829 : 0 : ut_teardown_rx_inject(void)
1830 : : {
1831 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1832 : : void *sec_ctx;
1833 : : int ret;
1834 : :
1835 [ # # ]: 0 : if (rte_eth_dev_count_avail() != 0) {
1836 : 0 : ret = rte_eth_dev_reset(0);
1837 [ # # ]: 0 : if (ret)
1838 : : printf("Could not reset eth port 0");
1839 : :
1840 : : }
1841 : :
1842 : 0 : ut_teardown();
1843 : :
1844 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1845 [ # # ]: 0 : if (sec_ctx == NULL)
1846 : : return;
1847 : :
1848 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1849 [ # # ]: 0 : if (ret) {
1850 : : printf("Could not disable Rx inject offload");
1851 : 0 : return;
1852 : : }
1853 : : }
1854 : :
1855 : : static int
1856 : 1 : test_device_configure_invalid_dev_id(void)
1857 : : {
1858 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1859 : : uint16_t dev_id, num_devs = 0;
1860 : :
1861 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1862 : : "Need at least %d devices for test", 1);
1863 : :
1864 : : /* valid dev_id values */
1865 : 1 : dev_id = ts_params->valid_devs[0];
1866 : :
1867 : : /* Stop the device in case it's started so it can be configured */
1868 : 1 : rte_cryptodev_stop(dev_id);
1869 : :
1870 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1871 : : "Failed test for rte_cryptodev_configure: "
1872 : : "invalid dev_num %u", dev_id);
1873 : :
1874 : : /* invalid dev_id values */
1875 : : dev_id = num_devs;
1876 : :
1877 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1878 : : "Failed test for rte_cryptodev_configure: "
1879 : : "invalid dev_num %u", dev_id);
1880 : :
1881 : : dev_id = 0xff;
1882 : :
1883 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1884 : : "Failed test for rte_cryptodev_configure:"
1885 : : "invalid dev_num %u", dev_id);
1886 : :
1887 : : return TEST_SUCCESS;
1888 : : }
1889 : :
1890 : : static int
1891 : 1 : test_device_configure_invalid_queue_pair_ids(void)
1892 : : {
1893 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1894 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1895 : :
1896 : : /* Stop the device in case it's started so it can be configured */
1897 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1898 : :
1899 : : /* valid - max value queue pairs */
1900 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1901 : :
1902 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1903 : : &ts_params->conf),
1904 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1905 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1906 : :
1907 : : /* valid - one queue pairs */
1908 : 1 : ts_params->conf.nb_queue_pairs = 1;
1909 : :
1910 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1911 : : &ts_params->conf),
1912 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1913 : : ts_params->valid_devs[0],
1914 : : ts_params->conf.nb_queue_pairs);
1915 : :
1916 : :
1917 : : /* invalid - zero queue pairs */
1918 : 1 : ts_params->conf.nb_queue_pairs = 0;
1919 : :
1920 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1921 : : &ts_params->conf),
1922 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1923 : : " invalid qps: %u",
1924 : : ts_params->valid_devs[0],
1925 : : ts_params->conf.nb_queue_pairs);
1926 : :
1927 : :
1928 : : /* invalid - max value supported by field queue pairs */
1929 : 1 : ts_params->conf.nb_queue_pairs = UINT16_MAX;
1930 : :
1931 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1932 : : &ts_params->conf),
1933 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1934 : : " invalid qps: %u",
1935 : : ts_params->valid_devs[0],
1936 : : ts_params->conf.nb_queue_pairs);
1937 : :
1938 : :
1939 : : /* invalid - max value + 1 queue pairs */
1940 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1941 : :
1942 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1943 : : &ts_params->conf),
1944 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1945 : : " invalid qps: %u",
1946 : : ts_params->valid_devs[0],
1947 : : ts_params->conf.nb_queue_pairs);
1948 : :
1949 : : /* revert to original testsuite value */
1950 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1951 : :
1952 : 1 : return TEST_SUCCESS;
1953 : : }
1954 : :
1955 : : static int
1956 : 1 : test_queue_pair_descriptor_setup(void)
1957 : : {
1958 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1959 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
1960 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1961 : : };
1962 : : uint16_t qp_id;
1963 : :
1964 : : /* Stop the device in case it's started so it can be configured */
1965 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1966 : :
1967 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1968 : : &ts_params->conf),
1969 : : "Failed to configure cryptodev %u",
1970 : : ts_params->valid_devs[0]);
1971 : :
1972 : : /*
1973 : : * Test various ring sizes on this device. memzones can't be
1974 : : * freed so are re-used if ring is released and re-created.
1975 : : */
1976 : 1 : qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1977 : 1 : qp_conf.mp_session = ts_params->session_mpool;
1978 : :
1979 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1980 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1981 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1982 : : rte_cryptodev_socket_id(
1983 : : ts_params->valid_devs[0])),
1984 : : "Failed test for "
1985 : : "rte_cryptodev_queue_pair_setup: num_inflights "
1986 : : "%u on qp %u on cryptodev %u",
1987 : : qp_conf.nb_descriptors, qp_id,
1988 : : ts_params->valid_devs[0]);
1989 : : }
1990 : :
1991 : 1 : qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1992 : :
1993 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1994 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1995 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1996 : : rte_cryptodev_socket_id(
1997 : : ts_params->valid_devs[0])),
1998 : : "Failed test for"
1999 : : " rte_cryptodev_queue_pair_setup: num_inflights"
2000 : : " %u on qp %u on cryptodev %u",
2001 : : qp_conf.nb_descriptors, qp_id,
2002 : : ts_params->valid_devs[0]);
2003 : : }
2004 : :
2005 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
2006 : :
2007 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
2008 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
2009 : : ts_params->valid_devs[0], qp_id, &qp_conf,
2010 : : rte_cryptodev_socket_id(
2011 : : ts_params->valid_devs[0])),
2012 : : "Failed test for "
2013 : : "rte_cryptodev_queue_pair_setup: num_inflights"
2014 : : " %u on qp %u on cryptodev %u",
2015 : : qp_conf.nb_descriptors, qp_id,
2016 : : ts_params->valid_devs[0]);
2017 : : }
2018 : :
2019 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
2020 : :
2021 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
2022 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
2023 : : ts_params->valid_devs[0], qp_id, &qp_conf,
2024 : : rte_cryptodev_socket_id(
2025 : : ts_params->valid_devs[0])),
2026 : : "Failed test for"
2027 : : " rte_cryptodev_queue_pair_setup:"
2028 : : "num_inflights %u on qp %u on cryptodev %u",
2029 : : qp_conf.nb_descriptors, qp_id,
2030 : : ts_params->valid_devs[0]);
2031 : : }
2032 : :
2033 : : /* test invalid queue pair id */
2034 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
2035 : :
2036 : : qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
2037 : :
2038 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2039 : : ts_params->valid_devs[0],
2040 : : qp_id, &qp_conf,
2041 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2042 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2043 : : "invalid qp %u on cryptodev %u",
2044 : : qp_id, ts_params->valid_devs[0]);
2045 : :
2046 : : qp_id = 0xffff; /*invalid*/
2047 : :
2048 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2049 : : ts_params->valid_devs[0],
2050 : : qp_id, &qp_conf,
2051 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2052 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2053 : : "invalid qp %u on cryptodev %u",
2054 : : qp_id, ts_params->valid_devs[0]);
2055 : :
2056 : : return TEST_SUCCESS;
2057 : : }
2058 : :
2059 : : /* ***** Plaintext data for tests ***** */
2060 : :
2061 : : const char catch_22_quote_1[] =
2062 : : "There was only one catch and that was Catch-22, which "
2063 : : "specified that a concern for one's safety in the face of "
2064 : : "dangers that were real and immediate was the process of a "
2065 : : "rational mind. Orr was crazy and could be grounded. All he "
2066 : : "had to do was ask; and as soon as he did, he would no longer "
2067 : : "be crazy and would have to fly more missions. Orr would be "
2068 : : "crazy to fly more missions and sane if he didn't, but if he "
2069 : : "was sane he had to fly them. If he flew them he was crazy "
2070 : : "and didn't have to; but if he didn't want to he was sane and "
2071 : : "had to. Yossarian was moved very deeply by the absolute "
2072 : : "simplicity of this clause of Catch-22 and let out a "
2073 : : "respectful whistle. \"That's some catch, that Catch-22\", he "
2074 : : "observed. \"It's the best there is,\" Doc Daneeka agreed.";
2075 : :
2076 : : const char catch_22_quote[] =
2077 : : "What a lousy earth! He wondered how many people were "
2078 : : "destitute that same night even in his own prosperous country, "
2079 : : "how many homes were shanties, how many husbands were drunk "
2080 : : "and wives socked, and how many children were bullied, abused, "
2081 : : "or abandoned. How many families hungered for food they could "
2082 : : "not afford to buy? How many hearts were broken? How many "
2083 : : "suicides would take place that same night, how many people "
2084 : : "would go insane? How many cockroaches and landlords would "
2085 : : "triumph? How many winners were losers, successes failures, "
2086 : : "and rich men poor men? How many wise guys were stupid? How "
2087 : : "many happy endings were unhappy endings? How many honest men "
2088 : : "were liars, brave men cowards, loyal men traitors, how many "
2089 : : "sainted men were corrupt, how many people in positions of "
2090 : : "trust had sold their souls to bodyguards, how many had never "
2091 : : "had souls? How many straight-and-narrow paths were crooked "
2092 : : "paths? How many best families were worst families and how "
2093 : : "many good people were bad people? When you added them all up "
2094 : : "and then subtracted, you might be left with only the children, "
2095 : : "and perhaps with Albert Einstein and an old violinist or "
2096 : : "sculptor somewhere.";
2097 : :
2098 : : #define QUOTE_480_BYTES (480)
2099 : : #define QUOTE_512_BYTES (512)
2100 : : #define QUOTE_768_BYTES (768)
2101 : : #define QUOTE_1024_BYTES (1024)
2102 : :
2103 : :
2104 : :
2105 : : /* ***** SHA1 Hash Tests ***** */
2106 : :
2107 : : #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
2108 : :
2109 : : static uint8_t hmac_sha1_key[] = {
2110 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
2111 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
2112 : : 0xDE, 0xF4, 0xDE, 0xAD };
2113 : :
2114 : : /* ***** SHA224 Hash Tests ***** */
2115 : :
2116 : : #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
2117 : :
2118 : :
2119 : : /* ***** AES-CBC Cipher Tests ***** */
2120 : :
2121 : : #define CIPHER_KEY_LENGTH_AES_CBC (16)
2122 : : #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
2123 : :
2124 : : static uint8_t aes_cbc_key[] = {
2125 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2126 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2127 : :
2128 : : static uint8_t aes_cbc_iv[] = {
2129 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2130 : : 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2131 : :
2132 : :
2133 : : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2134 : :
2135 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2136 : : 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2137 : : 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2138 : : 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2139 : : 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2140 : : 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2141 : : 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2142 : : 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2143 : : 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2144 : : 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2145 : : 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2146 : : 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2147 : : 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2148 : : 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2149 : : 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2150 : : 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2151 : : 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2152 : : 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2153 : : 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2154 : : 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2155 : : 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2156 : : 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2157 : : 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2158 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2159 : : 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2160 : : 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2161 : : 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2162 : : 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2163 : : 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2164 : : 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2165 : : 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2166 : : 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2167 : : 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2168 : : 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2169 : : 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2170 : : 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2171 : : 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2172 : : 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2173 : : 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2174 : : 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2175 : : 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2176 : : 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2177 : : 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2178 : : 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2179 : : 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2180 : : 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2181 : : 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2182 : : 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2183 : : 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2184 : : 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2185 : : 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2186 : : 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2187 : : 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2188 : : 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2189 : : 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2190 : : 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2191 : : 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2192 : : 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2193 : : 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2194 : : 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2195 : : 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2196 : : 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2197 : : 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2198 : : 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2199 : : 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2200 : : };
2201 : :
2202 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2203 : : 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2204 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2205 : : 0x18, 0x8c, 0x1d, 0x32
2206 : : };
2207 : :
2208 : :
2209 : : /* Multisession Vector context Test */
2210 : : /*Begin Session 0 */
2211 : : static uint8_t ms_aes_cbc_key0[] = {
2212 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2213 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2214 : : };
2215 : :
2216 : : static uint8_t ms_aes_cbc_iv0[] = {
2217 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2218 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2219 : : };
2220 : :
2221 : : static const uint8_t ms_aes_cbc_cipher0[] = {
2222 : : 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2223 : : 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2224 : : 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2225 : : 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2226 : : 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2227 : : 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2228 : : 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2229 : : 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2230 : : 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2231 : : 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2232 : : 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2233 : : 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2234 : : 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2235 : : 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2236 : : 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2237 : : 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2238 : : 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2239 : : 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2240 : : 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2241 : : 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2242 : : 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2243 : : 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2244 : : 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2245 : : 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2246 : : 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2247 : : 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2248 : : 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2249 : : 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2250 : : 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2251 : : 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2252 : : 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2253 : : 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2254 : : 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2255 : : 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2256 : : 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2257 : : 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2258 : : 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2259 : : 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2260 : : 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2261 : : 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2262 : : 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2263 : : 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2264 : : 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2265 : : 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2266 : : 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2267 : : 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2268 : : 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2269 : : 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2270 : : 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2271 : : 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2272 : : 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2273 : : 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2274 : : 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2275 : : 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2276 : : 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2277 : : 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2278 : : 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2279 : : 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2280 : : 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2281 : : 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2282 : : 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2283 : : 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2284 : : 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2285 : : 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2286 : : };
2287 : :
2288 : :
2289 : : static uint8_t ms_hmac_key0[] = {
2290 : : 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2291 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2292 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2293 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2294 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2295 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2296 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2297 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2298 : : };
2299 : :
2300 : : static const uint8_t ms_hmac_digest0[] = {
2301 : : 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2302 : : 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2303 : : 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2304 : : 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2305 : : 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2306 : : 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2307 : : 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2308 : : 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2309 : : };
2310 : :
2311 : : /* End Session 0 */
2312 : : /* Begin session 1 */
2313 : :
2314 : : static uint8_t ms_aes_cbc_key1[] = {
2315 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2316 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2317 : : };
2318 : :
2319 : : static uint8_t ms_aes_cbc_iv1[] = {
2320 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2321 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2322 : : };
2323 : :
2324 : : static const uint8_t ms_aes_cbc_cipher1[] = {
2325 : : 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2326 : : 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2327 : : 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2328 : : 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2329 : : 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2330 : : 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2331 : : 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2332 : : 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2333 : : 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2334 : : 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2335 : : 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2336 : : 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2337 : : 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2338 : : 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2339 : : 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2340 : : 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2341 : : 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2342 : : 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2343 : : 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2344 : : 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2345 : : 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2346 : : 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2347 : : 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2348 : : 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2349 : : 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2350 : : 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2351 : : 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2352 : : 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2353 : : 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2354 : : 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2355 : : 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2356 : : 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2357 : : 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2358 : : 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2359 : : 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2360 : : 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2361 : : 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2362 : : 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2363 : : 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2364 : : 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2365 : : 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2366 : : 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2367 : : 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2368 : : 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2369 : : 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2370 : : 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2371 : : 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2372 : : 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2373 : : 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2374 : : 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2375 : : 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2376 : : 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2377 : : 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2378 : : 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2379 : : 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2380 : : 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2381 : : 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2382 : : 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2383 : : 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2384 : : 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2385 : : 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2386 : : 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2387 : : 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2388 : : 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2389 : :
2390 : : };
2391 : :
2392 : : static uint8_t ms_hmac_key1[] = {
2393 : : 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2394 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2395 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2396 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2397 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2398 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2399 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2400 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2401 : : };
2402 : :
2403 : : static const uint8_t ms_hmac_digest1[] = {
2404 : : 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2405 : : 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2406 : : 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2407 : : 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2408 : : 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2409 : : 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2410 : : 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2411 : : 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2412 : : };
2413 : : /* End Session 1 */
2414 : : /* Begin Session 2 */
2415 : : static uint8_t ms_aes_cbc_key2[] = {
2416 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2417 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2418 : : };
2419 : :
2420 : : static uint8_t ms_aes_cbc_iv2[] = {
2421 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2422 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2423 : : };
2424 : :
2425 : : static const uint8_t ms_aes_cbc_cipher2[] = {
2426 : : 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2427 : : 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2428 : : 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2429 : : 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2430 : : 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2431 : : 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2432 : : 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2433 : : 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2434 : : 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2435 : : 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2436 : : 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2437 : : 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2438 : : 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2439 : : 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2440 : : 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2441 : : 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2442 : : 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2443 : : 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2444 : : 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2445 : : 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2446 : : 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2447 : : 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2448 : : 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2449 : : 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2450 : : 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2451 : : 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2452 : : 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2453 : : 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2454 : : 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2455 : : 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2456 : : 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2457 : : 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2458 : : 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2459 : : 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2460 : : 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2461 : : 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2462 : : 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2463 : : 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2464 : : 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2465 : : 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2466 : : 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2467 : : 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2468 : : 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2469 : : 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2470 : : 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2471 : : 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2472 : : 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2473 : : 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2474 : : 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2475 : : 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2476 : : 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2477 : : 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2478 : : 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2479 : : 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2480 : : 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2481 : : 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2482 : : 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2483 : : 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2484 : : 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2485 : : 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2486 : : 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2487 : : 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2488 : : 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2489 : : 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2490 : : };
2491 : :
2492 : : static uint8_t ms_hmac_key2[] = {
2493 : : 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2494 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2495 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2496 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2497 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2498 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2499 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2500 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2501 : : };
2502 : :
2503 : : static const uint8_t ms_hmac_digest2[] = {
2504 : : 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2505 : : 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2506 : : 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2507 : : 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2508 : : 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2509 : : 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2510 : : 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2511 : : 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2512 : : };
2513 : :
2514 : : /* End Session 2 */
2515 : :
2516 : : #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
2517 : : static int
2518 : 1 : test_queue_pair_descriptor_count(void)
2519 : : {
2520 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2521 : : struct crypto_unittest_params *ut_params = &unittest_params;
2522 : 1 : struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
2523 : 1 : struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
2524 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2525 : : int qp_depth = 0;
2526 : : int i;
2527 : :
2528 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2529 : : return TEST_SKIPPED;
2530 : :
2531 : : /* Verify if the queue pair depth API is supported by driver */
2532 [ + - ]: 1 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2533 [ # # ]: 0 : if (qp_depth == -ENOTSUP)
2534 : 1 : return TEST_SKIPPED;
2535 : :
2536 : : /* Verify the capabilities */
2537 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2538 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2539 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2540 : : return TEST_SKIPPED;
2541 : :
2542 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2543 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2544 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2545 : : return TEST_SKIPPED;
2546 : :
2547 : : /* Setup Cipher Parameters */
2548 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2549 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2550 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2551 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2552 : 0 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2553 : 0 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2554 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2555 : 0 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2556 : :
2557 : : /* Setup HMAC Parameters */
2558 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2559 : 0 : ut_params->auth_xform.next = NULL;
2560 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2561 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2562 : 0 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2563 : 0 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2564 : 0 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2565 : :
2566 : 0 : rte_errno = 0;
2567 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
2568 : : &ut_params->cipher_xform, ts_params->session_mpool);
2569 [ # # ]: 0 : if (rte_errno == ENOTSUP)
2570 : : return TEST_SKIPPED;
2571 : :
2572 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2573 : :
2574 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
2575 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
2576 : : MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
2577 : :
2578 : : /* Generate crypto op data structure */
2579 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2580 : : struct rte_mbuf *m;
2581 : : uint8_t *digest;
2582 : :
2583 : : /* Generate test mbuf data and space for digest */
2584 : 0 : m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
2585 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
2586 : :
2587 : : digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
2588 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
2589 : :
2590 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
2591 : :
2592 : : /* set crypto operation source mbuf */
2593 : 0 : ops[i]->sym->m_src = m;
2594 : :
2595 : : /* Set crypto operation authentication parameters */
2596 : 0 : ops[i]->sym->auth.digest.data = digest;
2597 : 0 : ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
2598 : :
2599 : 0 : ops[i]->sym->auth.data.offset = 0;
2600 : 0 : ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
2601 : :
2602 : : /* Copy IV at the end of the crypto operation */
2603 : 0 : memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
2604 : : CIPHER_IV_LENGTH_AES_CBC);
2605 : :
2606 : : /* Set crypto operation cipher parameters */
2607 : 0 : ops[i]->sym->cipher.data.offset = 0;
2608 : 0 : ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
2609 : :
2610 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
2611 : : &ops[i], 1), 1, "Error enqueuing");
2612 : : }
2613 : :
2614 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2615 [ # # ]: 0 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2616 [ # # ]: 0 : TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
2617 : : "Crypto queue pair depth used does not match with inflight ops");
2618 : :
2619 : 0 : while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
2620 [ # # ]: 0 : &ops_deq[i], 1) == 0)
2621 : : rte_pause();
2622 : :
2623 [ # # ]: 0 : TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2624 : : "crypto op processing failed");
2625 : :
2626 : 0 : rte_pktmbuf_free(ops_deq[i]->sym->m_src);
2627 : 0 : rte_crypto_op_free(ops_deq[i]);
2628 : : }
2629 : :
2630 : : return TEST_SUCCESS;
2631 : : }
2632 : :
2633 : : static int
2634 : 2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2635 : : {
2636 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2637 : : struct crypto_unittest_params *ut_params = &unittest_params;
2638 : : /* Verify the capabilities */
2639 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2640 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2641 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2642 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2643 : : &cap_idx) == NULL)
2644 : : return TEST_SKIPPED;
2645 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2646 : 2 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2647 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2648 : : &cap_idx) == NULL)
2649 : : return TEST_SKIPPED;
2650 : :
2651 : : /* Generate test mbuf data and space for digest */
2652 : 2 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2653 : : catch_22_quote, QUOTE_512_BYTES, 0);
2654 : :
2655 : 2 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2656 : : DIGEST_BYTE_LENGTH_SHA1);
2657 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2658 : :
2659 : : /* Setup Cipher Parameters */
2660 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2661 : 2 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2662 : :
2663 : 2 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2664 : 2 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2665 : 2 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2666 : 2 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2667 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2668 : 2 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2669 : :
2670 : : /* Setup HMAC Parameters */
2671 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2672 : :
2673 : 2 : ut_params->auth_xform.next = NULL;
2674 : :
2675 : 2 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2676 : 2 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2677 : 2 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2678 : 2 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2679 : 2 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2680 : :
2681 : 2 : rte_errno = 0;
2682 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(
2683 : 2 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2684 : : ts_params->session_mpool);
2685 [ + - ]: 2 : if (rte_errno == ENOTSUP)
2686 : : return TEST_SKIPPED;
2687 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2688 : :
2689 : : /* Generate crypto op data structure */
2690 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2691 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2692 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
2693 : : "Failed to allocate symmetric crypto operation struct");
2694 : :
2695 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2696 : :
2697 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2698 : :
2699 : : /* set crypto operation source mbuf */
2700 : 2 : sym_op->m_src = ut_params->ibuf;
2701 : :
2702 : : /* Set crypto operation authentication parameters */
2703 : 2 : sym_op->auth.digest.data = ut_params->digest;
2704 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2705 : : ut_params->ibuf, QUOTE_512_BYTES);
2706 : :
2707 : 2 : sym_op->auth.data.offset = 0;
2708 : 2 : sym_op->auth.data.length = QUOTE_512_BYTES;
2709 : :
2710 : : /* Copy IV at the end of the crypto operation */
2711 [ - + ]: 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2712 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2713 : :
2714 : : /* Set crypto operation cipher parameters */
2715 : 2 : sym_op->cipher.data.offset = 0;
2716 : 2 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2717 : :
2718 : : /* Process crypto operation */
2719 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2720 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2721 : : ut_params->op);
2722 : : else
2723 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
2724 : : process_crypto_request(ts_params->valid_devs[0],
2725 : : ut_params->op),
2726 : : "failed to process sym crypto op");
2727 : :
2728 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2729 : : "crypto op processing failed");
2730 : :
2731 : : /* Validate obuf */
2732 : 2 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2733 : : uint8_t *);
2734 : :
2735 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2736 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2737 : : QUOTE_512_BYTES,
2738 : : "ciphertext data not as expected");
2739 : :
2740 : 2 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2741 : :
2742 [ + - - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2743 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2744 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2745 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2746 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2747 : : DIGEST_BYTE_LENGTH_SHA1,
2748 : : "Generated digest data not as expected");
2749 : :
2750 : : return TEST_SUCCESS;
2751 : : }
2752 : :
2753 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2754 : :
2755 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2756 : :
2757 : : static uint8_t hmac_sha512_key[] = {
2758 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2759 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2760 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2761 : : 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2762 : : 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2763 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2764 : : 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2765 : : 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2766 : :
2767 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2768 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2769 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2770 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2771 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2772 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2773 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2774 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2775 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2776 : :
2777 : :
2778 : :
2779 : : static int
2780 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2781 : : struct crypto_unittest_params *ut_params,
2782 : : uint8_t *cipher_key,
2783 : : uint8_t *hmac_key);
2784 : :
2785 : : static int
2786 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2787 : : struct crypto_unittest_params *ut_params,
2788 : : struct crypto_testsuite_params *ts_params,
2789 : : const uint8_t *cipher,
2790 : : const uint8_t *digest,
2791 : : const uint8_t *iv);
2792 : :
2793 : :
2794 : : static int
2795 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2796 : : struct crypto_unittest_params *ut_params,
2797 : : uint8_t *cipher_key,
2798 : : uint8_t *hmac_key)
2799 : : {
2800 : :
2801 : : /* Setup Cipher Parameters */
2802 : 4 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2803 : 4 : ut_params->cipher_xform.next = NULL;
2804 : :
2805 : 4 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2806 : 4 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2807 : 4 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2808 : 4 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2809 : 4 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2810 : 4 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2811 : :
2812 : : /* Setup HMAC Parameters */
2813 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2814 : 4 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2815 : :
2816 : 4 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2817 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2818 : 4 : ut_params->auth_xform.auth.key.data = hmac_key;
2819 : 4 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2820 : 4 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2821 : :
2822 : : return TEST_SUCCESS;
2823 : : }
2824 : :
2825 : :
2826 : : static int
2827 : 5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2828 : : struct crypto_unittest_params *ut_params,
2829 : : struct crypto_testsuite_params *ts_params,
2830 : : const uint8_t *cipher,
2831 : : const uint8_t *digest,
2832 : : const uint8_t *iv)
2833 : : {
2834 : : int ret;
2835 : :
2836 : : /* Generate test mbuf data and digest */
2837 : 5 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2838 : : (const char *)
2839 : : cipher,
2840 : : QUOTE_512_BYTES, 0);
2841 : :
2842 : 5 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2843 : : DIGEST_BYTE_LENGTH_SHA512);
2844 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2845 : :
2846 : : rte_memcpy(ut_params->digest,
2847 : : digest,
2848 : : DIGEST_BYTE_LENGTH_SHA512);
2849 : :
2850 : : /* Generate Crypto op data structure */
2851 : 5 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2852 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2853 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->op,
2854 : : "Failed to allocate symmetric crypto operation struct");
2855 : :
2856 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2857 : :
2858 : 5 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2859 : :
2860 : : /* set crypto operation source mbuf */
2861 : 5 : sym_op->m_src = ut_params->ibuf;
2862 : :
2863 : 5 : sym_op->auth.digest.data = ut_params->digest;
2864 [ - + ]: 5 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2865 : : ut_params->ibuf, QUOTE_512_BYTES);
2866 : :
2867 : 5 : sym_op->auth.data.offset = 0;
2868 : 5 : sym_op->auth.data.length = QUOTE_512_BYTES;
2869 : :
2870 : : /* Copy IV at the end of the crypto operation */
2871 [ - + ]: 5 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2872 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2873 : :
2874 : 5 : sym_op->cipher.data.offset = 0;
2875 : 5 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2876 : :
2877 : : /* Process crypto operation */
2878 [ - + ]: 5 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2879 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2880 : : ut_params->op);
2881 [ - + ]: 5 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2882 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2883 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2884 : : return ret;
2885 : : } else
2886 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(
2887 : : process_crypto_request(ts_params->valid_devs[0],
2888 : : ut_params->op),
2889 : : "failed to process sym crypto op");
2890 : :
2891 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2892 : : "crypto op processing failed");
2893 : :
2894 : 5 : ut_params->obuf = ut_params->op->sym->m_src;
2895 : :
2896 : : /* Validate obuf */
2897 [ - + ]: 5 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2898 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2899 : : catch_22_quote,
2900 : : QUOTE_512_BYTES,
2901 : : "Plaintext data not as expected");
2902 : :
2903 : : /* Validate obuf */
2904 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2905 : : "Digest verification failed");
2906 : :
2907 : : return TEST_SUCCESS;
2908 : : }
2909 : :
2910 : : /* ***** SNOW 3G Tests ***** */
2911 : : static int
2912 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2913 : : const uint8_t *key, const uint8_t key_len,
2914 : : const uint8_t iv_len, const uint8_t auth_len,
2915 : : enum rte_crypto_auth_operation op,
2916 : : enum rte_crypto_auth_algorithm algo)
2917 : : {
2918 : 0 : uint8_t *hash_key = alloca(key_len);
2919 : :
2920 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2921 : : struct crypto_unittest_params *ut_params = &unittest_params;
2922 : :
2923 : : memcpy(hash_key, key, key_len);
2924 : :
2925 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2926 : :
2927 : : /* Setup Authentication Parameters */
2928 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2929 : 0 : ut_params->auth_xform.next = NULL;
2930 : :
2931 : 0 : ut_params->auth_xform.auth.op = op;
2932 : 0 : ut_params->auth_xform.auth.algo = algo;
2933 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2934 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2935 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2936 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2937 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2938 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2939 : : &ut_params->auth_xform, ts_params->session_mpool);
2940 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2941 : : return TEST_SKIPPED;
2942 : :
2943 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2944 : : return 0;
2945 : : }
2946 : :
2947 : : static int
2948 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2949 : : enum rte_crypto_cipher_operation op,
2950 : : enum rte_crypto_cipher_algorithm algo,
2951 : : const uint8_t *key, const uint8_t key_len,
2952 : : uint8_t iv_len)
2953 : : {
2954 : 0 : uint8_t *cipher_key = alloca(key_len);
2955 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2956 : : struct crypto_unittest_params *ut_params = &unittest_params;
2957 : :
2958 : : memcpy(cipher_key, key, key_len);
2959 : :
2960 : : /* Setup Cipher Parameters */
2961 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2962 : 0 : ut_params->cipher_xform.next = NULL;
2963 : :
2964 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2965 : 0 : ut_params->cipher_xform.cipher.op = op;
2966 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2967 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2968 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2969 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2970 : :
2971 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2972 : :
2973 : : /* Create Crypto session */
2974 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2975 : : &ut_params->cipher_xform, ts_params->session_mpool);
2976 : :
2977 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2978 : : return TEST_SKIPPED;
2979 : :
2980 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2981 : : return 0;
2982 : : }
2983 : :
2984 : : static int
2985 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2986 : : unsigned int cipher_len,
2987 : : unsigned int cipher_offset)
2988 : : {
2989 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2990 : : struct crypto_unittest_params *ut_params = &unittest_params;
2991 : :
2992 : : /* Generate Crypto op data structure */
2993 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2994 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2995 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2996 : : "Failed to allocate pktmbuf offload");
2997 : :
2998 : : /* Set crypto operation data parameters */
2999 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3000 : :
3001 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3002 : :
3003 : : /* set crypto operation source mbuf */
3004 : 0 : sym_op->m_src = ut_params->ibuf;
3005 : :
3006 : : /* iv */
3007 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3008 : : iv, iv_len);
3009 : 0 : sym_op->cipher.data.length = cipher_len;
3010 : 0 : sym_op->cipher.data.offset = cipher_offset;
3011 : 0 : return 0;
3012 : : }
3013 : :
3014 : : static int
3015 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
3016 : : unsigned int cipher_len,
3017 : : unsigned int cipher_offset)
3018 : : {
3019 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3020 : : struct crypto_unittest_params *ut_params = &unittest_params;
3021 : :
3022 : : /* Generate Crypto op data structure */
3023 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3024 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3025 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3026 : : "Failed to allocate pktmbuf offload");
3027 : :
3028 : : /* Set crypto operation data parameters */
3029 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3030 : :
3031 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3032 : :
3033 : : /* set crypto operation source mbuf */
3034 : 0 : sym_op->m_src = ut_params->ibuf;
3035 : 0 : sym_op->m_dst = ut_params->obuf;
3036 : :
3037 : : /* iv */
3038 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3039 : : iv, iv_len);
3040 : 0 : sym_op->cipher.data.length = cipher_len;
3041 : 0 : sym_op->cipher.data.offset = cipher_offset;
3042 : 0 : return 0;
3043 : : }
3044 : :
3045 : : static int
3046 : 1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
3047 : : enum rte_crypto_cipher_operation cipher_op,
3048 : : enum rte_crypto_auth_operation auth_op,
3049 : : enum rte_crypto_auth_algorithm auth_algo,
3050 : : enum rte_crypto_cipher_algorithm cipher_algo,
3051 : : const uint8_t *a_key, uint8_t a_key_len,
3052 : : const uint8_t *c_key, uint8_t c_key_len,
3053 : : uint8_t auth_iv_len, uint8_t auth_len,
3054 : : uint8_t cipher_iv_len)
3055 : :
3056 : : {
3057 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3058 : : struct crypto_unittest_params *ut_params = &unittest_params;
3059 : :
3060 : : /* Setup Authentication Parameters */
3061 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3062 : 1 : ut_params->auth_xform.next = NULL;
3063 : :
3064 : 1 : ut_params->auth_xform.auth.op = auth_op;
3065 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3066 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3067 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3068 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3069 : : /* Auth IV will be after cipher IV */
3070 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3071 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3072 : :
3073 : : /* Setup Cipher Parameters */
3074 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3075 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3076 : :
3077 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3078 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3079 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3080 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3081 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3082 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3083 : :
3084 : 1 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
3085 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3086 : :
3087 : : /* Create Crypto session*/
3088 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3089 : : &ut_params->cipher_xform, ts_params->session_mpool);
3090 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3091 : : return TEST_SKIPPED;
3092 : :
3093 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3094 : : return 0;
3095 : : }
3096 : :
3097 : : static int
3098 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
3099 : : enum rte_crypto_cipher_operation cipher_op,
3100 : : enum rte_crypto_auth_operation auth_op,
3101 : : enum rte_crypto_auth_algorithm auth_algo,
3102 : : enum rte_crypto_cipher_algorithm cipher_algo,
3103 : : const struct wireless_test_data *tdata)
3104 : : {
3105 : 0 : const uint8_t key_len = tdata->key.len;
3106 : 0 : uint8_t *cipher_auth_key = alloca(key_len);
3107 : :
3108 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3109 : : struct crypto_unittest_params *ut_params = &unittest_params;
3110 : 0 : const uint8_t *key = tdata->key.data;
3111 : 0 : const uint8_t auth_len = tdata->digest.len;
3112 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
3113 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
3114 : :
3115 : : memcpy(cipher_auth_key, key, key_len);
3116 : :
3117 : : /* Setup Authentication Parameters */
3118 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3119 : 0 : ut_params->auth_xform.next = NULL;
3120 : :
3121 : 0 : ut_params->auth_xform.auth.op = auth_op;
3122 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
3123 : 0 : ut_params->auth_xform.auth.key.length = key_len;
3124 : : /* Hash key = cipher key */
3125 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
3126 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
3127 : : /* Auth IV will be after cipher IV */
3128 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3129 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3130 : :
3131 : : /* Setup Cipher Parameters */
3132 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3133 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3134 : :
3135 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3136 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
3137 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
3138 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
3139 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3140 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3141 : :
3142 : :
3143 : 0 : debug_hexdump(stdout, "key:", key, key_len);
3144 : :
3145 : : /* Create Crypto session*/
3146 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3147 : : &ut_params->cipher_xform, ts_params->session_mpool);
3148 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3149 : : return TEST_SKIPPED;
3150 : :
3151 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3152 : : return 0;
3153 : : }
3154 : :
3155 : : static int
3156 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
3157 : : const struct wireless_test_data *tdata)
3158 : : {
3159 : 0 : return create_wireless_cipher_auth_session(dev_id,
3160 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3161 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
3162 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
3163 : : }
3164 : :
3165 : : static int
3166 : 1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
3167 : : enum rte_crypto_cipher_operation cipher_op,
3168 : : enum rte_crypto_auth_operation auth_op,
3169 : : enum rte_crypto_auth_algorithm auth_algo,
3170 : : enum rte_crypto_cipher_algorithm cipher_algo,
3171 : : const uint8_t *a_key, const uint8_t a_key_len,
3172 : : const uint8_t *c_key, const uint8_t c_key_len,
3173 : : uint8_t auth_iv_len, uint8_t auth_len,
3174 : : uint8_t cipher_iv_len)
3175 : : {
3176 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 : : struct crypto_unittest_params *ut_params = &unittest_params;
3178 : :
3179 : : /* Setup Authentication Parameters */
3180 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3181 : 1 : ut_params->auth_xform.auth.op = auth_op;
3182 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
3183 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3184 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3185 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3186 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3187 : : /* Auth IV will be after cipher IV */
3188 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3189 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3190 : :
3191 : : /* Setup Cipher Parameters */
3192 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3193 : 1 : ut_params->cipher_xform.next = NULL;
3194 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3195 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3196 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3197 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3198 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3199 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3200 : :
3201 : 1 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
3202 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3203 : :
3204 : : /* Create Crypto session*/
3205 [ - + ]: 1 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3206 : 0 : ut_params->auth_xform.next = NULL;
3207 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3208 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3209 : : &ut_params->cipher_xform, ts_params->session_mpool);
3210 : : } else
3211 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3212 : : &ut_params->auth_xform, ts_params->session_mpool);
3213 : :
3214 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3215 : : return TEST_SKIPPED;
3216 : :
3217 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3218 : :
3219 : : return 0;
3220 : : }
3221 : :
3222 : : static int
3223 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
3224 : : unsigned int auth_tag_len,
3225 : : const uint8_t *iv, unsigned int iv_len,
3226 : : unsigned int data_pad_len,
3227 : : enum rte_crypto_auth_operation op,
3228 : : unsigned int auth_len, unsigned int auth_offset)
3229 : : {
3230 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3231 : :
3232 : : struct crypto_unittest_params *ut_params = &unittest_params;
3233 : :
3234 : : /* Generate Crypto op data structure */
3235 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3236 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3237 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3238 : : "Failed to allocate pktmbuf offload");
3239 : :
3240 : : /* Set crypto operation data parameters */
3241 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3242 : :
3243 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3244 : :
3245 : : /* set crypto operation source mbuf */
3246 : 0 : sym_op->m_src = ut_params->ibuf;
3247 : :
3248 : : /* iv */
3249 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3250 : : iv, iv_len);
3251 : : /* digest */
3252 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3253 : : ut_params->ibuf, auth_tag_len);
3254 : :
3255 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3256 : : "no room to append auth tag");
3257 : 0 : ut_params->digest = sym_op->auth.digest.data;
3258 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3259 : : ut_params->ibuf, data_pad_len);
3260 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3261 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3262 : : else
3263 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3264 : :
3265 : 0 : debug_hexdump(stdout, "digest:",
3266 : 0 : sym_op->auth.digest.data,
3267 : : auth_tag_len);
3268 : :
3269 : 0 : sym_op->auth.data.length = auth_len;
3270 : 0 : sym_op->auth.data.offset = auth_offset;
3271 : :
3272 : 0 : return 0;
3273 : : }
3274 : :
3275 : : static int
3276 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3277 : : enum rte_crypto_auth_operation op)
3278 : : {
3279 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3280 : : struct crypto_unittest_params *ut_params = &unittest_params;
3281 : :
3282 : 0 : const uint8_t *auth_tag = tdata->digest.data;
3283 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
3284 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3285 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3286 : :
3287 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
3288 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3289 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
3290 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
3291 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3292 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
3293 : :
3294 : : /* Generate Crypto op data structure */
3295 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3296 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3297 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3298 : : "Failed to allocate pktmbuf offload");
3299 : : /* Set crypto operation data parameters */
3300 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3301 : :
3302 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3303 : :
3304 : : /* set crypto operation source mbuf */
3305 : 0 : sym_op->m_src = ut_params->ibuf;
3306 : :
3307 : : /* digest */
3308 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3309 : : ut_params->ibuf, auth_tag_len);
3310 : :
3311 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3312 : : "no room to append auth tag");
3313 : 0 : ut_params->digest = sym_op->auth.digest.data;
3314 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3315 : : ut_params->ibuf, data_pad_len);
3316 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3317 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3318 : : else
3319 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3320 : :
3321 : 0 : debug_hexdump(stdout, "digest:",
3322 : 0 : sym_op->auth.digest.data,
3323 : : auth_tag_len);
3324 : :
3325 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3326 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3327 : : IV_OFFSET);
3328 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3329 : 0 : iv_ptr += cipher_iv_len;
3330 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3331 : :
3332 : 0 : sym_op->cipher.data.length = cipher_len;
3333 : 0 : sym_op->cipher.data.offset = 0;
3334 : 0 : sym_op->auth.data.length = auth_len;
3335 : 0 : sym_op->auth.data.offset = 0;
3336 : :
3337 : 0 : return 0;
3338 : : }
3339 : :
3340 : : static int
3341 : : create_zuc_cipher_hash_generate_operation(
3342 : : const struct wireless_test_data *tdata)
3343 : : {
3344 : 0 : return create_wireless_cipher_hash_operation(tdata,
3345 : : RTE_CRYPTO_AUTH_OP_GENERATE);
3346 : : }
3347 : :
3348 : : static int
3349 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3350 : : const unsigned auth_tag_len,
3351 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3352 : : unsigned data_pad_len,
3353 : : enum rte_crypto_auth_operation op,
3354 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3355 : : const unsigned cipher_len, const unsigned cipher_offset,
3356 : : const unsigned auth_len, const unsigned auth_offset)
3357 : : {
3358 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3359 : : struct crypto_unittest_params *ut_params = &unittest_params;
3360 : :
3361 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
3362 : : ut_params->cipher_xform.cipher.algo;
3363 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3364 : : ut_params->auth_xform.auth.algo;
3365 : :
3366 : : /* Generate Crypto op data structure */
3367 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3368 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3369 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3370 : : "Failed to allocate pktmbuf offload");
3371 : : /* Set crypto operation data parameters */
3372 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3373 : :
3374 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3375 : :
3376 : : /* set crypto operation source mbuf */
3377 : 0 : sym_op->m_src = ut_params->ibuf;
3378 : :
3379 : : /* digest */
3380 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3381 : : ut_params->ibuf, auth_tag_len);
3382 : :
3383 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3384 : : "no room to append auth tag");
3385 : 0 : ut_params->digest = sym_op->auth.digest.data;
3386 : :
3387 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3388 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3389 : : ut_params->ibuf, data_pad_len);
3390 : : } else {
3391 : : struct rte_mbuf *m = ut_params->ibuf;
3392 : : unsigned int offset = data_pad_len;
3393 : :
3394 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3395 : 0 : offset -= m->data_len;
3396 : : m = m->next;
3397 : : }
3398 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3399 : : m, offset);
3400 : : }
3401 : :
3402 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3403 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3404 : : else
3405 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3406 : :
3407 : 0 : debug_hexdump(stdout, "digest:",
3408 : 0 : sym_op->auth.digest.data,
3409 : : auth_tag_len);
3410 : :
3411 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3412 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3413 : : IV_OFFSET);
3414 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3415 : 0 : iv_ptr += cipher_iv_len;
3416 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3417 : :
3418 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3419 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3420 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3421 : 0 : sym_op->cipher.data.length = cipher_len;
3422 : 0 : sym_op->cipher.data.offset = cipher_offset;
3423 : : } else {
3424 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3425 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3426 : : }
3427 : :
3428 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3429 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3430 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3431 : 0 : sym_op->auth.data.length = auth_len;
3432 : 0 : sym_op->auth.data.offset = auth_offset;
3433 : : } else {
3434 : 0 : sym_op->auth.data.length = auth_len >> 3;
3435 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3436 : : }
3437 : :
3438 : : return 0;
3439 : : }
3440 : :
3441 : : static int
3442 : 2 : create_wireless_algo_auth_cipher_operation(
3443 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3444 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3445 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3446 : : unsigned int data_pad_len,
3447 : : unsigned int cipher_len, unsigned int cipher_offset,
3448 : : unsigned int auth_len, unsigned int auth_offset,
3449 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3450 : : {
3451 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3452 : : struct crypto_unittest_params *ut_params = &unittest_params;
3453 : :
3454 : 2 : enum rte_crypto_cipher_algorithm cipher_algo =
3455 : : ut_params->cipher_xform.cipher.algo;
3456 : 2 : enum rte_crypto_auth_algorithm auth_algo =
3457 : : ut_params->auth_xform.auth.algo;
3458 : :
3459 : : /* Generate Crypto op data structure */
3460 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3461 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3462 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
3463 : : "Failed to allocate pktmbuf offload");
3464 : :
3465 : : /* Set crypto operation data parameters */
3466 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3467 : :
3468 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3469 : :
3470 : : /* set crypto operation mbufs */
3471 : 2 : sym_op->m_src = ut_params->ibuf;
3472 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE)
3473 : 0 : sym_op->m_dst = ut_params->obuf;
3474 : :
3475 : : /* digest */
3476 [ - + ]: 2 : if (!do_sgl) {
3477 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3478 : : (op_mode == IN_PLACE ?
3479 : : ut_params->ibuf : ut_params->obuf),
3480 : : uint8_t *, data_pad_len);
3481 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3482 : : (op_mode == IN_PLACE ?
3483 : : ut_params->ibuf : ut_params->obuf),
3484 : : data_pad_len);
3485 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3486 : : } else {
3487 : 2 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3488 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3489 [ - + ]: 2 : sym_op->m_src : sym_op->m_dst);
3490 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3491 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3492 : 30 : sgl_buf = sgl_buf->next;
3493 : : }
3494 : :
3495 : : /* The last segment should be large enough to hold full digest */
3496 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3497 : 0 : rte_pktmbuf_free(sgl_buf->next);
3498 : 0 : sgl_buf->next = NULL;
3499 [ # # # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3500 : : auth_tag_len - sgl_buf->data_len),
3501 : : "No room to append auth tag");
3502 : : }
3503 : :
3504 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3505 : : uint8_t *, remaining_off);
3506 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3507 : : remaining_off);
3508 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3509 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3510 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3511 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3512 : 0 : sgl_buf = sgl_buf->next;
3513 : : }
3514 : : }
3515 : :
3516 : : /* Copy digest for the verification */
3517 [ + + ]: 2 : if (verify)
3518 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3519 : :
3520 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3521 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3522 : : ut_params->op, uint8_t *, IV_OFFSET);
3523 : :
3524 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3525 : 2 : iv_ptr += cipher_iv_len;
3526 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3527 : :
3528 : : /* Only copy over the offset data needed from src to dst in OOP,
3529 : : * if the auth and cipher offsets are not aligned
3530 : : */
3531 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3532 [ # # ]: 0 : if (cipher_offset > auth_offset)
3533 : 0 : rte_memcpy(
3534 : 0 : rte_pktmbuf_mtod_offset(
3535 : : sym_op->m_dst,
3536 : : uint8_t *, auth_offset >> 3),
3537 : 0 : rte_pktmbuf_mtod_offset(
3538 : : sym_op->m_src,
3539 : : uint8_t *, auth_offset >> 3),
3540 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3541 : : }
3542 : :
3543 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3544 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3545 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3546 : 0 : sym_op->cipher.data.length = cipher_len;
3547 : 0 : sym_op->cipher.data.offset = cipher_offset;
3548 : : } else {
3549 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3550 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3551 : : }
3552 : :
3553 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3554 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3555 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3556 : 0 : sym_op->auth.data.length = auth_len;
3557 : 0 : sym_op->auth.data.offset = auth_offset;
3558 : : } else {
3559 : 2 : sym_op->auth.data.length = auth_len >> 3;
3560 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3561 : : }
3562 : :
3563 : : return 0;
3564 : : }
3565 : :
3566 : : static int
3567 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3568 : : {
3569 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3570 : : struct crypto_unittest_params *ut_params = &unittest_params;
3571 : :
3572 : : int retval;
3573 : : unsigned plaintext_pad_len;
3574 : : unsigned plaintext_len;
3575 : : uint8_t *plaintext;
3576 : : struct rte_cryptodev_info dev_info;
3577 : :
3578 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3579 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3580 : :
3581 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3582 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3583 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3584 : 0 : return TEST_SKIPPED;
3585 : : }
3586 : :
3587 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3588 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3589 : : printf("Device doesn't support RAW data-path APIs.\n");
3590 : 0 : return TEST_SKIPPED;
3591 : : }
3592 : :
3593 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3594 : : return TEST_SKIPPED;
3595 : :
3596 : : /* Verify the capabilities */
3597 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3598 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3599 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3600 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3601 : : &cap_idx) == NULL)
3602 : : return TEST_SKIPPED;
3603 : :
3604 : : /* Create SNOW 3G session */
3605 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3606 : 0 : tdata->key.data, tdata->key.len,
3607 : 0 : tdata->auth_iv.len, tdata->digest.len,
3608 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3609 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3610 [ # # ]: 0 : if (retval < 0)
3611 : : return retval;
3612 : :
3613 : : /* alloc mbuf and set payload */
3614 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3615 : :
3616 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3617 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3618 : :
3619 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3620 : : /* Append data which is padded to a multiple of */
3621 : : /* the algorithms block size */
3622 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3623 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3624 : : plaintext_pad_len);
3625 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3626 : :
3627 : : /* Create SNOW 3G operation */
3628 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3629 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3630 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3631 : 0 : tdata->validAuthLenInBits.len,
3632 : : 0);
3633 [ # # ]: 0 : if (retval < 0)
3634 : : return retval;
3635 : :
3636 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3637 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3638 : : 0);
3639 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3640 : : return retval;
3641 : : } else
3642 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3643 : : ut_params->op);
3644 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3645 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3646 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3647 : : uint8_t *,
3648 : : plaintext_pad_len);
3649 : :
3650 : : /* Validate obuf */
3651 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3652 : : ut_params->digest,
3653 : : tdata->digest.data,
3654 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3655 : : "SNOW 3G Generated auth tag not as expected");
3656 : :
3657 : : return 0;
3658 : : }
3659 : :
3660 : : static int
3661 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3662 : : {
3663 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3664 : : struct crypto_unittest_params *ut_params = &unittest_params;
3665 : :
3666 : : int retval;
3667 : : unsigned plaintext_pad_len;
3668 : : unsigned plaintext_len;
3669 : : uint8_t *plaintext;
3670 : : struct rte_cryptodev_info dev_info;
3671 : :
3672 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3673 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3674 : :
3675 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3676 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3677 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3678 : 0 : return TEST_SKIPPED;
3679 : : }
3680 : :
3681 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3682 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3683 : : printf("Device doesn't support RAW data-path APIs.\n");
3684 : 0 : return TEST_SKIPPED;
3685 : : }
3686 : :
3687 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3688 : : return TEST_SKIPPED;
3689 : :
3690 : : /* Verify the capabilities */
3691 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3692 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3693 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3694 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3695 : : &cap_idx) == NULL)
3696 : : return TEST_SKIPPED;
3697 : :
3698 : : /* Create SNOW 3G session */
3699 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3700 : 0 : tdata->key.data, tdata->key.len,
3701 : 0 : tdata->auth_iv.len, tdata->digest.len,
3702 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3703 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3704 [ # # ]: 0 : if (retval < 0)
3705 : : return retval;
3706 : : /* alloc mbuf and set payload */
3707 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3708 : :
3709 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3710 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3711 : :
3712 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3713 : : /* Append data which is padded to a multiple of */
3714 : : /* the algorithms block size */
3715 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3716 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3717 : : plaintext_pad_len);
3718 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3719 : :
3720 : : /* Create SNOW 3G operation */
3721 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3722 : 0 : tdata->digest.len,
3723 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3724 : : plaintext_pad_len,
3725 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3726 : 0 : tdata->validAuthLenInBits.len,
3727 : : 0);
3728 [ # # ]: 0 : if (retval < 0)
3729 : : return retval;
3730 : :
3731 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3732 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3733 : : 0);
3734 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3735 : : return retval;
3736 : : } else
3737 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3738 : : ut_params->op);
3739 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3740 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3741 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3742 : : uint8_t *,
3743 : : plaintext_pad_len);
3744 : :
3745 : : /* Validate obuf */
3746 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3747 : : return 0;
3748 : : else
3749 : 0 : return -1;
3750 : :
3751 : : return 0;
3752 : : }
3753 : :
3754 : : static int
3755 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3756 : : {
3757 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3758 : : struct crypto_unittest_params *ut_params = &unittest_params;
3759 : :
3760 : : int retval;
3761 : : unsigned plaintext_pad_len;
3762 : : unsigned plaintext_len;
3763 : : uint8_t *plaintext;
3764 : : struct rte_cryptodev_info dev_info;
3765 : :
3766 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3767 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3768 : :
3769 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3770 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3771 : : printf("Device doesn't support RAW data-path APIs.\n");
3772 : 0 : return TEST_SKIPPED;
3773 : : }
3774 : :
3775 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3776 : : return TEST_SKIPPED;
3777 : :
3778 : : /* Verify the capabilities */
3779 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3780 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3781 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3782 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3783 : : &cap_idx) == NULL)
3784 : : return TEST_SKIPPED;
3785 : :
3786 : : /* Create KASUMI session */
3787 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3788 : 0 : tdata->key.data, tdata->key.len,
3789 : 0 : 0, tdata->digest.len,
3790 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3791 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3792 [ # # ]: 0 : if (retval < 0)
3793 : : return retval;
3794 : :
3795 : : /* alloc mbuf and set payload */
3796 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3797 : :
3798 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3799 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3800 : :
3801 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3802 : : /* Append data which is padded to a multiple of */
3803 : : /* the algorithms block size */
3804 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3805 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3806 : : plaintext_pad_len);
3807 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3808 : :
3809 : : /* Create KASUMI operation */
3810 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3811 : : NULL, 0,
3812 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3813 : 0 : tdata->plaintext.len,
3814 : : 0);
3815 [ # # ]: 0 : if (retval < 0)
3816 : : return retval;
3817 : :
3818 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3819 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3820 : : ut_params->op);
3821 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3822 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3823 : : 0);
3824 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3825 : : return retval;
3826 : : } else
3827 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3828 : : ut_params->op);
3829 : :
3830 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3831 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3832 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3833 : : uint8_t *,
3834 : : plaintext_pad_len);
3835 : :
3836 : : /* Validate obuf */
3837 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3838 : : ut_params->digest,
3839 : : tdata->digest.data,
3840 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3841 : : "KASUMI Generated auth tag not as expected");
3842 : :
3843 : : return 0;
3844 : : }
3845 : :
3846 : : static int
3847 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3848 : : {
3849 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3850 : : struct crypto_unittest_params *ut_params = &unittest_params;
3851 : :
3852 : : int retval;
3853 : : unsigned plaintext_pad_len;
3854 : : unsigned plaintext_len;
3855 : : uint8_t *plaintext;
3856 : : struct rte_cryptodev_info dev_info;
3857 : :
3858 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3859 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3860 : :
3861 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3862 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3863 : : printf("Device doesn't support RAW data-path APIs.\n");
3864 : 0 : return TEST_SKIPPED;
3865 : : }
3866 : :
3867 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3868 : : return TEST_SKIPPED;
3869 : :
3870 : : /* Verify the capabilities */
3871 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3872 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3873 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3874 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3875 : : &cap_idx) == NULL)
3876 : : return TEST_SKIPPED;
3877 : :
3878 : : /* Create KASUMI session */
3879 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3880 : 0 : tdata->key.data, tdata->key.len,
3881 : 0 : 0, tdata->digest.len,
3882 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3883 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3884 [ # # ]: 0 : if (retval < 0)
3885 : : return retval;
3886 : : /* alloc mbuf and set payload */
3887 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3888 : :
3889 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3890 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3891 : :
3892 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3893 : : /* Append data which is padded to a multiple */
3894 : : /* of the algorithms block size */
3895 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3896 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3897 : : plaintext_pad_len);
3898 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3899 : :
3900 : : /* Create KASUMI operation */
3901 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3902 : 0 : tdata->digest.len,
3903 : : NULL, 0,
3904 : : plaintext_pad_len,
3905 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3906 : 0 : tdata->plaintext.len,
3907 : : 0);
3908 [ # # ]: 0 : if (retval < 0)
3909 : : return retval;
3910 : :
3911 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3912 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3913 : : 0);
3914 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3915 : : return retval;
3916 : : } else
3917 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3918 : : ut_params->op);
3919 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3920 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3921 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3922 : : uint8_t *,
3923 : : plaintext_pad_len);
3924 : :
3925 : : /* Validate obuf */
3926 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3927 : : return 0;
3928 : : else
3929 : 0 : return -1;
3930 : :
3931 : : return 0;
3932 : : }
3933 : :
3934 : : static int
3935 : 0 : test_snow3g_hash_generate_test_case_1(void)
3936 : : {
3937 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3938 : : }
3939 : :
3940 : : static int
3941 : 0 : test_snow3g_hash_generate_test_case_2(void)
3942 : : {
3943 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3944 : : }
3945 : :
3946 : : static int
3947 : 0 : test_snow3g_hash_generate_test_case_3(void)
3948 : : {
3949 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3950 : : }
3951 : :
3952 : : static int
3953 : 0 : test_snow3g_hash_generate_test_case_4(void)
3954 : : {
3955 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3956 : : }
3957 : :
3958 : : static int
3959 : 0 : test_snow3g_hash_generate_test_case_5(void)
3960 : : {
3961 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3962 : : }
3963 : :
3964 : : static int
3965 : 0 : test_snow3g_hash_generate_test_case_6(void)
3966 : : {
3967 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3968 : : }
3969 : :
3970 : : static int
3971 : 0 : test_snow3g_hash_verify_test_case_1(void)
3972 : : {
3973 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3974 : :
3975 : : }
3976 : :
3977 : : static int
3978 : 0 : test_snow3g_hash_verify_test_case_2(void)
3979 : : {
3980 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3981 : : }
3982 : :
3983 : : static int
3984 : 0 : test_snow3g_hash_verify_test_case_3(void)
3985 : : {
3986 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3987 : : }
3988 : :
3989 : : static int
3990 : 0 : test_snow3g_hash_verify_test_case_4(void)
3991 : : {
3992 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3993 : : }
3994 : :
3995 : : static int
3996 : 0 : test_snow3g_hash_verify_test_case_5(void)
3997 : : {
3998 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3999 : : }
4000 : :
4001 : : static int
4002 : 0 : test_snow3g_hash_verify_test_case_6(void)
4003 : : {
4004 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
4005 : : }
4006 : :
4007 : : static int
4008 : 0 : test_kasumi_hash_generate_test_case_1(void)
4009 : : {
4010 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
4011 : : }
4012 : :
4013 : : static int
4014 : 0 : test_kasumi_hash_generate_test_case_2(void)
4015 : : {
4016 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
4017 : : }
4018 : :
4019 : : static int
4020 : 0 : test_kasumi_hash_generate_test_case_3(void)
4021 : : {
4022 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
4023 : : }
4024 : :
4025 : : static int
4026 : 0 : test_kasumi_hash_generate_test_case_4(void)
4027 : : {
4028 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
4029 : : }
4030 : :
4031 : : static int
4032 : 0 : test_kasumi_hash_generate_test_case_5(void)
4033 : : {
4034 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
4035 : : }
4036 : :
4037 : : static int
4038 : 0 : test_kasumi_hash_generate_test_case_6(void)
4039 : : {
4040 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
4041 : : }
4042 : :
4043 : : static int
4044 : 0 : test_kasumi_hash_verify_test_case_1(void)
4045 : : {
4046 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
4047 : : }
4048 : :
4049 : : static int
4050 : 0 : test_kasumi_hash_verify_test_case_2(void)
4051 : : {
4052 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
4053 : : }
4054 : :
4055 : : static int
4056 : 0 : test_kasumi_hash_verify_test_case_3(void)
4057 : : {
4058 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
4059 : : }
4060 : :
4061 : : static int
4062 : 0 : test_kasumi_hash_verify_test_case_4(void)
4063 : : {
4064 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
4065 : : }
4066 : :
4067 : : static int
4068 : 0 : test_kasumi_hash_verify_test_case_5(void)
4069 : : {
4070 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
4071 : : }
4072 : :
4073 : : static int
4074 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
4075 : : {
4076 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4077 : : struct crypto_unittest_params *ut_params = &unittest_params;
4078 : :
4079 : : int retval;
4080 : : uint8_t *plaintext, *ciphertext;
4081 : : unsigned plaintext_pad_len;
4082 : : unsigned plaintext_len;
4083 : : struct rte_cryptodev_info dev_info;
4084 : :
4085 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4086 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4087 : :
4088 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4089 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4090 : : printf("Device doesn't support RAW data-path APIs.\n");
4091 : 0 : return TEST_SKIPPED;
4092 : : }
4093 : :
4094 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4095 : : return TEST_SKIPPED;
4096 : :
4097 : : /* Verify the capabilities */
4098 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4099 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4100 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4101 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4102 : : &cap_idx) == NULL)
4103 : : return TEST_SKIPPED;
4104 : :
4105 : : /* Create KASUMI session */
4106 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4107 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4108 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4109 : 0 : tdata->key.data, tdata->key.len,
4110 : 0 : tdata->cipher_iv.len);
4111 [ # # ]: 0 : if (retval < 0)
4112 : : return retval;
4113 : :
4114 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4115 : :
4116 : : /* Clear mbuf payload */
4117 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4118 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4119 : :
4120 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4121 : : /* Append data which is padded to a multiple */
4122 : : /* of the algorithms block size */
4123 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4124 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4125 : : plaintext_pad_len);
4126 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4127 : :
4128 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4129 : :
4130 : : /* Create KASUMI operation */
4131 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4132 : 0 : tdata->cipher_iv.len,
4133 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4134 : 0 : tdata->validCipherOffsetInBits.len);
4135 [ # # ]: 0 : if (retval < 0)
4136 : : return retval;
4137 : :
4138 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4139 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4140 : 0 : tdata->cipher_iv.len);
4141 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4142 : : return retval;
4143 : : } else
4144 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4145 : : ut_params->op);
4146 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4147 : :
4148 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4149 [ # # ]: 0 : if (ut_params->obuf)
4150 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4151 : : else
4152 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4153 : :
4154 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4155 : :
4156 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4157 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4158 : : /* Validate obuf */
4159 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4160 : : ciphertext,
4161 : : reference_ciphertext,
4162 : : tdata->validCipherLenInBits.len,
4163 : : "KASUMI Ciphertext data not as expected");
4164 : : return 0;
4165 : : }
4166 : :
4167 : : static int
4168 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4169 : : {
4170 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4171 : : struct crypto_unittest_params *ut_params = &unittest_params;
4172 : :
4173 : : int retval;
4174 : :
4175 : : unsigned int plaintext_pad_len;
4176 : : unsigned int plaintext_len;
4177 : :
4178 : : uint8_t buffer[10000];
4179 : : const uint8_t *ciphertext;
4180 : :
4181 : : struct rte_cryptodev_info dev_info;
4182 : :
4183 : : /* Verify the capabilities */
4184 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4185 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4186 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4187 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4188 : : &cap_idx) == NULL)
4189 : : return TEST_SKIPPED;
4190 : :
4191 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4192 : :
4193 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4194 : :
4195 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4196 : : printf("Device doesn't support in-place scatter-gather. "
4197 : : "Test Skipped.\n");
4198 : 0 : return TEST_SKIPPED;
4199 : : }
4200 : :
4201 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4202 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4203 : : printf("Device doesn't support RAW data-path APIs.\n");
4204 : 0 : return TEST_SKIPPED;
4205 : : }
4206 : :
4207 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4208 : : return TEST_SKIPPED;
4209 : :
4210 : : /* Create KASUMI session */
4211 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4212 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4213 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4214 : 0 : tdata->key.data, tdata->key.len,
4215 : 0 : tdata->cipher_iv.len);
4216 [ # # ]: 0 : if (retval < 0)
4217 : : return retval;
4218 : :
4219 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4220 : :
4221 : :
4222 : : /* Append data which is padded to a multiple */
4223 : : /* of the algorithms block size */
4224 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4225 : :
4226 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4227 : : plaintext_pad_len, 10, 0);
4228 : :
4229 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4230 : :
4231 : : /* Create KASUMI operation */
4232 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4233 : 0 : tdata->cipher_iv.len,
4234 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4235 : 0 : tdata->validCipherOffsetInBits.len);
4236 [ # # ]: 0 : if (retval < 0)
4237 : : return retval;
4238 : :
4239 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4240 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4241 : 0 : tdata->cipher_iv.len);
4242 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4243 : : return retval;
4244 : : } else
4245 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4246 : : ut_params->op);
4247 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4248 : :
4249 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4250 : :
4251 [ # # ]: 0 : if (ut_params->obuf)
4252 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4253 : : plaintext_len, buffer);
4254 : : else
4255 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4256 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4257 : : plaintext_len, buffer);
4258 : :
4259 : : /* Validate obuf */
4260 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4261 : :
4262 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4263 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4264 : : /* Validate obuf */
4265 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4266 : : ciphertext,
4267 : : reference_ciphertext,
4268 : : tdata->validCipherLenInBits.len,
4269 : : "KASUMI Ciphertext data not as expected");
4270 : : return 0;
4271 : : }
4272 : :
4273 : : static int
4274 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4275 : : {
4276 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4277 : : struct crypto_unittest_params *ut_params = &unittest_params;
4278 : :
4279 : : int retval;
4280 : : uint8_t *plaintext, *ciphertext;
4281 : : unsigned plaintext_pad_len;
4282 : : unsigned plaintext_len;
4283 : :
4284 : : /* Verify the capabilities */
4285 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4286 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4287 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4288 : : /* Data-path service does not support OOP */
4289 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4290 : : &cap_idx) == NULL)
4291 : : return TEST_SKIPPED;
4292 : :
4293 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4294 : : return TEST_SKIPPED;
4295 : :
4296 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4297 : : return TEST_SKIPPED;
4298 : :
4299 : : /* Create KASUMI session */
4300 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4301 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4302 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4303 : 0 : tdata->key.data, tdata->key.len,
4304 : 0 : tdata->cipher_iv.len);
4305 [ # # ]: 0 : if (retval < 0)
4306 : : return retval;
4307 : :
4308 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4309 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4310 : :
4311 : : /* Clear mbuf payload */
4312 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4313 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4314 : :
4315 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4316 : : /* Append data which is padded to a multiple */
4317 : : /* of the algorithms block size */
4318 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4319 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4320 : : plaintext_pad_len);
4321 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4322 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4323 : :
4324 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4325 : :
4326 : : /* Create KASUMI operation */
4327 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4328 : 0 : tdata->cipher_iv.len,
4329 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4330 : 0 : tdata->validCipherOffsetInBits.len);
4331 [ # # ]: 0 : if (retval < 0)
4332 : : return retval;
4333 : :
4334 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4335 : : ut_params->op);
4336 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4337 : :
4338 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4339 [ # # ]: 0 : if (ut_params->obuf)
4340 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4341 : : else
4342 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4343 : :
4344 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4345 : :
4346 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4347 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4348 : : /* Validate obuf */
4349 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4350 : : ciphertext,
4351 : : reference_ciphertext,
4352 : : tdata->validCipherLenInBits.len,
4353 : : "KASUMI Ciphertext data not as expected");
4354 : : return 0;
4355 : : }
4356 : :
4357 : : static int
4358 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4359 : : {
4360 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4361 : : struct crypto_unittest_params *ut_params = &unittest_params;
4362 : :
4363 : : int retval;
4364 : : unsigned int plaintext_pad_len;
4365 : : unsigned int plaintext_len;
4366 : :
4367 : : const uint8_t *ciphertext;
4368 : : uint8_t buffer[2048];
4369 : :
4370 : : struct rte_cryptodev_info dev_info;
4371 : :
4372 : : /* Verify the capabilities */
4373 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4374 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4375 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4376 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4377 : : &cap_idx) == NULL)
4378 : : return TEST_SKIPPED;
4379 : :
4380 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4381 : : return TEST_SKIPPED;
4382 : :
4383 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4384 : : return TEST_SKIPPED;
4385 : :
4386 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4387 : :
4388 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4389 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4390 : : printf("Device doesn't support out-of-place scatter-gather "
4391 : : "in both input and output mbufs. "
4392 : : "Test Skipped.\n");
4393 : 0 : return TEST_SKIPPED;
4394 : : }
4395 : :
4396 : : /* Create KASUMI session */
4397 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4398 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4399 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4400 : 0 : tdata->key.data, tdata->key.len,
4401 : 0 : tdata->cipher_iv.len);
4402 [ # # ]: 0 : if (retval < 0)
4403 : : return retval;
4404 : :
4405 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4406 : : /* Append data which is padded to a multiple */
4407 : : /* of the algorithms block size */
4408 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4409 : :
4410 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4411 : : plaintext_pad_len, 10, 0);
4412 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4413 : : plaintext_pad_len, 3, 0);
4414 : :
4415 : : /* Append data which is padded to a multiple */
4416 : : /* of the algorithms block size */
4417 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4418 : :
4419 : : /* Create KASUMI operation */
4420 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4421 : 0 : tdata->cipher_iv.len,
4422 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4423 : 0 : tdata->validCipherOffsetInBits.len);
4424 [ # # ]: 0 : if (retval < 0)
4425 : : return retval;
4426 : :
4427 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4428 : : ut_params->op);
4429 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4430 : :
4431 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4432 [ # # ]: 0 : if (ut_params->obuf)
4433 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4434 : : plaintext_pad_len, buffer);
4435 : : else
4436 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4437 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4438 : : plaintext_pad_len, buffer);
4439 : :
4440 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4441 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4442 : : /* Validate obuf */
4443 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4444 : : ciphertext,
4445 : : reference_ciphertext,
4446 : : tdata->validCipherLenInBits.len,
4447 : : "KASUMI Ciphertext data not as expected");
4448 : : return 0;
4449 : : }
4450 : :
4451 : :
4452 : : static int
4453 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4454 : : {
4455 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4456 : : struct crypto_unittest_params *ut_params = &unittest_params;
4457 : :
4458 : : int retval;
4459 : : uint8_t *ciphertext, *plaintext;
4460 : : unsigned ciphertext_pad_len;
4461 : : unsigned ciphertext_len;
4462 : :
4463 : : /* Verify the capabilities */
4464 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4465 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4466 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4467 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4468 : : &cap_idx) == NULL)
4469 : : return TEST_SKIPPED;
4470 : :
4471 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4472 : : return TEST_SKIPPED;
4473 : :
4474 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4475 : : return TEST_SKIPPED;
4476 : :
4477 : : /* Create KASUMI session */
4478 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4479 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4480 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4481 : 0 : tdata->key.data, tdata->key.len,
4482 : 0 : tdata->cipher_iv.len);
4483 [ # # ]: 0 : if (retval < 0)
4484 : : return retval;
4485 : :
4486 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4487 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4488 : :
4489 : : /* Clear mbuf payload */
4490 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4491 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4492 : :
4493 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4494 : : /* Append data which is padded to a multiple */
4495 : : /* of the algorithms block size */
4496 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4497 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4498 : : ciphertext_pad_len);
4499 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4500 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4501 : :
4502 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4503 : :
4504 : : /* Create KASUMI operation */
4505 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4506 : 0 : tdata->cipher_iv.len,
4507 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4508 : 0 : tdata->validCipherOffsetInBits.len);
4509 [ # # ]: 0 : if (retval < 0)
4510 : : return retval;
4511 : :
4512 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4513 : : ut_params->op);
4514 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4515 : :
4516 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4517 [ # # ]: 0 : if (ut_params->obuf)
4518 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4519 : : else
4520 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4521 : :
4522 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4523 : :
4524 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4525 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4526 : : /* Validate obuf */
4527 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4528 : : plaintext,
4529 : : reference_plaintext,
4530 : : tdata->validCipherLenInBits.len,
4531 : : "KASUMI Plaintext data not as expected");
4532 : : return 0;
4533 : : }
4534 : :
4535 : : static int
4536 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4537 : : {
4538 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4539 : : struct crypto_unittest_params *ut_params = &unittest_params;
4540 : :
4541 : : int retval;
4542 : : uint8_t *ciphertext, *plaintext;
4543 : : unsigned ciphertext_pad_len;
4544 : : unsigned ciphertext_len;
4545 : : struct rte_cryptodev_info dev_info;
4546 : :
4547 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4548 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4549 : :
4550 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4551 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4552 : : printf("Device doesn't support RAW data-path APIs.\n");
4553 : 0 : return TEST_SKIPPED;
4554 : : }
4555 : :
4556 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4557 : : return TEST_SKIPPED;
4558 : :
4559 : : /* Verify the capabilities */
4560 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4561 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4562 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4563 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4564 : : &cap_idx) == NULL)
4565 : : return TEST_SKIPPED;
4566 : :
4567 : : /* Create KASUMI session */
4568 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4569 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4570 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4571 : 0 : tdata->key.data, tdata->key.len,
4572 : 0 : tdata->cipher_iv.len);
4573 [ # # ]: 0 : if (retval < 0)
4574 : : return retval;
4575 : :
4576 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4577 : :
4578 : : /* Clear mbuf payload */
4579 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4580 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4581 : :
4582 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4583 : : /* Append data which is padded to a multiple */
4584 : : /* of the algorithms block size */
4585 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4586 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4587 : : ciphertext_pad_len);
4588 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4589 : :
4590 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4591 : :
4592 : : /* Create KASUMI operation */
4593 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4594 : 0 : tdata->cipher_iv.len,
4595 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4596 : 0 : tdata->validCipherOffsetInBits.len);
4597 [ # # ]: 0 : if (retval < 0)
4598 : : return retval;
4599 : :
4600 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4601 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4602 : : 0);
4603 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4604 : : return retval;
4605 : : } else
4606 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4607 : : ut_params->op);
4608 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4609 : :
4610 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4611 [ # # ]: 0 : if (ut_params->obuf)
4612 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4613 : : else
4614 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4615 : :
4616 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4617 : :
4618 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4619 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4620 : : /* Validate obuf */
4621 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4622 : : plaintext,
4623 : : reference_plaintext,
4624 : : tdata->validCipherLenInBits.len,
4625 : : "KASUMI Plaintext data not as expected");
4626 : : return 0;
4627 : : }
4628 : :
4629 : : static int
4630 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4631 : : {
4632 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4633 : : struct crypto_unittest_params *ut_params = &unittest_params;
4634 : :
4635 : : int retval;
4636 : : uint8_t *plaintext, *ciphertext;
4637 : : unsigned plaintext_pad_len;
4638 : : unsigned plaintext_len;
4639 : : struct rte_cryptodev_info dev_info;
4640 : :
4641 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4642 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4643 : :
4644 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4645 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4646 : : printf("Device doesn't support RAW data-path APIs.\n");
4647 : 0 : return TEST_SKIPPED;
4648 : : }
4649 : :
4650 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4651 : : return TEST_SKIPPED;
4652 : :
4653 : : /* Verify the capabilities */
4654 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4655 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4656 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4657 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4658 : : &cap_idx) == NULL)
4659 : : return TEST_SKIPPED;
4660 : :
4661 : : /* Create SNOW 3G session */
4662 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4663 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4664 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4665 : 0 : tdata->key.data, tdata->key.len,
4666 : 0 : tdata->cipher_iv.len);
4667 [ # # ]: 0 : if (retval < 0)
4668 : : return retval;
4669 : :
4670 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4671 : :
4672 : : /* Clear mbuf payload */
4673 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4674 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4675 : :
4676 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4677 : : /* Append data which is padded to a multiple of */
4678 : : /* the algorithms block size */
4679 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4680 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4681 : : plaintext_pad_len);
4682 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4683 : :
4684 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4685 : :
4686 : : /* Create SNOW 3G operation */
4687 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4688 : 0 : tdata->cipher_iv.len,
4689 : 0 : tdata->validCipherLenInBits.len,
4690 : : 0);
4691 [ # # ]: 0 : if (retval < 0)
4692 : : return retval;
4693 : :
4694 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4695 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4696 : 0 : tdata->cipher_iv.len);
4697 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4698 : : return retval;
4699 : : } else
4700 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4701 : : ut_params->op);
4702 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4703 : :
4704 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4705 [ # # ]: 0 : if (ut_params->obuf)
4706 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4707 : : else
4708 : : ciphertext = plaintext;
4709 : :
4710 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4711 : :
4712 : : /* Validate obuf */
4713 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4714 : : ciphertext,
4715 : : tdata->ciphertext.data,
4716 : : tdata->validDataLenInBits.len,
4717 : : "SNOW 3G Ciphertext data not as expected");
4718 : : return 0;
4719 : : }
4720 : :
4721 : :
4722 : : static int
4723 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4724 : : {
4725 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4726 : : struct crypto_unittest_params *ut_params = &unittest_params;
4727 : : uint8_t *plaintext, *ciphertext;
4728 : :
4729 : : int retval;
4730 : : unsigned plaintext_pad_len;
4731 : : unsigned plaintext_len;
4732 : : struct rte_cryptodev_info dev_info;
4733 : :
4734 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4735 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4736 : :
4737 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4738 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4739 : : printf("Device does not support RAW data-path APIs.\n");
4740 : 0 : return -ENOTSUP;
4741 : : }
4742 : :
4743 : : /* Verify the capabilities */
4744 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4745 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4746 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4747 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4748 : : &cap_idx) == NULL)
4749 : : return TEST_SKIPPED;
4750 : :
4751 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4752 : : return TEST_SKIPPED;
4753 : :
4754 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4755 : : return TEST_SKIPPED;
4756 : :
4757 : : /* Create SNOW 3G session */
4758 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4759 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4760 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4761 : 0 : tdata->key.data, tdata->key.len,
4762 : 0 : tdata->cipher_iv.len);
4763 [ # # ]: 0 : if (retval < 0)
4764 : : return retval;
4765 : :
4766 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4767 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4768 : :
4769 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4770 : : "Failed to allocate input buffer in mempool");
4771 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4772 : : "Failed to allocate output buffer in mempool");
4773 : :
4774 : : /* Clear mbuf payload */
4775 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4776 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4777 : :
4778 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4779 : : /* Append data which is padded to a multiple of */
4780 : : /* the algorithms block size */
4781 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4782 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4783 : : plaintext_pad_len);
4784 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4785 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4786 : :
4787 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4788 : :
4789 : : /* Create SNOW 3G operation */
4790 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4791 : 0 : tdata->cipher_iv.len,
4792 : 0 : tdata->validCipherLenInBits.len,
4793 : : 0);
4794 [ # # ]: 0 : if (retval < 0)
4795 : : return retval;
4796 : :
4797 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4798 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4799 : 0 : tdata->cipher_iv.len);
4800 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4801 : : return retval;
4802 : : } else
4803 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4804 : : ut_params->op);
4805 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4806 : :
4807 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4808 [ # # ]: 0 : if (ut_params->obuf)
4809 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4810 : : else
4811 : : ciphertext = plaintext;
4812 : :
4813 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4814 : :
4815 : : /* Validate obuf */
4816 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4817 : : ciphertext,
4818 : : tdata->ciphertext.data,
4819 : : tdata->validDataLenInBits.len,
4820 : : "SNOW 3G Ciphertext data not as expected");
4821 : : return 0;
4822 : : }
4823 : :
4824 : : static int
4825 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4826 : : uint8_t sgl_in, uint8_t sgl_out)
4827 : : {
4828 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4829 : : struct crypto_unittest_params *ut_params = &unittest_params;
4830 : :
4831 : : int retval;
4832 : : unsigned int plaintext_pad_len;
4833 : : unsigned int plaintext_len;
4834 : : uint8_t buffer[10000];
4835 : : const uint8_t *ciphertext;
4836 : :
4837 : : struct rte_cryptodev_info dev_info;
4838 : :
4839 : : /* Verify the capabilities */
4840 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4841 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4842 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4843 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4844 : : &cap_idx) == NULL)
4845 : : return TEST_SKIPPED;
4846 : :
4847 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4848 : : return TEST_SKIPPED;
4849 : :
4850 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4851 : : return TEST_SKIPPED;
4852 : :
4853 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4854 : :
4855 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4856 : :
4857 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4858 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4859 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4860 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4861 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4862 : : printf("Device doesn't support out-of-place scatter gather type. "
4863 : : "Test Skipped.\n");
4864 : 0 : return TEST_SKIPPED;
4865 : : }
4866 : :
4867 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4868 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4869 : : printf("Device does not support RAW data-path APIs.\n");
4870 : 0 : return -ENOTSUP;
4871 : : }
4872 : :
4873 : : /* Create SNOW 3G session */
4874 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4875 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4876 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4877 : 0 : tdata->key.data, tdata->key.len,
4878 : 0 : tdata->cipher_iv.len);
4879 [ # # ]: 0 : if (retval < 0)
4880 : : return retval;
4881 : :
4882 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4883 : : /* Append data which is padded to a multiple of */
4884 : : /* the algorithms block size */
4885 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4886 : :
4887 [ # # ]: 0 : if (sgl_in)
4888 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4889 : : plaintext_pad_len, 10, 0);
4890 : : else {
4891 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4892 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4893 : : }
4894 : :
4895 [ # # ]: 0 : if (sgl_out)
4896 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4897 : : plaintext_pad_len, 3, 0);
4898 : : else {
4899 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4900 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4901 : : }
4902 : :
4903 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4904 : : "Failed to allocate input buffer in mempool");
4905 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4906 : : "Failed to allocate output buffer in mempool");
4907 : :
4908 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4909 : :
4910 : : /* Create SNOW 3G operation */
4911 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4912 : 0 : tdata->cipher_iv.len,
4913 : 0 : tdata->validCipherLenInBits.len,
4914 : : 0);
4915 [ # # ]: 0 : if (retval < 0)
4916 : : return retval;
4917 : :
4918 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4919 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4920 : 0 : tdata->cipher_iv.len);
4921 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4922 : : return retval;
4923 : : } else
4924 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4925 : : ut_params->op);
4926 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4927 : :
4928 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4929 [ # # ]: 0 : if (ut_params->obuf)
4930 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4931 : : plaintext_len, buffer);
4932 : : else
4933 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4934 : : plaintext_len, buffer);
4935 : :
4936 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4937 : :
4938 : : /* Validate obuf */
4939 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4940 : : ciphertext,
4941 : : tdata->ciphertext.data,
4942 : : tdata->validDataLenInBits.len,
4943 : : "SNOW 3G Ciphertext data not as expected");
4944 : :
4945 : : return 0;
4946 : : }
4947 : :
4948 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4949 : : static void
4950 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4951 : : {
4952 : : uint8_t curr_byte, prev_byte;
4953 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4954 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4955 : : unsigned i;
4956 : :
4957 : 0 : prev_byte = buffer[0];
4958 : 0 : buffer[0] >>= offset;
4959 : :
4960 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4961 : 0 : curr_byte = buffer[i];
4962 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4963 : 0 : (curr_byte >> offset);
4964 : : prev_byte = curr_byte;
4965 : : }
4966 : 0 : }
4967 : :
4968 : : static int
4969 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4970 : : {
4971 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4972 : : struct crypto_unittest_params *ut_params = &unittest_params;
4973 : : uint8_t *plaintext, *ciphertext;
4974 : : int retval;
4975 : : uint32_t plaintext_len;
4976 : : uint32_t plaintext_pad_len;
4977 : : uint8_t extra_offset = 4;
4978 : : uint8_t *expected_ciphertext_shifted;
4979 : : struct rte_cryptodev_info dev_info;
4980 : :
4981 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4982 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4983 : :
4984 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4985 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4986 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4987 : 0 : return TEST_SKIPPED;
4988 : : }
4989 : :
4990 : : /* Verify the capabilities */
4991 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4992 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4993 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4994 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4995 : : &cap_idx) == NULL)
4996 : : return TEST_SKIPPED;
4997 : :
4998 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4999 : : return TEST_SKIPPED;
5000 : :
5001 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5002 : : return TEST_SKIPPED;
5003 : :
5004 : : /* Create SNOW 3G session */
5005 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5006 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5007 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5008 : 0 : tdata->key.data, tdata->key.len,
5009 : 0 : tdata->cipher_iv.len);
5010 [ # # ]: 0 : if (retval < 0)
5011 : : return retval;
5012 : :
5013 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5014 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5015 : :
5016 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5017 : : "Failed to allocate input buffer in mempool");
5018 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5019 : : "Failed to allocate output buffer in mempool");
5020 : :
5021 : : /* Clear mbuf payload */
5022 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5023 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5024 : :
5025 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
5026 : : /*
5027 : : * Append data which is padded to a
5028 : : * multiple of the algorithms block size
5029 : : */
5030 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5031 : :
5032 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
5033 : : plaintext_pad_len);
5034 : :
5035 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5036 : :
5037 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
5038 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
5039 : :
5040 : : #ifdef RTE_APP_TEST_DEBUG
5041 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
5042 : : #endif
5043 : : /* Create SNOW 3G operation */
5044 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5045 : 0 : tdata->cipher_iv.len,
5046 : 0 : tdata->validCipherLenInBits.len,
5047 : : extra_offset);
5048 [ # # ]: 0 : if (retval < 0)
5049 : : return retval;
5050 : :
5051 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5052 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5053 : 0 : tdata->cipher_iv.len);
5054 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5055 : : return retval;
5056 : : } else
5057 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5058 : : ut_params->op);
5059 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5060 : :
5061 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5062 [ # # ]: 0 : if (ut_params->obuf)
5063 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5064 : : else
5065 : : ciphertext = plaintext;
5066 : :
5067 : : #ifdef RTE_APP_TEST_DEBUG
5068 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5069 : : #endif
5070 : :
5071 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
5072 : :
5073 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
5074 : : "failed to reserve memory for ciphertext shifted\n");
5075 : :
5076 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
5077 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
5078 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
5079 : : extra_offset);
5080 : : /* Validate obuf */
5081 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
5082 : : ciphertext,
5083 : : expected_ciphertext_shifted,
5084 : : tdata->validDataLenInBits.len,
5085 : : extra_offset,
5086 : : "SNOW 3G Ciphertext data not as expected");
5087 : : return 0;
5088 : : }
5089 : :
5090 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
5091 : : {
5092 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5093 : : struct crypto_unittest_params *ut_params = &unittest_params;
5094 : :
5095 : : int retval;
5096 : :
5097 : : uint8_t *plaintext, *ciphertext;
5098 : : unsigned ciphertext_pad_len;
5099 : : unsigned ciphertext_len;
5100 : : struct rte_cryptodev_info dev_info;
5101 : :
5102 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5103 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5104 : :
5105 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5106 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5107 : : printf("Device doesn't support RAW data-path APIs.\n");
5108 : 0 : return TEST_SKIPPED;
5109 : : }
5110 : :
5111 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5112 : : return TEST_SKIPPED;
5113 : :
5114 : : /* Verify the capabilities */
5115 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5116 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5117 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5118 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5119 : : &cap_idx) == NULL)
5120 : : return TEST_SKIPPED;
5121 : :
5122 : : /* Create SNOW 3G session */
5123 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5124 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5125 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5126 : 0 : tdata->key.data, tdata->key.len,
5127 : 0 : tdata->cipher_iv.len);
5128 [ # # ]: 0 : if (retval < 0)
5129 : : return retval;
5130 : :
5131 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5132 : :
5133 : : /* Clear mbuf payload */
5134 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5135 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5136 : :
5137 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5138 : : /* Append data which is padded to a multiple of */
5139 : : /* the algorithms block size */
5140 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5141 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5142 : : ciphertext_pad_len);
5143 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5144 : :
5145 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5146 : :
5147 : : /* Create SNOW 3G operation */
5148 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5149 : 0 : tdata->cipher_iv.len,
5150 : 0 : tdata->validCipherLenInBits.len,
5151 : 0 : tdata->cipher.offset_bits);
5152 [ # # ]: 0 : if (retval < 0)
5153 : : return retval;
5154 : :
5155 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5156 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5157 : 0 : tdata->cipher_iv.len);
5158 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5159 : : return retval;
5160 : : } else
5161 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5162 : : ut_params->op);
5163 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5164 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5165 [ # # ]: 0 : if (ut_params->obuf)
5166 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5167 : : else
5168 : : plaintext = ciphertext;
5169 : :
5170 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5171 : :
5172 : : /* Validate obuf */
5173 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5174 : : tdata->plaintext.data,
5175 : : tdata->validDataLenInBits.len,
5176 : : "SNOW 3G Plaintext data not as expected");
5177 : : return 0;
5178 : : }
5179 : :
5180 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5181 : : {
5182 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5183 : : struct crypto_unittest_params *ut_params = &unittest_params;
5184 : :
5185 : : int retval;
5186 : :
5187 : : uint8_t *plaintext, *ciphertext;
5188 : : unsigned ciphertext_pad_len;
5189 : : unsigned ciphertext_len;
5190 : : struct rte_cryptodev_info dev_info;
5191 : :
5192 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5193 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5194 : :
5195 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5196 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5197 : : printf("Device does not support RAW data-path APIs.\n");
5198 : 0 : return -ENOTSUP;
5199 : : }
5200 : : /* Verify the capabilities */
5201 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5202 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5203 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5204 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5205 : : &cap_idx) == NULL)
5206 : : return TEST_SKIPPED;
5207 : :
5208 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5209 : : return TEST_SKIPPED;
5210 : :
5211 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5212 : : return TEST_SKIPPED;
5213 : :
5214 : : /* Create SNOW 3G session */
5215 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5216 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5217 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5218 : 0 : tdata->key.data, tdata->key.len,
5219 : 0 : tdata->cipher_iv.len);
5220 [ # # ]: 0 : if (retval < 0)
5221 : : return retval;
5222 : :
5223 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5224 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5225 : :
5226 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5227 : : "Failed to allocate input buffer");
5228 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5229 : : "Failed to allocate output buffer");
5230 : :
5231 : : /* Clear mbuf payload */
5232 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5233 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5234 : :
5235 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5236 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5237 : :
5238 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5239 : : /* Append data which is padded to a multiple of */
5240 : : /* the algorithms block size */
5241 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5242 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5243 : : ciphertext_pad_len);
5244 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5245 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5246 : :
5247 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5248 : :
5249 : : /* Create SNOW 3G operation */
5250 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5251 : 0 : tdata->cipher_iv.len,
5252 : 0 : tdata->validCipherLenInBits.len,
5253 : : 0);
5254 [ # # ]: 0 : if (retval < 0)
5255 : : return retval;
5256 : :
5257 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5258 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5259 : 0 : tdata->cipher_iv.len);
5260 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5261 : : return retval;
5262 : : } else
5263 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5264 : : ut_params->op);
5265 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5266 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5267 [ # # ]: 0 : if (ut_params->obuf)
5268 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5269 : : else
5270 : : plaintext = ciphertext;
5271 : :
5272 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5273 : :
5274 : : /* Validate obuf */
5275 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5276 : : tdata->plaintext.data,
5277 : : tdata->validDataLenInBits.len,
5278 : : "SNOW 3G Plaintext data not as expected");
5279 : : return 0;
5280 : : }
5281 : :
5282 : : static int
5283 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5284 : : {
5285 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5286 : : struct crypto_unittest_params *ut_params = &unittest_params;
5287 : :
5288 : : int retval;
5289 : :
5290 : : uint8_t *plaintext, *ciphertext;
5291 : : unsigned int plaintext_pad_len;
5292 : : unsigned int plaintext_len;
5293 : :
5294 : : struct rte_cryptodev_info dev_info;
5295 : :
5296 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5297 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5298 : :
5299 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5300 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
5301 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
5302 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
5303 : 0 : return TEST_SKIPPED;
5304 : : }
5305 : :
5306 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5307 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5308 : : printf("Device doesn't support RAW data-path APIs.\n");
5309 : 0 : return TEST_SKIPPED;
5310 : : }
5311 : :
5312 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5313 : : return TEST_SKIPPED;
5314 : :
5315 : : /* Check if device supports ZUC EEA3 */
5316 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5317 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
5318 : : return TEST_SKIPPED;
5319 : :
5320 : : /* Check if device supports ZUC EIA3 */
5321 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5322 : 0 : tdata->key.len, tdata->auth_iv.len,
5323 : 0 : tdata->digest.len) < 0)
5324 : : return TEST_SKIPPED;
5325 : :
5326 : : /* Create ZUC session */
5327 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
5328 : 0 : ts_params->valid_devs[0],
5329 : : tdata);
5330 [ # # ]: 0 : if (retval != 0)
5331 : : return retval;
5332 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5333 : :
5334 : : /* clear mbuf payload */
5335 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5336 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5337 : :
5338 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5339 : : /* Append data which is padded to a multiple of */
5340 : : /* the algorithms block size */
5341 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5342 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5343 : : plaintext_pad_len);
5344 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5345 : :
5346 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5347 : :
5348 : : /* Create ZUC operation */
5349 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
5350 [ # # ]: 0 : if (retval < 0)
5351 : : return retval;
5352 : :
5353 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5354 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5355 : 0 : tdata->cipher_iv.len);
5356 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5357 : : return retval;
5358 : : } else
5359 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5360 : : ut_params->op);
5361 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5362 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5363 [ # # ]: 0 : if (ut_params->obuf)
5364 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5365 : : else
5366 : : ciphertext = plaintext;
5367 : :
5368 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5369 : : /* Validate obuf */
5370 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5371 : : ciphertext,
5372 : : tdata->ciphertext.data,
5373 : : tdata->validDataLenInBits.len,
5374 : : "ZUC Ciphertext data not as expected");
5375 : :
5376 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5377 : : uint8_t *,
5378 : : plaintext_pad_len);
5379 : :
5380 : : /* Validate obuf */
5381 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5382 : : ut_params->digest,
5383 : : tdata->digest.data,
5384 : : tdata->digest.len,
5385 : : "ZUC Generated auth tag not as expected");
5386 : : return 0;
5387 : : }
5388 : :
5389 : : static int
5390 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5391 : : {
5392 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5393 : : struct crypto_unittest_params *ut_params = &unittest_params;
5394 : :
5395 : : int retval;
5396 : :
5397 : : uint8_t *plaintext, *ciphertext;
5398 : : unsigned plaintext_pad_len;
5399 : : unsigned plaintext_len;
5400 : : struct rte_cryptodev_info dev_info;
5401 : :
5402 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5403 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5404 : :
5405 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5406 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5407 : : printf("Device doesn't support RAW data-path APIs.\n");
5408 : 0 : return TEST_SKIPPED;
5409 : : }
5410 : :
5411 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5412 : : return TEST_SKIPPED;
5413 : :
5414 : : /* Verify the capabilities */
5415 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5416 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5417 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5418 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5419 : : &cap_idx) == NULL)
5420 : : return TEST_SKIPPED;
5421 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5422 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5423 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5424 : : &cap_idx) == NULL)
5425 : : return TEST_SKIPPED;
5426 : :
5427 : : /* Create SNOW 3G session */
5428 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5429 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5430 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5431 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5432 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5433 : : tdata->key.data, tdata->key.len,
5434 : 0 : tdata->key.data, tdata->key.len,
5435 : 0 : tdata->auth_iv.len, tdata->digest.len,
5436 : 0 : tdata->cipher_iv.len);
5437 [ # # ]: 0 : if (retval != 0)
5438 : : return retval;
5439 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5440 : :
5441 : : /* clear mbuf payload */
5442 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5443 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5444 : :
5445 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5446 : : /* Append data which is padded to a multiple of */
5447 : : /* the algorithms block size */
5448 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5449 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5450 : : plaintext_pad_len);
5451 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5452 : :
5453 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5454 : :
5455 : : /* Create SNOW 3G operation */
5456 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5457 : 0 : tdata->digest.len, tdata->auth_iv.data,
5458 : 0 : tdata->auth_iv.len,
5459 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5460 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5461 : 0 : tdata->validCipherLenInBits.len,
5462 : : 0,
5463 : 0 : tdata->validAuthLenInBits.len,
5464 : : 0
5465 : : );
5466 [ # # ]: 0 : if (retval < 0)
5467 : : return retval;
5468 : :
5469 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5470 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5471 : 0 : tdata->cipher_iv.len);
5472 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5473 : : return retval;
5474 : : } else
5475 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5476 : : ut_params->op);
5477 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5478 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5479 [ # # ]: 0 : if (ut_params->obuf)
5480 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5481 : : else
5482 : : ciphertext = plaintext;
5483 : :
5484 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5485 : : /* Validate obuf */
5486 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5487 : : ciphertext,
5488 : : tdata->ciphertext.data,
5489 : : tdata->validDataLenInBits.len,
5490 : : "SNOW 3G Ciphertext data not as expected");
5491 : :
5492 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5493 : : uint8_t *,
5494 : : plaintext_pad_len);
5495 : :
5496 : : /* Validate obuf */
5497 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5498 : : ut_params->digest,
5499 : : tdata->digest.data,
5500 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5501 : : "SNOW 3G Generated auth tag not as expected");
5502 : : return 0;
5503 : : }
5504 : :
5505 : : static int
5506 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5507 : : uint8_t op_mode, uint8_t verify)
5508 : : {
5509 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5510 : : struct crypto_unittest_params *ut_params = &unittest_params;
5511 : :
5512 : : int retval;
5513 : :
5514 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5515 : : unsigned int plaintext_pad_len;
5516 : : unsigned int plaintext_len;
5517 : : unsigned int ciphertext_pad_len;
5518 : : unsigned int ciphertext_len;
5519 : : unsigned int digest_offset;
5520 : :
5521 : : struct rte_cryptodev_info dev_info;
5522 : :
5523 : : /* Verify the capabilities */
5524 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5525 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5526 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5527 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5528 : : &cap_idx) == NULL)
5529 : : return TEST_SKIPPED;
5530 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5531 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5532 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5533 : : &cap_idx) == NULL)
5534 : : return TEST_SKIPPED;
5535 : :
5536 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5537 : : return TEST_SKIPPED;
5538 : :
5539 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5540 : :
5541 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5542 : :
5543 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5544 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5545 : : printf("Device doesn't support digest encrypted.\n");
5546 : 0 : return TEST_SKIPPED;
5547 : : }
5548 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5549 : : return TEST_SKIPPED;
5550 : : }
5551 : :
5552 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5553 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5554 : : printf("Device doesn't support RAW data-path APIs.\n");
5555 : 0 : return TEST_SKIPPED;
5556 : : }
5557 : :
5558 : : /* Create SNOW 3G session */
5559 : 0 : retval = create_wireless_algo_auth_cipher_session(
5560 : 0 : ts_params->valid_devs[0],
5561 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5562 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5563 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5564 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5565 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5566 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5567 : : tdata->key.data, tdata->key.len,
5568 : 0 : tdata->key.data, tdata->key.len,
5569 : 0 : tdata->auth_iv.len, tdata->digest.len,
5570 : 0 : tdata->cipher_iv.len);
5571 [ # # ]: 0 : if (retval != 0)
5572 : : return retval;
5573 : :
5574 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5575 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5576 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5577 : :
5578 : : /* clear mbuf payload */
5579 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5580 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5581 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5582 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5583 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5584 : :
5585 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5586 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5587 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5588 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5589 : :
5590 [ # # ]: 0 : if (verify) {
5591 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5592 : : ciphertext_pad_len);
5593 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5594 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5595 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5596 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5597 : : ciphertext_len);
5598 : : } else {
5599 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5600 : : plaintext_pad_len);
5601 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5602 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5603 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5604 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5605 : : }
5606 : :
5607 : : /* Create SNOW 3G operation */
5608 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5609 : 0 : tdata->digest.data, tdata->digest.len,
5610 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5611 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5612 : 0 : (tdata->digest.offset_bytes == 0 ?
5613 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5614 : : : tdata->digest.offset_bytes),
5615 : 0 : tdata->validCipherLenInBits.len,
5616 : 0 : tdata->cipher.offset_bits,
5617 : 0 : tdata->validAuthLenInBits.len,
5618 [ # # ]: 0 : tdata->auth.offset_bits,
5619 : : op_mode, 0, verify);
5620 : :
5621 [ # # ]: 0 : if (retval < 0)
5622 : : return retval;
5623 : :
5624 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5625 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5626 : 0 : tdata->cipher_iv.len);
5627 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5628 : : return retval;
5629 : : } else
5630 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5631 : : ut_params->op);
5632 : :
5633 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5634 : :
5635 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5636 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5637 : :
5638 [ # # ]: 0 : if (verify) {
5639 [ # # ]: 0 : if (ut_params->obuf)
5640 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5641 : : uint8_t *);
5642 : : else
5643 : 0 : plaintext = ciphertext +
5644 : 0 : (tdata->cipher.offset_bits >> 3);
5645 : :
5646 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5647 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5648 : 0 : debug_hexdump(stdout, "plaintext expected:",
5649 : 0 : tdata->plaintext.data,
5650 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5651 : : } else {
5652 [ # # ]: 0 : if (ut_params->obuf)
5653 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5654 : : uint8_t *);
5655 : : else
5656 : : ciphertext = plaintext;
5657 : :
5658 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5659 : : ciphertext_len);
5660 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5661 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5662 : :
5663 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5664 : : digest_offset = plaintext_pad_len;
5665 : : else
5666 : : digest_offset = tdata->digest.offset_bytes;
5667 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5668 : : uint8_t *, digest_offset);
5669 : :
5670 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5671 : 0 : tdata->digest.len);
5672 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5673 : 0 : tdata->digest.len);
5674 : : }
5675 : :
5676 : : /* Validate obuf */
5677 [ # # ]: 0 : if (verify) {
5678 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5679 : : plaintext,
5680 : : tdata->plaintext.data,
5681 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5682 : : (tdata->digest.len << 3)),
5683 : : tdata->cipher.offset_bits,
5684 : : "SNOW 3G Plaintext data not as expected");
5685 : : } else {
5686 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5687 : : ciphertext,
5688 : : tdata->ciphertext.data,
5689 : : (tdata->validDataLenInBits.len -
5690 : : tdata->cipher.offset_bits),
5691 : : tdata->cipher.offset_bits,
5692 : : "SNOW 3G Ciphertext data not as expected");
5693 : :
5694 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5695 : : ut_params->digest,
5696 : : tdata->digest.data,
5697 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5698 : : "SNOW 3G Generated auth tag not as expected");
5699 : : }
5700 : : return 0;
5701 : : }
5702 : :
5703 : : static int
5704 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5705 : : uint8_t op_mode, uint8_t verify)
5706 : : {
5707 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5708 : : struct crypto_unittest_params *ut_params = &unittest_params;
5709 : :
5710 : : int retval;
5711 : :
5712 : : const uint8_t *plaintext = NULL;
5713 : : const uint8_t *ciphertext = NULL;
5714 : : const uint8_t *digest = NULL;
5715 : : unsigned int plaintext_pad_len;
5716 : : unsigned int plaintext_len;
5717 : : unsigned int ciphertext_pad_len;
5718 : : unsigned int ciphertext_len;
5719 : : uint8_t buffer[10000];
5720 : : uint8_t digest_buffer[10000];
5721 : :
5722 : : struct rte_cryptodev_info dev_info;
5723 : :
5724 : : /* Verify the capabilities */
5725 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5726 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5727 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5728 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5729 : : &cap_idx) == NULL)
5730 : : return TEST_SKIPPED;
5731 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5732 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5733 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5734 : : &cap_idx) == NULL)
5735 : : return TEST_SKIPPED;
5736 : :
5737 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5738 : : return TEST_SKIPPED;
5739 : :
5740 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5741 : :
5742 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5743 : :
5744 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5745 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5746 : : printf("Device doesn't support in-place scatter-gather "
5747 : : "in both input and output mbufs.\n");
5748 : 0 : return TEST_SKIPPED;
5749 : : }
5750 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5751 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5752 : : printf("Device doesn't support RAW data-path APIs.\n");
5753 : 0 : return TEST_SKIPPED;
5754 : : }
5755 : : } else {
5756 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5757 : : return TEST_SKIPPED;
5758 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5759 : : printf("Device doesn't support out-of-place scatter-gather "
5760 : : "in both input and output mbufs.\n");
5761 : 0 : return TEST_SKIPPED;
5762 : : }
5763 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5764 : : printf("Device doesn't support digest encrypted.\n");
5765 : 0 : return TEST_SKIPPED;
5766 : : }
5767 : : }
5768 : :
5769 : : /* Create SNOW 3G session */
5770 : 0 : retval = create_wireless_algo_auth_cipher_session(
5771 : 0 : ts_params->valid_devs[0],
5772 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5773 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5774 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5775 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5776 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5777 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5778 : : tdata->key.data, tdata->key.len,
5779 : 0 : tdata->key.data, tdata->key.len,
5780 : 0 : tdata->auth_iv.len, tdata->digest.len,
5781 : 0 : tdata->cipher_iv.len);
5782 : :
5783 [ # # ]: 0 : if (retval != 0)
5784 : : return retval;
5785 : :
5786 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5787 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5788 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5789 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5790 : :
5791 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5792 : : plaintext_pad_len, 15, 0);
5793 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5794 : : "Failed to allocate input buffer in mempool");
5795 : :
5796 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5797 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5798 : : plaintext_pad_len, 15, 0);
5799 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5800 : : "Failed to allocate output buffer in mempool");
5801 : : }
5802 : :
5803 [ # # ]: 0 : if (verify) {
5804 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5805 : 0 : tdata->ciphertext.data);
5806 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5807 : : ciphertext_len, buffer);
5808 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5809 : : ciphertext_len);
5810 : : } else {
5811 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5812 : 0 : tdata->plaintext.data);
5813 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5814 : : plaintext_len, buffer);
5815 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5816 : : plaintext_len);
5817 : : }
5818 : : memset(buffer, 0, sizeof(buffer));
5819 : :
5820 : : /* Create SNOW 3G operation */
5821 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5822 : 0 : tdata->digest.data, tdata->digest.len,
5823 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5824 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5825 : 0 : (tdata->digest.offset_bytes == 0 ?
5826 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5827 : : : tdata->digest.offset_bytes),
5828 : 0 : tdata->validCipherLenInBits.len,
5829 : 0 : tdata->cipher.offset_bits,
5830 : 0 : tdata->validAuthLenInBits.len,
5831 [ # # ]: 0 : tdata->auth.offset_bits,
5832 : : op_mode, 1, verify);
5833 : :
5834 [ # # ]: 0 : if (retval < 0)
5835 : : return retval;
5836 : :
5837 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5838 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5839 : 0 : tdata->cipher_iv.len);
5840 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5841 : : return retval;
5842 : : } else
5843 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5844 : : ut_params->op);
5845 : :
5846 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5847 : :
5848 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5849 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5850 : :
5851 [ # # ]: 0 : if (verify) {
5852 [ # # ]: 0 : if (ut_params->obuf)
5853 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5854 : : plaintext_len, buffer);
5855 : : else
5856 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5857 : : plaintext_len, buffer);
5858 : :
5859 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5860 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5861 : 0 : debug_hexdump(stdout, "plaintext expected:",
5862 : 0 : tdata->plaintext.data,
5863 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5864 : : } else {
5865 [ # # ]: 0 : if (ut_params->obuf)
5866 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5867 : : ciphertext_len, buffer);
5868 : : else
5869 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5870 : : ciphertext_len, buffer);
5871 : :
5872 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5873 : : ciphertext_len);
5874 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5875 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5876 : :
5877 [ # # ]: 0 : if (ut_params->obuf)
5878 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5879 : 0 : (tdata->digest.offset_bytes == 0 ?
5880 : : plaintext_pad_len : tdata->digest.offset_bytes),
5881 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5882 : : else
5883 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5884 : 0 : (tdata->digest.offset_bytes == 0 ?
5885 : : plaintext_pad_len : tdata->digest.offset_bytes),
5886 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5887 : :
5888 : 0 : debug_hexdump(stdout, "digest:", digest,
5889 : 0 : tdata->digest.len);
5890 : 0 : debug_hexdump(stdout, "digest expected:",
5891 : 0 : tdata->digest.data, tdata->digest.len);
5892 : : }
5893 : :
5894 : : /* Validate obuf */
5895 [ # # ]: 0 : if (verify) {
5896 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5897 : : plaintext,
5898 : : tdata->plaintext.data,
5899 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5900 : : (tdata->digest.len << 3)),
5901 : : tdata->cipher.offset_bits,
5902 : : "SNOW 3G Plaintext data not as expected");
5903 : : } else {
5904 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5905 : : ciphertext,
5906 : : tdata->ciphertext.data,
5907 : : (tdata->validDataLenInBits.len -
5908 : : tdata->cipher.offset_bits),
5909 : : tdata->cipher.offset_bits,
5910 : : "SNOW 3G Ciphertext data not as expected");
5911 : :
5912 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5913 : : digest,
5914 : : tdata->digest.data,
5915 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5916 : : "SNOW 3G Generated auth tag not as expected");
5917 : : }
5918 : : return 0;
5919 : : }
5920 : :
5921 : : static int
5922 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5923 : : uint8_t op_mode, uint8_t verify)
5924 : : {
5925 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5926 : : struct crypto_unittest_params *ut_params = &unittest_params;
5927 : :
5928 : : int retval;
5929 : :
5930 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5931 : : unsigned int plaintext_pad_len;
5932 : : unsigned int plaintext_len;
5933 : : unsigned int ciphertext_pad_len;
5934 : : unsigned int ciphertext_len;
5935 : : unsigned int digest_offset;
5936 : :
5937 : : struct rte_cryptodev_info dev_info;
5938 : :
5939 : : /* Verify the capabilities */
5940 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5941 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5942 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5943 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5944 : : &cap_idx) == NULL)
5945 : : return TEST_SKIPPED;
5946 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5947 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5948 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5949 : : &cap_idx) == NULL)
5950 : : return TEST_SKIPPED;
5951 : :
5952 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5953 : :
5954 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5955 : :
5956 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5957 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5958 : : printf("Device doesn't support RAW data-path APIs.\n");
5959 : 0 : return TEST_SKIPPED;
5960 : : }
5961 : :
5962 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5963 : : return TEST_SKIPPED;
5964 : :
5965 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5966 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5967 : : return TEST_SKIPPED;
5968 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5969 : : printf("Device doesn't support digest encrypted.\n");
5970 : 0 : return TEST_SKIPPED;
5971 : : }
5972 : : }
5973 : :
5974 : : /* Create KASUMI session */
5975 : 0 : retval = create_wireless_algo_auth_cipher_session(
5976 : 0 : ts_params->valid_devs[0],
5977 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5978 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5979 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5980 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5981 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5982 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5983 : : tdata->key.data, tdata->key.len,
5984 : 0 : tdata->key.data, tdata->key.len,
5985 : 0 : 0, tdata->digest.len,
5986 : 0 : tdata->cipher_iv.len);
5987 : :
5988 [ # # ]: 0 : if (retval != 0)
5989 : : return retval;
5990 : :
5991 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5992 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5993 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5994 : :
5995 : : /* clear mbuf payload */
5996 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5997 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5998 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5999 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6000 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6001 : :
6002 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6003 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6004 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6005 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6006 : :
6007 [ # # ]: 0 : if (verify) {
6008 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6009 : : ciphertext_pad_len);
6010 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6011 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6012 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6013 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6014 : : ciphertext_len);
6015 : : } else {
6016 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6017 : : plaintext_pad_len);
6018 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6019 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6020 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6021 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6022 : : plaintext_len);
6023 : : }
6024 : :
6025 : : /* Create KASUMI operation */
6026 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6027 : 0 : tdata->digest.data, tdata->digest.len,
6028 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6029 : : NULL, 0,
6030 : 0 : (tdata->digest.offset_bytes == 0 ?
6031 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6032 : : : tdata->digest.offset_bytes),
6033 : 0 : tdata->validCipherLenInBits.len,
6034 : 0 : tdata->validCipherOffsetInBits.len,
6035 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6036 : : 0,
6037 : : op_mode, 0, verify);
6038 : :
6039 [ # # ]: 0 : if (retval < 0)
6040 : : return retval;
6041 : :
6042 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6043 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6044 : 0 : tdata->cipher_iv.len);
6045 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6046 : : return retval;
6047 : : } else
6048 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6049 : : ut_params->op);
6050 : :
6051 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6052 : :
6053 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6054 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6055 : :
6056 : :
6057 [ # # ]: 0 : if (verify) {
6058 [ # # ]: 0 : if (ut_params->obuf)
6059 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6060 : : uint8_t *);
6061 : : else
6062 : : plaintext = ciphertext;
6063 : :
6064 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6065 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6066 : 0 : debug_hexdump(stdout, "plaintext expected:",
6067 : 0 : tdata->plaintext.data,
6068 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6069 : : } else {
6070 [ # # ]: 0 : if (ut_params->obuf)
6071 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6072 : : uint8_t *);
6073 : : else
6074 : : ciphertext = plaintext;
6075 : :
6076 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6077 : : ciphertext_len);
6078 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6079 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6080 : :
6081 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6082 : : digest_offset = plaintext_pad_len;
6083 : : else
6084 : : digest_offset = tdata->digest.offset_bytes;
6085 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6086 : : uint8_t *, digest_offset);
6087 : :
6088 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6089 : 0 : tdata->digest.len);
6090 : 0 : debug_hexdump(stdout, "digest expected:",
6091 : 0 : tdata->digest.data, tdata->digest.len);
6092 : : }
6093 : :
6094 : : /* Validate obuf */
6095 [ # # ]: 0 : if (verify) {
6096 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6097 : : plaintext,
6098 : : tdata->plaintext.data,
6099 : : tdata->plaintext.len >> 3,
6100 : : "KASUMI Plaintext data not as expected");
6101 : : } else {
6102 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6103 : : ciphertext,
6104 : : tdata->ciphertext.data,
6105 : : tdata->ciphertext.len >> 3,
6106 : : "KASUMI Ciphertext data not as expected");
6107 : :
6108 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6109 : : ut_params->digest,
6110 : : tdata->digest.data,
6111 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6112 : : "KASUMI Generated auth tag not as expected");
6113 : : }
6114 : : return 0;
6115 : : }
6116 : :
6117 : : static int
6118 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6119 : : uint8_t op_mode, uint8_t verify)
6120 : : {
6121 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6122 : : struct crypto_unittest_params *ut_params = &unittest_params;
6123 : :
6124 : : int retval;
6125 : :
6126 : : const uint8_t *plaintext = NULL;
6127 : : const uint8_t *ciphertext = NULL;
6128 : : const uint8_t *digest = NULL;
6129 : : unsigned int plaintext_pad_len;
6130 : : unsigned int plaintext_len;
6131 : : unsigned int ciphertext_pad_len;
6132 : : unsigned int ciphertext_len;
6133 : : uint8_t buffer[10000];
6134 : : uint8_t digest_buffer[10000];
6135 : :
6136 : : struct rte_cryptodev_info dev_info;
6137 : :
6138 : : /* Verify the capabilities */
6139 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6140 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6141 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6142 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6143 : : &cap_idx) == NULL)
6144 : : return TEST_SKIPPED;
6145 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6146 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6147 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6148 : : &cap_idx) == NULL)
6149 : : return TEST_SKIPPED;
6150 : :
6151 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6152 : : return TEST_SKIPPED;
6153 : :
6154 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6155 : :
6156 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6157 : :
6158 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6159 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6160 : : printf("Device doesn't support in-place scatter-gather "
6161 : : "in both input and output mbufs.\n");
6162 : 0 : return TEST_SKIPPED;
6163 : : }
6164 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6165 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6166 : : printf("Device doesn't support RAW data-path APIs.\n");
6167 : 0 : return TEST_SKIPPED;
6168 : : }
6169 : : } else {
6170 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6171 : : return TEST_SKIPPED;
6172 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6173 : : printf("Device doesn't support out-of-place scatter-gather "
6174 : : "in both input and output mbufs.\n");
6175 : 0 : return TEST_SKIPPED;
6176 : : }
6177 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6178 : : printf("Device doesn't support digest encrypted.\n");
6179 : 0 : return TEST_SKIPPED;
6180 : : }
6181 : : }
6182 : :
6183 : : /* Create KASUMI session */
6184 : 0 : retval = create_wireless_algo_auth_cipher_session(
6185 : 0 : ts_params->valid_devs[0],
6186 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6187 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6188 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6189 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6190 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6191 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6192 : : tdata->key.data, tdata->key.len,
6193 : 0 : tdata->key.data, tdata->key.len,
6194 : 0 : 0, tdata->digest.len,
6195 : 0 : tdata->cipher_iv.len);
6196 : :
6197 [ # # ]: 0 : if (retval != 0)
6198 : : return retval;
6199 : :
6200 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6201 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6202 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6203 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6204 : :
6205 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6206 : : plaintext_pad_len, 15, 0);
6207 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6208 : : "Failed to allocate input buffer in mempool");
6209 : :
6210 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6211 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6212 : : plaintext_pad_len, 15, 0);
6213 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6214 : : "Failed to allocate output buffer in mempool");
6215 : : }
6216 : :
6217 [ # # ]: 0 : if (verify) {
6218 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6219 : 0 : tdata->ciphertext.data);
6220 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6221 : : ciphertext_len, buffer);
6222 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6223 : : ciphertext_len);
6224 : : } else {
6225 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6226 : 0 : tdata->plaintext.data);
6227 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6228 : : plaintext_len, buffer);
6229 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6230 : : plaintext_len);
6231 : : }
6232 : : memset(buffer, 0, sizeof(buffer));
6233 : :
6234 : : /* Create KASUMI operation */
6235 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6236 : 0 : tdata->digest.data, tdata->digest.len,
6237 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6238 : : NULL, 0,
6239 : 0 : (tdata->digest.offset_bytes == 0 ?
6240 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6241 : : : tdata->digest.offset_bytes),
6242 : 0 : tdata->validCipherLenInBits.len,
6243 : 0 : tdata->validCipherOffsetInBits.len,
6244 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6245 : : 0,
6246 : : op_mode, 1, verify);
6247 : :
6248 [ # # ]: 0 : if (retval < 0)
6249 : : return retval;
6250 : :
6251 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6252 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6253 : 0 : tdata->cipher_iv.len);
6254 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6255 : : return retval;
6256 : : } else
6257 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6258 : : ut_params->op);
6259 : :
6260 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6261 : :
6262 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6263 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6264 : :
6265 [ # # ]: 0 : if (verify) {
6266 [ # # ]: 0 : if (ut_params->obuf)
6267 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6268 : : plaintext_len, buffer);
6269 : : else
6270 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6271 : : plaintext_len, buffer);
6272 : :
6273 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6274 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6275 : 0 : debug_hexdump(stdout, "plaintext expected:",
6276 : 0 : tdata->plaintext.data,
6277 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6278 : : } else {
6279 [ # # ]: 0 : if (ut_params->obuf)
6280 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6281 : : ciphertext_len, buffer);
6282 : : else
6283 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6284 : : ciphertext_len, buffer);
6285 : :
6286 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6287 : : ciphertext_len);
6288 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6289 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6290 : :
6291 [ # # ]: 0 : if (ut_params->obuf)
6292 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6293 : 0 : (tdata->digest.offset_bytes == 0 ?
6294 : : plaintext_pad_len : tdata->digest.offset_bytes),
6295 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6296 : : else
6297 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6298 : 0 : (tdata->digest.offset_bytes == 0 ?
6299 : : plaintext_pad_len : tdata->digest.offset_bytes),
6300 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6301 : :
6302 : 0 : debug_hexdump(stdout, "digest:", digest,
6303 : 0 : tdata->digest.len);
6304 : 0 : debug_hexdump(stdout, "digest expected:",
6305 : 0 : tdata->digest.data, tdata->digest.len);
6306 : : }
6307 : :
6308 : : /* Validate obuf */
6309 [ # # ]: 0 : if (verify) {
6310 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6311 : : plaintext,
6312 : : tdata->plaintext.data,
6313 : : tdata->plaintext.len >> 3,
6314 : : "KASUMI Plaintext data not as expected");
6315 : : } else {
6316 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6317 : : ciphertext,
6318 : : tdata->ciphertext.data,
6319 : : tdata->validDataLenInBits.len,
6320 : : "KASUMI Ciphertext data not as expected");
6321 : :
6322 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6323 : : digest,
6324 : : tdata->digest.data,
6325 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6326 : : "KASUMI Generated auth tag not as expected");
6327 : : }
6328 : : return 0;
6329 : : }
6330 : :
6331 : : static int
6332 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6333 : : {
6334 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6335 : : struct crypto_unittest_params *ut_params = &unittest_params;
6336 : :
6337 : : int retval;
6338 : :
6339 : : uint8_t *plaintext, *ciphertext;
6340 : : unsigned plaintext_pad_len;
6341 : : unsigned plaintext_len;
6342 : : struct rte_cryptodev_info dev_info;
6343 : :
6344 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6345 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6346 : :
6347 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6348 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6349 : : printf("Device doesn't support RAW data-path APIs.\n");
6350 : 0 : return TEST_SKIPPED;
6351 : : }
6352 : :
6353 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6354 : : return TEST_SKIPPED;
6355 : :
6356 : : /* Verify the capabilities */
6357 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6358 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6359 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6360 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6361 : : &cap_idx) == NULL)
6362 : : return TEST_SKIPPED;
6363 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6364 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6365 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6366 : : &cap_idx) == NULL)
6367 : : return TEST_SKIPPED;
6368 : :
6369 : : /* Create KASUMI session */
6370 : 0 : retval = create_wireless_algo_cipher_auth_session(
6371 : 0 : ts_params->valid_devs[0],
6372 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6373 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6374 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6375 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6376 : : tdata->key.data, tdata->key.len,
6377 : 0 : tdata->key.data, tdata->key.len,
6378 : 0 : 0, tdata->digest.len,
6379 : 0 : tdata->cipher_iv.len);
6380 [ # # ]: 0 : if (retval != 0)
6381 : : return retval;
6382 : :
6383 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6384 : :
6385 : : /* clear mbuf payload */
6386 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6387 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6388 : :
6389 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6390 : : /* Append data which is padded to a multiple of */
6391 : : /* the algorithms block size */
6392 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6393 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6394 : : plaintext_pad_len);
6395 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6396 : :
6397 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6398 : :
6399 : : /* Create KASUMI operation */
6400 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6401 : 0 : tdata->digest.len, NULL, 0,
6402 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6403 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6404 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6405 : 0 : tdata->validCipherOffsetInBits.len,
6406 : 0 : tdata->validAuthLenInBits.len,
6407 : : 0
6408 : : );
6409 [ # # ]: 0 : if (retval < 0)
6410 : : return retval;
6411 : :
6412 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6413 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6414 : 0 : tdata->cipher_iv.len);
6415 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6416 : : return retval;
6417 : : } else
6418 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6419 : : ut_params->op);
6420 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6421 : :
6422 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6423 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6424 : : else
6425 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6426 : :
6427 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6428 : : tdata->validCipherOffsetInBits.len >> 3);
6429 : :
6430 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6431 : : uint8_t *,
6432 : : plaintext_pad_len);
6433 : :
6434 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6435 : : (tdata->validCipherOffsetInBits.len >> 3);
6436 : : /* Validate obuf */
6437 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6438 : : ciphertext,
6439 : : reference_ciphertext,
6440 : : tdata->validCipherLenInBits.len,
6441 : : "KASUMI Ciphertext data not as expected");
6442 : :
6443 : : /* Validate obuf */
6444 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6445 : : ut_params->digest,
6446 : : tdata->digest.data,
6447 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6448 : : "KASUMI Generated auth tag not as expected");
6449 : : return 0;
6450 : : }
6451 : :
6452 : : static int
6453 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6454 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6455 : : const uint16_t key_size, const uint16_t iv_size)
6456 : : {
6457 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6458 : : const struct rte_cryptodev_symmetric_capability *cap;
6459 : :
6460 : : /* Check if device supports the algorithm */
6461 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6462 : 0 : cap_idx.algo.cipher = cipher_algo;
6463 : :
6464 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6465 : : &cap_idx);
6466 : :
6467 [ # # ]: 0 : if (cap == NULL)
6468 : : return -1;
6469 : :
6470 : : /* Check if device supports key size and IV size */
6471 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6472 : : iv_size) < 0) {
6473 : 0 : return -1;
6474 : : }
6475 : :
6476 : : return 0;
6477 : : }
6478 : :
6479 : : static int
6480 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6481 : : const enum rte_crypto_auth_algorithm auth_algo,
6482 : : const uint16_t key_size, const uint16_t iv_size,
6483 : : const uint16_t tag_size)
6484 : : {
6485 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6486 : : const struct rte_cryptodev_symmetric_capability *cap;
6487 : :
6488 : : /* Check if device supports the algorithm */
6489 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6490 : 0 : cap_idx.algo.auth = auth_algo;
6491 : :
6492 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6493 : : &cap_idx);
6494 : :
6495 [ # # ]: 0 : if (cap == NULL)
6496 : : return -1;
6497 : :
6498 : : /* Check if device supports key size and IV size */
6499 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6500 : : tag_size, iv_size) < 0) {
6501 : 0 : return -1;
6502 : : }
6503 : :
6504 : : return 0;
6505 : : }
6506 : :
6507 : : static int
6508 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6509 : : enum rte_crypto_cipher_operation direction)
6510 : : {
6511 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6512 : : struct crypto_unittest_params *ut_params = &unittest_params;
6513 : :
6514 : : int retval;
6515 : : uint8_t *plaintext = NULL;
6516 : : uint8_t *ciphertext = NULL;
6517 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6518 : : unsigned int plaintext_len = 0;
6519 : : unsigned int ciphertext_len = 0;
6520 : : struct rte_cryptodev_info dev_info;
6521 : :
6522 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6523 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6524 : :
6525 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6526 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6527 : : printf("Device doesn't support RAW data-path APIs.\n");
6528 : 0 : return TEST_SKIPPED;
6529 : : }
6530 : :
6531 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6532 : : return TEST_SKIPPED;
6533 : :
6534 : : /* Check if device supports ZUC EEA3 */
6535 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6536 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6537 : : return TEST_SKIPPED;
6538 : :
6539 : : /* Create ZUC session */
6540 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6541 : : direction,
6542 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6543 : 0 : tdata->key.data, tdata->key.len,
6544 : 0 : tdata->cipher_iv.len);
6545 [ # # ]: 0 : if (retval != 0)
6546 : : return retval;
6547 : :
6548 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6549 : :
6550 : : /* Clear mbuf payload */
6551 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6552 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6553 : :
6554 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6555 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6556 : : /* Append data which is padded to a multiple */
6557 : : /* of the algorithms block size */
6558 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6559 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6560 : : plaintext_pad_len);
6561 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6562 : :
6563 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6564 : : } else {
6565 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6566 : : /* Append data which is padded to a multiple */
6567 : : /* of the algorithms block size */
6568 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6569 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6570 : : ciphertext_pad_len);
6571 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6572 : :
6573 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6574 : : }
6575 : :
6576 : : /* Create ZUC operation */
6577 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6578 : 0 : tdata->cipher_iv.len,
6579 : 0 : tdata->plaintext.len,
6580 : 0 : tdata->validCipherOffsetInBits.len);
6581 [ # # ]: 0 : if (retval < 0)
6582 : : return retval;
6583 : :
6584 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6585 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6586 : 0 : tdata->cipher_iv.len);
6587 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6588 : : return retval;
6589 : : } else
6590 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6591 : : ut_params->op);
6592 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6593 : :
6594 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6595 : :
6596 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6597 [ # # ]: 0 : if (ut_params->obuf)
6598 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6599 : : else
6600 : : ciphertext = plaintext;
6601 : :
6602 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6603 : :
6604 : : /* Validate obuf */
6605 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6606 : : ciphertext,
6607 : : tdata->ciphertext.data,
6608 : : tdata->validCipherLenInBits.len,
6609 : : "ZUC Ciphertext data not as expected");
6610 : : } else {
6611 [ # # ]: 0 : if (ut_params->obuf)
6612 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6613 : : else
6614 : : plaintext = ciphertext;
6615 : :
6616 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6617 : :
6618 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6619 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6620 : :
6621 : : /* Validate obuf */
6622 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6623 : : plaintext,
6624 : : reference_plaintext,
6625 : : tdata->validCipherLenInBits.len,
6626 : : "ZUC Plaintext data not as expected");
6627 : : }
6628 : :
6629 : : return 0;
6630 : : }
6631 : :
6632 : : static int
6633 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6634 : : enum rte_crypto_cipher_operation direction)
6635 : : {
6636 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6637 : : struct crypto_unittest_params *ut_params = &unittest_params;
6638 : :
6639 : : int retval;
6640 : :
6641 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6642 : : unsigned int plaintext_len = 0;
6643 : : unsigned int ciphertext_len = 0;
6644 : : const uint8_t *ciphertext, *plaintext;
6645 : : uint8_t buffer[2048];
6646 : : struct rte_cryptodev_info dev_info;
6647 : :
6648 : : /* Check if device supports ZUC EEA3 */
6649 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6650 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6651 : : return TEST_SKIPPED;
6652 : :
6653 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6654 : : return TEST_SKIPPED;
6655 : :
6656 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6657 : :
6658 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6659 : :
6660 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6661 : : printf("Device doesn't support in-place scatter-gather. "
6662 : : "Test Skipped.\n");
6663 : 0 : return TEST_SKIPPED;
6664 : : }
6665 : :
6666 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6667 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6668 : : printf("Device doesn't support RAW data-path APIs.\n");
6669 : 0 : return TEST_SKIPPED;
6670 : : }
6671 : :
6672 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6673 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6674 : :
6675 : : /* Append data which is padded to a multiple */
6676 : : /* of the algorithms block size */
6677 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6678 : :
6679 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6680 : : plaintext_pad_len, 10, 0);
6681 : :
6682 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6683 : 0 : tdata->plaintext.data);
6684 : : } else {
6685 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6686 : :
6687 : : /* Append data which is padded to a multiple */
6688 : : /* of the algorithms block size */
6689 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6690 : :
6691 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6692 : : ciphertext_pad_len, 10, 0);
6693 : :
6694 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6695 : 0 : tdata->ciphertext.data);
6696 : :
6697 : : }
6698 : :
6699 : : /* Create ZUC session */
6700 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6701 : : direction,
6702 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6703 : 0 : tdata->key.data, tdata->key.len,
6704 : 0 : tdata->cipher_iv.len);
6705 [ # # ]: 0 : if (retval < 0)
6706 : : return retval;
6707 : :
6708 : : /* Clear mbuf payload */
6709 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6710 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6711 : : else
6712 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6713 : :
6714 : : /* Create ZUC operation */
6715 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6716 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6717 : 0 : tdata->validCipherOffsetInBits.len);
6718 [ # # ]: 0 : if (retval < 0)
6719 : : return retval;
6720 : :
6721 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6722 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6723 : 0 : tdata->cipher_iv.len);
6724 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6725 : : return retval;
6726 : : } else
6727 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6728 : : ut_params->op);
6729 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6730 : :
6731 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6732 : :
6733 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6734 [ # # ]: 0 : if (ut_params->obuf)
6735 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6736 : : 0, plaintext_len, buffer);
6737 : : else
6738 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6739 : : 0, plaintext_len, buffer);
6740 : :
6741 : : /* Validate obuf */
6742 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6743 : :
6744 : : /* Validate obuf */
6745 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6746 : : ciphertext,
6747 : : tdata->ciphertext.data,
6748 : : tdata->validCipherLenInBits.len,
6749 : : "ZUC Ciphertext data not as expected");
6750 : : } else {
6751 [ # # ]: 0 : if (ut_params->obuf)
6752 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6753 : : 0, ciphertext_len, buffer);
6754 : : else
6755 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6756 : : 0, ciphertext_len, buffer);
6757 : :
6758 : : /* Validate obuf */
6759 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6760 : :
6761 : : /* Validate obuf */
6762 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6763 : : plaintext,
6764 : : tdata->plaintext.data,
6765 : : tdata->validCipherLenInBits.len,
6766 : : "ZUC Plaintext data not as expected");
6767 : : }
6768 : :
6769 : : return 0;
6770 : : }
6771 : :
6772 : : static int
6773 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6774 : : enum rte_crypto_auth_operation auth_op)
6775 : : {
6776 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6777 : : struct crypto_unittest_params *ut_params = &unittest_params;
6778 : :
6779 : : int retval;
6780 : : unsigned plaintext_pad_len;
6781 : : unsigned plaintext_len;
6782 : : uint8_t *plaintext;
6783 : :
6784 : : struct rte_cryptodev_info dev_info;
6785 : :
6786 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6787 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6788 : :
6789 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6790 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6791 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6792 : 0 : return TEST_SKIPPED;
6793 : : }
6794 : :
6795 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6796 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6797 : : printf("Device doesn't support RAW data-path APIs.\n");
6798 : 0 : return TEST_SKIPPED;
6799 : : }
6800 : :
6801 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6802 : : return TEST_SKIPPED;
6803 : :
6804 : : /* Check if device supports ZUC EIA3 */
6805 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6806 : 0 : tdata->key.len, tdata->auth_iv.len,
6807 : 0 : tdata->digest.len) < 0)
6808 : : return TEST_SKIPPED;
6809 : :
6810 : : /* Create ZUC session */
6811 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6812 : 0 : tdata->key.data, tdata->key.len,
6813 : 0 : tdata->auth_iv.len, tdata->digest.len,
6814 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6815 [ # # ]: 0 : if (retval != 0)
6816 : : return retval;
6817 : :
6818 : : /* alloc mbuf and set payload */
6819 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6820 : :
6821 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6822 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6823 : :
6824 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6825 : : /* Append data which is padded to a multiple of */
6826 : : /* the algorithms block size */
6827 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6828 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6829 : : plaintext_pad_len);
6830 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6831 : :
6832 : : /* Create ZUC operation */
6833 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6834 : 0 : tdata->digest.len,
6835 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6836 : : plaintext_pad_len,
6837 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6838 [ # # ]: 0 : if (retval < 0)
6839 : : return retval;
6840 : :
6841 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6842 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6843 : : 0);
6844 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6845 : : return retval;
6846 : : } else
6847 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6848 : : ut_params->op);
6849 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6850 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6851 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6852 : : uint8_t *,
6853 : : plaintext_pad_len);
6854 : :
6855 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6856 : : /* Validate obuf */
6857 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6858 : : ut_params->digest,
6859 : : tdata->digest.data,
6860 : : tdata->digest.len,
6861 : : "ZUC Generated auth tag not as expected");
6862 : : return 0;
6863 : : }
6864 : :
6865 : : /* Validate obuf */
6866 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6867 : : return 0;
6868 : : else
6869 : 0 : return -1;
6870 : :
6871 : : return 0;
6872 : : }
6873 : :
6874 : : static int
6875 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6876 : : uint8_t op_mode, uint8_t verify)
6877 : : {
6878 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6879 : : struct crypto_unittest_params *ut_params = &unittest_params;
6880 : :
6881 : : int retval;
6882 : :
6883 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6884 : : unsigned int plaintext_pad_len;
6885 : : unsigned int plaintext_len;
6886 : : unsigned int ciphertext_pad_len;
6887 : : unsigned int ciphertext_len;
6888 : : unsigned int digest_offset;
6889 : :
6890 : : struct rte_cryptodev_info dev_info;
6891 : :
6892 : : /* Check if device supports ZUC EEA3 */
6893 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6894 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6895 : : return TEST_SKIPPED;
6896 : :
6897 : : /* Check if device supports ZUC EIA3 */
6898 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6899 : 0 : tdata->key.len, tdata->auth_iv.len,
6900 : 0 : tdata->digest.len) < 0)
6901 : : return TEST_SKIPPED;
6902 : :
6903 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6904 : : return TEST_SKIPPED;
6905 : :
6906 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6907 : :
6908 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6909 : :
6910 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6911 : : printf("Device doesn't support digest encrypted.\n");
6912 : 0 : return TEST_SKIPPED;
6913 : : }
6914 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6915 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6916 : : printf("Device doesn't support in-place scatter-gather "
6917 : : "in both input and output mbufs.\n");
6918 : 0 : return TEST_SKIPPED;
6919 : : }
6920 : :
6921 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6922 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6923 : : printf("Device doesn't support RAW data-path APIs.\n");
6924 : 0 : return TEST_SKIPPED;
6925 : : }
6926 : : } else {
6927 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6928 : : return TEST_SKIPPED;
6929 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6930 : : printf("Device doesn't support out-of-place scatter-gather "
6931 : : "in both input and output mbufs.\n");
6932 : 0 : return TEST_SKIPPED;
6933 : : }
6934 : : }
6935 : :
6936 : : /* Create ZUC session */
6937 : 0 : retval = create_wireless_algo_auth_cipher_session(
6938 : 0 : ts_params->valid_devs[0],
6939 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6940 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6941 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6942 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6943 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6944 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6945 : : tdata->key.data, tdata->key.len,
6946 : 0 : tdata->key.data, tdata->key.len,
6947 : 0 : tdata->auth_iv.len, tdata->digest.len,
6948 : 0 : tdata->cipher_iv.len);
6949 : :
6950 [ # # ]: 0 : if (retval != 0)
6951 : : return retval;
6952 : :
6953 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6954 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6955 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6956 : :
6957 : : /* clear mbuf payload */
6958 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6959 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6960 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6961 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6962 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6963 : :
6964 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6965 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6966 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6967 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6968 : :
6969 [ # # ]: 0 : if (verify) {
6970 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6971 : : ciphertext_pad_len);
6972 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6973 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6974 : : ciphertext_len);
6975 : : } else {
6976 : : /* make sure enough space to cover partial digest verify case */
6977 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6978 : : ciphertext_pad_len);
6979 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6980 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6981 : : plaintext_len);
6982 : : }
6983 : :
6984 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6985 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6986 : :
6987 : : /* Create ZUC operation */
6988 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6989 : 0 : tdata->digest.data, tdata->digest.len,
6990 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6991 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6992 : 0 : (tdata->digest.offset_bytes == 0 ?
6993 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6994 : : : tdata->digest.offset_bytes),
6995 : 0 : tdata->validCipherLenInBits.len,
6996 : 0 : tdata->validCipherOffsetInBits.len,
6997 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6998 : : 0,
6999 : : op_mode, 0, verify);
7000 : :
7001 [ # # ]: 0 : if (retval < 0)
7002 : : return retval;
7003 : :
7004 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7005 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7006 : 0 : tdata->cipher_iv.len);
7007 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7008 : : return retval;
7009 : : } else
7010 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7011 : : ut_params->op);
7012 : :
7013 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7014 : :
7015 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7016 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7017 : :
7018 : :
7019 [ # # ]: 0 : if (verify) {
7020 [ # # ]: 0 : if (ut_params->obuf)
7021 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7022 : : uint8_t *);
7023 : : else
7024 : : plaintext = ciphertext;
7025 : :
7026 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7027 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7028 : 0 : debug_hexdump(stdout, "plaintext expected:",
7029 : 0 : tdata->plaintext.data,
7030 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7031 : : } else {
7032 [ # # ]: 0 : if (ut_params->obuf)
7033 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7034 : : uint8_t *);
7035 : : else
7036 : : ciphertext = plaintext;
7037 : :
7038 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7039 : : ciphertext_len);
7040 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7041 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7042 : :
7043 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
7044 : : digest_offset = plaintext_pad_len;
7045 : : else
7046 : : digest_offset = tdata->digest.offset_bytes;
7047 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
7048 : : uint8_t *, digest_offset);
7049 : :
7050 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
7051 : 0 : tdata->digest.len);
7052 : 0 : debug_hexdump(stdout, "digest expected:",
7053 : 0 : tdata->digest.data, tdata->digest.len);
7054 : : }
7055 : :
7056 : : /* Validate obuf */
7057 [ # # ]: 0 : if (verify) {
7058 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7059 : : plaintext,
7060 : : tdata->plaintext.data,
7061 : : tdata->plaintext.len >> 3,
7062 : : "ZUC Plaintext data not as expected");
7063 : : } else {
7064 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7065 : : ciphertext,
7066 : : tdata->ciphertext.data,
7067 : : tdata->ciphertext.len >> 3,
7068 : : "ZUC Ciphertext data not as expected");
7069 : :
7070 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7071 : : ut_params->digest,
7072 : : tdata->digest.data,
7073 : : tdata->digest.len,
7074 : : "ZUC Generated auth tag not as expected");
7075 : : }
7076 : : return 0;
7077 : : }
7078 : :
7079 : : static int
7080 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
7081 : : uint8_t op_mode, uint8_t verify)
7082 : : {
7083 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7084 : : struct crypto_unittest_params *ut_params = &unittest_params;
7085 : :
7086 : : int retval;
7087 : :
7088 : : const uint8_t *plaintext = NULL;
7089 : : const uint8_t *ciphertext = NULL;
7090 : : const uint8_t *digest = NULL;
7091 : : unsigned int plaintext_pad_len;
7092 : : unsigned int plaintext_len;
7093 : : unsigned int ciphertext_pad_len;
7094 : : unsigned int ciphertext_len;
7095 : : uint8_t buffer[10000];
7096 : : uint8_t digest_buffer[10000];
7097 : :
7098 : : struct rte_cryptodev_info dev_info;
7099 : :
7100 : : /* Check if device supports ZUC EEA3 */
7101 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
7102 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
7103 : : return TEST_SKIPPED;
7104 : :
7105 : : /* Check if device supports ZUC EIA3 */
7106 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
7107 : 0 : tdata->key.len, tdata->auth_iv.len,
7108 : 0 : tdata->digest.len) < 0)
7109 : : return TEST_SKIPPED;
7110 : :
7111 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7112 : : return TEST_SKIPPED;
7113 : :
7114 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7115 : :
7116 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7117 : :
7118 [ # # ]: 0 : if (op_mode == IN_PLACE) {
7119 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7120 : : printf("Device doesn't support in-place scatter-gather "
7121 : : "in both input and output mbufs.\n");
7122 : 0 : return TEST_SKIPPED;
7123 : : }
7124 : :
7125 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7126 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7127 : : printf("Device doesn't support RAW data-path APIs.\n");
7128 : 0 : return TEST_SKIPPED;
7129 : : }
7130 : : } else {
7131 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7132 : : return TEST_SKIPPED;
7133 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7134 : : printf("Device doesn't support out-of-place scatter-gather "
7135 : : "in both input and output mbufs.\n");
7136 : 0 : return TEST_SKIPPED;
7137 : : }
7138 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7139 : : printf("Device doesn't support digest encrypted.\n");
7140 : 0 : return TEST_SKIPPED;
7141 : : }
7142 : : }
7143 : :
7144 : : /* Create ZUC session */
7145 : 0 : retval = create_wireless_algo_auth_cipher_session(
7146 : 0 : ts_params->valid_devs[0],
7147 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7148 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7149 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7150 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
7151 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
7152 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
7153 : : tdata->key.data, tdata->key.len,
7154 : 0 : tdata->key.data, tdata->key.len,
7155 : 0 : tdata->auth_iv.len, tdata->digest.len,
7156 : 0 : tdata->cipher_iv.len);
7157 : :
7158 [ # # ]: 0 : if (retval != 0)
7159 : : return retval;
7160 : :
7161 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7162 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
7163 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7164 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7165 : :
7166 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7167 : : plaintext_pad_len, 15, 0);
7168 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7169 : : "Failed to allocate input buffer in mempool");
7170 : :
7171 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
7172 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7173 : : plaintext_pad_len, 15, 0);
7174 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
7175 : : "Failed to allocate output buffer in mempool");
7176 : : }
7177 : :
7178 [ # # ]: 0 : if (verify) {
7179 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7180 : 0 : tdata->ciphertext.data);
7181 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7182 : : ciphertext_len, buffer);
7183 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7184 : : ciphertext_len);
7185 : : } else {
7186 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7187 : 0 : tdata->plaintext.data);
7188 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7189 : : plaintext_len, buffer);
7190 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7191 : : plaintext_len);
7192 : : }
7193 : : memset(buffer, 0, sizeof(buffer));
7194 : :
7195 : : /* Create ZUC operation */
7196 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7197 : 0 : tdata->digest.data, tdata->digest.len,
7198 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7199 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7200 : 0 : (tdata->digest.offset_bytes == 0 ?
7201 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7202 : : : tdata->digest.offset_bytes),
7203 : 0 : tdata->validCipherLenInBits.len,
7204 : 0 : tdata->validCipherOffsetInBits.len,
7205 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7206 : : 0,
7207 : : op_mode, 1, verify);
7208 : :
7209 [ # # ]: 0 : if (retval < 0)
7210 : : return retval;
7211 : :
7212 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7213 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7214 : 0 : tdata->cipher_iv.len);
7215 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7216 : : return retval;
7217 : : } else
7218 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7219 : : ut_params->op);
7220 : :
7221 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7222 : :
7223 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7224 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7225 : :
7226 [ # # ]: 0 : if (verify) {
7227 [ # # ]: 0 : if (ut_params->obuf)
7228 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7229 : : plaintext_len, buffer);
7230 : : else
7231 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7232 : : plaintext_len, buffer);
7233 : :
7234 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7235 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7236 : 0 : debug_hexdump(stdout, "plaintext expected:",
7237 : 0 : tdata->plaintext.data,
7238 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7239 : : } else {
7240 [ # # ]: 0 : if (ut_params->obuf)
7241 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7242 : : ciphertext_len, buffer);
7243 : : else
7244 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7245 : : ciphertext_len, buffer);
7246 : :
7247 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7248 : : ciphertext_len);
7249 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7250 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7251 : :
7252 [ # # ]: 0 : if (ut_params->obuf)
7253 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
7254 : 0 : (tdata->digest.offset_bytes == 0 ?
7255 : : plaintext_pad_len : tdata->digest.offset_bytes),
7256 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7257 : : else
7258 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
7259 : 0 : (tdata->digest.offset_bytes == 0 ?
7260 : : plaintext_pad_len : tdata->digest.offset_bytes),
7261 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7262 : :
7263 : 0 : debug_hexdump(stdout, "digest:", digest,
7264 : 0 : tdata->digest.len);
7265 : 0 : debug_hexdump(stdout, "digest expected:",
7266 : 0 : tdata->digest.data, tdata->digest.len);
7267 : : }
7268 : :
7269 : : /* Validate obuf */
7270 [ # # ]: 0 : if (verify) {
7271 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7272 : : plaintext,
7273 : : tdata->plaintext.data,
7274 : : tdata->plaintext.len >> 3,
7275 : : "ZUC Plaintext data not as expected");
7276 : : } else {
7277 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7278 : : ciphertext,
7279 : : tdata->ciphertext.data,
7280 : : tdata->validDataLenInBits.len,
7281 : : "ZUC Ciphertext data not as expected");
7282 : :
7283 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7284 : : digest,
7285 : : tdata->digest.data,
7286 : : tdata->digest.len,
7287 : : "ZUC Generated auth tag not as expected");
7288 : : }
7289 : : return 0;
7290 : : }
7291 : :
7292 : : static int
7293 : 0 : test_kasumi_encryption_test_case_1(void)
7294 : : {
7295 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
7296 : : }
7297 : :
7298 : : static int
7299 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
7300 : : {
7301 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7302 : : }
7303 : :
7304 : : static int
7305 : 0 : test_kasumi_encryption_test_case_1_oop(void)
7306 : : {
7307 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
7308 : : }
7309 : :
7310 : : static int
7311 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
7312 : : {
7313 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7314 : : }
7315 : :
7316 : : static int
7317 : 0 : test_kasumi_encryption_test_case_2(void)
7318 : : {
7319 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
7320 : : }
7321 : :
7322 : : static int
7323 : 0 : test_kasumi_encryption_test_case_3(void)
7324 : : {
7325 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
7326 : : }
7327 : :
7328 : : static int
7329 : 0 : test_kasumi_encryption_test_case_4(void)
7330 : : {
7331 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
7332 : : }
7333 : :
7334 : : static int
7335 : 0 : test_kasumi_encryption_test_case_5(void)
7336 : : {
7337 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
7338 : : }
7339 : :
7340 : : static int
7341 : 0 : test_kasumi_decryption_test_case_1(void)
7342 : : {
7343 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
7344 : : }
7345 : :
7346 : : static int
7347 : 0 : test_kasumi_decryption_test_case_1_oop(void)
7348 : : {
7349 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
7350 : : }
7351 : :
7352 : : static int
7353 : 0 : test_kasumi_decryption_test_case_2(void)
7354 : : {
7355 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
7356 : : }
7357 : :
7358 : : static int
7359 : 0 : test_kasumi_decryption_test_case_3(void)
7360 : : {
7361 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7362 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7363 : : return TEST_SKIPPED;
7364 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7365 : : }
7366 : :
7367 : : static int
7368 : 0 : test_kasumi_decryption_test_case_4(void)
7369 : : {
7370 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7371 : : }
7372 : :
7373 : : static int
7374 : 0 : test_kasumi_decryption_test_case_5(void)
7375 : : {
7376 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7377 : : }
7378 : : static int
7379 : 0 : test_snow3g_encryption_test_case_1(void)
7380 : : {
7381 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7382 : : }
7383 : :
7384 : : static int
7385 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7386 : : {
7387 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7388 : : }
7389 : :
7390 : : static int
7391 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7392 : : {
7393 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7394 : : }
7395 : :
7396 : : static int
7397 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7398 : : {
7399 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7400 : : }
7401 : :
7402 : : static int
7403 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7404 : : {
7405 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7406 : : }
7407 : :
7408 : : static int
7409 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7410 : : {
7411 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7412 : : }
7413 : :
7414 : : static int
7415 : 0 : test_snow3g_encryption_test_case_2(void)
7416 : : {
7417 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7418 : : }
7419 : :
7420 : : static int
7421 : 0 : test_snow3g_encryption_test_case_3(void)
7422 : : {
7423 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7424 : : }
7425 : :
7426 : : static int
7427 : 0 : test_snow3g_encryption_test_case_4(void)
7428 : : {
7429 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7430 : : }
7431 : :
7432 : : static int
7433 : 0 : test_snow3g_encryption_test_case_5(void)
7434 : : {
7435 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7436 : : }
7437 : :
7438 : : static int
7439 : 0 : test_snow3g_decryption_test_case_1(void)
7440 : : {
7441 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7442 : : }
7443 : :
7444 : : static int
7445 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7446 : : {
7447 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7448 : : }
7449 : :
7450 : : static int
7451 : 0 : test_snow3g_decryption_test_case_2(void)
7452 : : {
7453 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7454 : : }
7455 : :
7456 : : static int
7457 : 0 : test_snow3g_decryption_test_case_3(void)
7458 : : {
7459 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7460 : : }
7461 : :
7462 : : static int
7463 : 0 : test_snow3g_decryption_test_case_4(void)
7464 : : {
7465 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7466 : : }
7467 : :
7468 : : static int
7469 : 0 : test_snow3g_decryption_test_case_5(void)
7470 : : {
7471 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7472 : : }
7473 : :
7474 : : /*
7475 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7476 : : * Pattern digest from snow3g_test_data must be allocated as
7477 : : * 4 last bytes in plaintext.
7478 : : */
7479 : : static void
7480 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7481 : : struct snow3g_hash_test_data *output)
7482 : : {
7483 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7484 : 0 : output->key.len = pattern->key.len;
7485 : :
7486 : 0 : memcpy(output->key.data,
7487 : 0 : pattern->key.data, pattern->key.len);
7488 : :
7489 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7490 : :
7491 : 0 : memcpy(output->auth_iv.data,
7492 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7493 : :
7494 : 0 : output->plaintext.len = pattern->plaintext.len;
7495 : :
7496 : 0 : memcpy(output->plaintext.data,
7497 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7498 : :
7499 : 0 : output->digest.len = pattern->digest.len;
7500 : :
7501 : 0 : memcpy(output->digest.data,
7502 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7503 : : pattern->digest.len);
7504 : :
7505 : 0 : output->validAuthLenInBits.len =
7506 : 0 : pattern->validAuthLenInBits.len;
7507 : : }
7508 : 0 : }
7509 : :
7510 : : /*
7511 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7512 : : */
7513 : : static int
7514 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7515 : : {
7516 : : int ret;
7517 : : struct snow3g_hash_test_data snow3g_hash_data;
7518 : : struct rte_cryptodev_info dev_info;
7519 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7520 : :
7521 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7522 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7523 : :
7524 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7525 : : printf("Device doesn't support encrypted digest operations.\n");
7526 : 0 : return TEST_SKIPPED;
7527 : : }
7528 : :
7529 : : /*
7530 : : * Function prepare data for hash verification test case.
7531 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7532 : : */
7533 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7534 : :
7535 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7536 [ # # ]: 0 : if (ret != 0)
7537 : : return ret;
7538 : :
7539 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7540 : : }
7541 : :
7542 : : static int
7543 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7544 : : {
7545 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7546 : : }
7547 : :
7548 : : static int
7549 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7550 : : {
7551 : 0 : return test_snow3g_auth_cipher(
7552 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7553 : : }
7554 : :
7555 : : static int
7556 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7557 : : {
7558 : 0 : return test_snow3g_auth_cipher(
7559 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7560 : : }
7561 : :
7562 : : static int
7563 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7564 : : {
7565 : 0 : return test_snow3g_auth_cipher(
7566 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7567 : : }
7568 : :
7569 : : static int
7570 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7571 : : {
7572 : 0 : return test_snow3g_auth_cipher(
7573 : : &snow3g_auth_cipher_partial_digest_encryption,
7574 : : IN_PLACE, 0);
7575 : : }
7576 : :
7577 : : static int
7578 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7579 : : {
7580 : 0 : return test_snow3g_auth_cipher(
7581 : : &snow3g_auth_cipher_partial_digest_encryption,
7582 : : OUT_OF_PLACE, 0);
7583 : : }
7584 : :
7585 : : static int
7586 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7587 : : {
7588 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7589 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7590 : : return TEST_SKIPPED;
7591 : 0 : return test_snow3g_auth_cipher_sgl(
7592 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7593 : : }
7594 : :
7595 : : static int
7596 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7597 : : {
7598 : 0 : return test_snow3g_auth_cipher_sgl(
7599 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7600 : : }
7601 : :
7602 : : static int
7603 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7604 : : {
7605 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7606 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7607 : : return TEST_SKIPPED;
7608 : 0 : return test_snow3g_auth_cipher_sgl(
7609 : : &snow3g_auth_cipher_partial_digest_encryption,
7610 : : IN_PLACE, 0);
7611 : : }
7612 : :
7613 : : static int
7614 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7615 : : {
7616 : 0 : return test_snow3g_auth_cipher_sgl(
7617 : : &snow3g_auth_cipher_partial_digest_encryption,
7618 : : OUT_OF_PLACE, 0);
7619 : : }
7620 : :
7621 : : static int
7622 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7623 : : {
7624 : 0 : return test_snow3g_auth_cipher(
7625 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7626 : : }
7627 : :
7628 : : static int
7629 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7630 : : {
7631 : 0 : return test_snow3g_auth_cipher(
7632 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7633 : : }
7634 : :
7635 : : static int
7636 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7637 : : {
7638 : 0 : return test_snow3g_auth_cipher_sgl(
7639 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7640 : : }
7641 : :
7642 : : static int
7643 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7644 : : {
7645 : 0 : return test_snow3g_auth_cipher_sgl(
7646 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7647 : : }
7648 : :
7649 : : static int
7650 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7651 : : {
7652 : 0 : return test_snow3g_auth_cipher(
7653 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7654 : : }
7655 : :
7656 : : static int
7657 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7658 : : {
7659 : 0 : return test_snow3g_auth_cipher(
7660 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7661 : : }
7662 : :
7663 : : static int
7664 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7665 : : {
7666 : 0 : return test_snow3g_auth_cipher(
7667 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7668 : : }
7669 : :
7670 : : static int
7671 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7672 : : {
7673 : 0 : return test_snow3g_auth_cipher(
7674 : : &snow3g_auth_cipher_partial_digest_encryption,
7675 : : IN_PLACE, 1);
7676 : : }
7677 : :
7678 : : static int
7679 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7680 : : {
7681 : 0 : return test_snow3g_auth_cipher(
7682 : : &snow3g_auth_cipher_partial_digest_encryption,
7683 : : OUT_OF_PLACE, 1);
7684 : : }
7685 : :
7686 : : static int
7687 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7688 : : {
7689 : 0 : return test_snow3g_auth_cipher_sgl(
7690 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7691 : : }
7692 : :
7693 : : static int
7694 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7695 : : {
7696 : 0 : return test_snow3g_auth_cipher_sgl(
7697 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7698 : : }
7699 : :
7700 : : static int
7701 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7702 : : {
7703 : 0 : return test_snow3g_auth_cipher_sgl(
7704 : : &snow3g_auth_cipher_partial_digest_encryption,
7705 : : IN_PLACE, 1);
7706 : : }
7707 : :
7708 : : static int
7709 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7710 : : {
7711 : 0 : return test_snow3g_auth_cipher_sgl(
7712 : : &snow3g_auth_cipher_partial_digest_encryption,
7713 : : OUT_OF_PLACE, 1);
7714 : : }
7715 : :
7716 : : static int
7717 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7718 : : {
7719 : 0 : return test_snow3g_auth_cipher(
7720 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7721 : : }
7722 : :
7723 : : static int
7724 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7725 : : {
7726 : 0 : return test_snow3g_auth_cipher(
7727 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7728 : : }
7729 : :
7730 : : static int
7731 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7732 : : {
7733 : 0 : return test_snow3g_auth_cipher_sgl(
7734 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7735 : : }
7736 : :
7737 : : static int
7738 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7739 : : {
7740 : 0 : return test_snow3g_auth_cipher_sgl(
7741 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7742 : : }
7743 : :
7744 : : static int
7745 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7746 : : {
7747 : 0 : return test_snow3g_auth_cipher(
7748 : : &snow3g_test_case_7, IN_PLACE, 0);
7749 : : }
7750 : :
7751 : : static int
7752 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7753 : : {
7754 : 0 : return test_kasumi_auth_cipher(
7755 : : &kasumi_test_case_3, IN_PLACE, 0);
7756 : : }
7757 : :
7758 : : static int
7759 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7760 : : {
7761 : 0 : return test_kasumi_auth_cipher(
7762 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7763 : : }
7764 : :
7765 : : static int
7766 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7767 : : {
7768 : 0 : return test_kasumi_auth_cipher(
7769 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7770 : : }
7771 : :
7772 : : static int
7773 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7774 : : {
7775 : 0 : return test_kasumi_auth_cipher_sgl(
7776 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7777 : : }
7778 : :
7779 : : static int
7780 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7781 : : {
7782 : 0 : return test_kasumi_auth_cipher_sgl(
7783 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7784 : : }
7785 : :
7786 : : static int
7787 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7788 : : {
7789 : 0 : return test_kasumi_auth_cipher(
7790 : : &kasumi_test_case_3, IN_PLACE, 1);
7791 : : }
7792 : :
7793 : : static int
7794 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7795 : : {
7796 : 0 : return test_kasumi_auth_cipher(
7797 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7798 : : }
7799 : :
7800 : : static int
7801 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7802 : : {
7803 : 0 : return test_kasumi_auth_cipher(
7804 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7805 : : }
7806 : :
7807 : : static int
7808 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7809 : : {
7810 : 0 : return test_kasumi_auth_cipher_sgl(
7811 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7812 : : }
7813 : :
7814 : : static int
7815 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7816 : : {
7817 : 0 : return test_kasumi_auth_cipher_sgl(
7818 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7819 : : }
7820 : :
7821 : : static int
7822 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7823 : : {
7824 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7825 : : }
7826 : :
7827 : : static int
7828 : 0 : test_zuc_encryption_test_case_1(void)
7829 : : {
7830 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7831 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7832 : : }
7833 : :
7834 : : static int
7835 : 0 : test_zuc_encryption_test_case_2(void)
7836 : : {
7837 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7838 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7839 : : }
7840 : :
7841 : : static int
7842 : 0 : test_zuc_encryption_test_case_3(void)
7843 : : {
7844 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7845 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7846 : : }
7847 : :
7848 : : static int
7849 : 0 : test_zuc_encryption_test_case_4(void)
7850 : : {
7851 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7852 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7853 : : }
7854 : :
7855 : : static int
7856 : 0 : test_zuc_encryption_test_case_5(void)
7857 : : {
7858 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7859 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7860 : : }
7861 : :
7862 : : static int
7863 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7864 : : {
7865 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7866 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7867 : : }
7868 : :
7869 : : static int
7870 : 0 : test_zuc_decryption_test_case_1(void)
7871 : : {
7872 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7873 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7874 : : }
7875 : :
7876 : : static int
7877 : 0 : test_zuc_decryption_test_case_2(void)
7878 : : {
7879 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7880 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7881 : : }
7882 : :
7883 : : static int
7884 : 0 : test_zuc_decryption_test_case_3(void)
7885 : : {
7886 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7887 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7888 : : }
7889 : :
7890 : : static int
7891 : 0 : test_zuc_decryption_test_case_4(void)
7892 : : {
7893 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7894 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7895 : : }
7896 : :
7897 : : static int
7898 : 0 : test_zuc_decryption_test_case_5(void)
7899 : : {
7900 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7901 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7902 : : }
7903 : :
7904 : : static int
7905 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7906 : : {
7907 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7908 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7909 : : }
7910 : :
7911 : : static int
7912 : 0 : test_zuc_hash_generate_test_case_1(void)
7913 : : {
7914 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7915 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7916 : : }
7917 : :
7918 : : static int
7919 : 0 : test_zuc_hash_generate_test_case_2(void)
7920 : : {
7921 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7922 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7923 : : }
7924 : :
7925 : : static int
7926 : 0 : test_zuc_hash_generate_test_case_3(void)
7927 : : {
7928 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7929 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7930 : : }
7931 : :
7932 : : static int
7933 : 0 : test_zuc_hash_generate_test_case_4(void)
7934 : : {
7935 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7936 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7937 : : }
7938 : :
7939 : : static int
7940 : 0 : test_zuc_hash_generate_test_case_5(void)
7941 : : {
7942 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7943 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7944 : : }
7945 : :
7946 : : static int
7947 : 0 : test_zuc_hash_generate_test_case_6(void)
7948 : : {
7949 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7950 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7951 : : }
7952 : :
7953 : : static int
7954 : 0 : test_zuc_hash_generate_test_case_7(void)
7955 : : {
7956 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7957 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7958 : : }
7959 : :
7960 : : static int
7961 : 0 : test_zuc_hash_generate_test_case_8(void)
7962 : : {
7963 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7964 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7965 : : }
7966 : :
7967 : : static int
7968 : 0 : test_zuc_hash_verify_test_case_1(void)
7969 : : {
7970 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7971 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7972 : : }
7973 : :
7974 : : static int
7975 : 0 : test_zuc_hash_verify_test_case_2(void)
7976 : : {
7977 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7978 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7979 : : }
7980 : :
7981 : : static int
7982 : 0 : test_zuc_hash_verify_test_case_3(void)
7983 : : {
7984 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7985 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7986 : : }
7987 : :
7988 : : static int
7989 : 0 : test_zuc_hash_verify_test_case_4(void)
7990 : : {
7991 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7992 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7993 : : }
7994 : :
7995 : : static int
7996 : 0 : test_zuc_hash_verify_test_case_5(void)
7997 : : {
7998 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7999 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8000 : : }
8001 : :
8002 : : static int
8003 : 0 : test_zuc_hash_verify_test_case_6(void)
8004 : : {
8005 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
8006 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8007 : : }
8008 : :
8009 : : static int
8010 : 0 : test_zuc_hash_verify_test_case_7(void)
8011 : : {
8012 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
8013 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8014 : : }
8015 : :
8016 : : static int
8017 : 0 : test_zuc_hash_verify_test_case_8(void)
8018 : : {
8019 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
8020 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8021 : : }
8022 : :
8023 : : static int
8024 : 0 : test_zuc_cipher_auth_test_case_1(void)
8025 : : {
8026 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
8027 : : }
8028 : :
8029 : : static int
8030 : 0 : test_zuc_cipher_auth_test_case_2(void)
8031 : : {
8032 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
8033 : : }
8034 : :
8035 : : static int
8036 : 0 : test_zuc_auth_cipher_test_case_1(void)
8037 : : {
8038 : 0 : return test_zuc_auth_cipher(
8039 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8040 : : }
8041 : :
8042 : : static int
8043 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
8044 : : {
8045 : 0 : return test_zuc_auth_cipher(
8046 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8047 : : }
8048 : :
8049 : : static int
8050 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
8051 : : {
8052 : 0 : return test_zuc_auth_cipher_sgl(
8053 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8054 : : }
8055 : :
8056 : : static int
8057 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
8058 : : {
8059 : 0 : return test_zuc_auth_cipher_sgl(
8060 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8061 : : }
8062 : :
8063 : : static int
8064 : 0 : test_zuc_auth_cipher_test_case_2(void)
8065 : : {
8066 : 0 : return test_zuc_auth_cipher(
8067 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
8068 : : }
8069 : :
8070 : : static int
8071 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
8072 : : {
8073 : 0 : return test_zuc_auth_cipher(
8074 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
8075 : : }
8076 : :
8077 : : static int
8078 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
8079 : : {
8080 : 0 : return test_zuc_auth_cipher(
8081 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8082 : : }
8083 : :
8084 : : static int
8085 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
8086 : : {
8087 : 0 : return test_zuc_auth_cipher(
8088 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8089 : : }
8090 : :
8091 : : static int
8092 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
8093 : : {
8094 : 0 : return test_zuc_auth_cipher_sgl(
8095 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8096 : : }
8097 : :
8098 : : static int
8099 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
8100 : : {
8101 : 0 : return test_zuc_auth_cipher_sgl(
8102 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8103 : : }
8104 : :
8105 : : static int
8106 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
8107 : : {
8108 : 0 : return test_zuc_auth_cipher(
8109 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
8110 : : }
8111 : :
8112 : : static int
8113 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
8114 : : {
8115 : 0 : return test_zuc_auth_cipher(
8116 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8117 : : }
8118 : :
8119 : : static int
8120 : 0 : test_zuc256_encryption_test_case_1(void)
8121 : : {
8122 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8123 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8124 : : }
8125 : :
8126 : : static int
8127 : 0 : test_zuc256_encryption_test_case_2(void)
8128 : : {
8129 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8130 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8131 : : }
8132 : :
8133 : : static int
8134 : 0 : test_zuc256_decryption_test_case_1(void)
8135 : : {
8136 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8137 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8138 : : }
8139 : :
8140 : : static int
8141 : 0 : test_zuc256_decryption_test_case_2(void)
8142 : : {
8143 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8144 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8145 : : }
8146 : :
8147 : : static int
8148 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
8149 : : {
8150 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8151 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8152 : : }
8153 : :
8154 : : static int
8155 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
8156 : : {
8157 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8158 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8159 : : }
8160 : :
8161 : : static int
8162 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
8163 : : {
8164 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8165 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8166 : : }
8167 : :
8168 : : static int
8169 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
8170 : : {
8171 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8172 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8173 : : }
8174 : :
8175 : : static int
8176 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
8177 : : {
8178 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8179 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8180 : : }
8181 : :
8182 : : static int
8183 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
8184 : : {
8185 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8186 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8187 : : }
8188 : :
8189 : : static int
8190 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
8191 : : {
8192 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8193 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8194 : : }
8195 : :
8196 : : static int
8197 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
8198 : : {
8199 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8200 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8201 : : }
8202 : :
8203 : : static int
8204 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
8205 : : {
8206 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8207 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8208 : : }
8209 : :
8210 : : static int
8211 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
8212 : : {
8213 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8214 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8215 : : }
8216 : :
8217 : : static int
8218 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8219 : : {
8220 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8221 : : }
8222 : :
8223 : : static int
8224 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8225 : : {
8226 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8227 : : }
8228 : :
8229 : : static int
8230 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8231 : : {
8232 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8233 : : }
8234 : :
8235 : : static int
8236 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8237 : : {
8238 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8239 : : }
8240 : :
8241 : : static int
8242 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8243 : : {
8244 : 0 : return test_zuc_auth_cipher(
8245 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8246 : : }
8247 : :
8248 : : static int
8249 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8250 : : {
8251 : 0 : return test_zuc_auth_cipher(
8252 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8253 : : }
8254 : :
8255 : : static int
8256 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8257 : : {
8258 : 0 : return test_zuc_auth_cipher(
8259 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8260 : : }
8261 : :
8262 : : static int
8263 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8264 : : {
8265 : 0 : return test_zuc_auth_cipher(
8266 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8267 : : }
8268 : :
8269 : : static int
8270 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8271 : : {
8272 : 0 : return test_zuc_auth_cipher(
8273 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8274 : : }
8275 : :
8276 : : static int
8277 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8278 : : {
8279 : 0 : return test_zuc_auth_cipher(
8280 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8281 : : }
8282 : :
8283 : : static int
8284 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8285 : : {
8286 : 0 : return test_zuc_auth_cipher(
8287 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8288 : : }
8289 : :
8290 : : static int
8291 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8292 : : {
8293 : 0 : return test_zuc_auth_cipher(
8294 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8295 : : }
8296 : :
8297 : : static int
8298 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8299 : : {
8300 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
8301 : :
8302 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8303 : :
8304 : : /* Check if device supports particular cipher algorithm */
8305 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8306 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
8307 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8308 : : return TEST_SKIPPED;
8309 : :
8310 : : /* Check if device supports particular hash algorithm */
8311 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8312 : 24 : cap_idx.algo.auth = tdata->auth_algo;
8313 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8314 : 12 : return TEST_SKIPPED;
8315 : :
8316 : : return 0;
8317 : : }
8318 : :
8319 : : static int
8320 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8321 : : uint8_t op_mode, uint8_t verify)
8322 : : {
8323 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8324 : : struct crypto_unittest_params *ut_params = &unittest_params;
8325 : :
8326 : : int retval;
8327 : :
8328 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
8329 : : unsigned int plaintext_pad_len;
8330 : : unsigned int plaintext_len;
8331 : : unsigned int ciphertext_pad_len;
8332 : : unsigned int ciphertext_len;
8333 : : unsigned int digest_offset;
8334 : :
8335 : : struct rte_cryptodev_info dev_info;
8336 : : struct rte_crypto_op *op;
8337 : :
8338 : : /* Check if device supports particular algorithms separately */
8339 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
8340 : : return TEST_SKIPPED;
8341 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8342 : : return TEST_SKIPPED;
8343 : :
8344 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8345 : : return TEST_SKIPPED;
8346 : :
8347 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8348 : :
8349 : 8 : uint64_t feat_flags = dev_info.feature_flags;
8350 : :
8351 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8352 : : printf("Device doesn't support digest encrypted.\n");
8353 : 8 : return TEST_SKIPPED;
8354 : : }
8355 : :
8356 : : /* Create the session */
8357 [ # # ]: 0 : if (verify)
8358 : 0 : retval = create_wireless_algo_cipher_auth_session(
8359 : 0 : ts_params->valid_devs[0],
8360 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8361 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8362 : 0 : tdata->auth_algo,
8363 : 0 : tdata->cipher_algo,
8364 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8365 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8366 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8367 : 0 : tdata->cipher_iv.len);
8368 : : else
8369 : 0 : retval = create_wireless_algo_auth_cipher_session(
8370 : 0 : ts_params->valid_devs[0],
8371 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8372 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8373 : 0 : tdata->auth_algo,
8374 : 0 : tdata->cipher_algo,
8375 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8376 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8377 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8378 : 0 : tdata->cipher_iv.len);
8379 [ # # ]: 0 : if (retval != 0)
8380 : : return retval;
8381 : :
8382 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8383 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8384 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8385 : :
8386 : : /* clear mbuf payload */
8387 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8388 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8389 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8390 : :
8391 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8392 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8393 : : }
8394 : :
8395 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8396 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8397 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8398 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8399 : :
8400 [ # # ]: 0 : if (verify) {
8401 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8402 : : ciphertext_pad_len);
8403 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8404 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8405 : : ciphertext_len);
8406 : : } else {
8407 : : /* make sure enough space to cover partial digest verify case */
8408 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8409 : : ciphertext_pad_len);
8410 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8411 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8412 : : }
8413 : :
8414 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8415 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8416 : :
8417 : : /* Create the operation */
8418 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8419 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8420 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8421 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8422 : 0 : (tdata->digest_enc.offset == 0 ?
8423 : : plaintext_pad_len
8424 : : : tdata->digest_enc.offset),
8425 : 0 : tdata->validCipherLen.len_bits,
8426 : 0 : tdata->cipher.offset_bits,
8427 : 0 : tdata->validAuthLen.len_bits,
8428 [ # # ]: 0 : tdata->auth.offset_bits,
8429 : : op_mode, 0, verify);
8430 : :
8431 [ # # ]: 0 : if (retval < 0)
8432 : : return retval;
8433 : :
8434 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8435 : :
8436 : : /* Check if the op failed because the device doesn't */
8437 : : /* support this particular combination of algorithms */
8438 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8439 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8440 : : printf("Device doesn't support this mixed combination. "
8441 : : "Test Skipped.\n");
8442 : 0 : return TEST_SKIPPED;
8443 : : }
8444 : 0 : ut_params->op = op;
8445 : :
8446 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8447 : :
8448 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8449 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8450 : :
8451 [ # # ]: 0 : if (verify) {
8452 [ # # ]: 0 : if (ut_params->obuf)
8453 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8454 : : uint8_t *);
8455 : : else
8456 : 0 : plaintext = ciphertext +
8457 : 0 : (tdata->cipher.offset_bits >> 3);
8458 : :
8459 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8460 : 0 : tdata->plaintext.len_bits >> 3);
8461 : 0 : debug_hexdump(stdout, "plaintext expected:",
8462 : 0 : tdata->plaintext.data,
8463 : 0 : tdata->plaintext.len_bits >> 3);
8464 : : } else {
8465 [ # # ]: 0 : if (ut_params->obuf)
8466 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8467 : : uint8_t *);
8468 : : else
8469 : : ciphertext = plaintext;
8470 : :
8471 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8472 : : ciphertext_len);
8473 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8474 : 0 : tdata->ciphertext.data,
8475 : 0 : tdata->ciphertext.len_bits >> 3);
8476 : :
8477 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8478 : : digest_offset = plaintext_pad_len;
8479 : : else
8480 : : digest_offset = tdata->digest_enc.offset;
8481 : :
8482 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8483 : : uint8_t *, digest_offset);
8484 : :
8485 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8486 : 0 : tdata->digest_enc.len);
8487 : 0 : debug_hexdump(stdout, "digest expected:",
8488 : : tdata->digest_enc.data,
8489 : 0 : tdata->digest_enc.len);
8490 : : }
8491 : :
8492 [ # # ]: 0 : if (!verify) {
8493 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8494 : : ut_params->digest,
8495 : : tdata->digest_enc.data,
8496 : : tdata->digest_enc.len,
8497 : : "Generated auth tag not as expected");
8498 : : }
8499 : :
8500 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8501 [ # # ]: 0 : if (verify) {
8502 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8503 : : plaintext,
8504 : : tdata->plaintext.data,
8505 : : tdata->plaintext.len_bits >> 3,
8506 : : "Plaintext data not as expected");
8507 : : } else {
8508 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8509 : : ciphertext,
8510 : : tdata->ciphertext.data,
8511 : : tdata->validDataLen.len_bits,
8512 : : "Ciphertext data not as expected");
8513 : : }
8514 : : }
8515 : :
8516 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8517 : : "crypto op processing failed");
8518 : :
8519 : : return 0;
8520 : : }
8521 : :
8522 : : static int
8523 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8524 : : uint8_t op_mode, uint8_t verify)
8525 : : {
8526 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8527 : : struct crypto_unittest_params *ut_params = &unittest_params;
8528 : :
8529 : : int retval;
8530 : :
8531 : : const uint8_t *plaintext = NULL;
8532 : : const uint8_t *ciphertext = NULL;
8533 : : const uint8_t *digest = NULL;
8534 : : unsigned int plaintext_pad_len;
8535 : : unsigned int plaintext_len;
8536 : : unsigned int ciphertext_pad_len;
8537 : : unsigned int ciphertext_len;
8538 : : uint8_t buffer[10000];
8539 : : uint8_t digest_buffer[10000];
8540 : :
8541 : : struct rte_cryptodev_info dev_info;
8542 : : struct rte_crypto_op *op;
8543 : :
8544 : : /* Check if device supports particular algorithms */
8545 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8546 : : return TEST_SKIPPED;
8547 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8548 : : return TEST_SKIPPED;
8549 : :
8550 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8551 : :
8552 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8553 : :
8554 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8555 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8556 : : printf("Device doesn't support in-place scatter-gather "
8557 : : "in both input and output mbufs.\n");
8558 : 0 : return TEST_SKIPPED;
8559 : : }
8560 : : } else {
8561 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8562 : : printf("Device doesn't support out-of-place scatter-gather "
8563 : : "in both input and output mbufs.\n");
8564 : 2 : return TEST_SKIPPED;
8565 : : }
8566 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8567 : : printf("Device doesn't support digest encrypted.\n");
8568 : 0 : return TEST_SKIPPED;
8569 : : }
8570 : : }
8571 : :
8572 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8573 : : return TEST_SKIPPED;
8574 : :
8575 : : /* Create the session */
8576 [ + + ]: 2 : if (verify)
8577 : 1 : retval = create_wireless_algo_cipher_auth_session(
8578 : 1 : ts_params->valid_devs[0],
8579 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8580 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8581 : 1 : tdata->auth_algo,
8582 : 1 : tdata->cipher_algo,
8583 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8584 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8585 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8586 : 1 : tdata->cipher_iv.len);
8587 : : else
8588 : 1 : retval = create_wireless_algo_auth_cipher_session(
8589 : 1 : ts_params->valid_devs[0],
8590 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8591 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8592 : 1 : tdata->auth_algo,
8593 : 1 : tdata->cipher_algo,
8594 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8595 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8596 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8597 : 1 : tdata->cipher_iv.len);
8598 [ + - ]: 2 : if (retval != 0)
8599 : : return retval;
8600 : :
8601 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8602 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8603 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8604 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8605 : :
8606 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8607 : : ciphertext_pad_len, 15, 0);
8608 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8609 : : "Failed to allocate input buffer in mempool");
8610 : :
8611 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8612 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8613 : : plaintext_pad_len, 15, 0);
8614 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8615 : : "Failed to allocate output buffer in mempool");
8616 : : }
8617 : :
8618 [ + + ]: 2 : if (verify) {
8619 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8620 : 1 : tdata->ciphertext.data);
8621 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8622 : : ciphertext_len, buffer);
8623 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8624 : : ciphertext_len);
8625 : : } else {
8626 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8627 : 1 : tdata->plaintext.data);
8628 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8629 : : plaintext_len, buffer);
8630 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8631 : : plaintext_len);
8632 : : }
8633 : : memset(buffer, 0, sizeof(buffer));
8634 : :
8635 : : /* Create the operation */
8636 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8637 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8638 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8639 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8640 : 2 : (tdata->digest_enc.offset == 0 ?
8641 : : plaintext_pad_len
8642 : : : tdata->digest_enc.offset),
8643 : 2 : tdata->validCipherLen.len_bits,
8644 : 2 : tdata->cipher.offset_bits,
8645 : 2 : tdata->validAuthLen.len_bits,
8646 [ + - ]: 2 : tdata->auth.offset_bits,
8647 : : op_mode, 1, verify);
8648 : :
8649 [ + - ]: 2 : if (retval < 0)
8650 : : return retval;
8651 : :
8652 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8653 : :
8654 : : /* Check if the op failed because the device doesn't */
8655 : : /* support this particular combination of algorithms */
8656 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8657 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8658 : : printf("Device doesn't support this mixed combination. "
8659 : : "Test Skipped.\n");
8660 : 0 : return TEST_SKIPPED;
8661 : : }
8662 : 2 : ut_params->op = op;
8663 : :
8664 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8665 : :
8666 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8667 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8668 : :
8669 [ + + ]: 2 : if (verify) {
8670 [ + - ]: 1 : if (ut_params->obuf)
8671 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8672 : : plaintext_len, buffer);
8673 : : else
8674 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8675 : : plaintext_len, buffer);
8676 : :
8677 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8678 : 1 : (tdata->plaintext.len_bits >> 3) -
8679 : 1 : tdata->digest_enc.len);
8680 : 1 : debug_hexdump(stdout, "plaintext expected:",
8681 : 1 : tdata->plaintext.data,
8682 : 1 : (tdata->plaintext.len_bits >> 3) -
8683 : 1 : tdata->digest_enc.len);
8684 : : } else {
8685 [ + - ]: 1 : if (ut_params->obuf)
8686 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8687 : : ciphertext_len, buffer);
8688 : : else
8689 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8690 : : ciphertext_len, buffer);
8691 : :
8692 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8693 : : ciphertext_len);
8694 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8695 : 1 : tdata->ciphertext.data,
8696 : 1 : tdata->ciphertext.len_bits >> 3);
8697 : :
8698 [ + - ]: 1 : if (ut_params->obuf)
8699 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8700 : 1 : (tdata->digest_enc.offset == 0 ?
8701 : : plaintext_pad_len :
8702 : : tdata->digest_enc.offset),
8703 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8704 : : else
8705 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8706 : 0 : (tdata->digest_enc.offset == 0 ?
8707 : : plaintext_pad_len :
8708 : : tdata->digest_enc.offset),
8709 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8710 : :
8711 : 1 : debug_hexdump(stdout, "digest:", digest,
8712 : 1 : tdata->digest_enc.len);
8713 : 1 : debug_hexdump(stdout, "digest expected:",
8714 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8715 : : }
8716 : :
8717 [ + + ]: 2 : if (!verify) {
8718 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8719 : : digest,
8720 : : tdata->digest_enc.data,
8721 : : tdata->digest_enc.len,
8722 : : "Generated auth tag not as expected");
8723 : : }
8724 : :
8725 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8726 [ + + ]: 2 : if (verify) {
8727 [ - + + - : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- + ]
8728 : : plaintext,
8729 : : tdata->plaintext.data,
8730 : : tdata->plaintext.len_bits >> 3,
8731 : : "Plaintext data not as expected");
8732 : : } else {
8733 [ - + - + : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- - ]
8734 : : ciphertext,
8735 : : tdata->ciphertext.data,
8736 : : tdata->validDataLen.len_bits,
8737 : : "Ciphertext data not as expected");
8738 : : }
8739 : : }
8740 : :
8741 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8742 : : "crypto op processing failed");
8743 : :
8744 : : return 0;
8745 : : }
8746 : :
8747 : : /** AUTH AES CMAC + CIPHER AES CTR */
8748 : :
8749 : : static int
8750 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8751 : : {
8752 : 1 : return test_mixed_auth_cipher(
8753 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8754 : : }
8755 : :
8756 : : static int
8757 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8758 : : {
8759 : 1 : return test_mixed_auth_cipher(
8760 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8761 : : }
8762 : :
8763 : : static int
8764 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8765 : : {
8766 : 1 : return test_mixed_auth_cipher_sgl(
8767 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8768 : : }
8769 : :
8770 : : static int
8771 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8772 : : {
8773 : 1 : return test_mixed_auth_cipher_sgl(
8774 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8775 : : }
8776 : :
8777 : : static int
8778 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8779 : : {
8780 : 1 : return test_mixed_auth_cipher(
8781 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8782 : : }
8783 : :
8784 : : static int
8785 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8786 : : {
8787 : 1 : return test_mixed_auth_cipher(
8788 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8789 : : }
8790 : :
8791 : : static int
8792 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8793 : : {
8794 : 1 : return test_mixed_auth_cipher(
8795 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8796 : : }
8797 : :
8798 : : static int
8799 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8800 : : {
8801 : 1 : return test_mixed_auth_cipher(
8802 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8803 : : }
8804 : :
8805 : : static int
8806 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8807 : : {
8808 : 1 : return test_mixed_auth_cipher(
8809 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8810 : : }
8811 : :
8812 : : static int
8813 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8814 : : {
8815 : 1 : return test_mixed_auth_cipher_sgl(
8816 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8817 : : }
8818 : :
8819 : : static int
8820 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8821 : : {
8822 : 1 : return test_mixed_auth_cipher_sgl(
8823 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8824 : : }
8825 : :
8826 : : static int
8827 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8828 : : {
8829 : 1 : return test_mixed_auth_cipher(
8830 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8831 : : }
8832 : :
8833 : : /** MIXED AUTH + CIPHER */
8834 : :
8835 : : static int
8836 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8837 : : {
8838 : 1 : return test_mixed_auth_cipher(
8839 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8840 : : }
8841 : :
8842 : : static int
8843 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8844 : : {
8845 : 1 : return test_mixed_auth_cipher(
8846 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8847 : : }
8848 : :
8849 : : static int
8850 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8851 : : {
8852 : 1 : return test_mixed_auth_cipher(
8853 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8854 : : }
8855 : :
8856 : : static int
8857 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8858 : : {
8859 : 1 : return test_mixed_auth_cipher(
8860 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8861 : : }
8862 : :
8863 : :
8864 : : static int
8865 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8866 : : {
8867 : 1 : return test_mixed_auth_cipher(
8868 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8869 : : }
8870 : :
8871 : : static int
8872 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8873 : : {
8874 : 1 : return test_mixed_auth_cipher(
8875 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8876 : : }
8877 : :
8878 : : static int
8879 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8880 : : {
8881 : 1 : return test_mixed_auth_cipher(
8882 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8883 : : }
8884 : :
8885 : : static int
8886 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8887 : : {
8888 : 1 : return test_mixed_auth_cipher(
8889 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8890 : : }
8891 : :
8892 : : static int
8893 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8894 : : {
8895 : 1 : return test_mixed_auth_cipher(
8896 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8897 : : }
8898 : :
8899 : : static int
8900 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8901 : : {
8902 : 1 : return test_mixed_auth_cipher(
8903 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8904 : : }
8905 : :
8906 : : static int
8907 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8908 : : {
8909 : 1 : return test_mixed_auth_cipher(
8910 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8911 : : }
8912 : :
8913 : : static int
8914 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8915 : : {
8916 : 1 : return test_mixed_auth_cipher(
8917 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8918 : : }
8919 : :
8920 : : static int
8921 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8922 : : {
8923 : 1 : return test_mixed_auth_cipher(
8924 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8925 : : }
8926 : :
8927 : : static int
8928 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8929 : : {
8930 : 1 : return test_mixed_auth_cipher(
8931 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8932 : : }
8933 : :
8934 : : static int
8935 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8936 : : {
8937 : 1 : return test_mixed_auth_cipher_sgl(
8938 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8939 : : }
8940 : :
8941 : : static int
8942 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8943 : : {
8944 : 1 : return test_mixed_auth_cipher(
8945 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8946 : : }
8947 : :
8948 : : static int
8949 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8950 : : {
8951 : 1 : return test_mixed_auth_cipher_sgl(
8952 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8953 : : }
8954 : :
8955 : : static int
8956 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8957 : : {
8958 : 1 : return test_mixed_auth_cipher(
8959 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8960 : : }
8961 : :
8962 : : static int
8963 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8964 : : {
8965 : 1 : return test_mixed_auth_cipher(
8966 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8967 : : }
8968 : :
8969 : : static int
8970 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8971 : : {
8972 : 1 : return test_mixed_auth_cipher(
8973 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8974 : : }
8975 : :
8976 : : static int
8977 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8978 : : {
8979 : 1 : return test_mixed_auth_cipher(
8980 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8981 : : }
8982 : :
8983 : : static int
8984 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8985 : : {
8986 : 1 : return test_mixed_auth_cipher(
8987 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8988 : : }
8989 : :
8990 : : static int
8991 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8992 : : {
8993 : 1 : return test_mixed_auth_cipher(
8994 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8995 : : }
8996 : :
8997 : : static int
8998 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8999 : : {
9000 : 1 : return test_mixed_auth_cipher(
9001 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9002 : : }
9003 : : static int
9004 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9005 : : {
9006 : 1 : return test_mixed_auth_cipher(
9007 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
9008 : : }
9009 : :
9010 : : static int
9011 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9012 : : {
9013 : 1 : return test_mixed_auth_cipher(
9014 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
9015 : : }
9016 : :
9017 : : static int
9018 : 1 : test_auth_null_cipher_snow_test_case_1(void)
9019 : : {
9020 : 1 : return test_mixed_auth_cipher(
9021 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
9022 : : }
9023 : :
9024 : : static int
9025 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
9026 : : {
9027 : 1 : return test_mixed_auth_cipher(
9028 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
9029 : : }
9030 : :
9031 : : static int
9032 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
9033 : : {
9034 : 1 : return test_mixed_auth_cipher(
9035 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9036 : : }
9037 : :
9038 : : static int
9039 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
9040 : : {
9041 : 1 : return test_mixed_auth_cipher(
9042 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9043 : : }
9044 : :
9045 : : static int
9046 : 1 : test_auth_snow_cipher_null_test_case_1(void)
9047 : : {
9048 : 1 : return test_mixed_auth_cipher(
9049 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9050 : : }
9051 : :
9052 : : static int
9053 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
9054 : : {
9055 : 1 : return test_mixed_auth_cipher(
9056 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9057 : : }
9058 : :
9059 : : static int
9060 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
9061 : : {
9062 : 1 : return test_mixed_auth_cipher(
9063 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9064 : : }
9065 : :
9066 : : static int
9067 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
9068 : : {
9069 : 1 : return test_mixed_auth_cipher(
9070 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9071 : : }
9072 : :
9073 : : static int
9074 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
9075 : : {
9076 : 1 : return test_mixed_auth_cipher(
9077 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
9078 : : }
9079 : :
9080 : : static int
9081 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
9082 : : {
9083 : 1 : return test_mixed_auth_cipher(
9084 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
9085 : : }
9086 : :
9087 : : static int
9088 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
9089 : : {
9090 : 1 : return test_mixed_auth_cipher(
9091 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9092 : : }
9093 : :
9094 : : static int
9095 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
9096 : : {
9097 : 1 : return test_mixed_auth_cipher(
9098 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9099 : : }
9100 : :
9101 : : /* ***** AEAD algorithm Tests ***** */
9102 : :
9103 : : static int
9104 : 85 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
9105 : : enum rte_crypto_aead_operation op,
9106 : : const uint8_t *key, const uint8_t key_len,
9107 : : const uint16_t aad_len, const uint8_t auth_len,
9108 : : uint8_t iv_len)
9109 : : {
9110 : 85 : uint8_t *aead_key = alloca(key_len);
9111 : :
9112 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9113 : : struct crypto_unittest_params *ut_params = &unittest_params;
9114 : :
9115 : : memcpy(aead_key, key, key_len);
9116 : :
9117 : : /* Setup AEAD Parameters */
9118 : 85 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9119 : 85 : ut_params->aead_xform.next = NULL;
9120 : 85 : ut_params->aead_xform.aead.algo = algo;
9121 : 85 : ut_params->aead_xform.aead.op = op;
9122 : 85 : ut_params->aead_xform.aead.key.data = aead_key;
9123 : 85 : ut_params->aead_xform.aead.key.length = key_len;
9124 : 85 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9125 : 85 : ut_params->aead_xform.aead.iv.length = iv_len;
9126 : 85 : ut_params->aead_xform.aead.digest_length = auth_len;
9127 : 85 : ut_params->aead_xform.aead.aad_length = aad_len;
9128 : :
9129 : 85 : debug_hexdump(stdout, "key:", key, key_len);
9130 : :
9131 : : /* Create Crypto session*/
9132 : 85 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9133 : : &ut_params->aead_xform, ts_params->session_mpool);
9134 [ - + - - ]: 85 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9135 : : return TEST_SKIPPED;
9136 [ - + ]: 85 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9137 : : return 0;
9138 : : }
9139 : :
9140 : : static int
9141 : 2 : create_aead_xform(struct rte_crypto_op *op,
9142 : : enum rte_crypto_aead_algorithm algo,
9143 : : enum rte_crypto_aead_operation aead_op,
9144 : : uint8_t *key, const uint8_t key_len,
9145 : : const uint8_t aad_len, const uint8_t auth_len,
9146 : : uint8_t iv_len)
9147 : : {
9148 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9149 : : "failed to allocate space for crypto transform");
9150 : :
9151 : : struct rte_crypto_sym_op *sym_op = op->sym;
9152 : :
9153 : : /* Setup AEAD Parameters */
9154 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9155 : 2 : sym_op->xform->next = NULL;
9156 : 2 : sym_op->xform->aead.algo = algo;
9157 : 2 : sym_op->xform->aead.op = aead_op;
9158 : 2 : sym_op->xform->aead.key.data = key;
9159 : 2 : sym_op->xform->aead.key.length = key_len;
9160 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
9161 : 2 : sym_op->xform->aead.iv.length = iv_len;
9162 : 2 : sym_op->xform->aead.digest_length = auth_len;
9163 : 2 : sym_op->xform->aead.aad_length = aad_len;
9164 : :
9165 : 2 : debug_hexdump(stdout, "key:", key, key_len);
9166 : :
9167 : : return 0;
9168 : : }
9169 : :
9170 : : static int
9171 : 86 : create_aead_operation(enum rte_crypto_aead_operation op,
9172 : : const struct aead_test_data *tdata)
9173 : : {
9174 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9175 : : struct crypto_unittest_params *ut_params = &unittest_params;
9176 : :
9177 : : uint8_t *plaintext, *ciphertext;
9178 : : unsigned int aad_pad_len, plaintext_pad_len;
9179 : :
9180 : : /* Generate Crypto op data structure */
9181 : 86 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9182 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9183 [ - + ]: 86 : TEST_ASSERT_NOT_NULL(ut_params->op,
9184 : : "Failed to allocate symmetric crypto operation struct");
9185 : :
9186 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9187 : :
9188 : : /* Append aad data */
9189 [ + + ]: 86 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9190 : 18 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9191 : 18 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9192 : : aad_pad_len);
9193 [ - + ]: 18 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9194 : : "no room to append aad");
9195 : :
9196 : 18 : sym_op->aead.aad.phys_addr =
9197 : 18 : rte_pktmbuf_iova(ut_params->ibuf);
9198 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9199 : 18 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9200 : 18 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9201 : 18 : tdata->aad.len);
9202 : :
9203 : : /* Append IV at the end of the crypto operation*/
9204 : 18 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9205 : : uint8_t *, IV_OFFSET);
9206 : :
9207 : : /* Copy IV 1 byte after the IV pointer, according to the API */
9208 [ - + ]: 18 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9209 : 18 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
9210 : 18 : tdata->iv.len);
9211 : : } else {
9212 : 68 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9213 : 68 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9214 : : aad_pad_len);
9215 [ - + ]: 68 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9216 : : "no room to append aad");
9217 : :
9218 : 68 : sym_op->aead.aad.phys_addr =
9219 : 68 : rte_pktmbuf_iova(ut_params->ibuf);
9220 : 68 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9221 : 68 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9222 : 68 : tdata->aad.len);
9223 : :
9224 : : /* Append IV at the end of the crypto operation*/
9225 : 68 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9226 : : uint8_t *, IV_OFFSET);
9227 : :
9228 [ - + ]: 68 : if (tdata->iv.len == 0) {
9229 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9230 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
9231 : : AES_GCM_J0_LENGTH);
9232 : : } else {
9233 [ - + ]: 68 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9234 : 68 : debug_hexdump(stdout, "iv:", iv_ptr,
9235 : 68 : tdata->iv.len);
9236 : : }
9237 : : }
9238 : :
9239 : : /* Append plaintext/ciphertext */
9240 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9241 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9242 : 43 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9243 : : plaintext_pad_len);
9244 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9245 : :
9246 : 43 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9247 : 43 : debug_hexdump(stdout, "plaintext:", plaintext,
9248 : 43 : tdata->plaintext.len);
9249 : :
9250 [ + + ]: 43 : if (ut_params->obuf) {
9251 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
9252 : : ut_params->obuf,
9253 : 1 : plaintext_pad_len + aad_pad_len);
9254 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
9255 : : "no room to append ciphertext");
9256 : :
9257 : 1 : memset(ciphertext + aad_pad_len, 0,
9258 : 1 : tdata->ciphertext.len);
9259 : : }
9260 : : } else {
9261 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9262 : 43 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9263 : : plaintext_pad_len);
9264 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(ciphertext,
9265 : : "no room to append ciphertext");
9266 : :
9267 : 43 : memcpy(ciphertext, tdata->ciphertext.data,
9268 : 43 : tdata->ciphertext.len);
9269 : 43 : debug_hexdump(stdout, "ciphertext:", ciphertext,
9270 : 43 : tdata->ciphertext.len);
9271 : :
9272 [ + + ]: 43 : if (ut_params->obuf) {
9273 : : plaintext = (uint8_t *)rte_pktmbuf_append(
9274 : : ut_params->obuf,
9275 : 1 : plaintext_pad_len + aad_pad_len);
9276 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
9277 : : "no room to append plaintext");
9278 : :
9279 : 1 : memset(plaintext + aad_pad_len, 0,
9280 : 1 : tdata->plaintext.len);
9281 : : }
9282 : : }
9283 : :
9284 : : /* Append digest data */
9285 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9286 : 42 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9287 : 43 : ut_params->obuf ? ut_params->obuf :
9288 : : ut_params->ibuf,
9289 [ + + ]: 43 : tdata->auth_tag.len);
9290 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9291 : : "no room to append digest");
9292 [ + + ]: 43 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9293 [ + + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9294 : : ut_params->obuf ? ut_params->obuf :
9295 : : ut_params->ibuf,
9296 : : plaintext_pad_len +
9297 : : aad_pad_len);
9298 : : } else {
9299 : 86 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9300 : 43 : ut_params->ibuf, tdata->auth_tag.len);
9301 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9302 : : "no room to append digest");
9303 [ - + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9304 : : ut_params->ibuf,
9305 : : plaintext_pad_len + aad_pad_len);
9306 : :
9307 : 43 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9308 [ - + ]: 43 : tdata->auth_tag.len);
9309 : 43 : debug_hexdump(stdout, "digest:",
9310 : 43 : sym_op->aead.digest.data,
9311 : 43 : tdata->auth_tag.len);
9312 : : }
9313 : :
9314 : 86 : sym_op->aead.data.length = tdata->plaintext.len;
9315 : 86 : sym_op->aead.data.offset = aad_pad_len;
9316 : :
9317 : 86 : return 0;
9318 : : }
9319 : :
9320 : : static int
9321 : 42 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9322 : : {
9323 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9324 : : struct crypto_unittest_params *ut_params = &unittest_params;
9325 : :
9326 : : int retval;
9327 : : uint8_t *ciphertext, *auth_tag;
9328 : : uint16_t plaintext_pad_len;
9329 : : uint32_t i;
9330 : : struct rte_cryptodev_info dev_info;
9331 : :
9332 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9333 : 42 : uint64_t feat_flags = dev_info.feature_flags;
9334 : :
9335 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9336 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9337 : : printf("Device doesn't support RAW data-path APIs.\n");
9338 : 0 : return TEST_SKIPPED;
9339 : : }
9340 : :
9341 : : /* Verify the capabilities */
9342 : : struct rte_cryptodev_sym_capability_idx cap_idx;
9343 : : const struct rte_cryptodev_symmetric_capability *capability;
9344 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9345 : 42 : cap_idx.algo.aead = tdata->algo;
9346 : 42 : capability = rte_cryptodev_sym_capability_get(
9347 : 42 : ts_params->valid_devs[0], &cap_idx);
9348 [ + - ]: 42 : if (capability == NULL)
9349 : : return TEST_SKIPPED;
9350 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
9351 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
9352 : 42 : tdata->aad.len, tdata->iv.len))
9353 : : return TEST_SKIPPED;
9354 : :
9355 : : /* Create AEAD session */
9356 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
9357 : 41 : tdata->algo,
9358 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
9359 : 41 : tdata->key.data, tdata->key.len,
9360 : 41 : tdata->aad.len, tdata->auth_tag.len,
9361 : 41 : tdata->iv.len);
9362 [ + - ]: 41 : if (retval != TEST_SUCCESS)
9363 : : return retval;
9364 : :
9365 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
9366 [ - + ]: 2 : if (use_ext_mbuf) {
9367 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9368 : : AEAD_TEXT_MAX_LENGTH,
9369 : : 1 /* nb_segs */,
9370 : : NULL);
9371 : : } else {
9372 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9373 : : }
9374 : : /* Populate full size of add data */
9375 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9376 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9377 : : } else {
9378 [ + + ]: 39 : if (use_ext_mbuf) {
9379 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9380 : : AEAD_TEXT_MAX_LENGTH,
9381 : : 1 /* nb_segs */,
9382 : : NULL);
9383 : : } else {
9384 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9385 : : }
9386 : : }
9387 : :
9388 : : /* clear mbuf payload */
9389 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9390 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
9391 : :
9392 : : /* Create AEAD operation */
9393 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9394 [ + - ]: 41 : if (retval < 0)
9395 : : return retval;
9396 : :
9397 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9398 : :
9399 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
9400 : :
9401 : : /* Process crypto operation */
9402 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9403 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9404 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9405 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9406 : : 0);
9407 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9408 : : return retval;
9409 : : } else
9410 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(
9411 : : process_crypto_request(ts_params->valid_devs[0],
9412 : : ut_params->op), "failed to process sym crypto op");
9413 : :
9414 [ - + ]: 41 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9415 : : "crypto op processing failed");
9416 : :
9417 : 41 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9418 : :
9419 [ - + ]: 41 : if (ut_params->op->sym->m_dst) {
9420 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9421 : : uint8_t *);
9422 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9423 : : uint8_t *, plaintext_pad_len);
9424 : : } else {
9425 : 41 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9426 : : uint8_t *,
9427 : : ut_params->op->sym->cipher.data.offset);
9428 : 41 : auth_tag = ciphertext + plaintext_pad_len;
9429 : : }
9430 : :
9431 : 41 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9432 : 41 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9433 : :
9434 : : /* Validate obuf */
9435 [ + + ]: 44 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9436 : : ciphertext,
9437 : : tdata->ciphertext.data,
9438 : : tdata->ciphertext.len,
9439 : : "Ciphertext data not as expected");
9440 : :
9441 [ + + ]: 41 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9442 : : auth_tag,
9443 : : tdata->auth_tag.data,
9444 : : tdata->auth_tag.len,
9445 : : "Generated auth tag not as expected");
9446 : :
9447 : : return 0;
9448 : :
9449 : : }
9450 : :
9451 : : static int
9452 : : test_authenticated_encryption(const struct aead_test_data *tdata)
9453 : : {
9454 : 41 : return test_authenticated_encryption_helper(tdata, false);
9455 : : }
9456 : :
9457 : : #ifdef RTE_LIB_SECURITY
9458 : : static int
9459 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9460 : : enum rte_security_session_protocol proto)
9461 : : {
9462 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9463 : :
9464 : : const struct rte_security_capability *capabilities;
9465 : : const struct rte_security_capability *capability;
9466 : : uint16_t i = 0;
9467 : :
9468 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9469 : :
9470 : :
9471 : 0 : capabilities = rte_security_capabilities_get(ctx);
9472 : :
9473 [ # # ]: 0 : if (capabilities == NULL)
9474 : : return -ENOTSUP;
9475 : :
9476 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9477 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9478 [ # # ]: 0 : if (capability->action == action &&
9479 [ # # ]: 0 : capability->protocol == proto)
9480 : : return 0;
9481 : : }
9482 : :
9483 : : return -ENOTSUP;
9484 : : }
9485 : :
9486 : : /* Basic algorithm run function for async inplace mode.
9487 : : * Creates a session from input parameters and runs one operation
9488 : : * on input_vec. Checks the output of the crypto operation against
9489 : : * output_vec.
9490 : : */
9491 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9492 : : enum rte_crypto_auth_operation opa,
9493 : : const uint8_t *input_vec, unsigned int input_vec_len,
9494 : : const uint8_t *output_vec,
9495 : : unsigned int output_vec_len,
9496 : : enum rte_crypto_cipher_algorithm cipher_alg,
9497 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9498 : : enum rte_crypto_auth_algorithm auth_alg,
9499 : : const uint8_t *auth_key, uint32_t auth_key_len,
9500 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9501 : : uint8_t packet_direction, uint8_t sn_size,
9502 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9503 : : {
9504 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9505 : : struct crypto_unittest_params *ut_params = &unittest_params;
9506 : : uint8_t *plaintext;
9507 : : int ret = TEST_SUCCESS;
9508 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9509 : : struct rte_cryptodev_info dev_info;
9510 : : uint64_t feat_flags;
9511 : :
9512 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9513 : 0 : feat_flags = dev_info.feature_flags;
9514 : :
9515 : : /* Verify the capabilities */
9516 : : struct rte_security_capability_idx sec_cap_idx;
9517 : :
9518 : 0 : sec_cap_idx.action = ut_params->type;
9519 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9520 : 0 : sec_cap_idx.pdcp.domain = domain;
9521 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9522 : : return TEST_SKIPPED;
9523 : :
9524 : : /* Generate test mbuf data */
9525 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9526 : :
9527 : : /* clear mbuf payload */
9528 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9529 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9530 : :
9531 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9532 : : input_vec_len);
9533 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9534 : :
9535 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9536 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9537 : : printf("Device does not support RAW data-path APIs.\n");
9538 : 0 : return TEST_SKIPPED;
9539 : : }
9540 : : /* Out of place support */
9541 [ # # ]: 0 : if (oop) {
9542 : : /*
9543 : : * For out-of-place we need to alloc another mbuf
9544 : : */
9545 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9546 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9547 : : }
9548 : :
9549 : : /* Setup Cipher Parameters */
9550 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9551 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9552 : 0 : ut_params->cipher_xform.cipher.op = opc;
9553 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9554 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9555 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9556 : : packet_direction ? 4 : 0;
9557 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9558 : :
9559 : : /* Setup HMAC Parameters if ICV header is required */
9560 [ # # ]: 0 : if (auth_alg != 0) {
9561 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9562 : 0 : ut_params->auth_xform.next = NULL;
9563 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9564 : 0 : ut_params->auth_xform.auth.op = opa;
9565 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9566 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9567 : :
9568 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9569 : : } else {
9570 : 0 : ut_params->cipher_xform.next = NULL;
9571 : : }
9572 : :
9573 : 0 : struct rte_security_session_conf sess_conf = {
9574 : 0 : .action_type = ut_params->type,
9575 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9576 : : {.pdcp = {
9577 : : .bearer = bearer,
9578 : : .domain = domain,
9579 : : .pkt_dir = packet_direction,
9580 : : .sn_size = sn_size,
9581 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9582 : : /**
9583 : : * hfn can be set as pdcp_test_hfn[i]
9584 : : * if hfn_ovrd is not set. Here, PDCP
9585 : : * packet direction is just used to
9586 : : * run half of the cases with session
9587 : : * HFN and other half with per packet
9588 : : * HFN.
9589 : : */
9590 : : .hfn_threshold = hfn_threshold,
9591 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9592 : : .sdap_enabled = sdap,
9593 : : } },
9594 : : .crypto_xform = &ut_params->cipher_xform
9595 : : };
9596 : :
9597 : : /* Create security session */
9598 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9599 : : &sess_conf, ts_params->session_mpool);
9600 : :
9601 [ # # ]: 0 : if (!ut_params->sec_session) {
9602 : : printf("TestCase %s()-%d line %d failed %s: ",
9603 : : __func__, i, __LINE__, "Failed to allocate session");
9604 : : ret = TEST_FAILED;
9605 : 0 : goto on_err;
9606 : : }
9607 : :
9608 : : /* Generate crypto op data structure */
9609 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9610 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9611 [ # # ]: 0 : if (!ut_params->op) {
9612 : : printf("TestCase %s()-%d line %d failed %s: ",
9613 : : __func__, i, __LINE__,
9614 : : "Failed to allocate symmetric crypto operation struct");
9615 : : ret = TEST_FAILED;
9616 : 0 : goto on_err;
9617 : : }
9618 : :
9619 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9620 : : uint32_t *, IV_OFFSET);
9621 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9622 : :
9623 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9624 : :
9625 : : /* set crypto operation source mbuf */
9626 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9627 [ # # ]: 0 : if (oop)
9628 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9629 : :
9630 : : /* Process crypto operation */
9631 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9632 : : /* filling lengths */
9633 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9634 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9635 : :
9636 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9637 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9638 : : return ret;
9639 : : } else {
9640 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9641 : : }
9642 [ # # ]: 0 : if (ut_params->op == NULL) {
9643 : : printf("TestCase %s()-%d line %d failed %s: ",
9644 : : __func__, i, __LINE__,
9645 : : "failed to process sym crypto op");
9646 : : ret = TEST_FAILED;
9647 : 0 : goto on_err;
9648 : : }
9649 : :
9650 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9651 : : printf("TestCase %s()-%d line %d failed %s: ",
9652 : : __func__, i, __LINE__, "crypto op processing failed");
9653 : : ret = TEST_FAILED;
9654 : 0 : goto on_err;
9655 : : }
9656 : :
9657 : : /* Validate obuf */
9658 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9659 : : uint8_t *);
9660 [ # # ]: 0 : if (oop) {
9661 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9662 : : uint8_t *);
9663 : : }
9664 : :
9665 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9666 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9667 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9668 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9669 : : ret = TEST_FAILED;
9670 : 0 : goto on_err;
9671 : : }
9672 : :
9673 : 0 : on_err:
9674 : 0 : rte_crypto_op_free(ut_params->op);
9675 : 0 : ut_params->op = NULL;
9676 : :
9677 [ # # ]: 0 : if (ut_params->sec_session)
9678 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9679 : 0 : ut_params->sec_session = NULL;
9680 : :
9681 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9682 : 0 : ut_params->ibuf = NULL;
9683 [ # # ]: 0 : if (oop) {
9684 : 0 : rte_pktmbuf_free(ut_params->obuf);
9685 : 0 : ut_params->obuf = NULL;
9686 : : }
9687 : :
9688 : : return ret;
9689 : : }
9690 : :
9691 : : static int
9692 : 0 : test_pdcp_proto_SGL(int i, int oop,
9693 : : enum rte_crypto_cipher_operation opc,
9694 : : enum rte_crypto_auth_operation opa,
9695 : : uint8_t *input_vec,
9696 : : unsigned int input_vec_len,
9697 : : uint8_t *output_vec,
9698 : : unsigned int output_vec_len,
9699 : : uint32_t fragsz,
9700 : : uint32_t fragsz_oop)
9701 : : {
9702 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9703 : : struct crypto_unittest_params *ut_params = &unittest_params;
9704 : : uint8_t *plaintext;
9705 : : struct rte_mbuf *buf, *buf_oop = NULL;
9706 : : int ret = TEST_SUCCESS;
9707 : : int to_trn = 0;
9708 : : int to_trn_tbl[16];
9709 : : int segs = 1;
9710 : : unsigned int trn_data = 0;
9711 : : struct rte_cryptodev_info dev_info;
9712 : : uint64_t feat_flags;
9713 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9714 : : struct rte_mbuf *temp_mbuf;
9715 : :
9716 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9717 : 0 : feat_flags = dev_info.feature_flags;
9718 : :
9719 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9720 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9721 : : printf("Device does not support RAW data-path APIs.\n");
9722 : 0 : return -ENOTSUP;
9723 : : }
9724 : : /* Verify the capabilities */
9725 : : struct rte_security_capability_idx sec_cap_idx;
9726 : :
9727 : 0 : sec_cap_idx.action = ut_params->type;
9728 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9729 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9730 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9731 : : return TEST_SKIPPED;
9732 : :
9733 : : if (fragsz > input_vec_len)
9734 : : fragsz = input_vec_len;
9735 : :
9736 : 0 : uint16_t plaintext_len = fragsz;
9737 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9738 : :
9739 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9740 : 0 : frag_size_oop = output_vec_len;
9741 : :
9742 : : int ecx = 0;
9743 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9744 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9745 : : return 1;
9746 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9747 : : return 1;
9748 : :
9749 : : /* Out of place support */
9750 [ # # ]: 0 : if (oop) {
9751 : : /*
9752 : : * For out-of-place we need to alloc another mbuf
9753 : : */
9754 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9755 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9756 : 0 : buf_oop = ut_params->obuf;
9757 : : }
9758 : :
9759 : : /* Generate test mbuf data */
9760 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9761 : :
9762 : : /* clear mbuf payload */
9763 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9764 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9765 : :
9766 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9767 : : plaintext_len);
9768 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9769 : : trn_data += plaintext_len;
9770 : :
9771 : 0 : buf = ut_params->ibuf;
9772 : :
9773 : : /*
9774 : : * Loop until no more fragments
9775 : : */
9776 : :
9777 [ # # ]: 0 : while (trn_data < input_vec_len) {
9778 : 0 : ++segs;
9779 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9780 : 0 : (input_vec_len - trn_data) : fragsz;
9781 : :
9782 : 0 : to_trn_tbl[ecx++] = to_trn;
9783 : :
9784 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9785 : : buf = buf->next;
9786 : :
9787 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9788 : : rte_pktmbuf_tailroom(buf));
9789 : :
9790 : : /* OOP */
9791 [ # # ]: 0 : if (oop && !fragsz_oop) {
9792 : 0 : buf_oop->next =
9793 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9794 : : buf_oop = buf_oop->next;
9795 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9796 : : 0, rte_pktmbuf_tailroom(buf_oop));
9797 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9798 : : }
9799 : :
9800 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9801 : : to_trn);
9802 : :
9803 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9804 : 0 : trn_data += to_trn;
9805 : : }
9806 : :
9807 : 0 : ut_params->ibuf->nb_segs = segs;
9808 : :
9809 : : segs = 1;
9810 [ # # ]: 0 : if (fragsz_oop && oop) {
9811 : : to_trn = 0;
9812 : : ecx = 0;
9813 : :
9814 : 0 : trn_data = frag_size_oop;
9815 [ # # ]: 0 : while (trn_data < output_vec_len) {
9816 : 0 : ++segs;
9817 : 0 : to_trn =
9818 : 0 : (output_vec_len - trn_data <
9819 : : frag_size_oop) ?
9820 : 0 : (output_vec_len - trn_data) :
9821 : : frag_size_oop;
9822 : :
9823 : 0 : to_trn_tbl[ecx++] = to_trn;
9824 : :
9825 : 0 : buf_oop->next =
9826 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9827 : : buf_oop = buf_oop->next;
9828 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9829 : : 0, rte_pktmbuf_tailroom(buf_oop));
9830 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9831 : :
9832 : 0 : trn_data += to_trn;
9833 : : }
9834 : 0 : ut_params->obuf->nb_segs = segs;
9835 : : }
9836 : :
9837 : : /* Setup Cipher Parameters */
9838 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9839 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9840 : 0 : ut_params->cipher_xform.cipher.op = opc;
9841 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9842 : 0 : ut_params->cipher_xform.cipher.key.length =
9843 : 0 : pdcp_test_params[i].cipher_key_len;
9844 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9845 : :
9846 : : /* Setup HMAC Parameters if ICV header is required */
9847 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9848 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9849 : 0 : ut_params->auth_xform.next = NULL;
9850 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9851 : 0 : ut_params->auth_xform.auth.op = opa;
9852 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9853 : 0 : ut_params->auth_xform.auth.key.length =
9854 : 0 : pdcp_test_params[i].auth_key_len;
9855 : :
9856 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9857 : : } else {
9858 : 0 : ut_params->cipher_xform.next = NULL;
9859 : : }
9860 : :
9861 : 0 : struct rte_security_session_conf sess_conf = {
9862 : 0 : .action_type = ut_params->type,
9863 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9864 : : {.pdcp = {
9865 : 0 : .bearer = pdcp_test_bearer[i],
9866 : 0 : .domain = pdcp_test_params[i].domain,
9867 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9868 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9869 : 0 : .hfn = pdcp_test_hfn[i],
9870 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9871 : : .hfn_ovrd = 0,
9872 : : } },
9873 : : .crypto_xform = &ut_params->cipher_xform
9874 : : };
9875 : :
9876 : : /* Create security session */
9877 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9878 : : &sess_conf, ts_params->session_mpool);
9879 : :
9880 [ # # ]: 0 : if (!ut_params->sec_session) {
9881 : : printf("TestCase %s()-%d line %d failed %s: ",
9882 : : __func__, i, __LINE__, "Failed to allocate session");
9883 : : ret = TEST_FAILED;
9884 : 0 : goto on_err;
9885 : : }
9886 : :
9887 : : /* Generate crypto op data structure */
9888 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9889 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9890 [ # # ]: 0 : if (!ut_params->op) {
9891 : : printf("TestCase %s()-%d line %d failed %s: ",
9892 : : __func__, i, __LINE__,
9893 : : "Failed to allocate symmetric crypto operation struct");
9894 : : ret = TEST_FAILED;
9895 : 0 : goto on_err;
9896 : : }
9897 : :
9898 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9899 : :
9900 : : /* set crypto operation source mbuf */
9901 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9902 [ # # ]: 0 : if (oop)
9903 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9904 : :
9905 : : /* Process crypto operation */
9906 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9907 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9908 : : /* filling lengths */
9909 [ # # ]: 0 : while (temp_mbuf) {
9910 : 0 : ut_params->op->sym->cipher.data.length
9911 : 0 : += temp_mbuf->pkt_len;
9912 : 0 : ut_params->op->sym->auth.data.length
9913 : 0 : += temp_mbuf->pkt_len;
9914 : 0 : temp_mbuf = temp_mbuf->next;
9915 : : }
9916 : :
9917 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9918 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9919 : : return ret;
9920 : : } else {
9921 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9922 : : ut_params->op);
9923 : : }
9924 [ # # ]: 0 : if (ut_params->op == NULL) {
9925 : : printf("TestCase %s()-%d line %d failed %s: ",
9926 : : __func__, i, __LINE__,
9927 : : "failed to process sym crypto op");
9928 : : ret = TEST_FAILED;
9929 : 0 : goto on_err;
9930 : : }
9931 : :
9932 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9933 : : printf("TestCase %s()-%d line %d failed %s: ",
9934 : : __func__, i, __LINE__, "crypto op processing failed");
9935 : : ret = TEST_FAILED;
9936 : 0 : goto on_err;
9937 : : }
9938 : :
9939 : : /* Validate obuf */
9940 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9941 : : uint8_t *);
9942 [ # # ]: 0 : if (oop) {
9943 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9944 : : uint8_t *);
9945 : : }
9946 [ # # ]: 0 : if (fragsz_oop)
9947 : 0 : fragsz = frag_size_oop;
9948 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9949 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9950 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9951 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9952 : : ret = TEST_FAILED;
9953 : 0 : goto on_err;
9954 : : }
9955 : :
9956 : 0 : buf = ut_params->op->sym->m_src->next;
9957 [ # # ]: 0 : if (oop)
9958 : 0 : buf = ut_params->op->sym->m_dst->next;
9959 : :
9960 : : unsigned int off = fragsz;
9961 : :
9962 : : ecx = 0;
9963 [ # # ]: 0 : while (buf) {
9964 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9965 : : uint8_t *);
9966 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9967 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9968 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9969 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9970 : : to_trn_tbl[ecx]);
9971 : : ret = TEST_FAILED;
9972 : 0 : goto on_err;
9973 : : }
9974 : 0 : off += to_trn_tbl[ecx++];
9975 : 0 : buf = buf->next;
9976 : : }
9977 : 0 : on_err:
9978 : 0 : rte_crypto_op_free(ut_params->op);
9979 : 0 : ut_params->op = NULL;
9980 : :
9981 [ # # ]: 0 : if (ut_params->sec_session)
9982 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9983 : 0 : ut_params->sec_session = NULL;
9984 : :
9985 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9986 : 0 : ut_params->ibuf = NULL;
9987 [ # # ]: 0 : if (oop) {
9988 : 0 : rte_pktmbuf_free(ut_params->obuf);
9989 : 0 : ut_params->obuf = NULL;
9990 : : }
9991 : :
9992 : : return ret;
9993 : : }
9994 : :
9995 : : int
9996 : 0 : test_pdcp_proto_cplane_encap(int i)
9997 : : {
9998 : 0 : return test_pdcp_proto(
9999 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10000 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10001 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10002 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10003 : 0 : pdcp_test_params[i].cipher_key_len,
10004 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10005 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10006 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10007 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10008 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10009 : : }
10010 : :
10011 : : int
10012 : 0 : test_pdcp_proto_uplane_encap(int i)
10013 : : {
10014 : 0 : return test_pdcp_proto(
10015 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10016 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10017 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10018 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10019 : 0 : pdcp_test_params[i].cipher_key_len,
10020 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10021 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10022 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10023 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10024 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10025 : : }
10026 : :
10027 : : int
10028 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
10029 : : {
10030 : 0 : return test_pdcp_proto(
10031 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10032 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10033 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10034 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10035 : 0 : pdcp_test_params[i].cipher_key_len,
10036 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10037 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10038 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10039 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10040 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10041 : : }
10042 : :
10043 : : int
10044 : 0 : test_pdcp_proto_cplane_decap(int i)
10045 : : {
10046 : 0 : return test_pdcp_proto(
10047 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10048 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10049 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10050 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10051 : 0 : pdcp_test_params[i].cipher_key_len,
10052 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10053 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10054 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10055 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10056 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10057 : : }
10058 : :
10059 : : int
10060 : 0 : test_pdcp_proto_uplane_decap(int i)
10061 : : {
10062 : 0 : return test_pdcp_proto(
10063 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10064 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10065 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10066 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10067 : 0 : pdcp_test_params[i].cipher_key_len,
10068 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10069 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10070 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10071 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10072 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10073 : : }
10074 : :
10075 : : int
10076 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
10077 : : {
10078 : 0 : return test_pdcp_proto(
10079 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10080 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10081 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10082 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10083 : 0 : pdcp_test_params[i].cipher_key_len,
10084 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10085 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10086 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10087 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10088 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10089 : : }
10090 : :
10091 : : static int
10092 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
10093 : : {
10094 : : /* i can be used for running any PDCP case
10095 : : * In this case it is uplane 12-bit AES-SNOW DL encap
10096 : : */
10097 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
10098 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
10099 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10100 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10101 : : pdcp_test_data_in[i],
10102 : : pdcp_test_data_in_len[i],
10103 : : pdcp_test_data_out[i],
10104 : 0 : pdcp_test_data_in_len[i]+4,
10105 : : 32, 0);
10106 : : }
10107 : : static int
10108 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
10109 : : {
10110 : : /* i can be used for running any PDCP case
10111 : : * In this case it is uplane 18-bit NULL-NULL DL encap
10112 : : */
10113 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10114 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10115 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10116 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10117 : : pdcp_test_data_in[i],
10118 : : pdcp_test_data_in_len[i],
10119 : : pdcp_test_data_out[i],
10120 : 0 : pdcp_test_data_in_len[i]+4,
10121 : : 32, 128);
10122 : : }
10123 : : static int
10124 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
10125 : : {
10126 : : /* i can be used for running any PDCP case
10127 : : * In this case it is uplane 18-bit AES DL encap
10128 : : */
10129 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10130 : : + DOWNLINK;
10131 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10132 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10133 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10134 : : pdcp_test_data_in[i],
10135 : : pdcp_test_data_in_len[i],
10136 : : pdcp_test_data_out[i],
10137 : : pdcp_test_data_in_len[i],
10138 : : 32, 40);
10139 : : }
10140 : : static int
10141 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
10142 : : {
10143 : : /* i can be used for running any PDCP case
10144 : : * In this case it is cplane 12-bit AES-ZUC DL encap
10145 : : */
10146 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10147 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10148 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10149 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10150 : : pdcp_test_data_in[i],
10151 : : pdcp_test_data_in_len[i],
10152 : : pdcp_test_data_out[i],
10153 : 0 : pdcp_test_data_in_len[i]+4,
10154 : : 128, 32);
10155 : : }
10156 : :
10157 : : static int
10158 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
10159 : : {
10160 : : int i = 0, size = 0;
10161 : : int err, all_err = TEST_SUCCESS;
10162 : : const struct pdcp_sdap_test *cur_test;
10163 : :
10164 : : size = RTE_DIM(list_pdcp_sdap_tests);
10165 : :
10166 [ # # ]: 0 : for (i = 0; i < size; i++) {
10167 : : cur_test = &list_pdcp_sdap_tests[i];
10168 : 0 : err = test_pdcp_proto(
10169 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10170 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10171 : 0 : cur_test->in_len, cur_test->data_out,
10172 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10173 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
10174 : 0 : cur_test->param.cipher_key_len,
10175 : 0 : cur_test->param.auth_alg,
10176 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10177 : 0 : cur_test->bearer, cur_test->param.domain,
10178 : 0 : cur_test->packet_direction, cur_test->sn_size,
10179 : 0 : cur_test->hfn,
10180 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10181 [ # # ]: 0 : if (err) {
10182 : : printf("\t%d) %s: Encapsulation failed\n",
10183 : 0 : cur_test->test_idx,
10184 : 0 : cur_test->param.name);
10185 : : err = TEST_FAILED;
10186 : : } else {
10187 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10188 : 0 : cur_test->param.name);
10189 : : err = TEST_SUCCESS;
10190 : : }
10191 : 0 : all_err += err;
10192 : : }
10193 : :
10194 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10195 : :
10196 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10197 : : }
10198 : :
10199 : : static int
10200 : 0 : test_PDCP_PROTO_short_mac(void)
10201 : : {
10202 : : int i = 0, size = 0;
10203 : : int err, all_err = TEST_SUCCESS;
10204 : : const struct pdcp_short_mac_test *cur_test;
10205 : :
10206 : : size = RTE_DIM(list_pdcp_smac_tests);
10207 : :
10208 [ # # ]: 0 : for (i = 0; i < size; i++) {
10209 : : cur_test = &list_pdcp_smac_tests[i];
10210 : 0 : err = test_pdcp_proto(
10211 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10212 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10213 : 0 : cur_test->in_len, cur_test->data_out,
10214 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10215 : : RTE_CRYPTO_CIPHER_NULL, NULL,
10216 : 0 : 0, cur_test->param.auth_alg,
10217 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10218 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
10219 : : 0, 0, 0);
10220 [ # # ]: 0 : if (err) {
10221 : : printf("\t%d) %s: Short MAC test failed\n",
10222 : 0 : cur_test->test_idx,
10223 : 0 : cur_test->param.name);
10224 : : err = TEST_FAILED;
10225 : : } else {
10226 : : printf("\t%d) %s: Short MAC test PASS\n",
10227 : 0 : cur_test->test_idx,
10228 : 0 : cur_test->param.name);
10229 : 0 : rte_hexdump(stdout, "MAC I",
10230 : 0 : cur_test->data_out + cur_test->in_len + 2,
10231 : : 2);
10232 : : err = TEST_SUCCESS;
10233 : : }
10234 : 0 : all_err += err;
10235 : : }
10236 : :
10237 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10238 : :
10239 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10240 : :
10241 : : }
10242 : :
10243 : : static int
10244 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
10245 : : {
10246 : : int i = 0, size = 0;
10247 : : int err, all_err = TEST_SUCCESS;
10248 : : const struct pdcp_sdap_test *cur_test;
10249 : :
10250 : : size = RTE_DIM(list_pdcp_sdap_tests);
10251 : :
10252 [ # # ]: 0 : for (i = 0; i < size; i++) {
10253 : : cur_test = &list_pdcp_sdap_tests[i];
10254 : 0 : err = test_pdcp_proto(
10255 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10256 : : RTE_CRYPTO_AUTH_OP_VERIFY,
10257 : 0 : cur_test->data_out,
10258 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10259 : 0 : cur_test->data_in, cur_test->in_len,
10260 : 0 : cur_test->param.cipher_alg,
10261 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
10262 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
10263 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
10264 : 0 : cur_test->param.domain, cur_test->packet_direction,
10265 : 0 : cur_test->sn_size, cur_test->hfn,
10266 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10267 [ # # ]: 0 : if (err) {
10268 : : printf("\t%d) %s: Decapsulation failed\n",
10269 : 0 : cur_test->test_idx,
10270 : 0 : cur_test->param.name);
10271 : : err = TEST_FAILED;
10272 : : } else {
10273 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10274 : 0 : cur_test->param.name);
10275 : : err = TEST_SUCCESS;
10276 : : }
10277 : 0 : all_err += err;
10278 : : }
10279 : :
10280 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10281 : :
10282 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10283 : : }
10284 : :
10285 : : static int
10286 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10287 : : struct crypto_unittest_params *ut_params,
10288 : : struct rte_security_ipsec_xform *ipsec_xform,
10289 : : const struct ipsec_test_data *td,
10290 : : const struct ipsec_test_flags *flags,
10291 : : int pkt_num)
10292 : : {
10293 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10294 : : enum rte_security_ipsec_sa_direction dir;
10295 : : int ret;
10296 : :
10297 : 0 : dir = ipsec_xform->direction;
10298 : :
10299 : : /* Generate crypto op data structure */
10300 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10301 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10302 [ # # ]: 0 : if (!ut_params->op) {
10303 : : printf("Could not allocate crypto op");
10304 : 0 : return TEST_FAILED;
10305 : : }
10306 : :
10307 : : /* Attach session to operation */
10308 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10309 : :
10310 : : /* Set crypto operation mbufs */
10311 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10312 : 0 : ut_params->op->sym->m_dst = NULL;
10313 : :
10314 : : /* Copy IV in crypto operation when IV generation is disabled */
10315 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10316 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10317 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10318 : : uint8_t *,
10319 : : IV_OFFSET);
10320 : : int len;
10321 : :
10322 [ # # ]: 0 : if (td->aead)
10323 : 0 : len = td->xform.aead.aead.iv.length;
10324 [ # # ]: 0 : else if (td->aes_gmac)
10325 : 0 : len = td->xform.chain.auth.auth.iv.length;
10326 : : else
10327 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10328 : :
10329 : 0 : memcpy(iv, td->iv.data, len);
10330 : : }
10331 : :
10332 : : /* Process crypto operation */
10333 : 0 : process_crypto_request(dev_id, ut_params->op);
10334 : :
10335 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10336 : :
10337 : 0 : rte_crypto_op_free(ut_params->op);
10338 : 0 : ut_params->op = NULL;
10339 : :
10340 : 0 : return ret;
10341 : : }
10342 : :
10343 : : static int
10344 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10345 : : struct crypto_unittest_params *ut_params,
10346 : : void *ctx)
10347 : : {
10348 : : uint64_t timeout, userdata;
10349 : : struct rte_ether_hdr *hdr;
10350 : : struct rte_mbuf *m;
10351 : : void **sec_sess;
10352 : : int ret;
10353 : :
10354 : : RTE_SET_USED(ts_params);
10355 : :
10356 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10357 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10358 : :
10359 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10360 : 0 : ut_params->ibuf->port = 0;
10361 : :
10362 : 0 : sec_sess = &ut_params->sec_session;
10363 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10364 : :
10365 [ # # ]: 0 : if (ret != 1)
10366 : : return TEST_FAILED;
10367 : :
10368 : 0 : ut_params->ibuf = NULL;
10369 : :
10370 : : /* Add a timeout for 1 s */
10371 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10372 : :
10373 : : do {
10374 : : /* Get packet from port 0, queue 0 */
10375 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10376 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10377 : :
10378 [ # # ]: 0 : if (ret == 0) {
10379 : : printf("Could not receive packets from ethdev\n");
10380 : 0 : return TEST_FAILED;
10381 : : }
10382 : :
10383 [ # # ]: 0 : if (m == NULL) {
10384 : : printf("Received mbuf is NULL\n");
10385 : 0 : return TEST_FAILED;
10386 : : }
10387 : :
10388 : 0 : ut_params->ibuf = m;
10389 : :
10390 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10391 : : printf("Received packet is not Rx security processed\n");
10392 : 0 : return TEST_FAILED;
10393 : : }
10394 : :
10395 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10396 : : printf("Received packet has failed Rx security processing\n");
10397 : 0 : return TEST_FAILED;
10398 : : }
10399 : :
10400 : : /*
10401 : : * 'ut_params' is set as userdata. Verify that the field is returned
10402 : : * correctly.
10403 : : */
10404 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10405 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10406 : : printf("Userdata retrieved not matching expected\n");
10407 : 0 : return TEST_FAILED;
10408 : : }
10409 : :
10410 : : /* Trim L2 header */
10411 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10412 : :
10413 : : return TEST_SUCCESS;
10414 : : }
10415 : :
10416 : : static int
10417 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10418 : : struct ipsec_test_data res_d[],
10419 : : int nb_td,
10420 : : bool silent,
10421 : : const struct ipsec_test_flags *flags)
10422 : : {
10423 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10424 : : 0x0000, 0x001a};
10425 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10426 : : 0xe82c, 0x4887};
10427 : : const struct rte_ipv4_hdr *ipv4 =
10428 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10429 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10430 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10431 : : struct crypto_unittest_params *ut_params = &unittest_params;
10432 : : struct rte_security_capability_idx sec_cap_idx;
10433 : : const struct rte_security_capability *sec_cap;
10434 : : struct rte_security_ipsec_xform ipsec_xform;
10435 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10436 : : enum rte_security_ipsec_sa_direction dir;
10437 : : struct ipsec_test_data *res_d_tmp = NULL;
10438 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10439 : : int salt_len, i, ret = TEST_SUCCESS;
10440 : : void *ctx;
10441 : : uint32_t src, dst;
10442 : : uint32_t verify;
10443 : :
10444 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10445 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10446 : :
10447 : : /* Use first test data to create session */
10448 : :
10449 : : /* Copy IPsec xform */
10450 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10451 : :
10452 : 0 : dir = ipsec_xform.direction;
10453 : 0 : verify = flags->tunnel_hdr_verify;
10454 : :
10455 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10456 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10457 : :
10458 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10459 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10460 : 0 : src += 1;
10461 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10462 : 0 : dst += 1;
10463 : : }
10464 : :
10465 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10466 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10467 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10468 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10469 : : sizeof(src));
10470 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10471 : : sizeof(dst));
10472 : :
10473 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10474 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10475 : :
10476 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10477 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10478 : :
10479 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10480 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10481 : :
10482 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10483 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10484 : : TEST_IPSEC_DSCP_VAL;
10485 : :
10486 : : } else {
10487 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10488 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10489 : :
10490 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10491 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10492 : : TEST_IPSEC_DSCP_VAL;
10493 : :
10494 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10495 : : sizeof(v6_src));
10496 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10497 : : sizeof(v6_dst));
10498 : : }
10499 : : }
10500 : :
10501 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10502 : :
10503 : 0 : sec_cap_idx.action = ut_params->type;
10504 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10505 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10506 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10507 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10508 : :
10509 [ # # ]: 0 : if (flags->udp_encap)
10510 : 0 : ipsec_xform.options.udp_encap = 1;
10511 : :
10512 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10513 [ # # ]: 0 : if (sec_cap == NULL)
10514 : : return TEST_SKIPPED;
10515 : :
10516 : : /* Copy cipher session parameters */
10517 [ # # ]: 0 : if (td[0].aead) {
10518 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10519 : : sizeof(ut_params->aead_xform));
10520 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10521 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10522 : :
10523 : : /* Verify crypto capabilities */
10524 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10525 [ # # ]: 0 : if (!silent)
10526 : 0 : RTE_LOG(INFO, USER1,
10527 : : "Crypto capabilities not supported\n");
10528 : 0 : return TEST_SKIPPED;
10529 : : }
10530 [ # # ]: 0 : } else if (td[0].auth_only) {
10531 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10532 : : sizeof(ut_params->auth_xform));
10533 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10534 : :
10535 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10536 [ # # ]: 0 : if (!silent)
10537 : 0 : RTE_LOG(INFO, USER1,
10538 : : "Auth crypto capabilities not supported\n");
10539 : 0 : return TEST_SKIPPED;
10540 : : }
10541 : : } else {
10542 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10543 : : sizeof(ut_params->cipher_xform));
10544 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10545 : : sizeof(ut_params->auth_xform));
10546 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10547 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10548 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10549 : :
10550 : : /* Verify crypto capabilities */
10551 : :
10552 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10553 [ # # ]: 0 : if (!silent)
10554 : 0 : RTE_LOG(INFO, USER1,
10555 : : "Cipher crypto capabilities not supported\n");
10556 : 0 : return TEST_SKIPPED;
10557 : : }
10558 : :
10559 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10560 [ # # ]: 0 : if (!silent)
10561 : 0 : RTE_LOG(INFO, USER1,
10562 : : "Auth crypto capabilities not supported\n");
10563 : 0 : return TEST_SKIPPED;
10564 : : }
10565 : : }
10566 : :
10567 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10568 : : return TEST_SKIPPED;
10569 : :
10570 : 0 : struct rte_security_session_conf sess_conf = {
10571 : 0 : .action_type = ut_params->type,
10572 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10573 : : };
10574 : :
10575 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac) {
10576 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10577 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10578 : : }
10579 : :
10580 [ # # ]: 0 : if (td[0].aead) {
10581 : 0 : sess_conf.ipsec = ipsec_xform;
10582 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10583 [ # # ]: 0 : } else if (td[0].auth_only) {
10584 : 0 : sess_conf.ipsec = ipsec_xform;
10585 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10586 : : } else {
10587 : 0 : sess_conf.ipsec = ipsec_xform;
10588 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10589 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10590 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10591 : : } else {
10592 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10593 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10594 : : }
10595 : : }
10596 : :
10597 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10598 : 0 : sess_conf.userdata = ut_params;
10599 : :
10600 : : /* Create security session */
10601 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10602 : : ts_params->session_mpool);
10603 : :
10604 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10605 : : return TEST_SKIPPED;
10606 : :
10607 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10608 [ # # # # ]: 0 : if (flags->antireplay &&
10609 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10610 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10611 : 0 : ret = rte_security_session_update(ctx,
10612 : : ut_params->sec_session, &sess_conf);
10613 [ # # ]: 0 : if (ret) {
10614 : : printf("Could not update sequence number in "
10615 : : "session\n");
10616 : 0 : return TEST_SKIPPED;
10617 : : }
10618 : : }
10619 : :
10620 : : /* Copy test data before modification */
10621 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10622 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10623 : : ret = TEST_FAILED;
10624 : 0 : goto mbuf_free;
10625 : : }
10626 : :
10627 : : /* Setup source mbuf payload */
10628 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10629 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10630 : 0 : td[i].input_text.len, nb_segs, input_text);
10631 : : } else {
10632 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10633 : 0 : td[i].input_text.len, nb_segs, 0);
10634 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10635 : : }
10636 : :
10637 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10638 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10639 : : ctx);
10640 : : else
10641 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10642 : : ut_params,
10643 : : &ipsec_xform,
10644 : : &td[i], flags,
10645 : : i + 1);
10646 : :
10647 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10648 : 0 : goto mbuf_free;
10649 : :
10650 [ # # ]: 0 : if (res_d != NULL)
10651 : 0 : res_d_tmp = &res_d[i];
10652 : :
10653 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10654 : : res_d_tmp, silent, flags);
10655 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10656 : 0 : goto mbuf_free;
10657 : :
10658 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10659 : : flags, dir);
10660 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10661 : 0 : goto mbuf_free;
10662 : :
10663 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10664 : 0 : ut_params->ibuf = NULL;
10665 : : }
10666 : :
10667 : 0 : mbuf_free:
10668 [ # # ]: 0 : if (flags->use_ext_mbuf)
10669 : 0 : ext_mbuf_memzone_free(nb_segs);
10670 : :
10671 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10672 : 0 : ut_params->ibuf = NULL;
10673 : :
10674 [ # # ]: 0 : if (ut_params->sec_session)
10675 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10676 : 0 : ut_params->sec_session = NULL;
10677 : :
10678 : 0 : return ret;
10679 : : }
10680 : :
10681 : : static int
10682 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10683 : : {
10684 : : struct ipsec_test_data td_outb;
10685 : : struct ipsec_test_flags flags;
10686 : :
10687 : : memset(&flags, 0, sizeof(flags));
10688 : :
10689 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10690 : :
10691 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10692 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10693 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10694 : : /* Disable IV gen to be able to test with known vectors */
10695 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10696 : : }
10697 : :
10698 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10699 : : }
10700 : :
10701 : : static int
10702 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10703 : : {
10704 : : struct ipsec_test_data td_outb;
10705 : : struct ipsec_test_flags flags;
10706 : :
10707 : : memset(&flags, 0, sizeof(flags));
10708 [ # # ]: 0 : flags.use_ext_mbuf = true;
10709 : :
10710 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10711 : :
10712 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10713 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10714 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10715 : : /* Disable IV gen to be able to test with known vectors */
10716 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10717 : : }
10718 : :
10719 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10720 : : }
10721 : :
10722 : : static int
10723 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10724 : : {
10725 : : const struct ipsec_test_data *td = test_data;
10726 : : struct ipsec_test_flags flags;
10727 : : struct ipsec_test_data td_inb;
10728 : :
10729 : : memset(&flags, 0, sizeof(flags));
10730 : :
10731 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10732 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10733 : : else
10734 : : memcpy(&td_inb, td, sizeof(td_inb));
10735 : :
10736 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10737 : : }
10738 : :
10739 : : static int
10740 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10741 : : {
10742 : : struct ipsec_test_data td_outb;
10743 : : struct ipsec_test_flags flags;
10744 : :
10745 : : memset(&flags, 0, sizeof(flags));
10746 : 0 : flags.fragment = true;
10747 : :
10748 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10749 : :
10750 : : /* Disable IV gen to be able to test with known vectors */
10751 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10752 : :
10753 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10754 : : }
10755 : :
10756 : : static int
10757 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10758 : : {
10759 : : const struct ipsec_test_data *td = test_data;
10760 : : struct ipsec_test_flags flags;
10761 : : struct ipsec_test_data td_inb;
10762 : :
10763 : : memset(&flags, 0, sizeof(flags));
10764 : 0 : flags.rx_inject = true;
10765 : :
10766 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10767 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10768 : : else
10769 : : memcpy(&td_inb, td, sizeof(td_inb));
10770 : :
10771 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10772 : : }
10773 : :
10774 : : static int
10775 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10776 : : {
10777 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10778 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10779 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10780 : : int ret;
10781 : :
10782 [ # # ]: 0 : if (flags->iv_gen ||
10783 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10784 : : flags->sa_expiry_pkts_hard)
10785 : : nb_pkts = TEST_SEC_PKTS_MAX;
10786 : :
10787 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10788 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10789 : : sec_alg_list[i].param2,
10790 : : flags,
10791 : : td_outb,
10792 : : nb_pkts);
10793 : :
10794 [ # # ]: 0 : if (!td_outb->aead) {
10795 : : enum rte_crypto_cipher_algorithm cipher_alg;
10796 : : enum rte_crypto_auth_algorithm auth_alg;
10797 : :
10798 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10799 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10800 : :
10801 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10802 : 0 : continue;
10803 : :
10804 : : /* ICV is not applicable for NULL auth */
10805 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10806 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10807 : 0 : continue;
10808 : :
10809 : : /* IV is not applicable for NULL cipher */
10810 [ # # # # ]: 0 : if (flags->iv_gen &&
10811 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10812 : 0 : continue;
10813 : : }
10814 : :
10815 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10816 : : flags);
10817 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10818 : 0 : continue;
10819 : :
10820 [ # # ]: 0 : if (ret == TEST_FAILED)
10821 : : return TEST_FAILED;
10822 : :
10823 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10824 : :
10825 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10826 : : flags);
10827 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10828 : 0 : continue;
10829 : :
10830 [ # # ]: 0 : if (ret == TEST_FAILED)
10831 : : return TEST_FAILED;
10832 : :
10833 [ # # ]: 0 : if (flags->display_alg)
10834 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10835 : :
10836 : 0 : pass_cnt++;
10837 : : }
10838 : :
10839 [ # # ]: 0 : if (pass_cnt > 0)
10840 : : return TEST_SUCCESS;
10841 : : else
10842 : 0 : return TEST_SKIPPED;
10843 : : }
10844 : :
10845 : : static int
10846 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10847 : : {
10848 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10849 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10850 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10851 : : int ret;
10852 : :
10853 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10854 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10855 : : sec_auth_only_alg_list[i].param2,
10856 : : flags,
10857 : : td_outb,
10858 : : nb_pkts);
10859 : :
10860 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10861 : : flags);
10862 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10863 : 0 : continue;
10864 : :
10865 [ # # ]: 0 : if (ret == TEST_FAILED)
10866 : : return TEST_FAILED;
10867 : :
10868 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10869 : :
10870 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10871 : : flags);
10872 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10873 : 0 : continue;
10874 : :
10875 [ # # ]: 0 : if (ret == TEST_FAILED)
10876 : : return TEST_FAILED;
10877 : :
10878 [ # # ]: 0 : if (flags->display_alg)
10879 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10880 : : sec_auth_only_alg_list[i].param2);
10881 : :
10882 : 0 : pass_cnt++;
10883 : : }
10884 : :
10885 [ # # ]: 0 : if (pass_cnt > 0)
10886 : : return TEST_SUCCESS;
10887 : : else
10888 : 0 : return TEST_SKIPPED;
10889 : : }
10890 : :
10891 : : static int
10892 : 0 : test_ipsec_proto_display_list(void)
10893 : : {
10894 : : struct ipsec_test_flags flags;
10895 : :
10896 : : memset(&flags, 0, sizeof(flags));
10897 : :
10898 : 0 : flags.display_alg = true;
10899 : :
10900 : 0 : return test_ipsec_proto_all(&flags);
10901 : : }
10902 : :
10903 : : static int
10904 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10905 : : {
10906 : : struct ipsec_test_flags flags;
10907 : :
10908 : : memset(&flags, 0, sizeof(flags));
10909 : :
10910 : 0 : flags.ah = true;
10911 : 0 : flags.display_alg = true;
10912 : :
10913 : 0 : return test_ipsec_ah_proto_all(&flags);
10914 : : }
10915 : :
10916 : : static int
10917 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10918 : : {
10919 : : struct ipsec_test_flags flags;
10920 : :
10921 : : memset(&flags, 0, sizeof(flags));
10922 : :
10923 : 0 : flags.ah = true;
10924 : 0 : flags.transport = true;
10925 : :
10926 : 0 : return test_ipsec_ah_proto_all(&flags);
10927 : : }
10928 : :
10929 : : static int
10930 : 0 : test_ipsec_proto_iv_gen(void)
10931 : : {
10932 : : struct ipsec_test_flags flags;
10933 : :
10934 : : memset(&flags, 0, sizeof(flags));
10935 : :
10936 : 0 : flags.iv_gen = true;
10937 : :
10938 : 0 : return test_ipsec_proto_all(&flags);
10939 : : }
10940 : :
10941 : : static int
10942 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10943 : : {
10944 : : struct ipsec_test_flags flags;
10945 : :
10946 : : memset(&flags, 0, sizeof(flags));
10947 : :
10948 : 0 : flags.sa_expiry_pkts_soft = true;
10949 : :
10950 : 0 : return test_ipsec_proto_all(&flags);
10951 : : }
10952 : :
10953 : : static int
10954 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10955 : : {
10956 : : struct ipsec_test_flags flags;
10957 : :
10958 : : memset(&flags, 0, sizeof(flags));
10959 : :
10960 : 0 : flags.sa_expiry_pkts_hard = true;
10961 : :
10962 : 0 : return test_ipsec_proto_all(&flags);
10963 : : }
10964 : :
10965 : : static int
10966 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10967 : : {
10968 : : struct ipsec_test_flags flags;
10969 : :
10970 : : memset(&flags, 0, sizeof(flags));
10971 : :
10972 : 0 : flags.icv_corrupt = true;
10973 : :
10974 : 0 : return test_ipsec_proto_all(&flags);
10975 : : }
10976 : :
10977 : : static int
10978 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10979 : : {
10980 : : struct ipsec_test_flags flags;
10981 : :
10982 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10983 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10984 : : return TEST_SKIPPED;
10985 : :
10986 : : memset(&flags, 0, sizeof(flags));
10987 : :
10988 : 0 : flags.udp_encap = true;
10989 : 0 : flags.udp_encap_custom_ports = true;
10990 : :
10991 : 0 : return test_ipsec_proto_all(&flags);
10992 : : }
10993 : :
10994 : : static int
10995 : 0 : test_ipsec_proto_udp_encap(void)
10996 : : {
10997 : : struct ipsec_test_flags flags;
10998 : :
10999 : : memset(&flags, 0, sizeof(flags));
11000 : :
11001 : 0 : flags.udp_encap = true;
11002 : :
11003 : 0 : return test_ipsec_proto_all(&flags);
11004 : : }
11005 : :
11006 : : static int
11007 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
11008 : : {
11009 : : struct ipsec_test_flags flags;
11010 : :
11011 : : memset(&flags, 0, sizeof(flags));
11012 : :
11013 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
11014 : :
11015 : 0 : return test_ipsec_proto_all(&flags);
11016 : : }
11017 : :
11018 : : static int
11019 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
11020 : : {
11021 : : struct ipsec_test_flags flags;
11022 : :
11023 : : memset(&flags, 0, sizeof(flags));
11024 : :
11025 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
11026 : :
11027 : 0 : return test_ipsec_proto_all(&flags);
11028 : : }
11029 : :
11030 : : static int
11031 : 0 : test_ipsec_proto_udp_ports_verify(void)
11032 : : {
11033 : : struct ipsec_test_flags flags;
11034 : :
11035 : : memset(&flags, 0, sizeof(flags));
11036 : :
11037 : 0 : flags.udp_encap = true;
11038 : 0 : flags.udp_ports_verify = true;
11039 : :
11040 : 0 : return test_ipsec_proto_all(&flags);
11041 : : }
11042 : :
11043 : : static int
11044 : 0 : test_ipsec_proto_inner_ip_csum(void)
11045 : : {
11046 : : struct ipsec_test_flags flags;
11047 : :
11048 : : memset(&flags, 0, sizeof(flags));
11049 : :
11050 : 0 : flags.ip_csum = true;
11051 : :
11052 : 0 : return test_ipsec_proto_all(&flags);
11053 : : }
11054 : :
11055 : : static int
11056 : 0 : test_ipsec_proto_inner_l4_csum(void)
11057 : : {
11058 : : struct ipsec_test_flags flags;
11059 : :
11060 : : memset(&flags, 0, sizeof(flags));
11061 : :
11062 : 0 : flags.l4_csum = true;
11063 : :
11064 : 0 : return test_ipsec_proto_all(&flags);
11065 : : }
11066 : :
11067 : : static int
11068 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
11069 : : {
11070 : : struct ipsec_test_flags flags;
11071 : :
11072 : : memset(&flags, 0, sizeof(flags));
11073 : :
11074 : : flags.ipv6 = false;
11075 : : flags.tunnel_ipv6 = false;
11076 : :
11077 : 0 : return test_ipsec_proto_all(&flags);
11078 : : }
11079 : :
11080 : : static int
11081 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
11082 : : {
11083 : : struct ipsec_test_flags flags;
11084 : :
11085 : : memset(&flags, 0, sizeof(flags));
11086 : :
11087 : 0 : flags.ipv6 = true;
11088 : 0 : flags.tunnel_ipv6 = true;
11089 : :
11090 : 0 : return test_ipsec_proto_all(&flags);
11091 : : }
11092 : :
11093 : : static int
11094 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
11095 : : {
11096 : : struct ipsec_test_flags flags;
11097 : :
11098 : : memset(&flags, 0, sizeof(flags));
11099 : :
11100 : : flags.ipv6 = false;
11101 : 0 : flags.tunnel_ipv6 = true;
11102 : :
11103 : 0 : return test_ipsec_proto_all(&flags);
11104 : : }
11105 : :
11106 : : static int
11107 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
11108 : : {
11109 : : struct ipsec_test_flags flags;
11110 : :
11111 : : memset(&flags, 0, sizeof(flags));
11112 : :
11113 : 0 : flags.ipv6 = true;
11114 : : flags.tunnel_ipv6 = false;
11115 : :
11116 : 0 : return test_ipsec_proto_all(&flags);
11117 : : }
11118 : :
11119 : : static int
11120 : 0 : test_ipsec_proto_transport_v4(void)
11121 : : {
11122 : : struct ipsec_test_flags flags;
11123 : :
11124 : : memset(&flags, 0, sizeof(flags));
11125 : :
11126 : : flags.ipv6 = false;
11127 : 0 : flags.transport = true;
11128 : :
11129 : 0 : return test_ipsec_proto_all(&flags);
11130 : : }
11131 : :
11132 : : static int
11133 : 0 : test_ipsec_proto_transport_l4_csum(void)
11134 : : {
11135 : 0 : struct ipsec_test_flags flags = {
11136 : : .l4_csum = true,
11137 : : .transport = true,
11138 : : };
11139 : :
11140 : 0 : return test_ipsec_proto_all(&flags);
11141 : : }
11142 : :
11143 : : static int
11144 : 0 : test_ipsec_proto_stats(void)
11145 : : {
11146 : : struct ipsec_test_flags flags;
11147 : :
11148 : : memset(&flags, 0, sizeof(flags));
11149 : :
11150 : 0 : flags.stats_success = true;
11151 : :
11152 : 0 : return test_ipsec_proto_all(&flags);
11153 : : }
11154 : :
11155 : : static int
11156 : 0 : test_ipsec_proto_pkt_fragment(void)
11157 : : {
11158 : : struct ipsec_test_flags flags;
11159 : :
11160 : : memset(&flags, 0, sizeof(flags));
11161 : :
11162 : 0 : flags.fragment = true;
11163 : :
11164 : 0 : return test_ipsec_proto_all(&flags);
11165 : :
11166 : : }
11167 : :
11168 : : static int
11169 : 0 : test_ipsec_proto_copy_df_inner_0(void)
11170 : : {
11171 : : struct ipsec_test_flags flags;
11172 : :
11173 : : memset(&flags, 0, sizeof(flags));
11174 : :
11175 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11176 : :
11177 : 0 : return test_ipsec_proto_all(&flags);
11178 : : }
11179 : :
11180 : : static int
11181 : 0 : test_ipsec_proto_copy_df_inner_1(void)
11182 : : {
11183 : : struct ipsec_test_flags flags;
11184 : :
11185 : : memset(&flags, 0, sizeof(flags));
11186 : :
11187 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11188 : :
11189 : 0 : return test_ipsec_proto_all(&flags);
11190 : : }
11191 : :
11192 : : static int
11193 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
11194 : : {
11195 : : struct ipsec_test_flags flags;
11196 : :
11197 : : memset(&flags, 0, sizeof(flags));
11198 : :
11199 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11200 : :
11201 : 0 : return test_ipsec_proto_all(&flags);
11202 : : }
11203 : :
11204 : : static int
11205 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
11206 : : {
11207 : : struct ipsec_test_flags flags;
11208 : :
11209 : : memset(&flags, 0, sizeof(flags));
11210 : :
11211 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11212 : :
11213 : 0 : return test_ipsec_proto_all(&flags);
11214 : : }
11215 : :
11216 : : static int
11217 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11218 : : {
11219 : : struct ipsec_test_flags flags;
11220 : :
11221 : : memset(&flags, 0, sizeof(flags));
11222 : :
11223 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11224 : :
11225 : 0 : return test_ipsec_proto_all(&flags);
11226 : : }
11227 : :
11228 : : static int
11229 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11230 : : {
11231 : : struct ipsec_test_flags flags;
11232 : :
11233 : : memset(&flags, 0, sizeof(flags));
11234 : :
11235 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11236 : :
11237 : 0 : return test_ipsec_proto_all(&flags);
11238 : : }
11239 : :
11240 : : static int
11241 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11242 : : {
11243 : : struct ipsec_test_flags flags;
11244 : :
11245 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11246 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11247 : : return TEST_SKIPPED;
11248 : :
11249 : : memset(&flags, 0, sizeof(flags));
11250 : :
11251 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11252 : :
11253 : 0 : return test_ipsec_proto_all(&flags);
11254 : : }
11255 : :
11256 : : static int
11257 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11258 : : {
11259 : : struct ipsec_test_flags flags;
11260 : :
11261 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11262 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11263 : : return TEST_SKIPPED;
11264 : :
11265 : : memset(&flags, 0, sizeof(flags));
11266 : :
11267 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11268 : :
11269 : 0 : return test_ipsec_proto_all(&flags);
11270 : : }
11271 : :
11272 : : static int
11273 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11274 : : {
11275 : : struct ipsec_test_flags flags;
11276 : :
11277 : : memset(&flags, 0, sizeof(flags));
11278 : :
11279 : 0 : flags.ipv6 = true;
11280 : 0 : flags.tunnel_ipv6 = true;
11281 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11282 : :
11283 : 0 : return test_ipsec_proto_all(&flags);
11284 : : }
11285 : :
11286 : : static int
11287 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11288 : : {
11289 : : struct ipsec_test_flags flags;
11290 : :
11291 : : memset(&flags, 0, sizeof(flags));
11292 : :
11293 : 0 : flags.ipv6 = true;
11294 : 0 : flags.tunnel_ipv6 = true;
11295 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11296 : :
11297 : 0 : return test_ipsec_proto_all(&flags);
11298 : : }
11299 : :
11300 : : static int
11301 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11302 : : {
11303 : : struct ipsec_test_flags flags;
11304 : :
11305 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11306 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11307 : : return TEST_SKIPPED;
11308 : :
11309 : : memset(&flags, 0, sizeof(flags));
11310 : :
11311 : 0 : flags.ipv6 = true;
11312 : 0 : flags.tunnel_ipv6 = true;
11313 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11314 : :
11315 : 0 : return test_ipsec_proto_all(&flags);
11316 : : }
11317 : :
11318 : : static int
11319 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11320 : : {
11321 : : struct ipsec_test_flags flags;
11322 : :
11323 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11324 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11325 : : return TEST_SKIPPED;
11326 : :
11327 : : memset(&flags, 0, sizeof(flags));
11328 : :
11329 : 0 : flags.ipv6 = true;
11330 : 0 : flags.tunnel_ipv6 = true;
11331 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11332 : :
11333 : 0 : return test_ipsec_proto_all(&flags);
11334 : : }
11335 : :
11336 : : static int
11337 : 0 : test_ipsec_proto_sgl(void)
11338 : : {
11339 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11340 : : struct rte_cryptodev_info dev_info;
11341 : :
11342 : 0 : struct ipsec_test_flags flags = {
11343 : : .nb_segs_in_mbuf = 5
11344 : : };
11345 : :
11346 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11347 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11348 : : printf("Device doesn't support in-place scatter-gather. "
11349 : : "Test Skipped.\n");
11350 : 0 : return TEST_SKIPPED;
11351 : : }
11352 : :
11353 : 0 : return test_ipsec_proto_all(&flags);
11354 : : }
11355 : :
11356 : : static int
11357 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11358 : : {
11359 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11360 : : struct rte_cryptodev_info dev_info;
11361 : :
11362 : 0 : struct ipsec_test_flags flags = {
11363 : : .nb_segs_in_mbuf = 5,
11364 : : .use_ext_mbuf = 1
11365 : : };
11366 : :
11367 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11368 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11369 : : printf("Device doesn't support in-place scatter-gather. "
11370 : : "Test Skipped.\n");
11371 : 0 : return TEST_SKIPPED;
11372 : : }
11373 : :
11374 : 0 : return test_ipsec_proto_all(&flags);
11375 : : }
11376 : :
11377 : : static int
11378 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11379 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11380 : : uint64_t winsz)
11381 : : {
11382 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11383 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11384 : : struct ipsec_test_flags flags;
11385 : : uint32_t i = 0, ret = 0;
11386 : :
11387 [ # # ]: 0 : if (nb_pkts == 0)
11388 : : return TEST_FAILED;
11389 : :
11390 : : memset(&flags, 0, sizeof(flags));
11391 : 0 : flags.antireplay = true;
11392 : :
11393 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11394 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11395 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11396 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11397 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11398 : : }
11399 : :
11400 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11401 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11402 : :
11403 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11404 : : &flags);
11405 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11406 : : return ret;
11407 : :
11408 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11409 : :
11410 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11411 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11412 : : /* Set antireplay flag for packets to be dropped */
11413 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11414 : : }
11415 : :
11416 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11417 : : &flags);
11418 : :
11419 : 0 : return ret;
11420 : : }
11421 : :
11422 : : static int
11423 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11424 : : {
11425 : :
11426 : : uint32_t nb_pkts = 5;
11427 : : bool replayed_pkt[5];
11428 : : uint64_t esn[5];
11429 : :
11430 : : /* 1. Advance the TOP of the window to WS * 2 */
11431 : 0 : esn[0] = winsz * 2;
11432 : : /* 2. Test sequence number within the new window(WS + 1) */
11433 : 0 : esn[1] = winsz + 1;
11434 : : /* 3. Test sequence number less than the window BOTTOM */
11435 : 0 : esn[2] = winsz;
11436 : : /* 4. Test sequence number in the middle of the window */
11437 : 0 : esn[3] = winsz + (winsz / 2);
11438 : : /* 5. Test replay of the packet in the middle of the window */
11439 : 0 : esn[4] = winsz + (winsz / 2);
11440 : :
11441 : 0 : replayed_pkt[0] = false;
11442 : 0 : replayed_pkt[1] = false;
11443 : 0 : replayed_pkt[2] = true;
11444 : 0 : replayed_pkt[3] = false;
11445 : 0 : replayed_pkt[4] = true;
11446 : :
11447 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11448 : : false, winsz);
11449 : : }
11450 : :
11451 : : static int
11452 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11453 : : {
11454 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11455 : : }
11456 : :
11457 : : static int
11458 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11459 : : {
11460 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11461 : : }
11462 : :
11463 : : static int
11464 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11465 : : {
11466 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11467 : : }
11468 : :
11469 : : static int
11470 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11471 : : {
11472 : :
11473 : : uint32_t nb_pkts = 7;
11474 : : bool replayed_pkt[7];
11475 : : uint64_t esn[7];
11476 : :
11477 : : /* Set the initial sequence number */
11478 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11479 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11480 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11481 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11482 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11483 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11484 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11485 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11486 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11487 : : /* 5. Test with duplicate sequence number within
11488 : : * new window (1<<32 - 1)
11489 : : */
11490 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11491 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11492 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11493 : :
11494 : 0 : replayed_pkt[0] = false;
11495 : 0 : replayed_pkt[1] = false;
11496 : 0 : replayed_pkt[2] = false;
11497 : 0 : replayed_pkt[3] = false;
11498 : 0 : replayed_pkt[4] = false;
11499 : 0 : replayed_pkt[5] = true;
11500 : 0 : replayed_pkt[6] = true;
11501 : :
11502 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11503 : : true, winsz);
11504 : : }
11505 : :
11506 : : static int
11507 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11508 : : {
11509 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11510 : : }
11511 : :
11512 : : static int
11513 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11514 : : {
11515 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11516 : : }
11517 : :
11518 : : static int
11519 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11520 : : {
11521 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11522 : : }
11523 : :
11524 : : static int
11525 : 0 : test_PDCP_PROTO_all(void)
11526 : : {
11527 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11528 : : struct crypto_unittest_params *ut_params = &unittest_params;
11529 : : struct rte_cryptodev_info dev_info;
11530 : : int status;
11531 : :
11532 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11533 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11534 : :
11535 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11536 : : return TEST_SKIPPED;
11537 : :
11538 : : /* Set action type */
11539 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11540 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11541 : : gbl_action_type;
11542 : :
11543 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11544 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11545 : : return TEST_SKIPPED;
11546 : :
11547 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11548 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11549 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11550 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11551 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11552 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11553 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11554 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11555 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11556 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11557 : 0 : status += test_PDCP_PROTO_short_mac();
11558 : :
11559 [ # # ]: 0 : if (status)
11560 : : return TEST_FAILED;
11561 : : else
11562 : 0 : return TEST_SUCCESS;
11563 : : }
11564 : :
11565 : : static int
11566 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11567 : : {
11568 : 0 : struct ipsec_test_flags flags = {
11569 : : .dec_ttl_or_hop_limit = true
11570 : : };
11571 : :
11572 : 0 : return test_ipsec_proto_all(&flags);
11573 : : }
11574 : :
11575 : : static int
11576 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11577 : : {
11578 : 0 : struct ipsec_test_flags flags = {
11579 : : .ipv6 = true,
11580 : : .dec_ttl_or_hop_limit = true
11581 : : };
11582 : :
11583 : 0 : return test_ipsec_proto_all(&flags);
11584 : : }
11585 : :
11586 : : static int
11587 : 0 : test_docsis_proto_uplink(const void *data)
11588 : : {
11589 : : const struct docsis_test_data *d_td = data;
11590 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11591 : : struct crypto_unittest_params *ut_params = &unittest_params;
11592 : : uint8_t *plaintext = NULL;
11593 : : uint8_t *ciphertext = NULL;
11594 : : uint8_t *iv_ptr;
11595 : : int32_t cipher_len, crc_len;
11596 : : uint32_t crc_data_len;
11597 : : int ret = TEST_SUCCESS;
11598 : :
11599 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11600 : :
11601 : : /* Verify the capabilities */
11602 : : struct rte_security_capability_idx sec_cap_idx;
11603 : : const struct rte_security_capability *sec_cap;
11604 : : const struct rte_cryptodev_capabilities *crypto_cap;
11605 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11606 : : int j = 0;
11607 : :
11608 : : /* Set action type */
11609 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11610 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11611 : : gbl_action_type;
11612 : :
11613 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11614 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11615 : : return TEST_SKIPPED;
11616 : :
11617 : 0 : sec_cap_idx.action = ut_params->type;
11618 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11619 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11620 : :
11621 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11622 [ # # ]: 0 : if (sec_cap == NULL)
11623 : : return TEST_SKIPPED;
11624 : :
11625 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11626 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11627 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11628 : : crypto_cap->sym.xform_type ==
11629 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11630 : : crypto_cap->sym.cipher.algo ==
11631 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11632 : 0 : sym_cap = &crypto_cap->sym;
11633 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11634 : 0 : d_td->key.len,
11635 : 0 : d_td->iv.len) == 0)
11636 : : break;
11637 : : }
11638 : : }
11639 : :
11640 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11641 : : return TEST_SKIPPED;
11642 : :
11643 : : /* Setup source mbuf payload */
11644 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11645 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11646 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11647 : :
11648 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11649 : 0 : d_td->ciphertext.len);
11650 : :
11651 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11652 : :
11653 : : /* Setup cipher session parameters */
11654 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11655 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11656 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11657 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11658 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11659 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11660 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11661 : 0 : ut_params->cipher_xform.next = NULL;
11662 : :
11663 : : /* Setup DOCSIS session parameters */
11664 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11665 : :
11666 : 0 : struct rte_security_session_conf sess_conf = {
11667 : 0 : .action_type = ut_params->type,
11668 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11669 : : .docsis = ut_params->docsis_xform,
11670 : : .crypto_xform = &ut_params->cipher_xform,
11671 : : };
11672 : :
11673 : : /* Create security session */
11674 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11675 : : ts_params->session_mpool);
11676 : :
11677 [ # # ]: 0 : if (!ut_params->sec_session) {
11678 : : printf("Test function %s line %u: failed to allocate session\n",
11679 : : __func__, __LINE__);
11680 : : ret = TEST_FAILED;
11681 : 0 : goto on_err;
11682 : : }
11683 : :
11684 : : /* Generate crypto op data structure */
11685 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11686 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11687 [ # # ]: 0 : if (!ut_params->op) {
11688 : : printf("Test function %s line %u: failed to allocate symmetric "
11689 : : "crypto operation\n", __func__, __LINE__);
11690 : : ret = TEST_FAILED;
11691 : 0 : goto on_err;
11692 : : }
11693 : :
11694 : : /* Setup CRC operation parameters */
11695 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11696 : 0 : (d_td->ciphertext.len -
11697 : 0 : d_td->ciphertext.crc_offset -
11698 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11699 : : 0;
11700 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11701 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11702 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11703 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11704 : :
11705 : : /* Setup cipher operation parameters */
11706 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11707 : 0 : (d_td->ciphertext.len -
11708 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11709 : : 0;
11710 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11711 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11712 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11713 : :
11714 : : /* Setup cipher IV */
11715 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11716 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11717 : :
11718 : : /* Attach session to operation */
11719 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11720 : :
11721 : : /* Set crypto operation mbufs */
11722 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11723 : 0 : ut_params->op->sym->m_dst = NULL;
11724 : :
11725 : : /* Process crypto operation */
11726 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11727 : : NULL) {
11728 : : printf("Test function %s line %u: failed to process security "
11729 : : "crypto op\n", __func__, __LINE__);
11730 : : ret = TEST_FAILED;
11731 : 0 : goto on_err;
11732 : : }
11733 : :
11734 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11735 : : printf("Test function %s line %u: failed to process crypto op\n",
11736 : : __func__, __LINE__);
11737 : : ret = TEST_FAILED;
11738 : 0 : goto on_err;
11739 : : }
11740 : :
11741 : : /* Validate plaintext */
11742 : : plaintext = ciphertext;
11743 : :
11744 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11745 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11746 : : printf("Test function %s line %u: plaintext not as expected\n",
11747 : : __func__, __LINE__);
11748 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11749 : 0 : d_td->plaintext.len);
11750 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11751 : : ret = TEST_FAILED;
11752 : 0 : goto on_err;
11753 : : }
11754 : :
11755 : 0 : on_err:
11756 : 0 : rte_crypto_op_free(ut_params->op);
11757 : 0 : ut_params->op = NULL;
11758 : :
11759 [ # # ]: 0 : if (ut_params->sec_session)
11760 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11761 : 0 : ut_params->sec_session = NULL;
11762 : :
11763 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11764 : 0 : ut_params->ibuf = NULL;
11765 : :
11766 : 0 : return ret;
11767 : : }
11768 : :
11769 : : static int
11770 : 0 : test_docsis_proto_downlink(const void *data)
11771 : : {
11772 : : const struct docsis_test_data *d_td = data;
11773 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11774 : : struct crypto_unittest_params *ut_params = &unittest_params;
11775 : : uint8_t *plaintext = NULL;
11776 : : uint8_t *ciphertext = NULL;
11777 : : uint8_t *iv_ptr;
11778 : : int32_t cipher_len, crc_len;
11779 : : int ret = TEST_SUCCESS;
11780 : :
11781 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11782 : :
11783 : : /* Verify the capabilities */
11784 : : struct rte_security_capability_idx sec_cap_idx;
11785 : : const struct rte_security_capability *sec_cap;
11786 : : const struct rte_cryptodev_capabilities *crypto_cap;
11787 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11788 : : int j = 0;
11789 : :
11790 : : /* Set action type */
11791 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11792 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11793 : : gbl_action_type;
11794 : :
11795 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11796 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11797 : : return TEST_SKIPPED;
11798 : :
11799 : 0 : sec_cap_idx.action = ut_params->type;
11800 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11801 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11802 : :
11803 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11804 [ # # ]: 0 : if (sec_cap == NULL)
11805 : : return TEST_SKIPPED;
11806 : :
11807 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11808 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11809 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11810 : : crypto_cap->sym.xform_type ==
11811 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11812 : : crypto_cap->sym.cipher.algo ==
11813 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11814 : 0 : sym_cap = &crypto_cap->sym;
11815 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11816 : 0 : d_td->key.len,
11817 : 0 : d_td->iv.len) == 0)
11818 : : break;
11819 : : }
11820 : : }
11821 : :
11822 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11823 : : return TEST_SKIPPED;
11824 : :
11825 : : /* Setup source mbuf payload */
11826 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11827 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11828 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11829 : :
11830 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11831 : 0 : d_td->plaintext.len);
11832 : :
11833 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11834 : :
11835 : : /* Setup cipher session parameters */
11836 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11837 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11838 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11839 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11840 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11841 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11842 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11843 : 0 : ut_params->cipher_xform.next = NULL;
11844 : :
11845 : : /* Setup DOCSIS session parameters */
11846 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11847 : :
11848 : 0 : struct rte_security_session_conf sess_conf = {
11849 : 0 : .action_type = ut_params->type,
11850 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11851 : : .docsis = ut_params->docsis_xform,
11852 : : .crypto_xform = &ut_params->cipher_xform,
11853 : : };
11854 : :
11855 : : /* Create security session */
11856 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11857 : : ts_params->session_mpool);
11858 : :
11859 [ # # ]: 0 : if (!ut_params->sec_session) {
11860 : : printf("Test function %s line %u: failed to allocate session\n",
11861 : : __func__, __LINE__);
11862 : : ret = TEST_FAILED;
11863 : 0 : goto on_err;
11864 : : }
11865 : :
11866 : : /* Generate crypto op data structure */
11867 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11868 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11869 [ # # ]: 0 : if (!ut_params->op) {
11870 : : printf("Test function %s line %u: failed to allocate symmetric "
11871 : : "crypto operation\n", __func__, __LINE__);
11872 : : ret = TEST_FAILED;
11873 : 0 : goto on_err;
11874 : : }
11875 : :
11876 : : /* Setup CRC operation parameters */
11877 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11878 : 0 : (d_td->plaintext.len -
11879 : 0 : d_td->plaintext.crc_offset -
11880 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11881 : : 0;
11882 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11883 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11884 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11885 : :
11886 : : /* Setup cipher operation parameters */
11887 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11888 : 0 : (d_td->plaintext.len -
11889 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11890 : : 0;
11891 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11892 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11893 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11894 : :
11895 : : /* Setup cipher IV */
11896 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11897 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11898 : :
11899 : : /* Attach session to operation */
11900 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11901 : :
11902 : : /* Set crypto operation mbufs */
11903 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11904 : 0 : ut_params->op->sym->m_dst = NULL;
11905 : :
11906 : : /* Process crypto operation */
11907 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11908 : : NULL) {
11909 : : printf("Test function %s line %u: failed to process crypto op\n",
11910 : : __func__, __LINE__);
11911 : : ret = TEST_FAILED;
11912 : 0 : goto on_err;
11913 : : }
11914 : :
11915 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11916 : : printf("Test function %s line %u: crypto op processing failed\n",
11917 : : __func__, __LINE__);
11918 : : ret = TEST_FAILED;
11919 : 0 : goto on_err;
11920 : : }
11921 : :
11922 : : /* Validate ciphertext */
11923 : : ciphertext = plaintext;
11924 : :
11925 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11926 : : printf("Test function %s line %u: plaintext not as expected\n",
11927 : : __func__, __LINE__);
11928 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11929 : 0 : d_td->ciphertext.len);
11930 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11931 : : ret = TEST_FAILED;
11932 : 0 : goto on_err;
11933 : : }
11934 : :
11935 : 0 : on_err:
11936 : 0 : rte_crypto_op_free(ut_params->op);
11937 : 0 : ut_params->op = NULL;
11938 : :
11939 [ # # ]: 0 : if (ut_params->sec_session)
11940 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11941 : 0 : ut_params->sec_session = NULL;
11942 : :
11943 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11944 : 0 : ut_params->ibuf = NULL;
11945 : :
11946 : 0 : return ret;
11947 : : }
11948 : :
11949 : : static void
11950 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11951 : : struct rte_security_tls_record_xform *tls_record_xform)
11952 : : {
11953 : : unsigned int imp_nonce_len;
11954 : : uint8_t *imp_nonce;
11955 : :
11956 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11957 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11958 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11959 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11960 : 0 : break;
11961 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11962 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11963 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11964 : 0 : break;
11965 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
11966 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11967 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11968 : 0 : break;
11969 : : default:
11970 : : return;
11971 : : }
11972 : :
11973 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11974 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11975 : : }
11976 : :
11977 : : static int
11978 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
11979 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
11980 : : const struct tls_record_test_flags *flags)
11981 : : {
11982 : 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11983 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11984 : : struct crypto_unittest_params *ut_params = &unittest_params;
11985 : : struct rte_security_tls_record_xform tls_record_xform;
11986 : : struct rte_security_capability_idx sec_cap_idx;
11987 : : const struct rte_security_capability *sec_cap;
11988 : : struct tls_record_test_data *res_d_tmp = NULL;
11989 : : enum rte_security_tls_sess_type sess_type;
11990 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
11991 : : struct rte_security_ctx *ctx;
11992 : : int i, ret = TEST_SUCCESS;
11993 : :
11994 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11995 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11996 : :
11997 : : /* Use first test data to create session */
11998 : :
11999 : : /* Copy TLS record xform */
12000 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
12001 : :
12002 : 0 : sess_type = tls_record_xform.type;
12003 : :
12004 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12005 : :
12006 : 0 : sec_cap_idx.action = ut_params->type;
12007 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
12008 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
12009 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
12010 : :
12011 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
12012 [ # # ]: 0 : if (sec_cap == NULL)
12013 : : return TEST_SKIPPED;
12014 : :
12015 : : /* Copy cipher session parameters */
12016 [ # # ]: 0 : if (td[0].aead) {
12017 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
12018 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
12019 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
12020 : :
12021 : : /* Verify crypto capabilities */
12022 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
12023 [ # # ]: 0 : if (!silent)
12024 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
12025 : 0 : return TEST_SKIPPED;
12026 : : }
12027 : : } else {
12028 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
12029 : : sizeof(ut_params->cipher_xform));
12030 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
12031 : : sizeof(ut_params->auth_xform));
12032 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
12033 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12034 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
12035 : :
12036 : : /* Verify crypto capabilities */
12037 : :
12038 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
12039 [ # # ]: 0 : if (!silent)
12040 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
12041 : 0 : return TEST_SKIPPED;
12042 : : }
12043 : :
12044 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
12045 [ # # ]: 0 : if (!silent)
12046 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
12047 : 0 : return TEST_SKIPPED;
12048 : : }
12049 : : }
12050 : :
12051 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
12052 : : return TEST_SKIPPED;
12053 : :
12054 : 0 : struct rte_security_session_conf sess_conf = {
12055 : 0 : .action_type = ut_params->type,
12056 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
12057 : : };
12058 : :
12059 : : if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
12060 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
12061 : : sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
12062 : :
12063 [ # # ]: 0 : if (td[0].aead)
12064 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
12065 : :
12066 [ # # ]: 0 : if (flags->opt_padding)
12067 : 0 : tls_record_xform.options.extra_padding_enable = 1;
12068 : :
12069 : 0 : sess_conf.tls_record = tls_record_xform;
12070 : :
12071 [ # # ]: 0 : if (td[0].aead) {
12072 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
12073 : : } else {
12074 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
12075 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
12076 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
12077 : : } else {
12078 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
12079 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
12080 : : }
12081 : : }
12082 : :
12083 [ # # ]: 0 : if (ut_params->sec_session == NULL) {
12084 : : /* Create security session */
12085 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
12086 : : ts_params->session_mpool);
12087 : : }
12088 : :
12089 [ # # ]: 0 : if (ut_params->sec_session == NULL)
12090 : : return TEST_SKIPPED;
12091 : :
12092 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
12093 [ # # # # ]: 0 : if (flags->ar_win_size &&
12094 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
12095 : 0 : sess_conf.tls_record.dtls_1_2.seq_no =
12096 : 0 : td[i].tls_record_xform.dtls_1_2.seq_no;
12097 : 0 : ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
12098 [ # # ]: 0 : if (ret) {
12099 : : printf("Could not update sequence number in session\n");
12100 : 0 : return TEST_SKIPPED;
12101 : : }
12102 : : }
12103 : :
12104 : : /* Setup source mbuf payload */
12105 : 0 : ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12106 : 0 : ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
12107 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
12108 [ # # ]: 0 : if (flags->out_of_place)
12109 : 0 : ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12110 : 0 : ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
12111 : : 0);
12112 : : else
12113 : 0 : ut_params->obuf = NULL;
12114 : :
12115 : : /* Generate crypto op data structure */
12116 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12117 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12118 [ # # ]: 0 : if (ut_params->op == NULL) {
12119 : : printf("Could not allocate crypto op");
12120 : : ret = TEST_FAILED;
12121 : 0 : goto crypto_op_free;
12122 : : }
12123 : :
12124 : : /* Attach session to operation */
12125 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
12126 : :
12127 : : /* Set crypto operation mbufs */
12128 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12129 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12130 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
12131 : :
12132 [ # # ]: 0 : if (flags->opt_padding)
12133 : 0 : ut_params->op->aux_flags = flags->opt_padding;
12134 : :
12135 : : /* Copy IV in crypto operation when IV generation is disabled */
12136 [ # # ]: 0 : if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12137 [ # # ]: 0 : (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12138 [ # # ]: 0 : (tls_record_xform.options.iv_gen_disable == 1)) {
12139 : : uint8_t *iv;
12140 : : int len;
12141 : :
12142 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12143 [ # # ]: 0 : if (td[i].aead)
12144 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
12145 : : else
12146 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
12147 : 0 : memcpy(iv, td[i].iv.data, len);
12148 : : }
12149 : :
12150 : : /* Process crypto operation */
12151 : 0 : process_crypto_request(dev_id, ut_params->op);
12152 : :
12153 : 0 : ret = test_tls_record_status_check(ut_params->op, &td[i]);
12154 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12155 : 0 : goto crypto_op_free;
12156 : :
12157 [ # # ]: 0 : if (res_d != NULL)
12158 : 0 : res_d_tmp = &res_d[i];
12159 : :
12160 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12161 [ # # ]: 0 : struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12162 : : ut_params->ibuf;
12163 : :
12164 : 0 : ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12165 : : silent, flags);
12166 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12167 : 0 : goto crypto_op_free;
12168 : : }
12169 : :
12170 : 0 : rte_crypto_op_free(ut_params->op);
12171 : 0 : ut_params->op = NULL;
12172 : :
12173 [ # # ]: 0 : if (flags->out_of_place) {
12174 : 0 : rte_pktmbuf_free(ut_params->obuf);
12175 : 0 : ut_params->obuf = NULL;
12176 : : }
12177 : :
12178 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12179 : 0 : ut_params->ibuf = NULL;
12180 : : }
12181 : :
12182 : 0 : crypto_op_free:
12183 : 0 : rte_crypto_op_free(ut_params->op);
12184 : 0 : ut_params->op = NULL;
12185 : :
12186 [ # # ]: 0 : if (flags->out_of_place) {
12187 : 0 : rte_pktmbuf_free(ut_params->obuf);
12188 : 0 : ut_params->obuf = NULL;
12189 : : }
12190 : :
12191 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12192 : 0 : ut_params->ibuf = NULL;
12193 : :
12194 [ # # # # ]: 0 : if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12195 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
12196 : 0 : ut_params->sec_session = NULL;
12197 : : }
12198 : :
12199 : : RTE_SET_USED(flags);
12200 : :
12201 : : return ret;
12202 : : }
12203 : :
12204 : : static int
12205 : 0 : test_tls_record_proto_known_vec(const void *test_data)
12206 : : {
12207 : : struct tls_record_test_data td_write;
12208 : : struct tls_record_test_flags flags;
12209 : :
12210 : : memset(&flags, 0, sizeof(flags));
12211 : :
12212 : : memcpy(&td_write, test_data, sizeof(td_write));
12213 : :
12214 : : /* Disable IV gen to be able to test with known vectors */
12215 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
12216 : :
12217 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12218 : : }
12219 : :
12220 : : static int
12221 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
12222 : : {
12223 : : const struct tls_record_test_data *td = test_data;
12224 : : struct tls_record_test_flags flags;
12225 : : struct tls_record_test_data td_inb;
12226 : :
12227 : : memset(&flags, 0, sizeof(flags));
12228 : :
12229 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12230 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
12231 : : else
12232 : : memcpy(&td_inb, td, sizeof(td_inb));
12233 : :
12234 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12235 : : }
12236 : :
12237 : : static int
12238 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12239 : : {
12240 : : unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12241 : : struct crypto_unittest_params *ut_params = &unittest_params;
12242 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12243 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12244 : : void *sec_session_outb = NULL;
12245 : : void *sec_session_inb = NULL;
12246 : : int ret;
12247 : :
12248 [ # # # ]: 0 : switch (flags->tls_version) {
12249 : : case RTE_SECURITY_VERSION_TLS_1_2:
12250 : : max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12251 : : break;
12252 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
12253 : : max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12254 : 0 : break;
12255 : : case RTE_SECURITY_VERSION_DTLS_1_2:
12256 : : max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12257 : : break;
12258 : 0 : default:
12259 : : max_payload_len = 0;
12260 : : }
12261 : :
12262 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12263 : : payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12264 [ # # ]: 0 : if (flags->nb_segs_in_mbuf)
12265 : 0 : payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12266 : :
12267 [ # # ]: 0 : if (flags->zero_len)
12268 : : payload_len = 0;
12269 : 0 : again:
12270 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12271 : : flags, td_outb, nb_pkts, payload_len);
12272 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12273 : 0 : continue;
12274 : :
12275 [ # # ]: 0 : if (flags->skip_sess_destroy)
12276 : 0 : ut_params->sec_session = sec_session_outb;
12277 : :
12278 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12279 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12280 : 0 : continue;
12281 : :
12282 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_outb == NULL)
12283 : 0 : sec_session_outb = ut_params->sec_session;
12284 : :
12285 [ # # # # ]: 0 : if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
12286 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12287 : : return TEST_FAILED;
12288 : 0 : goto skip_decrypt;
12289 [ # # ]: 0 : } else if (ret == TEST_FAILED) {
12290 : : return TEST_FAILED;
12291 : : }
12292 : :
12293 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12294 : :
12295 [ # # ]: 0 : if (flags->skip_sess_destroy)
12296 : 0 : ut_params->sec_session = sec_session_inb;
12297 : :
12298 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12299 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12300 : 0 : continue;
12301 : :
12302 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_inb == NULL)
12303 : 0 : sec_session_inb = ut_params->sec_session;
12304 : :
12305 [ # # # # ]: 0 : if (flags->pkt_corruption || flags->padding_corruption) {
12306 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12307 : : return TEST_FAILED;
12308 : : } else {
12309 [ # # ]: 0 : if (ret == TEST_FAILED)
12310 : : return TEST_FAILED;
12311 : : }
12312 : :
12313 : 0 : skip_decrypt:
12314 [ # # # # ]: 0 : if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12315 : 0 : goto again;
12316 : :
12317 [ # # ]: 0 : if (flags->display_alg)
12318 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12319 : :
12320 [ # # ]: 0 : if (flags->skip_sess_destroy) {
12321 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
12322 : : struct rte_security_ctx *ctx;
12323 : :
12324 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12325 [ # # ]: 0 : if (sec_session_inb != NULL) {
12326 : 0 : rte_security_session_destroy(ctx, sec_session_inb);
12327 : : sec_session_inb = NULL;
12328 : : }
12329 [ # # ]: 0 : if (sec_session_outb != NULL) {
12330 : 0 : rte_security_session_destroy(ctx, sec_session_outb);
12331 : : sec_session_outb = NULL;
12332 : : }
12333 : 0 : ut_params->sec_session = NULL;
12334 : : }
12335 : :
12336 : 0 : pass_cnt++;
12337 : : }
12338 : :
12339 [ # # ]: 0 : if (flags->data_walkthrough)
12340 : : printf("\t Min payload size: %d, Max payload size: %d\n",
12341 : : TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
12342 : :
12343 [ # # ]: 0 : if (pass_cnt > 0)
12344 : : return TEST_SUCCESS;
12345 : : else
12346 : 0 : return TEST_SKIPPED;
12347 : : }
12348 : :
12349 : : static int
12350 : 0 : test_tls_1_2_record_proto_data_walkthrough(void)
12351 : : {
12352 : : struct tls_record_test_flags flags;
12353 : :
12354 : : memset(&flags, 0, sizeof(flags));
12355 : :
12356 : 0 : flags.data_walkthrough = true;
12357 : 0 : flags.skip_sess_destroy = true;
12358 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12359 : :
12360 : 0 : return test_tls_record_proto_all(&flags);
12361 : : }
12362 : :
12363 : : static int
12364 : 0 : test_tls_1_2_record_proto_display_list(void)
12365 : : {
12366 : : struct tls_record_test_flags flags;
12367 : :
12368 : : memset(&flags, 0, sizeof(flags));
12369 : :
12370 : 0 : flags.display_alg = true;
12371 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12372 : :
12373 : 0 : return test_tls_record_proto_all(&flags);
12374 : : }
12375 : :
12376 : : static int
12377 : 0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12378 : : {
12379 : 0 : struct tls_record_test_flags flags = {
12380 : : .nb_segs_in_mbuf = 5,
12381 : : .tls_version = tls_version
12382 : : };
12383 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12384 : : struct rte_cryptodev_info dev_info;
12385 : :
12386 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12387 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12388 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12389 : 0 : return TEST_SKIPPED;
12390 : : }
12391 : :
12392 : 0 : return test_tls_record_proto_all(&flags);
12393 : : }
12394 : :
12395 : : static int
12396 : 0 : test_tls_1_2_record_proto_sgl(void)
12397 : : {
12398 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12399 : : }
12400 : :
12401 : : static int
12402 : 0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12403 : : {
12404 : 0 : struct tls_record_test_flags flags = {
12405 : : .nb_segs_in_mbuf = 5,
12406 : : .tls_version = tls_version,
12407 : : .skip_sess_destroy = true,
12408 : : .data_walkthrough = true
12409 : : };
12410 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12411 : : struct rte_cryptodev_info dev_info;
12412 : :
12413 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12414 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12415 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12416 : 0 : return TEST_SKIPPED;
12417 : : }
12418 : :
12419 : 0 : return test_tls_record_proto_all(&flags);
12420 : : }
12421 : :
12422 : : static int
12423 : 0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12424 : : {
12425 : 0 : struct tls_record_test_flags flags = {
12426 : : .nb_segs_in_mbuf = 5,
12427 : : .out_of_place = true,
12428 : : .tls_version = tls_version
12429 : : };
12430 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12431 : : struct rte_cryptodev_info dev_info;
12432 : :
12433 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12434 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12435 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12436 : 0 : return TEST_SKIPPED;
12437 : : }
12438 : :
12439 : 0 : return test_tls_record_proto_all(&flags);
12440 : : }
12441 : :
12442 : : static int
12443 : 0 : test_tls_1_2_record_proto_sgl_oop(void)
12444 : : {
12445 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12446 : : }
12447 : :
12448 : : static int
12449 : 0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12450 : : {
12451 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12452 : : }
12453 : :
12454 : : static int
12455 : 0 : test_tls_record_proto_corrupt_pkt(void)
12456 : : {
12457 : 0 : struct tls_record_test_flags flags = {
12458 : : .pkt_corruption = 1
12459 : : };
12460 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12461 : : struct rte_cryptodev_info dev_info;
12462 : :
12463 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12464 : :
12465 : 0 : return test_tls_record_proto_all(&flags);
12466 : : }
12467 : :
12468 : : static int
12469 : 0 : test_tls_record_proto_custom_content_type(void)
12470 : : {
12471 : 0 : struct tls_record_test_flags flags = {
12472 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12473 : : };
12474 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12475 : : struct rte_cryptodev_info dev_info;
12476 : :
12477 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12478 : :
12479 : 0 : return test_tls_record_proto_all(&flags);
12480 : : }
12481 : :
12482 : : static int
12483 : 0 : test_tls_record_proto_zero_len(void)
12484 : : {
12485 : 0 : struct tls_record_test_flags flags = {
12486 : : .zero_len = 1
12487 : : };
12488 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12489 : : struct rte_cryptodev_info dev_info;
12490 : :
12491 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12492 : :
12493 : 0 : return test_tls_record_proto_all(&flags);
12494 : : }
12495 : :
12496 : : static int
12497 : 0 : test_tls_record_proto_zero_len_non_app(void)
12498 : : {
12499 : 0 : struct tls_record_test_flags flags = {
12500 : : .zero_len = 1,
12501 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12502 : : };
12503 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12504 : : struct rte_cryptodev_info dev_info;
12505 : :
12506 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12507 : :
12508 : 0 : return test_tls_record_proto_all(&flags);
12509 : : }
12510 : :
12511 : : static int
12512 : 0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12513 : : enum rte_security_tls_version tls_version)
12514 : : {
12515 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12516 : : struct rte_cryptodev_info dev_info;
12517 : 0 : struct tls_record_test_flags flags = {
12518 : : .nb_segs_in_mbuf = num_segs,
12519 : : .tls_version = tls_version,
12520 : : .opt_padding = padding
12521 : : };
12522 : :
12523 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12524 : :
12525 : 0 : return test_tls_record_proto_all(&flags);
12526 : : }
12527 : :
12528 : : static int
12529 : 0 : test_tls_record_proto_dm_opt_padding(void)
12530 : : {
12531 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12532 : : }
12533 : :
12534 : : static int
12535 : 0 : test_tls_record_proto_dm_opt_padding_1(void)
12536 : : {
12537 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12538 : : }
12539 : :
12540 : : static int
12541 : 0 : test_tls_record_proto_sg_opt_padding(void)
12542 : : {
12543 : 0 : return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12544 : : }
12545 : :
12546 : : static int
12547 : 0 : test_tls_record_proto_sg_opt_padding_1(void)
12548 : : {
12549 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12550 : : }
12551 : :
12552 : : static int
12553 : 0 : test_tls_record_proto_sg_opt_padding_2(void)
12554 : : {
12555 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12556 : : }
12557 : :
12558 : : static int
12559 : 0 : test_tls_record_proto_sg_opt_padding_max(void)
12560 : : {
12561 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12562 : : }
12563 : :
12564 : : static int
12565 : 0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
12566 : : {
12567 : 0 : struct tls_record_test_flags flags = {
12568 : : .opt_padding = 8,
12569 : : .padding_corruption = true,
12570 : : .nb_segs_in_mbuf = 4,
12571 : : };
12572 : :
12573 : 0 : return test_tls_record_proto_all(&flags);
12574 : : }
12575 : :
12576 : : static int
12577 : 0 : test_dtls_1_2_record_proto_data_walkthrough(void)
12578 : : {
12579 : : struct tls_record_test_flags flags;
12580 : :
12581 : : memset(&flags, 0, sizeof(flags));
12582 : :
12583 : 0 : flags.data_walkthrough = true;
12584 : 0 : flags.skip_sess_destroy = true;
12585 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12586 : :
12587 : 0 : return test_tls_record_proto_all(&flags);
12588 : : }
12589 : :
12590 : : static int
12591 : 0 : test_dtls_1_2_record_proto_display_list(void)
12592 : : {
12593 : : struct tls_record_test_flags flags;
12594 : :
12595 : : memset(&flags, 0, sizeof(flags));
12596 : :
12597 : 0 : flags.display_alg = true;
12598 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12599 : :
12600 : 0 : return test_tls_record_proto_all(&flags);
12601 : : }
12602 : :
12603 : : static int
12604 : 0 : test_dtls_pkt_replay(const uint64_t seq_no[],
12605 : : bool replayed_pkt[], uint32_t nb_pkts,
12606 : : struct tls_record_test_flags *flags)
12607 : : {
12608 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12609 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12610 : : unsigned int i, idx, pass_cnt = 0;
12611 : : int ret;
12612 : :
12613 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12614 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12615 : : flags, td_outb, nb_pkts, 0);
12616 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12617 : 0 : continue;
12618 : :
12619 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++)
12620 : 0 : td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12621 : :
12622 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12623 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12624 : 0 : continue;
12625 : :
12626 [ # # ]: 0 : if (ret == TEST_FAILED)
12627 : : return TEST_FAILED;
12628 : :
12629 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12630 : :
12631 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
12632 : 0 : td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12633 : : /* Set antireplay flag for packets to be dropped */
12634 : 0 : td_inb[idx].ar_packet = replayed_pkt[idx];
12635 : : }
12636 : :
12637 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12638 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12639 : 0 : continue;
12640 : :
12641 [ # # ]: 0 : if (ret == TEST_FAILED)
12642 : : return TEST_FAILED;
12643 : :
12644 [ # # ]: 0 : if (flags->display_alg)
12645 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12646 : :
12647 : 0 : pass_cnt++;
12648 : : }
12649 : :
12650 [ # # ]: 0 : if (pass_cnt > 0)
12651 : : return TEST_SUCCESS;
12652 : : else
12653 : 0 : return TEST_SKIPPED;
12654 : : }
12655 : :
12656 : : static int
12657 : 0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12658 : : {
12659 : : struct tls_record_test_flags flags;
12660 : : uint32_t nb_pkts = 5;
12661 : : bool replayed_pkt[5];
12662 : : uint64_t seq_no[5];
12663 : :
12664 : : memset(&flags, 0, sizeof(flags));
12665 : :
12666 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12667 : 0 : flags.ar_win_size = winsz;
12668 : :
12669 : : /* 1. Advance the TOP of the window to WS * 2 */
12670 : 0 : seq_no[0] = winsz * 2;
12671 : : /* 2. Test sequence number within the new window(WS + 1) */
12672 : 0 : seq_no[1] = winsz + 1;
12673 : : /* 3. Test sequence number less than the window BOTTOM */
12674 : 0 : seq_no[2] = winsz;
12675 : : /* 4. Test sequence number in the middle of the window */
12676 : 0 : seq_no[3] = winsz + (winsz / 2);
12677 : : /* 5. Test replay of the packet in the middle of the window */
12678 : 0 : seq_no[4] = winsz + (winsz / 2);
12679 : :
12680 : 0 : replayed_pkt[0] = false;
12681 : 0 : replayed_pkt[1] = false;
12682 : 0 : replayed_pkt[2] = true;
12683 : 0 : replayed_pkt[3] = false;
12684 : 0 : replayed_pkt[4] = true;
12685 : :
12686 : 0 : return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12687 : : }
12688 : :
12689 : : static int
12690 : 0 : test_dtls_1_2_record_proto_antireplay64(void)
12691 : : {
12692 : 0 : return test_dtls_1_2_record_proto_antireplay(64);
12693 : : }
12694 : :
12695 : : static int
12696 : 0 : test_dtls_1_2_record_proto_antireplay128(void)
12697 : : {
12698 : 0 : return test_dtls_1_2_record_proto_antireplay(128);
12699 : : }
12700 : :
12701 : : static int
12702 : 0 : test_dtls_1_2_record_proto_antireplay256(void)
12703 : : {
12704 : 0 : return test_dtls_1_2_record_proto_antireplay(256);
12705 : : }
12706 : :
12707 : : static int
12708 : 0 : test_dtls_1_2_record_proto_antireplay512(void)
12709 : : {
12710 : 0 : return test_dtls_1_2_record_proto_antireplay(512);
12711 : : }
12712 : :
12713 : : static int
12714 : 0 : test_dtls_1_2_record_proto_antireplay1024(void)
12715 : : {
12716 : 0 : return test_dtls_1_2_record_proto_antireplay(1024);
12717 : : }
12718 : :
12719 : : static int
12720 : 0 : test_dtls_1_2_record_proto_antireplay2048(void)
12721 : : {
12722 : 0 : return test_dtls_1_2_record_proto_antireplay(2048);
12723 : : }
12724 : :
12725 : : static int
12726 : 0 : test_dtls_1_2_record_proto_antireplay4096(void)
12727 : : {
12728 : 0 : return test_dtls_1_2_record_proto_antireplay(4096);
12729 : : }
12730 : :
12731 : : static int
12732 : 0 : test_dtls_1_2_record_proto_sgl(void)
12733 : : {
12734 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12735 : : }
12736 : :
12737 : : static int
12738 : 0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12739 : : {
12740 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12741 : : }
12742 : :
12743 : : static int
12744 : 0 : test_dtls_1_2_record_proto_sgl_oop(void)
12745 : : {
12746 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12747 : : }
12748 : :
12749 : : static int
12750 : 0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
12751 : : {
12752 : 0 : struct tls_record_test_flags flags = {
12753 : : .pkt_corruption = 1,
12754 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12755 : : };
12756 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12757 : : struct rte_cryptodev_info dev_info;
12758 : :
12759 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12760 : :
12761 : 0 : return test_tls_record_proto_all(&flags);
12762 : : }
12763 : :
12764 : : static int
12765 : 0 : test_dtls_1_2_record_proto_custom_content_type(void)
12766 : : {
12767 : 0 : struct tls_record_test_flags flags = {
12768 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12769 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12770 : : };
12771 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12772 : : struct rte_cryptodev_info dev_info;
12773 : :
12774 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12775 : :
12776 : 0 : return test_tls_record_proto_all(&flags);
12777 : : }
12778 : :
12779 : : static int
12780 : 0 : test_dtls_1_2_record_proto_zero_len(void)
12781 : : {
12782 : 0 : struct tls_record_test_flags flags = {
12783 : : .zero_len = 1,
12784 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12785 : : };
12786 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12787 : : struct rte_cryptodev_info dev_info;
12788 : :
12789 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12790 : :
12791 : 0 : return test_tls_record_proto_all(&flags);
12792 : : }
12793 : :
12794 : : static int
12795 : 0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
12796 : : {
12797 : 0 : struct tls_record_test_flags flags = {
12798 : : .zero_len = 1,
12799 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12800 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12801 : : };
12802 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12803 : : struct rte_cryptodev_info dev_info;
12804 : :
12805 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12806 : :
12807 : 0 : return test_tls_record_proto_all(&flags);
12808 : : }
12809 : :
12810 : : static int
12811 : 0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
12812 : : {
12813 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12814 : : }
12815 : :
12816 : : static int
12817 : 0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12818 : : {
12819 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12820 : : }
12821 : :
12822 : : static int
12823 : 0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
12824 : : {
12825 : 0 : return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12826 : : }
12827 : :
12828 : : static int
12829 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12830 : : {
12831 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12832 : : }
12833 : :
12834 : : static int
12835 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12836 : : {
12837 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12838 : : }
12839 : :
12840 : : static int
12841 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12842 : : {
12843 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12844 : : }
12845 : :
12846 : : static int
12847 : 0 : test_tls_1_3_record_proto_display_list(void)
12848 : : {
12849 : : struct tls_record_test_flags flags;
12850 : :
12851 : : memset(&flags, 0, sizeof(flags));
12852 : :
12853 : 0 : flags.display_alg = true;
12854 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12855 : :
12856 : 0 : return test_tls_record_proto_all(&flags);
12857 : : }
12858 : :
12859 : : static int
12860 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12861 : : {
12862 : 0 : struct tls_record_test_flags flags = {
12863 : : .opt_padding = 8,
12864 : : .padding_corruption = true,
12865 : : .nb_segs_in_mbuf = 4,
12866 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12867 : : };
12868 : :
12869 : 0 : return test_tls_record_proto_all(&flags);
12870 : : }
12871 : :
12872 : : static int
12873 : 0 : test_tls_1_3_record_proto_corrupt_pkt(void)
12874 : : {
12875 : 0 : struct tls_record_test_flags flags = {
12876 : : .pkt_corruption = 1,
12877 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12878 : : };
12879 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12880 : : struct rte_cryptodev_info dev_info;
12881 : :
12882 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12883 : :
12884 : 0 : return test_tls_record_proto_all(&flags);
12885 : : }
12886 : :
12887 : : static int
12888 : 0 : test_tls_1_3_record_proto_custom_content_type(void)
12889 : : {
12890 : 0 : struct tls_record_test_flags flags = {
12891 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12892 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12893 : : };
12894 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12895 : : struct rte_cryptodev_info dev_info;
12896 : :
12897 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12898 : :
12899 : 0 : return test_tls_record_proto_all(&flags);
12900 : : }
12901 : :
12902 : : static int
12903 : 0 : test_tls_1_3_record_proto_zero_len(void)
12904 : : {
12905 : 0 : struct tls_record_test_flags flags = {
12906 : : .zero_len = 1,
12907 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12908 : : };
12909 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12910 : : struct rte_cryptodev_info dev_info;
12911 : :
12912 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12913 : :
12914 : 0 : return test_tls_record_proto_all(&flags);
12915 : : }
12916 : :
12917 : : static int
12918 : 0 : test_tls_1_3_record_proto_zero_len_non_app(void)
12919 : : {
12920 : 0 : struct tls_record_test_flags flags = {
12921 : : .zero_len = 1,
12922 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12923 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12924 : : };
12925 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12926 : : struct rte_cryptodev_info dev_info;
12927 : :
12928 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12929 : :
12930 : 0 : return test_tls_record_proto_all(&flags);
12931 : : }
12932 : :
12933 : : static int
12934 : 0 : test_tls_1_3_record_proto_dm_opt_padding(void)
12935 : : {
12936 : 0 : return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12937 : : }
12938 : :
12939 : : static int
12940 : 0 : test_tls_1_3_record_proto_sg_opt_padding(void)
12941 : : {
12942 : 0 : return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12943 : : }
12944 : :
12945 : : static int
12946 : 0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
12947 : : {
12948 : 0 : return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12949 : : }
12950 : :
12951 : : static int
12952 : 0 : test_tls_1_3_record_proto_data_walkthrough(void)
12953 : : {
12954 : : struct tls_record_test_flags flags;
12955 : :
12956 : : memset(&flags, 0, sizeof(flags));
12957 : :
12958 : 0 : flags.data_walkthrough = true;
12959 : 0 : flags.skip_sess_destroy = true;
12960 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12961 : :
12962 : 0 : return test_tls_record_proto_all(&flags);
12963 : : }
12964 : :
12965 : : static int
12966 : 0 : test_tls_1_3_record_proto_sgl(void)
12967 : : {
12968 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
12969 : : }
12970 : :
12971 : : static int
12972 : 0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
12973 : : {
12974 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
12975 : : }
12976 : :
12977 : : static int
12978 : 0 : test_tls_1_3_record_proto_sgl_oop(void)
12979 : : {
12980 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
12981 : : }
12982 : :
12983 : : #endif
12984 : :
12985 : : static int
12986 : 1 : test_cryptodev_error_recover_helper_check(void)
12987 : : {
12988 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12989 : : struct rte_cryptodev_info dev_info;
12990 : : uint64_t feat_flags;
12991 : : int ret;
12992 : :
12993 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12994 : 1 : feat_flags = dev_info.feature_flags;
12995 : :
12996 : : /* Skip the test if queue pair reset is not supported */
12997 : 1 : ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
12998 [ - + ]: 1 : if (ret == -ENOTSUP)
12999 : : return TEST_SKIPPED;
13000 : :
13001 [ # # ]: 0 : ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
13002 [ # # ]: 0 : if (ret == -ENOTSUP)
13003 : 0 : return TEST_SKIPPED;
13004 : :
13005 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
13006 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13007 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13008 : 0 : RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
13009 : 0 : return TEST_SKIPPED;
13010 : : }
13011 : :
13012 : : return 0;
13013 : : }
13014 : :
13015 : : static int
13016 : 0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
13017 : : {
13018 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13019 : : struct crypto_unittest_params *ut_params = &unittest_params;
13020 : : const struct blockcipher_test_data *tdata = test_data;
13021 : 0 : uint8_t *cipher_key = alloca(tdata->cipher_key.len);
13022 : : struct rte_crypto_sym_op *sym_op = NULL;
13023 : : struct rte_crypto_op *op = NULL;
13024 : : char *dst;
13025 : :
13026 : 0 : memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
13027 : 0 : ut_params->cipher_xform.next = NULL;
13028 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13029 : 0 : ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
13030 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13031 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
13032 : 0 : ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
13033 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13034 : 0 : ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
13035 : :
13036 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
13037 : : ts_params->session_mpool);
13038 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13039 : : return TEST_SKIPPED;
13040 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13041 : :
13042 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13043 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
13044 : :
13045 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
13046 [ # # ]: 0 : tdata->iv.len);
13047 : : sym_op = ut_params->op->sym;
13048 : 0 : sym_op->cipher.data.offset = tdata->cipher_offset;
13049 : 0 : sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
13050 : :
13051 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13052 : :
13053 [ # # ]: 0 : if (generate_err) {
13054 : 0 : ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
13055 [ # # ]: 0 : if (ut_params->ibuf == NULL)
13056 : : return TEST_FAILED;
13057 : 0 : crypto_err = CRYPTODEV_ERR_TRIGGERED;
13058 : : } else {
13059 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13060 : : }
13061 : :
13062 : : /* clear mbuf payload */
13063 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13064 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
13065 : :
13066 : 0 : dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
13067 : 0 : memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
13068 : :
13069 : 0 : sym_op->m_src = ut_params->ibuf;
13070 : 0 : sym_op->m_dst = NULL;
13071 : :
13072 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
13073 : :
13074 [ # # ]: 0 : if (generate_err) {
13075 : 0 : free(ut_params->ibuf);
13076 : 0 : ut_params->ibuf = NULL;
13077 [ # # ]: 0 : if (op == NULL) {
13078 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13079 : 0 : ut_params->sess = NULL;
13080 : 0 : return TEST_SUCCESS;
13081 : : } else {
13082 : : return TEST_FAILED;
13083 : : }
13084 : : }
13085 : :
13086 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13087 : : "crypto op processing failed");
13088 : :
13089 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
13090 : : tdata->ciphertext.len - tdata->cipher_offset,
13091 : : "Data not as expected");
13092 : :
13093 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13094 : 0 : ut_params->sess = NULL;
13095 : :
13096 : 0 : return TEST_SUCCESS;
13097 : : }
13098 : :
13099 : : /*
13100 : : * This unit test verifies the recovery of the cryptodev from any fatal error.
13101 : : * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
13102 : : * for every call to helper function.
13103 : : *
13104 : : * When the flag is set to 0, the helper function verifies the test data without generating any
13105 : : * errors, i.e: verifies the default behaviour of the cryptodev.
13106 : : *
13107 : : * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
13108 : : * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
13109 : : * is generated, it waits till the cryptodev is recoverd from the error.
13110 : : *
13111 : : * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
13112 : : * of cryptodev after the recovery.
13113 : : */
13114 : : static int
13115 : 1 : test_cryptodev_verify_error_recover(const void *test_data)
13116 : : {
13117 : : int ret = TEST_FAILED;
13118 : : int i, num_itr = 5;
13119 : :
13120 : 1 : ret = test_cryptodev_error_recover_helper_check();
13121 [ - + ]: 1 : if (ret)
13122 : : return ret;
13123 : :
13124 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
13125 : : RTE_CRYPTODEV_EVENT_ERROR,
13126 : : test_cryptodev_error_cb, NULL),
13127 : : "Failed to register Cryptodev callback");
13128 : :
13129 [ # # ]: 0 : for (i = 0; i < num_itr; i++) {
13130 : : int ticks = 0;
13131 : :
13132 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13133 : : test_data, false);
13134 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13135 : :
13136 : : /* Generate Error */
13137 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13138 : : test_data, true);
13139 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13140 : :
13141 : : /* Wait till cryptodev recovered from error */
13142 [ # # ]: 0 : while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
13143 : : rte_delay_ms(10);
13144 [ # # ]: 0 : if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
13145 : : return TEST_FAILED;
13146 : : }
13147 : : }
13148 [ # # ]: 0 : TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
13149 : :
13150 : : return ret;
13151 : : }
13152 : :
13153 : : static int
13154 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
13155 : : {
13156 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
13157 : : }
13158 : :
13159 : : static int
13160 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
13161 : : {
13162 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
13163 : : }
13164 : :
13165 : : static int
13166 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
13167 : : {
13168 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
13169 : : }
13170 : :
13171 : : static int
13172 : 1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
13173 : : {
13174 : 1 : return test_authenticated_encryption_helper(&gcm_test_case_3, true);
13175 : : }
13176 : :
13177 : : static int
13178 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
13179 : : {
13180 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
13181 : : }
13182 : :
13183 : : static int
13184 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
13185 : : {
13186 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
13187 : : }
13188 : :
13189 : : static int
13190 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
13191 : : {
13192 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
13193 : : }
13194 : :
13195 : : static int
13196 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
13197 : : {
13198 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
13199 : : }
13200 : :
13201 : : static int
13202 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
13203 : : {
13204 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
13205 : : }
13206 : :
13207 : : static int
13208 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
13209 : : {
13210 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
13211 : : }
13212 : :
13213 : : static int
13214 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
13215 : : {
13216 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
13217 : : }
13218 : :
13219 : : static int
13220 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
13221 : : {
13222 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
13223 : : }
13224 : :
13225 : : static int
13226 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
13227 : : {
13228 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
13229 : : }
13230 : :
13231 : : static int
13232 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
13233 : : {
13234 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
13235 : : }
13236 : :
13237 : : static int
13238 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
13239 : : {
13240 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
13241 : : }
13242 : :
13243 : : static int
13244 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
13245 : : {
13246 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
13247 : : }
13248 : :
13249 : : static int
13250 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
13251 : : {
13252 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
13253 : : }
13254 : :
13255 : : static int
13256 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
13257 : : {
13258 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
13259 : : }
13260 : :
13261 : : static int
13262 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
13263 : : {
13264 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
13265 : : }
13266 : :
13267 : : static int
13268 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
13269 : : {
13270 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
13271 : : }
13272 : :
13273 : : static int
13274 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
13275 : : {
13276 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
13277 : : }
13278 : :
13279 : : static int
13280 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
13281 : : {
13282 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
13283 : : }
13284 : :
13285 : : static int
13286 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
13287 : : {
13288 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
13289 : : }
13290 : :
13291 : : static int
13292 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
13293 : : {
13294 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
13295 : : }
13296 : :
13297 : : static int
13298 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
13299 : : {
13300 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
13301 : : }
13302 : :
13303 : : static int
13304 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
13305 : : {
13306 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
13307 : : }
13308 : :
13309 : : static int
13310 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13311 : : {
13312 : : struct aead_test_data tdata;
13313 : : int res;
13314 : :
13315 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13316 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13317 : 1 : tdata.iv.data[0] += 1;
13318 : : res = test_authenticated_encryption(&tdata);
13319 [ + - ]: 1 : if (res == TEST_SKIPPED)
13320 : : return res;
13321 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13322 : : return TEST_SUCCESS;
13323 : : }
13324 : :
13325 : : static int
13326 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13327 : : {
13328 : : struct aead_test_data tdata;
13329 : : int res;
13330 : :
13331 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13332 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13333 : 1 : tdata.plaintext.data[0] += 1;
13334 : : res = test_authenticated_encryption(&tdata);
13335 [ + - ]: 1 : if (res == TEST_SKIPPED)
13336 : : return res;
13337 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13338 : : return TEST_SUCCESS;
13339 : : }
13340 : :
13341 : : static int
13342 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13343 : : {
13344 : : struct aead_test_data tdata;
13345 : : int res;
13346 : :
13347 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13348 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13349 : 1 : tdata.ciphertext.data[0] += 1;
13350 : : res = test_authenticated_encryption(&tdata);
13351 [ + - ]: 1 : if (res == TEST_SKIPPED)
13352 : : return res;
13353 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13354 : : return TEST_SUCCESS;
13355 : : }
13356 : :
13357 : : static int
13358 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13359 : : {
13360 : : struct aead_test_data tdata;
13361 : : int res;
13362 : :
13363 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13364 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13365 : 1 : tdata.aad.len += 1;
13366 : : res = test_authenticated_encryption(&tdata);
13367 [ + - ]: 1 : if (res == TEST_SKIPPED)
13368 : : return res;
13369 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13370 : : return TEST_SUCCESS;
13371 : : }
13372 : :
13373 : : static int
13374 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13375 : : {
13376 : : struct aead_test_data tdata;
13377 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13378 : : int res;
13379 : :
13380 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13381 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13382 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13383 : 1 : aad[0] += 1;
13384 : 1 : tdata.aad.data = aad;
13385 : : res = test_authenticated_encryption(&tdata);
13386 [ + - ]: 1 : if (res == TEST_SKIPPED)
13387 : : return res;
13388 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13389 : : return TEST_SUCCESS;
13390 : : }
13391 : :
13392 : : static int
13393 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13394 : : {
13395 : : struct aead_test_data tdata;
13396 : : int res;
13397 : :
13398 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13399 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13400 : 1 : tdata.auth_tag.data[0] += 1;
13401 : : res = test_authenticated_encryption(&tdata);
13402 [ + - ]: 1 : if (res == TEST_SKIPPED)
13403 : : return res;
13404 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13405 : : return TEST_SUCCESS;
13406 : : }
13407 : :
13408 : : static int
13409 : 42 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13410 : : {
13411 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13412 : : struct crypto_unittest_params *ut_params = &unittest_params;
13413 : :
13414 : : int retval;
13415 : : uint8_t *plaintext;
13416 : : uint32_t i;
13417 : : struct rte_cryptodev_info dev_info;
13418 : :
13419 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13420 : 42 : uint64_t feat_flags = dev_info.feature_flags;
13421 : :
13422 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13423 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13424 : : printf("Device doesn't support RAW data-path APIs.\n");
13425 : 0 : return TEST_SKIPPED;
13426 : : }
13427 : :
13428 : : /* Verify the capabilities */
13429 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13430 : : const struct rte_cryptodev_symmetric_capability *capability;
13431 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13432 : 42 : cap_idx.algo.aead = tdata->algo;
13433 : 42 : capability = rte_cryptodev_sym_capability_get(
13434 : 42 : ts_params->valid_devs[0], &cap_idx);
13435 [ + - ]: 42 : if (capability == NULL)
13436 : : return TEST_SKIPPED;
13437 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
13438 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
13439 : 42 : tdata->aad.len, tdata->iv.len))
13440 : : return TEST_SKIPPED;
13441 : :
13442 : : /* Create AEAD session */
13443 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
13444 : 41 : tdata->algo,
13445 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13446 : 41 : tdata->key.data, tdata->key.len,
13447 : 41 : tdata->aad.len, tdata->auth_tag.len,
13448 : 41 : tdata->iv.len);
13449 [ + - ]: 41 : if (retval != TEST_SUCCESS)
13450 : : return retval;
13451 : :
13452 : : /* alloc mbuf and set payload */
13453 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
13454 [ - + ]: 2 : if (use_ext_mbuf) {
13455 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13456 : : AEAD_TEXT_MAX_LENGTH,
13457 : : 1 /* nb_segs */,
13458 : : NULL);
13459 : : } else {
13460 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13461 : : }
13462 : : /* Populate full size of add data */
13463 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13464 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13465 : : } else {
13466 [ + + ]: 39 : if (use_ext_mbuf) {
13467 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13468 : : AEAD_TEXT_MAX_LENGTH,
13469 : : 1 /* nb_segs */,
13470 : : NULL);
13471 : : } else {
13472 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13473 : : }
13474 : : }
13475 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13476 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
13477 : :
13478 : : /* Create AEAD operation */
13479 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13480 [ + - ]: 41 : if (retval < 0)
13481 : : return retval;
13482 : :
13483 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13484 : :
13485 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
13486 : :
13487 : : /* Process crypto operation */
13488 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13489 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13490 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13491 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13492 : : 0);
13493 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13494 : : return retval;
13495 : : } else
13496 [ + + ]: 41 : TEST_ASSERT_NOT_NULL(
13497 : : process_crypto_request(ts_params->valid_devs[0],
13498 : : ut_params->op), "failed to process sym crypto op");
13499 : :
13500 [ - + ]: 36 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13501 : : "crypto op processing failed");
13502 : :
13503 [ - + ]: 36 : if (ut_params->op->sym->m_dst)
13504 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13505 : : uint8_t *);
13506 : : else
13507 : 36 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13508 : : uint8_t *,
13509 : : ut_params->op->sym->cipher.data.offset);
13510 : :
13511 : 36 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13512 : :
13513 : : /* Validate obuf */
13514 [ + + ]: 37 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13515 : : plaintext,
13516 : : tdata->plaintext.data,
13517 : : tdata->plaintext.len,
13518 : : "Plaintext data not as expected");
13519 : :
13520 [ - + ]: 35 : TEST_ASSERT_EQUAL(ut_params->op->status,
13521 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13522 : : "Authentication failed");
13523 : :
13524 : : return 0;
13525 : : }
13526 : :
13527 : : static int
13528 : : test_authenticated_decryption(const struct aead_test_data *tdata)
13529 : : {
13530 : 41 : return test_authenticated_decryption_helper(tdata, false);
13531 : : }
13532 : :
13533 : : static int
13534 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
13535 : : {
13536 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
13537 : : }
13538 : :
13539 : : static int
13540 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
13541 : : {
13542 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
13543 : : }
13544 : :
13545 : : static int
13546 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
13547 : : {
13548 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
13549 : : }
13550 : :
13551 : : static int
13552 : 1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13553 : : {
13554 : 1 : return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13555 : : }
13556 : :
13557 : : static int
13558 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
13559 : : {
13560 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
13561 : : }
13562 : :
13563 : : static int
13564 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
13565 : : {
13566 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
13567 : : }
13568 : :
13569 : : static int
13570 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
13571 : : {
13572 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
13573 : : }
13574 : :
13575 : : static int
13576 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
13577 : : {
13578 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
13579 : : }
13580 : :
13581 : : static int
13582 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
13583 : : {
13584 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
13585 : : }
13586 : :
13587 : : static int
13588 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13589 : : {
13590 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
13591 : : }
13592 : :
13593 : : static int
13594 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
13595 : : {
13596 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
13597 : : }
13598 : :
13599 : : static int
13600 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
13601 : : {
13602 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
13603 : : }
13604 : :
13605 : : static int
13606 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
13607 : : {
13608 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
13609 : : }
13610 : :
13611 : : static int
13612 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
13613 : : {
13614 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
13615 : : }
13616 : :
13617 : : static int
13618 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
13619 : : {
13620 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
13621 : : }
13622 : :
13623 : : static int
13624 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
13625 : : {
13626 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
13627 : : }
13628 : :
13629 : : static int
13630 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
13631 : : {
13632 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
13633 : : }
13634 : :
13635 : : static int
13636 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
13637 : : {
13638 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
13639 : : }
13640 : :
13641 : : static int
13642 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
13643 : : {
13644 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
13645 : : }
13646 : :
13647 : : static int
13648 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
13649 : : {
13650 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
13651 : : }
13652 : :
13653 : : static int
13654 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
13655 : : {
13656 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
13657 : : }
13658 : :
13659 : : static int
13660 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
13661 : : {
13662 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
13663 : : }
13664 : :
13665 : : static int
13666 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
13667 : : {
13668 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
13669 : : }
13670 : :
13671 : : static int
13672 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
13673 : : {
13674 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
13675 : : }
13676 : :
13677 : : static int
13678 : 1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
13679 : : {
13680 : 1 : return test_authenticated_decryption(&gcm_test_case_256_8);
13681 : : }
13682 : :
13683 : : static int
13684 : 1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
13685 : : {
13686 : 1 : return test_authenticated_encryption(&gcm_test_case_256_8);
13687 : : }
13688 : :
13689 : : static int
13690 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
13691 : : {
13692 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
13693 : : }
13694 : :
13695 : : static int
13696 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
13697 : : {
13698 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
13699 : : }
13700 : :
13701 : : static int
13702 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13703 : : {
13704 : : struct aead_test_data tdata;
13705 : : int res;
13706 : :
13707 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13708 : 1 : tdata.iv.data[0] += 1;
13709 : : res = test_authenticated_decryption(&tdata);
13710 [ + - ]: 1 : if (res == TEST_SKIPPED)
13711 : : return res;
13712 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13713 : : return TEST_SUCCESS;
13714 : : }
13715 : :
13716 : : static int
13717 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13718 : : {
13719 : : struct aead_test_data tdata;
13720 : : int res;
13721 : :
13722 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13723 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13724 : 1 : tdata.plaintext.data[0] += 1;
13725 : : res = test_authenticated_decryption(&tdata);
13726 [ + - ]: 1 : if (res == TEST_SKIPPED)
13727 : : return res;
13728 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13729 : : return TEST_SUCCESS;
13730 : : }
13731 : :
13732 : : static int
13733 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13734 : : {
13735 : : struct aead_test_data tdata;
13736 : : int res;
13737 : :
13738 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13739 : 1 : tdata.ciphertext.data[0] += 1;
13740 : : res = test_authenticated_decryption(&tdata);
13741 [ + - ]: 1 : if (res == TEST_SKIPPED)
13742 : : return res;
13743 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13744 : : return TEST_SUCCESS;
13745 : : }
13746 : :
13747 : : static int
13748 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13749 : : {
13750 : : struct aead_test_data tdata;
13751 : : int res;
13752 : :
13753 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13754 : 1 : tdata.aad.len += 1;
13755 : : res = test_authenticated_decryption(&tdata);
13756 [ + - ]: 1 : if (res == TEST_SKIPPED)
13757 : : return res;
13758 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13759 : : return TEST_SUCCESS;
13760 : : }
13761 : :
13762 : : static int
13763 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13764 : : {
13765 : : struct aead_test_data tdata;
13766 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13767 : : int res;
13768 : :
13769 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13770 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13771 : 1 : aad[0] += 1;
13772 : 1 : tdata.aad.data = aad;
13773 : : res = test_authenticated_decryption(&tdata);
13774 [ + - ]: 1 : if (res == TEST_SKIPPED)
13775 : : return res;
13776 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13777 : : return TEST_SUCCESS;
13778 : : }
13779 : :
13780 : : static int
13781 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13782 : : {
13783 : : struct aead_test_data tdata;
13784 : : int res;
13785 : :
13786 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13787 : 1 : tdata.auth_tag.data[0] += 1;
13788 : : res = test_authenticated_decryption(&tdata);
13789 [ + - ]: 1 : if (res == TEST_SKIPPED)
13790 : : return res;
13791 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13792 : : return TEST_SUCCESS;
13793 : : }
13794 : :
13795 : : static int
13796 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13797 : : {
13798 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13799 : : struct crypto_unittest_params *ut_params = &unittest_params;
13800 : :
13801 : : uint32_t i;
13802 : : int retval;
13803 : : uint8_t *ciphertext, *auth_tag, *buffer_oop;
13804 : : uint16_t plaintext_pad_len;
13805 : : struct rte_cryptodev_info dev_info;
13806 : :
13807 : : /* Verify the capabilities */
13808 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13809 : : const struct rte_cryptodev_symmetric_capability *capability;
13810 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13811 : 1 : cap_idx.algo.aead = tdata->algo;
13812 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13813 [ + - ]: 1 : if (capability == NULL)
13814 : : return TEST_SKIPPED;
13815 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(
13816 : 1 : capability, tdata->key.len, tdata->auth_tag.len,
13817 : 1 : tdata->aad.len, tdata->iv.len))
13818 : : return TEST_SKIPPED;
13819 : :
13820 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13821 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13822 : :
13823 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13824 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13825 : : return TEST_SKIPPED;
13826 : :
13827 : : /* not supported with CPU crypto */
13828 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13829 : : return TEST_SKIPPED;
13830 : :
13831 : : /* Create AEAD session */
13832 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13833 : 1 : tdata->algo,
13834 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13835 : 1 : tdata->key.data, tdata->key.len,
13836 : 1 : tdata->aad.len, tdata->auth_tag.len,
13837 : 1 : tdata->iv.len);
13838 [ + - ]: 1 : if (retval < 0)
13839 : : return retval;
13840 : :
13841 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13842 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13843 : :
13844 : : /* clear mbuf payload */
13845 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13846 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13847 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13848 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13849 : :
13850 : : /* Create AEAD operation */
13851 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13852 [ + - ]: 1 : if (retval < 0)
13853 : : return retval;
13854 : :
13855 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13856 : :
13857 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13858 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13859 : :
13860 : : /* Process crypto operation */
13861 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13862 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13863 : : 0);
13864 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13865 : : return retval;
13866 : : } else
13867 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13868 : : ut_params->op), "failed to process sym crypto op");
13869 : :
13870 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13871 : : "crypto op processing failed");
13872 : :
13873 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13874 : :
13875 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13876 : : ut_params->op->sym->cipher.data.offset);
13877 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13878 : :
13879 : : /* Check if the data within the offset range is not overwritten in the OOP */
13880 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
13881 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
13882 [ - + ]: 16 : if (buffer_oop[i]) {
13883 : 0 : RTE_LOG(ERR, USER1,
13884 : : "Incorrect value of the output buffer header\n");
13885 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
13886 : 0 : ut_params->op->sym->cipher.data.offset);
13887 : 0 : return TEST_FAILED;
13888 : : }
13889 : : }
13890 : :
13891 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13892 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13893 : :
13894 : : /* Validate obuf */
13895 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13896 : : ciphertext,
13897 : : tdata->ciphertext.data,
13898 : : tdata->ciphertext.len,
13899 : : "Ciphertext data not as expected");
13900 : :
13901 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13902 : : auth_tag,
13903 : : tdata->auth_tag.data,
13904 : : tdata->auth_tag.len,
13905 : : "Generated auth tag not as expected");
13906 : :
13907 : : return 0;
13908 : :
13909 : : }
13910 : :
13911 : : static int
13912 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13913 : : {
13914 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
13915 : : }
13916 : :
13917 : : static int
13918 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13919 : : {
13920 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13921 : : struct crypto_unittest_params *ut_params = &unittest_params;
13922 : :
13923 : : uint32_t i;
13924 : : int retval;
13925 : : uint8_t *plaintext, *buffer_oop;
13926 : : struct rte_cryptodev_info dev_info;
13927 : :
13928 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13929 : : uint64_t feat_flags = dev_info.feature_flags;
13930 : :
13931 : : /* Verify the capabilities */
13932 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13933 : : const struct rte_cryptodev_symmetric_capability *capability;
13934 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13935 : 1 : cap_idx.algo.aead = tdata->algo;
13936 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13937 : :
13938 [ + - ]: 1 : if (capability == NULL)
13939 : : return TEST_SKIPPED;
13940 : :
13941 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13942 : 1 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13943 : : return TEST_SKIPPED;
13944 : :
13945 : : /* not supported with CPU crypto and raw data-path APIs*/
13946 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13947 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
13948 : : return TEST_SKIPPED;
13949 : :
13950 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13951 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13952 : : printf("Device does not support RAW data-path APIs.\n");
13953 : : return TEST_SKIPPED;
13954 : : }
13955 : :
13956 : : /* Create AEAD session */
13957 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13958 : 1 : tdata->algo,
13959 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13960 : 1 : tdata->key.data, tdata->key.len,
13961 : 1 : tdata->aad.len, tdata->auth_tag.len,
13962 : 1 : tdata->iv.len);
13963 [ + - ]: 1 : if (retval < 0)
13964 : : return retval;
13965 : :
13966 : : /* alloc mbuf and set payload */
13967 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13968 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13969 : :
13970 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13971 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13972 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13973 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13974 : :
13975 : : /* Create AEAD operation */
13976 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13977 [ + - ]: 1 : if (retval < 0)
13978 : : return retval;
13979 : :
13980 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13981 : :
13982 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13983 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13984 : :
13985 : : /* Process crypto operation */
13986 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13987 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13988 : : 0);
13989 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13990 : : return retval;
13991 : : } else
13992 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13993 : : ut_params->op), "failed to process sym crypto op");
13994 : :
13995 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13996 : : "crypto op processing failed");
13997 : :
13998 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13999 : : ut_params->op->sym->cipher.data.offset);
14000 : :
14001 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14002 : :
14003 : : /* Check if the data within the offset range is not overwritten in the OOP */
14004 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
14005 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
14006 [ - + ]: 16 : if (buffer_oop[i]) {
14007 : 0 : RTE_LOG(ERR, USER1,
14008 : : "Incorrect value of the output buffer header\n");
14009 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
14010 : 0 : ut_params->op->sym->cipher.data.offset);
14011 : 0 : return TEST_FAILED;
14012 : : }
14013 : : }
14014 : : /* Validate obuf */
14015 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14016 : : plaintext,
14017 : : tdata->plaintext.data,
14018 : : tdata->plaintext.len,
14019 : : "Plaintext data not as expected");
14020 : :
14021 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14022 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14023 : : "Authentication failed");
14024 : : return 0;
14025 : : }
14026 : :
14027 : : static int
14028 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
14029 : : {
14030 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
14031 : : }
14032 : :
14033 : : static int
14034 : 1 : test_authenticated_encryption_sessionless(
14035 : : const struct aead_test_data *tdata)
14036 : : {
14037 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14038 : : struct crypto_unittest_params *ut_params = &unittest_params;
14039 : :
14040 : : int retval;
14041 : : uint8_t *ciphertext, *auth_tag;
14042 : : uint16_t plaintext_pad_len;
14043 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14044 : : struct rte_cryptodev_info dev_info;
14045 : :
14046 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14047 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14048 : :
14049 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14050 : : printf("Device doesn't support Sessionless ops.\n");
14051 : 0 : return TEST_SKIPPED;
14052 : : }
14053 : :
14054 : : /* not supported with CPU crypto */
14055 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14056 : : return TEST_SKIPPED;
14057 : :
14058 : : /* Verify the capabilities */
14059 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14060 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14061 : 1 : cap_idx.algo.aead = tdata->algo;
14062 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14063 : : &cap_idx) == NULL)
14064 : : return TEST_SKIPPED;
14065 : :
14066 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14067 : :
14068 : : /* clear mbuf payload */
14069 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14070 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14071 : :
14072 : : /* Create AEAD operation */
14073 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
14074 [ + - ]: 1 : if (retval < 0)
14075 : : return retval;
14076 : :
14077 : : /* Create GCM xform */
14078 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14079 : 1 : retval = create_aead_xform(ut_params->op,
14080 : 1 : tdata->algo,
14081 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
14082 : : key, tdata->key.len,
14083 : 1 : tdata->aad.len, tdata->auth_tag.len,
14084 : 1 : tdata->iv.len);
14085 [ + - ]: 1 : if (retval < 0)
14086 : : return retval;
14087 : :
14088 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14089 : :
14090 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14091 : : RTE_CRYPTO_OP_SESSIONLESS,
14092 : : "crypto op session type not sessionless");
14093 : :
14094 : : /* Process crypto operation */
14095 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14096 : : ut_params->op), "failed to process sym crypto op");
14097 : :
14098 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14099 : :
14100 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14101 : : "crypto op status not success");
14102 : :
14103 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14104 : :
14105 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14106 : : ut_params->op->sym->cipher.data.offset);
14107 : 1 : auth_tag = ciphertext + plaintext_pad_len;
14108 : :
14109 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
14110 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
14111 : :
14112 : : /* Validate obuf */
14113 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14114 : : ciphertext,
14115 : : tdata->ciphertext.data,
14116 : : tdata->ciphertext.len,
14117 : : "Ciphertext data not as expected");
14118 : :
14119 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14120 : : auth_tag,
14121 : : tdata->auth_tag.data,
14122 : : tdata->auth_tag.len,
14123 : : "Generated auth tag not as expected");
14124 : :
14125 : : return 0;
14126 : :
14127 : : }
14128 : :
14129 : : static int
14130 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
14131 : : {
14132 : 1 : return test_authenticated_encryption_sessionless(
14133 : : &gcm_test_case_5);
14134 : : }
14135 : :
14136 : : static int
14137 : 1 : test_authenticated_decryption_sessionless(
14138 : : const struct aead_test_data *tdata)
14139 : : {
14140 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14141 : : struct crypto_unittest_params *ut_params = &unittest_params;
14142 : :
14143 : : int retval;
14144 : : uint8_t *plaintext;
14145 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14146 : : struct rte_cryptodev_info dev_info;
14147 : :
14148 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14149 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14150 : :
14151 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14152 : : printf("Device doesn't support Sessionless ops.\n");
14153 : 0 : return TEST_SKIPPED;
14154 : : }
14155 : :
14156 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14157 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14158 : : printf("Device doesn't support RAW data-path APIs.\n");
14159 : 0 : return TEST_SKIPPED;
14160 : : }
14161 : :
14162 : : /* not supported with CPU crypto */
14163 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14164 : : return TEST_SKIPPED;
14165 : :
14166 : : /* Verify the capabilities */
14167 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14168 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14169 : 1 : cap_idx.algo.aead = tdata->algo;
14170 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14171 : : &cap_idx) == NULL)
14172 : : return TEST_SKIPPED;
14173 : :
14174 : : /* alloc mbuf and set payload */
14175 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14176 : :
14177 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14178 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14179 : :
14180 : : /* Create AEAD operation */
14181 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14182 [ + - ]: 1 : if (retval < 0)
14183 : : return retval;
14184 : :
14185 : : /* Create AEAD xform */
14186 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14187 : 1 : retval = create_aead_xform(ut_params->op,
14188 : 1 : tdata->algo,
14189 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
14190 : : key, tdata->key.len,
14191 : 1 : tdata->aad.len, tdata->auth_tag.len,
14192 : 1 : tdata->iv.len);
14193 [ + - ]: 1 : if (retval < 0)
14194 : : return retval;
14195 : :
14196 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14197 : :
14198 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14199 : : RTE_CRYPTO_OP_SESSIONLESS,
14200 : : "crypto op session type not sessionless");
14201 : :
14202 : : /* Process crypto operation */
14203 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14204 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14205 : : 0);
14206 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14207 : : return retval;
14208 : : } else
14209 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
14210 : : ts_params->valid_devs[0], ut_params->op),
14211 : : "failed to process sym crypto op");
14212 : :
14213 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14214 : :
14215 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14216 : : "crypto op status not success");
14217 : :
14218 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14219 : : ut_params->op->sym->cipher.data.offset);
14220 : :
14221 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14222 : :
14223 : : /* Validate obuf */
14224 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14225 : : plaintext,
14226 : : tdata->plaintext.data,
14227 : : tdata->plaintext.len,
14228 : : "Plaintext data not as expected");
14229 : :
14230 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14231 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14232 : : "Authentication failed");
14233 : : return 0;
14234 : : }
14235 : :
14236 : : static int
14237 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
14238 : : {
14239 : 1 : return test_authenticated_decryption_sessionless(
14240 : : &gcm_test_case_5);
14241 : : }
14242 : :
14243 : : static int
14244 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
14245 : : {
14246 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
14247 : : }
14248 : :
14249 : : static int
14250 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
14251 : : {
14252 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
14253 : : }
14254 : :
14255 : : static int
14256 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
14257 : : {
14258 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
14259 : : }
14260 : :
14261 : : static int
14262 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
14263 : : {
14264 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
14265 : : }
14266 : :
14267 : : static int
14268 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
14269 : : {
14270 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
14271 : : }
14272 : :
14273 : : static int
14274 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
14275 : : {
14276 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
14277 : : }
14278 : :
14279 : : static int
14280 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
14281 : : {
14282 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
14283 : : }
14284 : :
14285 : : static int
14286 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
14287 : : {
14288 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
14289 : : }
14290 : :
14291 : : static int
14292 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
14293 : : {
14294 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
14295 : : }
14296 : :
14297 : : static int
14298 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
14299 : : {
14300 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
14301 : : }
14302 : :
14303 : : static int
14304 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
14305 : : {
14306 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
14307 : : }
14308 : :
14309 : : static int
14310 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14311 : : {
14312 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
14313 : : }
14314 : :
14315 : : static int
14316 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14317 : : {
14318 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
14319 : : }
14320 : :
14321 : : static int
14322 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14323 : : {
14324 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
14325 : : }
14326 : :
14327 : : static int
14328 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14329 : : {
14330 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
14331 : : }
14332 : :
14333 : : static int
14334 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14335 : : {
14336 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
14337 : : }
14338 : :
14339 : : static int
14340 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14341 : : {
14342 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
14343 : : }
14344 : :
14345 : : static int
14346 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14347 : : {
14348 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
14349 : : }
14350 : :
14351 : : static int
14352 : 1 : test_stats(void)
14353 : : {
14354 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14355 : : struct rte_cryptodev_stats stats;
14356 : :
14357 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14358 : : return TEST_SKIPPED;
14359 : :
14360 : : /* Verify the capabilities */
14361 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14362 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14363 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14364 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14365 : : &cap_idx) == NULL)
14366 : : return TEST_SKIPPED;
14367 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14368 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14369 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14370 : : &cap_idx) == NULL)
14371 : : return TEST_SKIPPED;
14372 : :
14373 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14374 : : == -ENOTSUP)
14375 : : return TEST_SKIPPED;
14376 : :
14377 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14378 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14379 : : &stats) == -ENODEV),
14380 : : "rte_cryptodev_stats_get invalid dev failed");
14381 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14382 : : "rte_cryptodev_stats_get invalid Param failed");
14383 : :
14384 : : /* Test expected values */
14385 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
14386 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14387 : : &stats),
14388 : : "rte_cryptodev_stats_get failed");
14389 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14390 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
14391 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
14392 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
14393 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
14394 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14395 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
14396 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14397 : :
14398 : : /* invalid device but should ignore and not reset device stats*/
14399 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14400 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14401 : : &stats),
14402 : : "rte_cryptodev_stats_get failed");
14403 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14404 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14405 : :
14406 : : /* check that a valid reset clears stats */
14407 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14408 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14409 : : &stats),
14410 : : "rte_cryptodev_stats_get failed");
14411 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
14412 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14413 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
14414 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14415 : :
14416 : : return TEST_SUCCESS;
14417 : : }
14418 : :
14419 : : static int
14420 : 1 : test_device_reconfigure(void)
14421 : : {
14422 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14423 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14424 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14425 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14426 : 1 : .mp_session = ts_params->session_mpool
14427 : : };
14428 : : uint16_t qp_id, dev_id, num_devs = 0;
14429 : :
14430 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14431 : : "Need at least %d devices for test", 1);
14432 : :
14433 : 1 : dev_id = ts_params->valid_devs[0];
14434 : :
14435 : : /* Stop the device in case it's started so it can be configured */
14436 : 1 : rte_cryptodev_stop(dev_id);
14437 : :
14438 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14439 : : "Failed test for rte_cryptodev_configure: "
14440 : : "dev_num %u", dev_id);
14441 : :
14442 : : /* Reconfigure with same configure params */
14443 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14444 : : "Failed test for rte_cryptodev_configure: "
14445 : : "dev_num %u", dev_id);
14446 : :
14447 : : /* Reconfigure with just one queue pair */
14448 : 1 : ts_params->conf.nb_queue_pairs = 1;
14449 : :
14450 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14451 : : &ts_params->conf),
14452 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14453 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14454 : :
14455 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14456 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14457 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14458 : : rte_cryptodev_socket_id(
14459 : : ts_params->valid_devs[0])),
14460 : : "Failed test for "
14461 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14462 : : "%u on qp %u on cryptodev %u",
14463 : : qp_conf.nb_descriptors, qp_id,
14464 : : ts_params->valid_devs[0]);
14465 : : }
14466 : :
14467 : : /* Reconfigure with max number of queue pairs */
14468 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
14469 : :
14470 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14471 : : &ts_params->conf),
14472 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14473 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14474 : :
14475 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14476 : :
14477 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14478 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14479 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14480 : : rte_cryptodev_socket_id(
14481 : : ts_params->valid_devs[0])),
14482 : : "Failed test for "
14483 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14484 : : "%u on qp %u on cryptodev %u",
14485 : : qp_conf.nb_descriptors, qp_id,
14486 : : ts_params->valid_devs[0]);
14487 : : }
14488 : :
14489 : : /* Start the device */
14490 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14491 : : "Failed to start cryptodev %u",
14492 : : ts_params->valid_devs[0]);
14493 : :
14494 : : /* Test expected values */
14495 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14496 : : }
14497 : :
14498 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14499 : : struct crypto_unittest_params *ut_params,
14500 : : enum rte_crypto_auth_operation op,
14501 : : const struct HMAC_MD5_vector *test_case)
14502 : : {
14503 : : uint8_t key[64];
14504 : :
14505 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
14506 : :
14507 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14508 : 4 : ut_params->auth_xform.next = NULL;
14509 : 4 : ut_params->auth_xform.auth.op = op;
14510 : :
14511 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14512 : :
14513 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14514 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
14515 : 4 : ut_params->auth_xform.auth.key.data = key;
14516 : :
14517 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
14518 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14519 : : ts_params->session_mpool);
14520 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14521 : : return TEST_SKIPPED;
14522 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14523 : :
14524 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14525 : :
14526 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14527 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14528 : :
14529 : 4 : return 0;
14530 : : }
14531 : :
14532 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14533 : : const struct HMAC_MD5_vector *test_case,
14534 : : uint8_t **plaintext)
14535 : : {
14536 : : uint16_t plaintext_pad_len;
14537 : :
14538 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14539 : :
14540 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14541 : : 16);
14542 : :
14543 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14544 : : plaintext_pad_len);
14545 : 4 : memcpy(*plaintext, test_case->plaintext.data,
14546 : 4 : test_case->plaintext.len);
14547 : :
14548 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14549 : : ut_params->ibuf, MD5_DIGEST_LEN);
14550 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14551 : : "no room to append digest");
14552 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14553 : : ut_params->ibuf, plaintext_pad_len);
14554 : :
14555 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14556 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14557 [ - + ]: 2 : test_case->auth_tag.len);
14558 : : }
14559 : :
14560 : 4 : sym_op->auth.data.offset = 0;
14561 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
14562 : :
14563 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14564 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14565 : :
14566 : 4 : return 0;
14567 : : }
14568 : :
14569 : : static int
14570 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14571 : : {
14572 : : uint16_t plaintext_pad_len;
14573 : : uint8_t *plaintext, *auth_tag;
14574 : : int ret;
14575 : :
14576 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14577 : : struct crypto_unittest_params *ut_params = &unittest_params;
14578 : : struct rte_cryptodev_info dev_info;
14579 : :
14580 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14581 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14582 : :
14583 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14584 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14585 : : printf("Device doesn't support RAW data-path APIs.\n");
14586 : 0 : return TEST_SKIPPED;
14587 : : }
14588 : :
14589 : : /* Verify the capabilities */
14590 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14591 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14592 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14593 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14594 : : &cap_idx) == NULL)
14595 : : return TEST_SKIPPED;
14596 : :
14597 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14598 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14599 : : return TEST_FAILED;
14600 : :
14601 : : /* Generate Crypto op data structure */
14602 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14603 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14604 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14605 : : "Failed to allocate symmetric crypto operation struct");
14606 : :
14607 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14608 : : 16);
14609 : :
14610 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14611 : : return TEST_FAILED;
14612 : :
14613 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14614 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14615 : : ut_params->op);
14616 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14617 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14618 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14619 : : return ret;
14620 : : } else
14621 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14622 : : process_crypto_request(ts_params->valid_devs[0],
14623 : : ut_params->op),
14624 : : "failed to process sym crypto op");
14625 : :
14626 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14627 : : "crypto op processing failed");
14628 : :
14629 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
14630 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14631 : : uint8_t *, plaintext_pad_len);
14632 : : } else {
14633 : 2 : auth_tag = plaintext + plaintext_pad_len;
14634 : : }
14635 : :
14636 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14637 : : auth_tag,
14638 : : test_case->auth_tag.data,
14639 : : test_case->auth_tag.len,
14640 : : "HMAC_MD5 generated tag not as expected");
14641 : :
14642 : : return TEST_SUCCESS;
14643 : : }
14644 : :
14645 : : static int
14646 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14647 : : {
14648 : : uint8_t *plaintext;
14649 : : int ret;
14650 : :
14651 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14652 : : struct crypto_unittest_params *ut_params = &unittest_params;
14653 : : struct rte_cryptodev_info dev_info;
14654 : :
14655 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14656 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14657 : :
14658 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14659 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14660 : : printf("Device doesn't support RAW data-path APIs.\n");
14661 : 0 : return TEST_SKIPPED;
14662 : : }
14663 : :
14664 : : /* Verify the capabilities */
14665 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14666 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14667 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14668 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14669 : : &cap_idx) == NULL)
14670 : : return TEST_SKIPPED;
14671 : :
14672 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14673 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14674 : : return TEST_FAILED;
14675 : : }
14676 : :
14677 : : /* Generate Crypto op data structure */
14678 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14679 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14680 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14681 : : "Failed to allocate symmetric crypto operation struct");
14682 : :
14683 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14684 : : return TEST_FAILED;
14685 : :
14686 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14687 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14688 : : ut_params->op);
14689 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14690 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14691 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14692 : : return ret;
14693 : : } else
14694 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14695 : : process_crypto_request(ts_params->valid_devs[0],
14696 : : ut_params->op),
14697 : : "failed to process sym crypto op");
14698 : :
14699 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14700 : : "HMAC_MD5 crypto op processing failed");
14701 : :
14702 : : return TEST_SUCCESS;
14703 : : }
14704 : :
14705 : : static int
14706 : 1 : test_MD5_HMAC_generate_case_1(void)
14707 : : {
14708 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14709 : : }
14710 : :
14711 : : static int
14712 : 1 : test_MD5_HMAC_verify_case_1(void)
14713 : : {
14714 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14715 : : }
14716 : :
14717 : : static int
14718 : 1 : test_MD5_HMAC_generate_case_2(void)
14719 : : {
14720 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14721 : : }
14722 : :
14723 : : static int
14724 : 1 : test_MD5_HMAC_verify_case_2(void)
14725 : : {
14726 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14727 : : }
14728 : :
14729 : : static int
14730 : 1 : test_multi_session(void)
14731 : : {
14732 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14733 : : struct crypto_unittest_params *ut_params = &unittest_params;
14734 : : struct rte_cryptodev_info dev_info;
14735 : : int i, nb_sess, ret = TEST_SUCCESS;
14736 : : void **sessions;
14737 : :
14738 : : /* Verify the capabilities */
14739 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14740 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14741 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14742 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14743 : : &cap_idx) == NULL)
14744 : : return TEST_SKIPPED;
14745 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14746 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14747 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14748 : : &cap_idx) == NULL)
14749 : : return TEST_SKIPPED;
14750 : :
14751 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14752 : : aes_cbc_key, hmac_sha512_key);
14753 : :
14754 : :
14755 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14756 : :
14757 : 1 : sessions = rte_malloc(NULL,
14758 : : sizeof(void *) *
14759 : : (MAX_NB_SESSIONS + 1), 0);
14760 : :
14761 : : /* Create multiple crypto sessions*/
14762 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
14763 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
14764 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14765 : : ts_params->session_mpool);
14766 [ - + ]: 4 : if (sessions[i] == NULL) {
14767 : : nb_sess = i;
14768 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14769 : : ret = TEST_SKIPPED;
14770 : : else {
14771 : : ret = TEST_FAILED;
14772 : : printf("TestCase %s() line %d failed : "
14773 : : "Session creation failed at session number %u",
14774 : : __func__, __LINE__, i);
14775 : : }
14776 : : break;
14777 : : }
14778 : :
14779 : :
14780 : : /* Attempt to send a request on each session */
14781 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14782 : : sessions[i],
14783 : : ut_params,
14784 : : ts_params,
14785 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14786 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14787 : : aes_cbc_iv);
14788 : :
14789 : : /* free crypto operation structure */
14790 : 4 : rte_crypto_op_free(ut_params->op);
14791 : :
14792 : : /*
14793 : : * free mbuf - both obuf and ibuf are usually the same,
14794 : : * so check if they point at the same address is necessary,
14795 : : * to avoid freeing the mbuf twice.
14796 : : */
14797 [ + - ]: 4 : if (ut_params->obuf) {
14798 : 4 : rte_pktmbuf_free(ut_params->obuf);
14799 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
14800 : 4 : ut_params->ibuf = 0;
14801 : 4 : ut_params->obuf = 0;
14802 : : }
14803 [ - + ]: 4 : if (ut_params->ibuf) {
14804 : 0 : rte_pktmbuf_free(ut_params->ibuf);
14805 : 0 : ut_params->ibuf = 0;
14806 : : }
14807 : :
14808 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
14809 : 0 : i++;
14810 : 0 : break;
14811 : : }
14812 : : }
14813 : :
14814 : : nb_sess = i;
14815 : :
14816 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
14817 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14818 : 4 : sessions[i]);
14819 : : }
14820 : :
14821 : 1 : rte_free(sessions);
14822 : :
14823 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14824 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14825 : :
14826 : : return ret;
14827 : : }
14828 : :
14829 : : struct multi_session_params {
14830 : : struct crypto_unittest_params ut_params;
14831 : : uint8_t *cipher_key;
14832 : : uint8_t *hmac_key;
14833 : : const uint8_t *cipher;
14834 : : const uint8_t *digest;
14835 : : uint8_t *iv;
14836 : : };
14837 : :
14838 : : #define MB_SESSION_NUMBER 3
14839 : :
14840 : : static int
14841 : 1 : test_multi_session_random_usage(void)
14842 : : {
14843 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14844 : : struct rte_cryptodev_info dev_info;
14845 : : int index = 0, ret = TEST_SUCCESS;
14846 : : uint32_t nb_sess, i, j;
14847 : : void **sessions;
14848 : 1 : struct multi_session_params ut_paramz[] = {
14849 : :
14850 : : {
14851 : : .cipher_key = ms_aes_cbc_key0,
14852 : : .hmac_key = ms_hmac_key0,
14853 : : .cipher = ms_aes_cbc_cipher0,
14854 : : .digest = ms_hmac_digest0,
14855 : : .iv = ms_aes_cbc_iv0
14856 : : },
14857 : : {
14858 : : .cipher_key = ms_aes_cbc_key1,
14859 : : .hmac_key = ms_hmac_key1,
14860 : : .cipher = ms_aes_cbc_cipher1,
14861 : : .digest = ms_hmac_digest1,
14862 : : .iv = ms_aes_cbc_iv1
14863 : : },
14864 : : {
14865 : : .cipher_key = ms_aes_cbc_key2,
14866 : : .hmac_key = ms_hmac_key2,
14867 : : .cipher = ms_aes_cbc_cipher2,
14868 : : .digest = ms_hmac_digest2,
14869 : : .iv = ms_aes_cbc_iv2
14870 : : },
14871 : :
14872 : : };
14873 : :
14874 : : /* Verify the capabilities */
14875 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14876 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14877 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14878 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14879 : : &cap_idx) == NULL)
14880 : : return TEST_SKIPPED;
14881 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14882 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14883 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14884 : : &cap_idx) == NULL)
14885 : : return TEST_SKIPPED;
14886 : :
14887 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14888 : :
14889 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
14890 : : * MAX_NB_SESSIONS) + 1, 0);
14891 : :
14892 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
14893 : :
14894 [ + + ]: 3 : rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
14895 : : sizeof(struct crypto_unittest_params));
14896 : :
14897 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14898 : : &ut_paramz[i].ut_params,
14899 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14900 : :
14901 : : /* Create multiple crypto sessions*/
14902 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
14903 : 3 : ts_params->valid_devs[0],
14904 : : &ut_paramz[i].ut_params.auth_xform,
14905 : : ts_params->session_mpool);
14906 [ - + ]: 3 : if (sessions[i] == NULL) {
14907 : : nb_sess = i;
14908 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14909 : : ret = TEST_SKIPPED;
14910 : : else {
14911 : : ret = TEST_FAILED;
14912 : : printf("TestCase %s() line %d failed : "
14913 : : "Session creation failed at session number %u",
14914 : : __func__, __LINE__, i);
14915 : : }
14916 : 0 : goto session_clear;
14917 : : }
14918 : :
14919 : : }
14920 : :
14921 : : nb_sess = i;
14922 : :
14923 : 1 : srand(time(NULL));
14924 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
14925 : :
14926 : 1 : j = rand() % MB_SESSION_NUMBER;
14927 : :
14928 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14929 : 1 : sessions[j],
14930 : : &ut_paramz[j].ut_params,
14931 : : ts_params, ut_paramz[j].cipher,
14932 : : ut_paramz[j].digest,
14933 : 1 : ut_paramz[j].iv);
14934 : :
14935 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
14936 : :
14937 : : /*
14938 : : * free mbuf - both obuf and ibuf are usually the same,
14939 : : * so check if they point at the same address is necessary,
14940 : : * to avoid freeing the mbuf twice.
14941 : : */
14942 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
14943 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14944 : 1 : if (ut_paramz[j].ut_params.ibuf
14945 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
14946 : 1 : ut_paramz[j].ut_params.ibuf = 0;
14947 : 1 : ut_paramz[j].ut_params.obuf = 0;
14948 : : }
14949 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
14950 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14951 : 0 : ut_paramz[j].ut_params.ibuf = 0;
14952 : : }
14953 : :
14954 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
14955 : 1 : index = i;
14956 : 1 : break;
14957 : : }
14958 : : }
14959 : :
14960 : 0 : session_clear:
14961 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
14962 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14963 : 3 : sessions[i]);
14964 : : }
14965 : :
14966 : 1 : rte_free(sessions);
14967 : :
14968 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14969 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14970 : :
14971 : : return TEST_SUCCESS;
14972 : : }
14973 : :
14974 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14975 : : 0xab, 0xab, 0xab, 0xab,
14976 : : 0xab, 0xab, 0xab, 0xab,
14977 : : 0xab, 0xab, 0xab, 0xab};
14978 : :
14979 : : static int
14980 : 0 : test_null_invalid_operation(void)
14981 : : {
14982 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14983 : : struct crypto_unittest_params *ut_params = &unittest_params;
14984 : :
14985 : : /* This test is for NULL PMD only */
14986 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
14987 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14988 : : return TEST_SKIPPED;
14989 : :
14990 : : /* Setup Cipher Parameters */
14991 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14992 : 0 : ut_params->cipher_xform.next = NULL;
14993 : :
14994 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14995 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14996 : :
14997 : : /* Create Crypto session*/
14998 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
14999 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15000 : : ts_params->session_mpool);
15001 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15002 : : return TEST_SKIPPED;
15003 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15004 : : "Session creation succeeded unexpectedly");
15005 : :
15006 : : /* Setup HMAC Parameters */
15007 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15008 : 0 : ut_params->auth_xform.next = NULL;
15009 : :
15010 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
15011 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15012 : :
15013 : : /* Create Crypto session*/
15014 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15015 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
15016 : : ts_params->session_mpool);
15017 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15018 : : return TEST_SKIPPED;
15019 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15020 : : "Session creation succeeded unexpectedly");
15021 : :
15022 : : return TEST_SUCCESS;
15023 : : }
15024 : :
15025 : :
15026 : : #define NULL_BURST_LENGTH (32)
15027 : :
15028 : : static int
15029 : 0 : test_null_burst_operation(void)
15030 : : {
15031 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15032 : : struct crypto_unittest_params *ut_params = &unittest_params;
15033 : :
15034 : : unsigned i, burst_len = NULL_BURST_LENGTH;
15035 : :
15036 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
15037 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
15038 : :
15039 : : /* This test is for NULL PMD only */
15040 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15041 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15042 : : return TEST_SKIPPED;
15043 : :
15044 : : /* Setup Cipher Parameters */
15045 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15046 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15047 : :
15048 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15049 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15050 : :
15051 : : /* Setup HMAC Parameters */
15052 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15053 : 0 : ut_params->auth_xform.next = NULL;
15054 : :
15055 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15056 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15057 : :
15058 : : /* Create Crypto session*/
15059 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15060 : 0 : ts_params->valid_devs[0],
15061 : : &ut_params->auth_xform,
15062 : : ts_params->session_mpool);
15063 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15064 : : return TEST_SKIPPED;
15065 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15066 : :
15067 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
15068 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
15069 : : burst_len, "failed to generate burst of crypto ops");
15070 : :
15071 : : /* Generate an operation for each mbuf in burst */
15072 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15073 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15074 : :
15075 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
15076 : :
15077 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
15078 : : sizeof(unsigned));
15079 : 0 : *data = i;
15080 : :
15081 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
15082 : :
15083 : 0 : burst[i]->sym->m_src = m;
15084 : : }
15085 : :
15086 : : /* Process crypto operation */
15087 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
15088 : : 0, burst, burst_len),
15089 : : burst_len,
15090 : : "Error enqueuing burst");
15091 : :
15092 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
15093 : : 0, burst_dequeued, burst_len),
15094 : : burst_len,
15095 : : "Error dequeuing burst");
15096 : :
15097 : :
15098 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15099 [ # # ]: 0 : TEST_ASSERT_EQUAL(
15100 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
15101 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
15102 : : uint32_t *),
15103 : : "data not as expected");
15104 : :
15105 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
15106 : 0 : rte_crypto_op_free(burst[i]);
15107 : : }
15108 : :
15109 : : return TEST_SUCCESS;
15110 : : }
15111 : :
15112 : : static uint16_t
15113 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15114 : : uint16_t nb_ops, void *user_param)
15115 : : {
15116 : : RTE_SET_USED(dev_id);
15117 : : RTE_SET_USED(qp_id);
15118 : : RTE_SET_USED(ops);
15119 : : RTE_SET_USED(user_param);
15120 : :
15121 : 0 : enq_cb_called = true;
15122 : : printf("crypto enqueue callback called\n");
15123 : 0 : return nb_ops;
15124 : : }
15125 : :
15126 : : static uint16_t
15127 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15128 : : uint16_t nb_ops, void *user_param)
15129 : : {
15130 : : RTE_SET_USED(dev_id);
15131 : : RTE_SET_USED(qp_id);
15132 : : RTE_SET_USED(ops);
15133 : : RTE_SET_USED(user_param);
15134 : :
15135 : 0 : deq_cb_called = true;
15136 : : printf("crypto dequeue callback called\n");
15137 : 0 : return nb_ops;
15138 : : }
15139 : :
15140 : : /*
15141 : : * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
15142 : : */
15143 : : static int
15144 : 0 : test_enqdeq_callback_null_cipher(void)
15145 : : {
15146 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15147 : : struct crypto_unittest_params *ut_params = &unittest_params;
15148 : :
15149 : : /* Setup Cipher Parameters */
15150 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15151 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15152 : :
15153 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15154 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15155 : :
15156 : : /* Setup Auth Parameters */
15157 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15158 : 0 : ut_params->auth_xform.next = NULL;
15159 : :
15160 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15161 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15162 : :
15163 : : /* Create Crypto session */
15164 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
15165 : : &ut_params->auth_xform, ts_params->session_mpool);
15166 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15167 : : return TEST_SKIPPED;
15168 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15169 : :
15170 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15171 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
15172 : :
15173 : : /* Allocate mbuf */
15174 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15175 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
15176 : :
15177 : : /* Append some random data */
15178 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
15179 : : "no room to append data");
15180 : :
15181 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15182 : :
15183 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15184 : :
15185 : : /* Process crypto operation */
15186 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
15187 : : "failed to process sym crypto op");
15188 : :
15189 : : return 0;
15190 : : }
15191 : :
15192 : : static int
15193 : 1 : test_enq_callback_setup(void)
15194 : : {
15195 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15196 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15197 : : struct rte_cryptodev_info dev_info;
15198 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15199 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15200 : : };
15201 : :
15202 : : struct rte_cryptodev_cb *cb;
15203 : : uint16_t qp_id = 0;
15204 : : int j = 0;
15205 : :
15206 : : /* Skip test if synchronous API is used */
15207 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15208 : : return TEST_SKIPPED;
15209 : :
15210 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15211 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15212 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15213 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15214 : : &cap_idx) == NULL)
15215 : : return TEST_SKIPPED;
15216 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15217 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15218 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15219 : : &cap_idx) == NULL)
15220 : : return TEST_SKIPPED;
15221 : :
15222 : : /* Stop the device in case it's started so it can be configured */
15223 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15224 : :
15225 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15226 : :
15227 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15228 : : &ts_params->conf),
15229 : : "Failed to configure cryptodev %u",
15230 : : ts_params->valid_devs[0]);
15231 : :
15232 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15233 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15234 : :
15235 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15236 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15237 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15238 : : "Failed test for "
15239 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15240 : : "%u on qp %u on cryptodev %u",
15241 : : qp_conf.nb_descriptors, qp_id,
15242 : : ts_params->valid_devs[0]);
15243 : :
15244 : 0 : enq_cb_called = false;
15245 : : /* Test with invalid crypto device */
15246 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
15247 : : qp_id, test_enq_callback, NULL);
15248 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15249 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15250 : : "rte_cryptodev_add_enq_callback() "
15251 : : "Not supported, skipped\n", __func__, __LINE__);
15252 : 0 : return TEST_SKIPPED;
15253 : : }
15254 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15255 : : "cryptodev %u did not fail",
15256 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15257 : :
15258 : : /* Test with invalid queue pair */
15259 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15260 : 0 : dev_info.max_nb_queue_pairs + 1,
15261 : : test_enq_callback, NULL);
15262 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15263 : : "cryptodev %u did not fail",
15264 : : dev_info.max_nb_queue_pairs + 1,
15265 : : ts_params->valid_devs[0]);
15266 : :
15267 : : /* Test with NULL callback */
15268 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15269 : : qp_id, NULL, NULL);
15270 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15271 : : "cryptodev %u did not fail",
15272 : : qp_id, ts_params->valid_devs[0]);
15273 : :
15274 : : /* Test with valid configuration */
15275 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15276 : : qp_id, test_enq_callback, NULL);
15277 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15278 : : "qp %u on cryptodev %u",
15279 : : qp_id, ts_params->valid_devs[0]);
15280 : :
15281 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15282 : :
15283 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
15284 : :
15285 : : /* Wait until callback not called. */
15286 [ # # # # ]: 0 : while (!enq_cb_called && (j++ < 10))
15287 : : rte_delay_ms(10);
15288 : :
15289 : : /* Test with invalid crypto device */
15290 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15291 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15292 : : "Expected call to fail as crypto device is invalid");
15293 : :
15294 : : /* Test with invalid queue pair */
15295 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15296 : : ts_params->valid_devs[0],
15297 : : dev_info.max_nb_queue_pairs + 1, cb),
15298 : : "Expected call to fail as queue pair is invalid");
15299 : :
15300 : : /* Test with NULL callback */
15301 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15302 : : ts_params->valid_devs[0], qp_id, NULL),
15303 : : "Expected call to fail as callback is NULL");
15304 : :
15305 : : /* Test with valid configuration */
15306 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
15307 : : ts_params->valid_devs[0], qp_id, cb),
15308 : : "Failed test to remove callback on "
15309 : : "qp %u on cryptodev %u",
15310 : : qp_id, ts_params->valid_devs[0]);
15311 : :
15312 [ # # ]: 0 : TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
15313 : :
15314 : : return TEST_SUCCESS;
15315 : : }
15316 : :
15317 : : static int
15318 : 1 : test_deq_callback_setup(void)
15319 : : {
15320 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15321 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15322 : : struct rte_cryptodev_info dev_info;
15323 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15324 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15325 : : };
15326 : :
15327 : : struct rte_cryptodev_cb *cb;
15328 : : uint16_t qp_id = 0;
15329 : : int j = 0;
15330 : :
15331 : : /* Skip test if synchronous API is used */
15332 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15333 : : return TEST_SKIPPED;
15334 : :
15335 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15336 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15337 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15338 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15339 : : &cap_idx) == NULL)
15340 : : return TEST_SKIPPED;
15341 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15342 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15343 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15344 : : &cap_idx) == NULL)
15345 : : return TEST_SKIPPED;
15346 : :
15347 : : /* Stop the device in case it's started so it can be configured */
15348 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15349 : :
15350 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15351 : :
15352 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15353 : : &ts_params->conf),
15354 : : "Failed to configure cryptodev %u",
15355 : : ts_params->valid_devs[0]);
15356 : :
15357 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15358 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15359 : :
15360 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15361 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15362 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15363 : : "Failed test for "
15364 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15365 : : "%u on qp %u on cryptodev %u",
15366 : : qp_conf.nb_descriptors, qp_id,
15367 : : ts_params->valid_devs[0]);
15368 : :
15369 : 0 : deq_cb_called = false;
15370 : : /* Test with invalid crypto device */
15371 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15372 : : qp_id, test_deq_callback, NULL);
15373 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15374 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15375 : : "rte_cryptodev_add_deq_callback() "
15376 : : "Not supported, skipped\n", __func__, __LINE__);
15377 : 0 : return TEST_SKIPPED;
15378 : : }
15379 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15380 : : "cryptodev %u did not fail",
15381 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15382 : :
15383 : : /* Test with invalid queue pair */
15384 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15385 : 0 : dev_info.max_nb_queue_pairs + 1,
15386 : : test_deq_callback, NULL);
15387 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15388 : : "cryptodev %u did not fail",
15389 : : dev_info.max_nb_queue_pairs + 1,
15390 : : ts_params->valid_devs[0]);
15391 : :
15392 : : /* Test with NULL callback */
15393 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15394 : : qp_id, NULL, NULL);
15395 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15396 : : "cryptodev %u did not fail",
15397 : : qp_id, ts_params->valid_devs[0]);
15398 : :
15399 : : /* Test with valid configuration */
15400 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15401 : : qp_id, test_deq_callback, NULL);
15402 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15403 : : "qp %u on cryptodev %u",
15404 : : qp_id, ts_params->valid_devs[0]);
15405 : :
15406 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15407 : :
15408 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15409 : :
15410 : : /* Wait until callback not called. */
15411 [ # # # # ]: 0 : while (!deq_cb_called && (j++ < 10))
15412 : : rte_delay_ms(10);
15413 : :
15414 : : /* Test with invalid crypto device */
15415 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15416 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15417 : : "Expected call to fail as crypto device is invalid");
15418 : :
15419 : : /* Test with invalid queue pair */
15420 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15421 : : ts_params->valid_devs[0],
15422 : : dev_info.max_nb_queue_pairs + 1, cb),
15423 : : "Expected call to fail as queue pair is invalid");
15424 : :
15425 : : /* Test with NULL callback */
15426 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15427 : : ts_params->valid_devs[0], qp_id, NULL),
15428 : : "Expected call to fail as callback is NULL");
15429 : :
15430 : : /* Test with valid configuration */
15431 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15432 : : ts_params->valid_devs[0], qp_id, cb),
15433 : : "Failed test to remove callback on "
15434 : : "qp %u on cryptodev %u",
15435 : : qp_id, ts_params->valid_devs[0]);
15436 : :
15437 [ # # ]: 0 : TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15438 : :
15439 : : return TEST_SUCCESS;
15440 : : }
15441 : :
15442 : : static void
15443 : : generate_gmac_large_plaintext(uint8_t *data)
15444 : : {
15445 : : uint16_t i;
15446 : :
15447 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15448 : 4082 : memcpy(&data[i], &data[0], 32);
15449 : : }
15450 : :
15451 : : static int
15452 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
15453 : : const struct gmac_test_data *tdata)
15454 : : {
15455 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15456 : : struct crypto_unittest_params *ut_params = &unittest_params;
15457 : : struct rte_crypto_sym_op *sym_op;
15458 : :
15459 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15460 : :
15461 : : /* Generate Crypto op data structure */
15462 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15463 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15464 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
15465 : : "Failed to allocate symmetric crypto operation struct");
15466 : :
15467 : : sym_op = ut_params->op->sym;
15468 : :
15469 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15470 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
15471 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15472 : : "no room to append digest");
15473 : :
15474 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15475 : : ut_params->ibuf, plaintext_pad_len);
15476 : :
15477 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15478 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15479 [ - + ]: 4 : tdata->gmac_tag.len);
15480 : 4 : debug_hexdump(stdout, "digest:",
15481 : 4 : sym_op->auth.digest.data,
15482 : 4 : tdata->gmac_tag.len);
15483 : : }
15484 : :
15485 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15486 : : uint8_t *, IV_OFFSET);
15487 : :
15488 [ - + ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15489 : :
15490 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15491 : :
15492 : 8 : sym_op->cipher.data.length = 0;
15493 : 8 : sym_op->cipher.data.offset = 0;
15494 : :
15495 : 8 : sym_op->auth.data.offset = 0;
15496 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
15497 : :
15498 : 8 : return 0;
15499 : : }
15500 : :
15501 : : static int
15502 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15503 : : const struct gmac_test_data *tdata,
15504 : : void *digest_mem, uint64_t digest_phys)
15505 : : {
15506 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15507 : : struct crypto_unittest_params *ut_params = &unittest_params;
15508 : : struct rte_crypto_sym_op *sym_op;
15509 : :
15510 : : /* Generate Crypto op data structure */
15511 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15512 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15513 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15514 : : "Failed to allocate symmetric crypto operation struct");
15515 : :
15516 : : sym_op = ut_params->op->sym;
15517 : :
15518 : 0 : sym_op->auth.digest.data = digest_mem;
15519 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15520 : : "no room to append digest");
15521 : :
15522 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
15523 : :
15524 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15525 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15526 [ # # ]: 0 : tdata->gmac_tag.len);
15527 : 0 : debug_hexdump(stdout, "digest:",
15528 : 0 : sym_op->auth.digest.data,
15529 : 0 : tdata->gmac_tag.len);
15530 : : }
15531 : :
15532 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15533 : : uint8_t *, IV_OFFSET);
15534 : :
15535 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15536 : :
15537 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15538 : :
15539 : 0 : sym_op->cipher.data.length = 0;
15540 : 0 : sym_op->cipher.data.offset = 0;
15541 : :
15542 : 0 : sym_op->auth.data.offset = 0;
15543 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
15544 : :
15545 : 0 : return 0;
15546 : : }
15547 : :
15548 : 8 : static int create_gmac_session(uint8_t dev_id,
15549 : : const struct gmac_test_data *tdata,
15550 : : enum rte_crypto_auth_operation auth_op)
15551 : : {
15552 : 8 : uint8_t *auth_key = alloca(tdata->key.len);
15553 : :
15554 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15555 : : struct crypto_unittest_params *ut_params = &unittest_params;
15556 : :
15557 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
15558 : :
15559 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15560 : 8 : ut_params->auth_xform.next = NULL;
15561 : :
15562 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15563 : 8 : ut_params->auth_xform.auth.op = auth_op;
15564 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15565 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
15566 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
15567 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15568 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15569 : :
15570 : :
15571 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15572 : : &ut_params->auth_xform, ts_params->session_mpool);
15573 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15574 : : return TEST_SKIPPED;
15575 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15576 : :
15577 : : return 0;
15578 : : }
15579 : :
15580 : : static int
15581 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15582 : : {
15583 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15584 : : struct crypto_unittest_params *ut_params = &unittest_params;
15585 : : struct rte_cryptodev_info dev_info;
15586 : :
15587 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15588 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15589 : :
15590 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15591 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15592 : : printf("Device doesn't support RAW data-path APIs.\n");
15593 : 0 : return TEST_SKIPPED;
15594 : : }
15595 : :
15596 : : int retval;
15597 : :
15598 : : uint8_t *auth_tag, *plaintext;
15599 : : uint16_t plaintext_pad_len;
15600 : :
15601 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15602 : : "No GMAC length in the source data");
15603 : :
15604 : : /* Verify the capabilities */
15605 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15606 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15607 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15608 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15609 : : &cap_idx) == NULL)
15610 : : return TEST_SKIPPED;
15611 : :
15612 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15613 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15614 : :
15615 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15616 : : return TEST_SKIPPED;
15617 [ + - ]: 4 : if (retval < 0)
15618 : : return retval;
15619 : :
15620 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15621 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15622 : : else
15623 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15624 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15625 : : "Failed to allocate input buffer in mempool");
15626 : :
15627 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15628 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15629 : :
15630 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15631 : : /*
15632 : : * Runtime generate the large plain text instead of use hard code
15633 : : * plain text vector. It is done to avoid create huge source file
15634 : : * with the test vector.
15635 : : */
15636 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15637 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15638 : :
15639 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15640 : : plaintext_pad_len);
15641 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15642 : :
15643 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15644 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15645 : 4 : tdata->plaintext.len);
15646 : :
15647 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15648 : : tdata);
15649 : :
15650 [ + - ]: 4 : if (retval < 0)
15651 : : return retval;
15652 : :
15653 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15654 : :
15655 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15656 : :
15657 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15658 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15659 : : ut_params->op);
15660 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15661 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15662 : : 0);
15663 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15664 : : return retval;
15665 : : } else
15666 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15667 : : process_crypto_request(ts_params->valid_devs[0],
15668 : : ut_params->op), "failed to process sym crypto op");
15669 : :
15670 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15671 : : "crypto op processing failed");
15672 : :
15673 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
15674 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15675 : : uint8_t *, plaintext_pad_len);
15676 : : } else {
15677 : 4 : auth_tag = plaintext + plaintext_pad_len;
15678 : : }
15679 : :
15680 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15681 : :
15682 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15683 : : auth_tag,
15684 : : tdata->gmac_tag.data,
15685 : : tdata->gmac_tag.len,
15686 : : "GMAC Generated auth tag not as expected");
15687 : :
15688 : : return 0;
15689 : : }
15690 : :
15691 : : static int
15692 : 1 : test_AES_GMAC_authentication_test_case_1(void)
15693 : : {
15694 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
15695 : : }
15696 : :
15697 : : static int
15698 : 1 : test_AES_GMAC_authentication_test_case_2(void)
15699 : : {
15700 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
15701 : : }
15702 : :
15703 : : static int
15704 : 1 : test_AES_GMAC_authentication_test_case_3(void)
15705 : : {
15706 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
15707 : : }
15708 : :
15709 : : static int
15710 : 1 : test_AES_GMAC_authentication_test_case_4(void)
15711 : : {
15712 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
15713 : : }
15714 : :
15715 : : static int
15716 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15717 : : {
15718 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15719 : : struct crypto_unittest_params *ut_params = &unittest_params;
15720 : : int retval;
15721 : : uint32_t plaintext_pad_len;
15722 : : uint8_t *plaintext;
15723 : : struct rte_cryptodev_info dev_info;
15724 : :
15725 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15726 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15727 : :
15728 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15729 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15730 : : printf("Device doesn't support RAW data-path APIs.\n");
15731 : 0 : return TEST_SKIPPED;
15732 : : }
15733 : :
15734 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15735 : : "No GMAC length in the source data");
15736 : :
15737 : : /* Verify the capabilities */
15738 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15739 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15740 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15741 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15742 : : &cap_idx) == NULL)
15743 : : return TEST_SKIPPED;
15744 : :
15745 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15746 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15747 : :
15748 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15749 : : return TEST_SKIPPED;
15750 [ + - ]: 4 : if (retval < 0)
15751 : : return retval;
15752 : :
15753 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15754 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15755 : : else
15756 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15757 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15758 : : "Failed to allocate input buffer in mempool");
15759 : :
15760 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15761 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15762 : :
15763 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15764 : :
15765 : : /*
15766 : : * Runtime generate the large plain text instead of use hard code
15767 : : * plain text vector. It is done to avoid create huge source file
15768 : : * with the test vector.
15769 : : */
15770 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15771 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15772 : :
15773 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15774 : : plaintext_pad_len);
15775 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15776 : :
15777 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15778 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15779 : 4 : tdata->plaintext.len);
15780 : :
15781 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15782 : : tdata);
15783 : :
15784 [ + - ]: 4 : if (retval < 0)
15785 : : return retval;
15786 : :
15787 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15788 : :
15789 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15790 : :
15791 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15792 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15793 : : ut_params->op);
15794 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15795 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15796 : : 0);
15797 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15798 : : return retval;
15799 : : } else
15800 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15801 : : process_crypto_request(ts_params->valid_devs[0],
15802 : : ut_params->op), "failed to process sym crypto op");
15803 : :
15804 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15805 : : "crypto op processing failed");
15806 : :
15807 : : return 0;
15808 : :
15809 : : }
15810 : :
15811 : : static int
15812 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
15813 : : {
15814 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15815 : : }
15816 : :
15817 : : static int
15818 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
15819 : : {
15820 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15821 : : }
15822 : :
15823 : : static int
15824 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
15825 : : {
15826 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15827 : : }
15828 : :
15829 : : static int
15830 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
15831 : : {
15832 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15833 : : }
15834 : :
15835 : : static int
15836 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15837 : : uint32_t fragsz)
15838 : : {
15839 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15840 : : struct crypto_unittest_params *ut_params = &unittest_params;
15841 : : struct rte_cryptodev_info dev_info;
15842 : : uint64_t feature_flags;
15843 : : unsigned int trn_data = 0;
15844 : : void *digest_mem = NULL;
15845 : : uint32_t segs = 1;
15846 : : unsigned int to_trn = 0;
15847 : : struct rte_mbuf *buf = NULL;
15848 : : uint8_t *auth_tag, *plaintext;
15849 : : int retval;
15850 : :
15851 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15852 : : "No GMAC length in the source data");
15853 : :
15854 : : /* Verify the capabilities */
15855 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15856 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15857 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15858 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15859 : : &cap_idx) == NULL)
15860 : : return TEST_SKIPPED;
15861 : :
15862 : : /* Check for any input SGL support */
15863 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15864 : 4 : feature_flags = dev_info.feature_flags;
15865 : :
15866 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15867 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15868 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15869 : : return TEST_SKIPPED;
15870 : :
15871 : 0 : if (fragsz > tdata->plaintext.len)
15872 : : fragsz = tdata->plaintext.len;
15873 : :
15874 : 0 : uint16_t plaintext_len = fragsz;
15875 : :
15876 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
15877 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15878 : :
15879 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15880 : : return TEST_SKIPPED;
15881 [ # # ]: 0 : if (retval < 0)
15882 : : return retval;
15883 : :
15884 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15885 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15886 : : "Failed to allocate input buffer in mempool");
15887 : :
15888 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15889 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15890 : :
15891 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15892 : : plaintext_len);
15893 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15894 : :
15895 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15896 : :
15897 : : trn_data += plaintext_len;
15898 : :
15899 : 0 : buf = ut_params->ibuf;
15900 : :
15901 : : /*
15902 : : * Loop until no more fragments
15903 : : */
15904 : :
15905 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15906 : 0 : ++segs;
15907 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15908 : : (tdata->plaintext.len - trn_data) : fragsz;
15909 : :
15910 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15911 : : buf = buf->next;
15912 : :
15913 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15914 : : rte_pktmbuf_tailroom(buf));
15915 : :
15916 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15917 : : to_trn);
15918 : :
15919 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15920 : : to_trn);
15921 : 0 : trn_data += to_trn;
15922 [ # # ]: 0 : if (trn_data == tdata->plaintext.len)
15923 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15924 : 0 : tdata->gmac_tag.len);
15925 : : }
15926 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
15927 : :
15928 : : /*
15929 : : * Place digest at the end of the last buffer
15930 : : */
15931 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15932 : :
15933 [ # # ]: 0 : if (!digest_mem) {
15934 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15935 : 0 : + tdata->gmac_tag.len);
15936 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15937 : : tdata->plaintext.len);
15938 : : }
15939 : :
15940 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15941 : : tdata, digest_mem, digest_phys);
15942 : :
15943 [ # # ]: 0 : if (retval < 0)
15944 : : return retval;
15945 : :
15946 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15947 : :
15948 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15949 : :
15950 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15951 : : return TEST_SKIPPED;
15952 : :
15953 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15954 : : process_crypto_request(ts_params->valid_devs[0],
15955 : : ut_params->op), "failed to process sym crypto op");
15956 : :
15957 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15958 : : "crypto op processing failed");
15959 : :
15960 : : auth_tag = digest_mem;
15961 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15962 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15963 : : auth_tag,
15964 : : tdata->gmac_tag.data,
15965 : : tdata->gmac_tag.len,
15966 : : "GMAC Generated auth tag not as expected");
15967 : :
15968 : : return 0;
15969 : : }
15970 : :
15971 : : /* Segment size not multiple of block size (16B) */
15972 : : static int
15973 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
15974 : : {
15975 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15976 : : }
15977 : :
15978 : : static int
15979 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
15980 : : {
15981 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15982 : : }
15983 : :
15984 : : static int
15985 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
15986 : : {
15987 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15988 : : }
15989 : :
15990 : : /* Segment size not multiple of block size (16B) */
15991 : : static int
15992 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
15993 : : {
15994 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15995 : : }
15996 : :
15997 : : struct test_crypto_vector {
15998 : : enum rte_crypto_cipher_algorithm crypto_algo;
15999 : : unsigned int cipher_offset;
16000 : : unsigned int cipher_len;
16001 : :
16002 : : struct {
16003 : : uint8_t data[64];
16004 : : unsigned int len;
16005 : : } cipher_key;
16006 : :
16007 : : struct {
16008 : : uint8_t data[64];
16009 : : unsigned int len;
16010 : : } iv;
16011 : :
16012 : : struct {
16013 : : const uint8_t *data;
16014 : : unsigned int len;
16015 : : } plaintext;
16016 : :
16017 : : struct {
16018 : : const uint8_t *data;
16019 : : unsigned int len;
16020 : : } ciphertext;
16021 : :
16022 : : enum rte_crypto_auth_algorithm auth_algo;
16023 : : unsigned int auth_offset;
16024 : :
16025 : : struct {
16026 : : uint8_t data[128];
16027 : : unsigned int len;
16028 : : } auth_key;
16029 : :
16030 : : struct {
16031 : : const uint8_t *data;
16032 : : unsigned int len;
16033 : : } aad;
16034 : :
16035 : : struct {
16036 : : uint8_t data[128];
16037 : : unsigned int len;
16038 : : } digest;
16039 : : };
16040 : :
16041 : : static const struct test_crypto_vector
16042 : : hmac_sha1_test_crypto_vector = {
16043 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16044 : : .plaintext = {
16045 : : .data = plaintext_hash,
16046 : : .len = 512
16047 : : },
16048 : : .auth_key = {
16049 : : .data = {
16050 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16051 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16052 : : 0xDE, 0xF4, 0xDE, 0xAD
16053 : : },
16054 : : .len = 20
16055 : : },
16056 : : .digest = {
16057 : : .data = {
16058 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
16059 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
16060 : : 0x3F, 0x91, 0x64, 0x59
16061 : : },
16062 : : .len = 20
16063 : : }
16064 : : };
16065 : :
16066 : : static const struct test_crypto_vector
16067 : : aes128_gmac_test_vector = {
16068 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
16069 : : .plaintext = {
16070 : : .data = plaintext_hash,
16071 : : .len = 512
16072 : : },
16073 : : .iv = {
16074 : : .data = {
16075 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16076 : : 0x08, 0x09, 0x0A, 0x0B
16077 : : },
16078 : : .len = 12
16079 : : },
16080 : : .auth_key = {
16081 : : .data = {
16082 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16083 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
16084 : : },
16085 : : .len = 16
16086 : : },
16087 : : .digest = {
16088 : : .data = {
16089 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
16090 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
16091 : : },
16092 : : .len = 16
16093 : : }
16094 : : };
16095 : :
16096 : : static const struct test_crypto_vector
16097 : : aes128cbc_hmac_sha1_test_vector = {
16098 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16099 : : .cipher_offset = 0,
16100 : : .cipher_len = 512,
16101 : : .cipher_key = {
16102 : : .data = {
16103 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16104 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16105 : : },
16106 : : .len = 16
16107 : : },
16108 : : .iv = {
16109 : : .data = {
16110 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16111 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16112 : : },
16113 : : .len = 16
16114 : : },
16115 : : .plaintext = {
16116 : : .data = plaintext_hash,
16117 : : .len = 512
16118 : : },
16119 : : .ciphertext = {
16120 : : .data = ciphertext512_aes128cbc,
16121 : : .len = 512
16122 : : },
16123 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16124 : : .auth_offset = 0,
16125 : : .auth_key = {
16126 : : .data = {
16127 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16128 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16129 : : 0xDE, 0xF4, 0xDE, 0xAD
16130 : : },
16131 : : .len = 20
16132 : : },
16133 : : .digest = {
16134 : : .data = {
16135 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
16136 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16137 : : 0x18, 0x8C, 0x1D, 0x32
16138 : : },
16139 : : .len = 20
16140 : : }
16141 : : };
16142 : :
16143 : : static const struct test_crypto_vector
16144 : : aes128cbc_hmac_sha1_aad_test_vector = {
16145 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16146 : : .cipher_offset = 8,
16147 : : .cipher_len = 496,
16148 : : .cipher_key = {
16149 : : .data = {
16150 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16151 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16152 : : },
16153 : : .len = 16
16154 : : },
16155 : : .iv = {
16156 : : .data = {
16157 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16158 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16159 : : },
16160 : : .len = 16
16161 : : },
16162 : : .plaintext = {
16163 : : .data = plaintext_hash,
16164 : : .len = 512
16165 : : },
16166 : : .ciphertext = {
16167 : : .data = ciphertext512_aes128cbc_aad,
16168 : : .len = 512
16169 : : },
16170 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16171 : : .auth_offset = 0,
16172 : : .auth_key = {
16173 : : .data = {
16174 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16175 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16176 : : 0xDE, 0xF4, 0xDE, 0xAD
16177 : : },
16178 : : .len = 20
16179 : : },
16180 : : .digest = {
16181 : : .data = {
16182 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
16183 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
16184 : : 0x62, 0x0F, 0xFB, 0x10
16185 : : },
16186 : : .len = 20
16187 : : }
16188 : : };
16189 : :
16190 : : static void
16191 : : data_corruption(uint8_t *data)
16192 : : {
16193 : 3 : data[0] += 1;
16194 : 3 : }
16195 : :
16196 : : static void
16197 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
16198 : : {
16199 : 3 : data[tag_offset] += 1;
16200 : 3 : }
16201 : :
16202 : : static int
16203 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
16204 : : uint8_t dev_id,
16205 : : const struct test_crypto_vector *reference,
16206 : : enum rte_crypto_auth_operation auth_op)
16207 : : {
16208 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16209 : 2 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16210 : :
16211 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16212 : :
16213 : : /* Setup Authentication Parameters */
16214 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16215 : 2 : ut_params->auth_xform.auth.op = auth_op;
16216 : 2 : ut_params->auth_xform.next = NULL;
16217 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16218 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16219 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
16220 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16221 : :
16222 : : /* Create Crypto session*/
16223 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16224 : : &ut_params->auth_xform,
16225 : : ts_params->session_mpool);
16226 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16227 : : return TEST_SKIPPED;
16228 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16229 : :
16230 : : return 0;
16231 : : }
16232 : :
16233 : : static int
16234 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
16235 : : uint8_t dev_id,
16236 : : const struct test_crypto_vector *reference,
16237 : : enum rte_crypto_auth_operation auth_op,
16238 : : enum rte_crypto_cipher_operation cipher_op)
16239 : : {
16240 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16241 : 4 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16242 : 4 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16243 : :
16244 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
16245 : : reference->cipher_key.len);
16246 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16247 : :
16248 : : /* Setup Authentication Parameters */
16249 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16250 : 4 : ut_params->auth_xform.auth.op = auth_op;
16251 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16252 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16253 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
16254 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16255 : :
16256 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
16257 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
16258 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
16259 : : } else {
16260 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16261 : :
16262 : : /* Setup Cipher Parameters */
16263 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16264 : 2 : ut_params->cipher_xform.next = NULL;
16265 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16266 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
16267 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16268 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16269 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16270 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16271 : : }
16272 : :
16273 : : /* Create Crypto session*/
16274 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16275 : : &ut_params->auth_xform,
16276 : : ts_params->session_mpool);
16277 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16278 : : return TEST_SKIPPED;
16279 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16280 : :
16281 : : return 0;
16282 : : }
16283 : :
16284 : : static int
16285 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
16286 : : struct crypto_unittest_params *ut_params,
16287 : : const struct test_crypto_vector *reference,
16288 : : unsigned int auth_generate)
16289 : : {
16290 : : /* Generate Crypto op data structure */
16291 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16292 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16293 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16294 : : "Failed to allocate pktmbuf offload");
16295 : :
16296 : : /* Set crypto operation data parameters */
16297 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16298 : :
16299 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16300 : :
16301 : : /* set crypto operation source mbuf */
16302 : 2 : sym_op->m_src = ut_params->ibuf;
16303 : :
16304 : : /* digest */
16305 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16306 : 2 : ut_params->ibuf, reference->digest.len);
16307 : :
16308 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16309 : : "no room to append auth tag");
16310 : :
16311 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16312 : : ut_params->ibuf, reference->plaintext.len);
16313 : :
16314 [ - + ]: 2 : if (auth_generate)
16315 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16316 : : else
16317 : 2 : memcpy(sym_op->auth.digest.data,
16318 : 2 : reference->digest.data,
16319 : 2 : reference->digest.len);
16320 : :
16321 : 2 : debug_hexdump(stdout, "digest:",
16322 : 2 : sym_op->auth.digest.data,
16323 : 2 : reference->digest.len);
16324 : :
16325 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16326 : 2 : sym_op->auth.data.offset = 0;
16327 : :
16328 : 2 : return 0;
16329 : : }
16330 : :
16331 : : static int
16332 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16333 : : struct crypto_unittest_params *ut_params,
16334 : : const struct test_crypto_vector *reference,
16335 : : unsigned int auth_generate)
16336 : : {
16337 : : /* Generate Crypto op data structure */
16338 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16339 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16340 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16341 : : "Failed to allocate pktmbuf offload");
16342 : :
16343 : : /* Set crypto operation data parameters */
16344 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16345 : :
16346 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16347 : :
16348 : : /* set crypto operation source mbuf */
16349 : 2 : sym_op->m_src = ut_params->ibuf;
16350 : :
16351 : : /* digest */
16352 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16353 : 2 : ut_params->ibuf, reference->digest.len);
16354 : :
16355 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16356 : : "no room to append auth tag");
16357 : :
16358 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16359 : : ut_params->ibuf, reference->ciphertext.len);
16360 : :
16361 [ - + ]: 2 : if (auth_generate)
16362 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16363 : : else
16364 : 2 : memcpy(sym_op->auth.digest.data,
16365 : 2 : reference->digest.data,
16366 : 2 : reference->digest.len);
16367 : :
16368 : 2 : debug_hexdump(stdout, "digest:",
16369 : 2 : sym_op->auth.digest.data,
16370 : 2 : reference->digest.len);
16371 : :
16372 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16373 [ - + ]: 2 : reference->iv.data, reference->iv.len);
16374 : :
16375 : 2 : sym_op->cipher.data.length = 0;
16376 : 2 : sym_op->cipher.data.offset = 0;
16377 : :
16378 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16379 : 2 : sym_op->auth.data.offset = 0;
16380 : :
16381 : 2 : return 0;
16382 : : }
16383 : :
16384 : : static int
16385 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16386 : : struct crypto_unittest_params *ut_params,
16387 : : const struct test_crypto_vector *reference,
16388 : : unsigned int auth_generate)
16389 : : {
16390 : : /* Generate Crypto op data structure */
16391 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16392 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16393 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
16394 : : "Failed to allocate pktmbuf offload");
16395 : :
16396 : : /* Set crypto operation data parameters */
16397 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16398 : :
16399 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16400 : :
16401 : : /* set crypto operation source mbuf */
16402 : 4 : sym_op->m_src = ut_params->ibuf;
16403 : :
16404 : : /* digest */
16405 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16406 : 4 : ut_params->ibuf, reference->digest.len);
16407 : :
16408 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16409 : : "no room to append auth tag");
16410 : :
16411 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16412 : : ut_params->ibuf, reference->ciphertext.len);
16413 : :
16414 [ - + ]: 4 : if (auth_generate)
16415 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16416 : : else
16417 : 4 : memcpy(sym_op->auth.digest.data,
16418 : 4 : reference->digest.data,
16419 : 4 : reference->digest.len);
16420 : :
16421 : 4 : debug_hexdump(stdout, "digest:",
16422 : 4 : sym_op->auth.digest.data,
16423 : 4 : reference->digest.len);
16424 : :
16425 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16426 [ - + ]: 4 : reference->iv.data, reference->iv.len);
16427 : :
16428 : 4 : sym_op->cipher.data.length = reference->cipher_len;
16429 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
16430 : :
16431 : 4 : sym_op->auth.data.length = reference->plaintext.len;
16432 : 4 : sym_op->auth.data.offset = reference->auth_offset;
16433 : :
16434 : 4 : return 0;
16435 : : }
16436 : :
16437 : : static int
16438 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16439 : : struct crypto_unittest_params *ut_params,
16440 : : const struct test_crypto_vector *reference)
16441 : : {
16442 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
16443 : : }
16444 : :
16445 : : static int
16446 : : create_auth_verify_GMAC_operation(
16447 : : struct crypto_testsuite_params *ts_params,
16448 : : struct crypto_unittest_params *ut_params,
16449 : : const struct test_crypto_vector *reference)
16450 : : {
16451 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16452 : : }
16453 : :
16454 : : static int
16455 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16456 : : struct crypto_unittest_params *ut_params,
16457 : : const struct test_crypto_vector *reference)
16458 : : {
16459 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16460 : : }
16461 : :
16462 : : static int
16463 : 2 : test_authentication_verify_fail_when_data_corruption(
16464 : : struct crypto_testsuite_params *ts_params,
16465 : : struct crypto_unittest_params *ut_params,
16466 : : const struct test_crypto_vector *reference,
16467 : : unsigned int data_corrupted)
16468 : : {
16469 : : int retval;
16470 : :
16471 : : uint8_t *plaintext;
16472 : : struct rte_cryptodev_info dev_info;
16473 : :
16474 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16475 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16476 : :
16477 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16478 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16479 : : printf("Device doesn't support RAW data-path APIs.\n");
16480 : 0 : return TEST_SKIPPED;
16481 : : }
16482 : :
16483 : : /* Verify the capabilities */
16484 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16485 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16486 : 2 : cap_idx.algo.auth = reference->auth_algo;
16487 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16488 : : &cap_idx) == NULL)
16489 : : return TEST_SKIPPED;
16490 : :
16491 : :
16492 : : /* Create session */
16493 : 2 : retval = create_auth_session(ut_params,
16494 : 2 : ts_params->valid_devs[0],
16495 : : reference,
16496 : : RTE_CRYPTO_AUTH_OP_VERIFY);
16497 : :
16498 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16499 : : return TEST_SKIPPED;
16500 [ + - ]: 2 : if (retval < 0)
16501 : : return retval;
16502 : :
16503 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16504 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16505 : : "Failed to allocate input buffer in mempool");
16506 : :
16507 : : /* clear mbuf payload */
16508 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16509 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16510 : :
16511 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16512 : 2 : reference->plaintext.len);
16513 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16514 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16515 : :
16516 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16517 : 2 : reference->plaintext.len);
16518 : :
16519 : : /* Create operation */
16520 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
16521 : :
16522 [ + - ]: 2 : if (retval < 0)
16523 : : return retval;
16524 : :
16525 [ + + ]: 2 : if (data_corrupted)
16526 : : data_corruption(plaintext);
16527 : : else
16528 : 1 : tag_corruption(plaintext, reference->plaintext.len);
16529 : :
16530 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16531 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16532 : : ut_params->op);
16533 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16534 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16535 : : "authentication not failed");
16536 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16537 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16538 : : 0);
16539 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16540 : : return retval;
16541 : : } else {
16542 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16543 : : ut_params->op);
16544 : : }
16545 [ - + ]: 2 : if (ut_params->op == NULL)
16546 : : return 0;
16547 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16548 : 0 : return 0;
16549 : :
16550 : : return -1;
16551 : : }
16552 : :
16553 : : static int
16554 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
16555 : : struct crypto_testsuite_params *ts_params,
16556 : : struct crypto_unittest_params *ut_params,
16557 : : const struct test_crypto_vector *reference,
16558 : : unsigned int data_corrupted)
16559 : : {
16560 : : int retval;
16561 : : uint8_t *plaintext;
16562 : : struct rte_cryptodev_info dev_info;
16563 : :
16564 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16565 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16566 : :
16567 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16568 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16569 : : printf("Device doesn't support RAW data-path APIs.\n");
16570 : 0 : return TEST_SKIPPED;
16571 : : }
16572 : :
16573 : : /* Verify the capabilities */
16574 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16575 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16576 : 2 : cap_idx.algo.auth = reference->auth_algo;
16577 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16578 : : &cap_idx) == NULL)
16579 : : return TEST_SKIPPED;
16580 : :
16581 : : /* Create session */
16582 : 2 : retval = create_auth_cipher_session(ut_params,
16583 : 2 : ts_params->valid_devs[0],
16584 : : reference,
16585 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16586 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16587 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16588 : : return TEST_SKIPPED;
16589 [ + - ]: 2 : if (retval < 0)
16590 : : return retval;
16591 : :
16592 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16593 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16594 : : "Failed to allocate input buffer in mempool");
16595 : :
16596 : : /* clear mbuf payload */
16597 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16598 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16599 : :
16600 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16601 : 2 : reference->plaintext.len);
16602 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16603 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16604 : :
16605 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16606 : 2 : reference->plaintext.len);
16607 : :
16608 : : /* Create operation */
16609 : : retval = create_auth_verify_GMAC_operation(ts_params,
16610 : : ut_params,
16611 : : reference);
16612 : :
16613 [ + - ]: 2 : if (retval < 0)
16614 : : return retval;
16615 : :
16616 [ + + ]: 2 : if (data_corrupted)
16617 : : data_corruption(plaintext);
16618 : : else
16619 : 1 : tag_corruption(plaintext, reference->aad.len);
16620 : :
16621 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16622 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16623 : : ut_params->op);
16624 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16625 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16626 : : "authentication not failed");
16627 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16628 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16629 : : 0);
16630 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16631 : 0 : return retval;
16632 : : } else {
16633 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16634 : : ut_params->op);
16635 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16636 : : }
16637 : :
16638 : : return 0;
16639 : : }
16640 : :
16641 : : static int
16642 : 2 : test_authenticated_decryption_fail_when_corruption(
16643 : : struct crypto_testsuite_params *ts_params,
16644 : : struct crypto_unittest_params *ut_params,
16645 : : const struct test_crypto_vector *reference,
16646 : : unsigned int data_corrupted)
16647 : : {
16648 : : int retval;
16649 : :
16650 : : uint8_t *ciphertext;
16651 : : struct rte_cryptodev_info dev_info;
16652 : :
16653 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16654 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16655 : :
16656 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16657 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16658 : : printf("Device doesn't support RAW data-path APIs.\n");
16659 : 0 : return TEST_SKIPPED;
16660 : : }
16661 : :
16662 : : /* Verify the capabilities */
16663 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16664 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16665 : 2 : cap_idx.algo.auth = reference->auth_algo;
16666 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16667 : : &cap_idx) == NULL)
16668 : : return TEST_SKIPPED;
16669 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16670 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
16671 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16672 : : &cap_idx) == NULL)
16673 : : return TEST_SKIPPED;
16674 : :
16675 : : /* Create session */
16676 : 2 : retval = create_auth_cipher_session(ut_params,
16677 : 2 : ts_params->valid_devs[0],
16678 : : reference,
16679 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16680 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16681 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16682 : : return TEST_SKIPPED;
16683 [ + - ]: 2 : if (retval < 0)
16684 : : return retval;
16685 : :
16686 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16687 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16688 : : "Failed to allocate input buffer in mempool");
16689 : :
16690 : : /* clear mbuf payload */
16691 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16692 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16693 : :
16694 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16695 : 2 : reference->ciphertext.len);
16696 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16697 : 2 : memcpy(ciphertext, reference->ciphertext.data,
16698 : 2 : reference->ciphertext.len);
16699 : :
16700 : : /* Create operation */
16701 : : retval = create_cipher_auth_verify_operation(ts_params,
16702 : : ut_params,
16703 : : reference);
16704 : :
16705 [ + - ]: 2 : if (retval < 0)
16706 : : return retval;
16707 : :
16708 [ + + ]: 2 : if (data_corrupted)
16709 : : data_corruption(ciphertext);
16710 : : else
16711 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
16712 : :
16713 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16714 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16715 : : ut_params->op);
16716 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16717 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16718 : : "authentication not failed");
16719 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16720 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16721 : : 0);
16722 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16723 : 0 : return retval;
16724 : : } else {
16725 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16726 : : ut_params->op);
16727 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16728 : : }
16729 : :
16730 : : return 0;
16731 : : }
16732 : :
16733 : : static int
16734 : 1 : test_authenticated_encrypt_with_esn(
16735 : : struct crypto_testsuite_params *ts_params,
16736 : : struct crypto_unittest_params *ut_params,
16737 : : const struct test_crypto_vector *reference)
16738 : : {
16739 : : int retval;
16740 : :
16741 : : uint8_t *authciphertext, *plaintext, *auth_tag;
16742 : : uint16_t plaintext_pad_len;
16743 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16744 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16745 : : struct rte_cryptodev_info dev_info;
16746 : :
16747 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16748 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16749 : :
16750 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16751 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16752 : : printf("Device doesn't support RAW data-path APIs.\n");
16753 : 0 : return TEST_SKIPPED;
16754 : : }
16755 : :
16756 : : /* Verify the capabilities */
16757 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16758 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16759 : 1 : cap_idx.algo.auth = reference->auth_algo;
16760 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16761 : : &cap_idx) == NULL)
16762 : : return TEST_SKIPPED;
16763 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16764 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16765 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16766 : : &cap_idx) == NULL)
16767 : : return TEST_SKIPPED;
16768 : :
16769 : : /* Create session */
16770 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16771 : 1 : reference->cipher_key.len);
16772 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16773 : :
16774 : : /* Setup Cipher Parameters */
16775 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16776 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16777 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16778 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16779 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16780 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16781 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16782 : :
16783 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
16784 : :
16785 : : /* Setup Authentication Parameters */
16786 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16787 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16788 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16789 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16790 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16791 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16792 : 1 : ut_params->auth_xform.next = NULL;
16793 : :
16794 : : /* Create Crypto session*/
16795 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16796 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
16797 : : ts_params->session_mpool);
16798 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16799 : : return TEST_SKIPPED;
16800 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16801 : :
16802 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16803 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16804 : : "Failed to allocate input buffer in mempool");
16805 : :
16806 : : /* clear mbuf payload */
16807 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16808 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16809 : :
16810 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16811 : 1 : reference->plaintext.len);
16812 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16813 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16814 : :
16815 : : /* Create operation */
16816 : 1 : retval = create_cipher_auth_operation(ts_params,
16817 : : ut_params,
16818 : : reference, 0);
16819 : :
16820 [ + - ]: 1 : if (retval < 0)
16821 : : return retval;
16822 : :
16823 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16824 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16825 : : ut_params->op);
16826 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16827 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16828 : : 0);
16829 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16830 : : return retval;
16831 : : } else
16832 : 1 : ut_params->op = process_crypto_request(
16833 : 1 : ts_params->valid_devs[0], ut_params->op);
16834 : :
16835 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16836 : :
16837 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16838 : : "crypto op processing failed");
16839 : :
16840 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16841 : :
16842 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16843 : : ut_params->op->sym->auth.data.offset);
16844 : 1 : auth_tag = authciphertext + plaintext_pad_len;
16845 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
16846 : 1 : reference->ciphertext.len);
16847 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16848 : :
16849 : : /* Validate obuf */
16850 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16851 : : authciphertext,
16852 : : reference->ciphertext.data,
16853 : : reference->ciphertext.len,
16854 : : "Ciphertext data not as expected");
16855 : :
16856 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16857 : : auth_tag,
16858 : : reference->digest.data,
16859 : : reference->digest.len,
16860 : : "Generated digest not as expected");
16861 : :
16862 : : return TEST_SUCCESS;
16863 : :
16864 : : }
16865 : :
16866 : : static int
16867 : 1 : test_authenticated_decrypt_with_esn(
16868 : : struct crypto_testsuite_params *ts_params,
16869 : : struct crypto_unittest_params *ut_params,
16870 : : const struct test_crypto_vector *reference)
16871 : : {
16872 : : int retval;
16873 : :
16874 : : uint8_t *ciphertext;
16875 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16876 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16877 : : struct rte_cryptodev_info dev_info;
16878 : :
16879 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16880 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16881 : :
16882 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16883 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16884 : : printf("Device doesn't support RAW data-path APIs.\n");
16885 : 0 : return TEST_SKIPPED;
16886 : : }
16887 : :
16888 : : /* Verify the capabilities */
16889 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16890 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16891 : 1 : cap_idx.algo.auth = reference->auth_algo;
16892 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16893 : : &cap_idx) == NULL)
16894 : : return TEST_SKIPPED;
16895 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16896 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16897 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16898 : : &cap_idx) == NULL)
16899 : : return TEST_SKIPPED;
16900 : :
16901 : : /* Create session */
16902 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16903 : 1 : reference->cipher_key.len);
16904 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16905 : :
16906 : : /* Setup Authentication Parameters */
16907 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16908 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16909 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16910 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16911 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16912 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16913 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16914 : :
16915 : : /* Setup Cipher Parameters */
16916 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16917 : 1 : ut_params->cipher_xform.next = NULL;
16918 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16919 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16920 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16921 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16922 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16923 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16924 : :
16925 : : /* Create Crypto session*/
16926 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16927 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
16928 : : ts_params->session_mpool);
16929 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16930 : : return TEST_SKIPPED;
16931 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16932 : :
16933 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16934 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16935 : : "Failed to allocate input buffer in mempool");
16936 : :
16937 : : /* clear mbuf payload */
16938 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16939 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16940 : :
16941 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16942 : 1 : reference->ciphertext.len);
16943 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16944 : 1 : memcpy(ciphertext, reference->ciphertext.data,
16945 : 1 : reference->ciphertext.len);
16946 : :
16947 : : /* Create operation */
16948 : : retval = create_cipher_auth_verify_operation(ts_params,
16949 : : ut_params,
16950 : : reference);
16951 : :
16952 [ + - ]: 1 : if (retval < 0)
16953 : : return retval;
16954 : :
16955 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16956 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16957 : : ut_params->op);
16958 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16959 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16960 : : 0);
16961 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16962 : : return retval;
16963 : : } else
16964 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16965 : : ut_params->op);
16966 : :
16967 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16968 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
16969 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16970 : : "crypto op processing passed");
16971 : :
16972 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
16973 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16974 : :
16975 : : return 0;
16976 : : }
16977 : :
16978 : : static int
16979 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16980 : : const struct aead_test_data *tdata,
16981 : : void *digest_mem, uint64_t digest_phys)
16982 : : {
16983 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16984 : : struct crypto_unittest_params *ut_params = &unittest_params;
16985 : :
16986 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
16987 : 1 : const unsigned int iv_len = tdata->iv.len;
16988 : 1 : unsigned int aad_len = tdata->aad.len;
16989 : : unsigned int aad_len_pad = 0;
16990 : :
16991 : : /* Generate Crypto op data structure */
16992 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16993 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16994 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
16995 : : "Failed to allocate symmetric crypto operation struct");
16996 : :
16997 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16998 : :
16999 : 1 : sym_op->aead.digest.data = digest_mem;
17000 : :
17001 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
17002 : : "no room to append digest");
17003 : :
17004 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
17005 : :
17006 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
17007 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
17008 : : auth_tag_len);
17009 : 0 : debug_hexdump(stdout, "digest:",
17010 : 0 : sym_op->aead.digest.data,
17011 : : auth_tag_len);
17012 : : }
17013 : :
17014 : : /* Append aad data */
17015 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
17016 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17017 : : uint8_t *, IV_OFFSET);
17018 : :
17019 : : /* Copy IV 1 byte after the IV pointer, according to the API */
17020 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
17021 : :
17022 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
17023 : :
17024 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17025 : : ut_params->ibuf, aad_len);
17026 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17027 : : "no room to prepend aad");
17028 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17029 : : ut_params->ibuf);
17030 : :
17031 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
17032 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
17033 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17034 : :
17035 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17036 : 0 : debug_hexdump(stdout, "aad:",
17037 : 0 : sym_op->aead.aad.data, aad_len);
17038 : : } else {
17039 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17040 : : uint8_t *, IV_OFFSET);
17041 : :
17042 [ - + ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
17043 : :
17044 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
17045 : :
17046 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17047 : : ut_params->ibuf, aad_len_pad);
17048 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17049 : : "no room to prepend aad");
17050 [ - + ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17051 : : ut_params->ibuf);
17052 : :
17053 [ - + ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
17054 [ - + ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17055 : :
17056 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17057 : 1 : debug_hexdump(stdout, "aad:",
17058 : 1 : sym_op->aead.aad.data, aad_len);
17059 : : }
17060 : :
17061 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
17062 : 1 : sym_op->aead.data.offset = aad_len_pad;
17063 : :
17064 : 1 : return 0;
17065 : : }
17066 : :
17067 : : #define SGL_MAX_NO 16
17068 : :
17069 : : static int
17070 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
17071 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
17072 : : {
17073 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17074 : : struct crypto_unittest_params *ut_params = &unittest_params;
17075 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
17076 : : int retval;
17077 : : int to_trn = 0;
17078 : : int to_trn_tbl[SGL_MAX_NO];
17079 : : int segs = 1;
17080 : : unsigned int trn_data = 0;
17081 : : uint8_t *plaintext, *ciphertext, *auth_tag;
17082 : : struct rte_cryptodev_info dev_info;
17083 : :
17084 : : /* Verify the capabilities */
17085 : : struct rte_cryptodev_sym_capability_idx cap_idx;
17086 : : const struct rte_cryptodev_symmetric_capability *capability;
17087 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
17088 : 3 : cap_idx.algo.aead = tdata->algo;
17089 : 3 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
17090 [ + - ]: 3 : if (capability == NULL)
17091 : : return TEST_SKIPPED;
17092 [ + - ]: 3 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
17093 : 3 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
17094 : : return TEST_SKIPPED;
17095 : :
17096 : : /*
17097 : : * SGL not supported on AESNI_MB PMD CPU crypto,
17098 : : * OOP not supported on AESNI_GCM CPU crypto
17099 : : */
17100 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
17101 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
17102 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
17103 : : return TEST_SKIPPED;
17104 : :
17105 : : /* Detailed check for the particular SGL support flag */
17106 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
17107 [ - + ]: 3 : if (!oop) {
17108 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17109 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
17110 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
17111 : : return TEST_SKIPPED;
17112 : :
17113 : 0 : uint64_t feat_flags = dev_info.feature_flags;
17114 : :
17115 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
17116 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
17117 : : printf("Device doesn't support RAW data-path APIs.\n");
17118 : 0 : return TEST_SKIPPED;
17119 : : }
17120 : : } else {
17121 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17122 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
17123 : : tdata->plaintext.len;
17124 : : /* Raw data path API does not support OOP */
17125 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
17126 : : return TEST_SKIPPED;
17127 [ + + ]: 3 : if (sgl_in && !sgl_out) {
17128 [ + - ]: 1 : if (!(dev_info.feature_flags &
17129 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
17130 : : return TEST_SKIPPED;
17131 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
17132 [ # # ]: 0 : if (!(dev_info.feature_flags &
17133 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
17134 : : return TEST_SKIPPED;
17135 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
17136 [ - + ]: 2 : if (!(dev_info.feature_flags &
17137 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
17138 : : return TEST_SKIPPED;
17139 : : }
17140 : : }
17141 : :
17142 : 1 : if (fragsz > tdata->plaintext.len)
17143 : : fragsz = tdata->plaintext.len;
17144 : :
17145 : 1 : uint16_t plaintext_len = fragsz;
17146 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
17147 : :
17148 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
17149 : 0 : frag_size_oop = tdata->plaintext.len;
17150 : :
17151 : : int ecx = 0;
17152 : : void *digest_mem = NULL;
17153 : :
17154 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
17155 : :
17156 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
17157 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
17158 : : return 1;
17159 : : } else {
17160 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
17161 : : return 1;
17162 : : }
17163 : :
17164 : : /*
17165 : : * For out-of-place we need to alloc another mbuf
17166 : : */
17167 [ + - ]: 1 : if (oop) {
17168 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17169 : : rte_pktmbuf_append(ut_params->obuf,
17170 : 1 : frag_size_oop + prepend_len);
17171 : 1 : buf_oop = ut_params->obuf;
17172 : : }
17173 : :
17174 : : /* Create AEAD session */
17175 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
17176 : 1 : tdata->algo,
17177 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
17178 : 1 : tdata->key.data, tdata->key.len,
17179 : 1 : tdata->aad.len, tdata->auth_tag.len,
17180 : 1 : tdata->iv.len);
17181 [ + - ]: 1 : if (retval < 0)
17182 : : return retval;
17183 : :
17184 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17185 : :
17186 : : /* clear mbuf payload */
17187 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
17188 : : rte_pktmbuf_tailroom(ut_params->ibuf));
17189 : :
17190 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17191 : : plaintext_len);
17192 : :
17193 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
17194 : :
17195 : : trn_data += plaintext_len;
17196 : :
17197 : 1 : buf = ut_params->ibuf;
17198 : :
17199 : : /*
17200 : : * Loop until no more fragments
17201 : : */
17202 : :
17203 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
17204 : 5 : ++segs;
17205 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
17206 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
17207 : :
17208 : 5 : to_trn_tbl[ecx++] = to_trn;
17209 : :
17210 [ - + ]: 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17211 : : buf = buf->next;
17212 : :
17213 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
17214 : : rte_pktmbuf_tailroom(buf));
17215 : :
17216 : : /* OOP */
17217 [ - + ]: 5 : if (oop && !fragsz_oop) {
17218 : 0 : buf_last_oop = buf_oop->next =
17219 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17220 : : buf_oop = buf_oop->next;
17221 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17222 : : 0, rte_pktmbuf_tailroom(buf_oop));
17223 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
17224 : : }
17225 : :
17226 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
17227 : : to_trn);
17228 : :
17229 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
17230 : : to_trn);
17231 : 5 : trn_data += to_trn;
17232 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
17233 [ + - ]: 1 : if (oop) {
17234 [ - + ]: 1 : if (!fragsz_oop)
17235 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
17236 : 0 : tdata->auth_tag.len);
17237 : : } else
17238 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
17239 : 0 : tdata->auth_tag.len);
17240 : : }
17241 : : }
17242 : :
17243 : : uint64_t digest_phys = 0;
17244 : :
17245 : 1 : ut_params->ibuf->nb_segs = segs;
17246 : :
17247 : : segs = 1;
17248 [ + - ]: 1 : if (fragsz_oop && oop) {
17249 : : to_trn = 0;
17250 : : ecx = 0;
17251 : :
17252 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
17253 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17254 : 1 : tdata->auth_tag.len);
17255 : :
17256 : 1 : digest_phys = rte_pktmbuf_iova_offset(
17257 : : ut_params->obuf,
17258 : : tdata->plaintext.len + prepend_len);
17259 : : }
17260 : :
17261 : : trn_data = frag_size_oop;
17262 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
17263 : 0 : ++segs;
17264 : 0 : to_trn =
17265 : 0 : (tdata->plaintext.len - trn_data <
17266 : : frag_size_oop) ?
17267 : 0 : (tdata->plaintext.len - trn_data) :
17268 : : frag_size_oop;
17269 : :
17270 : 0 : to_trn_tbl[ecx++] = to_trn;
17271 : :
17272 : 0 : buf_last_oop = buf_oop->next =
17273 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17274 : : buf_oop = buf_oop->next;
17275 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17276 : : 0, rte_pktmbuf_tailroom(buf_oop));
17277 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
17278 : :
17279 : 0 : trn_data += to_trn;
17280 : :
17281 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
17282 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
17283 : 0 : tdata->auth_tag.len);
17284 : : }
17285 : : }
17286 : :
17287 : 1 : ut_params->obuf->nb_segs = segs;
17288 : : }
17289 : :
17290 : : /*
17291 : : * Place digest at the end of the last buffer
17292 : : */
17293 [ - + ]: 1 : if (!digest_phys)
17294 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
17295 [ - + ]: 1 : if (oop && buf_last_oop)
17296 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
17297 : :
17298 [ - + ]: 1 : if (!digest_mem && !oop) {
17299 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17300 : 0 : + tdata->auth_tag.len);
17301 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
17302 : : tdata->plaintext.len);
17303 : : }
17304 : :
17305 : : /* Create AEAD operation */
17306 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
17307 : : tdata, digest_mem, digest_phys);
17308 : :
17309 [ + - ]: 1 : if (retval < 0)
17310 : : return retval;
17311 : :
17312 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
17313 : :
17314 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
17315 [ + - ]: 1 : if (oop)
17316 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
17317 : :
17318 : : /* Process crypto operation */
17319 [ - + ]: 1 : if (oop == IN_PLACE &&
17320 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17321 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
17322 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17323 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
17324 : : 0);
17325 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17326 : : return retval;
17327 : : } else
17328 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
17329 : : process_crypto_request(ts_params->valid_devs[0],
17330 : : ut_params->op), "failed to process sym crypto op");
17331 : :
17332 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17333 : : "crypto op processing failed");
17334 : :
17335 : :
17336 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17337 : : uint8_t *, prepend_len);
17338 [ + - ]: 1 : if (oop) {
17339 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17340 : : uint8_t *, prepend_len);
17341 : : }
17342 : :
17343 [ + - ]: 1 : if (fragsz_oop)
17344 : : fragsz = fragsz_oop;
17345 : :
17346 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17347 : : ciphertext,
17348 : : tdata->ciphertext.data,
17349 : : fragsz,
17350 : : "Ciphertext data not as expected");
17351 : :
17352 : 1 : buf = ut_params->op->sym->m_src->next;
17353 [ + - ]: 1 : if (oop)
17354 : 1 : buf = ut_params->op->sym->m_dst->next;
17355 : :
17356 : : unsigned int off = fragsz;
17357 : :
17358 : : ecx = 0;
17359 [ - + ]: 1 : while (buf) {
17360 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
17361 : : uint8_t *);
17362 : :
17363 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17364 : : ciphertext,
17365 : : tdata->ciphertext.data + off,
17366 : : to_trn_tbl[ecx],
17367 : : "Ciphertext data not as expected");
17368 : :
17369 : 0 : off += to_trn_tbl[ecx++];
17370 : 0 : buf = buf->next;
17371 : : }
17372 : :
17373 : : auth_tag = digest_mem;
17374 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17375 : : auth_tag,
17376 : : tdata->auth_tag.data,
17377 : : tdata->auth_tag.len,
17378 : : "Generated auth tag not as expected");
17379 : :
17380 : : return 0;
17381 : : }
17382 : :
17383 : : static int
17384 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17385 : : {
17386 : 1 : return test_authenticated_encryption_SGL(
17387 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17388 : : }
17389 : :
17390 : : static int
17391 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17392 : : {
17393 : 1 : return test_authenticated_encryption_SGL(
17394 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17395 : : }
17396 : :
17397 : : static int
17398 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17399 : : {
17400 : 1 : return test_authenticated_encryption_SGL(
17401 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
17402 : : gcm_test_case_8.plaintext.len);
17403 : : }
17404 : :
17405 : : static int
17406 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17407 : : {
17408 : : /* This test is not for OPENSSL PMD */
17409 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17410 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17411 : : return TEST_SKIPPED;
17412 : :
17413 : 0 : return test_authenticated_encryption_SGL(
17414 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17415 : : }
17416 : :
17417 : : static int
17418 : : test_authentication_verify_fail_when_data_corrupted(
17419 : : struct crypto_testsuite_params *ts_params,
17420 : : struct crypto_unittest_params *ut_params,
17421 : : const struct test_crypto_vector *reference)
17422 : : {
17423 : 1 : return test_authentication_verify_fail_when_data_corruption(
17424 : : ts_params, ut_params, reference, 1);
17425 : : }
17426 : :
17427 : : static int
17428 : : test_authentication_verify_fail_when_tag_corrupted(
17429 : : struct crypto_testsuite_params *ts_params,
17430 : : struct crypto_unittest_params *ut_params,
17431 : : const struct test_crypto_vector *reference)
17432 : : {
17433 : 1 : return test_authentication_verify_fail_when_data_corruption(
17434 : : ts_params, ut_params, reference, 0);
17435 : : }
17436 : :
17437 : : static int
17438 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
17439 : : struct crypto_testsuite_params *ts_params,
17440 : : struct crypto_unittest_params *ut_params,
17441 : : const struct test_crypto_vector *reference)
17442 : : {
17443 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17444 : : ts_params, ut_params, reference, 1);
17445 : : }
17446 : :
17447 : : static int
17448 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
17449 : : struct crypto_testsuite_params *ts_params,
17450 : : struct crypto_unittest_params *ut_params,
17451 : : const struct test_crypto_vector *reference)
17452 : : {
17453 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17454 : : ts_params, ut_params, reference, 0);
17455 : : }
17456 : :
17457 : : static int
17458 : : test_authenticated_decryption_fail_when_data_corrupted(
17459 : : struct crypto_testsuite_params *ts_params,
17460 : : struct crypto_unittest_params *ut_params,
17461 : : const struct test_crypto_vector *reference)
17462 : : {
17463 : 1 : return test_authenticated_decryption_fail_when_corruption(
17464 : : ts_params, ut_params, reference, 1);
17465 : : }
17466 : :
17467 : : static int
17468 : : test_authenticated_decryption_fail_when_tag_corrupted(
17469 : : struct crypto_testsuite_params *ts_params,
17470 : : struct crypto_unittest_params *ut_params,
17471 : : const struct test_crypto_vector *reference)
17472 : : {
17473 : 1 : return test_authenticated_decryption_fail_when_corruption(
17474 : : ts_params, ut_params, reference, 0);
17475 : : }
17476 : :
17477 : : static int
17478 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17479 : : {
17480 : 1 : return test_authentication_verify_fail_when_data_corrupted(
17481 : : &testsuite_params, &unittest_params,
17482 : : &hmac_sha1_test_crypto_vector);
17483 : : }
17484 : :
17485 : : static int
17486 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17487 : : {
17488 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
17489 : : &testsuite_params, &unittest_params,
17490 : : &hmac_sha1_test_crypto_vector);
17491 : : }
17492 : :
17493 : : static int
17494 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17495 : : {
17496 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
17497 : : &testsuite_params, &unittest_params,
17498 : : &aes128_gmac_test_vector);
17499 : : }
17500 : :
17501 : : static int
17502 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17503 : : {
17504 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17505 : : &testsuite_params, &unittest_params,
17506 : : &aes128_gmac_test_vector);
17507 : : }
17508 : :
17509 : : static int
17510 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17511 : : {
17512 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
17513 : : &testsuite_params,
17514 : : &unittest_params,
17515 : : &aes128cbc_hmac_sha1_test_vector);
17516 : : }
17517 : :
17518 : : static int
17519 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17520 : : {
17521 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
17522 : : &testsuite_params,
17523 : : &unittest_params,
17524 : : &aes128cbc_hmac_sha1_test_vector);
17525 : : }
17526 : :
17527 : : static int
17528 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17529 : : {
17530 : 1 : return test_authenticated_encrypt_with_esn(
17531 : : &testsuite_params,
17532 : : &unittest_params,
17533 : : &aes128cbc_hmac_sha1_aad_test_vector);
17534 : : }
17535 : :
17536 : : static int
17537 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17538 : : {
17539 : 1 : return test_authenticated_decrypt_with_esn(
17540 : : &testsuite_params,
17541 : : &unittest_params,
17542 : : &aes128cbc_hmac_sha1_aad_test_vector);
17543 : : }
17544 : :
17545 : : static int
17546 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17547 : : {
17548 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17549 : : }
17550 : :
17551 : : static int
17552 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17553 : : {
17554 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17555 : : }
17556 : :
17557 : : static int
17558 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17559 : : {
17560 : 0 : return test_authenticated_encryption_SGL(
17561 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17562 : : chacha20_poly1305_case_2.plaintext.len);
17563 : : }
17564 : :
17565 : : static int
17566 : 0 : test_SM4_GCM_case_1(void)
17567 : : {
17568 : 0 : return test_authenticated_encryption(&sm4_gcm_case_1);
17569 : : }
17570 : :
17571 : : static int
17572 : 0 : test_SM4_GCM_case_2(void)
17573 : : {
17574 : 0 : return test_authenticated_encryption(&sm4_gcm_case_2);
17575 : : }
17576 : :
17577 : : static int
17578 : 0 : test_SM4_GCM_case_3(void)
17579 : : {
17580 : 0 : return test_authenticated_encryption(&sm4_gcm_case_3);
17581 : : }
17582 : :
17583 : : static int
17584 : 0 : test_SM4_GCM_case_4(void)
17585 : : {
17586 : 0 : return test_authenticated_encryption(&sm4_gcm_case_4);
17587 : : }
17588 : :
17589 : : static int
17590 : 0 : test_SM4_GCM_case_5(void)
17591 : : {
17592 : 0 : return test_authenticated_encryption(&sm4_gcm_case_5);
17593 : : }
17594 : :
17595 : : static int
17596 : 0 : test_SM4_GCM_case_6(void)
17597 : : {
17598 : 0 : return test_authenticated_encryption(&sm4_gcm_case_6);
17599 : : }
17600 : :
17601 : : static int
17602 : 0 : test_SM4_GCM_case_7(void)
17603 : : {
17604 : 0 : return test_authenticated_encryption(&sm4_gcm_case_7);
17605 : : }
17606 : :
17607 : : static int
17608 : 0 : test_SM4_GCM_case_8(void)
17609 : : {
17610 : 0 : return test_authenticated_encryption(&sm4_gcm_case_8);
17611 : : }
17612 : :
17613 : : static int
17614 : 0 : test_SM4_GCM_case_9(void)
17615 : : {
17616 : 0 : return test_authenticated_encryption(&sm4_gcm_case_9);
17617 : : }
17618 : :
17619 : : static int
17620 : 0 : test_SM4_GCM_case_10(void)
17621 : : {
17622 : 0 : return test_authenticated_encryption(&sm4_gcm_case_10);
17623 : : }
17624 : :
17625 : : static int
17626 : 0 : test_SM4_GCM_case_11(void)
17627 : : {
17628 : 0 : return test_authenticated_encryption(&sm4_gcm_case_11);
17629 : : }
17630 : :
17631 : : static int
17632 : 0 : test_SM4_GCM_case_12(void)
17633 : : {
17634 : 0 : return test_authenticated_encryption(&sm4_gcm_case_12);
17635 : : }
17636 : :
17637 : : static int
17638 : 0 : test_SM4_GCM_case_13(void)
17639 : : {
17640 : 0 : return test_authenticated_encryption(&sm4_gcm_case_13);
17641 : : }
17642 : :
17643 : : static int
17644 : 0 : test_SM4_GCM_case_14(void)
17645 : : {
17646 : 0 : return test_authenticated_encryption(&sm4_gcm_case_14);
17647 : : }
17648 : :
17649 : : static int
17650 : 0 : test_SM4_GCM_case_15(void)
17651 : : {
17652 : 0 : return test_authenticated_encryption(&sm4_gcm_case_15);
17653 : : }
17654 : :
17655 : : #ifdef RTE_CRYPTO_SCHEDULER
17656 : :
17657 : : /* global AESNI worker IDs for the scheduler test */
17658 : : uint8_t aesni_ids[2];
17659 : :
17660 : : static int
17661 : 0 : scheduler_testsuite_setup(void)
17662 : : {
17663 : : uint32_t i = 0;
17664 : : int32_t nb_devs, ret;
17665 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
17666 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17667 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
17668 : : uint16_t worker_core_count = 0;
17669 : : uint16_t socket_id = 0;
17670 : :
17671 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17672 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17673 : :
17674 : : /* Identify the Worker Cores
17675 : : * Use 2 worker cores for the device args
17676 : : */
17677 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
17678 [ # # ]: 0 : if (worker_core_count > 1)
17679 : : break;
17680 : : snprintf(vdev_args, sizeof(vdev_args),
17681 : : "%s%d", temp_str, i);
17682 : : strcpy(temp_str, vdev_args);
17683 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
17684 : 0 : worker_core_count++;
17685 : 0 : socket_id = rte_lcore_to_socket_id(i);
17686 : : }
17687 [ # # ]: 0 : if (worker_core_count != 2) {
17688 : 0 : RTE_LOG(ERR, USER1,
17689 : : "Cryptodev scheduler test require at least "
17690 : : "two worker cores to run. "
17691 : : "Please use the correct coremask.\n");
17692 : 0 : return TEST_FAILED;
17693 : : }
17694 : : strcpy(temp_str, vdev_args);
17695 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
17696 : : temp_str, socket_id);
17697 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17698 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
17699 : 0 : rte_cryptodev_driver_id_get(
17700 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17701 [ # # ]: 0 : if (nb_devs < 1) {
17702 : 0 : ret = rte_vdev_init(
17703 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17704 : : vdev_args);
17705 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17706 : : "Failed to create instance %u of pmd : %s",
17707 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17708 : : }
17709 : : }
17710 : 0 : return testsuite_setup();
17711 : : }
17712 : :
17713 : : static int
17714 : 0 : test_scheduler_attach_worker_op(void)
17715 : : {
17716 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17717 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17718 : : uint32_t i, nb_devs_attached = 0;
17719 : : int ret;
17720 : : char vdev_name[32];
17721 : 0 : unsigned int count = rte_cryptodev_count();
17722 : :
17723 : : /* create 2 AESNI_MB vdevs on top of existing devices */
17724 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17725 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17726 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17727 : : i);
17728 : 0 : ret = rte_vdev_init(vdev_name, NULL);
17729 : :
17730 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17731 : : "Failed to create instance %u of"
17732 : : " pmd : %s",
17733 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17734 : :
17735 : : if (ret < 0) {
17736 : : RTE_LOG(ERR, USER1,
17737 : : "Failed to create 2 AESNI MB PMDs.\n");
17738 : : return TEST_SKIPPED;
17739 : : }
17740 : : }
17741 : :
17742 : : /* attach 2 AESNI_MB cdevs */
17743 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17744 : : struct rte_cryptodev_info info;
17745 : : unsigned int session_size;
17746 : :
17747 : 0 : rte_cryptodev_info_get(i, &info);
17748 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
17749 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17750 : 0 : continue;
17751 : :
17752 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
17753 : : /*
17754 : : * Create the session mempool again, since now there are new devices
17755 : : * to use the mempool.
17756 : : */
17757 [ # # ]: 0 : if (ts_params->session_mpool) {
17758 : 0 : rte_mempool_free(ts_params->session_mpool);
17759 : 0 : ts_params->session_mpool = NULL;
17760 : : }
17761 : :
17762 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
17763 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17764 : 0 : RTE_LOG(ERR, USER1,
17765 : : "Device does not support "
17766 : : "at least %u sessions\n",
17767 : : MAX_NB_SESSIONS);
17768 : 0 : return TEST_FAILED;
17769 : : }
17770 : : /*
17771 : : * Create mempool with maximum number of sessions,
17772 : : * to include the session headers
17773 : : */
17774 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
17775 : 0 : ts_params->session_mpool =
17776 : 0 : rte_cryptodev_sym_session_pool_create(
17777 : : "test_sess_mp",
17778 : : MAX_NB_SESSIONS, session_size,
17779 : : 0, 0, SOCKET_ID_ANY);
17780 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17781 : : "session mempool allocation failed");
17782 : : }
17783 : :
17784 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
17785 : :
17786 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17787 : : (uint8_t)i);
17788 : :
17789 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17790 : : "Failed to attach device %u of pmd : %s", i,
17791 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17792 : :
17793 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
17794 : :
17795 : 0 : nb_devs_attached++;
17796 : : }
17797 : :
17798 : : return 0;
17799 : : }
17800 : :
17801 : : static int
17802 : 0 : test_scheduler_detach_worker_op(void)
17803 : : {
17804 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17805 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17806 : : uint32_t i;
17807 : : int ret;
17808 : :
17809 [ # # ]: 0 : for (i = 0; i < 2; i++) {
17810 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17811 : 0 : aesni_ids[i]);
17812 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17813 : : "Failed to detach device %u", aesni_ids[i]);
17814 : : }
17815 : :
17816 : : return 0;
17817 : : }
17818 : :
17819 : : static int
17820 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17821 : : {
17822 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17823 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17824 : : /* set mode */
17825 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
17826 : : scheduler_mode);
17827 : : }
17828 : :
17829 : : static int
17830 : 0 : test_scheduler_mode_roundrobin_op(void)
17831 : : {
17832 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17833 : : 0, "Failed to set roundrobin mode");
17834 : : return 0;
17835 : :
17836 : : }
17837 : :
17838 : : static int
17839 : 0 : test_scheduler_mode_multicore_op(void)
17840 : : {
17841 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17842 : : 0, "Failed to set multicore mode");
17843 : :
17844 : : return 0;
17845 : : }
17846 : :
17847 : : static int
17848 : 0 : test_scheduler_mode_failover_op(void)
17849 : : {
17850 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17851 : : 0, "Failed to set failover mode");
17852 : :
17853 : : return 0;
17854 : : }
17855 : :
17856 : : static int
17857 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
17858 : : {
17859 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17860 : : 0, "Failed to set pktsize mode");
17861 : :
17862 : : return 0;
17863 : : }
17864 : :
17865 : : static int
17866 : 0 : scheduler_multicore_testsuite_setup(void)
17867 : : {
17868 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17869 : : return TEST_SKIPPED;
17870 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17871 : 0 : return TEST_SKIPPED;
17872 : : return 0;
17873 : : }
17874 : :
17875 : : static int
17876 : 0 : scheduler_roundrobin_testsuite_setup(void)
17877 : : {
17878 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17879 : : return TEST_SKIPPED;
17880 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17881 : 0 : return TEST_SKIPPED;
17882 : : return 0;
17883 : : }
17884 : :
17885 : : static int
17886 : 0 : scheduler_failover_testsuite_setup(void)
17887 : : {
17888 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17889 : : return TEST_SKIPPED;
17890 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17891 : 0 : return TEST_SKIPPED;
17892 : : return 0;
17893 : : }
17894 : :
17895 : : static int
17896 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
17897 : : {
17898 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17899 : : return TEST_SKIPPED;
17900 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17901 : 0 : return TEST_SKIPPED;
17902 : : return 0;
17903 : : }
17904 : :
17905 : : static void
17906 : 0 : scheduler_mode_testsuite_teardown(void)
17907 : : {
17908 : 0 : test_scheduler_detach_worker_op();
17909 : 0 : }
17910 : :
17911 : : #endif /* RTE_CRYPTO_SCHEDULER */
17912 : :
17913 : : static struct unit_test_suite end_testsuite = {
17914 : : .suite_name = NULL,
17915 : : .setup = NULL,
17916 : : .teardown = NULL,
17917 : : .unit_test_suites = NULL
17918 : : };
17919 : :
17920 : : #ifdef RTE_LIB_SECURITY
17921 : : static struct unit_test_suite ipsec_proto_testsuite = {
17922 : : .suite_name = "IPsec Proto Unit Test Suite",
17923 : : .setup = ipsec_proto_testsuite_setup,
17924 : : .unit_test_cases = {
17925 : : TEST_CASE_NAMED_WITH_DATA(
17926 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17927 : : ut_setup_security, ut_teardown,
17928 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17929 : : TEST_CASE_NAMED_WITH_DATA(
17930 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17931 : : ut_setup_security, ut_teardown,
17932 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17933 : : TEST_CASE_NAMED_WITH_DATA(
17934 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17935 : : ut_setup_security, ut_teardown,
17936 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17937 : : TEST_CASE_NAMED_WITH_DATA(
17938 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17939 : : ut_setup_security, ut_teardown,
17940 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17941 : : TEST_CASE_NAMED_WITH_DATA(
17942 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17943 : : ut_setup_security, ut_teardown,
17944 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17945 : : TEST_CASE_NAMED_WITH_DATA(
17946 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17947 : : ut_setup_security, ut_teardown,
17948 : : test_ipsec_proto_known_vec,
17949 : : &pkt_aes_128_cbc_md5),
17950 : : TEST_CASE_NAMED_WITH_DATA(
17951 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17952 : : ut_setup_security, ut_teardown,
17953 : : test_ipsec_proto_known_vec,
17954 : : &pkt_aes_128_cbc_hmac_sha256),
17955 : : TEST_CASE_NAMED_WITH_DATA(
17956 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17957 : : ut_setup_security, ut_teardown,
17958 : : test_ipsec_proto_known_vec,
17959 : : &pkt_aes_128_cbc_hmac_sha384),
17960 : : TEST_CASE_NAMED_WITH_DATA(
17961 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17962 : : ut_setup_security, ut_teardown,
17963 : : test_ipsec_proto_known_vec,
17964 : : &pkt_aes_128_cbc_hmac_sha512),
17965 : : TEST_CASE_NAMED_WITH_DATA(
17966 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17967 : : ut_setup_security, ut_teardown,
17968 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
17969 : : TEST_CASE_NAMED_WITH_DATA(
17970 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17971 : : ut_setup_security, ut_teardown,
17972 : : test_ipsec_proto_known_vec,
17973 : : &pkt_aes_128_cbc_hmac_sha256_v6),
17974 : : TEST_CASE_NAMED_WITH_DATA(
17975 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17976 : : ut_setup_security, ut_teardown,
17977 : : test_ipsec_proto_known_vec,
17978 : : &pkt_null_aes_xcbc),
17979 : : TEST_CASE_NAMED_WITH_DATA(
17980 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17981 : : ut_setup_security, ut_teardown,
17982 : : test_ipsec_proto_known_vec,
17983 : : &pkt_des_cbc_hmac_sha256),
17984 : : TEST_CASE_NAMED_WITH_DATA(
17985 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17986 : : ut_setup_security, ut_teardown,
17987 : : test_ipsec_proto_known_vec,
17988 : : &pkt_des_cbc_hmac_sha384),
17989 : : TEST_CASE_NAMED_WITH_DATA(
17990 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17991 : : ut_setup_security, ut_teardown,
17992 : : test_ipsec_proto_known_vec,
17993 : : &pkt_des_cbc_hmac_sha512),
17994 : : TEST_CASE_NAMED_WITH_DATA(
17995 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17996 : : ut_setup_security, ut_teardown,
17997 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
17998 : : TEST_CASE_NAMED_WITH_DATA(
17999 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18000 : : ut_setup_security, ut_teardown,
18001 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
18002 : : TEST_CASE_NAMED_WITH_DATA(
18003 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18004 : : ut_setup_security, ut_teardown,
18005 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
18006 : : TEST_CASE_NAMED_WITH_DATA(
18007 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18008 : : ut_setup_security, ut_teardown,
18009 : : test_ipsec_proto_known_vec,
18010 : : &pkt_des_cbc_hmac_sha256_v6),
18011 : : TEST_CASE_NAMED_WITH_DATA(
18012 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18013 : : ut_setup_security, ut_teardown,
18014 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
18015 : : TEST_CASE_NAMED_WITH_DATA(
18016 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18017 : : ut_setup_security, ut_teardown,
18018 : : test_ipsec_proto_known_vec,
18019 : : &pkt_ah_tunnel_sha256),
18020 : : TEST_CASE_NAMED_WITH_DATA(
18021 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18022 : : ut_setup_security, ut_teardown,
18023 : : test_ipsec_proto_known_vec,
18024 : : &pkt_ah_transport_sha256),
18025 : : TEST_CASE_NAMED_WITH_DATA(
18026 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18027 : : ut_setup_security, ut_teardown,
18028 : : test_ipsec_proto_known_vec,
18029 : : &pkt_ah_ipv4_aes_gmac_128),
18030 : : TEST_CASE_NAMED_WITH_DATA(
18031 : : "Outbound fragmented packet",
18032 : : ut_setup_security, ut_teardown,
18033 : : test_ipsec_proto_known_vec_fragmented,
18034 : : &pkt_aes_128_gcm_frag),
18035 : : TEST_CASE_NAMED_WITH_DATA(
18036 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
18037 : : ut_setup_security, ut_teardown,
18038 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
18039 : : TEST_CASE_NAMED_WITH_DATA(
18040 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
18041 : : ut_setup_security, ut_teardown,
18042 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
18043 : : TEST_CASE_NAMED_WITH_DATA(
18044 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
18045 : : ut_setup_security, ut_teardown,
18046 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
18047 : : TEST_CASE_NAMED_WITH_DATA(
18048 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
18049 : : ut_setup_security, ut_teardown,
18050 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
18051 : : TEST_CASE_NAMED_WITH_DATA(
18052 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
18053 : : ut_setup_security, ut_teardown,
18054 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
18055 : : TEST_CASE_NAMED_WITH_DATA(
18056 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
18057 : : ut_setup_security, ut_teardown,
18058 : : test_ipsec_proto_known_vec_inb,
18059 : : &pkt_aes_128_cbc_md5),
18060 : : TEST_CASE_NAMED_WITH_DATA(
18061 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18062 : : ut_setup_security, ut_teardown,
18063 : : test_ipsec_proto_known_vec_inb,
18064 : : &pkt_aes_128_cbc_hmac_sha256),
18065 : : TEST_CASE_NAMED_WITH_DATA(
18066 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18067 : : ut_setup_security, ut_teardown,
18068 : : test_ipsec_proto_known_vec_inb,
18069 : : &pkt_aes_128_cbc_hmac_sha384),
18070 : : TEST_CASE_NAMED_WITH_DATA(
18071 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18072 : : ut_setup_security, ut_teardown,
18073 : : test_ipsec_proto_known_vec_inb,
18074 : : &pkt_aes_128_cbc_hmac_sha512),
18075 : : TEST_CASE_NAMED_WITH_DATA(
18076 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18077 : : ut_setup_security, ut_teardown,
18078 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
18079 : : TEST_CASE_NAMED_WITH_DATA(
18080 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18081 : : ut_setup_security, ut_teardown,
18082 : : test_ipsec_proto_known_vec_inb,
18083 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18084 : : TEST_CASE_NAMED_WITH_DATA(
18085 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18086 : : ut_setup_security, ut_teardown,
18087 : : test_ipsec_proto_known_vec_inb,
18088 : : &pkt_null_aes_xcbc),
18089 : : TEST_CASE_NAMED_WITH_DATA(
18090 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18091 : : ut_setup_security, ut_teardown,
18092 : : test_ipsec_proto_known_vec_inb,
18093 : : &pkt_des_cbc_hmac_sha256),
18094 : : TEST_CASE_NAMED_WITH_DATA(
18095 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18096 : : ut_setup_security, ut_teardown,
18097 : : test_ipsec_proto_known_vec_inb,
18098 : : &pkt_des_cbc_hmac_sha384),
18099 : : TEST_CASE_NAMED_WITH_DATA(
18100 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18101 : : ut_setup_security, ut_teardown,
18102 : : test_ipsec_proto_known_vec_inb,
18103 : : &pkt_des_cbc_hmac_sha512),
18104 : : TEST_CASE_NAMED_WITH_DATA(
18105 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18106 : : ut_setup_security, ut_teardown,
18107 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
18108 : : TEST_CASE_NAMED_WITH_DATA(
18109 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18110 : : ut_setup_security, ut_teardown,
18111 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
18112 : : TEST_CASE_NAMED_WITH_DATA(
18113 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18114 : : ut_setup_security, ut_teardown,
18115 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
18116 : : TEST_CASE_NAMED_WITH_DATA(
18117 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18118 : : ut_setup_security, ut_teardown,
18119 : : test_ipsec_proto_known_vec_inb,
18120 : : &pkt_des_cbc_hmac_sha256_v6),
18121 : : TEST_CASE_NAMED_WITH_DATA(
18122 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18123 : : ut_setup_security, ut_teardown,
18124 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
18125 : : TEST_CASE_NAMED_WITH_DATA(
18126 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18127 : : ut_setup_security, ut_teardown,
18128 : : test_ipsec_proto_known_vec_inb,
18129 : : &pkt_ah_tunnel_sha256),
18130 : : TEST_CASE_NAMED_WITH_DATA(
18131 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18132 : : ut_setup_security, ut_teardown,
18133 : : test_ipsec_proto_known_vec_inb,
18134 : : &pkt_ah_transport_sha256),
18135 : : TEST_CASE_NAMED_WITH_DATA(
18136 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18137 : : ut_setup_security, ut_teardown,
18138 : : test_ipsec_proto_known_vec_inb,
18139 : : &pkt_ah_ipv4_aes_gmac_128),
18140 : : TEST_CASE_NAMED_ST(
18141 : : "Combined test alg list",
18142 : : ut_setup_security, ut_teardown,
18143 : : test_ipsec_proto_display_list),
18144 : : TEST_CASE_NAMED_ST(
18145 : : "Combined test alg list (AH)",
18146 : : ut_setup_security, ut_teardown,
18147 : : test_ipsec_proto_ah_tunnel_ipv4),
18148 : : TEST_CASE_NAMED_ST(
18149 : : "IV generation",
18150 : : ut_setup_security, ut_teardown,
18151 : : test_ipsec_proto_iv_gen),
18152 : : TEST_CASE_NAMED_ST(
18153 : : "UDP encapsulation",
18154 : : ut_setup_security, ut_teardown,
18155 : : test_ipsec_proto_udp_encap),
18156 : : TEST_CASE_NAMED_ST(
18157 : : "UDP encapsulation with custom ports",
18158 : : ut_setup_security, ut_teardown,
18159 : : test_ipsec_proto_udp_encap_custom_ports),
18160 : : TEST_CASE_NAMED_ST(
18161 : : "UDP encapsulation ports verification test",
18162 : : ut_setup_security, ut_teardown,
18163 : : test_ipsec_proto_udp_ports_verify),
18164 : : TEST_CASE_NAMED_ST(
18165 : : "SA expiry packets soft",
18166 : : ut_setup_security, ut_teardown,
18167 : : test_ipsec_proto_sa_exp_pkts_soft),
18168 : : TEST_CASE_NAMED_ST(
18169 : : "SA expiry packets hard",
18170 : : ut_setup_security, ut_teardown,
18171 : : test_ipsec_proto_sa_exp_pkts_hard),
18172 : : TEST_CASE_NAMED_ST(
18173 : : "Negative test: ICV corruption",
18174 : : ut_setup_security, ut_teardown,
18175 : : test_ipsec_proto_err_icv_corrupt),
18176 : : TEST_CASE_NAMED_ST(
18177 : : "Tunnel dst addr verification",
18178 : : ut_setup_security, ut_teardown,
18179 : : test_ipsec_proto_tunnel_dst_addr_verify),
18180 : : TEST_CASE_NAMED_ST(
18181 : : "Tunnel src and dst addr verification",
18182 : : ut_setup_security, ut_teardown,
18183 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
18184 : : TEST_CASE_NAMED_ST(
18185 : : "Inner IP checksum",
18186 : : ut_setup_security, ut_teardown,
18187 : : test_ipsec_proto_inner_ip_csum),
18188 : : TEST_CASE_NAMED_ST(
18189 : : "Inner L4 checksum",
18190 : : ut_setup_security, ut_teardown,
18191 : : test_ipsec_proto_inner_l4_csum),
18192 : : TEST_CASE_NAMED_ST(
18193 : : "Tunnel IPv4 in IPv4",
18194 : : ut_setup_security, ut_teardown,
18195 : : test_ipsec_proto_tunnel_v4_in_v4),
18196 : : TEST_CASE_NAMED_ST(
18197 : : "Tunnel IPv6 in IPv6",
18198 : : ut_setup_security, ut_teardown,
18199 : : test_ipsec_proto_tunnel_v6_in_v6),
18200 : : TEST_CASE_NAMED_ST(
18201 : : "Tunnel IPv4 in IPv6",
18202 : : ut_setup_security, ut_teardown,
18203 : : test_ipsec_proto_tunnel_v4_in_v6),
18204 : : TEST_CASE_NAMED_ST(
18205 : : "Tunnel IPv6 in IPv4",
18206 : : ut_setup_security, ut_teardown,
18207 : : test_ipsec_proto_tunnel_v6_in_v4),
18208 : : TEST_CASE_NAMED_ST(
18209 : : "Transport IPv4",
18210 : : ut_setup_security, ut_teardown,
18211 : : test_ipsec_proto_transport_v4),
18212 : : TEST_CASE_NAMED_ST(
18213 : : "AH transport IPv4",
18214 : : ut_setup_security, ut_teardown,
18215 : : test_ipsec_proto_ah_transport_ipv4),
18216 : : TEST_CASE_NAMED_ST(
18217 : : "Transport l4 checksum",
18218 : : ut_setup_security, ut_teardown,
18219 : : test_ipsec_proto_transport_l4_csum),
18220 : : TEST_CASE_NAMED_ST(
18221 : : "Statistics: success",
18222 : : ut_setup_security, ut_teardown,
18223 : : test_ipsec_proto_stats),
18224 : : TEST_CASE_NAMED_ST(
18225 : : "Fragmented packet",
18226 : : ut_setup_security, ut_teardown,
18227 : : test_ipsec_proto_pkt_fragment),
18228 : : TEST_CASE_NAMED_ST(
18229 : : "Tunnel header copy DF (inner 0)",
18230 : : ut_setup_security, ut_teardown,
18231 : : test_ipsec_proto_copy_df_inner_0),
18232 : : TEST_CASE_NAMED_ST(
18233 : : "Tunnel header copy DF (inner 1)",
18234 : : ut_setup_security, ut_teardown,
18235 : : test_ipsec_proto_copy_df_inner_1),
18236 : : TEST_CASE_NAMED_ST(
18237 : : "Tunnel header set DF 0 (inner 1)",
18238 : : ut_setup_security, ut_teardown,
18239 : : test_ipsec_proto_set_df_0_inner_1),
18240 : : TEST_CASE_NAMED_ST(
18241 : : "Tunnel header set DF 1 (inner 0)",
18242 : : ut_setup_security, ut_teardown,
18243 : : test_ipsec_proto_set_df_1_inner_0),
18244 : : TEST_CASE_NAMED_ST(
18245 : : "Tunnel header IPv4 copy DSCP (inner 0)",
18246 : : ut_setup_security, ut_teardown,
18247 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
18248 : : TEST_CASE_NAMED_ST(
18249 : : "Tunnel header IPv4 copy DSCP (inner 1)",
18250 : : ut_setup_security, ut_teardown,
18251 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
18252 : : TEST_CASE_NAMED_ST(
18253 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
18254 : : ut_setup_security, ut_teardown,
18255 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
18256 : : TEST_CASE_NAMED_ST(
18257 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
18258 : : ut_setup_security, ut_teardown,
18259 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
18260 : : TEST_CASE_NAMED_ST(
18261 : : "Tunnel header IPv6 copy DSCP (inner 0)",
18262 : : ut_setup_security, ut_teardown,
18263 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
18264 : : TEST_CASE_NAMED_ST(
18265 : : "Tunnel header IPv6 copy DSCP (inner 1)",
18266 : : ut_setup_security, ut_teardown,
18267 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
18268 : : TEST_CASE_NAMED_ST(
18269 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
18270 : : ut_setup_security, ut_teardown,
18271 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
18272 : : TEST_CASE_NAMED_ST(
18273 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
18274 : : ut_setup_security, ut_teardown,
18275 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
18276 : : TEST_CASE_NAMED_WITH_DATA(
18277 : : "Antireplay with window size 1024",
18278 : : ut_setup_security, ut_teardown,
18279 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
18280 : : TEST_CASE_NAMED_WITH_DATA(
18281 : : "Antireplay with window size 2048",
18282 : : ut_setup_security, ut_teardown,
18283 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
18284 : : TEST_CASE_NAMED_WITH_DATA(
18285 : : "Antireplay with window size 4096",
18286 : : ut_setup_security, ut_teardown,
18287 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
18288 : : TEST_CASE_NAMED_WITH_DATA(
18289 : : "ESN and Antireplay with window size 1024",
18290 : : ut_setup_security, ut_teardown,
18291 : : test_ipsec_proto_pkt_esn_antireplay1024,
18292 : : &pkt_aes_128_gcm),
18293 : : TEST_CASE_NAMED_WITH_DATA(
18294 : : "ESN and Antireplay with window size 2048",
18295 : : ut_setup_security, ut_teardown,
18296 : : test_ipsec_proto_pkt_esn_antireplay2048,
18297 : : &pkt_aes_128_gcm),
18298 : : TEST_CASE_NAMED_WITH_DATA(
18299 : : "ESN and Antireplay with window size 4096",
18300 : : ut_setup_security, ut_teardown,
18301 : : test_ipsec_proto_pkt_esn_antireplay4096,
18302 : : &pkt_aes_128_gcm),
18303 : : TEST_CASE_NAMED_ST(
18304 : : "Tunnel header IPv4 decrement inner TTL",
18305 : : ut_setup_security, ut_teardown,
18306 : : test_ipsec_proto_ipv4_ttl_decrement),
18307 : : TEST_CASE_NAMED_ST(
18308 : : "Tunnel header IPv6 decrement inner hop limit",
18309 : : ut_setup_security, ut_teardown,
18310 : : test_ipsec_proto_ipv6_hop_limit_decrement),
18311 : : TEST_CASE_NAMED_ST(
18312 : : "Multi-segmented mode",
18313 : : ut_setup_security, ut_teardown,
18314 : : test_ipsec_proto_sgl),
18315 : : TEST_CASE_NAMED_ST(
18316 : : "Multi-segmented external mbuf mode",
18317 : : ut_setup_security, ut_teardown,
18318 : : test_ipsec_proto_sgl_ext_mbuf),
18319 : : TEST_CASE_NAMED_WITH_DATA(
18320 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
18321 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18322 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
18323 : : TEST_CASES_END() /**< NULL terminate unit test array */
18324 : : }
18325 : : };
18326 : :
18327 : : static struct unit_test_suite pdcp_proto_testsuite = {
18328 : : .suite_name = "PDCP Proto Unit Test Suite",
18329 : : .setup = pdcp_proto_testsuite_setup,
18330 : : .unit_test_cases = {
18331 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
18332 : : test_PDCP_PROTO_all),
18333 : : TEST_CASES_END() /**< NULL terminate unit test array */
18334 : : }
18335 : : };
18336 : :
18337 : : static struct unit_test_suite tls12_record_proto_testsuite = {
18338 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
18339 : : .setup = tls_record_proto_testsuite_setup,
18340 : : .unit_test_cases = {
18341 : : TEST_CASE_NAMED_WITH_DATA(
18342 : : "Write record known vector AES-GCM-128 (vector 1)",
18343 : : ut_setup_security, ut_teardown,
18344 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
18345 : : TEST_CASE_NAMED_WITH_DATA(
18346 : : "Write record known vector AES-GCM-128 (vector 2)",
18347 : : ut_setup_security, ut_teardown,
18348 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
18349 : : TEST_CASE_NAMED_WITH_DATA(
18350 : : "Write record known vector AES-GCM-256",
18351 : : ut_setup_security, ut_teardown,
18352 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
18353 : : TEST_CASE_NAMED_WITH_DATA(
18354 : : "Write record known vector AES-CBC-128-SHA1",
18355 : : ut_setup_security, ut_teardown,
18356 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
18357 : : TEST_CASE_NAMED_WITH_DATA(
18358 : : "Write record known vector AES-128-CBC-SHA256",
18359 : : ut_setup_security, ut_teardown,
18360 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
18361 : : TEST_CASE_NAMED_WITH_DATA(
18362 : : "Write record known vector AES-256-CBC-SHA1",
18363 : : ut_setup_security, ut_teardown,
18364 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
18365 : : TEST_CASE_NAMED_WITH_DATA(
18366 : : "Write record known vector AES-256-CBC-SHA256",
18367 : : ut_setup_security, ut_teardown,
18368 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
18369 : : TEST_CASE_NAMED_WITH_DATA(
18370 : : "Write record known vector AES-256-CBC-SHA384",
18371 : : ut_setup_security, ut_teardown,
18372 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
18373 : : TEST_CASE_NAMED_WITH_DATA(
18374 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18375 : : ut_setup_security, ut_teardown,
18376 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
18377 : : TEST_CASE_NAMED_WITH_DATA(
18378 : : "Write record known vector NULL-SHA1-HMAC",
18379 : : ut_setup_security, ut_teardown,
18380 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
18381 : : TEST_CASE_NAMED_WITH_DATA(
18382 : : "Write record known vector CHACHA20-POLY1305",
18383 : : ut_setup_security, ut_teardown,
18384 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
18385 : :
18386 : : TEST_CASE_NAMED_WITH_DATA(
18387 : : "Read record known vector AES-GCM-128 (vector 1)",
18388 : : ut_setup_security, ut_teardown,
18389 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
18390 : : TEST_CASE_NAMED_WITH_DATA(
18391 : : "Read record known vector AES-GCM-128 (vector 2)",
18392 : : ut_setup_security, ut_teardown,
18393 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
18394 : : TEST_CASE_NAMED_WITH_DATA(
18395 : : "Read record known vector AES-GCM-256",
18396 : : ut_setup_security, ut_teardown,
18397 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
18398 : : TEST_CASE_NAMED_WITH_DATA(
18399 : : "Read record known vector AES-128-CBC-SHA1",
18400 : : ut_setup_security, ut_teardown,
18401 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
18402 : : TEST_CASE_NAMED_WITH_DATA(
18403 : : "Read record known vector AES-128-CBC-SHA256",
18404 : : ut_setup_security, ut_teardown,
18405 : : test_tls_record_proto_known_vec_read,
18406 : : &tls_test_data_aes_128_cbc_sha256_hmac),
18407 : : TEST_CASE_NAMED_WITH_DATA(
18408 : : "Read record known vector AES-256-CBC-SHA1",
18409 : : ut_setup_security, ut_teardown,
18410 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
18411 : : TEST_CASE_NAMED_WITH_DATA(
18412 : : "Read record known vector AES-256-CBC-SHA256",
18413 : : ut_setup_security, ut_teardown,
18414 : : test_tls_record_proto_known_vec_read,
18415 : : &tls_test_data_aes_256_cbc_sha256_hmac),
18416 : : TEST_CASE_NAMED_WITH_DATA(
18417 : : "Read record known vector AES-256-CBC-SHA384",
18418 : : ut_setup_security, ut_teardown,
18419 : : test_tls_record_proto_known_vec_read,
18420 : : &tls_test_data_aes_256_cbc_sha384_hmac),
18421 : : TEST_CASE_NAMED_WITH_DATA(
18422 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18423 : : ut_setup_security, ut_teardown,
18424 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18425 : : TEST_CASE_NAMED_WITH_DATA(
18426 : : "Read record known vector NULL-SHA1-HMAC",
18427 : : ut_setup_security, ut_teardown,
18428 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18429 : : TEST_CASE_NAMED_WITH_DATA(
18430 : : "Read record known vector CHACHA20-POLY1305",
18431 : : ut_setup_security, ut_teardown,
18432 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18433 : :
18434 : : TEST_CASE_NAMED_ST(
18435 : : "Combined test alg list",
18436 : : ut_setup_security, ut_teardown,
18437 : : test_tls_1_2_record_proto_display_list),
18438 : : TEST_CASE_NAMED_ST(
18439 : : "Data walkthrough combined test alg list",
18440 : : ut_setup_security, ut_teardown,
18441 : : test_tls_1_2_record_proto_data_walkthrough),
18442 : : TEST_CASE_NAMED_ST(
18443 : : "Multi-segmented mode",
18444 : : ut_setup_security, ut_teardown,
18445 : : test_tls_1_2_record_proto_sgl),
18446 : : TEST_CASE_NAMED_ST(
18447 : : "Multi-segmented mode data walkthrough",
18448 : : ut_setup_security, ut_teardown,
18449 : : test_tls_1_2_record_proto_sgl_data_walkthrough),
18450 : : TEST_CASE_NAMED_ST(
18451 : : "Multi-segmented mode out of place",
18452 : : ut_setup_security, ut_teardown,
18453 : : test_tls_1_2_record_proto_sgl_oop),
18454 : : TEST_CASE_NAMED_ST(
18455 : : "TLS packet header corruption",
18456 : : ut_setup_security, ut_teardown,
18457 : : test_tls_record_proto_corrupt_pkt),
18458 : : TEST_CASE_NAMED_ST(
18459 : : "Custom content type",
18460 : : ut_setup_security, ut_teardown,
18461 : : test_tls_record_proto_custom_content_type),
18462 : : TEST_CASE_NAMED_ST(
18463 : : "Zero len TLS record with content type as app",
18464 : : ut_setup_security, ut_teardown,
18465 : : test_tls_record_proto_zero_len),
18466 : : TEST_CASE_NAMED_ST(
18467 : : "Zero len TLS record with content type as ctrl",
18468 : : ut_setup_security, ut_teardown,
18469 : : test_tls_record_proto_zero_len_non_app),
18470 : : TEST_CASE_NAMED_ST(
18471 : : "TLS record DM mode with optional padding < 2 blocks",
18472 : : ut_setup_security, ut_teardown,
18473 : : test_tls_record_proto_dm_opt_padding),
18474 : : TEST_CASE_NAMED_ST(
18475 : : "TLS record DM mode with optional padding > 2 blocks",
18476 : : ut_setup_security, ut_teardown,
18477 : : test_tls_record_proto_dm_opt_padding_1),
18478 : : TEST_CASE_NAMED_ST(
18479 : : "TLS record SG mode with optional padding < 2 blocks",
18480 : : ut_setup_security, ut_teardown,
18481 : : test_tls_record_proto_sg_opt_padding),
18482 : : TEST_CASE_NAMED_ST(
18483 : : "TLS record SG mode with optional padding > 2 blocks",
18484 : : ut_setup_security, ut_teardown,
18485 : : test_tls_record_proto_sg_opt_padding_1),
18486 : : TEST_CASE_NAMED_ST(
18487 : : "TLS record SG mode with optional padding > 2 blocks",
18488 : : ut_setup_security, ut_teardown,
18489 : : test_tls_record_proto_sg_opt_padding_2),
18490 : : TEST_CASE_NAMED_ST(
18491 : : "TLS record SG mode with optional padding > max range",
18492 : : ut_setup_security, ut_teardown,
18493 : : test_tls_record_proto_sg_opt_padding_max),
18494 : : TEST_CASE_NAMED_ST(
18495 : : "TLS record SG mode with padding corruption",
18496 : : ut_setup_security, ut_teardown,
18497 : : test_tls_record_proto_sg_opt_padding_corrupt),
18498 : : TEST_CASES_END() /**< NULL terminate unit test array */
18499 : : }
18500 : : };
18501 : :
18502 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
18503 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18504 : : .setup = tls_record_proto_testsuite_setup,
18505 : : .unit_test_cases = {
18506 : : TEST_CASE_NAMED_WITH_DATA(
18507 : : "Write record known vector AES-GCM-128",
18508 : : ut_setup_security, ut_teardown,
18509 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18510 : : TEST_CASE_NAMED_WITH_DATA(
18511 : : "Write record known vector AES-GCM-256",
18512 : : ut_setup_security, ut_teardown,
18513 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18514 : : TEST_CASE_NAMED_WITH_DATA(
18515 : : "Write record known vector AES-128-CBC-SHA1",
18516 : : ut_setup_security, ut_teardown,
18517 : : test_tls_record_proto_known_vec,
18518 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18519 : : TEST_CASE_NAMED_WITH_DATA(
18520 : : "Write record known vector AES-128-CBC-SHA256",
18521 : : ut_setup_security, ut_teardown,
18522 : : test_tls_record_proto_known_vec,
18523 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18524 : : TEST_CASE_NAMED_WITH_DATA(
18525 : : "Write record known vector AES-256-CBC-SHA1",
18526 : : ut_setup_security, ut_teardown,
18527 : : test_tls_record_proto_known_vec,
18528 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18529 : : TEST_CASE_NAMED_WITH_DATA(
18530 : : "Write record known vector AES-256-CBC-SHA256",
18531 : : ut_setup_security, ut_teardown,
18532 : : test_tls_record_proto_known_vec,
18533 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18534 : : TEST_CASE_NAMED_WITH_DATA(
18535 : : "Write record known vector AES-256-CBC-SHA384",
18536 : : ut_setup_security, ut_teardown,
18537 : : test_tls_record_proto_known_vec,
18538 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18539 : : TEST_CASE_NAMED_WITH_DATA(
18540 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18541 : : ut_setup_security, ut_teardown,
18542 : : test_tls_record_proto_known_vec,
18543 : : &dtls_test_data_3des_cbc_sha1_hmac),
18544 : : TEST_CASE_NAMED_WITH_DATA(
18545 : : "Write record known vector NULL-SHA1-HMAC",
18546 : : ut_setup_security, ut_teardown,
18547 : : test_tls_record_proto_known_vec,
18548 : : &dtls_test_data_null_cipher_sha1_hmac),
18549 : : TEST_CASE_NAMED_WITH_DATA(
18550 : : "Write record known vector CHACHA20-POLY1305",
18551 : : ut_setup_security, ut_teardown,
18552 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18553 : : TEST_CASE_NAMED_WITH_DATA(
18554 : : "Read record known vector AES-GCM-128",
18555 : : ut_setup_security, ut_teardown,
18556 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18557 : : TEST_CASE_NAMED_WITH_DATA(
18558 : : "Read record known vector AES-GCM-256",
18559 : : ut_setup_security, ut_teardown,
18560 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18561 : : TEST_CASE_NAMED_WITH_DATA(
18562 : : "Read record known vector AES-128-CBC-SHA1",
18563 : : ut_setup_security, ut_teardown,
18564 : : test_tls_record_proto_known_vec_read,
18565 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18566 : : TEST_CASE_NAMED_WITH_DATA(
18567 : : "Read record known vector AES-128-CBC-SHA256",
18568 : : ut_setup_security, ut_teardown,
18569 : : test_tls_record_proto_known_vec_read,
18570 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18571 : : TEST_CASE_NAMED_WITH_DATA(
18572 : : "Read record known vector AES-256-CBC-SHA1",
18573 : : ut_setup_security, ut_teardown,
18574 : : test_tls_record_proto_known_vec_read,
18575 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18576 : : TEST_CASE_NAMED_WITH_DATA(
18577 : : "Read record known vector AES-256-CBC-SHA256",
18578 : : ut_setup_security, ut_teardown,
18579 : : test_tls_record_proto_known_vec_read,
18580 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18581 : : TEST_CASE_NAMED_WITH_DATA(
18582 : : "Read record known vector AES-256-CBC-SHA384",
18583 : : ut_setup_security, ut_teardown,
18584 : : test_tls_record_proto_known_vec_read,
18585 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18586 : : TEST_CASE_NAMED_WITH_DATA(
18587 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18588 : : ut_setup_security, ut_teardown,
18589 : : test_tls_record_proto_known_vec_read,
18590 : : &dtls_test_data_3des_cbc_sha1_hmac),
18591 : : TEST_CASE_NAMED_WITH_DATA(
18592 : : "Read record known vector NULL-SHA1-HMAC",
18593 : : ut_setup_security, ut_teardown,
18594 : : test_tls_record_proto_known_vec_read,
18595 : : &dtls_test_data_null_cipher_sha1_hmac),
18596 : : TEST_CASE_NAMED_WITH_DATA(
18597 : : "Read record known vector CHACHA20-POLY1305",
18598 : : ut_setup_security, ut_teardown,
18599 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18600 : :
18601 : : TEST_CASE_NAMED_ST(
18602 : : "Combined test alg list",
18603 : : ut_setup_security, ut_teardown,
18604 : : test_dtls_1_2_record_proto_display_list),
18605 : : TEST_CASE_NAMED_ST(
18606 : : "Data walkthrough combined test alg list",
18607 : : ut_setup_security, ut_teardown,
18608 : : test_dtls_1_2_record_proto_data_walkthrough),
18609 : : TEST_CASE_NAMED_ST(
18610 : : "Multi-segmented mode",
18611 : : ut_setup_security, ut_teardown,
18612 : : test_dtls_1_2_record_proto_sgl),
18613 : : TEST_CASE_NAMED_ST(
18614 : : "Multi-segmented mode data walkthrough",
18615 : : ut_setup_security, ut_teardown,
18616 : : test_dtls_1_2_record_proto_sgl_data_walkthrough),
18617 : : TEST_CASE_NAMED_ST(
18618 : : "Multi-segmented mode out of place",
18619 : : ut_setup_security, ut_teardown,
18620 : : test_dtls_1_2_record_proto_sgl_oop),
18621 : : TEST_CASE_NAMED_ST(
18622 : : "Packet corruption",
18623 : : ut_setup_security, ut_teardown,
18624 : : test_dtls_1_2_record_proto_corrupt_pkt),
18625 : : TEST_CASE_NAMED_ST(
18626 : : "Custom content type",
18627 : : ut_setup_security, ut_teardown,
18628 : : test_dtls_1_2_record_proto_custom_content_type),
18629 : : TEST_CASE_NAMED_ST(
18630 : : "Zero len DTLS record with content type as app",
18631 : : ut_setup_security, ut_teardown,
18632 : : test_dtls_1_2_record_proto_zero_len),
18633 : : TEST_CASE_NAMED_ST(
18634 : : "Zero len DTLS record with content type as ctrl",
18635 : : ut_setup_security, ut_teardown,
18636 : : test_dtls_1_2_record_proto_zero_len_non_app),
18637 : : TEST_CASE_NAMED_ST(
18638 : : "Antireplay with window size 64",
18639 : : ut_setup_security, ut_teardown,
18640 : : test_dtls_1_2_record_proto_antireplay64),
18641 : : TEST_CASE_NAMED_ST(
18642 : : "Antireplay with window size 128",
18643 : : ut_setup_security, ut_teardown,
18644 : : test_dtls_1_2_record_proto_antireplay128),
18645 : : TEST_CASE_NAMED_ST(
18646 : : "Antireplay with window size 256",
18647 : : ut_setup_security, ut_teardown,
18648 : : test_dtls_1_2_record_proto_antireplay256),
18649 : : TEST_CASE_NAMED_ST(
18650 : : "Antireplay with window size 512",
18651 : : ut_setup_security, ut_teardown,
18652 : : test_dtls_1_2_record_proto_antireplay512),
18653 : : TEST_CASE_NAMED_ST(
18654 : : "Antireplay with window size 1024",
18655 : : ut_setup_security, ut_teardown,
18656 : : test_dtls_1_2_record_proto_antireplay1024),
18657 : : TEST_CASE_NAMED_ST(
18658 : : "Antireplay with window size 2048",
18659 : : ut_setup_security, ut_teardown,
18660 : : test_dtls_1_2_record_proto_antireplay2048),
18661 : : TEST_CASE_NAMED_ST(
18662 : : "Antireplay with window size 4096",
18663 : : ut_setup_security, ut_teardown,
18664 : : test_dtls_1_2_record_proto_antireplay4096),
18665 : : TEST_CASE_NAMED_ST(
18666 : : "DTLS record DM mode with optional padding < 2 blocks",
18667 : : ut_setup_security, ut_teardown,
18668 : : test_dtls_1_2_record_proto_dm_opt_padding),
18669 : : TEST_CASE_NAMED_ST(
18670 : : "DTLS record DM mode with optional padding > 2 blocks",
18671 : : ut_setup_security, ut_teardown,
18672 : : test_dtls_1_2_record_proto_dm_opt_padding_1),
18673 : : TEST_CASE_NAMED_ST(
18674 : : "DTLS record SG mode with optional padding < 2 blocks",
18675 : : ut_setup_security, ut_teardown,
18676 : : test_dtls_1_2_record_proto_sg_opt_padding),
18677 : : TEST_CASE_NAMED_ST(
18678 : : "DTLS record SG mode with optional padding > 2 blocks",
18679 : : ut_setup_security, ut_teardown,
18680 : : test_dtls_1_2_record_proto_sg_opt_padding_1),
18681 : : TEST_CASE_NAMED_ST(
18682 : : "DTLS record SG mode with optional padding > 2 blocks",
18683 : : ut_setup_security, ut_teardown,
18684 : : test_dtls_1_2_record_proto_sg_opt_padding_2),
18685 : : TEST_CASE_NAMED_ST(
18686 : : "DTLS record SG mode with optional padding > max range",
18687 : : ut_setup_security, ut_teardown,
18688 : : test_dtls_1_2_record_proto_sg_opt_padding_max),
18689 : : TEST_CASE_NAMED_ST(
18690 : : "DTLS record SG mode with padding corruption",
18691 : : ut_setup_security, ut_teardown,
18692 : : test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18693 : : TEST_CASES_END() /**< NULL terminate unit test array */
18694 : : }
18695 : : };
18696 : :
18697 : : static struct unit_test_suite tls13_record_proto_testsuite = {
18698 : : .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18699 : : .setup = tls_record_proto_testsuite_setup,
18700 : : .unit_test_cases = {
18701 : : TEST_CASE_NAMED_WITH_DATA(
18702 : : "Write record known vector AES-GCM-128",
18703 : : ut_setup_security, ut_teardown,
18704 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18705 : : TEST_CASE_NAMED_WITH_DATA(
18706 : : "Write record known vector AES-GCM-256",
18707 : : ut_setup_security, ut_teardown,
18708 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18709 : : TEST_CASE_NAMED_WITH_DATA(
18710 : : "Write record known vector CHACHA20-POLY1305",
18711 : : ut_setup_security, ut_teardown,
18712 : : test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18713 : :
18714 : : TEST_CASE_NAMED_WITH_DATA(
18715 : : "Read record known vector AES-GCM-128",
18716 : : ut_setup_security, ut_teardown,
18717 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18718 : : TEST_CASE_NAMED_WITH_DATA(
18719 : : "Read record known vector AES-GCM-256",
18720 : : ut_setup_security, ut_teardown,
18721 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18722 : : TEST_CASE_NAMED_WITH_DATA(
18723 : : "Read record known vector CHACHA20-POLY1305",
18724 : : ut_setup_security, ut_teardown,
18725 : : test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18726 : : TEST_CASE_NAMED_ST(
18727 : : "TLS-1.3 record header corruption",
18728 : : ut_setup_security, ut_teardown,
18729 : : test_tls_1_3_record_proto_corrupt_pkt),
18730 : : TEST_CASE_NAMED_ST(
18731 : : "TLS-1.3 record header with custom content type",
18732 : : ut_setup_security, ut_teardown,
18733 : : test_tls_1_3_record_proto_custom_content_type),
18734 : : TEST_CASE_NAMED_ST(
18735 : : "TLS-1.3 record with zero len and content type as app",
18736 : : ut_setup_security, ut_teardown,
18737 : : test_tls_1_3_record_proto_zero_len),
18738 : : TEST_CASE_NAMED_ST(
18739 : : "TLS-1.3 record with zero len and content type as ctrl",
18740 : : ut_setup_security, ut_teardown,
18741 : : test_tls_1_3_record_proto_zero_len_non_app),
18742 : : TEST_CASE_NAMED_ST(
18743 : : "TLS-1.3 record DM mode with optional padding",
18744 : : ut_setup_security, ut_teardown,
18745 : : test_tls_1_3_record_proto_dm_opt_padding),
18746 : : TEST_CASE_NAMED_ST(
18747 : : "TLS-1.3 record SG mode with optional padding - 1",
18748 : : ut_setup_security, ut_teardown,
18749 : : test_tls_1_3_record_proto_sg_opt_padding),
18750 : : TEST_CASE_NAMED_ST(
18751 : : "TLS-1.3 record SG mode with optional padding",
18752 : : ut_setup_security, ut_teardown,
18753 : : test_tls_1_3_record_proto_sg_opt_padding_1),
18754 : : TEST_CASE_NAMED_ST(
18755 : : "Combined test alg list",
18756 : : ut_setup_security, ut_teardown,
18757 : : test_tls_1_3_record_proto_display_list),
18758 : : TEST_CASE_NAMED_ST(
18759 : : "Data walkthrough combined test alg list",
18760 : : ut_setup_security, ut_teardown,
18761 : : test_tls_1_3_record_proto_data_walkthrough),
18762 : : TEST_CASE_NAMED_ST(
18763 : : "Multi-segmented mode",
18764 : : ut_setup_security, ut_teardown,
18765 : : test_tls_1_3_record_proto_sgl),
18766 : : TEST_CASE_NAMED_ST(
18767 : : "Multi-segmented mode data walkthrough",
18768 : : ut_setup_security, ut_teardown,
18769 : : test_tls_1_3_record_proto_sgl_data_walkthrough),
18770 : : TEST_CASE_NAMED_ST(
18771 : : "Multi-segmented mode out of place",
18772 : : ut_setup_security, ut_teardown,
18773 : : test_tls_1_3_record_proto_sgl_oop),
18774 : : TEST_CASES_END() /**< NULL terminate unit test array */
18775 : : }
18776 : : };
18777 : :
18778 : : #define ADD_UPLINK_TESTCASE(data) \
18779 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
18780 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
18781 : :
18782 : : #define ADD_DOWNLINK_TESTCASE(data) \
18783 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
18784 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
18785 : :
18786 : : static struct unit_test_suite docsis_proto_testsuite = {
18787 : : .suite_name = "DOCSIS Proto Unit Test Suite",
18788 : : .setup = docsis_proto_testsuite_setup,
18789 : : .unit_test_cases = {
18790 : : /* Uplink */
18791 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
18792 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
18793 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
18794 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
18795 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
18796 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
18797 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
18798 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
18799 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
18800 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
18801 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
18802 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
18803 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
18804 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
18805 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
18806 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
18807 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
18808 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
18809 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
18810 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
18811 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
18812 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
18813 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
18814 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
18815 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
18816 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
18817 : : /* Downlink */
18818 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18819 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18820 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18821 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18822 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18823 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18824 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18825 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18826 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18827 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18828 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18829 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18830 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18831 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18832 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18833 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18834 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18835 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18836 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18837 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18838 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18839 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18840 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18841 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18842 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18843 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18844 : : TEST_CASES_END() /**< NULL terminate unit test array */
18845 : : }
18846 : : };
18847 : : #endif
18848 : :
18849 : : static struct unit_test_suite cryptodev_gen_testsuite = {
18850 : : .suite_name = "Crypto General Unit Test Suite",
18851 : : .setup = crypto_gen_testsuite_setup,
18852 : : .unit_test_cases = {
18853 : : TEST_CASE_ST(ut_setup, ut_teardown,
18854 : : test_device_reconfigure),
18855 : : TEST_CASE_ST(ut_setup, ut_teardown,
18856 : : test_device_configure_invalid_dev_id),
18857 : : TEST_CASE_ST(ut_setup, ut_teardown,
18858 : : test_queue_pair_descriptor_setup),
18859 : : TEST_CASE_ST(ut_setup, ut_teardown,
18860 : : test_device_configure_invalid_queue_pair_ids),
18861 : : TEST_CASE_ST(ut_setup, ut_teardown,
18862 : : test_queue_pair_descriptor_count),
18863 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18864 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18865 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18866 : : TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
18867 : : test_cryptodev_verify_error_recover, &aes_test_data_4),
18868 : : TEST_CASES_END() /**< NULL terminate unit test array */
18869 : : }
18870 : : };
18871 : :
18872 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18873 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
18874 : : .setup = negative_hmac_sha1_testsuite_setup,
18875 : : .unit_test_cases = {
18876 : : /** Negative tests */
18877 : : TEST_CASE_ST(ut_setup, ut_teardown,
18878 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
18879 : : TEST_CASE_ST(ut_setup, ut_teardown,
18880 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18881 : : TEST_CASE_ST(ut_setup, ut_teardown,
18882 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18883 : : TEST_CASE_ST(ut_setup, ut_teardown,
18884 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18885 : :
18886 : : TEST_CASES_END() /**< NULL terminate unit test array */
18887 : : }
18888 : : };
18889 : :
18890 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
18891 : : .suite_name = "Multi Session Unit Test Suite",
18892 : : .setup = multi_session_testsuite_setup,
18893 : : .unit_test_cases = {
18894 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18895 : : TEST_CASE_ST(ut_setup, ut_teardown,
18896 : : test_multi_session_random_usage),
18897 : :
18898 : : TEST_CASES_END() /**< NULL terminate unit test array */
18899 : : }
18900 : : };
18901 : :
18902 : : static struct unit_test_suite cryptodev_null_testsuite = {
18903 : : .suite_name = "NULL Test Suite",
18904 : : .setup = null_testsuite_setup,
18905 : : .unit_test_cases = {
18906 : : TEST_CASE_ST(ut_setup, ut_teardown,
18907 : : test_null_invalid_operation),
18908 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
18909 : : TEST_CASES_END()
18910 : : }
18911 : : };
18912 : :
18913 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
18914 : : .suite_name = "AES CCM Authenticated Test Suite",
18915 : : .setup = aes_ccm_auth_testsuite_setup,
18916 : : .unit_test_cases = {
18917 : : /** AES CCM Authenticated Encryption 128 bits key*/
18918 : : TEST_CASE_ST(ut_setup, ut_teardown,
18919 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
18920 : : TEST_CASE_ST(ut_setup, ut_teardown,
18921 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
18922 : : TEST_CASE_ST(ut_setup, ut_teardown,
18923 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
18924 : :
18925 : : /** AES CCM Authenticated Decryption 128 bits key*/
18926 : : TEST_CASE_ST(ut_setup, ut_teardown,
18927 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
18928 : : TEST_CASE_ST(ut_setup, ut_teardown,
18929 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
18930 : : TEST_CASE_ST(ut_setup, ut_teardown,
18931 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
18932 : :
18933 : : /** AES CCM Authenticated Encryption 192 bits key */
18934 : : TEST_CASE_ST(ut_setup, ut_teardown,
18935 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
18936 : : TEST_CASE_ST(ut_setup, ut_teardown,
18937 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
18938 : : TEST_CASE_ST(ut_setup, ut_teardown,
18939 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
18940 : :
18941 : : /** AES CCM Authenticated Decryption 192 bits key*/
18942 : : TEST_CASE_ST(ut_setup, ut_teardown,
18943 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
18944 : : TEST_CASE_ST(ut_setup, ut_teardown,
18945 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
18946 : : TEST_CASE_ST(ut_setup, ut_teardown,
18947 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
18948 : :
18949 : : /** AES CCM Authenticated Encryption 256 bits key */
18950 : : TEST_CASE_ST(ut_setup, ut_teardown,
18951 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
18952 : : TEST_CASE_ST(ut_setup, ut_teardown,
18953 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
18954 : : TEST_CASE_ST(ut_setup, ut_teardown,
18955 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
18956 : :
18957 : : /** AES CCM Authenticated Decryption 256 bits key*/
18958 : : TEST_CASE_ST(ut_setup, ut_teardown,
18959 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
18960 : : TEST_CASE_ST(ut_setup, ut_teardown,
18961 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
18962 : : TEST_CASE_ST(ut_setup, ut_teardown,
18963 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
18964 : : TEST_CASES_END()
18965 : : }
18966 : : };
18967 : :
18968 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
18969 : : .suite_name = "AES GCM Authenticated Test Suite",
18970 : : .setup = aes_gcm_auth_testsuite_setup,
18971 : : .unit_test_cases = {
18972 : : /** AES GCM Authenticated Encryption */
18973 : : TEST_CASE_ST(ut_setup, ut_teardown,
18974 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
18975 : : TEST_CASE_ST(ut_setup, ut_teardown,
18976 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
18977 : : TEST_CASE_ST(ut_setup, ut_teardown,
18978 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
18979 : : TEST_CASE_ST(ut_setup, ut_teardown,
18980 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
18981 : : TEST_CASE_ST(ut_setup, ut_teardown,
18982 : : test_AES_GCM_authenticated_encryption_test_case_1),
18983 : : TEST_CASE_ST(ut_setup, ut_teardown,
18984 : : test_AES_GCM_authenticated_encryption_test_case_2),
18985 : : TEST_CASE_ST(ut_setup, ut_teardown,
18986 : : test_AES_GCM_authenticated_encryption_test_case_3),
18987 : : TEST_CASE_ST(ut_setup, ut_teardown,
18988 : : test_AES_GCM_authenticated_encryption_test_case_4),
18989 : : TEST_CASE_ST(ut_setup, ut_teardown,
18990 : : test_AES_GCM_authenticated_encryption_test_case_5),
18991 : : TEST_CASE_ST(ut_setup, ut_teardown,
18992 : : test_AES_GCM_authenticated_encryption_test_case_6),
18993 : : TEST_CASE_ST(ut_setup, ut_teardown,
18994 : : test_AES_GCM_authenticated_encryption_test_case_7),
18995 : : TEST_CASE_ST(ut_setup, ut_teardown,
18996 : : test_AES_GCM_authenticated_encryption_test_case_8),
18997 : : TEST_CASE_ST(ut_setup, ut_teardown,
18998 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
18999 : :
19000 : : /** AES GCM Authenticated Decryption */
19001 : : TEST_CASE_ST(ut_setup, ut_teardown,
19002 : : test_AES_GCM_authenticated_decryption_test_case_1),
19003 : : TEST_CASE_ST(ut_setup, ut_teardown,
19004 : : test_AES_GCM_authenticated_decryption_test_case_2),
19005 : : TEST_CASE_ST(ut_setup, ut_teardown,
19006 : : test_AES_GCM_authenticated_decryption_test_case_3),
19007 : : TEST_CASE_ST(ut_setup, ut_teardown,
19008 : : test_AES_GCM_authenticated_decryption_test_case_4),
19009 : : TEST_CASE_ST(ut_setup, ut_teardown,
19010 : : test_AES_GCM_authenticated_decryption_test_case_5),
19011 : : TEST_CASE_ST(ut_setup, ut_teardown,
19012 : : test_AES_GCM_authenticated_decryption_test_case_6),
19013 : : TEST_CASE_ST(ut_setup, ut_teardown,
19014 : : test_AES_GCM_authenticated_decryption_test_case_7),
19015 : : TEST_CASE_ST(ut_setup, ut_teardown,
19016 : : test_AES_GCM_authenticated_decryption_test_case_8),
19017 : : TEST_CASE_ST(ut_setup, ut_teardown,
19018 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
19019 : :
19020 : : /** AES GCM Authenticated Encryption 192 bits key */
19021 : : TEST_CASE_ST(ut_setup, ut_teardown,
19022 : : test_AES_GCM_auth_encryption_test_case_192_1),
19023 : : TEST_CASE_ST(ut_setup, ut_teardown,
19024 : : test_AES_GCM_auth_encryption_test_case_192_2),
19025 : : TEST_CASE_ST(ut_setup, ut_teardown,
19026 : : test_AES_GCM_auth_encryption_test_case_192_3),
19027 : : TEST_CASE_ST(ut_setup, ut_teardown,
19028 : : test_AES_GCM_auth_encryption_test_case_192_4),
19029 : : TEST_CASE_ST(ut_setup, ut_teardown,
19030 : : test_AES_GCM_auth_encryption_test_case_192_5),
19031 : : TEST_CASE_ST(ut_setup, ut_teardown,
19032 : : test_AES_GCM_auth_encryption_test_case_192_6),
19033 : : TEST_CASE_ST(ut_setup, ut_teardown,
19034 : : test_AES_GCM_auth_encryption_test_case_192_7),
19035 : :
19036 : : /** AES GCM Authenticated Decryption 192 bits key */
19037 : : TEST_CASE_ST(ut_setup, ut_teardown,
19038 : : test_AES_GCM_auth_decryption_test_case_192_1),
19039 : : TEST_CASE_ST(ut_setup, ut_teardown,
19040 : : test_AES_GCM_auth_decryption_test_case_192_2),
19041 : : TEST_CASE_ST(ut_setup, ut_teardown,
19042 : : test_AES_GCM_auth_decryption_test_case_192_3),
19043 : : TEST_CASE_ST(ut_setup, ut_teardown,
19044 : : test_AES_GCM_auth_decryption_test_case_192_4),
19045 : : TEST_CASE_ST(ut_setup, ut_teardown,
19046 : : test_AES_GCM_auth_decryption_test_case_192_5),
19047 : : TEST_CASE_ST(ut_setup, ut_teardown,
19048 : : test_AES_GCM_auth_decryption_test_case_192_6),
19049 : : TEST_CASE_ST(ut_setup, ut_teardown,
19050 : : test_AES_GCM_auth_decryption_test_case_192_7),
19051 : :
19052 : : /** AES GCM Authenticated Encryption 256 bits key */
19053 : : TEST_CASE_ST(ut_setup, ut_teardown,
19054 : : test_AES_GCM_auth_encryption_test_case_256_1),
19055 : : TEST_CASE_ST(ut_setup, ut_teardown,
19056 : : test_AES_GCM_auth_encryption_test_case_256_2),
19057 : : TEST_CASE_ST(ut_setup, ut_teardown,
19058 : : test_AES_GCM_auth_encryption_test_case_256_3),
19059 : : TEST_CASE_ST(ut_setup, ut_teardown,
19060 : : test_AES_GCM_auth_encryption_test_case_256_4),
19061 : : TEST_CASE_ST(ut_setup, ut_teardown,
19062 : : test_AES_GCM_auth_encryption_test_case_256_5),
19063 : : TEST_CASE_ST(ut_setup, ut_teardown,
19064 : : test_AES_GCM_auth_encryption_test_case_256_6),
19065 : : TEST_CASE_ST(ut_setup, ut_teardown,
19066 : : test_AES_GCM_auth_encryption_test_case_256_7),
19067 : : TEST_CASE_ST(ut_setup, ut_teardown,
19068 : : test_AES_GCM_auth_encryption_test_case_256_8),
19069 : :
19070 : : /** AES GCM Authenticated Decryption 256 bits key */
19071 : : TEST_CASE_ST(ut_setup, ut_teardown,
19072 : : test_AES_GCM_auth_decryption_test_case_256_1),
19073 : : TEST_CASE_ST(ut_setup, ut_teardown,
19074 : : test_AES_GCM_auth_decryption_test_case_256_2),
19075 : : TEST_CASE_ST(ut_setup, ut_teardown,
19076 : : test_AES_GCM_auth_decryption_test_case_256_3),
19077 : : TEST_CASE_ST(ut_setup, ut_teardown,
19078 : : test_AES_GCM_auth_decryption_test_case_256_4),
19079 : : TEST_CASE_ST(ut_setup, ut_teardown,
19080 : : test_AES_GCM_auth_decryption_test_case_256_5),
19081 : : TEST_CASE_ST(ut_setup, ut_teardown,
19082 : : test_AES_GCM_auth_decryption_test_case_256_6),
19083 : : TEST_CASE_ST(ut_setup, ut_teardown,
19084 : : test_AES_GCM_auth_decryption_test_case_256_7),
19085 : : TEST_CASE_ST(ut_setup, ut_teardown,
19086 : : test_AES_GCM_auth_decryption_test_case_256_8),
19087 : :
19088 : : /** AES GCM Authenticated Encryption big aad size */
19089 : : TEST_CASE_ST(ut_setup, ut_teardown,
19090 : : test_AES_GCM_auth_encryption_test_case_aad_1),
19091 : : TEST_CASE_ST(ut_setup, ut_teardown,
19092 : : test_AES_GCM_auth_encryption_test_case_aad_2),
19093 : :
19094 : : /** AES GCM Authenticated Decryption big aad size */
19095 : : TEST_CASE_ST(ut_setup, ut_teardown,
19096 : : test_AES_GCM_auth_decryption_test_case_aad_1),
19097 : : TEST_CASE_ST(ut_setup, ut_teardown,
19098 : : test_AES_GCM_auth_decryption_test_case_aad_2),
19099 : :
19100 : : /** Out of place tests */
19101 : : TEST_CASE_ST(ut_setup, ut_teardown,
19102 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
19103 : : TEST_CASE_ST(ut_setup, ut_teardown,
19104 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
19105 : :
19106 : : /** Session-less tests */
19107 : : TEST_CASE_ST(ut_setup, ut_teardown,
19108 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
19109 : : TEST_CASE_ST(ut_setup, ut_teardown,
19110 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
19111 : :
19112 : : /** AES GCM external mbuf tests */
19113 : : TEST_CASE_ST(ut_setup, ut_teardown,
19114 : : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
19115 : : TEST_CASE_ST(ut_setup, ut_teardown,
19116 : : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
19117 : :
19118 : : TEST_CASES_END()
19119 : : }
19120 : : };
19121 : :
19122 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
19123 : : .suite_name = "AES GMAC Authentication Test Suite",
19124 : : .setup = aes_gmac_auth_testsuite_setup,
19125 : : .unit_test_cases = {
19126 : : TEST_CASE_ST(ut_setup, ut_teardown,
19127 : : test_AES_GMAC_authentication_test_case_1),
19128 : : TEST_CASE_ST(ut_setup, ut_teardown,
19129 : : test_AES_GMAC_authentication_verify_test_case_1),
19130 : : TEST_CASE_ST(ut_setup, ut_teardown,
19131 : : test_AES_GMAC_authentication_test_case_2),
19132 : : TEST_CASE_ST(ut_setup, ut_teardown,
19133 : : test_AES_GMAC_authentication_verify_test_case_2),
19134 : : TEST_CASE_ST(ut_setup, ut_teardown,
19135 : : test_AES_GMAC_authentication_test_case_3),
19136 : : TEST_CASE_ST(ut_setup, ut_teardown,
19137 : : test_AES_GMAC_authentication_verify_test_case_3),
19138 : : TEST_CASE_ST(ut_setup, ut_teardown,
19139 : : test_AES_GMAC_authentication_test_case_4),
19140 : : TEST_CASE_ST(ut_setup, ut_teardown,
19141 : : test_AES_GMAC_authentication_verify_test_case_4),
19142 : : TEST_CASE_ST(ut_setup, ut_teardown,
19143 : : test_AES_GMAC_authentication_SGL_40B),
19144 : : TEST_CASE_ST(ut_setup, ut_teardown,
19145 : : test_AES_GMAC_authentication_SGL_80B),
19146 : : TEST_CASE_ST(ut_setup, ut_teardown,
19147 : : test_AES_GMAC_authentication_SGL_2048B),
19148 : : TEST_CASE_ST(ut_setup, ut_teardown,
19149 : : test_AES_GMAC_authentication_SGL_2047B),
19150 : :
19151 : : TEST_CASES_END()
19152 : : }
19153 : : };
19154 : :
19155 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
19156 : : .suite_name = "Chacha20-Poly1305 Test Suite",
19157 : : .setup = chacha20_poly1305_testsuite_setup,
19158 : : .unit_test_cases = {
19159 : : TEST_CASE_ST(ut_setup, ut_teardown,
19160 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
19161 : : TEST_CASE_ST(ut_setup, ut_teardown,
19162 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
19163 : : TEST_CASE_ST(ut_setup, ut_teardown,
19164 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
19165 : : TEST_CASES_END()
19166 : : }
19167 : : };
19168 : :
19169 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
19170 : : .suite_name = "SNOW 3G Test Suite",
19171 : : .setup = snow3g_testsuite_setup,
19172 : : .unit_test_cases = {
19173 : : /** SNOW 3G encrypt only (UEA2) */
19174 : : TEST_CASE_ST(ut_setup, ut_teardown,
19175 : : test_snow3g_encryption_test_case_1),
19176 : : TEST_CASE_ST(ut_setup, ut_teardown,
19177 : : test_snow3g_encryption_test_case_2),
19178 : : TEST_CASE_ST(ut_setup, ut_teardown,
19179 : : test_snow3g_encryption_test_case_3),
19180 : : TEST_CASE_ST(ut_setup, ut_teardown,
19181 : : test_snow3g_encryption_test_case_4),
19182 : : TEST_CASE_ST(ut_setup, ut_teardown,
19183 : : test_snow3g_encryption_test_case_5),
19184 : :
19185 : : TEST_CASE_ST(ut_setup, ut_teardown,
19186 : : test_snow3g_encryption_test_case_1_oop),
19187 : : TEST_CASE_ST(ut_setup, ut_teardown,
19188 : : test_snow3g_encryption_test_case_1_oop_sgl),
19189 : : TEST_CASE_ST(ut_setup, ut_teardown,
19190 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
19191 : : TEST_CASE_ST(ut_setup, ut_teardown,
19192 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
19193 : : TEST_CASE_ST(ut_setup, ut_teardown,
19194 : : test_snow3g_encryption_test_case_1_offset_oop),
19195 : : TEST_CASE_ST(ut_setup, ut_teardown,
19196 : : test_snow3g_decryption_test_case_1_oop),
19197 : :
19198 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
19199 : : TEST_CASE_ST(ut_setup, ut_teardown,
19200 : : test_snow3g_auth_cipher_test_case_1),
19201 : : TEST_CASE_ST(ut_setup, ut_teardown,
19202 : : test_snow3g_auth_cipher_test_case_2),
19203 : : TEST_CASE_ST(ut_setup, ut_teardown,
19204 : : test_snow3g_auth_cipher_test_case_2_oop),
19205 : : TEST_CASE_ST(ut_setup, ut_teardown,
19206 : : test_snow3g_auth_cipher_part_digest_enc),
19207 : : TEST_CASE_ST(ut_setup, ut_teardown,
19208 : : test_snow3g_auth_cipher_part_digest_enc_oop),
19209 : : TEST_CASE_ST(ut_setup, ut_teardown,
19210 : : test_snow3g_auth_cipher_test_case_3_sgl),
19211 : : TEST_CASE_ST(ut_setup, ut_teardown,
19212 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
19213 : : TEST_CASE_ST(ut_setup, ut_teardown,
19214 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
19215 : : TEST_CASE_ST(ut_setup, ut_teardown,
19216 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
19217 : : TEST_CASE_ST(ut_setup, ut_teardown,
19218 : : test_snow3g_auth_cipher_total_digest_enc_1),
19219 : : TEST_CASE_ST(ut_setup, ut_teardown,
19220 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
19221 : : TEST_CASE_ST(ut_setup, ut_teardown,
19222 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
19223 : : TEST_CASE_ST(ut_setup, ut_teardown,
19224 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
19225 : :
19226 : : /** SNOW 3G decrypt (UEA2), then verify auth */
19227 : : TEST_CASE_ST(ut_setup, ut_teardown,
19228 : : test_snow3g_auth_cipher_verify_test_case_1),
19229 : : TEST_CASE_ST(ut_setup, ut_teardown,
19230 : : test_snow3g_auth_cipher_verify_test_case_2),
19231 : : TEST_CASE_ST(ut_setup, ut_teardown,
19232 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
19233 : : TEST_CASE_ST(ut_setup, ut_teardown,
19234 : : test_snow3g_auth_cipher_verify_part_digest_enc),
19235 : : TEST_CASE_ST(ut_setup, ut_teardown,
19236 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
19237 : : TEST_CASE_ST(ut_setup, ut_teardown,
19238 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
19239 : : TEST_CASE_ST(ut_setup, ut_teardown,
19240 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
19241 : : TEST_CASE_ST(ut_setup, ut_teardown,
19242 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
19243 : : TEST_CASE_ST(ut_setup, ut_teardown,
19244 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
19245 : : TEST_CASE_ST(ut_setup, ut_teardown,
19246 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
19247 : : TEST_CASE_ST(ut_setup, ut_teardown,
19248 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
19249 : : TEST_CASE_ST(ut_setup, ut_teardown,
19250 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
19251 : : TEST_CASE_ST(ut_setup, ut_teardown,
19252 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
19253 : :
19254 : : /** SNOW 3G decrypt only (UEA2) */
19255 : : TEST_CASE_ST(ut_setup, ut_teardown,
19256 : : test_snow3g_decryption_test_case_1),
19257 : : TEST_CASE_ST(ut_setup, ut_teardown,
19258 : : test_snow3g_decryption_test_case_2),
19259 : : TEST_CASE_ST(ut_setup, ut_teardown,
19260 : : test_snow3g_decryption_test_case_3),
19261 : : TEST_CASE_ST(ut_setup, ut_teardown,
19262 : : test_snow3g_decryption_test_case_4),
19263 : : TEST_CASE_ST(ut_setup, ut_teardown,
19264 : : test_snow3g_decryption_test_case_5),
19265 : : TEST_CASE_ST(ut_setup, ut_teardown,
19266 : : test_snow3g_decryption_with_digest_test_case_1),
19267 : : TEST_CASE_ST(ut_setup, ut_teardown,
19268 : : test_snow3g_hash_generate_test_case_1),
19269 : : TEST_CASE_ST(ut_setup, ut_teardown,
19270 : : test_snow3g_hash_generate_test_case_2),
19271 : : TEST_CASE_ST(ut_setup, ut_teardown,
19272 : : test_snow3g_hash_generate_test_case_3),
19273 : :
19274 : : /* Tests with buffers which length is not byte-aligned */
19275 : : TEST_CASE_ST(ut_setup, ut_teardown,
19276 : : test_snow3g_hash_generate_test_case_4),
19277 : : TEST_CASE_ST(ut_setup, ut_teardown,
19278 : : test_snow3g_hash_generate_test_case_5),
19279 : : TEST_CASE_ST(ut_setup, ut_teardown,
19280 : : test_snow3g_hash_generate_test_case_6),
19281 : : TEST_CASE_ST(ut_setup, ut_teardown,
19282 : : test_snow3g_hash_verify_test_case_1),
19283 : : TEST_CASE_ST(ut_setup, ut_teardown,
19284 : : test_snow3g_hash_verify_test_case_2),
19285 : : TEST_CASE_ST(ut_setup, ut_teardown,
19286 : : test_snow3g_hash_verify_test_case_3),
19287 : :
19288 : : /* Tests with buffers which length is not byte-aligned */
19289 : : TEST_CASE_ST(ut_setup, ut_teardown,
19290 : : test_snow3g_hash_verify_test_case_4),
19291 : : TEST_CASE_ST(ut_setup, ut_teardown,
19292 : : test_snow3g_hash_verify_test_case_5),
19293 : : TEST_CASE_ST(ut_setup, ut_teardown,
19294 : : test_snow3g_hash_verify_test_case_6),
19295 : : TEST_CASE_ST(ut_setup, ut_teardown,
19296 : : test_snow3g_cipher_auth_test_case_1),
19297 : : TEST_CASE_ST(ut_setup, ut_teardown,
19298 : : test_snow3g_auth_cipher_with_digest_test_case_1),
19299 : : TEST_CASES_END()
19300 : : }
19301 : : };
19302 : :
19303 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
19304 : : .suite_name = "ZUC Test Suite",
19305 : : .setup = zuc_testsuite_setup,
19306 : : .unit_test_cases = {
19307 : : /** ZUC encrypt only (EEA3) */
19308 : : TEST_CASE_ST(ut_setup, ut_teardown,
19309 : : test_zuc_encryption_test_case_1),
19310 : : TEST_CASE_ST(ut_setup, ut_teardown,
19311 : : test_zuc_encryption_test_case_2),
19312 : : TEST_CASE_ST(ut_setup, ut_teardown,
19313 : : test_zuc_encryption_test_case_3),
19314 : : TEST_CASE_ST(ut_setup, ut_teardown,
19315 : : test_zuc_encryption_test_case_4),
19316 : : TEST_CASE_ST(ut_setup, ut_teardown,
19317 : : test_zuc_encryption_test_case_5),
19318 : : TEST_CASE_ST(ut_setup, ut_teardown,
19319 : : test_zuc_encryption_test_case_6_sgl),
19320 : :
19321 : : /** ZUC decrypt only (EEA3) */
19322 : : TEST_CASE_ST(ut_setup, ut_teardown,
19323 : : test_zuc_decryption_test_case_1),
19324 : : TEST_CASE_ST(ut_setup, ut_teardown,
19325 : : test_zuc_decryption_test_case_2),
19326 : : TEST_CASE_ST(ut_setup, ut_teardown,
19327 : : test_zuc_decryption_test_case_3),
19328 : : TEST_CASE_ST(ut_setup, ut_teardown,
19329 : : test_zuc_decryption_test_case_4),
19330 : : TEST_CASE_ST(ut_setup, ut_teardown,
19331 : : test_zuc_decryption_test_case_5),
19332 : : TEST_CASE_ST(ut_setup, ut_teardown,
19333 : : test_zuc_decryption_test_case_6_sgl),
19334 : :
19335 : : /** ZUC authenticate (EIA3) */
19336 : : TEST_CASE_ST(ut_setup, ut_teardown,
19337 : : test_zuc_hash_generate_test_case_1),
19338 : : TEST_CASE_ST(ut_setup, ut_teardown,
19339 : : test_zuc_hash_generate_test_case_2),
19340 : : TEST_CASE_ST(ut_setup, ut_teardown,
19341 : : test_zuc_hash_generate_test_case_3),
19342 : : TEST_CASE_ST(ut_setup, ut_teardown,
19343 : : test_zuc_hash_generate_test_case_4),
19344 : : TEST_CASE_ST(ut_setup, ut_teardown,
19345 : : test_zuc_hash_generate_test_case_5),
19346 : : TEST_CASE_ST(ut_setup, ut_teardown,
19347 : : test_zuc_hash_generate_test_case_6),
19348 : : TEST_CASE_ST(ut_setup, ut_teardown,
19349 : : test_zuc_hash_generate_test_case_7),
19350 : : TEST_CASE_ST(ut_setup, ut_teardown,
19351 : : test_zuc_hash_generate_test_case_8),
19352 : :
19353 : : /** ZUC verify (EIA3) */
19354 : : TEST_CASE_ST(ut_setup, ut_teardown,
19355 : : test_zuc_hash_verify_test_case_1),
19356 : : TEST_CASE_ST(ut_setup, ut_teardown,
19357 : : test_zuc_hash_verify_test_case_2),
19358 : : TEST_CASE_ST(ut_setup, ut_teardown,
19359 : : test_zuc_hash_verify_test_case_3),
19360 : : TEST_CASE_ST(ut_setup, ut_teardown,
19361 : : test_zuc_hash_verify_test_case_4),
19362 : : TEST_CASE_ST(ut_setup, ut_teardown,
19363 : : test_zuc_hash_verify_test_case_5),
19364 : : TEST_CASE_ST(ut_setup, ut_teardown,
19365 : : test_zuc_hash_verify_test_case_6),
19366 : : TEST_CASE_ST(ut_setup, ut_teardown,
19367 : : test_zuc_hash_verify_test_case_7),
19368 : : TEST_CASE_ST(ut_setup, ut_teardown,
19369 : : test_zuc_hash_verify_test_case_8),
19370 : :
19371 : : /** ZUC alg-chain (EEA3/EIA3) */
19372 : : TEST_CASE_ST(ut_setup, ut_teardown,
19373 : : test_zuc_cipher_auth_test_case_1),
19374 : : TEST_CASE_ST(ut_setup, ut_teardown,
19375 : : test_zuc_cipher_auth_test_case_2),
19376 : :
19377 : : /** ZUC generate auth, then encrypt (EEA3) */
19378 : : TEST_CASE_ST(ut_setup, ut_teardown,
19379 : : test_zuc_auth_cipher_test_case_1),
19380 : : TEST_CASE_ST(ut_setup, ut_teardown,
19381 : : test_zuc_auth_cipher_test_case_1_oop),
19382 : : TEST_CASE_ST(ut_setup, ut_teardown,
19383 : : test_zuc_auth_cipher_test_case_1_sgl),
19384 : : TEST_CASE_ST(ut_setup, ut_teardown,
19385 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
19386 : : TEST_CASE_ST(ut_setup, ut_teardown,
19387 : : test_zuc_auth_cipher_test_case_2),
19388 : : TEST_CASE_ST(ut_setup, ut_teardown,
19389 : : test_zuc_auth_cipher_test_case_2_oop),
19390 : :
19391 : : /** ZUC decrypt (EEA3), then verify auth */
19392 : : TEST_CASE_ST(ut_setup, ut_teardown,
19393 : : test_zuc_auth_cipher_verify_test_case_1),
19394 : : TEST_CASE_ST(ut_setup, ut_teardown,
19395 : : test_zuc_auth_cipher_verify_test_case_1_oop),
19396 : : TEST_CASE_ST(ut_setup, ut_teardown,
19397 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
19398 : : TEST_CASE_ST(ut_setup, ut_teardown,
19399 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
19400 : : TEST_CASE_ST(ut_setup, ut_teardown,
19401 : : test_zuc_auth_cipher_verify_test_case_2),
19402 : : TEST_CASE_ST(ut_setup, ut_teardown,
19403 : : test_zuc_auth_cipher_verify_test_case_2_oop),
19404 : :
19405 : : /** ZUC-256 encrypt only **/
19406 : : TEST_CASE_ST(ut_setup, ut_teardown,
19407 : : test_zuc256_encryption_test_case_1),
19408 : : TEST_CASE_ST(ut_setup, ut_teardown,
19409 : : test_zuc256_encryption_test_case_2),
19410 : :
19411 : : /** ZUC-256 decrypt only **/
19412 : : TEST_CASE_ST(ut_setup, ut_teardown,
19413 : : test_zuc256_decryption_test_case_1),
19414 : : TEST_CASE_ST(ut_setup, ut_teardown,
19415 : : test_zuc256_decryption_test_case_2),
19416 : :
19417 : : /** ZUC-256 authentication only **/
19418 : : TEST_CASE_ST(ut_setup, ut_teardown,
19419 : : test_zuc256_hash_generate_4b_tag_test_case_1),
19420 : : TEST_CASE_ST(ut_setup, ut_teardown,
19421 : : test_zuc256_hash_generate_4b_tag_test_case_2),
19422 : : TEST_CASE_ST(ut_setup, ut_teardown,
19423 : : test_zuc256_hash_generate_4b_tag_test_case_3),
19424 : : TEST_CASE_ST(ut_setup, ut_teardown,
19425 : : test_zuc256_hash_generate_8b_tag_test_case_1),
19426 : : TEST_CASE_ST(ut_setup, ut_teardown,
19427 : : test_zuc256_hash_generate_16b_tag_test_case_1),
19428 : :
19429 : : /** ZUC-256 authentication verify only **/
19430 : : TEST_CASE_ST(ut_setup, ut_teardown,
19431 : : test_zuc256_hash_verify_4b_tag_test_case_1),
19432 : : TEST_CASE_ST(ut_setup, ut_teardown,
19433 : : test_zuc256_hash_verify_4b_tag_test_case_2),
19434 : : TEST_CASE_ST(ut_setup, ut_teardown,
19435 : : test_zuc256_hash_verify_4b_tag_test_case_3),
19436 : : TEST_CASE_ST(ut_setup, ut_teardown,
19437 : : test_zuc256_hash_verify_8b_tag_test_case_1),
19438 : : TEST_CASE_ST(ut_setup, ut_teardown,
19439 : : test_zuc256_hash_verify_16b_tag_test_case_1),
19440 : :
19441 : : /** ZUC-256 encrypt and authenticate **/
19442 : : TEST_CASE_ST(ut_setup, ut_teardown,
19443 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
19444 : : TEST_CASE_ST(ut_setup, ut_teardown,
19445 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
19446 : : TEST_CASE_ST(ut_setup, ut_teardown,
19447 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
19448 : : TEST_CASE_ST(ut_setup, ut_teardown,
19449 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
19450 : :
19451 : : /** ZUC-256 generate auth, then encrypt */
19452 : : TEST_CASE_ST(ut_setup, ut_teardown,
19453 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
19454 : : TEST_CASE_ST(ut_setup, ut_teardown,
19455 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
19456 : : TEST_CASE_ST(ut_setup, ut_teardown,
19457 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
19458 : : TEST_CASE_ST(ut_setup, ut_teardown,
19459 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
19460 : :
19461 : : /** ZUC-256 decrypt, then verify auth */
19462 : : TEST_CASE_ST(ut_setup, ut_teardown,
19463 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19464 : : TEST_CASE_ST(ut_setup, ut_teardown,
19465 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19466 : : TEST_CASE_ST(ut_setup, ut_teardown,
19467 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19468 : : TEST_CASE_ST(ut_setup, ut_teardown,
19469 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19470 : :
19471 : : TEST_CASES_END()
19472 : : }
19473 : : };
19474 : :
19475 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
19476 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
19477 : : .setup = hmac_md5_auth_testsuite_setup,
19478 : : .unit_test_cases = {
19479 : : TEST_CASE_ST(ut_setup, ut_teardown,
19480 : : test_MD5_HMAC_generate_case_1),
19481 : : TEST_CASE_ST(ut_setup, ut_teardown,
19482 : : test_MD5_HMAC_verify_case_1),
19483 : : TEST_CASE_ST(ut_setup, ut_teardown,
19484 : : test_MD5_HMAC_generate_case_2),
19485 : : TEST_CASE_ST(ut_setup, ut_teardown,
19486 : : test_MD5_HMAC_verify_case_2),
19487 : : TEST_CASES_END()
19488 : : }
19489 : : };
19490 : :
19491 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
19492 : : .suite_name = "Kasumi Test Suite",
19493 : : .setup = kasumi_testsuite_setup,
19494 : : .unit_test_cases = {
19495 : : /** KASUMI hash only (UIA1) */
19496 : : TEST_CASE_ST(ut_setup, ut_teardown,
19497 : : test_kasumi_hash_generate_test_case_1),
19498 : : TEST_CASE_ST(ut_setup, ut_teardown,
19499 : : test_kasumi_hash_generate_test_case_2),
19500 : : TEST_CASE_ST(ut_setup, ut_teardown,
19501 : : test_kasumi_hash_generate_test_case_3),
19502 : : TEST_CASE_ST(ut_setup, ut_teardown,
19503 : : test_kasumi_hash_generate_test_case_4),
19504 : : TEST_CASE_ST(ut_setup, ut_teardown,
19505 : : test_kasumi_hash_generate_test_case_5),
19506 : : TEST_CASE_ST(ut_setup, ut_teardown,
19507 : : test_kasumi_hash_generate_test_case_6),
19508 : :
19509 : : TEST_CASE_ST(ut_setup, ut_teardown,
19510 : : test_kasumi_hash_verify_test_case_1),
19511 : : TEST_CASE_ST(ut_setup, ut_teardown,
19512 : : test_kasumi_hash_verify_test_case_2),
19513 : : TEST_CASE_ST(ut_setup, ut_teardown,
19514 : : test_kasumi_hash_verify_test_case_3),
19515 : : TEST_CASE_ST(ut_setup, ut_teardown,
19516 : : test_kasumi_hash_verify_test_case_4),
19517 : : TEST_CASE_ST(ut_setup, ut_teardown,
19518 : : test_kasumi_hash_verify_test_case_5),
19519 : :
19520 : : /** KASUMI encrypt only (UEA1) */
19521 : : TEST_CASE_ST(ut_setup, ut_teardown,
19522 : : test_kasumi_encryption_test_case_1),
19523 : : TEST_CASE_ST(ut_setup, ut_teardown,
19524 : : test_kasumi_encryption_test_case_1_sgl),
19525 : : TEST_CASE_ST(ut_setup, ut_teardown,
19526 : : test_kasumi_encryption_test_case_1_oop),
19527 : : TEST_CASE_ST(ut_setup, ut_teardown,
19528 : : test_kasumi_encryption_test_case_1_oop_sgl),
19529 : : TEST_CASE_ST(ut_setup, ut_teardown,
19530 : : test_kasumi_encryption_test_case_2),
19531 : : TEST_CASE_ST(ut_setup, ut_teardown,
19532 : : test_kasumi_encryption_test_case_3),
19533 : : TEST_CASE_ST(ut_setup, ut_teardown,
19534 : : test_kasumi_encryption_test_case_4),
19535 : : TEST_CASE_ST(ut_setup, ut_teardown,
19536 : : test_kasumi_encryption_test_case_5),
19537 : :
19538 : : /** KASUMI decrypt only (UEA1) */
19539 : : TEST_CASE_ST(ut_setup, ut_teardown,
19540 : : test_kasumi_decryption_test_case_1),
19541 : : TEST_CASE_ST(ut_setup, ut_teardown,
19542 : : test_kasumi_decryption_test_case_2),
19543 : : TEST_CASE_ST(ut_setup, ut_teardown,
19544 : : test_kasumi_decryption_test_case_3),
19545 : : TEST_CASE_ST(ut_setup, ut_teardown,
19546 : : test_kasumi_decryption_test_case_4),
19547 : : TEST_CASE_ST(ut_setup, ut_teardown,
19548 : : test_kasumi_decryption_test_case_5),
19549 : : TEST_CASE_ST(ut_setup, ut_teardown,
19550 : : test_kasumi_decryption_test_case_1_oop),
19551 : : TEST_CASE_ST(ut_setup, ut_teardown,
19552 : : test_kasumi_cipher_auth_test_case_1),
19553 : :
19554 : : /** KASUMI generate auth, then encrypt (F8) */
19555 : : TEST_CASE_ST(ut_setup, ut_teardown,
19556 : : test_kasumi_auth_cipher_test_case_1),
19557 : : TEST_CASE_ST(ut_setup, ut_teardown,
19558 : : test_kasumi_auth_cipher_test_case_2),
19559 : : TEST_CASE_ST(ut_setup, ut_teardown,
19560 : : test_kasumi_auth_cipher_test_case_2_oop),
19561 : : TEST_CASE_ST(ut_setup, ut_teardown,
19562 : : test_kasumi_auth_cipher_test_case_2_sgl),
19563 : : TEST_CASE_ST(ut_setup, ut_teardown,
19564 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
19565 : :
19566 : : /** KASUMI decrypt (F8), then verify auth */
19567 : : TEST_CASE_ST(ut_setup, ut_teardown,
19568 : : test_kasumi_auth_cipher_verify_test_case_1),
19569 : : TEST_CASE_ST(ut_setup, ut_teardown,
19570 : : test_kasumi_auth_cipher_verify_test_case_2),
19571 : : TEST_CASE_ST(ut_setup, ut_teardown,
19572 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
19573 : : TEST_CASE_ST(ut_setup, ut_teardown,
19574 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
19575 : : TEST_CASE_ST(ut_setup, ut_teardown,
19576 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19577 : :
19578 : : TEST_CASES_END()
19579 : : }
19580 : : };
19581 : :
19582 : : static struct unit_test_suite cryptodev_esn_testsuite = {
19583 : : .suite_name = "ESN Test Suite",
19584 : : .setup = esn_testsuite_setup,
19585 : : .unit_test_cases = {
19586 : : TEST_CASE_ST(ut_setup, ut_teardown,
19587 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19588 : : TEST_CASE_ST(ut_setup, ut_teardown,
19589 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19590 : : TEST_CASES_END()
19591 : : }
19592 : : };
19593 : :
19594 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
19595 : : .suite_name = "Negative AES GCM Test Suite",
19596 : : .setup = negative_aes_gcm_testsuite_setup,
19597 : : .unit_test_cases = {
19598 : : TEST_CASE_ST(ut_setup, ut_teardown,
19599 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
19600 : : TEST_CASE_ST(ut_setup, ut_teardown,
19601 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19602 : : TEST_CASE_ST(ut_setup, ut_teardown,
19603 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19604 : : TEST_CASE_ST(ut_setup, ut_teardown,
19605 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19606 : : TEST_CASE_ST(ut_setup, ut_teardown,
19607 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
19608 : : TEST_CASE_ST(ut_setup, ut_teardown,
19609 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
19610 : : TEST_CASE_ST(ut_setup, ut_teardown,
19611 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
19612 : : TEST_CASE_ST(ut_setup, ut_teardown,
19613 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19614 : : TEST_CASE_ST(ut_setup, ut_teardown,
19615 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19616 : : TEST_CASE_ST(ut_setup, ut_teardown,
19617 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19618 : : TEST_CASE_ST(ut_setup, ut_teardown,
19619 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
19620 : : TEST_CASE_ST(ut_setup, ut_teardown,
19621 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
19622 : :
19623 : : TEST_CASES_END()
19624 : : }
19625 : : };
19626 : :
19627 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
19628 : : .suite_name = "Negative AES GMAC Test Suite",
19629 : : .setup = negative_aes_gmac_testsuite_setup,
19630 : : .unit_test_cases = {
19631 : : TEST_CASE_ST(ut_setup, ut_teardown,
19632 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
19633 : : TEST_CASE_ST(ut_setup, ut_teardown,
19634 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
19635 : :
19636 : : TEST_CASES_END()
19637 : : }
19638 : : };
19639 : :
19640 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
19641 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19642 : : .setup = mixed_cipher_hash_testsuite_setup,
19643 : : .unit_test_cases = {
19644 : : /** AUTH AES CMAC + CIPHER AES CTR */
19645 : : TEST_CASE_ST(ut_setup, ut_teardown,
19646 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19647 : : TEST_CASE_ST(ut_setup, ut_teardown,
19648 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19649 : : TEST_CASE_ST(ut_setup, ut_teardown,
19650 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19651 : : TEST_CASE_ST(ut_setup, ut_teardown,
19652 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19653 : : TEST_CASE_ST(ut_setup, ut_teardown,
19654 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19655 : : TEST_CASE_ST(ut_setup, ut_teardown,
19656 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19657 : : TEST_CASE_ST(ut_setup, ut_teardown,
19658 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19659 : : TEST_CASE_ST(ut_setup, ut_teardown,
19660 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19661 : : TEST_CASE_ST(ut_setup, ut_teardown,
19662 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19663 : : TEST_CASE_ST(ut_setup, ut_teardown,
19664 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19665 : : TEST_CASE_ST(ut_setup, ut_teardown,
19666 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19667 : : TEST_CASE_ST(ut_setup, ut_teardown,
19668 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19669 : :
19670 : : /** AUTH ZUC + CIPHER SNOW3G */
19671 : : TEST_CASE_ST(ut_setup, ut_teardown,
19672 : : test_auth_zuc_cipher_snow_test_case_1),
19673 : : TEST_CASE_ST(ut_setup, ut_teardown,
19674 : : test_verify_auth_zuc_cipher_snow_test_case_1),
19675 : : TEST_CASE_ST(ut_setup, ut_teardown,
19676 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
19677 : : TEST_CASE_ST(ut_setup, ut_teardown,
19678 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19679 : : /** AUTH AES CMAC + CIPHER SNOW3G */
19680 : : TEST_CASE_ST(ut_setup, ut_teardown,
19681 : : test_auth_aes_cmac_cipher_snow_test_case_1),
19682 : : TEST_CASE_ST(ut_setup, ut_teardown,
19683 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19684 : : TEST_CASE_ST(ut_setup, ut_teardown,
19685 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19686 : : TEST_CASE_ST(ut_setup, ut_teardown,
19687 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19688 : : /** AUTH ZUC + CIPHER AES CTR */
19689 : : TEST_CASE_ST(ut_setup, ut_teardown,
19690 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
19691 : : TEST_CASE_ST(ut_setup, ut_teardown,
19692 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19693 : : TEST_CASE_ST(ut_setup, ut_teardown,
19694 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19695 : : TEST_CASE_ST(ut_setup, ut_teardown,
19696 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19697 : : /** AUTH SNOW3G + CIPHER AES CTR */
19698 : : TEST_CASE_ST(ut_setup, ut_teardown,
19699 : : test_auth_snow_cipher_aes_ctr_test_case_1),
19700 : : TEST_CASE_ST(ut_setup, ut_teardown,
19701 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19702 : : TEST_CASE_ST(ut_setup, ut_teardown,
19703 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19704 : : TEST_CASE_ST(ut_setup, ut_teardown,
19705 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19706 : : TEST_CASE_ST(ut_setup, ut_teardown,
19707 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19708 : : TEST_CASE_ST(ut_setup, ut_teardown,
19709 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19710 : : /** AUTH SNOW3G + CIPHER ZUC */
19711 : : TEST_CASE_ST(ut_setup, ut_teardown,
19712 : : test_auth_snow_cipher_zuc_test_case_1),
19713 : : TEST_CASE_ST(ut_setup, ut_teardown,
19714 : : test_verify_auth_snow_cipher_zuc_test_case_1),
19715 : : TEST_CASE_ST(ut_setup, ut_teardown,
19716 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
19717 : : TEST_CASE_ST(ut_setup, ut_teardown,
19718 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19719 : : /** AUTH AES CMAC + CIPHER ZUC */
19720 : : TEST_CASE_ST(ut_setup, ut_teardown,
19721 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
19722 : : TEST_CASE_ST(ut_setup, ut_teardown,
19723 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19724 : : TEST_CASE_ST(ut_setup, ut_teardown,
19725 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19726 : : TEST_CASE_ST(ut_setup, ut_teardown,
19727 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19728 : :
19729 : : /** AUTH NULL + CIPHER SNOW3G */
19730 : : TEST_CASE_ST(ut_setup, ut_teardown,
19731 : : test_auth_null_cipher_snow_test_case_1),
19732 : : TEST_CASE_ST(ut_setup, ut_teardown,
19733 : : test_verify_auth_null_cipher_snow_test_case_1),
19734 : : /** AUTH NULL + CIPHER ZUC */
19735 : : TEST_CASE_ST(ut_setup, ut_teardown,
19736 : : test_auth_null_cipher_zuc_test_case_1),
19737 : : TEST_CASE_ST(ut_setup, ut_teardown,
19738 : : test_verify_auth_null_cipher_zuc_test_case_1),
19739 : : /** AUTH SNOW3G + CIPHER NULL */
19740 : : TEST_CASE_ST(ut_setup, ut_teardown,
19741 : : test_auth_snow_cipher_null_test_case_1),
19742 : : TEST_CASE_ST(ut_setup, ut_teardown,
19743 : : test_verify_auth_snow_cipher_null_test_case_1),
19744 : : /** AUTH ZUC + CIPHER NULL */
19745 : : TEST_CASE_ST(ut_setup, ut_teardown,
19746 : : test_auth_zuc_cipher_null_test_case_1),
19747 : : TEST_CASE_ST(ut_setup, ut_teardown,
19748 : : test_verify_auth_zuc_cipher_null_test_case_1),
19749 : : /** AUTH NULL + CIPHER AES CTR */
19750 : : TEST_CASE_ST(ut_setup, ut_teardown,
19751 : : test_auth_null_cipher_aes_ctr_test_case_1),
19752 : : TEST_CASE_ST(ut_setup, ut_teardown,
19753 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
19754 : : /** AUTH AES CMAC + CIPHER NULL */
19755 : : TEST_CASE_ST(ut_setup, ut_teardown,
19756 : : test_auth_aes_cmac_cipher_null_test_case_1),
19757 : : TEST_CASE_ST(ut_setup, ut_teardown,
19758 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
19759 : : TEST_CASES_END()
19760 : : }
19761 : : };
19762 : :
19763 : : static struct unit_test_suite cryptodev_sm4_gcm_testsuite = {
19764 : : .suite_name = "SM4 GCM Test Suite",
19765 : : .setup = sm4_gcm_testsuite_setup,
19766 : : .unit_test_cases = {
19767 : : TEST_CASE_ST(ut_setup, ut_teardown,
19768 : : test_SM4_GCM_case_1),
19769 : : TEST_CASE_ST(ut_setup, ut_teardown,
19770 : : test_SM4_GCM_case_2),
19771 : : TEST_CASE_ST(ut_setup, ut_teardown,
19772 : : test_SM4_GCM_case_3),
19773 : : TEST_CASE_ST(ut_setup, ut_teardown,
19774 : : test_SM4_GCM_case_4),
19775 : : TEST_CASE_ST(ut_setup, ut_teardown,
19776 : : test_SM4_GCM_case_5),
19777 : : TEST_CASE_ST(ut_setup, ut_teardown,
19778 : : test_SM4_GCM_case_6),
19779 : : TEST_CASE_ST(ut_setup, ut_teardown,
19780 : : test_SM4_GCM_case_7),
19781 : : TEST_CASE_ST(ut_setup, ut_teardown,
19782 : : test_SM4_GCM_case_8),
19783 : : TEST_CASE_ST(ut_setup, ut_teardown,
19784 : : test_SM4_GCM_case_9),
19785 : : TEST_CASE_ST(ut_setup, ut_teardown,
19786 : : test_SM4_GCM_case_10),
19787 : : TEST_CASE_ST(ut_setup, ut_teardown,
19788 : : test_SM4_GCM_case_11),
19789 : : TEST_CASE_ST(ut_setup, ut_teardown,
19790 : : test_SM4_GCM_case_12),
19791 : : TEST_CASE_ST(ut_setup, ut_teardown,
19792 : : test_SM4_GCM_case_13),
19793 : : TEST_CASE_ST(ut_setup, ut_teardown,
19794 : : test_SM4_GCM_case_14),
19795 : : TEST_CASE_ST(ut_setup, ut_teardown,
19796 : : test_SM4_GCM_case_15),
19797 : : TEST_CASES_END()
19798 : : }
19799 : : };
19800 : :
19801 : : static int
19802 : 1 : run_cryptodev_testsuite(const char *pmd_name)
19803 : : {
19804 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
19805 : 1 : const enum blockcipher_test_type blk_suites[] = {
19806 : : BLKCIPHER_AES_CHAIN_TYPE,
19807 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
19808 : : BLKCIPHER_AES_DOCSIS_TYPE,
19809 : : BLKCIPHER_3DES_CHAIN_TYPE,
19810 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
19811 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
19812 : : BLKCIPHER_DES_DOCSIS_TYPE,
19813 : : BLKCIPHER_SM4_CHAIN_TYPE,
19814 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
19815 : : BLKCIPHER_AUTHONLY_TYPE};
19816 : 1 : struct unit_test_suite *static_suites[] = {
19817 : : &cryptodev_multi_session_testsuite,
19818 : : &cryptodev_null_testsuite,
19819 : : &cryptodev_aes_ccm_auth_testsuite,
19820 : : &cryptodev_aes_gcm_auth_testsuite,
19821 : : &cryptodev_aes_gmac_auth_testsuite,
19822 : : &cryptodev_snow3g_testsuite,
19823 : : &cryptodev_chacha20_poly1305_testsuite,
19824 : : &cryptodev_zuc_testsuite,
19825 : : &cryptodev_hmac_md5_auth_testsuite,
19826 : : &cryptodev_kasumi_testsuite,
19827 : : &cryptodev_esn_testsuite,
19828 : : &cryptodev_negative_aes_gcm_testsuite,
19829 : : &cryptodev_negative_aes_gmac_testsuite,
19830 : : &cryptodev_mixed_cipher_hash_testsuite,
19831 : : &cryptodev_negative_hmac_sha1_testsuite,
19832 : : &cryptodev_gen_testsuite,
19833 : : &cryptodev_sm4_gcm_testsuite,
19834 : : #ifdef RTE_LIB_SECURITY
19835 : : &ipsec_proto_testsuite,
19836 : : &pdcp_proto_testsuite,
19837 : : &docsis_proto_testsuite,
19838 : : &tls12_record_proto_testsuite,
19839 : : &dtls12_record_proto_testsuite,
19840 : : &tls13_record_proto_testsuite,
19841 : : #endif
19842 : : &end_testsuite
19843 : : };
19844 : : static struct unit_test_suite ts = {
19845 : : .suite_name = "Cryptodev Unit Test Suite",
19846 : : .setup = testsuite_setup,
19847 : : .teardown = testsuite_teardown,
19848 : : .unit_test_cases = {TEST_CASES_END()}
19849 : : };
19850 : :
19851 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
19852 : :
19853 [ - + ]: 1 : if (gbl_driver_id == -1) {
19854 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
19855 : 0 : return TEST_SKIPPED;
19856 : : }
19857 : :
19858 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19859 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
19860 : :
19861 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
19862 [ + + ]: 25 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19863 : 1 : ret = unit_test_suite_runner(&ts);
19864 : :
19865 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
19866 : 1 : free(ts.unit_test_suites);
19867 : 1 : return ret;
19868 : : }
19869 : :
19870 : : static int
19871 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
19872 : : {
19873 : : struct rte_cryptodev_info dev_info;
19874 : : uint8_t i, nb_devs;
19875 : : int driver_id;
19876 : :
19877 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
19878 [ # # ]: 0 : if (driver_id == -1) {
19879 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
19880 : 0 : return TEST_SKIPPED;
19881 : : }
19882 : :
19883 : 0 : nb_devs = rte_cryptodev_count();
19884 [ # # ]: 0 : if (nb_devs < 1) {
19885 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
19886 : 0 : return TEST_SKIPPED;
19887 : : }
19888 : :
19889 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
19890 : 0 : rte_cryptodev_info_get(i, &dev_info);
19891 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
19892 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
19893 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
19894 : : flag_name);
19895 : 0 : return TEST_SKIPPED;
19896 : : }
19897 : : return 0; /* found */
19898 : : }
19899 : : }
19900 : :
19901 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
19902 : 0 : return TEST_SKIPPED;
19903 : : }
19904 : :
19905 : : static int
19906 : 0 : test_cryptodev_qat(void)
19907 : : {
19908 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19909 : : }
19910 : :
19911 : : static int
19912 : 0 : test_cryptodev_uadk(void)
19913 : : {
19914 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
19915 : : }
19916 : :
19917 : : static int
19918 : 0 : test_cryptodev_virtio(void)
19919 : : {
19920 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
19921 : : }
19922 : :
19923 : : static int
19924 : 0 : test_cryptodev_virtio_user(void)
19925 : : {
19926 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_USER_PMD));
19927 : : }
19928 : :
19929 : : static int
19930 : 0 : test_cryptodev_aesni_mb(void)
19931 : : {
19932 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19933 : : }
19934 : :
19935 : : static int
19936 : 0 : test_cryptodev_cpu_aesni_mb(void)
19937 : : {
19938 : : int32_t rc;
19939 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19940 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19941 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19942 : 0 : gbl_action_type = at;
19943 : 0 : return rc;
19944 : : }
19945 : :
19946 : : static int
19947 : 0 : test_cryptodev_chacha_poly_mb(void)
19948 : : {
19949 : : int32_t rc;
19950 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19951 : 0 : rc = run_cryptodev_testsuite(
19952 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
19953 : 0 : gbl_action_type = at;
19954 : 0 : return rc;
19955 : : }
19956 : :
19957 : : static int
19958 : 1 : test_cryptodev_openssl(void)
19959 : : {
19960 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
19961 : : }
19962 : :
19963 : : static int
19964 : 0 : test_cryptodev_aesni_gcm(void)
19965 : : {
19966 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19967 : : }
19968 : :
19969 : : static int
19970 : 0 : test_cryptodev_cpu_aesni_gcm(void)
19971 : : {
19972 : : int32_t rc;
19973 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19974 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19975 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19976 : 0 : gbl_action_type = at;
19977 : 0 : return rc;
19978 : : }
19979 : :
19980 : : static int
19981 : 0 : test_cryptodev_mlx5(void)
19982 : : {
19983 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
19984 : : }
19985 : :
19986 : : static int
19987 : 0 : test_cryptodev_null(void)
19988 : : {
19989 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
19990 : : }
19991 : :
19992 : : static int
19993 : 0 : test_cryptodev_sw_snow3g(void)
19994 : : {
19995 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
19996 : : }
19997 : :
19998 : : static int
19999 : 0 : test_cryptodev_sw_kasumi(void)
20000 : : {
20001 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
20002 : : }
20003 : :
20004 : : static int
20005 : 0 : test_cryptodev_sw_zuc(void)
20006 : : {
20007 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
20008 : : }
20009 : :
20010 : : static int
20011 : 0 : test_cryptodev_armv8(void)
20012 : : {
20013 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
20014 : : }
20015 : :
20016 : : static int
20017 : 0 : test_cryptodev_mrvl(void)
20018 : : {
20019 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
20020 : : }
20021 : :
20022 : : #ifdef RTE_CRYPTO_SCHEDULER
20023 : :
20024 : : static int
20025 : 0 : test_cryptodev_scheduler(void)
20026 : : {
20027 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
20028 : 0 : const enum blockcipher_test_type blk_suites[] = {
20029 : : BLKCIPHER_AES_CHAIN_TYPE,
20030 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
20031 : : BLKCIPHER_AUTHONLY_TYPE
20032 : : };
20033 : : static struct unit_test_suite scheduler_multicore = {
20034 : : .suite_name = "Scheduler Multicore Unit Test Suite",
20035 : : .setup = scheduler_multicore_testsuite_setup,
20036 : : .teardown = scheduler_mode_testsuite_teardown,
20037 : : .unit_test_cases = {TEST_CASES_END()}
20038 : : };
20039 : : static struct unit_test_suite scheduler_round_robin = {
20040 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
20041 : : .setup = scheduler_roundrobin_testsuite_setup,
20042 : : .teardown = scheduler_mode_testsuite_teardown,
20043 : : .unit_test_cases = {TEST_CASES_END()}
20044 : : };
20045 : : static struct unit_test_suite scheduler_failover = {
20046 : : .suite_name = "Scheduler Failover Unit Test Suite",
20047 : : .setup = scheduler_failover_testsuite_setup,
20048 : : .teardown = scheduler_mode_testsuite_teardown,
20049 : : .unit_test_cases = {TEST_CASES_END()}
20050 : : };
20051 : : static struct unit_test_suite scheduler_pkt_size_distr = {
20052 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
20053 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
20054 : : .teardown = scheduler_mode_testsuite_teardown,
20055 : : .unit_test_cases = {TEST_CASES_END()}
20056 : : };
20057 : 0 : struct unit_test_suite *sched_mode_suites[] = {
20058 : : &scheduler_multicore,
20059 : : &scheduler_round_robin,
20060 : : &scheduler_failover,
20061 : : &scheduler_pkt_size_distr
20062 : : };
20063 : : static struct unit_test_suite scheduler_config = {
20064 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
20065 : : .unit_test_cases = {
20066 : : TEST_CASE(test_scheduler_attach_worker_op),
20067 : : TEST_CASE(test_scheduler_mode_multicore_op),
20068 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
20069 : : TEST_CASE(test_scheduler_mode_failover_op),
20070 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
20071 : : TEST_CASE(test_scheduler_detach_worker_op),
20072 : :
20073 : : TEST_CASES_END() /**< NULL terminate array */
20074 : : }
20075 : : };
20076 : 0 : struct unit_test_suite *static_suites[] = {
20077 : : &scheduler_config,
20078 : : &end_testsuite
20079 : : };
20080 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
20081 : : #ifdef RTE_LIB_SECURITY
20082 : : &docsis_proto_testsuite,
20083 : : #endif
20084 : : &end_testsuite
20085 : : };
20086 : : static struct unit_test_suite ts = {
20087 : : .suite_name = "Scheduler Unit Test Suite",
20088 : : .setup = scheduler_testsuite_setup,
20089 : : .teardown = testsuite_teardown,
20090 : : .unit_test_cases = {TEST_CASES_END()}
20091 : : };
20092 : :
20093 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
20094 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
20095 : :
20096 [ # # ]: 0 : if (gbl_driver_id == -1) {
20097 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
20098 : 0 : return TEST_SKIPPED;
20099 : : }
20100 : :
20101 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
20102 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
20103 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
20104 : 0 : return TEST_SKIPPED;
20105 : : }
20106 : :
20107 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20108 : : uint8_t blk_i = 0;
20109 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
20110 : : (struct unit_test_suite *) *
20111 : : (RTE_DIM(blk_suites) +
20112 : : RTE_DIM(sched_mode_static_suites) + 1));
20113 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20114 : : blk_suites, RTE_DIM(blk_suites));
20115 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20116 : : sched_mode_static_suites,
20117 : : RTE_DIM(sched_mode_static_suites));
20118 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
20119 : : }
20120 : :
20121 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
20122 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
20123 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
20124 : : RTE_DIM(sched_mode_suites));
20125 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
20126 : 0 : ret = unit_test_suite_runner(&ts);
20127 : :
20128 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20129 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
20130 : : (*sched_mode_suites[sched_i]),
20131 : : RTE_DIM(blk_suites));
20132 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
20133 : : }
20134 : 0 : free(ts.unit_test_suites);
20135 : 0 : return ret;
20136 : : }
20137 : :
20138 : 252 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
20139 : :
20140 : : #endif
20141 : :
20142 : : static int
20143 : 0 : test_cryptodev_dpaa2_sec(void)
20144 : : {
20145 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20146 : : }
20147 : :
20148 : : static int
20149 : 0 : test_cryptodev_dpaa_sec(void)
20150 : : {
20151 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20152 : : }
20153 : :
20154 : : static int
20155 : 0 : test_cryptodev_ccp(void)
20156 : : {
20157 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
20158 : : }
20159 : :
20160 : : static int
20161 : 0 : test_cryptodev_octeontx(void)
20162 : : {
20163 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
20164 : : }
20165 : :
20166 : : static int
20167 : 0 : test_cryptodev_caam_jr(void)
20168 : : {
20169 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
20170 : : }
20171 : :
20172 : : static int
20173 : 0 : test_cryptodev_nitrox(void)
20174 : : {
20175 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
20176 : : }
20177 : :
20178 : : static int
20179 : 0 : test_cryptodev_bcmfs(void)
20180 : : {
20181 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
20182 : : }
20183 : :
20184 : : static int
20185 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
20186 : : {
20187 : : int ret;
20188 : :
20189 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
20190 [ # # ]: 0 : if (ret)
20191 : : return ret;
20192 : :
20193 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
20194 : 0 : ret = run_cryptodev_testsuite(pmd_name);
20195 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
20196 : :
20197 : 0 : return ret;
20198 : : }
20199 : :
20200 : : static int
20201 : 0 : test_cryptodev_qat_raw_api(void)
20202 : : {
20203 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20204 : : }
20205 : :
20206 : : static int
20207 : 0 : test_cryptodev_cn9k(void)
20208 : : {
20209 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
20210 : : }
20211 : :
20212 : : static int
20213 : 0 : test_cryptodev_cn10k(void)
20214 : : {
20215 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20216 : : }
20217 : :
20218 : : static int
20219 : 0 : test_cryptodev_cn10k_raw_api(void)
20220 : : {
20221 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20222 : : }
20223 : :
20224 : : static int
20225 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
20226 : : {
20227 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20228 : : }
20229 : :
20230 : : static int
20231 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
20232 : : {
20233 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20234 : : }
20235 : :
20236 : 252 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
20237 : : test_cryptodev_cn10k_raw_api);
20238 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
20239 : : test_cryptodev_dpaa2_sec_raw_api);
20240 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
20241 : : test_cryptodev_dpaa_sec_raw_api);
20242 : 252 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
20243 : : test_cryptodev_qat_raw_api);
20244 : 252 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
20245 : 252 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
20246 : 252 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
20247 : : test_cryptodev_cpu_aesni_mb);
20248 : 252 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
20249 : : test_cryptodev_chacha_poly_mb);
20250 : 252 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
20251 : 252 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
20252 : 252 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
20253 : : test_cryptodev_cpu_aesni_gcm);
20254 : 252 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
20255 : 252 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
20256 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
20257 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
20258 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
20259 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
20260 : 252 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
20261 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
20262 : 252 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
20263 : 252 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
20264 : 252 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
20265 : 252 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
20266 : 252 : REGISTER_DRIVER_TEST(cryptodev_virtio_user_autotest, test_cryptodev_virtio_user);
20267 : 252 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
20268 : 252 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
20269 : 252 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
20270 : 252 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
20271 : 252 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
20272 : 252 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
|