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 : 0 : ops_deq[i] = NULL;
2629 : : }
2630 : :
2631 : : return TEST_SUCCESS;
2632 : : }
2633 : :
2634 : : static int
2635 : 2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2636 : : {
2637 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2638 : : struct crypto_unittest_params *ut_params = &unittest_params;
2639 : : /* Verify the capabilities */
2640 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2641 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2642 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2643 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2644 : : &cap_idx) == NULL)
2645 : : return TEST_SKIPPED;
2646 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2647 : 2 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2648 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2649 : : &cap_idx) == NULL)
2650 : : return TEST_SKIPPED;
2651 : :
2652 : : /* Generate test mbuf data and space for digest */
2653 : 2 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2654 : : catch_22_quote, QUOTE_512_BYTES, 0);
2655 : :
2656 : 2 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2657 : : DIGEST_BYTE_LENGTH_SHA1);
2658 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2659 : :
2660 : : /* Setup Cipher Parameters */
2661 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2662 : 2 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2663 : :
2664 : 2 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2665 : 2 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2666 : 2 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2667 : 2 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2668 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2669 : 2 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2670 : :
2671 : : /* Setup HMAC Parameters */
2672 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2673 : :
2674 : 2 : ut_params->auth_xform.next = NULL;
2675 : :
2676 : 2 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2677 : 2 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2678 : 2 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2679 : 2 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2680 : 2 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2681 : :
2682 : 2 : rte_errno = 0;
2683 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(
2684 : 2 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2685 : : ts_params->session_mpool);
2686 [ + - ]: 2 : if (rte_errno == ENOTSUP)
2687 : : return TEST_SKIPPED;
2688 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2689 : :
2690 : : /* Generate crypto op data structure */
2691 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2692 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2693 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
2694 : : "Failed to allocate symmetric crypto operation struct");
2695 : :
2696 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2697 : :
2698 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2699 : :
2700 : : /* set crypto operation source mbuf */
2701 : 2 : sym_op->m_src = ut_params->ibuf;
2702 : :
2703 : : /* Set crypto operation authentication parameters */
2704 : 2 : sym_op->auth.digest.data = ut_params->digest;
2705 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2706 : : ut_params->ibuf, QUOTE_512_BYTES);
2707 : :
2708 : 2 : sym_op->auth.data.offset = 0;
2709 : 2 : sym_op->auth.data.length = QUOTE_512_BYTES;
2710 : :
2711 : : /* Copy IV at the end of the crypto operation */
2712 [ - + ]: 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2713 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2714 : :
2715 : : /* Set crypto operation cipher parameters */
2716 : 2 : sym_op->cipher.data.offset = 0;
2717 : 2 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2718 : :
2719 : : /* Process crypto operation */
2720 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2721 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2722 : : ut_params->op);
2723 : : else
2724 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
2725 : : process_crypto_request(ts_params->valid_devs[0],
2726 : : ut_params->op),
2727 : : "failed to process sym crypto op");
2728 : :
2729 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2730 : : "crypto op processing failed");
2731 : :
2732 : : /* Validate obuf */
2733 : 2 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2734 : : uint8_t *);
2735 : :
2736 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2737 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2738 : : QUOTE_512_BYTES,
2739 : : "ciphertext data not as expected");
2740 : :
2741 : 2 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2742 : :
2743 [ + - - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2744 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2745 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2746 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2747 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2748 : : DIGEST_BYTE_LENGTH_SHA1,
2749 : : "Generated digest data not as expected");
2750 : :
2751 : : return TEST_SUCCESS;
2752 : : }
2753 : :
2754 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2755 : :
2756 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2757 : :
2758 : : static uint8_t hmac_sha512_key[] = {
2759 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2760 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2761 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2762 : : 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2763 : : 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2764 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2765 : : 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2766 : : 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2767 : :
2768 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2769 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2770 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2771 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2772 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2773 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2774 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2775 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2776 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2777 : :
2778 : :
2779 : :
2780 : : static int
2781 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2782 : : struct crypto_unittest_params *ut_params,
2783 : : uint8_t *cipher_key,
2784 : : uint8_t *hmac_key);
2785 : :
2786 : : static int
2787 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2788 : : struct crypto_unittest_params *ut_params,
2789 : : struct crypto_testsuite_params *ts_params,
2790 : : const uint8_t *cipher,
2791 : : const uint8_t *digest,
2792 : : const uint8_t *iv);
2793 : :
2794 : :
2795 : : static int
2796 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2797 : : struct crypto_unittest_params *ut_params,
2798 : : uint8_t *cipher_key,
2799 : : uint8_t *hmac_key)
2800 : : {
2801 : :
2802 : : /* Setup Cipher Parameters */
2803 : 4 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2804 : 4 : ut_params->cipher_xform.next = NULL;
2805 : :
2806 : 4 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2807 : 4 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2808 : 4 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2809 : 4 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2810 : 4 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2811 : 4 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2812 : :
2813 : : /* Setup HMAC Parameters */
2814 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2815 : 4 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2816 : :
2817 : 4 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2818 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2819 : 4 : ut_params->auth_xform.auth.key.data = hmac_key;
2820 : 4 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2821 : 4 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2822 : :
2823 : : return TEST_SUCCESS;
2824 : : }
2825 : :
2826 : :
2827 : : static int
2828 : 5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2829 : : struct crypto_unittest_params *ut_params,
2830 : : struct crypto_testsuite_params *ts_params,
2831 : : const uint8_t *cipher,
2832 : : const uint8_t *digest,
2833 : : const uint8_t *iv)
2834 : : {
2835 : : int ret;
2836 : :
2837 : : /* Generate test mbuf data and digest */
2838 : 5 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2839 : : (const char *)
2840 : : cipher,
2841 : : QUOTE_512_BYTES, 0);
2842 : :
2843 : 5 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2844 : : DIGEST_BYTE_LENGTH_SHA512);
2845 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2846 : :
2847 : : rte_memcpy(ut_params->digest,
2848 : : digest,
2849 : : DIGEST_BYTE_LENGTH_SHA512);
2850 : :
2851 : : /* Generate Crypto op data structure */
2852 : 5 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2853 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2854 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->op,
2855 : : "Failed to allocate symmetric crypto operation struct");
2856 : :
2857 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2858 : :
2859 : 5 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2860 : :
2861 : : /* set crypto operation source mbuf */
2862 : 5 : sym_op->m_src = ut_params->ibuf;
2863 : :
2864 : 5 : sym_op->auth.digest.data = ut_params->digest;
2865 [ - + ]: 5 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2866 : : ut_params->ibuf, QUOTE_512_BYTES);
2867 : :
2868 : 5 : sym_op->auth.data.offset = 0;
2869 : 5 : sym_op->auth.data.length = QUOTE_512_BYTES;
2870 : :
2871 : : /* Copy IV at the end of the crypto operation */
2872 [ - + ]: 5 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2873 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2874 : :
2875 : 5 : sym_op->cipher.data.offset = 0;
2876 : 5 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2877 : :
2878 : : /* Process crypto operation */
2879 [ - + ]: 5 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2880 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2881 : : ut_params->op);
2882 [ - + ]: 5 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2883 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2884 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2885 : : return ret;
2886 : : } else
2887 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(
2888 : : process_crypto_request(ts_params->valid_devs[0],
2889 : : ut_params->op),
2890 : : "failed to process sym crypto op");
2891 : :
2892 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2893 : : "crypto op processing failed");
2894 : :
2895 : 5 : ut_params->obuf = ut_params->op->sym->m_src;
2896 : :
2897 : : /* Validate obuf */
2898 [ - + ]: 5 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2899 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2900 : : catch_22_quote,
2901 : : QUOTE_512_BYTES,
2902 : : "Plaintext data not as expected");
2903 : :
2904 : : /* Validate obuf */
2905 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2906 : : "Digest verification failed");
2907 : :
2908 : : return TEST_SUCCESS;
2909 : : }
2910 : :
2911 : : /* ***** SNOW 3G Tests ***** */
2912 : : static int
2913 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2914 : : const uint8_t *key, const uint8_t key_len,
2915 : : const uint8_t iv_len, const uint8_t auth_len,
2916 : : enum rte_crypto_auth_operation op,
2917 : : enum rte_crypto_auth_algorithm algo)
2918 : : {
2919 : 0 : uint8_t *hash_key = alloca(key_len);
2920 : :
2921 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2922 : : struct crypto_unittest_params *ut_params = &unittest_params;
2923 : :
2924 : : memcpy(hash_key, key, key_len);
2925 : :
2926 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2927 : :
2928 : : /* Setup Authentication Parameters */
2929 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2930 : 0 : ut_params->auth_xform.next = NULL;
2931 : :
2932 : 0 : ut_params->auth_xform.auth.op = op;
2933 : 0 : ut_params->auth_xform.auth.algo = algo;
2934 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2935 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2936 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2937 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2938 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2939 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2940 : : &ut_params->auth_xform, ts_params->session_mpool);
2941 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2942 : : return TEST_SKIPPED;
2943 : :
2944 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2945 : : return 0;
2946 : : }
2947 : :
2948 : : static int
2949 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2950 : : enum rte_crypto_cipher_operation op,
2951 : : enum rte_crypto_cipher_algorithm algo,
2952 : : const uint8_t *key, const uint8_t key_len,
2953 : : uint8_t iv_len)
2954 : : {
2955 : 0 : uint8_t *cipher_key = alloca(key_len);
2956 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2957 : : struct crypto_unittest_params *ut_params = &unittest_params;
2958 : :
2959 : : memcpy(cipher_key, key, key_len);
2960 : :
2961 : : /* Setup Cipher Parameters */
2962 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2963 : 0 : ut_params->cipher_xform.next = NULL;
2964 : :
2965 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2966 : 0 : ut_params->cipher_xform.cipher.op = op;
2967 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2968 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2969 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2970 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2971 : :
2972 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2973 : :
2974 : : /* Create Crypto session */
2975 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2976 : : &ut_params->cipher_xform, ts_params->session_mpool);
2977 : :
2978 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2979 : : return TEST_SKIPPED;
2980 : :
2981 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2982 : : return 0;
2983 : : }
2984 : :
2985 : : static int
2986 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2987 : : unsigned int cipher_len,
2988 : : unsigned int cipher_offset)
2989 : : {
2990 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 : : struct crypto_unittest_params *ut_params = &unittest_params;
2992 : :
2993 : : /* Generate Crypto op data structure */
2994 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2995 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2996 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2997 : : "Failed to allocate pktmbuf offload");
2998 : :
2999 : : /* Set crypto operation data parameters */
3000 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3001 : :
3002 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3003 : :
3004 : : /* set crypto operation source mbuf */
3005 : 0 : sym_op->m_src = ut_params->ibuf;
3006 : :
3007 : : /* iv */
3008 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3009 : : iv, iv_len);
3010 : 0 : sym_op->cipher.data.length = cipher_len;
3011 : 0 : sym_op->cipher.data.offset = cipher_offset;
3012 : 0 : return 0;
3013 : : }
3014 : :
3015 : : static int
3016 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
3017 : : unsigned int cipher_len,
3018 : : unsigned int cipher_offset)
3019 : : {
3020 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3021 : : struct crypto_unittest_params *ut_params = &unittest_params;
3022 : :
3023 : : /* Generate Crypto op data structure */
3024 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3025 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3026 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3027 : : "Failed to allocate pktmbuf offload");
3028 : :
3029 : : /* Set crypto operation data parameters */
3030 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3031 : :
3032 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3033 : :
3034 : : /* set crypto operation source mbuf */
3035 : 0 : sym_op->m_src = ut_params->ibuf;
3036 : 0 : sym_op->m_dst = ut_params->obuf;
3037 : :
3038 : : /* iv */
3039 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3040 : : iv, iv_len);
3041 : 0 : sym_op->cipher.data.length = cipher_len;
3042 : 0 : sym_op->cipher.data.offset = cipher_offset;
3043 : 0 : return 0;
3044 : : }
3045 : :
3046 : : static int
3047 : 1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
3048 : : enum rte_crypto_cipher_operation cipher_op,
3049 : : enum rte_crypto_auth_operation auth_op,
3050 : : enum rte_crypto_auth_algorithm auth_algo,
3051 : : enum rte_crypto_cipher_algorithm cipher_algo,
3052 : : const uint8_t *a_key, uint8_t a_key_len,
3053 : : const uint8_t *c_key, uint8_t c_key_len,
3054 : : uint8_t auth_iv_len, uint8_t auth_len,
3055 : : uint8_t cipher_iv_len)
3056 : :
3057 : : {
3058 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3059 : : struct crypto_unittest_params *ut_params = &unittest_params;
3060 : :
3061 : : /* Setup Authentication Parameters */
3062 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3063 : 1 : ut_params->auth_xform.next = NULL;
3064 : :
3065 : 1 : ut_params->auth_xform.auth.op = auth_op;
3066 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3067 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3068 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3069 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3070 : : /* Auth IV will be after cipher IV */
3071 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3072 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3073 : :
3074 : : /* Setup Cipher Parameters */
3075 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3076 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3077 : :
3078 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3079 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3080 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3081 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3082 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3083 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3084 : :
3085 : 1 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
3086 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3087 : :
3088 : : /* Create Crypto session*/
3089 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3090 : : &ut_params->cipher_xform, ts_params->session_mpool);
3091 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3092 : : return TEST_SKIPPED;
3093 : :
3094 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3095 : : return 0;
3096 : : }
3097 : :
3098 : : static int
3099 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
3100 : : enum rte_crypto_cipher_operation cipher_op,
3101 : : enum rte_crypto_auth_operation auth_op,
3102 : : enum rte_crypto_auth_algorithm auth_algo,
3103 : : enum rte_crypto_cipher_algorithm cipher_algo,
3104 : : const struct wireless_test_data *tdata)
3105 : : {
3106 : 0 : const uint8_t key_len = tdata->key.len;
3107 : 0 : uint8_t *cipher_auth_key = alloca(key_len);
3108 : :
3109 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3110 : : struct crypto_unittest_params *ut_params = &unittest_params;
3111 : 0 : const uint8_t *key = tdata->key.data;
3112 : 0 : const uint8_t auth_len = tdata->digest.len;
3113 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
3114 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
3115 : :
3116 : : memcpy(cipher_auth_key, key, key_len);
3117 : :
3118 : : /* Setup Authentication Parameters */
3119 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3120 : 0 : ut_params->auth_xform.next = NULL;
3121 : :
3122 : 0 : ut_params->auth_xform.auth.op = auth_op;
3123 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
3124 : 0 : ut_params->auth_xform.auth.key.length = key_len;
3125 : : /* Hash key = cipher key */
3126 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
3127 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
3128 : : /* Auth IV will be after cipher IV */
3129 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3130 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3131 : :
3132 : : /* Setup Cipher Parameters */
3133 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3134 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3135 : :
3136 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3137 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
3138 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
3139 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
3140 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3141 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3142 : :
3143 : :
3144 : 0 : debug_hexdump(stdout, "key:", key, key_len);
3145 : :
3146 : : /* Create Crypto session*/
3147 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3148 : : &ut_params->cipher_xform, ts_params->session_mpool);
3149 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3150 : : return TEST_SKIPPED;
3151 : :
3152 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3153 : : return 0;
3154 : : }
3155 : :
3156 : : static int
3157 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
3158 : : const struct wireless_test_data *tdata)
3159 : : {
3160 : 0 : return create_wireless_cipher_auth_session(dev_id,
3161 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3162 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
3163 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
3164 : : }
3165 : :
3166 : : static int
3167 : 1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
3168 : : enum rte_crypto_cipher_operation cipher_op,
3169 : : enum rte_crypto_auth_operation auth_op,
3170 : : enum rte_crypto_auth_algorithm auth_algo,
3171 : : enum rte_crypto_cipher_algorithm cipher_algo,
3172 : : const uint8_t *a_key, const uint8_t a_key_len,
3173 : : const uint8_t *c_key, const uint8_t c_key_len,
3174 : : uint8_t auth_iv_len, uint8_t auth_len,
3175 : : uint8_t cipher_iv_len)
3176 : : {
3177 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3178 : : struct crypto_unittest_params *ut_params = &unittest_params;
3179 : :
3180 : : /* Setup Authentication Parameters */
3181 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3182 : 1 : ut_params->auth_xform.auth.op = auth_op;
3183 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
3184 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3185 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3186 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3187 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3188 : : /* Auth IV will be after cipher IV */
3189 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3190 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3191 : :
3192 : : /* Setup Cipher Parameters */
3193 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3194 : 1 : ut_params->cipher_xform.next = NULL;
3195 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3196 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3197 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3198 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3199 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3200 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3201 : :
3202 : 1 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
3203 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3204 : :
3205 : : /* Create Crypto session*/
3206 [ - + ]: 1 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3207 : 0 : ut_params->auth_xform.next = NULL;
3208 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3209 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3210 : : &ut_params->cipher_xform, ts_params->session_mpool);
3211 : : } else
3212 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3213 : : &ut_params->auth_xform, ts_params->session_mpool);
3214 : :
3215 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3216 : : return TEST_SKIPPED;
3217 : :
3218 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3219 : :
3220 : : return 0;
3221 : : }
3222 : :
3223 : : static int
3224 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
3225 : : unsigned int auth_tag_len,
3226 : : const uint8_t *iv, unsigned int iv_len,
3227 : : unsigned int data_pad_len,
3228 : : enum rte_crypto_auth_operation op,
3229 : : unsigned int auth_len, unsigned int auth_offset)
3230 : : {
3231 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3232 : :
3233 : : struct crypto_unittest_params *ut_params = &unittest_params;
3234 : :
3235 : : /* Generate Crypto op data structure */
3236 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3237 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3238 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3239 : : "Failed to allocate pktmbuf offload");
3240 : :
3241 : : /* Set crypto operation data parameters */
3242 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3243 : :
3244 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3245 : :
3246 : : /* set crypto operation source mbuf */
3247 : 0 : sym_op->m_src = ut_params->ibuf;
3248 : :
3249 : : /* iv */
3250 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3251 : : iv, iv_len);
3252 : : /* digest */
3253 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3254 : : ut_params->ibuf, auth_tag_len);
3255 : :
3256 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3257 : : "no room to append auth tag");
3258 : 0 : ut_params->digest = sym_op->auth.digest.data;
3259 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3260 : : ut_params->ibuf, data_pad_len);
3261 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3262 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3263 : : else
3264 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3265 : :
3266 : 0 : debug_hexdump(stdout, "digest:",
3267 : 0 : sym_op->auth.digest.data,
3268 : : auth_tag_len);
3269 : :
3270 : 0 : sym_op->auth.data.length = auth_len;
3271 : 0 : sym_op->auth.data.offset = auth_offset;
3272 : :
3273 : 0 : return 0;
3274 : : }
3275 : :
3276 : : static int
3277 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3278 : : enum rte_crypto_auth_operation op)
3279 : : {
3280 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3281 : : struct crypto_unittest_params *ut_params = &unittest_params;
3282 : :
3283 : 0 : const uint8_t *auth_tag = tdata->digest.data;
3284 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
3285 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3286 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3287 : :
3288 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
3289 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3290 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
3291 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
3292 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3293 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
3294 : :
3295 : : /* Generate Crypto op data structure */
3296 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3297 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3298 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3299 : : "Failed to allocate pktmbuf offload");
3300 : : /* Set crypto operation data parameters */
3301 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3302 : :
3303 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3304 : :
3305 : : /* set crypto operation source mbuf */
3306 : 0 : sym_op->m_src = ut_params->ibuf;
3307 : :
3308 : : /* digest */
3309 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3310 : : ut_params->ibuf, auth_tag_len);
3311 : :
3312 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3313 : : "no room to append auth tag");
3314 : 0 : ut_params->digest = sym_op->auth.digest.data;
3315 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3316 : : ut_params->ibuf, data_pad_len);
3317 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3318 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3319 : : else
3320 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3321 : :
3322 : 0 : debug_hexdump(stdout, "digest:",
3323 : 0 : sym_op->auth.digest.data,
3324 : : auth_tag_len);
3325 : :
3326 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3327 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3328 : : IV_OFFSET);
3329 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3330 : 0 : iv_ptr += cipher_iv_len;
3331 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3332 : :
3333 : 0 : sym_op->cipher.data.length = cipher_len;
3334 : 0 : sym_op->cipher.data.offset = 0;
3335 : 0 : sym_op->auth.data.length = auth_len;
3336 : 0 : sym_op->auth.data.offset = 0;
3337 : :
3338 : 0 : return 0;
3339 : : }
3340 : :
3341 : : static int
3342 : : create_zuc_cipher_hash_generate_operation(
3343 : : const struct wireless_test_data *tdata)
3344 : : {
3345 : 0 : return create_wireless_cipher_hash_operation(tdata,
3346 : : RTE_CRYPTO_AUTH_OP_GENERATE);
3347 : : }
3348 : :
3349 : : static int
3350 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3351 : : const unsigned auth_tag_len,
3352 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3353 : : unsigned data_pad_len,
3354 : : enum rte_crypto_auth_operation op,
3355 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3356 : : const unsigned cipher_len, const unsigned cipher_offset,
3357 : : const unsigned auth_len, const unsigned auth_offset)
3358 : : {
3359 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3360 : : struct crypto_unittest_params *ut_params = &unittest_params;
3361 : :
3362 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
3363 : : ut_params->cipher_xform.cipher.algo;
3364 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3365 : : ut_params->auth_xform.auth.algo;
3366 : :
3367 : : /* Generate Crypto op data structure */
3368 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3369 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3370 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3371 : : "Failed to allocate pktmbuf offload");
3372 : : /* Set crypto operation data parameters */
3373 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3374 : :
3375 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3376 : :
3377 : : /* set crypto operation source mbuf */
3378 : 0 : sym_op->m_src = ut_params->ibuf;
3379 : :
3380 : : /* digest */
3381 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3382 : : ut_params->ibuf, auth_tag_len);
3383 : :
3384 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3385 : : "no room to append auth tag");
3386 : 0 : ut_params->digest = sym_op->auth.digest.data;
3387 : :
3388 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3389 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3390 : : ut_params->ibuf, data_pad_len);
3391 : : } else {
3392 : : struct rte_mbuf *m = ut_params->ibuf;
3393 : : unsigned int offset = data_pad_len;
3394 : :
3395 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3396 : 0 : offset -= m->data_len;
3397 : : m = m->next;
3398 : : }
3399 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3400 : : m, offset);
3401 : : }
3402 : :
3403 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3404 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3405 : : else
3406 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3407 : :
3408 : 0 : debug_hexdump(stdout, "digest:",
3409 : 0 : sym_op->auth.digest.data,
3410 : : auth_tag_len);
3411 : :
3412 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3413 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3414 : : IV_OFFSET);
3415 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3416 : 0 : iv_ptr += cipher_iv_len;
3417 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3418 : :
3419 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3420 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3421 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3422 : 0 : sym_op->cipher.data.length = cipher_len;
3423 : 0 : sym_op->cipher.data.offset = cipher_offset;
3424 : : } else {
3425 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3426 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3427 : : }
3428 : :
3429 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3430 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3431 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3432 : 0 : sym_op->auth.data.length = auth_len;
3433 : 0 : sym_op->auth.data.offset = auth_offset;
3434 : : } else {
3435 : 0 : sym_op->auth.data.length = auth_len >> 3;
3436 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3437 : : }
3438 : :
3439 : : return 0;
3440 : : }
3441 : :
3442 : : static int
3443 : 2 : create_wireless_algo_auth_cipher_operation(
3444 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3445 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3446 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3447 : : unsigned int data_pad_len,
3448 : : unsigned int cipher_len, unsigned int cipher_offset,
3449 : : unsigned int auth_len, unsigned int auth_offset,
3450 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3451 : : {
3452 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3453 : : struct crypto_unittest_params *ut_params = &unittest_params;
3454 : :
3455 : 2 : enum rte_crypto_cipher_algorithm cipher_algo =
3456 : : ut_params->cipher_xform.cipher.algo;
3457 : 2 : enum rte_crypto_auth_algorithm auth_algo =
3458 : : ut_params->auth_xform.auth.algo;
3459 : :
3460 : : /* Generate Crypto op data structure */
3461 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3462 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3463 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
3464 : : "Failed to allocate pktmbuf offload");
3465 : :
3466 : : /* Set crypto operation data parameters */
3467 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3468 : :
3469 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3470 : :
3471 : : /* set crypto operation mbufs */
3472 : 2 : sym_op->m_src = ut_params->ibuf;
3473 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE)
3474 : 0 : sym_op->m_dst = ut_params->obuf;
3475 : :
3476 : : /* digest */
3477 [ - + ]: 2 : if (!do_sgl) {
3478 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3479 : : (op_mode == IN_PLACE ?
3480 : : ut_params->ibuf : ut_params->obuf),
3481 : : uint8_t *, data_pad_len);
3482 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3483 : : (op_mode == IN_PLACE ?
3484 : : ut_params->ibuf : ut_params->obuf),
3485 : : data_pad_len);
3486 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3487 : : } else {
3488 : 2 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3489 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3490 [ - + ]: 2 : sym_op->m_src : sym_op->m_dst);
3491 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3492 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3493 : 30 : sgl_buf = sgl_buf->next;
3494 : : }
3495 : :
3496 : : /* The last segment should be large enough to hold full digest */
3497 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3498 : 0 : rte_pktmbuf_free(sgl_buf->next);
3499 : 0 : sgl_buf->next = NULL;
3500 [ # # # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3501 : : auth_tag_len - sgl_buf->data_len),
3502 : : "No room to append auth tag");
3503 : : }
3504 : :
3505 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3506 : : uint8_t *, remaining_off);
3507 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3508 : : remaining_off);
3509 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3510 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3511 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3512 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3513 : 0 : sgl_buf = sgl_buf->next;
3514 : : }
3515 : : }
3516 : :
3517 : : /* Copy digest for the verification */
3518 [ + + ]: 2 : if (verify)
3519 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3520 : :
3521 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3522 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3523 : : ut_params->op, uint8_t *, IV_OFFSET);
3524 : :
3525 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3526 : 2 : iv_ptr += cipher_iv_len;
3527 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3528 : :
3529 : : /* Only copy over the offset data needed from src to dst in OOP,
3530 : : * if the auth and cipher offsets are not aligned
3531 : : */
3532 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3533 [ # # ]: 0 : if (cipher_offset > auth_offset)
3534 : 0 : rte_memcpy(
3535 : 0 : rte_pktmbuf_mtod_offset(
3536 : : sym_op->m_dst,
3537 : : uint8_t *, auth_offset >> 3),
3538 : 0 : rte_pktmbuf_mtod_offset(
3539 : : sym_op->m_src,
3540 : : uint8_t *, auth_offset >> 3),
3541 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3542 : : }
3543 : :
3544 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3545 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3546 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3547 : 0 : sym_op->cipher.data.length = cipher_len;
3548 : 0 : sym_op->cipher.data.offset = cipher_offset;
3549 : : } else {
3550 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3551 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3552 : : }
3553 : :
3554 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3555 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3556 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3557 : 0 : sym_op->auth.data.length = auth_len;
3558 : 0 : sym_op->auth.data.offset = auth_offset;
3559 : : } else {
3560 : 2 : sym_op->auth.data.length = auth_len >> 3;
3561 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3562 : : }
3563 : :
3564 : : return 0;
3565 : : }
3566 : :
3567 : : static int
3568 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3569 : : {
3570 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3571 : : struct crypto_unittest_params *ut_params = &unittest_params;
3572 : :
3573 : : int retval;
3574 : : unsigned plaintext_pad_len;
3575 : : unsigned plaintext_len;
3576 : : uint8_t *plaintext;
3577 : : struct rte_cryptodev_info dev_info;
3578 : :
3579 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3580 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3581 : :
3582 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3583 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3584 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3585 : 0 : return TEST_SKIPPED;
3586 : : }
3587 : :
3588 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3589 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3590 : : printf("Device doesn't support RAW data-path APIs.\n");
3591 : 0 : return TEST_SKIPPED;
3592 : : }
3593 : :
3594 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3595 : : return TEST_SKIPPED;
3596 : :
3597 : : /* Verify the capabilities */
3598 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3599 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3600 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3601 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3602 : : &cap_idx) == NULL)
3603 : : return TEST_SKIPPED;
3604 : :
3605 : : /* Create SNOW 3G session */
3606 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3607 : 0 : tdata->key.data, tdata->key.len,
3608 : 0 : tdata->auth_iv.len, tdata->digest.len,
3609 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3610 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3611 [ # # ]: 0 : if (retval < 0)
3612 : : return retval;
3613 : :
3614 : : /* alloc mbuf and set payload */
3615 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3616 : :
3617 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3618 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3619 : :
3620 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3621 : : /* Append data which is padded to a multiple of */
3622 : : /* the algorithms block size */
3623 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3624 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3625 : : plaintext_pad_len);
3626 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3627 : :
3628 : : /* Create SNOW 3G operation */
3629 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3630 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3631 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3632 : 0 : tdata->validAuthLenInBits.len,
3633 : : 0);
3634 [ # # ]: 0 : if (retval < 0)
3635 : : return retval;
3636 : :
3637 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3638 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3639 : : 0);
3640 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3641 : : return retval;
3642 : : } else
3643 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3644 : : ut_params->op);
3645 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3646 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3647 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3648 : : uint8_t *,
3649 : : plaintext_pad_len);
3650 : :
3651 : : /* Validate obuf */
3652 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3653 : : ut_params->digest,
3654 : : tdata->digest.data,
3655 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3656 : : "SNOW 3G Generated auth tag not as expected");
3657 : :
3658 : : return 0;
3659 : : }
3660 : :
3661 : : static int
3662 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3663 : : {
3664 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3665 : : struct crypto_unittest_params *ut_params = &unittest_params;
3666 : :
3667 : : int retval;
3668 : : unsigned plaintext_pad_len;
3669 : : unsigned plaintext_len;
3670 : : uint8_t *plaintext;
3671 : : struct rte_cryptodev_info dev_info;
3672 : :
3673 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3674 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3675 : :
3676 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3677 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3678 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3679 : 0 : return TEST_SKIPPED;
3680 : : }
3681 : :
3682 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3683 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3684 : : printf("Device doesn't support RAW data-path APIs.\n");
3685 : 0 : return TEST_SKIPPED;
3686 : : }
3687 : :
3688 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3689 : : return TEST_SKIPPED;
3690 : :
3691 : : /* Verify the capabilities */
3692 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3693 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3694 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3695 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3696 : : &cap_idx) == NULL)
3697 : : return TEST_SKIPPED;
3698 : :
3699 : : /* Create SNOW 3G session */
3700 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3701 : 0 : tdata->key.data, tdata->key.len,
3702 : 0 : tdata->auth_iv.len, tdata->digest.len,
3703 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3704 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3705 [ # # ]: 0 : if (retval < 0)
3706 : : return retval;
3707 : : /* alloc mbuf and set payload */
3708 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3709 : :
3710 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3711 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3712 : :
3713 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3714 : : /* Append data which is padded to a multiple of */
3715 : : /* the algorithms block size */
3716 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3717 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3718 : : plaintext_pad_len);
3719 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3720 : :
3721 : : /* Create SNOW 3G operation */
3722 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3723 : 0 : tdata->digest.len,
3724 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3725 : : plaintext_pad_len,
3726 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3727 : 0 : tdata->validAuthLenInBits.len,
3728 : : 0);
3729 [ # # ]: 0 : if (retval < 0)
3730 : : return retval;
3731 : :
3732 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3733 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3734 : : 0);
3735 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3736 : : return retval;
3737 : : } else
3738 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3739 : : ut_params->op);
3740 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3741 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3742 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3743 : : uint8_t *,
3744 : : plaintext_pad_len);
3745 : :
3746 : : /* Validate obuf */
3747 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3748 : : return 0;
3749 : : else
3750 : 0 : return -1;
3751 : :
3752 : : return 0;
3753 : : }
3754 : :
3755 : : static int
3756 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3757 : : {
3758 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3759 : : struct crypto_unittest_params *ut_params = &unittest_params;
3760 : :
3761 : : int retval;
3762 : : unsigned plaintext_pad_len;
3763 : : unsigned plaintext_len;
3764 : : uint8_t *plaintext;
3765 : : struct rte_cryptodev_info dev_info;
3766 : :
3767 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3768 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3769 : :
3770 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3771 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3772 : : printf("Device doesn't support RAW data-path APIs.\n");
3773 : 0 : return TEST_SKIPPED;
3774 : : }
3775 : :
3776 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3777 : : return TEST_SKIPPED;
3778 : :
3779 : : /* Verify the capabilities */
3780 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3781 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3782 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3783 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3784 : : &cap_idx) == NULL)
3785 : : return TEST_SKIPPED;
3786 : :
3787 : : /* Create KASUMI session */
3788 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3789 : 0 : tdata->key.data, tdata->key.len,
3790 : 0 : 0, tdata->digest.len,
3791 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3792 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3793 [ # # ]: 0 : if (retval < 0)
3794 : : return retval;
3795 : :
3796 : : /* alloc mbuf and set payload */
3797 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3798 : :
3799 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3800 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3801 : :
3802 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3803 : : /* Append data which is padded to a multiple of */
3804 : : /* the algorithms block size */
3805 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3806 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3807 : : plaintext_pad_len);
3808 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3809 : :
3810 : : /* Create KASUMI operation */
3811 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3812 : : NULL, 0,
3813 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3814 : 0 : tdata->plaintext.len,
3815 : : 0);
3816 [ # # ]: 0 : if (retval < 0)
3817 : : return retval;
3818 : :
3819 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3820 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3821 : : ut_params->op);
3822 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3823 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3824 : : 0);
3825 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3826 : : return retval;
3827 : : } else
3828 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3829 : : ut_params->op);
3830 : :
3831 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3832 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3833 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3834 : : uint8_t *,
3835 : : plaintext_pad_len);
3836 : :
3837 : : /* Validate obuf */
3838 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3839 : : ut_params->digest,
3840 : : tdata->digest.data,
3841 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3842 : : "KASUMI Generated auth tag not as expected");
3843 : :
3844 : : return 0;
3845 : : }
3846 : :
3847 : : static int
3848 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3849 : : {
3850 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3851 : : struct crypto_unittest_params *ut_params = &unittest_params;
3852 : :
3853 : : int retval;
3854 : : unsigned plaintext_pad_len;
3855 : : unsigned plaintext_len;
3856 : : uint8_t *plaintext;
3857 : : struct rte_cryptodev_info dev_info;
3858 : :
3859 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3860 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3861 : :
3862 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3863 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3864 : : printf("Device doesn't support RAW data-path APIs.\n");
3865 : 0 : return TEST_SKIPPED;
3866 : : }
3867 : :
3868 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3869 : : return TEST_SKIPPED;
3870 : :
3871 : : /* Verify the capabilities */
3872 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3873 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3874 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3875 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3876 : : &cap_idx) == NULL)
3877 : : return TEST_SKIPPED;
3878 : :
3879 : : /* Create KASUMI session */
3880 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3881 : 0 : tdata->key.data, tdata->key.len,
3882 : 0 : 0, tdata->digest.len,
3883 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3884 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3885 [ # # ]: 0 : if (retval < 0)
3886 : : return retval;
3887 : : /* alloc mbuf and set payload */
3888 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3889 : :
3890 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3891 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3892 : :
3893 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3894 : : /* Append data which is padded to a multiple */
3895 : : /* of the algorithms block size */
3896 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3897 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3898 : : plaintext_pad_len);
3899 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3900 : :
3901 : : /* Create KASUMI operation */
3902 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3903 : 0 : tdata->digest.len,
3904 : : NULL, 0,
3905 : : plaintext_pad_len,
3906 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3907 : 0 : tdata->plaintext.len,
3908 : : 0);
3909 [ # # ]: 0 : if (retval < 0)
3910 : : return retval;
3911 : :
3912 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3913 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3914 : : 0);
3915 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3916 : : return retval;
3917 : : } else
3918 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3919 : : ut_params->op);
3920 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3921 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3922 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3923 : : uint8_t *,
3924 : : plaintext_pad_len);
3925 : :
3926 : : /* Validate obuf */
3927 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3928 : : return 0;
3929 : : else
3930 : 0 : return -1;
3931 : :
3932 : : return 0;
3933 : : }
3934 : :
3935 : : static int
3936 : 0 : test_snow3g_hash_generate_test_case_1(void)
3937 : : {
3938 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3939 : : }
3940 : :
3941 : : static int
3942 : 0 : test_snow3g_hash_generate_test_case_2(void)
3943 : : {
3944 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3945 : : }
3946 : :
3947 : : static int
3948 : 0 : test_snow3g_hash_generate_test_case_3(void)
3949 : : {
3950 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3951 : : }
3952 : :
3953 : : static int
3954 : 0 : test_snow3g_hash_generate_test_case_4(void)
3955 : : {
3956 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3957 : : }
3958 : :
3959 : : static int
3960 : 0 : test_snow3g_hash_generate_test_case_5(void)
3961 : : {
3962 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3963 : : }
3964 : :
3965 : : static int
3966 : 0 : test_snow3g_hash_generate_test_case_6(void)
3967 : : {
3968 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3969 : : }
3970 : :
3971 : : static int
3972 : 0 : test_snow3g_hash_verify_test_case_1(void)
3973 : : {
3974 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3975 : :
3976 : : }
3977 : :
3978 : : static int
3979 : 0 : test_snow3g_hash_verify_test_case_2(void)
3980 : : {
3981 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3982 : : }
3983 : :
3984 : : static int
3985 : 0 : test_snow3g_hash_verify_test_case_3(void)
3986 : : {
3987 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3988 : : }
3989 : :
3990 : : static int
3991 : 0 : test_snow3g_hash_verify_test_case_4(void)
3992 : : {
3993 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3994 : : }
3995 : :
3996 : : static int
3997 : 0 : test_snow3g_hash_verify_test_case_5(void)
3998 : : {
3999 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
4000 : : }
4001 : :
4002 : : static int
4003 : 0 : test_snow3g_hash_verify_test_case_6(void)
4004 : : {
4005 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
4006 : : }
4007 : :
4008 : : static int
4009 : 0 : test_kasumi_hash_generate_test_case_1(void)
4010 : : {
4011 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
4012 : : }
4013 : :
4014 : : static int
4015 : 0 : test_kasumi_hash_generate_test_case_2(void)
4016 : : {
4017 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
4018 : : }
4019 : :
4020 : : static int
4021 : 0 : test_kasumi_hash_generate_test_case_3(void)
4022 : : {
4023 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
4024 : : }
4025 : :
4026 : : static int
4027 : 0 : test_kasumi_hash_generate_test_case_4(void)
4028 : : {
4029 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
4030 : : }
4031 : :
4032 : : static int
4033 : 0 : test_kasumi_hash_generate_test_case_5(void)
4034 : : {
4035 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
4036 : : }
4037 : :
4038 : : static int
4039 : 0 : test_kasumi_hash_generate_test_case_6(void)
4040 : : {
4041 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
4042 : : }
4043 : :
4044 : : static int
4045 : 0 : test_kasumi_hash_verify_test_case_1(void)
4046 : : {
4047 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
4048 : : }
4049 : :
4050 : : static int
4051 : 0 : test_kasumi_hash_verify_test_case_2(void)
4052 : : {
4053 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
4054 : : }
4055 : :
4056 : : static int
4057 : 0 : test_kasumi_hash_verify_test_case_3(void)
4058 : : {
4059 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
4060 : : }
4061 : :
4062 : : static int
4063 : 0 : test_kasumi_hash_verify_test_case_4(void)
4064 : : {
4065 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
4066 : : }
4067 : :
4068 : : static int
4069 : 0 : test_kasumi_hash_verify_test_case_5(void)
4070 : : {
4071 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
4072 : : }
4073 : :
4074 : : static int
4075 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
4076 : : {
4077 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4078 : : struct crypto_unittest_params *ut_params = &unittest_params;
4079 : :
4080 : : int retval;
4081 : : uint8_t *plaintext, *ciphertext;
4082 : : unsigned plaintext_pad_len;
4083 : : unsigned plaintext_len;
4084 : : struct rte_cryptodev_info dev_info;
4085 : :
4086 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4087 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4088 : :
4089 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4090 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4091 : : printf("Device doesn't support RAW data-path APIs.\n");
4092 : 0 : return TEST_SKIPPED;
4093 : : }
4094 : :
4095 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4096 : : return TEST_SKIPPED;
4097 : :
4098 : : /* Verify the capabilities */
4099 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4100 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4101 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4102 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4103 : : &cap_idx) == NULL)
4104 : : return TEST_SKIPPED;
4105 : :
4106 : : /* Create KASUMI session */
4107 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4108 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4109 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4110 : 0 : tdata->key.data, tdata->key.len,
4111 : 0 : tdata->cipher_iv.len);
4112 [ # # ]: 0 : if (retval < 0)
4113 : : return retval;
4114 : :
4115 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4116 : :
4117 : : /* Clear mbuf payload */
4118 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4119 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4120 : :
4121 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4122 : : /* Append data which is padded to a multiple */
4123 : : /* of the algorithms block size */
4124 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4125 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4126 : : plaintext_pad_len);
4127 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4128 : :
4129 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4130 : :
4131 : : /* Create KASUMI operation */
4132 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4133 : 0 : tdata->cipher_iv.len,
4134 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4135 : 0 : tdata->validCipherOffsetInBits.len);
4136 [ # # ]: 0 : if (retval < 0)
4137 : : return retval;
4138 : :
4139 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4140 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4141 : 0 : tdata->cipher_iv.len);
4142 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4143 : : return retval;
4144 : : } else
4145 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4146 : : ut_params->op);
4147 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4148 : :
4149 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4150 [ # # ]: 0 : if (ut_params->obuf)
4151 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4152 : : else
4153 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4154 : :
4155 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4156 : :
4157 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4158 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4159 : : /* Validate obuf */
4160 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4161 : : ciphertext,
4162 : : reference_ciphertext,
4163 : : tdata->validCipherLenInBits.len,
4164 : : "KASUMI Ciphertext data not as expected");
4165 : : return 0;
4166 : : }
4167 : :
4168 : : static int
4169 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4170 : : {
4171 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4172 : : struct crypto_unittest_params *ut_params = &unittest_params;
4173 : :
4174 : : int retval;
4175 : :
4176 : : unsigned int plaintext_pad_len;
4177 : : unsigned int plaintext_len;
4178 : :
4179 : : uint8_t buffer[10000];
4180 : : const uint8_t *ciphertext;
4181 : :
4182 : : struct rte_cryptodev_info dev_info;
4183 : :
4184 : : /* Verify the capabilities */
4185 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4186 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4187 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4188 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4189 : : &cap_idx) == NULL)
4190 : : return TEST_SKIPPED;
4191 : :
4192 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4193 : :
4194 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4195 : :
4196 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4197 : : printf("Device doesn't support in-place scatter-gather. "
4198 : : "Test Skipped.\n");
4199 : 0 : return TEST_SKIPPED;
4200 : : }
4201 : :
4202 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4203 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4204 : : printf("Device doesn't support RAW data-path APIs.\n");
4205 : 0 : return TEST_SKIPPED;
4206 : : }
4207 : :
4208 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4209 : : return TEST_SKIPPED;
4210 : :
4211 : : /* Create KASUMI session */
4212 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4213 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4214 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4215 : 0 : tdata->key.data, tdata->key.len,
4216 : 0 : tdata->cipher_iv.len);
4217 [ # # ]: 0 : if (retval < 0)
4218 : : return retval;
4219 : :
4220 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4221 : :
4222 : :
4223 : : /* Append data which is padded to a multiple */
4224 : : /* of the algorithms block size */
4225 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4226 : :
4227 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4228 : : plaintext_pad_len, 10, 0);
4229 : :
4230 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4231 : :
4232 : : /* Create KASUMI operation */
4233 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4234 : 0 : tdata->cipher_iv.len,
4235 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4236 : 0 : tdata->validCipherOffsetInBits.len);
4237 [ # # ]: 0 : if (retval < 0)
4238 : : return retval;
4239 : :
4240 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4241 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4242 : 0 : tdata->cipher_iv.len);
4243 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4244 : : return retval;
4245 : : } else
4246 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4247 : : ut_params->op);
4248 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4249 : :
4250 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4251 : :
4252 [ # # ]: 0 : if (ut_params->obuf)
4253 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4254 : : plaintext_len, buffer);
4255 : : else
4256 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4257 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4258 : : plaintext_len, buffer);
4259 : :
4260 : : /* Validate obuf */
4261 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4262 : :
4263 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4264 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4265 : : /* Validate obuf */
4266 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4267 : : ciphertext,
4268 : : reference_ciphertext,
4269 : : tdata->validCipherLenInBits.len,
4270 : : "KASUMI Ciphertext data not as expected");
4271 : : return 0;
4272 : : }
4273 : :
4274 : : static int
4275 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4276 : : {
4277 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4278 : : struct crypto_unittest_params *ut_params = &unittest_params;
4279 : :
4280 : : int retval;
4281 : : uint8_t *plaintext, *ciphertext;
4282 : : unsigned plaintext_pad_len;
4283 : : unsigned plaintext_len;
4284 : :
4285 : : /* Verify the capabilities */
4286 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4287 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4288 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4289 : : /* Data-path service does not support OOP */
4290 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4291 : : &cap_idx) == NULL)
4292 : : return TEST_SKIPPED;
4293 : :
4294 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4295 : : return TEST_SKIPPED;
4296 : :
4297 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4298 : : return TEST_SKIPPED;
4299 : :
4300 : : /* Create KASUMI session */
4301 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4302 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4303 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4304 : 0 : tdata->key.data, tdata->key.len,
4305 : 0 : tdata->cipher_iv.len);
4306 [ # # ]: 0 : if (retval < 0)
4307 : : return retval;
4308 : :
4309 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4310 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4311 : :
4312 : : /* Clear mbuf payload */
4313 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4314 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4315 : :
4316 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4317 : : /* Append data which is padded to a multiple */
4318 : : /* of the algorithms block size */
4319 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4320 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4321 : : plaintext_pad_len);
4322 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4323 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4324 : :
4325 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4326 : :
4327 : : /* Create KASUMI operation */
4328 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4329 : 0 : tdata->cipher_iv.len,
4330 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4331 : 0 : tdata->validCipherOffsetInBits.len);
4332 [ # # ]: 0 : if (retval < 0)
4333 : : return retval;
4334 : :
4335 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4336 : : ut_params->op);
4337 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4338 : :
4339 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4340 [ # # ]: 0 : if (ut_params->obuf)
4341 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4342 : : else
4343 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4344 : :
4345 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4346 : :
4347 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4348 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4349 : : /* Validate obuf */
4350 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4351 : : ciphertext,
4352 : : reference_ciphertext,
4353 : : tdata->validCipherLenInBits.len,
4354 : : "KASUMI Ciphertext data not as expected");
4355 : : return 0;
4356 : : }
4357 : :
4358 : : static int
4359 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4360 : : {
4361 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4362 : : struct crypto_unittest_params *ut_params = &unittest_params;
4363 : :
4364 : : int retval;
4365 : : unsigned int plaintext_pad_len;
4366 : : unsigned int plaintext_len;
4367 : :
4368 : : const uint8_t *ciphertext;
4369 : : uint8_t buffer[2048];
4370 : :
4371 : : struct rte_cryptodev_info dev_info;
4372 : :
4373 : : /* Verify the capabilities */
4374 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4375 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4376 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4377 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4378 : : &cap_idx) == NULL)
4379 : : return TEST_SKIPPED;
4380 : :
4381 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4382 : : return TEST_SKIPPED;
4383 : :
4384 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4385 : : return TEST_SKIPPED;
4386 : :
4387 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4388 : :
4389 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4390 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4391 : : printf("Device doesn't support out-of-place scatter-gather "
4392 : : "in both input and output mbufs. "
4393 : : "Test Skipped.\n");
4394 : 0 : return TEST_SKIPPED;
4395 : : }
4396 : :
4397 : : /* Create KASUMI session */
4398 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4399 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4400 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4401 : 0 : tdata->key.data, tdata->key.len,
4402 : 0 : tdata->cipher_iv.len);
4403 [ # # ]: 0 : if (retval < 0)
4404 : : return retval;
4405 : :
4406 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4407 : : /* Append data which is padded to a multiple */
4408 : : /* of the algorithms block size */
4409 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4410 : :
4411 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4412 : : plaintext_pad_len, 10, 0);
4413 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4414 : : plaintext_pad_len, 3, 0);
4415 : :
4416 : : /* Append data which is padded to a multiple */
4417 : : /* of the algorithms block size */
4418 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4419 : :
4420 : : /* Create KASUMI operation */
4421 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4422 : 0 : tdata->cipher_iv.len,
4423 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4424 : 0 : tdata->validCipherOffsetInBits.len);
4425 [ # # ]: 0 : if (retval < 0)
4426 : : return retval;
4427 : :
4428 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4429 : : ut_params->op);
4430 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4431 : :
4432 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4433 [ # # ]: 0 : if (ut_params->obuf)
4434 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4435 : : plaintext_pad_len, buffer);
4436 : : else
4437 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4438 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4439 : : plaintext_pad_len, buffer);
4440 : :
4441 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4442 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4443 : : /* Validate obuf */
4444 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4445 : : ciphertext,
4446 : : reference_ciphertext,
4447 : : tdata->validCipherLenInBits.len,
4448 : : "KASUMI Ciphertext data not as expected");
4449 : : return 0;
4450 : : }
4451 : :
4452 : :
4453 : : static int
4454 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4455 : : {
4456 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4457 : : struct crypto_unittest_params *ut_params = &unittest_params;
4458 : :
4459 : : int retval;
4460 : : uint8_t *ciphertext, *plaintext;
4461 : : unsigned ciphertext_pad_len;
4462 : : unsigned ciphertext_len;
4463 : :
4464 : : /* Verify the capabilities */
4465 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4466 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4467 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4468 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4469 : : &cap_idx) == NULL)
4470 : : return TEST_SKIPPED;
4471 : :
4472 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4473 : : return TEST_SKIPPED;
4474 : :
4475 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4476 : : return TEST_SKIPPED;
4477 : :
4478 : : /* Create KASUMI session */
4479 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4480 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4481 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4482 : 0 : tdata->key.data, tdata->key.len,
4483 : 0 : tdata->cipher_iv.len);
4484 [ # # ]: 0 : if (retval < 0)
4485 : : return retval;
4486 : :
4487 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4488 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4489 : :
4490 : : /* Clear mbuf payload */
4491 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4492 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4493 : :
4494 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4495 : : /* Append data which is padded to a multiple */
4496 : : /* of the algorithms block size */
4497 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4498 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4499 : : ciphertext_pad_len);
4500 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4501 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4502 : :
4503 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4504 : :
4505 : : /* Create KASUMI operation */
4506 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4507 : 0 : tdata->cipher_iv.len,
4508 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4509 : 0 : tdata->validCipherOffsetInBits.len);
4510 [ # # ]: 0 : if (retval < 0)
4511 : : return retval;
4512 : :
4513 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4514 : : ut_params->op);
4515 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4516 : :
4517 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4518 [ # # ]: 0 : if (ut_params->obuf)
4519 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4520 : : else
4521 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4522 : :
4523 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4524 : :
4525 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4526 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4527 : : /* Validate obuf */
4528 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4529 : : plaintext,
4530 : : reference_plaintext,
4531 : : tdata->validCipherLenInBits.len,
4532 : : "KASUMI Plaintext data not as expected");
4533 : : return 0;
4534 : : }
4535 : :
4536 : : static int
4537 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4538 : : {
4539 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4540 : : struct crypto_unittest_params *ut_params = &unittest_params;
4541 : :
4542 : : int retval;
4543 : : uint8_t *ciphertext, *plaintext;
4544 : : unsigned ciphertext_pad_len;
4545 : : unsigned ciphertext_len;
4546 : : struct rte_cryptodev_info dev_info;
4547 : :
4548 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4549 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4550 : :
4551 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4552 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4553 : : printf("Device doesn't support RAW data-path APIs.\n");
4554 : 0 : return TEST_SKIPPED;
4555 : : }
4556 : :
4557 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4558 : : return TEST_SKIPPED;
4559 : :
4560 : : /* Verify the capabilities */
4561 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4562 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4563 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4564 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4565 : : &cap_idx) == NULL)
4566 : : return TEST_SKIPPED;
4567 : :
4568 : : /* Create KASUMI session */
4569 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4570 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4571 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4572 : 0 : tdata->key.data, tdata->key.len,
4573 : 0 : tdata->cipher_iv.len);
4574 [ # # ]: 0 : if (retval < 0)
4575 : : return retval;
4576 : :
4577 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4578 : :
4579 : : /* Clear mbuf payload */
4580 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4581 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4582 : :
4583 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4584 : : /* Append data which is padded to a multiple */
4585 : : /* of the algorithms block size */
4586 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4587 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4588 : : ciphertext_pad_len);
4589 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4590 : :
4591 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4592 : :
4593 : : /* Create KASUMI operation */
4594 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4595 : 0 : tdata->cipher_iv.len,
4596 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4597 : 0 : tdata->validCipherOffsetInBits.len);
4598 [ # # ]: 0 : if (retval < 0)
4599 : : return retval;
4600 : :
4601 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4602 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4603 : : 0);
4604 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4605 : : return retval;
4606 : : } else
4607 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4608 : : ut_params->op);
4609 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4610 : :
4611 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4612 [ # # ]: 0 : if (ut_params->obuf)
4613 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4614 : : else
4615 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4616 : :
4617 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4618 : :
4619 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4620 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4621 : : /* Validate obuf */
4622 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4623 : : plaintext,
4624 : : reference_plaintext,
4625 : : tdata->validCipherLenInBits.len,
4626 : : "KASUMI Plaintext data not as expected");
4627 : : return 0;
4628 : : }
4629 : :
4630 : : static int
4631 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4632 : : {
4633 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4634 : : struct crypto_unittest_params *ut_params = &unittest_params;
4635 : :
4636 : : int retval;
4637 : : uint8_t *plaintext, *ciphertext;
4638 : : unsigned plaintext_pad_len;
4639 : : unsigned plaintext_len;
4640 : : struct rte_cryptodev_info dev_info;
4641 : :
4642 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4643 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4644 : :
4645 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4646 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4647 : : printf("Device doesn't support RAW data-path APIs.\n");
4648 : 0 : return TEST_SKIPPED;
4649 : : }
4650 : :
4651 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4652 : : return TEST_SKIPPED;
4653 : :
4654 : : /* Verify the capabilities */
4655 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4656 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4657 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4658 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4659 : : &cap_idx) == NULL)
4660 : : return TEST_SKIPPED;
4661 : :
4662 : : /* Create SNOW 3G session */
4663 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4664 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4665 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4666 : 0 : tdata->key.data, tdata->key.len,
4667 : 0 : tdata->cipher_iv.len);
4668 [ # # ]: 0 : if (retval < 0)
4669 : : return retval;
4670 : :
4671 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4672 : :
4673 : : /* Clear mbuf payload */
4674 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4675 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4676 : :
4677 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4678 : : /* Append data which is padded to a multiple of */
4679 : : /* the algorithms block size */
4680 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4681 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4682 : : plaintext_pad_len);
4683 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4684 : :
4685 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4686 : :
4687 : : /* Create SNOW 3G operation */
4688 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4689 : 0 : tdata->cipher_iv.len,
4690 : 0 : tdata->validCipherLenInBits.len,
4691 : : 0);
4692 [ # # ]: 0 : if (retval < 0)
4693 : : return retval;
4694 : :
4695 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4696 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4697 : 0 : tdata->cipher_iv.len);
4698 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4699 : : return retval;
4700 : : } else
4701 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4702 : : ut_params->op);
4703 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4704 : :
4705 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4706 [ # # ]: 0 : if (ut_params->obuf)
4707 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4708 : : else
4709 : : ciphertext = plaintext;
4710 : :
4711 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4712 : :
4713 : : /* Validate obuf */
4714 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4715 : : ciphertext,
4716 : : tdata->ciphertext.data,
4717 : : tdata->validDataLenInBits.len,
4718 : : "SNOW 3G Ciphertext data not as expected");
4719 : : return 0;
4720 : : }
4721 : :
4722 : :
4723 : : static int
4724 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4725 : : {
4726 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4727 : : struct crypto_unittest_params *ut_params = &unittest_params;
4728 : : uint8_t *plaintext, *ciphertext;
4729 : :
4730 : : int retval;
4731 : : unsigned plaintext_pad_len;
4732 : : unsigned plaintext_len;
4733 : : struct rte_cryptodev_info dev_info;
4734 : :
4735 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4736 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4737 : :
4738 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4739 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4740 : : printf("Device does not support RAW data-path APIs.\n");
4741 : 0 : return -ENOTSUP;
4742 : : }
4743 : :
4744 : : /* Verify the capabilities */
4745 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4746 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4747 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4748 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4749 : : &cap_idx) == NULL)
4750 : : return TEST_SKIPPED;
4751 : :
4752 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4753 : : return TEST_SKIPPED;
4754 : :
4755 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4756 : : return TEST_SKIPPED;
4757 : :
4758 : : /* Create SNOW 3G session */
4759 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4760 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4761 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4762 : 0 : tdata->key.data, tdata->key.len,
4763 : 0 : tdata->cipher_iv.len);
4764 [ # # ]: 0 : if (retval < 0)
4765 : : return retval;
4766 : :
4767 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4768 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4769 : :
4770 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4771 : : "Failed to allocate input buffer in mempool");
4772 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4773 : : "Failed to allocate output buffer in mempool");
4774 : :
4775 : : /* Clear mbuf payload */
4776 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4777 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4778 : :
4779 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4780 : : /* Append data which is padded to a multiple of */
4781 : : /* the algorithms block size */
4782 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4783 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4784 : : plaintext_pad_len);
4785 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4786 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4787 : :
4788 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4789 : :
4790 : : /* Create SNOW 3G operation */
4791 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4792 : 0 : tdata->cipher_iv.len,
4793 : 0 : tdata->validCipherLenInBits.len,
4794 : : 0);
4795 [ # # ]: 0 : if (retval < 0)
4796 : : return retval;
4797 : :
4798 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4799 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4800 : 0 : tdata->cipher_iv.len);
4801 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4802 : : return retval;
4803 : : } else
4804 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4805 : : ut_params->op);
4806 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4807 : :
4808 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4809 [ # # ]: 0 : if (ut_params->obuf)
4810 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4811 : : else
4812 : : ciphertext = plaintext;
4813 : :
4814 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4815 : :
4816 : : /* Validate obuf */
4817 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4818 : : ciphertext,
4819 : : tdata->ciphertext.data,
4820 : : tdata->validDataLenInBits.len,
4821 : : "SNOW 3G Ciphertext data not as expected");
4822 : : return 0;
4823 : : }
4824 : :
4825 : : static int
4826 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4827 : : uint8_t sgl_in, uint8_t sgl_out)
4828 : : {
4829 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4830 : : struct crypto_unittest_params *ut_params = &unittest_params;
4831 : :
4832 : : int retval;
4833 : : unsigned int plaintext_pad_len;
4834 : : unsigned int plaintext_len;
4835 : : uint8_t buffer[10000];
4836 : : const uint8_t *ciphertext;
4837 : :
4838 : : struct rte_cryptodev_info dev_info;
4839 : :
4840 : : /* Verify the capabilities */
4841 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4842 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4843 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4844 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4845 : : &cap_idx) == NULL)
4846 : : return TEST_SKIPPED;
4847 : :
4848 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4849 : : return TEST_SKIPPED;
4850 : :
4851 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4852 : : return TEST_SKIPPED;
4853 : :
4854 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4855 : :
4856 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4857 : :
4858 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4859 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4860 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4861 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4862 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4863 : : printf("Device doesn't support out-of-place scatter gather type. "
4864 : : "Test Skipped.\n");
4865 : 0 : return TEST_SKIPPED;
4866 : : }
4867 : :
4868 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4869 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4870 : : printf("Device does not support RAW data-path APIs.\n");
4871 : 0 : return -ENOTSUP;
4872 : : }
4873 : :
4874 : : /* Create SNOW 3G session */
4875 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4876 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4877 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4878 : 0 : tdata->key.data, tdata->key.len,
4879 : 0 : tdata->cipher_iv.len);
4880 [ # # ]: 0 : if (retval < 0)
4881 : : return retval;
4882 : :
4883 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4884 : : /* Append data which is padded to a multiple of */
4885 : : /* the algorithms block size */
4886 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4887 : :
4888 [ # # ]: 0 : if (sgl_in)
4889 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4890 : : plaintext_pad_len, 10, 0);
4891 : : else {
4892 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4893 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4894 : : }
4895 : :
4896 [ # # ]: 0 : if (sgl_out)
4897 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4898 : : plaintext_pad_len, 3, 0);
4899 : : else {
4900 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4901 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4902 : : }
4903 : :
4904 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4905 : : "Failed to allocate input buffer in mempool");
4906 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4907 : : "Failed to allocate output buffer in mempool");
4908 : :
4909 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4910 : :
4911 : : /* Create SNOW 3G operation */
4912 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4913 : 0 : tdata->cipher_iv.len,
4914 : 0 : tdata->validCipherLenInBits.len,
4915 : : 0);
4916 [ # # ]: 0 : if (retval < 0)
4917 : : return retval;
4918 : :
4919 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4920 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4921 : 0 : tdata->cipher_iv.len);
4922 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4923 : : return retval;
4924 : : } else
4925 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4926 : : ut_params->op);
4927 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4928 : :
4929 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4930 [ # # ]: 0 : if (ut_params->obuf)
4931 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4932 : : plaintext_len, buffer);
4933 : : else
4934 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4935 : : plaintext_len, buffer);
4936 : :
4937 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4938 : :
4939 : : /* Validate obuf */
4940 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4941 : : ciphertext,
4942 : : tdata->ciphertext.data,
4943 : : tdata->validDataLenInBits.len,
4944 : : "SNOW 3G Ciphertext data not as expected");
4945 : :
4946 : : return 0;
4947 : : }
4948 : :
4949 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4950 : : static void
4951 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4952 : : {
4953 : : uint8_t curr_byte, prev_byte;
4954 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4955 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4956 : : unsigned i;
4957 : :
4958 : 0 : prev_byte = buffer[0];
4959 : 0 : buffer[0] >>= offset;
4960 : :
4961 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4962 : 0 : curr_byte = buffer[i];
4963 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4964 : 0 : (curr_byte >> offset);
4965 : : prev_byte = curr_byte;
4966 : : }
4967 : 0 : }
4968 : :
4969 : : static int
4970 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4971 : : {
4972 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4973 : : struct crypto_unittest_params *ut_params = &unittest_params;
4974 : : uint8_t *plaintext, *ciphertext;
4975 : : int retval;
4976 : : uint32_t plaintext_len;
4977 : : uint32_t plaintext_pad_len;
4978 : : uint8_t extra_offset = 4;
4979 : : uint8_t *expected_ciphertext_shifted;
4980 : : struct rte_cryptodev_info dev_info;
4981 : :
4982 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4983 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4984 : :
4985 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4986 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4987 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4988 : 0 : return TEST_SKIPPED;
4989 : : }
4990 : :
4991 : : /* Verify the capabilities */
4992 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4993 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4994 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4995 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4996 : : &cap_idx) == NULL)
4997 : : return TEST_SKIPPED;
4998 : :
4999 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5000 : : return TEST_SKIPPED;
5001 : :
5002 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5003 : : return TEST_SKIPPED;
5004 : :
5005 : : /* Create SNOW 3G session */
5006 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5007 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5008 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5009 : 0 : tdata->key.data, tdata->key.len,
5010 : 0 : tdata->cipher_iv.len);
5011 [ # # ]: 0 : if (retval < 0)
5012 : : return retval;
5013 : :
5014 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5015 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5016 : :
5017 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5018 : : "Failed to allocate input buffer in mempool");
5019 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5020 : : "Failed to allocate output buffer in mempool");
5021 : :
5022 : : /* Clear mbuf payload */
5023 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5024 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5025 : :
5026 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
5027 : : /*
5028 : : * Append data which is padded to a
5029 : : * multiple of the algorithms block size
5030 : : */
5031 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5032 : :
5033 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
5034 : : plaintext_pad_len);
5035 : :
5036 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5037 : :
5038 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
5039 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
5040 : :
5041 : : #ifdef RTE_APP_TEST_DEBUG
5042 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
5043 : : #endif
5044 : : /* Create SNOW 3G operation */
5045 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5046 : 0 : tdata->cipher_iv.len,
5047 : 0 : tdata->validCipherLenInBits.len,
5048 : : extra_offset);
5049 [ # # ]: 0 : if (retval < 0)
5050 : : return retval;
5051 : :
5052 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5053 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5054 : 0 : tdata->cipher_iv.len);
5055 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5056 : : return retval;
5057 : : } else
5058 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5059 : : ut_params->op);
5060 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5061 : :
5062 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5063 [ # # ]: 0 : if (ut_params->obuf)
5064 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5065 : : else
5066 : : ciphertext = plaintext;
5067 : :
5068 : : #ifdef RTE_APP_TEST_DEBUG
5069 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5070 : : #endif
5071 : :
5072 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
5073 : :
5074 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
5075 : : "failed to reserve memory for ciphertext shifted\n");
5076 : :
5077 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
5078 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
5079 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
5080 : : extra_offset);
5081 : : /* Validate obuf */
5082 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
5083 : : ciphertext,
5084 : : expected_ciphertext_shifted,
5085 : : tdata->validDataLenInBits.len,
5086 : : extra_offset,
5087 : : "SNOW 3G Ciphertext data not as expected");
5088 : : return 0;
5089 : : }
5090 : :
5091 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
5092 : : {
5093 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5094 : : struct crypto_unittest_params *ut_params = &unittest_params;
5095 : :
5096 : : int retval;
5097 : :
5098 : : uint8_t *plaintext, *ciphertext;
5099 : : unsigned ciphertext_pad_len;
5100 : : unsigned ciphertext_len;
5101 : : struct rte_cryptodev_info dev_info;
5102 : :
5103 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5104 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5105 : :
5106 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5107 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5108 : : printf("Device doesn't support RAW data-path APIs.\n");
5109 : 0 : return TEST_SKIPPED;
5110 : : }
5111 : :
5112 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5113 : : return TEST_SKIPPED;
5114 : :
5115 : : /* Verify the capabilities */
5116 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5117 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5118 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5119 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5120 : : &cap_idx) == NULL)
5121 : : return TEST_SKIPPED;
5122 : :
5123 : : /* Create SNOW 3G session */
5124 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5125 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5126 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5127 : 0 : tdata->key.data, tdata->key.len,
5128 : 0 : tdata->cipher_iv.len);
5129 [ # # ]: 0 : if (retval < 0)
5130 : : return retval;
5131 : :
5132 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5133 : :
5134 : : /* Clear mbuf payload */
5135 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5136 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5137 : :
5138 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5139 : : /* Append data which is padded to a multiple of */
5140 : : /* the algorithms block size */
5141 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5142 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5143 : : ciphertext_pad_len);
5144 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5145 : :
5146 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5147 : :
5148 : : /* Create SNOW 3G operation */
5149 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5150 : 0 : tdata->cipher_iv.len,
5151 : 0 : tdata->validCipherLenInBits.len,
5152 : 0 : tdata->cipher.offset_bits);
5153 [ # # ]: 0 : if (retval < 0)
5154 : : return retval;
5155 : :
5156 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5157 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5158 : 0 : tdata->cipher_iv.len);
5159 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5160 : : return retval;
5161 : : } else
5162 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5163 : : ut_params->op);
5164 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5165 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5166 [ # # ]: 0 : if (ut_params->obuf)
5167 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5168 : : else
5169 : : plaintext = ciphertext;
5170 : :
5171 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5172 : :
5173 : : /* Validate obuf */
5174 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5175 : : tdata->plaintext.data,
5176 : : tdata->validDataLenInBits.len,
5177 : : "SNOW 3G Plaintext data not as expected");
5178 : : return 0;
5179 : : }
5180 : :
5181 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5182 : : {
5183 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5184 : : struct crypto_unittest_params *ut_params = &unittest_params;
5185 : :
5186 : : int retval;
5187 : :
5188 : : uint8_t *plaintext, *ciphertext;
5189 : : unsigned ciphertext_pad_len;
5190 : : unsigned ciphertext_len;
5191 : : struct rte_cryptodev_info dev_info;
5192 : :
5193 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5194 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5195 : :
5196 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5197 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5198 : : printf("Device does not support RAW data-path APIs.\n");
5199 : 0 : return -ENOTSUP;
5200 : : }
5201 : : /* Verify the capabilities */
5202 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5203 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5204 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5205 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5206 : : &cap_idx) == NULL)
5207 : : return TEST_SKIPPED;
5208 : :
5209 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5210 : : return TEST_SKIPPED;
5211 : :
5212 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5213 : : return TEST_SKIPPED;
5214 : :
5215 : : /* Create SNOW 3G session */
5216 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5217 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5218 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5219 : 0 : tdata->key.data, tdata->key.len,
5220 : 0 : tdata->cipher_iv.len);
5221 [ # # ]: 0 : if (retval < 0)
5222 : : return retval;
5223 : :
5224 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5225 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5226 : :
5227 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5228 : : "Failed to allocate input buffer");
5229 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5230 : : "Failed to allocate output buffer");
5231 : :
5232 : : /* Clear mbuf payload */
5233 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5234 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5235 : :
5236 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5237 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5238 : :
5239 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5240 : : /* Append data which is padded to a multiple of */
5241 : : /* the algorithms block size */
5242 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5243 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5244 : : ciphertext_pad_len);
5245 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5246 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5247 : :
5248 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5249 : :
5250 : : /* Create SNOW 3G operation */
5251 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5252 : 0 : tdata->cipher_iv.len,
5253 : 0 : tdata->validCipherLenInBits.len,
5254 : : 0);
5255 [ # # ]: 0 : if (retval < 0)
5256 : : return retval;
5257 : :
5258 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5259 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5260 : 0 : tdata->cipher_iv.len);
5261 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5262 : : return retval;
5263 : : } else
5264 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5265 : : ut_params->op);
5266 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5267 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5268 [ # # ]: 0 : if (ut_params->obuf)
5269 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5270 : : else
5271 : : plaintext = ciphertext;
5272 : :
5273 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5274 : :
5275 : : /* Validate obuf */
5276 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5277 : : tdata->plaintext.data,
5278 : : tdata->validDataLenInBits.len,
5279 : : "SNOW 3G Plaintext data not as expected");
5280 : : return 0;
5281 : : }
5282 : :
5283 : : static int
5284 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5285 : : {
5286 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5287 : : struct crypto_unittest_params *ut_params = &unittest_params;
5288 : :
5289 : : int retval;
5290 : :
5291 : : uint8_t *plaintext, *ciphertext;
5292 : : unsigned int plaintext_pad_len;
5293 : : unsigned int plaintext_len;
5294 : :
5295 : : struct rte_cryptodev_info dev_info;
5296 : :
5297 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5298 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5299 : :
5300 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5301 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
5302 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
5303 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
5304 : 0 : return TEST_SKIPPED;
5305 : : }
5306 : :
5307 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5308 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5309 : : printf("Device doesn't support RAW data-path APIs.\n");
5310 : 0 : return TEST_SKIPPED;
5311 : : }
5312 : :
5313 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5314 : : return TEST_SKIPPED;
5315 : :
5316 : : /* Check if device supports ZUC EEA3 */
5317 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5318 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
5319 : : return TEST_SKIPPED;
5320 : :
5321 : : /* Check if device supports ZUC EIA3 */
5322 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5323 : 0 : tdata->key.len, tdata->auth_iv.len,
5324 : 0 : tdata->digest.len) < 0)
5325 : : return TEST_SKIPPED;
5326 : :
5327 : : /* Create ZUC session */
5328 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
5329 : 0 : ts_params->valid_devs[0],
5330 : : tdata);
5331 [ # # ]: 0 : if (retval != 0)
5332 : : return retval;
5333 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5334 : :
5335 : : /* clear mbuf payload */
5336 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5337 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5338 : :
5339 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5340 : : /* Append data which is padded to a multiple of */
5341 : : /* the algorithms block size */
5342 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5343 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5344 : : plaintext_pad_len);
5345 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5346 : :
5347 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5348 : :
5349 : : /* Create ZUC operation */
5350 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
5351 [ # # ]: 0 : if (retval < 0)
5352 : : return retval;
5353 : :
5354 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5355 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5356 : 0 : tdata->cipher_iv.len);
5357 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5358 : : return retval;
5359 : : } else
5360 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5361 : : ut_params->op);
5362 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5363 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5364 [ # # ]: 0 : if (ut_params->obuf)
5365 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5366 : : else
5367 : : ciphertext = plaintext;
5368 : :
5369 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5370 : : /* Validate obuf */
5371 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5372 : : ciphertext,
5373 : : tdata->ciphertext.data,
5374 : : tdata->validDataLenInBits.len,
5375 : : "ZUC Ciphertext data not as expected");
5376 : :
5377 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5378 : : uint8_t *,
5379 : : plaintext_pad_len);
5380 : :
5381 : : /* Validate obuf */
5382 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5383 : : ut_params->digest,
5384 : : tdata->digest.data,
5385 : : tdata->digest.len,
5386 : : "ZUC Generated auth tag not as expected");
5387 : : return 0;
5388 : : }
5389 : :
5390 : : static int
5391 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5392 : : {
5393 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5394 : : struct crypto_unittest_params *ut_params = &unittest_params;
5395 : :
5396 : : int retval;
5397 : :
5398 : : uint8_t *plaintext, *ciphertext;
5399 : : unsigned plaintext_pad_len;
5400 : : unsigned plaintext_len;
5401 : : struct rte_cryptodev_info dev_info;
5402 : :
5403 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5404 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5405 : :
5406 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5407 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5408 : : printf("Device doesn't support RAW data-path APIs.\n");
5409 : 0 : return TEST_SKIPPED;
5410 : : }
5411 : :
5412 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5413 : : return TEST_SKIPPED;
5414 : :
5415 : : /* Verify the capabilities */
5416 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5417 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5418 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5419 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5420 : : &cap_idx) == NULL)
5421 : : return TEST_SKIPPED;
5422 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5423 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5424 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5425 : : &cap_idx) == NULL)
5426 : : return TEST_SKIPPED;
5427 : :
5428 : : /* Create SNOW 3G session */
5429 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5430 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5431 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5432 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5433 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5434 : : tdata->key.data, tdata->key.len,
5435 : 0 : tdata->key.data, tdata->key.len,
5436 : 0 : tdata->auth_iv.len, tdata->digest.len,
5437 : 0 : tdata->cipher_iv.len);
5438 [ # # ]: 0 : if (retval != 0)
5439 : : return retval;
5440 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5441 : :
5442 : : /* clear mbuf payload */
5443 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5444 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5445 : :
5446 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5447 : : /* Append data which is padded to a multiple of */
5448 : : /* the algorithms block size */
5449 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5450 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5451 : : plaintext_pad_len);
5452 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5453 : :
5454 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5455 : :
5456 : : /* Create SNOW 3G operation */
5457 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5458 : 0 : tdata->digest.len, tdata->auth_iv.data,
5459 : 0 : tdata->auth_iv.len,
5460 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5461 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5462 : 0 : tdata->validCipherLenInBits.len,
5463 : : 0,
5464 : 0 : tdata->validAuthLenInBits.len,
5465 : : 0
5466 : : );
5467 [ # # ]: 0 : if (retval < 0)
5468 : : return retval;
5469 : :
5470 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5471 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5472 : 0 : tdata->cipher_iv.len);
5473 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5474 : : return retval;
5475 : : } else
5476 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5477 : : ut_params->op);
5478 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5479 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5480 [ # # ]: 0 : if (ut_params->obuf)
5481 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5482 : : else
5483 : : ciphertext = plaintext;
5484 : :
5485 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5486 : : /* Validate obuf */
5487 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5488 : : ciphertext,
5489 : : tdata->ciphertext.data,
5490 : : tdata->validDataLenInBits.len,
5491 : : "SNOW 3G Ciphertext data not as expected");
5492 : :
5493 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5494 : : uint8_t *,
5495 : : plaintext_pad_len);
5496 : :
5497 : : /* Validate obuf */
5498 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5499 : : ut_params->digest,
5500 : : tdata->digest.data,
5501 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5502 : : "SNOW 3G Generated auth tag not as expected");
5503 : : return 0;
5504 : : }
5505 : :
5506 : : static int
5507 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5508 : : uint8_t op_mode, uint8_t verify)
5509 : : {
5510 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5511 : : struct crypto_unittest_params *ut_params = &unittest_params;
5512 : :
5513 : : int retval;
5514 : :
5515 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5516 : : unsigned int plaintext_pad_len;
5517 : : unsigned int plaintext_len;
5518 : : unsigned int ciphertext_pad_len;
5519 : : unsigned int ciphertext_len;
5520 : : unsigned int digest_offset;
5521 : :
5522 : : struct rte_cryptodev_info dev_info;
5523 : :
5524 : : /* Verify the capabilities */
5525 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5526 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5527 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5528 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5529 : : &cap_idx) == NULL)
5530 : : return TEST_SKIPPED;
5531 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5532 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5533 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5534 : : &cap_idx) == NULL)
5535 : : return TEST_SKIPPED;
5536 : :
5537 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5538 : : return TEST_SKIPPED;
5539 : :
5540 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5541 : :
5542 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5543 : :
5544 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5545 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5546 : : printf("Device doesn't support digest encrypted.\n");
5547 : 0 : return TEST_SKIPPED;
5548 : : }
5549 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5550 : : return TEST_SKIPPED;
5551 : : }
5552 : :
5553 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5554 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5555 : : printf("Device doesn't support RAW data-path APIs.\n");
5556 : 0 : return TEST_SKIPPED;
5557 : : }
5558 : :
5559 : : /* Create SNOW 3G session */
5560 : 0 : retval = create_wireless_algo_auth_cipher_session(
5561 : 0 : ts_params->valid_devs[0],
5562 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5563 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5564 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5565 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5566 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5567 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5568 : : tdata->key.data, tdata->key.len,
5569 : 0 : tdata->key.data, tdata->key.len,
5570 : 0 : tdata->auth_iv.len, tdata->digest.len,
5571 : 0 : tdata->cipher_iv.len);
5572 [ # # ]: 0 : if (retval != 0)
5573 : : return retval;
5574 : :
5575 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5576 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5577 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5578 : :
5579 : : /* clear mbuf payload */
5580 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5581 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5582 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5583 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5584 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5585 : :
5586 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5587 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5588 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5589 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5590 : :
5591 [ # # ]: 0 : if (verify) {
5592 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5593 : : ciphertext_pad_len);
5594 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5595 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5596 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5597 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5598 : : ciphertext_len);
5599 : : } else {
5600 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5601 : : plaintext_pad_len);
5602 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5603 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5604 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5605 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5606 : : }
5607 : :
5608 : : /* Create SNOW 3G operation */
5609 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5610 : 0 : tdata->digest.data, tdata->digest.len,
5611 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5612 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5613 : 0 : (tdata->digest.offset_bytes == 0 ?
5614 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5615 : : : tdata->digest.offset_bytes),
5616 : 0 : tdata->validCipherLenInBits.len,
5617 : 0 : tdata->cipher.offset_bits,
5618 : 0 : tdata->validAuthLenInBits.len,
5619 [ # # ]: 0 : tdata->auth.offset_bits,
5620 : : op_mode, 0, verify);
5621 : :
5622 [ # # ]: 0 : if (retval < 0)
5623 : : return retval;
5624 : :
5625 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5626 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5627 : 0 : tdata->cipher_iv.len);
5628 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5629 : : return retval;
5630 : : } else
5631 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5632 : : ut_params->op);
5633 : :
5634 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5635 : :
5636 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5637 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5638 : :
5639 [ # # ]: 0 : if (verify) {
5640 [ # # ]: 0 : if (ut_params->obuf)
5641 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5642 : : uint8_t *);
5643 : : else
5644 : 0 : plaintext = ciphertext +
5645 : 0 : (tdata->cipher.offset_bits >> 3);
5646 : :
5647 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5648 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5649 : 0 : debug_hexdump(stdout, "plaintext expected:",
5650 : 0 : tdata->plaintext.data,
5651 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5652 : : } else {
5653 [ # # ]: 0 : if (ut_params->obuf)
5654 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5655 : : uint8_t *);
5656 : : else
5657 : : ciphertext = plaintext;
5658 : :
5659 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5660 : : ciphertext_len);
5661 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5662 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5663 : :
5664 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5665 : : digest_offset = plaintext_pad_len;
5666 : : else
5667 : : digest_offset = tdata->digest.offset_bytes;
5668 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5669 : : uint8_t *, digest_offset);
5670 : :
5671 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5672 : 0 : tdata->digest.len);
5673 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5674 : 0 : tdata->digest.len);
5675 : : }
5676 : :
5677 : : /* Validate obuf */
5678 [ # # ]: 0 : if (verify) {
5679 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5680 : : plaintext,
5681 : : tdata->plaintext.data,
5682 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5683 : : (tdata->digest.len << 3)),
5684 : : tdata->cipher.offset_bits,
5685 : : "SNOW 3G Plaintext data not as expected");
5686 : : } else {
5687 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5688 : : ciphertext,
5689 : : tdata->ciphertext.data,
5690 : : (tdata->validDataLenInBits.len -
5691 : : tdata->cipher.offset_bits),
5692 : : tdata->cipher.offset_bits,
5693 : : "SNOW 3G Ciphertext data not as expected");
5694 : :
5695 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5696 : : ut_params->digest,
5697 : : tdata->digest.data,
5698 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5699 : : "SNOW 3G Generated auth tag not as expected");
5700 : : }
5701 : : return 0;
5702 : : }
5703 : :
5704 : : static int
5705 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5706 : : uint8_t op_mode, uint8_t verify)
5707 : : {
5708 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5709 : : struct crypto_unittest_params *ut_params = &unittest_params;
5710 : :
5711 : : int retval;
5712 : :
5713 : : const uint8_t *plaintext = NULL;
5714 : : const uint8_t *ciphertext = NULL;
5715 : : const uint8_t *digest = NULL;
5716 : : unsigned int plaintext_pad_len;
5717 : : unsigned int plaintext_len;
5718 : : unsigned int ciphertext_pad_len;
5719 : : unsigned int ciphertext_len;
5720 : : uint8_t buffer[10000];
5721 : : uint8_t digest_buffer[10000];
5722 : :
5723 : : struct rte_cryptodev_info dev_info;
5724 : :
5725 : : /* Verify the capabilities */
5726 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5727 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5728 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5729 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5730 : : &cap_idx) == NULL)
5731 : : return TEST_SKIPPED;
5732 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5733 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5734 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5735 : : &cap_idx) == NULL)
5736 : : return TEST_SKIPPED;
5737 : :
5738 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5739 : : return TEST_SKIPPED;
5740 : :
5741 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5742 : :
5743 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5744 : :
5745 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5746 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5747 : : printf("Device doesn't support in-place scatter-gather "
5748 : : "in both input and output mbufs.\n");
5749 : 0 : return TEST_SKIPPED;
5750 : : }
5751 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5752 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5753 : : printf("Device doesn't support RAW data-path APIs.\n");
5754 : 0 : return TEST_SKIPPED;
5755 : : }
5756 : : } else {
5757 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5758 : : return TEST_SKIPPED;
5759 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5760 : : printf("Device doesn't support out-of-place scatter-gather "
5761 : : "in both input and output mbufs.\n");
5762 : 0 : return TEST_SKIPPED;
5763 : : }
5764 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5765 : : printf("Device doesn't support digest encrypted.\n");
5766 : 0 : return TEST_SKIPPED;
5767 : : }
5768 : : }
5769 : :
5770 : : /* Create SNOW 3G session */
5771 : 0 : retval = create_wireless_algo_auth_cipher_session(
5772 : 0 : ts_params->valid_devs[0],
5773 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5774 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5775 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5776 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5777 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5778 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5779 : : tdata->key.data, tdata->key.len,
5780 : 0 : tdata->key.data, tdata->key.len,
5781 : 0 : tdata->auth_iv.len, tdata->digest.len,
5782 : 0 : tdata->cipher_iv.len);
5783 : :
5784 [ # # ]: 0 : if (retval != 0)
5785 : : return retval;
5786 : :
5787 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5788 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5789 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5790 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5791 : :
5792 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5793 : : plaintext_pad_len, 15, 0);
5794 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5795 : : "Failed to allocate input buffer in mempool");
5796 : :
5797 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5798 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5799 : : plaintext_pad_len, 15, 0);
5800 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5801 : : "Failed to allocate output buffer in mempool");
5802 : : }
5803 : :
5804 [ # # ]: 0 : if (verify) {
5805 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5806 : 0 : tdata->ciphertext.data);
5807 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5808 : : ciphertext_len, buffer);
5809 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5810 : : ciphertext_len);
5811 : : } else {
5812 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5813 : 0 : tdata->plaintext.data);
5814 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5815 : : plaintext_len, buffer);
5816 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5817 : : plaintext_len);
5818 : : }
5819 : : memset(buffer, 0, sizeof(buffer));
5820 : :
5821 : : /* Create SNOW 3G operation */
5822 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5823 : 0 : tdata->digest.data, tdata->digest.len,
5824 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5825 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5826 : 0 : (tdata->digest.offset_bytes == 0 ?
5827 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5828 : : : tdata->digest.offset_bytes),
5829 : 0 : tdata->validCipherLenInBits.len,
5830 : 0 : tdata->cipher.offset_bits,
5831 : 0 : tdata->validAuthLenInBits.len,
5832 [ # # ]: 0 : tdata->auth.offset_bits,
5833 : : op_mode, 1, verify);
5834 : :
5835 [ # # ]: 0 : if (retval < 0)
5836 : : return retval;
5837 : :
5838 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5839 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5840 : 0 : tdata->cipher_iv.len);
5841 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5842 : : return retval;
5843 : : } else
5844 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5845 : : ut_params->op);
5846 : :
5847 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5848 : :
5849 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5850 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5851 : :
5852 [ # # ]: 0 : if (verify) {
5853 [ # # ]: 0 : if (ut_params->obuf)
5854 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5855 : : plaintext_len, buffer);
5856 : : else
5857 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5858 : : plaintext_len, buffer);
5859 : :
5860 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5861 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5862 : 0 : debug_hexdump(stdout, "plaintext expected:",
5863 : 0 : tdata->plaintext.data,
5864 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5865 : : } else {
5866 [ # # ]: 0 : if (ut_params->obuf)
5867 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5868 : : ciphertext_len, buffer);
5869 : : else
5870 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5871 : : ciphertext_len, buffer);
5872 : :
5873 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5874 : : ciphertext_len);
5875 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5876 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5877 : :
5878 [ # # ]: 0 : if (ut_params->obuf)
5879 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5880 : 0 : (tdata->digest.offset_bytes == 0 ?
5881 : : plaintext_pad_len : tdata->digest.offset_bytes),
5882 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5883 : : else
5884 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5885 : 0 : (tdata->digest.offset_bytes == 0 ?
5886 : : plaintext_pad_len : tdata->digest.offset_bytes),
5887 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5888 : :
5889 : 0 : debug_hexdump(stdout, "digest:", digest,
5890 : 0 : tdata->digest.len);
5891 : 0 : debug_hexdump(stdout, "digest expected:",
5892 : 0 : tdata->digest.data, tdata->digest.len);
5893 : : }
5894 : :
5895 : : /* Validate obuf */
5896 [ # # ]: 0 : if (verify) {
5897 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5898 : : plaintext,
5899 : : tdata->plaintext.data,
5900 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5901 : : (tdata->digest.len << 3)),
5902 : : tdata->cipher.offset_bits,
5903 : : "SNOW 3G Plaintext data not as expected");
5904 : : } else {
5905 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5906 : : ciphertext,
5907 : : tdata->ciphertext.data,
5908 : : (tdata->validDataLenInBits.len -
5909 : : tdata->cipher.offset_bits),
5910 : : tdata->cipher.offset_bits,
5911 : : "SNOW 3G Ciphertext data not as expected");
5912 : :
5913 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5914 : : digest,
5915 : : tdata->digest.data,
5916 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5917 : : "SNOW 3G Generated auth tag not as expected");
5918 : : }
5919 : : return 0;
5920 : : }
5921 : :
5922 : : static int
5923 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5924 : : uint8_t op_mode, uint8_t verify)
5925 : : {
5926 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5927 : : struct crypto_unittest_params *ut_params = &unittest_params;
5928 : :
5929 : : int retval;
5930 : :
5931 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5932 : : unsigned int plaintext_pad_len;
5933 : : unsigned int plaintext_len;
5934 : : unsigned int ciphertext_pad_len;
5935 : : unsigned int ciphertext_len;
5936 : : unsigned int digest_offset;
5937 : :
5938 : : struct rte_cryptodev_info dev_info;
5939 : :
5940 : : /* Verify the capabilities */
5941 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5942 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5943 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5944 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5945 : : &cap_idx) == NULL)
5946 : : return TEST_SKIPPED;
5947 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5948 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5949 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5950 : : &cap_idx) == NULL)
5951 : : return TEST_SKIPPED;
5952 : :
5953 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5954 : :
5955 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5956 : :
5957 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5958 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5959 : : printf("Device doesn't support RAW data-path APIs.\n");
5960 : 0 : return TEST_SKIPPED;
5961 : : }
5962 : :
5963 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5964 : : return TEST_SKIPPED;
5965 : :
5966 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5967 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5968 : : return TEST_SKIPPED;
5969 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5970 : : printf("Device doesn't support digest encrypted.\n");
5971 : 0 : return TEST_SKIPPED;
5972 : : }
5973 : : }
5974 : :
5975 : : /* Create KASUMI session */
5976 : 0 : retval = create_wireless_algo_auth_cipher_session(
5977 : 0 : ts_params->valid_devs[0],
5978 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5979 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5980 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5981 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5982 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5983 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5984 : : tdata->key.data, tdata->key.len,
5985 : 0 : tdata->key.data, tdata->key.len,
5986 : 0 : 0, tdata->digest.len,
5987 : 0 : tdata->cipher_iv.len);
5988 : :
5989 [ # # ]: 0 : if (retval != 0)
5990 : : return retval;
5991 : :
5992 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5993 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5994 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5995 : :
5996 : : /* clear mbuf payload */
5997 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5998 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5999 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6000 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6001 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6002 : :
6003 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6004 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6005 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6006 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6007 : :
6008 [ # # ]: 0 : if (verify) {
6009 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6010 : : ciphertext_pad_len);
6011 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6012 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6013 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6014 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6015 : : ciphertext_len);
6016 : : } else {
6017 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6018 : : plaintext_pad_len);
6019 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6020 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6021 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6022 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6023 : : plaintext_len);
6024 : : }
6025 : :
6026 : : /* Create KASUMI operation */
6027 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6028 : 0 : tdata->digest.data, tdata->digest.len,
6029 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6030 : : NULL, 0,
6031 : 0 : (tdata->digest.offset_bytes == 0 ?
6032 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6033 : : : tdata->digest.offset_bytes),
6034 : 0 : tdata->validCipherLenInBits.len,
6035 : 0 : tdata->validCipherOffsetInBits.len,
6036 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6037 : : 0,
6038 : : op_mode, 0, verify);
6039 : :
6040 [ # # ]: 0 : if (retval < 0)
6041 : : return retval;
6042 : :
6043 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6044 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6045 : 0 : tdata->cipher_iv.len);
6046 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6047 : : return retval;
6048 : : } else
6049 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6050 : : ut_params->op);
6051 : :
6052 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6053 : :
6054 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6055 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6056 : :
6057 : :
6058 [ # # ]: 0 : if (verify) {
6059 [ # # ]: 0 : if (ut_params->obuf)
6060 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6061 : : uint8_t *);
6062 : : else
6063 : : plaintext = ciphertext;
6064 : :
6065 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6066 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6067 : 0 : debug_hexdump(stdout, "plaintext expected:",
6068 : 0 : tdata->plaintext.data,
6069 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6070 : : } else {
6071 [ # # ]: 0 : if (ut_params->obuf)
6072 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6073 : : uint8_t *);
6074 : : else
6075 : : ciphertext = plaintext;
6076 : :
6077 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6078 : : ciphertext_len);
6079 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6080 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6081 : :
6082 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6083 : : digest_offset = plaintext_pad_len;
6084 : : else
6085 : : digest_offset = tdata->digest.offset_bytes;
6086 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6087 : : uint8_t *, digest_offset);
6088 : :
6089 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6090 : 0 : tdata->digest.len);
6091 : 0 : debug_hexdump(stdout, "digest expected:",
6092 : 0 : tdata->digest.data, tdata->digest.len);
6093 : : }
6094 : :
6095 : : /* Validate obuf */
6096 [ # # ]: 0 : if (verify) {
6097 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6098 : : plaintext,
6099 : : tdata->plaintext.data,
6100 : : tdata->plaintext.len >> 3,
6101 : : "KASUMI Plaintext data not as expected");
6102 : : } else {
6103 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6104 : : ciphertext,
6105 : : tdata->ciphertext.data,
6106 : : tdata->ciphertext.len >> 3,
6107 : : "KASUMI Ciphertext data not as expected");
6108 : :
6109 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6110 : : ut_params->digest,
6111 : : tdata->digest.data,
6112 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6113 : : "KASUMI Generated auth tag not as expected");
6114 : : }
6115 : : return 0;
6116 : : }
6117 : :
6118 : : static int
6119 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6120 : : uint8_t op_mode, uint8_t verify)
6121 : : {
6122 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6123 : : struct crypto_unittest_params *ut_params = &unittest_params;
6124 : :
6125 : : int retval;
6126 : :
6127 : : const uint8_t *plaintext = NULL;
6128 : : const uint8_t *ciphertext = NULL;
6129 : : const uint8_t *digest = NULL;
6130 : : unsigned int plaintext_pad_len;
6131 : : unsigned int plaintext_len;
6132 : : unsigned int ciphertext_pad_len;
6133 : : unsigned int ciphertext_len;
6134 : : uint8_t buffer[10000];
6135 : : uint8_t digest_buffer[10000];
6136 : :
6137 : : struct rte_cryptodev_info dev_info;
6138 : :
6139 : : /* Verify the capabilities */
6140 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6141 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6142 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6143 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6144 : : &cap_idx) == NULL)
6145 : : return TEST_SKIPPED;
6146 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6147 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6148 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6149 : : &cap_idx) == NULL)
6150 : : return TEST_SKIPPED;
6151 : :
6152 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6153 : : return TEST_SKIPPED;
6154 : :
6155 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6156 : :
6157 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6158 : :
6159 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6160 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6161 : : printf("Device doesn't support in-place scatter-gather "
6162 : : "in both input and output mbufs.\n");
6163 : 0 : return TEST_SKIPPED;
6164 : : }
6165 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6166 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6167 : : printf("Device doesn't support RAW data-path APIs.\n");
6168 : 0 : return TEST_SKIPPED;
6169 : : }
6170 : : } else {
6171 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6172 : : return TEST_SKIPPED;
6173 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6174 : : printf("Device doesn't support out-of-place scatter-gather "
6175 : : "in both input and output mbufs.\n");
6176 : 0 : return TEST_SKIPPED;
6177 : : }
6178 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6179 : : printf("Device doesn't support digest encrypted.\n");
6180 : 0 : return TEST_SKIPPED;
6181 : : }
6182 : : }
6183 : :
6184 : : /* Create KASUMI session */
6185 : 0 : retval = create_wireless_algo_auth_cipher_session(
6186 : 0 : ts_params->valid_devs[0],
6187 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6188 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6189 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6190 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6191 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6192 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6193 : : tdata->key.data, tdata->key.len,
6194 : 0 : tdata->key.data, tdata->key.len,
6195 : 0 : 0, tdata->digest.len,
6196 : 0 : tdata->cipher_iv.len);
6197 : :
6198 [ # # ]: 0 : if (retval != 0)
6199 : : return retval;
6200 : :
6201 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6202 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6203 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6204 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6205 : :
6206 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6207 : : plaintext_pad_len, 15, 0);
6208 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6209 : : "Failed to allocate input buffer in mempool");
6210 : :
6211 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6212 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6213 : : plaintext_pad_len, 15, 0);
6214 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6215 : : "Failed to allocate output buffer in mempool");
6216 : : }
6217 : :
6218 [ # # ]: 0 : if (verify) {
6219 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6220 : 0 : tdata->ciphertext.data);
6221 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6222 : : ciphertext_len, buffer);
6223 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6224 : : ciphertext_len);
6225 : : } else {
6226 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6227 : 0 : tdata->plaintext.data);
6228 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6229 : : plaintext_len, buffer);
6230 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6231 : : plaintext_len);
6232 : : }
6233 : : memset(buffer, 0, sizeof(buffer));
6234 : :
6235 : : /* Create KASUMI operation */
6236 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6237 : 0 : tdata->digest.data, tdata->digest.len,
6238 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6239 : : NULL, 0,
6240 : 0 : (tdata->digest.offset_bytes == 0 ?
6241 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6242 : : : tdata->digest.offset_bytes),
6243 : 0 : tdata->validCipherLenInBits.len,
6244 : 0 : tdata->validCipherOffsetInBits.len,
6245 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6246 : : 0,
6247 : : op_mode, 1, verify);
6248 : :
6249 [ # # ]: 0 : if (retval < 0)
6250 : : return retval;
6251 : :
6252 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6253 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6254 : 0 : tdata->cipher_iv.len);
6255 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6256 : : return retval;
6257 : : } else
6258 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6259 : : ut_params->op);
6260 : :
6261 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6262 : :
6263 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6264 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6265 : :
6266 [ # # ]: 0 : if (verify) {
6267 [ # # ]: 0 : if (ut_params->obuf)
6268 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6269 : : plaintext_len, buffer);
6270 : : else
6271 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6272 : : plaintext_len, buffer);
6273 : :
6274 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6275 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6276 : 0 : debug_hexdump(stdout, "plaintext expected:",
6277 : 0 : tdata->plaintext.data,
6278 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6279 : : } else {
6280 [ # # ]: 0 : if (ut_params->obuf)
6281 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6282 : : ciphertext_len, buffer);
6283 : : else
6284 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6285 : : ciphertext_len, buffer);
6286 : :
6287 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6288 : : ciphertext_len);
6289 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6290 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6291 : :
6292 [ # # ]: 0 : if (ut_params->obuf)
6293 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6294 : 0 : (tdata->digest.offset_bytes == 0 ?
6295 : : plaintext_pad_len : tdata->digest.offset_bytes),
6296 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6297 : : else
6298 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6299 : 0 : (tdata->digest.offset_bytes == 0 ?
6300 : : plaintext_pad_len : tdata->digest.offset_bytes),
6301 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6302 : :
6303 : 0 : debug_hexdump(stdout, "digest:", digest,
6304 : 0 : tdata->digest.len);
6305 : 0 : debug_hexdump(stdout, "digest expected:",
6306 : 0 : tdata->digest.data, tdata->digest.len);
6307 : : }
6308 : :
6309 : : /* Validate obuf */
6310 [ # # ]: 0 : if (verify) {
6311 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6312 : : plaintext,
6313 : : tdata->plaintext.data,
6314 : : tdata->plaintext.len >> 3,
6315 : : "KASUMI Plaintext data not as expected");
6316 : : } else {
6317 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6318 : : ciphertext,
6319 : : tdata->ciphertext.data,
6320 : : tdata->validDataLenInBits.len,
6321 : : "KASUMI Ciphertext data not as expected");
6322 : :
6323 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6324 : : digest,
6325 : : tdata->digest.data,
6326 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6327 : : "KASUMI Generated auth tag not as expected");
6328 : : }
6329 : : return 0;
6330 : : }
6331 : :
6332 : : static int
6333 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6334 : : {
6335 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6336 : : struct crypto_unittest_params *ut_params = &unittest_params;
6337 : :
6338 : : int retval;
6339 : :
6340 : : uint8_t *plaintext, *ciphertext;
6341 : : unsigned plaintext_pad_len;
6342 : : unsigned plaintext_len;
6343 : : struct rte_cryptodev_info dev_info;
6344 : :
6345 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6346 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6347 : :
6348 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6349 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6350 : : printf("Device doesn't support RAW data-path APIs.\n");
6351 : 0 : return TEST_SKIPPED;
6352 : : }
6353 : :
6354 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6355 : : return TEST_SKIPPED;
6356 : :
6357 : : /* Verify the capabilities */
6358 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6359 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6360 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6361 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6362 : : &cap_idx) == NULL)
6363 : : return TEST_SKIPPED;
6364 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6365 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6366 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6367 : : &cap_idx) == NULL)
6368 : : return TEST_SKIPPED;
6369 : :
6370 : : /* Create KASUMI session */
6371 : 0 : retval = create_wireless_algo_cipher_auth_session(
6372 : 0 : ts_params->valid_devs[0],
6373 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6374 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6375 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6376 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6377 : : tdata->key.data, tdata->key.len,
6378 : 0 : tdata->key.data, tdata->key.len,
6379 : 0 : 0, tdata->digest.len,
6380 : 0 : tdata->cipher_iv.len);
6381 [ # # ]: 0 : if (retval != 0)
6382 : : return retval;
6383 : :
6384 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6385 : :
6386 : : /* clear mbuf payload */
6387 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6388 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6389 : :
6390 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6391 : : /* Append data which is padded to a multiple of */
6392 : : /* the algorithms block size */
6393 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6394 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6395 : : plaintext_pad_len);
6396 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6397 : :
6398 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6399 : :
6400 : : /* Create KASUMI operation */
6401 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6402 : 0 : tdata->digest.len, NULL, 0,
6403 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6404 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6405 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6406 : 0 : tdata->validCipherOffsetInBits.len,
6407 : 0 : tdata->validAuthLenInBits.len,
6408 : : 0
6409 : : );
6410 [ # # ]: 0 : if (retval < 0)
6411 : : return retval;
6412 : :
6413 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6414 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6415 : 0 : tdata->cipher_iv.len);
6416 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6417 : : return retval;
6418 : : } else
6419 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6420 : : ut_params->op);
6421 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6422 : :
6423 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6424 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6425 : : else
6426 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6427 : :
6428 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6429 : : tdata->validCipherOffsetInBits.len >> 3);
6430 : :
6431 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6432 : : uint8_t *,
6433 : : plaintext_pad_len);
6434 : :
6435 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6436 : : (tdata->validCipherOffsetInBits.len >> 3);
6437 : : /* Validate obuf */
6438 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6439 : : ciphertext,
6440 : : reference_ciphertext,
6441 : : tdata->validCipherLenInBits.len,
6442 : : "KASUMI Ciphertext data not as expected");
6443 : :
6444 : : /* Validate obuf */
6445 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6446 : : ut_params->digest,
6447 : : tdata->digest.data,
6448 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6449 : : "KASUMI Generated auth tag not as expected");
6450 : : return 0;
6451 : : }
6452 : :
6453 : : static int
6454 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6455 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6456 : : const uint16_t key_size, const uint16_t iv_size)
6457 : : {
6458 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6459 : : const struct rte_cryptodev_symmetric_capability *cap;
6460 : :
6461 : : /* Check if device supports the algorithm */
6462 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6463 : 0 : cap_idx.algo.cipher = cipher_algo;
6464 : :
6465 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6466 : : &cap_idx);
6467 : :
6468 [ # # ]: 0 : if (cap == NULL)
6469 : : return -1;
6470 : :
6471 : : /* Check if device supports key size and IV size */
6472 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6473 : : iv_size) < 0) {
6474 : 0 : return -1;
6475 : : }
6476 : :
6477 : : return 0;
6478 : : }
6479 : :
6480 : : static int
6481 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6482 : : const enum rte_crypto_auth_algorithm auth_algo,
6483 : : const uint16_t key_size, const uint16_t iv_size,
6484 : : const uint16_t tag_size)
6485 : : {
6486 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6487 : : const struct rte_cryptodev_symmetric_capability *cap;
6488 : :
6489 : : /* Check if device supports the algorithm */
6490 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6491 : 0 : cap_idx.algo.auth = auth_algo;
6492 : :
6493 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6494 : : &cap_idx);
6495 : :
6496 [ # # ]: 0 : if (cap == NULL)
6497 : : return -1;
6498 : :
6499 : : /* Check if device supports key size and IV size */
6500 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6501 : : tag_size, iv_size) < 0) {
6502 : 0 : return -1;
6503 : : }
6504 : :
6505 : : return 0;
6506 : : }
6507 : :
6508 : : static int
6509 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6510 : : enum rte_crypto_cipher_operation direction)
6511 : : {
6512 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6513 : : struct crypto_unittest_params *ut_params = &unittest_params;
6514 : :
6515 : : int retval;
6516 : : uint8_t *plaintext = NULL;
6517 : : uint8_t *ciphertext = NULL;
6518 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6519 : : unsigned int plaintext_len = 0;
6520 : : unsigned int ciphertext_len = 0;
6521 : : struct rte_cryptodev_info dev_info;
6522 : :
6523 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6524 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6525 : :
6526 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6527 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6528 : : printf("Device doesn't support RAW data-path APIs.\n");
6529 : 0 : return TEST_SKIPPED;
6530 : : }
6531 : :
6532 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6533 : : return TEST_SKIPPED;
6534 : :
6535 : : /* Check if device supports ZUC EEA3 */
6536 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6537 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6538 : : return TEST_SKIPPED;
6539 : :
6540 : : /* Create ZUC session */
6541 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6542 : : direction,
6543 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6544 : 0 : tdata->key.data, tdata->key.len,
6545 : 0 : tdata->cipher_iv.len);
6546 [ # # ]: 0 : if (retval != 0)
6547 : : return retval;
6548 : :
6549 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6550 : :
6551 : : /* Clear mbuf payload */
6552 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6553 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6554 : :
6555 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6556 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6557 : : /* Append data which is padded to a multiple */
6558 : : /* of the algorithms block size */
6559 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6560 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6561 : : plaintext_pad_len);
6562 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6563 : :
6564 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6565 : : } else {
6566 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6567 : : /* Append data which is padded to a multiple */
6568 : : /* of the algorithms block size */
6569 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6570 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6571 : : ciphertext_pad_len);
6572 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6573 : :
6574 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6575 : : }
6576 : :
6577 : : /* Create ZUC operation */
6578 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6579 : 0 : tdata->cipher_iv.len,
6580 : 0 : tdata->plaintext.len,
6581 : 0 : tdata->validCipherOffsetInBits.len);
6582 [ # # ]: 0 : if (retval < 0)
6583 : : return retval;
6584 : :
6585 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6586 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6587 : 0 : tdata->cipher_iv.len);
6588 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6589 : : return retval;
6590 : : } else
6591 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6592 : : ut_params->op);
6593 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6594 : :
6595 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6596 : :
6597 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6598 [ # # ]: 0 : if (ut_params->obuf)
6599 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6600 : : else
6601 : : ciphertext = plaintext;
6602 : :
6603 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6604 : :
6605 : : /* Validate obuf */
6606 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6607 : : ciphertext,
6608 : : tdata->ciphertext.data,
6609 : : tdata->validCipherLenInBits.len,
6610 : : "ZUC Ciphertext data not as expected");
6611 : : } else {
6612 [ # # ]: 0 : if (ut_params->obuf)
6613 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6614 : : else
6615 : : plaintext = ciphertext;
6616 : :
6617 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6618 : :
6619 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6620 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6621 : :
6622 : : /* Validate obuf */
6623 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6624 : : plaintext,
6625 : : reference_plaintext,
6626 : : tdata->validCipherLenInBits.len,
6627 : : "ZUC Plaintext data not as expected");
6628 : : }
6629 : :
6630 : : return 0;
6631 : : }
6632 : :
6633 : : static int
6634 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6635 : : enum rte_crypto_cipher_operation direction)
6636 : : {
6637 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6638 : : struct crypto_unittest_params *ut_params = &unittest_params;
6639 : :
6640 : : int retval;
6641 : :
6642 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6643 : : unsigned int plaintext_len = 0;
6644 : : unsigned int ciphertext_len = 0;
6645 : : const uint8_t *ciphertext, *plaintext;
6646 : : uint8_t buffer[2048];
6647 : : struct rte_cryptodev_info dev_info;
6648 : :
6649 : : /* Check if device supports ZUC EEA3 */
6650 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6651 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6652 : : return TEST_SKIPPED;
6653 : :
6654 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6655 : : return TEST_SKIPPED;
6656 : :
6657 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6658 : :
6659 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6660 : :
6661 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6662 : : printf("Device doesn't support in-place scatter-gather. "
6663 : : "Test Skipped.\n");
6664 : 0 : return TEST_SKIPPED;
6665 : : }
6666 : :
6667 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6668 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6669 : : printf("Device doesn't support RAW data-path APIs.\n");
6670 : 0 : return TEST_SKIPPED;
6671 : : }
6672 : :
6673 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6674 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6675 : :
6676 : : /* Append data which is padded to a multiple */
6677 : : /* of the algorithms block size */
6678 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6679 : :
6680 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6681 : : plaintext_pad_len, 10, 0);
6682 : :
6683 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6684 : 0 : tdata->plaintext.data);
6685 : : } else {
6686 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6687 : :
6688 : : /* Append data which is padded to a multiple */
6689 : : /* of the algorithms block size */
6690 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6691 : :
6692 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6693 : : ciphertext_pad_len, 10, 0);
6694 : :
6695 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6696 : 0 : tdata->ciphertext.data);
6697 : :
6698 : : }
6699 : :
6700 : : /* Create ZUC session */
6701 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6702 : : direction,
6703 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6704 : 0 : tdata->key.data, tdata->key.len,
6705 : 0 : tdata->cipher_iv.len);
6706 [ # # ]: 0 : if (retval < 0)
6707 : : return retval;
6708 : :
6709 : : /* Clear mbuf payload */
6710 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6711 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6712 : : else
6713 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6714 : :
6715 : : /* Create ZUC operation */
6716 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6717 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6718 : 0 : tdata->validCipherOffsetInBits.len);
6719 [ # # ]: 0 : if (retval < 0)
6720 : : return retval;
6721 : :
6722 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6723 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6724 : 0 : tdata->cipher_iv.len);
6725 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6726 : : return retval;
6727 : : } else
6728 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6729 : : ut_params->op);
6730 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6731 : :
6732 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6733 : :
6734 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6735 [ # # ]: 0 : if (ut_params->obuf)
6736 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6737 : : 0, plaintext_len, buffer);
6738 : : else
6739 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6740 : : 0, plaintext_len, buffer);
6741 : :
6742 : : /* Validate obuf */
6743 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6744 : :
6745 : : /* Validate obuf */
6746 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6747 : : ciphertext,
6748 : : tdata->ciphertext.data,
6749 : : tdata->validCipherLenInBits.len,
6750 : : "ZUC Ciphertext data not as expected");
6751 : : } else {
6752 [ # # ]: 0 : if (ut_params->obuf)
6753 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6754 : : 0, ciphertext_len, buffer);
6755 : : else
6756 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6757 : : 0, ciphertext_len, buffer);
6758 : :
6759 : : /* Validate obuf */
6760 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6761 : :
6762 : : /* Validate obuf */
6763 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6764 : : plaintext,
6765 : : tdata->plaintext.data,
6766 : : tdata->validCipherLenInBits.len,
6767 : : "ZUC Plaintext data not as expected");
6768 : : }
6769 : :
6770 : : return 0;
6771 : : }
6772 : :
6773 : : static int
6774 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6775 : : enum rte_crypto_auth_operation auth_op)
6776 : : {
6777 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6778 : : struct crypto_unittest_params *ut_params = &unittest_params;
6779 : :
6780 : : int retval;
6781 : : unsigned plaintext_pad_len;
6782 : : unsigned plaintext_len;
6783 : : uint8_t *plaintext;
6784 : :
6785 : : struct rte_cryptodev_info dev_info;
6786 : :
6787 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6788 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6789 : :
6790 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6791 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6792 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6793 : 0 : return TEST_SKIPPED;
6794 : : }
6795 : :
6796 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6797 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6798 : : printf("Device doesn't support RAW data-path APIs.\n");
6799 : 0 : return TEST_SKIPPED;
6800 : : }
6801 : :
6802 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6803 : : return TEST_SKIPPED;
6804 : :
6805 : : /* Check if device supports ZUC EIA3 */
6806 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6807 : 0 : tdata->key.len, tdata->auth_iv.len,
6808 : 0 : tdata->digest.len) < 0)
6809 : : return TEST_SKIPPED;
6810 : :
6811 : : /* Create ZUC session */
6812 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6813 : 0 : tdata->key.data, tdata->key.len,
6814 : 0 : tdata->auth_iv.len, tdata->digest.len,
6815 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6816 [ # # ]: 0 : if (retval != 0)
6817 : : return retval;
6818 : :
6819 : : /* alloc mbuf and set payload */
6820 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6821 : :
6822 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6823 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6824 : :
6825 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6826 : : /* Append data which is padded to a multiple of */
6827 : : /* the algorithms block size */
6828 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6829 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6830 : : plaintext_pad_len);
6831 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6832 : :
6833 : : /* Create ZUC operation */
6834 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6835 : 0 : tdata->digest.len,
6836 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6837 : : plaintext_pad_len,
6838 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6839 [ # # ]: 0 : if (retval < 0)
6840 : : return retval;
6841 : :
6842 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6843 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6844 : : 0);
6845 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6846 : : return retval;
6847 : : } else
6848 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6849 : : ut_params->op);
6850 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6851 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6852 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6853 : : uint8_t *,
6854 : : plaintext_pad_len);
6855 : :
6856 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6857 : : /* Validate obuf */
6858 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6859 : : ut_params->digest,
6860 : : tdata->digest.data,
6861 : : tdata->digest.len,
6862 : : "ZUC Generated auth tag not as expected");
6863 : : return 0;
6864 : : }
6865 : :
6866 : : /* Validate obuf */
6867 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6868 : : return 0;
6869 : : else
6870 : 0 : return -1;
6871 : :
6872 : : return 0;
6873 : : }
6874 : :
6875 : : static int
6876 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6877 : : uint8_t op_mode, uint8_t verify)
6878 : : {
6879 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6880 : : struct crypto_unittest_params *ut_params = &unittest_params;
6881 : :
6882 : : int retval;
6883 : :
6884 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6885 : : unsigned int plaintext_pad_len;
6886 : : unsigned int plaintext_len;
6887 : : unsigned int ciphertext_pad_len;
6888 : : unsigned int ciphertext_len;
6889 : : unsigned int digest_offset;
6890 : :
6891 : : struct rte_cryptodev_info dev_info;
6892 : :
6893 : : /* Check if device supports ZUC EEA3 */
6894 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6895 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6896 : : return TEST_SKIPPED;
6897 : :
6898 : : /* Check if device supports ZUC EIA3 */
6899 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6900 : 0 : tdata->key.len, tdata->auth_iv.len,
6901 : 0 : tdata->digest.len) < 0)
6902 : : return TEST_SKIPPED;
6903 : :
6904 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6905 : : return TEST_SKIPPED;
6906 : :
6907 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6908 : :
6909 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6910 : :
6911 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6912 : : printf("Device doesn't support digest encrypted.\n");
6913 : 0 : return TEST_SKIPPED;
6914 : : }
6915 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6916 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6917 : : printf("Device doesn't support in-place scatter-gather "
6918 : : "in both input and output mbufs.\n");
6919 : 0 : return TEST_SKIPPED;
6920 : : }
6921 : :
6922 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6923 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6924 : : printf("Device doesn't support RAW data-path APIs.\n");
6925 : 0 : return TEST_SKIPPED;
6926 : : }
6927 : : } else {
6928 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6929 : : return TEST_SKIPPED;
6930 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6931 : : printf("Device doesn't support out-of-place scatter-gather "
6932 : : "in both input and output mbufs.\n");
6933 : 0 : return TEST_SKIPPED;
6934 : : }
6935 : : }
6936 : :
6937 : : /* Create ZUC session */
6938 : 0 : retval = create_wireless_algo_auth_cipher_session(
6939 : 0 : ts_params->valid_devs[0],
6940 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6941 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6942 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6943 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6944 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6945 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6946 : : tdata->key.data, tdata->key.len,
6947 : 0 : tdata->key.data, tdata->key.len,
6948 : 0 : tdata->auth_iv.len, tdata->digest.len,
6949 : 0 : tdata->cipher_iv.len);
6950 : :
6951 [ # # ]: 0 : if (retval != 0)
6952 : : return retval;
6953 : :
6954 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6955 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6956 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6957 : :
6958 : : /* clear mbuf payload */
6959 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6960 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6961 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6962 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6963 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6964 : :
6965 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6966 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6967 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6968 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6969 : :
6970 [ # # ]: 0 : if (verify) {
6971 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6972 : : ciphertext_pad_len);
6973 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6974 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6975 : : ciphertext_len);
6976 : : } else {
6977 : : /* make sure enough space to cover partial digest verify case */
6978 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6979 : : ciphertext_pad_len);
6980 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6981 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6982 : : plaintext_len);
6983 : : }
6984 : :
6985 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6986 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6987 : :
6988 : : /* Create ZUC operation */
6989 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6990 : 0 : tdata->digest.data, tdata->digest.len,
6991 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6992 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6993 : 0 : (tdata->digest.offset_bytes == 0 ?
6994 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6995 : : : tdata->digest.offset_bytes),
6996 : 0 : tdata->validCipherLenInBits.len,
6997 : 0 : tdata->validCipherOffsetInBits.len,
6998 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6999 : : 0,
7000 : : op_mode, 0, verify);
7001 : :
7002 [ # # ]: 0 : if (retval < 0)
7003 : : return retval;
7004 : :
7005 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7006 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7007 : 0 : tdata->cipher_iv.len);
7008 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7009 : : return retval;
7010 : : } else
7011 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7012 : : ut_params->op);
7013 : :
7014 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7015 : :
7016 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7017 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7018 : :
7019 : :
7020 [ # # ]: 0 : if (verify) {
7021 [ # # ]: 0 : if (ut_params->obuf)
7022 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7023 : : uint8_t *);
7024 : : else
7025 : : plaintext = ciphertext;
7026 : :
7027 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7028 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7029 : 0 : debug_hexdump(stdout, "plaintext expected:",
7030 : 0 : tdata->plaintext.data,
7031 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7032 : : } else {
7033 [ # # ]: 0 : if (ut_params->obuf)
7034 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7035 : : uint8_t *);
7036 : : else
7037 : : ciphertext = plaintext;
7038 : :
7039 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7040 : : ciphertext_len);
7041 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7042 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7043 : :
7044 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
7045 : : digest_offset = plaintext_pad_len;
7046 : : else
7047 : : digest_offset = tdata->digest.offset_bytes;
7048 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
7049 : : uint8_t *, digest_offset);
7050 : :
7051 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
7052 : 0 : tdata->digest.len);
7053 : 0 : debug_hexdump(stdout, "digest expected:",
7054 : 0 : tdata->digest.data, tdata->digest.len);
7055 : : }
7056 : :
7057 : : /* Validate obuf */
7058 [ # # ]: 0 : if (verify) {
7059 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7060 : : plaintext,
7061 : : tdata->plaintext.data,
7062 : : tdata->plaintext.len >> 3,
7063 : : "ZUC Plaintext data not as expected");
7064 : : } else {
7065 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7066 : : ciphertext,
7067 : : tdata->ciphertext.data,
7068 : : tdata->ciphertext.len >> 3,
7069 : : "ZUC Ciphertext data not as expected");
7070 : :
7071 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7072 : : ut_params->digest,
7073 : : tdata->digest.data,
7074 : : tdata->digest.len,
7075 : : "ZUC Generated auth tag not as expected");
7076 : : }
7077 : : return 0;
7078 : : }
7079 : :
7080 : : static int
7081 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
7082 : : uint8_t op_mode, uint8_t verify)
7083 : : {
7084 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7085 : : struct crypto_unittest_params *ut_params = &unittest_params;
7086 : :
7087 : : int retval;
7088 : :
7089 : : const uint8_t *plaintext = NULL;
7090 : : const uint8_t *ciphertext = NULL;
7091 : : const uint8_t *digest = NULL;
7092 : : unsigned int plaintext_pad_len;
7093 : : unsigned int plaintext_len;
7094 : : unsigned int ciphertext_pad_len;
7095 : : unsigned int ciphertext_len;
7096 : : uint8_t buffer[10000];
7097 : : uint8_t digest_buffer[10000];
7098 : :
7099 : : struct rte_cryptodev_info dev_info;
7100 : :
7101 : : /* Check if device supports ZUC EEA3 */
7102 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
7103 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
7104 : : return TEST_SKIPPED;
7105 : :
7106 : : /* Check if device supports ZUC EIA3 */
7107 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
7108 : 0 : tdata->key.len, tdata->auth_iv.len,
7109 : 0 : tdata->digest.len) < 0)
7110 : : return TEST_SKIPPED;
7111 : :
7112 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7113 : : return TEST_SKIPPED;
7114 : :
7115 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7116 : :
7117 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7118 : :
7119 [ # # ]: 0 : if (op_mode == IN_PLACE) {
7120 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7121 : : printf("Device doesn't support in-place scatter-gather "
7122 : : "in both input and output mbufs.\n");
7123 : 0 : return TEST_SKIPPED;
7124 : : }
7125 : :
7126 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7127 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7128 : : printf("Device doesn't support RAW data-path APIs.\n");
7129 : 0 : return TEST_SKIPPED;
7130 : : }
7131 : : } else {
7132 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7133 : : return TEST_SKIPPED;
7134 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7135 : : printf("Device doesn't support out-of-place scatter-gather "
7136 : : "in both input and output mbufs.\n");
7137 : 0 : return TEST_SKIPPED;
7138 : : }
7139 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7140 : : printf("Device doesn't support digest encrypted.\n");
7141 : 0 : return TEST_SKIPPED;
7142 : : }
7143 : : }
7144 : :
7145 : : /* Create ZUC session */
7146 : 0 : retval = create_wireless_algo_auth_cipher_session(
7147 : 0 : ts_params->valid_devs[0],
7148 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7149 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7150 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7151 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
7152 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
7153 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
7154 : : tdata->key.data, tdata->key.len,
7155 : 0 : tdata->key.data, tdata->key.len,
7156 : 0 : tdata->auth_iv.len, tdata->digest.len,
7157 : 0 : tdata->cipher_iv.len);
7158 : :
7159 [ # # ]: 0 : if (retval != 0)
7160 : : return retval;
7161 : :
7162 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7163 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
7164 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7165 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7166 : :
7167 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7168 : : plaintext_pad_len, 15, 0);
7169 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7170 : : "Failed to allocate input buffer in mempool");
7171 : :
7172 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
7173 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7174 : : plaintext_pad_len, 15, 0);
7175 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
7176 : : "Failed to allocate output buffer in mempool");
7177 : : }
7178 : :
7179 [ # # ]: 0 : if (verify) {
7180 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7181 : 0 : tdata->ciphertext.data);
7182 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7183 : : ciphertext_len, buffer);
7184 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7185 : : ciphertext_len);
7186 : : } else {
7187 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7188 : 0 : tdata->plaintext.data);
7189 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7190 : : plaintext_len, buffer);
7191 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7192 : : plaintext_len);
7193 : : }
7194 : : memset(buffer, 0, sizeof(buffer));
7195 : :
7196 : : /* Create ZUC operation */
7197 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7198 : 0 : tdata->digest.data, tdata->digest.len,
7199 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7200 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7201 : 0 : (tdata->digest.offset_bytes == 0 ?
7202 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7203 : : : tdata->digest.offset_bytes),
7204 : 0 : tdata->validCipherLenInBits.len,
7205 : 0 : tdata->validCipherOffsetInBits.len,
7206 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7207 : : 0,
7208 : : op_mode, 1, verify);
7209 : :
7210 [ # # ]: 0 : if (retval < 0)
7211 : : return retval;
7212 : :
7213 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7214 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7215 : 0 : tdata->cipher_iv.len);
7216 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7217 : : return retval;
7218 : : } else
7219 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7220 : : ut_params->op);
7221 : :
7222 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7223 : :
7224 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7225 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7226 : :
7227 [ # # ]: 0 : if (verify) {
7228 [ # # ]: 0 : if (ut_params->obuf)
7229 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7230 : : plaintext_len, buffer);
7231 : : else
7232 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7233 : : plaintext_len, buffer);
7234 : :
7235 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7236 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7237 : 0 : debug_hexdump(stdout, "plaintext expected:",
7238 : 0 : tdata->plaintext.data,
7239 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7240 : : } else {
7241 [ # # ]: 0 : if (ut_params->obuf)
7242 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7243 : : ciphertext_len, buffer);
7244 : : else
7245 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7246 : : ciphertext_len, buffer);
7247 : :
7248 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7249 : : ciphertext_len);
7250 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7251 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7252 : :
7253 [ # # ]: 0 : if (ut_params->obuf)
7254 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
7255 : 0 : (tdata->digest.offset_bytes == 0 ?
7256 : : plaintext_pad_len : tdata->digest.offset_bytes),
7257 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7258 : : else
7259 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
7260 : 0 : (tdata->digest.offset_bytes == 0 ?
7261 : : plaintext_pad_len : tdata->digest.offset_bytes),
7262 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7263 : :
7264 : 0 : debug_hexdump(stdout, "digest:", digest,
7265 : 0 : tdata->digest.len);
7266 : 0 : debug_hexdump(stdout, "digest expected:",
7267 : 0 : tdata->digest.data, tdata->digest.len);
7268 : : }
7269 : :
7270 : : /* Validate obuf */
7271 [ # # ]: 0 : if (verify) {
7272 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7273 : : plaintext,
7274 : : tdata->plaintext.data,
7275 : : tdata->plaintext.len >> 3,
7276 : : "ZUC Plaintext data not as expected");
7277 : : } else {
7278 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7279 : : ciphertext,
7280 : : tdata->ciphertext.data,
7281 : : tdata->validDataLenInBits.len,
7282 : : "ZUC Ciphertext data not as expected");
7283 : :
7284 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7285 : : digest,
7286 : : tdata->digest.data,
7287 : : tdata->digest.len,
7288 : : "ZUC Generated auth tag not as expected");
7289 : : }
7290 : : return 0;
7291 : : }
7292 : :
7293 : : static int
7294 : 0 : test_kasumi_encryption_test_case_1(void)
7295 : : {
7296 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
7297 : : }
7298 : :
7299 : : static int
7300 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
7301 : : {
7302 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7303 : : }
7304 : :
7305 : : static int
7306 : 0 : test_kasumi_encryption_test_case_1_oop(void)
7307 : : {
7308 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
7309 : : }
7310 : :
7311 : : static int
7312 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
7313 : : {
7314 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7315 : : }
7316 : :
7317 : : static int
7318 : 0 : test_kasumi_encryption_test_case_2(void)
7319 : : {
7320 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
7321 : : }
7322 : :
7323 : : static int
7324 : 0 : test_kasumi_encryption_test_case_3(void)
7325 : : {
7326 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
7327 : : }
7328 : :
7329 : : static int
7330 : 0 : test_kasumi_encryption_test_case_4(void)
7331 : : {
7332 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
7333 : : }
7334 : :
7335 : : static int
7336 : 0 : test_kasumi_encryption_test_case_5(void)
7337 : : {
7338 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
7339 : : }
7340 : :
7341 : : static int
7342 : 0 : test_kasumi_decryption_test_case_1(void)
7343 : : {
7344 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
7345 : : }
7346 : :
7347 : : static int
7348 : 0 : test_kasumi_decryption_test_case_1_oop(void)
7349 : : {
7350 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
7351 : : }
7352 : :
7353 : : static int
7354 : 0 : test_kasumi_decryption_test_case_2(void)
7355 : : {
7356 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
7357 : : }
7358 : :
7359 : : static int
7360 : 0 : test_kasumi_decryption_test_case_3(void)
7361 : : {
7362 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7363 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7364 : : return TEST_SKIPPED;
7365 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7366 : : }
7367 : :
7368 : : static int
7369 : 0 : test_kasumi_decryption_test_case_4(void)
7370 : : {
7371 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7372 : : }
7373 : :
7374 : : static int
7375 : 0 : test_kasumi_decryption_test_case_5(void)
7376 : : {
7377 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7378 : : }
7379 : : static int
7380 : 0 : test_snow3g_encryption_test_case_1(void)
7381 : : {
7382 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7383 : : }
7384 : :
7385 : : static int
7386 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7387 : : {
7388 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7389 : : }
7390 : :
7391 : : static int
7392 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7393 : : {
7394 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7395 : : }
7396 : :
7397 : : static int
7398 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7399 : : {
7400 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7401 : : }
7402 : :
7403 : : static int
7404 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7405 : : {
7406 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7407 : : }
7408 : :
7409 : : static int
7410 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7411 : : {
7412 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7413 : : }
7414 : :
7415 : : static int
7416 : 0 : test_snow3g_encryption_test_case_2(void)
7417 : : {
7418 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7419 : : }
7420 : :
7421 : : static int
7422 : 0 : test_snow3g_encryption_test_case_3(void)
7423 : : {
7424 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7425 : : }
7426 : :
7427 : : static int
7428 : 0 : test_snow3g_encryption_test_case_4(void)
7429 : : {
7430 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7431 : : }
7432 : :
7433 : : static int
7434 : 0 : test_snow3g_encryption_test_case_5(void)
7435 : : {
7436 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7437 : : }
7438 : :
7439 : : static int
7440 : 0 : test_snow3g_decryption_test_case_1(void)
7441 : : {
7442 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7443 : : }
7444 : :
7445 : : static int
7446 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7447 : : {
7448 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7449 : : }
7450 : :
7451 : : static int
7452 : 0 : test_snow3g_decryption_test_case_2(void)
7453 : : {
7454 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7455 : : }
7456 : :
7457 : : static int
7458 : 0 : test_snow3g_decryption_test_case_3(void)
7459 : : {
7460 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7461 : : }
7462 : :
7463 : : static int
7464 : 0 : test_snow3g_decryption_test_case_4(void)
7465 : : {
7466 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7467 : : }
7468 : :
7469 : : static int
7470 : 0 : test_snow3g_decryption_test_case_5(void)
7471 : : {
7472 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7473 : : }
7474 : :
7475 : : /*
7476 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7477 : : * Pattern digest from snow3g_test_data must be allocated as
7478 : : * 4 last bytes in plaintext.
7479 : : */
7480 : : static void
7481 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7482 : : struct snow3g_hash_test_data *output)
7483 : : {
7484 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7485 : 0 : output->key.len = pattern->key.len;
7486 : :
7487 : 0 : memcpy(output->key.data,
7488 : 0 : pattern->key.data, pattern->key.len);
7489 : :
7490 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7491 : :
7492 : 0 : memcpy(output->auth_iv.data,
7493 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7494 : :
7495 : 0 : output->plaintext.len = pattern->plaintext.len;
7496 : :
7497 : 0 : memcpy(output->plaintext.data,
7498 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7499 : :
7500 : 0 : output->digest.len = pattern->digest.len;
7501 : :
7502 : 0 : memcpy(output->digest.data,
7503 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7504 : : pattern->digest.len);
7505 : :
7506 : 0 : output->validAuthLenInBits.len =
7507 : 0 : pattern->validAuthLenInBits.len;
7508 : : }
7509 : 0 : }
7510 : :
7511 : : /*
7512 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7513 : : */
7514 : : static int
7515 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7516 : : {
7517 : : int ret;
7518 : : struct snow3g_hash_test_data snow3g_hash_data;
7519 : : struct rte_cryptodev_info dev_info;
7520 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7521 : :
7522 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7523 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7524 : :
7525 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7526 : : printf("Device doesn't support encrypted digest operations.\n");
7527 : 0 : return TEST_SKIPPED;
7528 : : }
7529 : :
7530 : : /*
7531 : : * Function prepare data for hash verification test case.
7532 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7533 : : */
7534 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7535 : :
7536 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7537 [ # # ]: 0 : if (ret != 0)
7538 : : return ret;
7539 : :
7540 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7541 : : }
7542 : :
7543 : : static int
7544 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7545 : : {
7546 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7547 : : }
7548 : :
7549 : : static int
7550 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7551 : : {
7552 : 0 : return test_snow3g_auth_cipher(
7553 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7554 : : }
7555 : :
7556 : : static int
7557 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7558 : : {
7559 : 0 : return test_snow3g_auth_cipher(
7560 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7561 : : }
7562 : :
7563 : : static int
7564 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7565 : : {
7566 : 0 : return test_snow3g_auth_cipher(
7567 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7568 : : }
7569 : :
7570 : : static int
7571 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7572 : : {
7573 : 0 : return test_snow3g_auth_cipher(
7574 : : &snow3g_auth_cipher_partial_digest_encryption,
7575 : : IN_PLACE, 0);
7576 : : }
7577 : :
7578 : : static int
7579 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7580 : : {
7581 : 0 : return test_snow3g_auth_cipher(
7582 : : &snow3g_auth_cipher_partial_digest_encryption,
7583 : : OUT_OF_PLACE, 0);
7584 : : }
7585 : :
7586 : : static int
7587 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7588 : : {
7589 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7590 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7591 : : return TEST_SKIPPED;
7592 : 0 : return test_snow3g_auth_cipher_sgl(
7593 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7594 : : }
7595 : :
7596 : : static int
7597 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7598 : : {
7599 : 0 : return test_snow3g_auth_cipher_sgl(
7600 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7601 : : }
7602 : :
7603 : : static int
7604 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7605 : : {
7606 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7607 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7608 : : return TEST_SKIPPED;
7609 : 0 : return test_snow3g_auth_cipher_sgl(
7610 : : &snow3g_auth_cipher_partial_digest_encryption,
7611 : : IN_PLACE, 0);
7612 : : }
7613 : :
7614 : : static int
7615 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7616 : : {
7617 : 0 : return test_snow3g_auth_cipher_sgl(
7618 : : &snow3g_auth_cipher_partial_digest_encryption,
7619 : : OUT_OF_PLACE, 0);
7620 : : }
7621 : :
7622 : : static int
7623 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7624 : : {
7625 : 0 : return test_snow3g_auth_cipher(
7626 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7627 : : }
7628 : :
7629 : : static int
7630 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7631 : : {
7632 : 0 : return test_snow3g_auth_cipher(
7633 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7634 : : }
7635 : :
7636 : : static int
7637 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7638 : : {
7639 : 0 : return test_snow3g_auth_cipher_sgl(
7640 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7641 : : }
7642 : :
7643 : : static int
7644 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7645 : : {
7646 : 0 : return test_snow3g_auth_cipher_sgl(
7647 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7648 : : }
7649 : :
7650 : : static int
7651 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7652 : : {
7653 : 0 : return test_snow3g_auth_cipher(
7654 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7655 : : }
7656 : :
7657 : : static int
7658 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7659 : : {
7660 : 0 : return test_snow3g_auth_cipher(
7661 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7662 : : }
7663 : :
7664 : : static int
7665 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7666 : : {
7667 : 0 : return test_snow3g_auth_cipher(
7668 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7669 : : }
7670 : :
7671 : : static int
7672 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7673 : : {
7674 : 0 : return test_snow3g_auth_cipher(
7675 : : &snow3g_auth_cipher_partial_digest_encryption,
7676 : : IN_PLACE, 1);
7677 : : }
7678 : :
7679 : : static int
7680 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7681 : : {
7682 : 0 : return test_snow3g_auth_cipher(
7683 : : &snow3g_auth_cipher_partial_digest_encryption,
7684 : : OUT_OF_PLACE, 1);
7685 : : }
7686 : :
7687 : : static int
7688 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7689 : : {
7690 : 0 : return test_snow3g_auth_cipher_sgl(
7691 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7692 : : }
7693 : :
7694 : : static int
7695 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7696 : : {
7697 : 0 : return test_snow3g_auth_cipher_sgl(
7698 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7699 : : }
7700 : :
7701 : : static int
7702 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7703 : : {
7704 : 0 : return test_snow3g_auth_cipher_sgl(
7705 : : &snow3g_auth_cipher_partial_digest_encryption,
7706 : : IN_PLACE, 1);
7707 : : }
7708 : :
7709 : : static int
7710 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7711 : : {
7712 : 0 : return test_snow3g_auth_cipher_sgl(
7713 : : &snow3g_auth_cipher_partial_digest_encryption,
7714 : : OUT_OF_PLACE, 1);
7715 : : }
7716 : :
7717 : : static int
7718 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7719 : : {
7720 : 0 : return test_snow3g_auth_cipher(
7721 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7722 : : }
7723 : :
7724 : : static int
7725 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7726 : : {
7727 : 0 : return test_snow3g_auth_cipher(
7728 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7729 : : }
7730 : :
7731 : : static int
7732 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7733 : : {
7734 : 0 : return test_snow3g_auth_cipher_sgl(
7735 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7736 : : }
7737 : :
7738 : : static int
7739 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7740 : : {
7741 : 0 : return test_snow3g_auth_cipher_sgl(
7742 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7743 : : }
7744 : :
7745 : : static int
7746 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7747 : : {
7748 : 0 : return test_snow3g_auth_cipher(
7749 : : &snow3g_test_case_7, IN_PLACE, 0);
7750 : : }
7751 : :
7752 : : static int
7753 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7754 : : {
7755 : 0 : return test_kasumi_auth_cipher(
7756 : : &kasumi_test_case_3, IN_PLACE, 0);
7757 : : }
7758 : :
7759 : : static int
7760 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7761 : : {
7762 : 0 : return test_kasumi_auth_cipher(
7763 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7764 : : }
7765 : :
7766 : : static int
7767 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7768 : : {
7769 : 0 : return test_kasumi_auth_cipher(
7770 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7771 : : }
7772 : :
7773 : : static int
7774 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7775 : : {
7776 : 0 : return test_kasumi_auth_cipher_sgl(
7777 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7778 : : }
7779 : :
7780 : : static int
7781 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7782 : : {
7783 : 0 : return test_kasumi_auth_cipher_sgl(
7784 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7785 : : }
7786 : :
7787 : : static int
7788 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7789 : : {
7790 : 0 : return test_kasumi_auth_cipher(
7791 : : &kasumi_test_case_3, IN_PLACE, 1);
7792 : : }
7793 : :
7794 : : static int
7795 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7796 : : {
7797 : 0 : return test_kasumi_auth_cipher(
7798 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7799 : : }
7800 : :
7801 : : static int
7802 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7803 : : {
7804 : 0 : return test_kasumi_auth_cipher(
7805 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7806 : : }
7807 : :
7808 : : static int
7809 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7810 : : {
7811 : 0 : return test_kasumi_auth_cipher_sgl(
7812 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7813 : : }
7814 : :
7815 : : static int
7816 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7817 : : {
7818 : 0 : return test_kasumi_auth_cipher_sgl(
7819 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7820 : : }
7821 : :
7822 : : static int
7823 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7824 : : {
7825 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7826 : : }
7827 : :
7828 : : static int
7829 : 0 : test_zuc_encryption_test_case_1(void)
7830 : : {
7831 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7832 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7833 : : }
7834 : :
7835 : : static int
7836 : 0 : test_zuc_encryption_test_case_2(void)
7837 : : {
7838 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7839 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7840 : : }
7841 : :
7842 : : static int
7843 : 0 : test_zuc_encryption_test_case_3(void)
7844 : : {
7845 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7846 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7847 : : }
7848 : :
7849 : : static int
7850 : 0 : test_zuc_encryption_test_case_4(void)
7851 : : {
7852 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7853 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7854 : : }
7855 : :
7856 : : static int
7857 : 0 : test_zuc_encryption_test_case_5(void)
7858 : : {
7859 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7860 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7861 : : }
7862 : :
7863 : : static int
7864 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7865 : : {
7866 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7867 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7868 : : }
7869 : :
7870 : : static int
7871 : 0 : test_zuc_decryption_test_case_1(void)
7872 : : {
7873 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7874 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7875 : : }
7876 : :
7877 : : static int
7878 : 0 : test_zuc_decryption_test_case_2(void)
7879 : : {
7880 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7881 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7882 : : }
7883 : :
7884 : : static int
7885 : 0 : test_zuc_decryption_test_case_3(void)
7886 : : {
7887 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7888 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7889 : : }
7890 : :
7891 : : static int
7892 : 0 : test_zuc_decryption_test_case_4(void)
7893 : : {
7894 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7895 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7896 : : }
7897 : :
7898 : : static int
7899 : 0 : test_zuc_decryption_test_case_5(void)
7900 : : {
7901 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7902 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7903 : : }
7904 : :
7905 : : static int
7906 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7907 : : {
7908 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7909 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7910 : : }
7911 : :
7912 : : static int
7913 : 0 : test_zuc_hash_generate_test_case_1(void)
7914 : : {
7915 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7916 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7917 : : }
7918 : :
7919 : : static int
7920 : 0 : test_zuc_hash_generate_test_case_2(void)
7921 : : {
7922 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7923 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7924 : : }
7925 : :
7926 : : static int
7927 : 0 : test_zuc_hash_generate_test_case_3(void)
7928 : : {
7929 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7930 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7931 : : }
7932 : :
7933 : : static int
7934 : 0 : test_zuc_hash_generate_test_case_4(void)
7935 : : {
7936 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7937 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7938 : : }
7939 : :
7940 : : static int
7941 : 0 : test_zuc_hash_generate_test_case_5(void)
7942 : : {
7943 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7944 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7945 : : }
7946 : :
7947 : : static int
7948 : 0 : test_zuc_hash_generate_test_case_6(void)
7949 : : {
7950 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7951 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7952 : : }
7953 : :
7954 : : static int
7955 : 0 : test_zuc_hash_generate_test_case_7(void)
7956 : : {
7957 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7958 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7959 : : }
7960 : :
7961 : : static int
7962 : 0 : test_zuc_hash_generate_test_case_8(void)
7963 : : {
7964 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7965 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7966 : : }
7967 : :
7968 : : static int
7969 : 0 : test_zuc_hash_verify_test_case_1(void)
7970 : : {
7971 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7972 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7973 : : }
7974 : :
7975 : : static int
7976 : 0 : test_zuc_hash_verify_test_case_2(void)
7977 : : {
7978 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7979 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7980 : : }
7981 : :
7982 : : static int
7983 : 0 : test_zuc_hash_verify_test_case_3(void)
7984 : : {
7985 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7986 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7987 : : }
7988 : :
7989 : : static int
7990 : 0 : test_zuc_hash_verify_test_case_4(void)
7991 : : {
7992 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7993 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7994 : : }
7995 : :
7996 : : static int
7997 : 0 : test_zuc_hash_verify_test_case_5(void)
7998 : : {
7999 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
8000 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8001 : : }
8002 : :
8003 : : static int
8004 : 0 : test_zuc_hash_verify_test_case_6(void)
8005 : : {
8006 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
8007 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8008 : : }
8009 : :
8010 : : static int
8011 : 0 : test_zuc_hash_verify_test_case_7(void)
8012 : : {
8013 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
8014 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8015 : : }
8016 : :
8017 : : static int
8018 : 0 : test_zuc_hash_verify_test_case_8(void)
8019 : : {
8020 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
8021 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8022 : : }
8023 : :
8024 : : static int
8025 : 0 : test_zuc_cipher_auth_test_case_1(void)
8026 : : {
8027 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
8028 : : }
8029 : :
8030 : : static int
8031 : 0 : test_zuc_cipher_auth_test_case_2(void)
8032 : : {
8033 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
8034 : : }
8035 : :
8036 : : static int
8037 : 0 : test_zuc_auth_cipher_test_case_1(void)
8038 : : {
8039 : 0 : return test_zuc_auth_cipher(
8040 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8041 : : }
8042 : :
8043 : : static int
8044 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
8045 : : {
8046 : 0 : return test_zuc_auth_cipher(
8047 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8048 : : }
8049 : :
8050 : : static int
8051 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
8052 : : {
8053 : 0 : return test_zuc_auth_cipher_sgl(
8054 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8055 : : }
8056 : :
8057 : : static int
8058 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
8059 : : {
8060 : 0 : return test_zuc_auth_cipher_sgl(
8061 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8062 : : }
8063 : :
8064 : : static int
8065 : 0 : test_zuc_auth_cipher_test_case_2(void)
8066 : : {
8067 : 0 : return test_zuc_auth_cipher(
8068 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
8069 : : }
8070 : :
8071 : : static int
8072 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
8073 : : {
8074 : 0 : return test_zuc_auth_cipher(
8075 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
8076 : : }
8077 : :
8078 : : static int
8079 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
8080 : : {
8081 : 0 : return test_zuc_auth_cipher(
8082 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8083 : : }
8084 : :
8085 : : static int
8086 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
8087 : : {
8088 : 0 : return test_zuc_auth_cipher(
8089 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8090 : : }
8091 : :
8092 : : static int
8093 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
8094 : : {
8095 : 0 : return test_zuc_auth_cipher_sgl(
8096 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8097 : : }
8098 : :
8099 : : static int
8100 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
8101 : : {
8102 : 0 : return test_zuc_auth_cipher_sgl(
8103 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8104 : : }
8105 : :
8106 : : static int
8107 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
8108 : : {
8109 : 0 : return test_zuc_auth_cipher(
8110 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
8111 : : }
8112 : :
8113 : : static int
8114 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
8115 : : {
8116 : 0 : return test_zuc_auth_cipher(
8117 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8118 : : }
8119 : :
8120 : : static int
8121 : 0 : test_zuc256_encryption_test_case_1(void)
8122 : : {
8123 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8124 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8125 : : }
8126 : :
8127 : : static int
8128 : 0 : test_zuc256_encryption_test_case_2(void)
8129 : : {
8130 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8131 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8132 : : }
8133 : :
8134 : : static int
8135 : 0 : test_zuc256_decryption_test_case_1(void)
8136 : : {
8137 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8138 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8139 : : }
8140 : :
8141 : : static int
8142 : 0 : test_zuc256_decryption_test_case_2(void)
8143 : : {
8144 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8145 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8146 : : }
8147 : :
8148 : : static int
8149 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
8150 : : {
8151 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8152 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8153 : : }
8154 : :
8155 : : static int
8156 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
8157 : : {
8158 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8159 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8160 : : }
8161 : :
8162 : : static int
8163 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
8164 : : {
8165 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8166 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8167 : : }
8168 : :
8169 : : static int
8170 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
8171 : : {
8172 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8173 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8174 : : }
8175 : :
8176 : : static int
8177 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
8178 : : {
8179 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8180 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8181 : : }
8182 : :
8183 : : static int
8184 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
8185 : : {
8186 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8187 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8188 : : }
8189 : :
8190 : : static int
8191 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
8192 : : {
8193 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8194 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8195 : : }
8196 : :
8197 : : static int
8198 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
8199 : : {
8200 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8201 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8202 : : }
8203 : :
8204 : : static int
8205 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
8206 : : {
8207 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8208 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8209 : : }
8210 : :
8211 : : static int
8212 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
8213 : : {
8214 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8215 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8216 : : }
8217 : :
8218 : : static int
8219 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8220 : : {
8221 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8222 : : }
8223 : :
8224 : : static int
8225 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8226 : : {
8227 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8228 : : }
8229 : :
8230 : : static int
8231 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8232 : : {
8233 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8234 : : }
8235 : :
8236 : : static int
8237 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8238 : : {
8239 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8240 : : }
8241 : :
8242 : : static int
8243 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8244 : : {
8245 : 0 : return test_zuc_auth_cipher(
8246 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8247 : : }
8248 : :
8249 : : static int
8250 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8251 : : {
8252 : 0 : return test_zuc_auth_cipher(
8253 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8254 : : }
8255 : :
8256 : : static int
8257 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8258 : : {
8259 : 0 : return test_zuc_auth_cipher(
8260 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8261 : : }
8262 : :
8263 : : static int
8264 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8265 : : {
8266 : 0 : return test_zuc_auth_cipher(
8267 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8268 : : }
8269 : :
8270 : : static int
8271 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8272 : : {
8273 : 0 : return test_zuc_auth_cipher(
8274 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8275 : : }
8276 : :
8277 : : static int
8278 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8279 : : {
8280 : 0 : return test_zuc_auth_cipher(
8281 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8282 : : }
8283 : :
8284 : : static int
8285 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8286 : : {
8287 : 0 : return test_zuc_auth_cipher(
8288 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8289 : : }
8290 : :
8291 : : static int
8292 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8293 : : {
8294 : 0 : return test_zuc_auth_cipher(
8295 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8296 : : }
8297 : :
8298 : : static int
8299 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8300 : : {
8301 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
8302 : :
8303 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8304 : :
8305 : : /* Check if device supports particular cipher algorithm */
8306 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8307 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
8308 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8309 : : return TEST_SKIPPED;
8310 : :
8311 : : /* Check if device supports particular hash algorithm */
8312 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8313 : 24 : cap_idx.algo.auth = tdata->auth_algo;
8314 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8315 : 12 : return TEST_SKIPPED;
8316 : :
8317 : : return 0;
8318 : : }
8319 : :
8320 : : static int
8321 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8322 : : uint8_t op_mode, uint8_t verify)
8323 : : {
8324 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8325 : : struct crypto_unittest_params *ut_params = &unittest_params;
8326 : :
8327 : : int retval;
8328 : :
8329 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
8330 : : unsigned int plaintext_pad_len;
8331 : : unsigned int plaintext_len;
8332 : : unsigned int ciphertext_pad_len;
8333 : : unsigned int ciphertext_len;
8334 : : unsigned int digest_offset;
8335 : :
8336 : : struct rte_cryptodev_info dev_info;
8337 : : struct rte_crypto_op *op;
8338 : :
8339 : : /* Check if device supports particular algorithms separately */
8340 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
8341 : : return TEST_SKIPPED;
8342 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8343 : : return TEST_SKIPPED;
8344 : :
8345 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8346 : : return TEST_SKIPPED;
8347 : :
8348 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8349 : :
8350 : 8 : uint64_t feat_flags = dev_info.feature_flags;
8351 : :
8352 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8353 : : printf("Device doesn't support digest encrypted.\n");
8354 : 8 : return TEST_SKIPPED;
8355 : : }
8356 : :
8357 : : /* Create the session */
8358 [ # # ]: 0 : if (verify)
8359 : 0 : retval = create_wireless_algo_cipher_auth_session(
8360 : 0 : ts_params->valid_devs[0],
8361 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8362 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8363 : 0 : tdata->auth_algo,
8364 : 0 : tdata->cipher_algo,
8365 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8366 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8367 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8368 : 0 : tdata->cipher_iv.len);
8369 : : else
8370 : 0 : retval = create_wireless_algo_auth_cipher_session(
8371 : 0 : ts_params->valid_devs[0],
8372 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8373 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8374 : 0 : tdata->auth_algo,
8375 : 0 : tdata->cipher_algo,
8376 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8377 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8378 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8379 : 0 : tdata->cipher_iv.len);
8380 [ # # ]: 0 : if (retval != 0)
8381 : : return retval;
8382 : :
8383 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8384 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8385 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8386 : :
8387 : : /* clear mbuf payload */
8388 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8389 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8390 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8391 : :
8392 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8393 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8394 : : }
8395 : :
8396 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8397 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8398 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8399 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8400 : :
8401 [ # # ]: 0 : if (verify) {
8402 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8403 : : ciphertext_pad_len);
8404 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8405 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8406 : : ciphertext_len);
8407 : : } else {
8408 : : /* make sure enough space to cover partial digest verify case */
8409 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8410 : : ciphertext_pad_len);
8411 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8412 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8413 : : }
8414 : :
8415 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8416 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8417 : :
8418 : : /* Create the operation */
8419 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8420 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8421 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8422 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8423 : 0 : (tdata->digest_enc.offset == 0 ?
8424 : : plaintext_pad_len
8425 : : : tdata->digest_enc.offset),
8426 : 0 : tdata->validCipherLen.len_bits,
8427 : 0 : tdata->cipher.offset_bits,
8428 : 0 : tdata->validAuthLen.len_bits,
8429 [ # # ]: 0 : tdata->auth.offset_bits,
8430 : : op_mode, 0, verify);
8431 : :
8432 [ # # ]: 0 : if (retval < 0)
8433 : : return retval;
8434 : :
8435 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8436 : :
8437 : : /* Check if the op failed because the device doesn't */
8438 : : /* support this particular combination of algorithms */
8439 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8440 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8441 : : printf("Device doesn't support this mixed combination. "
8442 : : "Test Skipped.\n");
8443 : 0 : return TEST_SKIPPED;
8444 : : }
8445 : 0 : ut_params->op = op;
8446 : :
8447 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8448 : :
8449 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8450 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8451 : :
8452 [ # # ]: 0 : if (verify) {
8453 [ # # ]: 0 : if (ut_params->obuf)
8454 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8455 : : uint8_t *);
8456 : : else
8457 : 0 : plaintext = ciphertext +
8458 : 0 : (tdata->cipher.offset_bits >> 3);
8459 : :
8460 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8461 : 0 : tdata->plaintext.len_bits >> 3);
8462 : 0 : debug_hexdump(stdout, "plaintext expected:",
8463 : 0 : tdata->plaintext.data,
8464 : 0 : tdata->plaintext.len_bits >> 3);
8465 : : } else {
8466 [ # # ]: 0 : if (ut_params->obuf)
8467 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8468 : : uint8_t *);
8469 : : else
8470 : : ciphertext = plaintext;
8471 : :
8472 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8473 : : ciphertext_len);
8474 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8475 : 0 : tdata->ciphertext.data,
8476 : 0 : tdata->ciphertext.len_bits >> 3);
8477 : :
8478 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8479 : : digest_offset = plaintext_pad_len;
8480 : : else
8481 : : digest_offset = tdata->digest_enc.offset;
8482 : :
8483 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8484 : : uint8_t *, digest_offset);
8485 : :
8486 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8487 : 0 : tdata->digest_enc.len);
8488 : 0 : debug_hexdump(stdout, "digest expected:",
8489 : : tdata->digest_enc.data,
8490 : 0 : tdata->digest_enc.len);
8491 : : }
8492 : :
8493 [ # # ]: 0 : if (!verify) {
8494 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8495 : : ut_params->digest,
8496 : : tdata->digest_enc.data,
8497 : : tdata->digest_enc.len,
8498 : : "Generated auth tag not as expected");
8499 : : }
8500 : :
8501 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8502 [ # # ]: 0 : if (verify) {
8503 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8504 : : plaintext,
8505 : : tdata->plaintext.data,
8506 : : tdata->plaintext.len_bits >> 3,
8507 : : "Plaintext data not as expected");
8508 : : } else {
8509 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8510 : : ciphertext,
8511 : : tdata->ciphertext.data,
8512 : : tdata->validDataLen.len_bits,
8513 : : "Ciphertext data not as expected");
8514 : : }
8515 : : }
8516 : :
8517 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8518 : : "crypto op processing failed");
8519 : :
8520 : : return 0;
8521 : : }
8522 : :
8523 : : static int
8524 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8525 : : uint8_t op_mode, uint8_t verify)
8526 : : {
8527 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8528 : : struct crypto_unittest_params *ut_params = &unittest_params;
8529 : :
8530 : : int retval;
8531 : :
8532 : : const uint8_t *plaintext = NULL;
8533 : : const uint8_t *ciphertext = NULL;
8534 : : const uint8_t *digest = NULL;
8535 : : unsigned int plaintext_pad_len;
8536 : : unsigned int plaintext_len;
8537 : : unsigned int ciphertext_pad_len;
8538 : : unsigned int ciphertext_len;
8539 : : uint8_t buffer[10000];
8540 : : uint8_t digest_buffer[10000];
8541 : :
8542 : : struct rte_cryptodev_info dev_info;
8543 : : struct rte_crypto_op *op;
8544 : :
8545 : : /* Check if device supports particular algorithms */
8546 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8547 : : return TEST_SKIPPED;
8548 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8549 : : return TEST_SKIPPED;
8550 : :
8551 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8552 : :
8553 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8554 : :
8555 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8556 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8557 : : printf("Device doesn't support in-place scatter-gather "
8558 : : "in both input and output mbufs.\n");
8559 : 0 : return TEST_SKIPPED;
8560 : : }
8561 : : } else {
8562 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8563 : : printf("Device doesn't support out-of-place scatter-gather "
8564 : : "in both input and output mbufs.\n");
8565 : 2 : return TEST_SKIPPED;
8566 : : }
8567 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8568 : : printf("Device doesn't support digest encrypted.\n");
8569 : 0 : return TEST_SKIPPED;
8570 : : }
8571 : : }
8572 : :
8573 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8574 : : return TEST_SKIPPED;
8575 : :
8576 : : /* Create the session */
8577 [ + + ]: 2 : if (verify)
8578 : 1 : retval = create_wireless_algo_cipher_auth_session(
8579 : 1 : ts_params->valid_devs[0],
8580 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8581 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8582 : 1 : tdata->auth_algo,
8583 : 1 : tdata->cipher_algo,
8584 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8585 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8586 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8587 : 1 : tdata->cipher_iv.len);
8588 : : else
8589 : 1 : retval = create_wireless_algo_auth_cipher_session(
8590 : 1 : ts_params->valid_devs[0],
8591 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8592 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8593 : 1 : tdata->auth_algo,
8594 : 1 : tdata->cipher_algo,
8595 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8596 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8597 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8598 : 1 : tdata->cipher_iv.len);
8599 [ + - ]: 2 : if (retval != 0)
8600 : : return retval;
8601 : :
8602 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8603 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8604 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8605 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8606 : :
8607 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8608 : : ciphertext_pad_len, 15, 0);
8609 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8610 : : "Failed to allocate input buffer in mempool");
8611 : :
8612 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8613 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8614 : : plaintext_pad_len, 15, 0);
8615 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8616 : : "Failed to allocate output buffer in mempool");
8617 : : }
8618 : :
8619 [ + + ]: 2 : if (verify) {
8620 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8621 : 1 : tdata->ciphertext.data);
8622 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8623 : : ciphertext_len, buffer);
8624 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8625 : : ciphertext_len);
8626 : : } else {
8627 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8628 : 1 : tdata->plaintext.data);
8629 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8630 : : plaintext_len, buffer);
8631 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8632 : : plaintext_len);
8633 : : }
8634 : : memset(buffer, 0, sizeof(buffer));
8635 : :
8636 : : /* Create the operation */
8637 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8638 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8639 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8640 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8641 : 2 : (tdata->digest_enc.offset == 0 ?
8642 : : plaintext_pad_len
8643 : : : tdata->digest_enc.offset),
8644 : 2 : tdata->validCipherLen.len_bits,
8645 : 2 : tdata->cipher.offset_bits,
8646 : 2 : tdata->validAuthLen.len_bits,
8647 [ + - ]: 2 : tdata->auth.offset_bits,
8648 : : op_mode, 1, verify);
8649 : :
8650 [ + - ]: 2 : if (retval < 0)
8651 : : return retval;
8652 : :
8653 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8654 : :
8655 : : /* Check if the op failed because the device doesn't */
8656 : : /* support this particular combination of algorithms */
8657 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8658 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8659 : : printf("Device doesn't support this mixed combination. "
8660 : : "Test Skipped.\n");
8661 : 0 : return TEST_SKIPPED;
8662 : : }
8663 : 2 : ut_params->op = op;
8664 : :
8665 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8666 : :
8667 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8668 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8669 : :
8670 [ + + ]: 2 : if (verify) {
8671 [ + - ]: 1 : if (ut_params->obuf)
8672 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8673 : : plaintext_len, buffer);
8674 : : else
8675 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8676 : : plaintext_len, buffer);
8677 : :
8678 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8679 : 1 : (tdata->plaintext.len_bits >> 3) -
8680 : 1 : tdata->digest_enc.len);
8681 : 1 : debug_hexdump(stdout, "plaintext expected:",
8682 : 1 : tdata->plaintext.data,
8683 : 1 : (tdata->plaintext.len_bits >> 3) -
8684 : 1 : tdata->digest_enc.len);
8685 : : } else {
8686 [ + - ]: 1 : if (ut_params->obuf)
8687 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8688 : : ciphertext_len, buffer);
8689 : : else
8690 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8691 : : ciphertext_len, buffer);
8692 : :
8693 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8694 : : ciphertext_len);
8695 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8696 : 1 : tdata->ciphertext.data,
8697 : 1 : tdata->ciphertext.len_bits >> 3);
8698 : :
8699 [ + - ]: 1 : if (ut_params->obuf)
8700 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8701 : 1 : (tdata->digest_enc.offset == 0 ?
8702 : : plaintext_pad_len :
8703 : : tdata->digest_enc.offset),
8704 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8705 : : else
8706 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8707 : 0 : (tdata->digest_enc.offset == 0 ?
8708 : : plaintext_pad_len :
8709 : : tdata->digest_enc.offset),
8710 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8711 : :
8712 : 1 : debug_hexdump(stdout, "digest:", digest,
8713 : 1 : tdata->digest_enc.len);
8714 : 1 : debug_hexdump(stdout, "digest expected:",
8715 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8716 : : }
8717 : :
8718 [ + + ]: 2 : if (!verify) {
8719 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8720 : : digest,
8721 : : tdata->digest_enc.data,
8722 : : tdata->digest_enc.len,
8723 : : "Generated auth tag not as expected");
8724 : : }
8725 : :
8726 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8727 [ + + ]: 2 : if (verify) {
8728 [ - + + - : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- + ]
8729 : : plaintext,
8730 : : tdata->plaintext.data,
8731 : : tdata->plaintext.len_bits >> 3,
8732 : : "Plaintext data not as expected");
8733 : : } else {
8734 [ - + - + : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- - ]
8735 : : ciphertext,
8736 : : tdata->ciphertext.data,
8737 : : tdata->validDataLen.len_bits,
8738 : : "Ciphertext data not as expected");
8739 : : }
8740 : : }
8741 : :
8742 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8743 : : "crypto op processing failed");
8744 : :
8745 : : return 0;
8746 : : }
8747 : :
8748 : : /** AUTH AES CMAC + CIPHER AES CTR */
8749 : :
8750 : : static int
8751 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8752 : : {
8753 : 1 : return test_mixed_auth_cipher(
8754 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8755 : : }
8756 : :
8757 : : static int
8758 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8759 : : {
8760 : 1 : return test_mixed_auth_cipher(
8761 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8762 : : }
8763 : :
8764 : : static int
8765 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8766 : : {
8767 : 1 : return test_mixed_auth_cipher_sgl(
8768 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8769 : : }
8770 : :
8771 : : static int
8772 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8773 : : {
8774 : 1 : return test_mixed_auth_cipher_sgl(
8775 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8776 : : }
8777 : :
8778 : : static int
8779 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8780 : : {
8781 : 1 : return test_mixed_auth_cipher(
8782 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8783 : : }
8784 : :
8785 : : static int
8786 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8787 : : {
8788 : 1 : return test_mixed_auth_cipher(
8789 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8790 : : }
8791 : :
8792 : : static int
8793 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8794 : : {
8795 : 1 : return test_mixed_auth_cipher(
8796 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8797 : : }
8798 : :
8799 : : static int
8800 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8801 : : {
8802 : 1 : return test_mixed_auth_cipher(
8803 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8804 : : }
8805 : :
8806 : : static int
8807 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8808 : : {
8809 : 1 : return test_mixed_auth_cipher(
8810 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8811 : : }
8812 : :
8813 : : static int
8814 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8815 : : {
8816 : 1 : return test_mixed_auth_cipher_sgl(
8817 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8818 : : }
8819 : :
8820 : : static int
8821 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8822 : : {
8823 : 1 : return test_mixed_auth_cipher_sgl(
8824 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8825 : : }
8826 : :
8827 : : static int
8828 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8829 : : {
8830 : 1 : return test_mixed_auth_cipher(
8831 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8832 : : }
8833 : :
8834 : : /** MIXED AUTH + CIPHER */
8835 : :
8836 : : static int
8837 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8838 : : {
8839 : 1 : return test_mixed_auth_cipher(
8840 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8841 : : }
8842 : :
8843 : : static int
8844 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8845 : : {
8846 : 1 : return test_mixed_auth_cipher(
8847 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8848 : : }
8849 : :
8850 : : static int
8851 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8852 : : {
8853 : 1 : return test_mixed_auth_cipher(
8854 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8855 : : }
8856 : :
8857 : : static int
8858 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8859 : : {
8860 : 1 : return test_mixed_auth_cipher(
8861 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8862 : : }
8863 : :
8864 : :
8865 : : static int
8866 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8867 : : {
8868 : 1 : return test_mixed_auth_cipher(
8869 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8870 : : }
8871 : :
8872 : : static int
8873 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8874 : : {
8875 : 1 : return test_mixed_auth_cipher(
8876 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8877 : : }
8878 : :
8879 : : static int
8880 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8881 : : {
8882 : 1 : return test_mixed_auth_cipher(
8883 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8884 : : }
8885 : :
8886 : : static int
8887 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8888 : : {
8889 : 1 : return test_mixed_auth_cipher(
8890 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8891 : : }
8892 : :
8893 : : static int
8894 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8895 : : {
8896 : 1 : return test_mixed_auth_cipher(
8897 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8898 : : }
8899 : :
8900 : : static int
8901 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8902 : : {
8903 : 1 : return test_mixed_auth_cipher(
8904 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8905 : : }
8906 : :
8907 : : static int
8908 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8909 : : {
8910 : 1 : return test_mixed_auth_cipher(
8911 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8912 : : }
8913 : :
8914 : : static int
8915 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8916 : : {
8917 : 1 : return test_mixed_auth_cipher(
8918 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8919 : : }
8920 : :
8921 : : static int
8922 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8923 : : {
8924 : 1 : return test_mixed_auth_cipher(
8925 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8926 : : }
8927 : :
8928 : : static int
8929 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8930 : : {
8931 : 1 : return test_mixed_auth_cipher(
8932 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8933 : : }
8934 : :
8935 : : static int
8936 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8937 : : {
8938 : 1 : return test_mixed_auth_cipher_sgl(
8939 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8940 : : }
8941 : :
8942 : : static int
8943 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8944 : : {
8945 : 1 : return test_mixed_auth_cipher(
8946 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8947 : : }
8948 : :
8949 : : static int
8950 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8951 : : {
8952 : 1 : return test_mixed_auth_cipher_sgl(
8953 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8954 : : }
8955 : :
8956 : : static int
8957 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8958 : : {
8959 : 1 : return test_mixed_auth_cipher(
8960 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8961 : : }
8962 : :
8963 : : static int
8964 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8965 : : {
8966 : 1 : return test_mixed_auth_cipher(
8967 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8968 : : }
8969 : :
8970 : : static int
8971 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8972 : : {
8973 : 1 : return test_mixed_auth_cipher(
8974 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8975 : : }
8976 : :
8977 : : static int
8978 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8979 : : {
8980 : 1 : return test_mixed_auth_cipher(
8981 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8982 : : }
8983 : :
8984 : : static int
8985 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8986 : : {
8987 : 1 : return test_mixed_auth_cipher(
8988 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8989 : : }
8990 : :
8991 : : static int
8992 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8993 : : {
8994 : 1 : return test_mixed_auth_cipher(
8995 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8996 : : }
8997 : :
8998 : : static int
8999 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
9000 : : {
9001 : 1 : return test_mixed_auth_cipher(
9002 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9003 : : }
9004 : : static int
9005 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9006 : : {
9007 : 1 : return test_mixed_auth_cipher(
9008 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
9009 : : }
9010 : :
9011 : : static int
9012 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9013 : : {
9014 : 1 : return test_mixed_auth_cipher(
9015 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
9016 : : }
9017 : :
9018 : : static int
9019 : 1 : test_auth_null_cipher_snow_test_case_1(void)
9020 : : {
9021 : 1 : return test_mixed_auth_cipher(
9022 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
9023 : : }
9024 : :
9025 : : static int
9026 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
9027 : : {
9028 : 1 : return test_mixed_auth_cipher(
9029 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
9030 : : }
9031 : :
9032 : : static int
9033 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
9034 : : {
9035 : 1 : return test_mixed_auth_cipher(
9036 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9037 : : }
9038 : :
9039 : : static int
9040 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
9041 : : {
9042 : 1 : return test_mixed_auth_cipher(
9043 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9044 : : }
9045 : :
9046 : : static int
9047 : 1 : test_auth_snow_cipher_null_test_case_1(void)
9048 : : {
9049 : 1 : return test_mixed_auth_cipher(
9050 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9051 : : }
9052 : :
9053 : : static int
9054 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
9055 : : {
9056 : 1 : return test_mixed_auth_cipher(
9057 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9058 : : }
9059 : :
9060 : : static int
9061 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
9062 : : {
9063 : 1 : return test_mixed_auth_cipher(
9064 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9065 : : }
9066 : :
9067 : : static int
9068 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
9069 : : {
9070 : 1 : return test_mixed_auth_cipher(
9071 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9072 : : }
9073 : :
9074 : : static int
9075 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
9076 : : {
9077 : 1 : return test_mixed_auth_cipher(
9078 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
9079 : : }
9080 : :
9081 : : static int
9082 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
9083 : : {
9084 : 1 : return test_mixed_auth_cipher(
9085 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
9086 : : }
9087 : :
9088 : : static int
9089 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
9090 : : {
9091 : 1 : return test_mixed_auth_cipher(
9092 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9093 : : }
9094 : :
9095 : : static int
9096 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
9097 : : {
9098 : 1 : return test_mixed_auth_cipher(
9099 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9100 : : }
9101 : :
9102 : : /* ***** AEAD algorithm Tests ***** */
9103 : :
9104 : : static int
9105 : 85 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
9106 : : enum rte_crypto_aead_operation op,
9107 : : const uint8_t *key, const uint8_t key_len,
9108 : : const uint16_t aad_len, const uint8_t auth_len,
9109 : : uint8_t iv_len)
9110 : : {
9111 : 85 : uint8_t *aead_key = alloca(key_len);
9112 : :
9113 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9114 : : struct crypto_unittest_params *ut_params = &unittest_params;
9115 : :
9116 : : memcpy(aead_key, key, key_len);
9117 : :
9118 : : /* Setup AEAD Parameters */
9119 : 85 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9120 : 85 : ut_params->aead_xform.next = NULL;
9121 : 85 : ut_params->aead_xform.aead.algo = algo;
9122 : 85 : ut_params->aead_xform.aead.op = op;
9123 : 85 : ut_params->aead_xform.aead.key.data = aead_key;
9124 : 85 : ut_params->aead_xform.aead.key.length = key_len;
9125 : 85 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9126 : 85 : ut_params->aead_xform.aead.iv.length = iv_len;
9127 : 85 : ut_params->aead_xform.aead.digest_length = auth_len;
9128 : 85 : ut_params->aead_xform.aead.aad_length = aad_len;
9129 : :
9130 : 85 : debug_hexdump(stdout, "key:", key, key_len);
9131 : :
9132 : : /* Create Crypto session*/
9133 : 85 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9134 : : &ut_params->aead_xform, ts_params->session_mpool);
9135 [ - + - - ]: 85 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9136 : : return TEST_SKIPPED;
9137 [ - + ]: 85 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9138 : : return 0;
9139 : : }
9140 : :
9141 : : static int
9142 : 2 : create_aead_xform(struct rte_crypto_op *op,
9143 : : enum rte_crypto_aead_algorithm algo,
9144 : : enum rte_crypto_aead_operation aead_op,
9145 : : uint8_t *key, const uint8_t key_len,
9146 : : const uint8_t aad_len, const uint8_t auth_len,
9147 : : uint8_t iv_len)
9148 : : {
9149 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9150 : : "failed to allocate space for crypto transform");
9151 : :
9152 : : struct rte_crypto_sym_op *sym_op = op->sym;
9153 : :
9154 : : /* Setup AEAD Parameters */
9155 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9156 : 2 : sym_op->xform->next = NULL;
9157 : 2 : sym_op->xform->aead.algo = algo;
9158 : 2 : sym_op->xform->aead.op = aead_op;
9159 : 2 : sym_op->xform->aead.key.data = key;
9160 : 2 : sym_op->xform->aead.key.length = key_len;
9161 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
9162 : 2 : sym_op->xform->aead.iv.length = iv_len;
9163 : 2 : sym_op->xform->aead.digest_length = auth_len;
9164 : 2 : sym_op->xform->aead.aad_length = aad_len;
9165 : :
9166 : 2 : debug_hexdump(stdout, "key:", key, key_len);
9167 : :
9168 : : return 0;
9169 : : }
9170 : :
9171 : : static int
9172 : 86 : create_aead_operation(enum rte_crypto_aead_operation op,
9173 : : const struct aead_test_data *tdata)
9174 : : {
9175 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9176 : : struct crypto_unittest_params *ut_params = &unittest_params;
9177 : :
9178 : : uint8_t *plaintext, *ciphertext;
9179 : : unsigned int aad_pad_len, plaintext_pad_len;
9180 : :
9181 : : /* Generate Crypto op data structure */
9182 : 86 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9183 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9184 [ - + ]: 86 : TEST_ASSERT_NOT_NULL(ut_params->op,
9185 : : "Failed to allocate symmetric crypto operation struct");
9186 : :
9187 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9188 : :
9189 : : /* Append aad data */
9190 [ + + ]: 86 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9191 : 18 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9192 : 18 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9193 : : aad_pad_len);
9194 [ - + ]: 18 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9195 : : "no room to append aad");
9196 : :
9197 : 18 : sym_op->aead.aad.phys_addr =
9198 : 18 : rte_pktmbuf_iova(ut_params->ibuf);
9199 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9200 : 18 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9201 : 18 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9202 : 18 : tdata->aad.len);
9203 : :
9204 : : /* Append IV at the end of the crypto operation*/
9205 : 18 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9206 : : uint8_t *, IV_OFFSET);
9207 : :
9208 : : /* Copy IV 1 byte after the IV pointer, according to the API */
9209 [ - + ]: 18 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9210 : 18 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
9211 : 18 : tdata->iv.len);
9212 : : } else {
9213 : 68 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9214 : 68 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9215 : : aad_pad_len);
9216 [ - + ]: 68 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9217 : : "no room to append aad");
9218 : :
9219 : 68 : sym_op->aead.aad.phys_addr =
9220 : 68 : rte_pktmbuf_iova(ut_params->ibuf);
9221 : 68 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9222 : 68 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9223 : 68 : tdata->aad.len);
9224 : :
9225 : : /* Append IV at the end of the crypto operation*/
9226 : 68 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9227 : : uint8_t *, IV_OFFSET);
9228 : :
9229 [ - + ]: 68 : if (tdata->iv.len == 0) {
9230 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9231 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
9232 : : AES_GCM_J0_LENGTH);
9233 : : } else {
9234 [ - + ]: 68 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9235 : 68 : debug_hexdump(stdout, "iv:", iv_ptr,
9236 : 68 : tdata->iv.len);
9237 : : }
9238 : : }
9239 : :
9240 : : /* Append plaintext/ciphertext */
9241 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9242 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9243 : 43 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9244 : : plaintext_pad_len);
9245 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9246 : :
9247 : 43 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9248 : 43 : debug_hexdump(stdout, "plaintext:", plaintext,
9249 : 43 : tdata->plaintext.len);
9250 : :
9251 [ + + ]: 43 : if (ut_params->obuf) {
9252 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
9253 : : ut_params->obuf,
9254 : 1 : plaintext_pad_len + aad_pad_len);
9255 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
9256 : : "no room to append ciphertext");
9257 : :
9258 : 1 : memset(ciphertext + aad_pad_len, 0,
9259 : 1 : tdata->ciphertext.len);
9260 : : }
9261 : : } else {
9262 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9263 : 43 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9264 : : plaintext_pad_len);
9265 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(ciphertext,
9266 : : "no room to append ciphertext");
9267 : :
9268 : 43 : memcpy(ciphertext, tdata->ciphertext.data,
9269 : 43 : tdata->ciphertext.len);
9270 : 43 : debug_hexdump(stdout, "ciphertext:", ciphertext,
9271 : 43 : tdata->ciphertext.len);
9272 : :
9273 [ + + ]: 43 : if (ut_params->obuf) {
9274 : : plaintext = (uint8_t *)rte_pktmbuf_append(
9275 : : ut_params->obuf,
9276 : 1 : plaintext_pad_len + aad_pad_len);
9277 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
9278 : : "no room to append plaintext");
9279 : :
9280 : 1 : memset(plaintext + aad_pad_len, 0,
9281 : 1 : tdata->plaintext.len);
9282 : : }
9283 : : }
9284 : :
9285 : : /* Append digest data */
9286 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9287 : 42 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9288 : 43 : ut_params->obuf ? ut_params->obuf :
9289 : : ut_params->ibuf,
9290 [ + + ]: 43 : tdata->auth_tag.len);
9291 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9292 : : "no room to append digest");
9293 [ + + ]: 43 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9294 [ + + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9295 : : ut_params->obuf ? ut_params->obuf :
9296 : : ut_params->ibuf,
9297 : : plaintext_pad_len +
9298 : : aad_pad_len);
9299 : : } else {
9300 : 86 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9301 : 43 : ut_params->ibuf, tdata->auth_tag.len);
9302 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9303 : : "no room to append digest");
9304 [ - + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9305 : : ut_params->ibuf,
9306 : : plaintext_pad_len + aad_pad_len);
9307 : :
9308 : 43 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9309 [ - + ]: 43 : tdata->auth_tag.len);
9310 : 43 : debug_hexdump(stdout, "digest:",
9311 : 43 : sym_op->aead.digest.data,
9312 : 43 : tdata->auth_tag.len);
9313 : : }
9314 : :
9315 : 86 : sym_op->aead.data.length = tdata->plaintext.len;
9316 : 86 : sym_op->aead.data.offset = aad_pad_len;
9317 : :
9318 : 86 : return 0;
9319 : : }
9320 : :
9321 : : static int
9322 : 42 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9323 : : {
9324 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9325 : : struct crypto_unittest_params *ut_params = &unittest_params;
9326 : :
9327 : : int retval;
9328 : : uint8_t *ciphertext, *auth_tag;
9329 : : uint16_t plaintext_pad_len;
9330 : : uint32_t i;
9331 : : struct rte_cryptodev_info dev_info;
9332 : :
9333 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9334 : 42 : uint64_t feat_flags = dev_info.feature_flags;
9335 : :
9336 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9337 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9338 : : printf("Device doesn't support RAW data-path APIs.\n");
9339 : 0 : return TEST_SKIPPED;
9340 : : }
9341 : :
9342 : : /* Verify the capabilities */
9343 : : struct rte_cryptodev_sym_capability_idx cap_idx;
9344 : : const struct rte_cryptodev_symmetric_capability *capability;
9345 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9346 : 42 : cap_idx.algo.aead = tdata->algo;
9347 : 42 : capability = rte_cryptodev_sym_capability_get(
9348 : 42 : ts_params->valid_devs[0], &cap_idx);
9349 [ + - ]: 42 : if (capability == NULL)
9350 : : return TEST_SKIPPED;
9351 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
9352 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
9353 : 42 : tdata->aad.len, tdata->iv.len))
9354 : : return TEST_SKIPPED;
9355 : :
9356 : : /* Create AEAD session */
9357 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
9358 : 41 : tdata->algo,
9359 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
9360 : 41 : tdata->key.data, tdata->key.len,
9361 : 41 : tdata->aad.len, tdata->auth_tag.len,
9362 : 41 : tdata->iv.len);
9363 [ + - ]: 41 : if (retval != TEST_SUCCESS)
9364 : : return retval;
9365 : :
9366 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
9367 [ - + ]: 2 : if (use_ext_mbuf) {
9368 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9369 : : AEAD_TEXT_MAX_LENGTH,
9370 : : 1 /* nb_segs */,
9371 : : NULL);
9372 : : } else {
9373 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9374 : : }
9375 : : /* Populate full size of add data */
9376 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9377 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9378 : : } else {
9379 [ + + ]: 39 : if (use_ext_mbuf) {
9380 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9381 : : AEAD_TEXT_MAX_LENGTH,
9382 : : 1 /* nb_segs */,
9383 : : NULL);
9384 : : } else {
9385 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9386 : : }
9387 : : }
9388 : :
9389 : : /* clear mbuf payload */
9390 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9391 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
9392 : :
9393 : : /* Create AEAD operation */
9394 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9395 [ + - ]: 41 : if (retval < 0)
9396 : : return retval;
9397 : :
9398 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9399 : :
9400 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
9401 : :
9402 : : /* Process crypto operation */
9403 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9404 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9405 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9406 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9407 : : 0);
9408 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9409 : : return retval;
9410 : : } else
9411 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(
9412 : : process_crypto_request(ts_params->valid_devs[0],
9413 : : ut_params->op), "failed to process sym crypto op");
9414 : :
9415 [ - + ]: 41 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9416 : : "crypto op processing failed");
9417 : :
9418 : 41 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9419 : :
9420 [ - + ]: 41 : if (ut_params->op->sym->m_dst) {
9421 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9422 : : uint8_t *);
9423 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9424 : : uint8_t *, plaintext_pad_len);
9425 : : } else {
9426 : 41 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9427 : : uint8_t *,
9428 : : ut_params->op->sym->cipher.data.offset);
9429 : 41 : auth_tag = ciphertext + plaintext_pad_len;
9430 : : }
9431 : :
9432 : 41 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9433 : 41 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9434 : :
9435 : : /* Validate obuf */
9436 [ + + ]: 44 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9437 : : ciphertext,
9438 : : tdata->ciphertext.data,
9439 : : tdata->ciphertext.len,
9440 : : "Ciphertext data not as expected");
9441 : :
9442 [ + + ]: 41 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9443 : : auth_tag,
9444 : : tdata->auth_tag.data,
9445 : : tdata->auth_tag.len,
9446 : : "Generated auth tag not as expected");
9447 : :
9448 : : return 0;
9449 : :
9450 : : }
9451 : :
9452 : : static int
9453 : : test_authenticated_encryption(const struct aead_test_data *tdata)
9454 : : {
9455 : 41 : return test_authenticated_encryption_helper(tdata, false);
9456 : : }
9457 : :
9458 : : #ifdef RTE_LIB_SECURITY
9459 : : static int
9460 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9461 : : enum rte_security_session_protocol proto)
9462 : : {
9463 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9464 : :
9465 : : const struct rte_security_capability *capabilities;
9466 : : const struct rte_security_capability *capability;
9467 : : uint16_t i = 0;
9468 : :
9469 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9470 : :
9471 : :
9472 : 0 : capabilities = rte_security_capabilities_get(ctx);
9473 : :
9474 [ # # ]: 0 : if (capabilities == NULL)
9475 : : return -ENOTSUP;
9476 : :
9477 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9478 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9479 [ # # ]: 0 : if (capability->action == action &&
9480 [ # # ]: 0 : capability->protocol == proto)
9481 : : return 0;
9482 : : }
9483 : :
9484 : : return -ENOTSUP;
9485 : : }
9486 : :
9487 : : /* Basic algorithm run function for async inplace mode.
9488 : : * Creates a session from input parameters and runs one operation
9489 : : * on input_vec. Checks the output of the crypto operation against
9490 : : * output_vec.
9491 : : */
9492 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9493 : : enum rte_crypto_auth_operation opa,
9494 : : const uint8_t *input_vec, unsigned int input_vec_len,
9495 : : const uint8_t *output_vec,
9496 : : unsigned int output_vec_len,
9497 : : enum rte_crypto_cipher_algorithm cipher_alg,
9498 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9499 : : enum rte_crypto_auth_algorithm auth_alg,
9500 : : const uint8_t *auth_key, uint32_t auth_key_len,
9501 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9502 : : uint8_t packet_direction, uint8_t sn_size,
9503 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9504 : : {
9505 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9506 : : struct crypto_unittest_params *ut_params = &unittest_params;
9507 : : uint8_t *plaintext;
9508 : : int ret = TEST_SUCCESS;
9509 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9510 : : struct rte_cryptodev_info dev_info;
9511 : : uint64_t feat_flags;
9512 : :
9513 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9514 : 0 : feat_flags = dev_info.feature_flags;
9515 : :
9516 : : /* Verify the capabilities */
9517 : : struct rte_security_capability_idx sec_cap_idx;
9518 : :
9519 : 0 : sec_cap_idx.action = ut_params->type;
9520 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9521 : 0 : sec_cap_idx.pdcp.domain = domain;
9522 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9523 : : return TEST_SKIPPED;
9524 : :
9525 : : /* Generate test mbuf data */
9526 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9527 : :
9528 : : /* clear mbuf payload */
9529 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9530 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9531 : :
9532 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9533 : : input_vec_len);
9534 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9535 : :
9536 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9537 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9538 : : printf("Device does not support RAW data-path APIs.\n");
9539 : 0 : return TEST_SKIPPED;
9540 : : }
9541 : : /* Out of place support */
9542 [ # # ]: 0 : if (oop) {
9543 : : /*
9544 : : * For out-of-place we need to alloc another mbuf
9545 : : */
9546 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9547 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9548 : : }
9549 : :
9550 : : /* Setup Cipher Parameters */
9551 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9552 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9553 : 0 : ut_params->cipher_xform.cipher.op = opc;
9554 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9555 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9556 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9557 : : packet_direction ? 4 : 0;
9558 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9559 : :
9560 : : /* Setup HMAC Parameters if ICV header is required */
9561 [ # # ]: 0 : if (auth_alg != 0) {
9562 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9563 : 0 : ut_params->auth_xform.next = NULL;
9564 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9565 : 0 : ut_params->auth_xform.auth.op = opa;
9566 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9567 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9568 : :
9569 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9570 : : } else {
9571 : 0 : ut_params->cipher_xform.next = NULL;
9572 : : }
9573 : :
9574 : 0 : struct rte_security_session_conf sess_conf = {
9575 : 0 : .action_type = ut_params->type,
9576 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9577 : : {.pdcp = {
9578 : : .bearer = bearer,
9579 : : .domain = domain,
9580 : : .pkt_dir = packet_direction,
9581 : : .sn_size = sn_size,
9582 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9583 : : /**
9584 : : * hfn can be set as pdcp_test_hfn[i]
9585 : : * if hfn_ovrd is not set. Here, PDCP
9586 : : * packet direction is just used to
9587 : : * run half of the cases with session
9588 : : * HFN and other half with per packet
9589 : : * HFN.
9590 : : */
9591 : : .hfn_threshold = hfn_threshold,
9592 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9593 : : .sdap_enabled = sdap,
9594 : : } },
9595 : : .crypto_xform = &ut_params->cipher_xform
9596 : : };
9597 : :
9598 : : /* Create security session */
9599 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9600 : : &sess_conf, ts_params->session_mpool);
9601 : :
9602 [ # # ]: 0 : if (!ut_params->sec_session) {
9603 : : printf("TestCase %s()-%d line %d failed %s: ",
9604 : : __func__, i, __LINE__, "Failed to allocate session");
9605 : : ret = TEST_FAILED;
9606 : 0 : goto on_err;
9607 : : }
9608 : :
9609 : : /* Generate crypto op data structure */
9610 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9611 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9612 [ # # ]: 0 : if (!ut_params->op) {
9613 : : printf("TestCase %s()-%d line %d failed %s: ",
9614 : : __func__, i, __LINE__,
9615 : : "Failed to allocate symmetric crypto operation struct");
9616 : : ret = TEST_FAILED;
9617 : 0 : goto on_err;
9618 : : }
9619 : :
9620 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9621 : : uint32_t *, IV_OFFSET);
9622 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9623 : :
9624 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9625 : :
9626 : : /* set crypto operation source mbuf */
9627 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9628 [ # # ]: 0 : if (oop)
9629 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9630 : :
9631 : : /* Process crypto operation */
9632 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9633 : : /* filling lengths */
9634 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9635 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9636 : :
9637 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9638 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9639 : : return ret;
9640 : : } else {
9641 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9642 : : }
9643 [ # # ]: 0 : if (ut_params->op == NULL) {
9644 : : printf("TestCase %s()-%d line %d failed %s: ",
9645 : : __func__, i, __LINE__,
9646 : : "failed to process sym crypto op");
9647 : : ret = TEST_FAILED;
9648 : 0 : goto on_err;
9649 : : }
9650 : :
9651 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9652 : : printf("TestCase %s()-%d line %d failed %s: ",
9653 : : __func__, i, __LINE__, "crypto op processing failed");
9654 : : ret = TEST_FAILED;
9655 : 0 : goto on_err;
9656 : : }
9657 : :
9658 : : /* Validate obuf */
9659 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9660 : : uint8_t *);
9661 [ # # ]: 0 : if (oop) {
9662 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9663 : : uint8_t *);
9664 : : }
9665 : :
9666 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9667 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9668 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9669 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9670 : : ret = TEST_FAILED;
9671 : 0 : goto on_err;
9672 : : }
9673 : :
9674 : 0 : on_err:
9675 : 0 : rte_crypto_op_free(ut_params->op);
9676 : 0 : ut_params->op = NULL;
9677 : :
9678 [ # # ]: 0 : if (ut_params->sec_session)
9679 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9680 : 0 : ut_params->sec_session = NULL;
9681 : :
9682 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9683 : 0 : ut_params->ibuf = NULL;
9684 [ # # ]: 0 : if (oop) {
9685 : 0 : rte_pktmbuf_free(ut_params->obuf);
9686 : 0 : ut_params->obuf = NULL;
9687 : : }
9688 : :
9689 : : return ret;
9690 : : }
9691 : :
9692 : : static int
9693 : 0 : test_pdcp_proto_SGL(int i, int oop,
9694 : : enum rte_crypto_cipher_operation opc,
9695 : : enum rte_crypto_auth_operation opa,
9696 : : uint8_t *input_vec,
9697 : : unsigned int input_vec_len,
9698 : : uint8_t *output_vec,
9699 : : unsigned int output_vec_len,
9700 : : uint32_t fragsz,
9701 : : uint32_t fragsz_oop)
9702 : : {
9703 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9704 : : struct crypto_unittest_params *ut_params = &unittest_params;
9705 : : uint8_t *plaintext;
9706 : : struct rte_mbuf *buf, *buf_oop = NULL;
9707 : : int ret = TEST_SUCCESS;
9708 : : int to_trn = 0;
9709 : : int to_trn_tbl[16];
9710 : : int segs = 1;
9711 : : unsigned int trn_data = 0;
9712 : : struct rte_cryptodev_info dev_info;
9713 : : uint64_t feat_flags;
9714 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9715 : : struct rte_mbuf *temp_mbuf;
9716 : :
9717 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9718 : 0 : feat_flags = dev_info.feature_flags;
9719 : :
9720 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9721 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9722 : : printf("Device does not support RAW data-path APIs.\n");
9723 : 0 : return -ENOTSUP;
9724 : : }
9725 : : /* Verify the capabilities */
9726 : : struct rte_security_capability_idx sec_cap_idx;
9727 : :
9728 : 0 : sec_cap_idx.action = ut_params->type;
9729 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9730 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9731 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9732 : : return TEST_SKIPPED;
9733 : :
9734 : : if (fragsz > input_vec_len)
9735 : : fragsz = input_vec_len;
9736 : :
9737 : 0 : uint16_t plaintext_len = fragsz;
9738 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9739 : :
9740 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9741 : 0 : frag_size_oop = output_vec_len;
9742 : :
9743 : : int ecx = 0;
9744 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9745 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9746 : : return 1;
9747 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9748 : : return 1;
9749 : :
9750 : : /* Out of place support */
9751 [ # # ]: 0 : if (oop) {
9752 : : /*
9753 : : * For out-of-place we need to alloc another mbuf
9754 : : */
9755 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9756 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9757 : 0 : buf_oop = ut_params->obuf;
9758 : : }
9759 : :
9760 : : /* Generate test mbuf data */
9761 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9762 : :
9763 : : /* clear mbuf payload */
9764 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9765 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9766 : :
9767 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9768 : : plaintext_len);
9769 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9770 : : trn_data += plaintext_len;
9771 : :
9772 : 0 : buf = ut_params->ibuf;
9773 : :
9774 : : /*
9775 : : * Loop until no more fragments
9776 : : */
9777 : :
9778 [ # # ]: 0 : while (trn_data < input_vec_len) {
9779 : 0 : ++segs;
9780 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9781 : 0 : (input_vec_len - trn_data) : fragsz;
9782 : :
9783 : 0 : to_trn_tbl[ecx++] = to_trn;
9784 : :
9785 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9786 : : buf = buf->next;
9787 : :
9788 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9789 : : rte_pktmbuf_tailroom(buf));
9790 : :
9791 : : /* OOP */
9792 [ # # ]: 0 : if (oop && !fragsz_oop) {
9793 : 0 : buf_oop->next =
9794 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9795 : : buf_oop = buf_oop->next;
9796 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9797 : : 0, rte_pktmbuf_tailroom(buf_oop));
9798 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9799 : : }
9800 : :
9801 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9802 : : to_trn);
9803 : :
9804 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9805 : 0 : trn_data += to_trn;
9806 : : }
9807 : :
9808 : 0 : ut_params->ibuf->nb_segs = segs;
9809 : :
9810 : : segs = 1;
9811 [ # # ]: 0 : if (fragsz_oop && oop) {
9812 : : to_trn = 0;
9813 : : ecx = 0;
9814 : :
9815 : 0 : trn_data = frag_size_oop;
9816 [ # # ]: 0 : while (trn_data < output_vec_len) {
9817 : 0 : ++segs;
9818 : 0 : to_trn =
9819 : 0 : (output_vec_len - trn_data <
9820 : : frag_size_oop) ?
9821 : 0 : (output_vec_len - trn_data) :
9822 : : frag_size_oop;
9823 : :
9824 : 0 : to_trn_tbl[ecx++] = to_trn;
9825 : :
9826 : 0 : buf_oop->next =
9827 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9828 : : buf_oop = buf_oop->next;
9829 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9830 : : 0, rte_pktmbuf_tailroom(buf_oop));
9831 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9832 : :
9833 : 0 : trn_data += to_trn;
9834 : : }
9835 : 0 : ut_params->obuf->nb_segs = segs;
9836 : : }
9837 : :
9838 : : /* Setup Cipher Parameters */
9839 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9840 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9841 : 0 : ut_params->cipher_xform.cipher.op = opc;
9842 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9843 : 0 : ut_params->cipher_xform.cipher.key.length =
9844 : 0 : pdcp_test_params[i].cipher_key_len;
9845 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9846 : :
9847 : : /* Setup HMAC Parameters if ICV header is required */
9848 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9849 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9850 : 0 : ut_params->auth_xform.next = NULL;
9851 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9852 : 0 : ut_params->auth_xform.auth.op = opa;
9853 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9854 : 0 : ut_params->auth_xform.auth.key.length =
9855 : 0 : pdcp_test_params[i].auth_key_len;
9856 : :
9857 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9858 : : } else {
9859 : 0 : ut_params->cipher_xform.next = NULL;
9860 : : }
9861 : :
9862 : 0 : struct rte_security_session_conf sess_conf = {
9863 : 0 : .action_type = ut_params->type,
9864 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9865 : : {.pdcp = {
9866 : 0 : .bearer = pdcp_test_bearer[i],
9867 : 0 : .domain = pdcp_test_params[i].domain,
9868 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9869 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9870 : 0 : .hfn = pdcp_test_hfn[i],
9871 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9872 : : .hfn_ovrd = 0,
9873 : : } },
9874 : : .crypto_xform = &ut_params->cipher_xform
9875 : : };
9876 : :
9877 : : /* Create security session */
9878 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9879 : : &sess_conf, ts_params->session_mpool);
9880 : :
9881 [ # # ]: 0 : if (!ut_params->sec_session) {
9882 : : printf("TestCase %s()-%d line %d failed %s: ",
9883 : : __func__, i, __LINE__, "Failed to allocate session");
9884 : : ret = TEST_FAILED;
9885 : 0 : goto on_err;
9886 : : }
9887 : :
9888 : : /* Generate crypto op data structure */
9889 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9890 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9891 [ # # ]: 0 : if (!ut_params->op) {
9892 : : printf("TestCase %s()-%d line %d failed %s: ",
9893 : : __func__, i, __LINE__,
9894 : : "Failed to allocate symmetric crypto operation struct");
9895 : : ret = TEST_FAILED;
9896 : 0 : goto on_err;
9897 : : }
9898 : :
9899 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9900 : :
9901 : : /* set crypto operation source mbuf */
9902 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9903 [ # # ]: 0 : if (oop)
9904 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9905 : :
9906 : : /* Process crypto operation */
9907 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9908 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9909 : : /* filling lengths */
9910 [ # # ]: 0 : while (temp_mbuf) {
9911 : 0 : ut_params->op->sym->cipher.data.length
9912 : 0 : += temp_mbuf->pkt_len;
9913 : 0 : ut_params->op->sym->auth.data.length
9914 : 0 : += temp_mbuf->pkt_len;
9915 : 0 : temp_mbuf = temp_mbuf->next;
9916 : : }
9917 : :
9918 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9919 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9920 : : return ret;
9921 : : } else {
9922 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9923 : : ut_params->op);
9924 : : }
9925 [ # # ]: 0 : if (ut_params->op == NULL) {
9926 : : printf("TestCase %s()-%d line %d failed %s: ",
9927 : : __func__, i, __LINE__,
9928 : : "failed to process sym crypto op");
9929 : : ret = TEST_FAILED;
9930 : 0 : goto on_err;
9931 : : }
9932 : :
9933 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9934 : : printf("TestCase %s()-%d line %d failed %s: ",
9935 : : __func__, i, __LINE__, "crypto op processing failed");
9936 : : ret = TEST_FAILED;
9937 : 0 : goto on_err;
9938 : : }
9939 : :
9940 : : /* Validate obuf */
9941 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9942 : : uint8_t *);
9943 [ # # ]: 0 : if (oop) {
9944 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9945 : : uint8_t *);
9946 : : }
9947 [ # # ]: 0 : if (fragsz_oop)
9948 : 0 : fragsz = frag_size_oop;
9949 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9950 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9951 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9952 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9953 : : ret = TEST_FAILED;
9954 : 0 : goto on_err;
9955 : : }
9956 : :
9957 : 0 : buf = ut_params->op->sym->m_src->next;
9958 [ # # ]: 0 : if (oop)
9959 : 0 : buf = ut_params->op->sym->m_dst->next;
9960 : :
9961 : : unsigned int off = fragsz;
9962 : :
9963 : : ecx = 0;
9964 [ # # ]: 0 : while (buf) {
9965 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9966 : : uint8_t *);
9967 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9968 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9969 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9970 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9971 : : to_trn_tbl[ecx]);
9972 : : ret = TEST_FAILED;
9973 : 0 : goto on_err;
9974 : : }
9975 : 0 : off += to_trn_tbl[ecx++];
9976 : 0 : buf = buf->next;
9977 : : }
9978 : 0 : on_err:
9979 : 0 : rte_crypto_op_free(ut_params->op);
9980 : 0 : ut_params->op = NULL;
9981 : :
9982 [ # # ]: 0 : if (ut_params->sec_session)
9983 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9984 : 0 : ut_params->sec_session = NULL;
9985 : :
9986 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9987 : 0 : ut_params->ibuf = NULL;
9988 [ # # ]: 0 : if (oop) {
9989 : 0 : rte_pktmbuf_free(ut_params->obuf);
9990 : 0 : ut_params->obuf = NULL;
9991 : : }
9992 : :
9993 : : return ret;
9994 : : }
9995 : :
9996 : : int
9997 : 0 : test_pdcp_proto_cplane_encap(int i)
9998 : : {
9999 : 0 : return test_pdcp_proto(
10000 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10001 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10002 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10003 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10004 : 0 : pdcp_test_params[i].cipher_key_len,
10005 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10006 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10007 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10008 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10009 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10010 : : }
10011 : :
10012 : : int
10013 : 0 : test_pdcp_proto_uplane_encap(int i)
10014 : : {
10015 : 0 : return test_pdcp_proto(
10016 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10017 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10018 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10019 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10020 : 0 : pdcp_test_params[i].cipher_key_len,
10021 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10022 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10023 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10024 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10025 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10026 : : }
10027 : :
10028 : : int
10029 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
10030 : : {
10031 : 0 : return test_pdcp_proto(
10032 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10033 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10034 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10035 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10036 : 0 : pdcp_test_params[i].cipher_key_len,
10037 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10038 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10039 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10040 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10041 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10042 : : }
10043 : :
10044 : : int
10045 : 0 : test_pdcp_proto_cplane_decap(int i)
10046 : : {
10047 : 0 : return test_pdcp_proto(
10048 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10049 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10050 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10051 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10052 : 0 : pdcp_test_params[i].cipher_key_len,
10053 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10054 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10055 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10056 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10057 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10058 : : }
10059 : :
10060 : : int
10061 : 0 : test_pdcp_proto_uplane_decap(int i)
10062 : : {
10063 : 0 : return test_pdcp_proto(
10064 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10065 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10066 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10067 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10068 : 0 : pdcp_test_params[i].cipher_key_len,
10069 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10070 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10071 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10072 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10073 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10074 : : }
10075 : :
10076 : : int
10077 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
10078 : : {
10079 : 0 : return test_pdcp_proto(
10080 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10081 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10082 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10083 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10084 : 0 : pdcp_test_params[i].cipher_key_len,
10085 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10086 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10087 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10088 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10089 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10090 : : }
10091 : :
10092 : : static int
10093 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
10094 : : {
10095 : : /* i can be used for running any PDCP case
10096 : : * In this case it is uplane 12-bit AES-SNOW DL encap
10097 : : */
10098 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
10099 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
10100 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10101 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10102 : : pdcp_test_data_in[i],
10103 : : pdcp_test_data_in_len[i],
10104 : : pdcp_test_data_out[i],
10105 : 0 : pdcp_test_data_in_len[i]+4,
10106 : : 32, 0);
10107 : : }
10108 : : static int
10109 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
10110 : : {
10111 : : /* i can be used for running any PDCP case
10112 : : * In this case it is uplane 18-bit NULL-NULL DL encap
10113 : : */
10114 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10115 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10116 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10117 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10118 : : pdcp_test_data_in[i],
10119 : : pdcp_test_data_in_len[i],
10120 : : pdcp_test_data_out[i],
10121 : 0 : pdcp_test_data_in_len[i]+4,
10122 : : 32, 128);
10123 : : }
10124 : : static int
10125 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
10126 : : {
10127 : : /* i can be used for running any PDCP case
10128 : : * In this case it is uplane 18-bit AES DL encap
10129 : : */
10130 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10131 : : + DOWNLINK;
10132 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10133 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10134 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10135 : : pdcp_test_data_in[i],
10136 : : pdcp_test_data_in_len[i],
10137 : : pdcp_test_data_out[i],
10138 : : pdcp_test_data_in_len[i],
10139 : : 32, 40);
10140 : : }
10141 : : static int
10142 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
10143 : : {
10144 : : /* i can be used for running any PDCP case
10145 : : * In this case it is cplane 12-bit AES-ZUC DL encap
10146 : : */
10147 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10148 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10149 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10150 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10151 : : pdcp_test_data_in[i],
10152 : : pdcp_test_data_in_len[i],
10153 : : pdcp_test_data_out[i],
10154 : 0 : pdcp_test_data_in_len[i]+4,
10155 : : 128, 32);
10156 : : }
10157 : :
10158 : : static int
10159 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
10160 : : {
10161 : : int i = 0, size = 0;
10162 : : int err, all_err = TEST_SUCCESS;
10163 : : const struct pdcp_sdap_test *cur_test;
10164 : :
10165 : : size = RTE_DIM(list_pdcp_sdap_tests);
10166 : :
10167 [ # # ]: 0 : for (i = 0; i < size; i++) {
10168 : : cur_test = &list_pdcp_sdap_tests[i];
10169 : 0 : err = test_pdcp_proto(
10170 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10171 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10172 : 0 : cur_test->in_len, cur_test->data_out,
10173 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10174 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
10175 : 0 : cur_test->param.cipher_key_len,
10176 : 0 : cur_test->param.auth_alg,
10177 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10178 : 0 : cur_test->bearer, cur_test->param.domain,
10179 : 0 : cur_test->packet_direction, cur_test->sn_size,
10180 : 0 : cur_test->hfn,
10181 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10182 [ # # ]: 0 : if (err) {
10183 : : printf("\t%d) %s: Encapsulation failed\n",
10184 : 0 : cur_test->test_idx,
10185 : 0 : cur_test->param.name);
10186 : : err = TEST_FAILED;
10187 : : } else {
10188 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10189 : 0 : cur_test->param.name);
10190 : : err = TEST_SUCCESS;
10191 : : }
10192 : 0 : all_err += err;
10193 : : }
10194 : :
10195 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10196 : :
10197 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10198 : : }
10199 : :
10200 : : static int
10201 : 0 : test_PDCP_PROTO_short_mac(void)
10202 : : {
10203 : : int i = 0, size = 0;
10204 : : int err, all_err = TEST_SUCCESS;
10205 : : const struct pdcp_short_mac_test *cur_test;
10206 : :
10207 : : size = RTE_DIM(list_pdcp_smac_tests);
10208 : :
10209 [ # # ]: 0 : for (i = 0; i < size; i++) {
10210 : : cur_test = &list_pdcp_smac_tests[i];
10211 : 0 : err = test_pdcp_proto(
10212 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10213 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10214 : 0 : cur_test->in_len, cur_test->data_out,
10215 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10216 : : RTE_CRYPTO_CIPHER_NULL, NULL,
10217 : 0 : 0, cur_test->param.auth_alg,
10218 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10219 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
10220 : : 0, 0, 0);
10221 [ # # ]: 0 : if (err) {
10222 : : printf("\t%d) %s: Short MAC test failed\n",
10223 : 0 : cur_test->test_idx,
10224 : 0 : cur_test->param.name);
10225 : : err = TEST_FAILED;
10226 : : } else {
10227 : : printf("\t%d) %s: Short MAC test PASS\n",
10228 : 0 : cur_test->test_idx,
10229 : 0 : cur_test->param.name);
10230 : 0 : rte_hexdump(stdout, "MAC I",
10231 : 0 : cur_test->data_out + cur_test->in_len + 2,
10232 : : 2);
10233 : : err = TEST_SUCCESS;
10234 : : }
10235 : 0 : all_err += err;
10236 : : }
10237 : :
10238 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10239 : :
10240 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10241 : :
10242 : : }
10243 : :
10244 : : static int
10245 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
10246 : : {
10247 : : int i = 0, size = 0;
10248 : : int err, all_err = TEST_SUCCESS;
10249 : : const struct pdcp_sdap_test *cur_test;
10250 : :
10251 : : size = RTE_DIM(list_pdcp_sdap_tests);
10252 : :
10253 [ # # ]: 0 : for (i = 0; i < size; i++) {
10254 : : cur_test = &list_pdcp_sdap_tests[i];
10255 : 0 : err = test_pdcp_proto(
10256 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10257 : : RTE_CRYPTO_AUTH_OP_VERIFY,
10258 : 0 : cur_test->data_out,
10259 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10260 : 0 : cur_test->data_in, cur_test->in_len,
10261 : 0 : cur_test->param.cipher_alg,
10262 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
10263 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
10264 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
10265 : 0 : cur_test->param.domain, cur_test->packet_direction,
10266 : 0 : cur_test->sn_size, cur_test->hfn,
10267 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10268 [ # # ]: 0 : if (err) {
10269 : : printf("\t%d) %s: Decapsulation failed\n",
10270 : 0 : cur_test->test_idx,
10271 : 0 : cur_test->param.name);
10272 : : err = TEST_FAILED;
10273 : : } else {
10274 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10275 : 0 : cur_test->param.name);
10276 : : err = TEST_SUCCESS;
10277 : : }
10278 : 0 : all_err += err;
10279 : : }
10280 : :
10281 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10282 : :
10283 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10284 : : }
10285 : :
10286 : : static int
10287 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10288 : : struct crypto_unittest_params *ut_params,
10289 : : struct rte_security_ipsec_xform *ipsec_xform,
10290 : : const struct ipsec_test_data *td,
10291 : : const struct ipsec_test_flags *flags,
10292 : : int pkt_num)
10293 : : {
10294 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10295 : : enum rte_security_ipsec_sa_direction dir;
10296 : : int ret;
10297 : :
10298 : 0 : dir = ipsec_xform->direction;
10299 : :
10300 : : /* Generate crypto op data structure */
10301 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10302 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10303 [ # # ]: 0 : if (!ut_params->op) {
10304 : : printf("Could not allocate crypto op");
10305 : 0 : return TEST_FAILED;
10306 : : }
10307 : :
10308 : : /* Attach session to operation */
10309 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10310 : :
10311 : : /* Set crypto operation mbufs */
10312 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10313 : 0 : ut_params->op->sym->m_dst = NULL;
10314 : :
10315 : : /* Copy IV in crypto operation when IV generation is disabled */
10316 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10317 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10318 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10319 : : uint8_t *,
10320 : : IV_OFFSET);
10321 : : int len;
10322 : :
10323 [ # # ]: 0 : if (td->aead)
10324 : 0 : len = td->xform.aead.aead.iv.length;
10325 [ # # ]: 0 : else if (td->aes_gmac)
10326 : 0 : len = td->xform.chain.auth.auth.iv.length;
10327 : : else
10328 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10329 : :
10330 : 0 : memcpy(iv, td->iv.data, len);
10331 : : }
10332 : :
10333 : : /* Process crypto operation */
10334 : 0 : process_crypto_request(dev_id, ut_params->op);
10335 : :
10336 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10337 : :
10338 : 0 : rte_crypto_op_free(ut_params->op);
10339 : 0 : ut_params->op = NULL;
10340 : :
10341 : 0 : return ret;
10342 : : }
10343 : :
10344 : : static int
10345 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10346 : : struct crypto_unittest_params *ut_params,
10347 : : void *ctx)
10348 : : {
10349 : : uint64_t timeout, userdata;
10350 : : struct rte_ether_hdr *hdr;
10351 : : struct rte_mbuf *m;
10352 : : void **sec_sess;
10353 : : int ret;
10354 : :
10355 : : RTE_SET_USED(ts_params);
10356 : :
10357 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10358 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10359 : :
10360 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10361 : 0 : ut_params->ibuf->port = 0;
10362 : :
10363 : 0 : sec_sess = &ut_params->sec_session;
10364 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10365 : :
10366 [ # # ]: 0 : if (ret != 1)
10367 : : return TEST_FAILED;
10368 : :
10369 : 0 : ut_params->ibuf = NULL;
10370 : :
10371 : : /* Add a timeout for 1 s */
10372 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10373 : :
10374 : : do {
10375 : : /* Get packet from port 0, queue 0 */
10376 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10377 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10378 : :
10379 [ # # ]: 0 : if (ret == 0) {
10380 : : printf("Could not receive packets from ethdev\n");
10381 : 0 : return TEST_FAILED;
10382 : : }
10383 : :
10384 [ # # ]: 0 : if (m == NULL) {
10385 : : printf("Received mbuf is NULL\n");
10386 : 0 : return TEST_FAILED;
10387 : : }
10388 : :
10389 : 0 : ut_params->ibuf = m;
10390 : :
10391 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10392 : : printf("Received packet is not Rx security processed\n");
10393 : 0 : return TEST_FAILED;
10394 : : }
10395 : :
10396 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10397 : : printf("Received packet has failed Rx security processing\n");
10398 : 0 : return TEST_FAILED;
10399 : : }
10400 : :
10401 : : /*
10402 : : * 'ut_params' is set as userdata. Verify that the field is returned
10403 : : * correctly.
10404 : : */
10405 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10406 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10407 : : printf("Userdata retrieved not matching expected\n");
10408 : 0 : return TEST_FAILED;
10409 : : }
10410 : :
10411 : : /* Trim L2 header */
10412 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10413 : :
10414 : : return TEST_SUCCESS;
10415 : : }
10416 : :
10417 : : static int
10418 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10419 : : struct ipsec_test_data res_d[],
10420 : : int nb_td,
10421 : : bool silent,
10422 : : const struct ipsec_test_flags *flags)
10423 : : {
10424 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10425 : : 0x0000, 0x001a};
10426 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10427 : : 0xe82c, 0x4887};
10428 : : const struct rte_ipv4_hdr *ipv4 =
10429 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10430 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10431 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10432 : : struct crypto_unittest_params *ut_params = &unittest_params;
10433 : : struct rte_security_capability_idx sec_cap_idx;
10434 : : const struct rte_security_capability *sec_cap;
10435 : : struct rte_security_ipsec_xform ipsec_xform;
10436 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10437 : : enum rte_security_ipsec_sa_direction dir;
10438 : : struct ipsec_test_data *res_d_tmp = NULL;
10439 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10440 : : int salt_len, i, ret = TEST_SUCCESS;
10441 : : void *ctx;
10442 : : uint32_t src, dst;
10443 : : uint32_t verify;
10444 : :
10445 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10446 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10447 : :
10448 : : /* Use first test data to create session */
10449 : :
10450 : : /* Copy IPsec xform */
10451 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10452 : :
10453 : 0 : dir = ipsec_xform.direction;
10454 : 0 : verify = flags->tunnel_hdr_verify;
10455 : :
10456 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10457 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10458 : :
10459 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10460 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10461 : 0 : src += 1;
10462 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10463 : 0 : dst += 1;
10464 : : }
10465 : :
10466 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10467 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10468 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10469 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10470 : : sizeof(src));
10471 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10472 : : sizeof(dst));
10473 : :
10474 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10475 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10476 : :
10477 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10478 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10479 : :
10480 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10481 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10482 : :
10483 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10484 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10485 : : TEST_IPSEC_DSCP_VAL;
10486 : :
10487 : : } else {
10488 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10489 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10490 : :
10491 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10492 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10493 : : TEST_IPSEC_DSCP_VAL;
10494 : :
10495 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10496 : : sizeof(v6_src));
10497 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10498 : : sizeof(v6_dst));
10499 : : }
10500 : : }
10501 : :
10502 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10503 : :
10504 : 0 : sec_cap_idx.action = ut_params->type;
10505 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10506 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10507 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10508 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10509 : :
10510 [ # # ]: 0 : if (flags->udp_encap)
10511 : 0 : ipsec_xform.options.udp_encap = 1;
10512 : :
10513 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10514 [ # # ]: 0 : if (sec_cap == NULL)
10515 : : return TEST_SKIPPED;
10516 : :
10517 : : /* Copy cipher session parameters */
10518 [ # # ]: 0 : if (td[0].aead) {
10519 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10520 : : sizeof(ut_params->aead_xform));
10521 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10522 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10523 : :
10524 : : /* Verify crypto capabilities */
10525 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10526 [ # # ]: 0 : if (!silent)
10527 : 0 : RTE_LOG(INFO, USER1,
10528 : : "Crypto capabilities not supported\n");
10529 : 0 : return TEST_SKIPPED;
10530 : : }
10531 [ # # ]: 0 : } else if (td[0].auth_only) {
10532 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10533 : : sizeof(ut_params->auth_xform));
10534 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10535 : :
10536 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10537 [ # # ]: 0 : if (!silent)
10538 : 0 : RTE_LOG(INFO, USER1,
10539 : : "Auth crypto capabilities not supported\n");
10540 : 0 : return TEST_SKIPPED;
10541 : : }
10542 : : } else {
10543 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10544 : : sizeof(ut_params->cipher_xform));
10545 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10546 : : sizeof(ut_params->auth_xform));
10547 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10548 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10549 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10550 : :
10551 : : /* Verify crypto capabilities */
10552 : :
10553 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10554 [ # # ]: 0 : if (!silent)
10555 : 0 : RTE_LOG(INFO, USER1,
10556 : : "Cipher crypto capabilities not supported\n");
10557 : 0 : return TEST_SKIPPED;
10558 : : }
10559 : :
10560 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10561 [ # # ]: 0 : if (!silent)
10562 : 0 : RTE_LOG(INFO, USER1,
10563 : : "Auth crypto capabilities not supported\n");
10564 : 0 : return TEST_SKIPPED;
10565 : : }
10566 : : }
10567 : :
10568 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10569 : : return TEST_SKIPPED;
10570 : :
10571 : 0 : struct rte_security_session_conf sess_conf = {
10572 : 0 : .action_type = ut_params->type,
10573 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10574 : : };
10575 : :
10576 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac ||
10577 [ # # ]: 0 : (td[0].xform.chain.cipher.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR)) {
10578 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10579 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10580 : : }
10581 : :
10582 [ # # ]: 0 : if (td[0].aead) {
10583 : 0 : sess_conf.ipsec = ipsec_xform;
10584 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10585 [ # # ]: 0 : } else if (td[0].auth_only) {
10586 : 0 : sess_conf.ipsec = ipsec_xform;
10587 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10588 : : } else {
10589 : 0 : sess_conf.ipsec = ipsec_xform;
10590 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10591 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10592 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10593 : : } else {
10594 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10595 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10596 : : }
10597 : : }
10598 : :
10599 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10600 : 0 : sess_conf.userdata = ut_params;
10601 : :
10602 : : /* Create security session */
10603 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10604 : : ts_params->session_mpool);
10605 : :
10606 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10607 : : return TEST_SKIPPED;
10608 : :
10609 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10610 [ # # # # ]: 0 : if (flags->antireplay &&
10611 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10612 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10613 : 0 : ret = rte_security_session_update(ctx,
10614 : : ut_params->sec_session, &sess_conf);
10615 [ # # ]: 0 : if (ret) {
10616 : : printf("Could not update sequence number in "
10617 : : "session\n");
10618 : 0 : return TEST_SKIPPED;
10619 : : }
10620 : : }
10621 : :
10622 : : /* Copy test data before modification */
10623 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10624 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10625 : : ret = TEST_FAILED;
10626 : 0 : goto mbuf_free;
10627 : : }
10628 : :
10629 : : /* Setup source mbuf payload */
10630 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10631 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10632 : 0 : td[i].input_text.len, nb_segs, input_text);
10633 : : } else {
10634 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10635 : 0 : td[i].input_text.len, nb_segs, 0);
10636 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10637 : : }
10638 : :
10639 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10640 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10641 : : ctx);
10642 : : else
10643 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10644 : : ut_params,
10645 : : &ipsec_xform,
10646 : : &td[i], flags,
10647 : : i + 1);
10648 : :
10649 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10650 : 0 : goto mbuf_free;
10651 : :
10652 [ # # ]: 0 : if (res_d != NULL)
10653 : 0 : res_d_tmp = &res_d[i];
10654 : :
10655 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10656 : : res_d_tmp, silent, flags);
10657 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10658 : 0 : goto mbuf_free;
10659 : :
10660 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10661 : : flags, dir);
10662 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10663 : 0 : goto mbuf_free;
10664 : :
10665 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10666 : 0 : ut_params->ibuf = NULL;
10667 : : }
10668 : :
10669 : 0 : mbuf_free:
10670 [ # # ]: 0 : if (flags->use_ext_mbuf)
10671 : 0 : ext_mbuf_memzone_free(nb_segs);
10672 : :
10673 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10674 : 0 : ut_params->ibuf = NULL;
10675 : :
10676 [ # # ]: 0 : if (ut_params->sec_session)
10677 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10678 : 0 : ut_params->sec_session = NULL;
10679 : :
10680 : 0 : return ret;
10681 : : }
10682 : :
10683 : : static int
10684 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10685 : : {
10686 : : struct ipsec_test_data td_outb;
10687 : : struct ipsec_test_flags flags;
10688 : :
10689 : : memset(&flags, 0, sizeof(flags));
10690 : :
10691 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10692 : :
10693 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10694 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10695 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10696 : : /* Disable IV gen to be able to test with known vectors */
10697 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10698 : : }
10699 : :
10700 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10701 : : }
10702 : :
10703 : : static int
10704 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10705 : : {
10706 : : struct ipsec_test_data td_outb;
10707 : : struct ipsec_test_flags flags;
10708 : :
10709 : : memset(&flags, 0, sizeof(flags));
10710 [ # # ]: 0 : flags.use_ext_mbuf = true;
10711 : :
10712 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10713 : :
10714 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10715 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10716 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10717 : : /* Disable IV gen to be able to test with known vectors */
10718 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10719 : : }
10720 : :
10721 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10722 : : }
10723 : :
10724 : : static int
10725 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10726 : : {
10727 : : const struct ipsec_test_data *td = test_data;
10728 : : struct ipsec_test_flags flags;
10729 : : struct ipsec_test_data td_inb;
10730 : :
10731 : : memset(&flags, 0, sizeof(flags));
10732 : :
10733 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10734 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10735 : : else
10736 : : memcpy(&td_inb, td, sizeof(td_inb));
10737 : :
10738 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10739 : : }
10740 : :
10741 : : static int
10742 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10743 : : {
10744 : : struct ipsec_test_data td_outb;
10745 : : struct ipsec_test_flags flags;
10746 : :
10747 : : memset(&flags, 0, sizeof(flags));
10748 : 0 : flags.fragment = true;
10749 : :
10750 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10751 : :
10752 : : /* Disable IV gen to be able to test with known vectors */
10753 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10754 : :
10755 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10756 : : }
10757 : :
10758 : : static int
10759 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10760 : : {
10761 : : const struct ipsec_test_data *td = test_data;
10762 : : struct ipsec_test_flags flags;
10763 : : struct ipsec_test_data td_inb;
10764 : :
10765 : : memset(&flags, 0, sizeof(flags));
10766 : 0 : flags.rx_inject = true;
10767 : :
10768 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10769 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10770 : : else
10771 : : memcpy(&td_inb, td, sizeof(td_inb));
10772 : :
10773 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10774 : : }
10775 : :
10776 : : static int
10777 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10778 : : {
10779 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10780 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10781 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10782 : : int ret;
10783 : :
10784 [ # # ]: 0 : if (flags->iv_gen ||
10785 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10786 : : flags->sa_expiry_pkts_hard)
10787 : : nb_pkts = TEST_SEC_PKTS_MAX;
10788 : :
10789 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10790 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10791 : : sec_alg_list[i].param2,
10792 : : flags,
10793 : : td_outb,
10794 : : nb_pkts);
10795 : :
10796 [ # # ]: 0 : if (!td_outb->aead) {
10797 : : enum rte_crypto_cipher_algorithm cipher_alg;
10798 : : enum rte_crypto_auth_algorithm auth_alg;
10799 : :
10800 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10801 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10802 : :
10803 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10804 : 0 : continue;
10805 : :
10806 : : /* ICV is not applicable for NULL auth */
10807 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10808 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10809 : 0 : continue;
10810 : :
10811 : : /* IV is not applicable for NULL cipher */
10812 [ # # # # ]: 0 : if (flags->iv_gen &&
10813 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10814 : 0 : continue;
10815 : : }
10816 : :
10817 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10818 : : flags);
10819 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10820 : 0 : continue;
10821 : :
10822 [ # # ]: 0 : if (ret == TEST_FAILED)
10823 : : return TEST_FAILED;
10824 : :
10825 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10826 : :
10827 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10828 : : flags);
10829 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10830 : 0 : continue;
10831 : :
10832 [ # # ]: 0 : if (ret == TEST_FAILED)
10833 : : return TEST_FAILED;
10834 : :
10835 [ # # ]: 0 : if (flags->display_alg)
10836 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10837 : :
10838 : 0 : pass_cnt++;
10839 : : }
10840 : :
10841 [ # # ]: 0 : if (pass_cnt > 0)
10842 : : return TEST_SUCCESS;
10843 : : else
10844 : 0 : return TEST_SKIPPED;
10845 : : }
10846 : :
10847 : : static int
10848 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10849 : : {
10850 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10851 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10852 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10853 : : int ret;
10854 : :
10855 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10856 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10857 : : sec_auth_only_alg_list[i].param2,
10858 : : flags,
10859 : : td_outb,
10860 : : nb_pkts);
10861 : :
10862 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10863 : : flags);
10864 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10865 : 0 : continue;
10866 : :
10867 [ # # ]: 0 : if (ret == TEST_FAILED)
10868 : : return TEST_FAILED;
10869 : :
10870 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10871 : :
10872 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10873 : : flags);
10874 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10875 : 0 : continue;
10876 : :
10877 [ # # ]: 0 : if (ret == TEST_FAILED)
10878 : : return TEST_FAILED;
10879 : :
10880 [ # # ]: 0 : if (flags->display_alg)
10881 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10882 : : sec_auth_only_alg_list[i].param2);
10883 : :
10884 : 0 : pass_cnt++;
10885 : : }
10886 : :
10887 [ # # ]: 0 : if (pass_cnt > 0)
10888 : : return TEST_SUCCESS;
10889 : : else
10890 : 0 : return TEST_SKIPPED;
10891 : : }
10892 : :
10893 : : static int
10894 : 0 : test_ipsec_proto_display_list(void)
10895 : : {
10896 : : struct ipsec_test_flags flags;
10897 : :
10898 : : memset(&flags, 0, sizeof(flags));
10899 : :
10900 : 0 : flags.display_alg = true;
10901 : :
10902 : 0 : return test_ipsec_proto_all(&flags);
10903 : : }
10904 : :
10905 : : static int
10906 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10907 : : {
10908 : : struct ipsec_test_flags flags;
10909 : :
10910 : : memset(&flags, 0, sizeof(flags));
10911 : :
10912 : 0 : flags.ah = true;
10913 : 0 : flags.display_alg = true;
10914 : :
10915 : 0 : return test_ipsec_ah_proto_all(&flags);
10916 : : }
10917 : :
10918 : : static int
10919 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10920 : : {
10921 : : struct ipsec_test_flags flags;
10922 : :
10923 : : memset(&flags, 0, sizeof(flags));
10924 : :
10925 : 0 : flags.ah = true;
10926 : 0 : flags.transport = true;
10927 : :
10928 : 0 : return test_ipsec_ah_proto_all(&flags);
10929 : : }
10930 : :
10931 : : static int
10932 : 0 : test_ipsec_proto_iv_gen(void)
10933 : : {
10934 : : struct ipsec_test_flags flags;
10935 : :
10936 : : memset(&flags, 0, sizeof(flags));
10937 : :
10938 : 0 : flags.iv_gen = true;
10939 : :
10940 : 0 : return test_ipsec_proto_all(&flags);
10941 : : }
10942 : :
10943 : : static int
10944 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10945 : : {
10946 : : struct ipsec_test_flags flags;
10947 : :
10948 : : memset(&flags, 0, sizeof(flags));
10949 : :
10950 : 0 : flags.sa_expiry_pkts_soft = true;
10951 : :
10952 : 0 : return test_ipsec_proto_all(&flags);
10953 : : }
10954 : :
10955 : : static int
10956 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10957 : : {
10958 : : struct ipsec_test_flags flags;
10959 : :
10960 : : memset(&flags, 0, sizeof(flags));
10961 : :
10962 : 0 : flags.sa_expiry_pkts_hard = true;
10963 : :
10964 : 0 : return test_ipsec_proto_all(&flags);
10965 : : }
10966 : :
10967 : : static int
10968 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10969 : : {
10970 : : struct ipsec_test_flags flags;
10971 : :
10972 : : memset(&flags, 0, sizeof(flags));
10973 : :
10974 : 0 : flags.icv_corrupt = true;
10975 : :
10976 : 0 : return test_ipsec_proto_all(&flags);
10977 : : }
10978 : :
10979 : : static int
10980 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10981 : : {
10982 : : struct ipsec_test_flags flags;
10983 : :
10984 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10985 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10986 : : return TEST_SKIPPED;
10987 : :
10988 : : memset(&flags, 0, sizeof(flags));
10989 : :
10990 : 0 : flags.udp_encap = true;
10991 : 0 : flags.udp_encap_custom_ports = true;
10992 : :
10993 : 0 : return test_ipsec_proto_all(&flags);
10994 : : }
10995 : :
10996 : : static int
10997 : 0 : test_ipsec_proto_udp_encap(void)
10998 : : {
10999 : : struct ipsec_test_flags flags;
11000 : :
11001 : : memset(&flags, 0, sizeof(flags));
11002 : :
11003 : 0 : flags.udp_encap = true;
11004 : :
11005 : 0 : return test_ipsec_proto_all(&flags);
11006 : : }
11007 : :
11008 : : static int
11009 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
11010 : : {
11011 : : struct ipsec_test_flags flags;
11012 : :
11013 : : memset(&flags, 0, sizeof(flags));
11014 : :
11015 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
11016 : :
11017 : 0 : return test_ipsec_proto_all(&flags);
11018 : : }
11019 : :
11020 : : static int
11021 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
11022 : : {
11023 : : struct ipsec_test_flags flags;
11024 : :
11025 : : memset(&flags, 0, sizeof(flags));
11026 : :
11027 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
11028 : :
11029 : 0 : return test_ipsec_proto_all(&flags);
11030 : : }
11031 : :
11032 : : static int
11033 : 0 : test_ipsec_proto_udp_ports_verify(void)
11034 : : {
11035 : : struct ipsec_test_flags flags;
11036 : :
11037 : : memset(&flags, 0, sizeof(flags));
11038 : :
11039 : 0 : flags.udp_encap = true;
11040 : 0 : flags.udp_ports_verify = true;
11041 : :
11042 : 0 : return test_ipsec_proto_all(&flags);
11043 : : }
11044 : :
11045 : : static int
11046 : 0 : test_ipsec_proto_inner_ip_csum(void)
11047 : : {
11048 : : struct ipsec_test_flags flags;
11049 : :
11050 : : memset(&flags, 0, sizeof(flags));
11051 : :
11052 : 0 : flags.ip_csum = true;
11053 : :
11054 : 0 : return test_ipsec_proto_all(&flags);
11055 : : }
11056 : :
11057 : : static int
11058 : 0 : test_ipsec_proto_inner_l4_csum(void)
11059 : : {
11060 : : struct ipsec_test_flags flags;
11061 : :
11062 : : memset(&flags, 0, sizeof(flags));
11063 : :
11064 : 0 : flags.l4_csum = true;
11065 : :
11066 : 0 : return test_ipsec_proto_all(&flags);
11067 : : }
11068 : :
11069 : : static int
11070 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
11071 : : {
11072 : : struct ipsec_test_flags flags;
11073 : :
11074 : : memset(&flags, 0, sizeof(flags));
11075 : :
11076 : : flags.ipv6 = false;
11077 : : flags.tunnel_ipv6 = false;
11078 : :
11079 : 0 : return test_ipsec_proto_all(&flags);
11080 : : }
11081 : :
11082 : : static int
11083 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
11084 : : {
11085 : : struct ipsec_test_flags flags;
11086 : :
11087 : : memset(&flags, 0, sizeof(flags));
11088 : :
11089 : 0 : flags.ipv6 = true;
11090 : 0 : flags.tunnel_ipv6 = true;
11091 : :
11092 : 0 : return test_ipsec_proto_all(&flags);
11093 : : }
11094 : :
11095 : : static int
11096 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
11097 : : {
11098 : : struct ipsec_test_flags flags;
11099 : :
11100 : : memset(&flags, 0, sizeof(flags));
11101 : :
11102 : : flags.ipv6 = false;
11103 : 0 : flags.tunnel_ipv6 = true;
11104 : :
11105 : 0 : return test_ipsec_proto_all(&flags);
11106 : : }
11107 : :
11108 : : static int
11109 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
11110 : : {
11111 : : struct ipsec_test_flags flags;
11112 : :
11113 : : memset(&flags, 0, sizeof(flags));
11114 : :
11115 : 0 : flags.ipv6 = true;
11116 : : flags.tunnel_ipv6 = false;
11117 : :
11118 : 0 : return test_ipsec_proto_all(&flags);
11119 : : }
11120 : :
11121 : : static int
11122 : 0 : test_ipsec_proto_transport_v4(void)
11123 : : {
11124 : : struct ipsec_test_flags flags;
11125 : :
11126 : : memset(&flags, 0, sizeof(flags));
11127 : :
11128 : : flags.ipv6 = false;
11129 : 0 : flags.transport = true;
11130 : :
11131 : 0 : return test_ipsec_proto_all(&flags);
11132 : : }
11133 : :
11134 : : static int
11135 : 0 : test_ipsec_proto_transport_l4_csum(void)
11136 : : {
11137 : 0 : struct ipsec_test_flags flags = {
11138 : : .l4_csum = true,
11139 : : .transport = true,
11140 : : };
11141 : :
11142 : 0 : return test_ipsec_proto_all(&flags);
11143 : : }
11144 : :
11145 : : static int
11146 : 0 : test_ipsec_proto_stats(void)
11147 : : {
11148 : : struct ipsec_test_flags flags;
11149 : :
11150 : : memset(&flags, 0, sizeof(flags));
11151 : :
11152 : 0 : flags.stats_success = true;
11153 : :
11154 : 0 : return test_ipsec_proto_all(&flags);
11155 : : }
11156 : :
11157 : : static int
11158 : 0 : test_ipsec_proto_pkt_fragment(void)
11159 : : {
11160 : : struct ipsec_test_flags flags;
11161 : :
11162 : : memset(&flags, 0, sizeof(flags));
11163 : :
11164 : 0 : flags.fragment = true;
11165 : :
11166 : 0 : return test_ipsec_proto_all(&flags);
11167 : :
11168 : : }
11169 : :
11170 : : static int
11171 : 0 : test_ipsec_proto_copy_df_inner_0(void)
11172 : : {
11173 : : struct ipsec_test_flags flags;
11174 : :
11175 : : memset(&flags, 0, sizeof(flags));
11176 : :
11177 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11178 : :
11179 : 0 : return test_ipsec_proto_all(&flags);
11180 : : }
11181 : :
11182 : : static int
11183 : 0 : test_ipsec_proto_copy_df_inner_1(void)
11184 : : {
11185 : : struct ipsec_test_flags flags;
11186 : :
11187 : : memset(&flags, 0, sizeof(flags));
11188 : :
11189 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11190 : :
11191 : 0 : return test_ipsec_proto_all(&flags);
11192 : : }
11193 : :
11194 : : static int
11195 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
11196 : : {
11197 : : struct ipsec_test_flags flags;
11198 : :
11199 : : memset(&flags, 0, sizeof(flags));
11200 : :
11201 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11202 : :
11203 : 0 : return test_ipsec_proto_all(&flags);
11204 : : }
11205 : :
11206 : : static int
11207 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
11208 : : {
11209 : : struct ipsec_test_flags flags;
11210 : :
11211 : : memset(&flags, 0, sizeof(flags));
11212 : :
11213 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11214 : :
11215 : 0 : return test_ipsec_proto_all(&flags);
11216 : : }
11217 : :
11218 : : static int
11219 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11220 : : {
11221 : : struct ipsec_test_flags flags;
11222 : :
11223 : : memset(&flags, 0, sizeof(flags));
11224 : :
11225 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11226 : :
11227 : 0 : return test_ipsec_proto_all(&flags);
11228 : : }
11229 : :
11230 : : static int
11231 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11232 : : {
11233 : : struct ipsec_test_flags flags;
11234 : :
11235 : : memset(&flags, 0, sizeof(flags));
11236 : :
11237 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11238 : :
11239 : 0 : return test_ipsec_proto_all(&flags);
11240 : : }
11241 : :
11242 : : static int
11243 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11244 : : {
11245 : : struct ipsec_test_flags flags;
11246 : :
11247 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11248 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11249 : : return TEST_SKIPPED;
11250 : :
11251 : : memset(&flags, 0, sizeof(flags));
11252 : :
11253 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11254 : :
11255 : 0 : return test_ipsec_proto_all(&flags);
11256 : : }
11257 : :
11258 : : static int
11259 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11260 : : {
11261 : : struct ipsec_test_flags flags;
11262 : :
11263 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11264 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11265 : : return TEST_SKIPPED;
11266 : :
11267 : : memset(&flags, 0, sizeof(flags));
11268 : :
11269 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11270 : :
11271 : 0 : return test_ipsec_proto_all(&flags);
11272 : : }
11273 : :
11274 : : static int
11275 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11276 : : {
11277 : : struct ipsec_test_flags flags;
11278 : :
11279 : : memset(&flags, 0, sizeof(flags));
11280 : :
11281 : 0 : flags.ipv6 = true;
11282 : 0 : flags.tunnel_ipv6 = true;
11283 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11284 : :
11285 : 0 : return test_ipsec_proto_all(&flags);
11286 : : }
11287 : :
11288 : : static int
11289 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11290 : : {
11291 : : struct ipsec_test_flags flags;
11292 : :
11293 : : memset(&flags, 0, sizeof(flags));
11294 : :
11295 : 0 : flags.ipv6 = true;
11296 : 0 : flags.tunnel_ipv6 = true;
11297 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11298 : :
11299 : 0 : return test_ipsec_proto_all(&flags);
11300 : : }
11301 : :
11302 : : static int
11303 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11304 : : {
11305 : : struct ipsec_test_flags flags;
11306 : :
11307 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11308 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11309 : : return TEST_SKIPPED;
11310 : :
11311 : : memset(&flags, 0, sizeof(flags));
11312 : :
11313 : 0 : flags.ipv6 = true;
11314 : 0 : flags.tunnel_ipv6 = true;
11315 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11316 : :
11317 : 0 : return test_ipsec_proto_all(&flags);
11318 : : }
11319 : :
11320 : : static int
11321 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11322 : : {
11323 : : struct ipsec_test_flags flags;
11324 : :
11325 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11326 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11327 : : return TEST_SKIPPED;
11328 : :
11329 : : memset(&flags, 0, sizeof(flags));
11330 : :
11331 : 0 : flags.ipv6 = true;
11332 : 0 : flags.tunnel_ipv6 = true;
11333 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11334 : :
11335 : 0 : return test_ipsec_proto_all(&flags);
11336 : : }
11337 : :
11338 : : static int
11339 : 0 : test_ipsec_proto_sgl(void)
11340 : : {
11341 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11342 : : struct rte_cryptodev_info dev_info;
11343 : :
11344 : 0 : struct ipsec_test_flags flags = {
11345 : : .nb_segs_in_mbuf = 5
11346 : : };
11347 : :
11348 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11349 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11350 : : printf("Device doesn't support in-place scatter-gather. "
11351 : : "Test Skipped.\n");
11352 : 0 : return TEST_SKIPPED;
11353 : : }
11354 : :
11355 : 0 : return test_ipsec_proto_all(&flags);
11356 : : }
11357 : :
11358 : : static int
11359 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11360 : : {
11361 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11362 : : struct rte_cryptodev_info dev_info;
11363 : :
11364 : 0 : struct ipsec_test_flags flags = {
11365 : : .nb_segs_in_mbuf = 5,
11366 : : .use_ext_mbuf = 1
11367 : : };
11368 : :
11369 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11370 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11371 : : printf("Device doesn't support in-place scatter-gather. "
11372 : : "Test Skipped.\n");
11373 : 0 : return TEST_SKIPPED;
11374 : : }
11375 : :
11376 : 0 : return test_ipsec_proto_all(&flags);
11377 : : }
11378 : :
11379 : : static int
11380 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11381 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11382 : : uint64_t winsz)
11383 : : {
11384 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11385 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11386 : : struct ipsec_test_flags flags;
11387 : : uint32_t i = 0, ret = 0;
11388 : :
11389 [ # # ]: 0 : if (nb_pkts == 0)
11390 : : return TEST_FAILED;
11391 : :
11392 : : memset(&flags, 0, sizeof(flags));
11393 : 0 : flags.antireplay = true;
11394 : :
11395 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11396 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11397 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11398 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11399 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11400 : : }
11401 : :
11402 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11403 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11404 : :
11405 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11406 : : &flags);
11407 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11408 : : return ret;
11409 : :
11410 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11411 : :
11412 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11413 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11414 : : /* Set antireplay flag for packets to be dropped */
11415 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11416 : : }
11417 : :
11418 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11419 : : &flags);
11420 : :
11421 : 0 : return ret;
11422 : : }
11423 : :
11424 : : static int
11425 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11426 : : {
11427 : :
11428 : : uint32_t nb_pkts = 5;
11429 : : bool replayed_pkt[5];
11430 : : uint64_t esn[5];
11431 : :
11432 : : /* 1. Advance the TOP of the window to WS * 2 */
11433 : 0 : esn[0] = winsz * 2;
11434 : : /* 2. Test sequence number within the new window(WS + 1) */
11435 : 0 : esn[1] = winsz + 1;
11436 : : /* 3. Test sequence number less than the window BOTTOM */
11437 : 0 : esn[2] = winsz;
11438 : : /* 4. Test sequence number in the middle of the window */
11439 : 0 : esn[3] = winsz + (winsz / 2);
11440 : : /* 5. Test replay of the packet in the middle of the window */
11441 : 0 : esn[4] = winsz + (winsz / 2);
11442 : :
11443 : 0 : replayed_pkt[0] = false;
11444 : 0 : replayed_pkt[1] = false;
11445 : 0 : replayed_pkt[2] = true;
11446 : 0 : replayed_pkt[3] = false;
11447 : 0 : replayed_pkt[4] = true;
11448 : :
11449 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11450 : : false, winsz);
11451 : : }
11452 : :
11453 : : static int
11454 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11455 : : {
11456 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11457 : : }
11458 : :
11459 : : static int
11460 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11461 : : {
11462 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11463 : : }
11464 : :
11465 : : static int
11466 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11467 : : {
11468 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11469 : : }
11470 : :
11471 : : static int
11472 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11473 : : {
11474 : :
11475 : : uint32_t nb_pkts = 7;
11476 : : bool replayed_pkt[7];
11477 : : uint64_t esn[7];
11478 : :
11479 : : /* Set the initial sequence number */
11480 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11481 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11482 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11483 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11484 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11485 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11486 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11487 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11488 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11489 : : /* 5. Test with duplicate sequence number within
11490 : : * new window (1<<32 - 1)
11491 : : */
11492 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11493 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11494 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11495 : :
11496 : 0 : replayed_pkt[0] = false;
11497 : 0 : replayed_pkt[1] = false;
11498 : 0 : replayed_pkt[2] = false;
11499 : 0 : replayed_pkt[3] = false;
11500 : 0 : replayed_pkt[4] = false;
11501 : 0 : replayed_pkt[5] = true;
11502 : 0 : replayed_pkt[6] = true;
11503 : :
11504 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11505 : : true, winsz);
11506 : : }
11507 : :
11508 : : static int
11509 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11510 : : {
11511 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11512 : : }
11513 : :
11514 : : static int
11515 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11516 : : {
11517 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11518 : : }
11519 : :
11520 : : static int
11521 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11522 : : {
11523 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11524 : : }
11525 : :
11526 : : static int
11527 : 0 : test_PDCP_PROTO_all(void)
11528 : : {
11529 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11530 : : struct crypto_unittest_params *ut_params = &unittest_params;
11531 : : struct rte_cryptodev_info dev_info;
11532 : : int status;
11533 : :
11534 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11535 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11536 : :
11537 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11538 : : return TEST_SKIPPED;
11539 : :
11540 : : /* Set action type */
11541 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11542 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11543 : : gbl_action_type;
11544 : :
11545 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11546 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11547 : : return TEST_SKIPPED;
11548 : :
11549 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11550 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11551 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11552 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11553 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11554 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11555 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11556 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11557 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11558 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11559 : 0 : status += test_PDCP_PROTO_short_mac();
11560 : :
11561 [ # # ]: 0 : if (status)
11562 : : return TEST_FAILED;
11563 : : else
11564 : 0 : return TEST_SUCCESS;
11565 : : }
11566 : :
11567 : : static int
11568 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11569 : : {
11570 : 0 : struct ipsec_test_flags flags = {
11571 : : .dec_ttl_or_hop_limit = true
11572 : : };
11573 : :
11574 : 0 : return test_ipsec_proto_all(&flags);
11575 : : }
11576 : :
11577 : : static int
11578 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11579 : : {
11580 : 0 : struct ipsec_test_flags flags = {
11581 : : .ipv6 = true,
11582 : : .dec_ttl_or_hop_limit = true
11583 : : };
11584 : :
11585 : 0 : return test_ipsec_proto_all(&flags);
11586 : : }
11587 : :
11588 : : static int
11589 : 0 : test_docsis_proto_uplink(const void *data)
11590 : : {
11591 : : const struct docsis_test_data *d_td = data;
11592 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11593 : : struct crypto_unittest_params *ut_params = &unittest_params;
11594 : : uint8_t *plaintext = NULL;
11595 : : uint8_t *ciphertext = NULL;
11596 : : uint8_t *iv_ptr;
11597 : : int32_t cipher_len, crc_len;
11598 : : uint32_t crc_data_len;
11599 : : int ret = TEST_SUCCESS;
11600 : :
11601 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11602 : :
11603 : : /* Verify the capabilities */
11604 : : struct rte_security_capability_idx sec_cap_idx;
11605 : : const struct rte_security_capability *sec_cap;
11606 : : const struct rte_cryptodev_capabilities *crypto_cap;
11607 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11608 : : int j = 0;
11609 : :
11610 : : /* Set action type */
11611 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11612 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11613 : : gbl_action_type;
11614 : :
11615 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11616 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11617 : : return TEST_SKIPPED;
11618 : :
11619 : 0 : sec_cap_idx.action = ut_params->type;
11620 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11621 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11622 : :
11623 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11624 [ # # ]: 0 : if (sec_cap == NULL)
11625 : : return TEST_SKIPPED;
11626 : :
11627 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11628 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11629 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11630 : : crypto_cap->sym.xform_type ==
11631 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11632 : : crypto_cap->sym.cipher.algo ==
11633 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11634 : 0 : sym_cap = &crypto_cap->sym;
11635 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11636 : 0 : d_td->key.len,
11637 : 0 : d_td->iv.len) == 0)
11638 : : break;
11639 : : }
11640 : : }
11641 : :
11642 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11643 : : return TEST_SKIPPED;
11644 : :
11645 : : /* Setup source mbuf payload */
11646 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11647 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11648 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11649 : :
11650 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11651 : 0 : d_td->ciphertext.len);
11652 : :
11653 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11654 : :
11655 : : /* Setup cipher session parameters */
11656 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11657 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11658 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11659 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11660 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11661 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11662 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11663 : 0 : ut_params->cipher_xform.next = NULL;
11664 : :
11665 : : /* Setup DOCSIS session parameters */
11666 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11667 : :
11668 : 0 : struct rte_security_session_conf sess_conf = {
11669 : 0 : .action_type = ut_params->type,
11670 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11671 : : .docsis = ut_params->docsis_xform,
11672 : : .crypto_xform = &ut_params->cipher_xform,
11673 : : };
11674 : :
11675 : : /* Create security session */
11676 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11677 : : ts_params->session_mpool);
11678 : :
11679 [ # # ]: 0 : if (!ut_params->sec_session) {
11680 : : printf("Test function %s line %u: failed to allocate session\n",
11681 : : __func__, __LINE__);
11682 : : ret = TEST_FAILED;
11683 : 0 : goto on_err;
11684 : : }
11685 : :
11686 : : /* Generate crypto op data structure */
11687 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11688 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11689 [ # # ]: 0 : if (!ut_params->op) {
11690 : : printf("Test function %s line %u: failed to allocate symmetric "
11691 : : "crypto operation\n", __func__, __LINE__);
11692 : : ret = TEST_FAILED;
11693 : 0 : goto on_err;
11694 : : }
11695 : :
11696 : : /* Setup CRC operation parameters */
11697 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11698 : 0 : (d_td->ciphertext.len -
11699 : 0 : d_td->ciphertext.crc_offset -
11700 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11701 : : 0;
11702 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11703 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11704 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11705 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11706 : :
11707 : : /* Setup cipher operation parameters */
11708 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11709 : 0 : (d_td->ciphertext.len -
11710 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11711 : : 0;
11712 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11713 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11714 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11715 : :
11716 : : /* Setup cipher IV */
11717 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11718 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11719 : :
11720 : : /* Attach session to operation */
11721 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11722 : :
11723 : : /* Set crypto operation mbufs */
11724 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11725 : 0 : ut_params->op->sym->m_dst = NULL;
11726 : :
11727 : : /* Process crypto operation */
11728 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11729 : : NULL) {
11730 : : printf("Test function %s line %u: failed to process security "
11731 : : "crypto op\n", __func__, __LINE__);
11732 : : ret = TEST_FAILED;
11733 : 0 : goto on_err;
11734 : : }
11735 : :
11736 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11737 : : printf("Test function %s line %u: failed to process crypto op\n",
11738 : : __func__, __LINE__);
11739 : : ret = TEST_FAILED;
11740 : 0 : goto on_err;
11741 : : }
11742 : :
11743 : : /* Validate plaintext */
11744 : : plaintext = ciphertext;
11745 : :
11746 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11747 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11748 : : printf("Test function %s line %u: plaintext not as expected\n",
11749 : : __func__, __LINE__);
11750 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11751 : 0 : d_td->plaintext.len);
11752 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11753 : : ret = TEST_FAILED;
11754 : 0 : goto on_err;
11755 : : }
11756 : :
11757 : 0 : on_err:
11758 : 0 : rte_crypto_op_free(ut_params->op);
11759 : 0 : ut_params->op = NULL;
11760 : :
11761 [ # # ]: 0 : if (ut_params->sec_session)
11762 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11763 : 0 : ut_params->sec_session = NULL;
11764 : :
11765 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11766 : 0 : ut_params->ibuf = NULL;
11767 : :
11768 : 0 : return ret;
11769 : : }
11770 : :
11771 : : static int
11772 : 0 : test_docsis_proto_downlink(const void *data)
11773 : : {
11774 : : const struct docsis_test_data *d_td = data;
11775 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11776 : : struct crypto_unittest_params *ut_params = &unittest_params;
11777 : : uint8_t *plaintext = NULL;
11778 : : uint8_t *ciphertext = NULL;
11779 : : uint8_t *iv_ptr;
11780 : : int32_t cipher_len, crc_len;
11781 : : int ret = TEST_SUCCESS;
11782 : :
11783 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11784 : :
11785 : : /* Verify the capabilities */
11786 : : struct rte_security_capability_idx sec_cap_idx;
11787 : : const struct rte_security_capability *sec_cap;
11788 : : const struct rte_cryptodev_capabilities *crypto_cap;
11789 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11790 : : int j = 0;
11791 : :
11792 : : /* Set action type */
11793 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11794 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11795 : : gbl_action_type;
11796 : :
11797 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11798 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11799 : : return TEST_SKIPPED;
11800 : :
11801 : 0 : sec_cap_idx.action = ut_params->type;
11802 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11803 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11804 : :
11805 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11806 [ # # ]: 0 : if (sec_cap == NULL)
11807 : : return TEST_SKIPPED;
11808 : :
11809 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11810 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11811 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11812 : : crypto_cap->sym.xform_type ==
11813 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11814 : : crypto_cap->sym.cipher.algo ==
11815 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11816 : 0 : sym_cap = &crypto_cap->sym;
11817 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11818 : 0 : d_td->key.len,
11819 : 0 : d_td->iv.len) == 0)
11820 : : break;
11821 : : }
11822 : : }
11823 : :
11824 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11825 : : return TEST_SKIPPED;
11826 : :
11827 : : /* Setup source mbuf payload */
11828 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11829 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11830 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11831 : :
11832 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11833 : 0 : d_td->plaintext.len);
11834 : :
11835 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11836 : :
11837 : : /* Setup cipher session parameters */
11838 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11839 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11840 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11841 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11842 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11843 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11844 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11845 : 0 : ut_params->cipher_xform.next = NULL;
11846 : :
11847 : : /* Setup DOCSIS session parameters */
11848 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11849 : :
11850 : 0 : struct rte_security_session_conf sess_conf = {
11851 : 0 : .action_type = ut_params->type,
11852 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11853 : : .docsis = ut_params->docsis_xform,
11854 : : .crypto_xform = &ut_params->cipher_xform,
11855 : : };
11856 : :
11857 : : /* Create security session */
11858 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11859 : : ts_params->session_mpool);
11860 : :
11861 [ # # ]: 0 : if (!ut_params->sec_session) {
11862 : : printf("Test function %s line %u: failed to allocate session\n",
11863 : : __func__, __LINE__);
11864 : : ret = TEST_FAILED;
11865 : 0 : goto on_err;
11866 : : }
11867 : :
11868 : : /* Generate crypto op data structure */
11869 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11870 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11871 [ # # ]: 0 : if (!ut_params->op) {
11872 : : printf("Test function %s line %u: failed to allocate symmetric "
11873 : : "crypto operation\n", __func__, __LINE__);
11874 : : ret = TEST_FAILED;
11875 : 0 : goto on_err;
11876 : : }
11877 : :
11878 : : /* Setup CRC operation parameters */
11879 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11880 : 0 : (d_td->plaintext.len -
11881 : 0 : d_td->plaintext.crc_offset -
11882 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11883 : : 0;
11884 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11885 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11886 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11887 : :
11888 : : /* Setup cipher operation parameters */
11889 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11890 : 0 : (d_td->plaintext.len -
11891 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11892 : : 0;
11893 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11894 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11895 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11896 : :
11897 : : /* Setup cipher IV */
11898 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11899 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11900 : :
11901 : : /* Attach session to operation */
11902 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11903 : :
11904 : : /* Set crypto operation mbufs */
11905 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11906 : 0 : ut_params->op->sym->m_dst = NULL;
11907 : :
11908 : : /* Process crypto operation */
11909 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11910 : : NULL) {
11911 : : printf("Test function %s line %u: failed to process crypto op\n",
11912 : : __func__, __LINE__);
11913 : : ret = TEST_FAILED;
11914 : 0 : goto on_err;
11915 : : }
11916 : :
11917 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11918 : : printf("Test function %s line %u: crypto op processing failed\n",
11919 : : __func__, __LINE__);
11920 : : ret = TEST_FAILED;
11921 : 0 : goto on_err;
11922 : : }
11923 : :
11924 : : /* Validate ciphertext */
11925 : : ciphertext = plaintext;
11926 : :
11927 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11928 : : printf("Test function %s line %u: plaintext not as expected\n",
11929 : : __func__, __LINE__);
11930 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11931 : 0 : d_td->ciphertext.len);
11932 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11933 : : ret = TEST_FAILED;
11934 : 0 : goto on_err;
11935 : : }
11936 : :
11937 : 0 : on_err:
11938 : 0 : rte_crypto_op_free(ut_params->op);
11939 : 0 : ut_params->op = NULL;
11940 : :
11941 [ # # ]: 0 : if (ut_params->sec_session)
11942 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11943 : 0 : ut_params->sec_session = NULL;
11944 : :
11945 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11946 : 0 : ut_params->ibuf = NULL;
11947 : :
11948 : 0 : return ret;
11949 : : }
11950 : :
11951 : : static void
11952 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11953 : : struct rte_security_tls_record_xform *tls_record_xform)
11954 : : {
11955 : : unsigned int imp_nonce_len;
11956 : : uint8_t *imp_nonce;
11957 : :
11958 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11959 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11960 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11961 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11962 : 0 : break;
11963 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11964 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11965 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11966 : 0 : break;
11967 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
11968 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11969 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11970 : 0 : break;
11971 : : default:
11972 : : return;
11973 : : }
11974 : :
11975 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11976 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11977 : : }
11978 : :
11979 : : static int
11980 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
11981 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
11982 : : const struct tls_record_test_flags *flags)
11983 : : {
11984 : 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11985 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11986 : : struct crypto_unittest_params *ut_params = &unittest_params;
11987 : : struct rte_security_tls_record_xform tls_record_xform;
11988 : : struct rte_security_capability_idx sec_cap_idx;
11989 : : const struct rte_security_capability *sec_cap;
11990 : : struct tls_record_test_data *res_d_tmp = NULL;
11991 : : enum rte_security_tls_sess_type sess_type;
11992 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
11993 : : struct rte_security_ctx *ctx;
11994 : : int i, ret = TEST_SUCCESS;
11995 : :
11996 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11997 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11998 : :
11999 : : /* Use first test data to create session */
12000 : :
12001 : : /* Copy TLS record xform */
12002 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
12003 : :
12004 : 0 : sess_type = tls_record_xform.type;
12005 : :
12006 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12007 : :
12008 : 0 : sec_cap_idx.action = ut_params->type;
12009 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
12010 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
12011 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
12012 : :
12013 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
12014 [ # # ]: 0 : if (sec_cap == NULL)
12015 : : return TEST_SKIPPED;
12016 : :
12017 : : /* Copy cipher session parameters */
12018 [ # # ]: 0 : if (td[0].aead) {
12019 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
12020 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
12021 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
12022 : :
12023 : : /* Verify crypto capabilities */
12024 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
12025 [ # # ]: 0 : if (!silent)
12026 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
12027 : 0 : return TEST_SKIPPED;
12028 : : }
12029 : : } else {
12030 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
12031 : : sizeof(ut_params->cipher_xform));
12032 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
12033 : : sizeof(ut_params->auth_xform));
12034 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
12035 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12036 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
12037 : :
12038 : : /* Verify crypto capabilities */
12039 : :
12040 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
12041 [ # # ]: 0 : if (!silent)
12042 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
12043 : 0 : return TEST_SKIPPED;
12044 : : }
12045 : :
12046 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
12047 [ # # ]: 0 : if (!silent)
12048 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
12049 : 0 : return TEST_SKIPPED;
12050 : : }
12051 : : }
12052 : :
12053 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
12054 : : return TEST_SKIPPED;
12055 : :
12056 : 0 : struct rte_security_session_conf sess_conf = {
12057 : 0 : .action_type = ut_params->type,
12058 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
12059 : : };
12060 : :
12061 : : if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
12062 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
12063 : : sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
12064 : :
12065 [ # # ]: 0 : if (td[0].aead)
12066 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
12067 : :
12068 [ # # ]: 0 : if (flags->opt_padding)
12069 : 0 : tls_record_xform.options.extra_padding_enable = 1;
12070 : :
12071 : 0 : sess_conf.tls_record = tls_record_xform;
12072 : :
12073 [ # # ]: 0 : if (td[0].aead) {
12074 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
12075 : : } else {
12076 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
12077 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
12078 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
12079 : : } else {
12080 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
12081 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
12082 : : }
12083 : : }
12084 : :
12085 [ # # ]: 0 : if (ut_params->sec_session == NULL) {
12086 : : /* Create security session */
12087 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
12088 : : ts_params->session_mpool);
12089 : : }
12090 : :
12091 [ # # ]: 0 : if (ut_params->sec_session == NULL)
12092 : : return TEST_SKIPPED;
12093 : :
12094 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
12095 [ # # # # ]: 0 : if (flags->ar_win_size &&
12096 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
12097 : 0 : sess_conf.tls_record.dtls_1_2.seq_no =
12098 : 0 : td[i].tls_record_xform.dtls_1_2.seq_no;
12099 : 0 : ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
12100 [ # # ]: 0 : if (ret) {
12101 : : printf("Could not update sequence number in session\n");
12102 : 0 : return TEST_SKIPPED;
12103 : : }
12104 : : }
12105 : :
12106 : : /* Setup source mbuf payload */
12107 : 0 : ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12108 : 0 : ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
12109 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
12110 [ # # ]: 0 : if (flags->out_of_place)
12111 : 0 : ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12112 : 0 : ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
12113 : : 0);
12114 : : else
12115 : 0 : ut_params->obuf = NULL;
12116 : :
12117 : : /* Generate crypto op data structure */
12118 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12119 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12120 [ # # ]: 0 : if (ut_params->op == NULL) {
12121 : : printf("Could not allocate crypto op");
12122 : : ret = TEST_FAILED;
12123 : 0 : goto crypto_op_free;
12124 : : }
12125 : :
12126 : : /* Attach session to operation */
12127 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
12128 : :
12129 : : /* Set crypto operation mbufs */
12130 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12131 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12132 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
12133 : :
12134 [ # # ]: 0 : if (flags->opt_padding)
12135 : 0 : ut_params->op->aux_flags = flags->opt_padding;
12136 : :
12137 : : /* Copy IV in crypto operation when IV generation is disabled */
12138 [ # # ]: 0 : if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12139 [ # # ]: 0 : (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12140 [ # # ]: 0 : (tls_record_xform.options.iv_gen_disable == 1)) {
12141 : : uint8_t *iv;
12142 : : int len;
12143 : :
12144 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12145 [ # # ]: 0 : if (td[i].aead)
12146 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
12147 : : else
12148 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
12149 : 0 : memcpy(iv, td[i].iv.data, len);
12150 : : }
12151 : :
12152 : : /* Process crypto operation */
12153 : 0 : process_crypto_request(dev_id, ut_params->op);
12154 : :
12155 : 0 : ret = test_tls_record_status_check(ut_params->op, &td[i]);
12156 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12157 : 0 : goto crypto_op_free;
12158 : :
12159 [ # # ]: 0 : if (res_d != NULL)
12160 : 0 : res_d_tmp = &res_d[i];
12161 : :
12162 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12163 [ # # ]: 0 : struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12164 : : ut_params->ibuf;
12165 : :
12166 : 0 : ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12167 : : silent, flags);
12168 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12169 : 0 : goto crypto_op_free;
12170 : : }
12171 : :
12172 : 0 : rte_crypto_op_free(ut_params->op);
12173 : 0 : ut_params->op = NULL;
12174 : :
12175 [ # # ]: 0 : if (flags->out_of_place) {
12176 : 0 : rte_pktmbuf_free(ut_params->obuf);
12177 : 0 : ut_params->obuf = NULL;
12178 : : }
12179 : :
12180 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12181 : 0 : ut_params->ibuf = NULL;
12182 : : }
12183 : :
12184 : 0 : crypto_op_free:
12185 : 0 : rte_crypto_op_free(ut_params->op);
12186 : 0 : ut_params->op = NULL;
12187 : :
12188 [ # # ]: 0 : if (flags->out_of_place) {
12189 : 0 : rte_pktmbuf_free(ut_params->obuf);
12190 : 0 : ut_params->obuf = NULL;
12191 : : }
12192 : :
12193 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12194 : 0 : ut_params->ibuf = NULL;
12195 : :
12196 [ # # # # ]: 0 : if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12197 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
12198 : 0 : ut_params->sec_session = NULL;
12199 : : }
12200 : :
12201 : : RTE_SET_USED(flags);
12202 : :
12203 : : return ret;
12204 : : }
12205 : :
12206 : : static int
12207 : 0 : test_tls_record_proto_known_vec(const void *test_data)
12208 : : {
12209 : : struct tls_record_test_data td_write;
12210 : : struct tls_record_test_flags flags;
12211 : :
12212 : : memset(&flags, 0, sizeof(flags));
12213 : :
12214 : : memcpy(&td_write, test_data, sizeof(td_write));
12215 : :
12216 : : /* Disable IV gen to be able to test with known vectors */
12217 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
12218 : :
12219 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12220 : : }
12221 : :
12222 : : static int
12223 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
12224 : : {
12225 : : const struct tls_record_test_data *td = test_data;
12226 : : struct tls_record_test_flags flags;
12227 : : struct tls_record_test_data td_inb;
12228 : :
12229 : : memset(&flags, 0, sizeof(flags));
12230 : :
12231 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12232 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
12233 : : else
12234 : : memcpy(&td_inb, td, sizeof(td_inb));
12235 : :
12236 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12237 : : }
12238 : :
12239 : : static int
12240 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12241 : : {
12242 : : unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12243 : : struct crypto_unittest_params *ut_params = &unittest_params;
12244 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12245 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12246 : : void *sec_session_outb = NULL;
12247 : : void *sec_session_inb = NULL;
12248 : : int ret;
12249 : :
12250 [ # # # ]: 0 : switch (flags->tls_version) {
12251 : : case RTE_SECURITY_VERSION_TLS_1_2:
12252 : : max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12253 : : break;
12254 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
12255 : : max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12256 : 0 : break;
12257 : : case RTE_SECURITY_VERSION_DTLS_1_2:
12258 : : max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12259 : : break;
12260 : 0 : default:
12261 : : max_payload_len = 0;
12262 : : }
12263 : :
12264 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12265 : : payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12266 [ # # ]: 0 : if (flags->nb_segs_in_mbuf)
12267 : 0 : payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12268 : :
12269 [ # # ]: 0 : if (flags->zero_len)
12270 : : payload_len = 0;
12271 : 0 : again:
12272 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12273 : : flags, td_outb, nb_pkts, payload_len);
12274 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12275 : 0 : continue;
12276 : :
12277 [ # # ]: 0 : if (flags->skip_sess_destroy)
12278 : 0 : ut_params->sec_session = sec_session_outb;
12279 : :
12280 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12281 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12282 : 0 : continue;
12283 : :
12284 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_outb == NULL)
12285 : 0 : sec_session_outb = ut_params->sec_session;
12286 : :
12287 [ # # # # ]: 0 : if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
12288 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12289 : : return TEST_FAILED;
12290 : 0 : goto skip_decrypt;
12291 [ # # ]: 0 : } else if (ret == TEST_FAILED) {
12292 : : return TEST_FAILED;
12293 : : }
12294 : :
12295 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12296 : :
12297 [ # # ]: 0 : if (flags->skip_sess_destroy)
12298 : 0 : ut_params->sec_session = sec_session_inb;
12299 : :
12300 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12301 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12302 : 0 : continue;
12303 : :
12304 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_inb == NULL)
12305 : 0 : sec_session_inb = ut_params->sec_session;
12306 : :
12307 [ # # # # ]: 0 : if (flags->pkt_corruption || flags->padding_corruption) {
12308 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12309 : : return TEST_FAILED;
12310 : : } else {
12311 [ # # ]: 0 : if (ret == TEST_FAILED)
12312 : : return TEST_FAILED;
12313 : : }
12314 : :
12315 : 0 : skip_decrypt:
12316 [ # # # # ]: 0 : if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12317 : 0 : goto again;
12318 : :
12319 [ # # ]: 0 : if (flags->display_alg)
12320 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12321 : :
12322 [ # # ]: 0 : if (flags->skip_sess_destroy) {
12323 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
12324 : : struct rte_security_ctx *ctx;
12325 : :
12326 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12327 [ # # ]: 0 : if (sec_session_inb != NULL) {
12328 : 0 : rte_security_session_destroy(ctx, sec_session_inb);
12329 : : sec_session_inb = NULL;
12330 : : }
12331 [ # # ]: 0 : if (sec_session_outb != NULL) {
12332 : 0 : rte_security_session_destroy(ctx, sec_session_outb);
12333 : : sec_session_outb = NULL;
12334 : : }
12335 : 0 : ut_params->sec_session = NULL;
12336 : : }
12337 : :
12338 : 0 : pass_cnt++;
12339 : : }
12340 : :
12341 [ # # ]: 0 : if (flags->data_walkthrough)
12342 : : printf("\t Min payload size: %d, Max payload size: %d\n",
12343 : : TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
12344 : :
12345 [ # # ]: 0 : if (pass_cnt > 0)
12346 : : return TEST_SUCCESS;
12347 : : else
12348 : 0 : return TEST_SKIPPED;
12349 : : }
12350 : :
12351 : : static int
12352 : 0 : test_tls_1_2_record_proto_data_walkthrough(void)
12353 : : {
12354 : : struct tls_record_test_flags flags;
12355 : :
12356 : : memset(&flags, 0, sizeof(flags));
12357 : :
12358 : 0 : flags.data_walkthrough = true;
12359 : 0 : flags.skip_sess_destroy = true;
12360 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12361 : :
12362 : 0 : return test_tls_record_proto_all(&flags);
12363 : : }
12364 : :
12365 : : static int
12366 : 0 : test_tls_1_2_record_proto_display_list(void)
12367 : : {
12368 : : struct tls_record_test_flags flags;
12369 : :
12370 : : memset(&flags, 0, sizeof(flags));
12371 : :
12372 : 0 : flags.display_alg = true;
12373 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12374 : :
12375 : 0 : return test_tls_record_proto_all(&flags);
12376 : : }
12377 : :
12378 : : static int
12379 : 0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12380 : : {
12381 : 0 : struct tls_record_test_flags flags = {
12382 : : .nb_segs_in_mbuf = 5,
12383 : : .tls_version = tls_version
12384 : : };
12385 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12386 : : struct rte_cryptodev_info dev_info;
12387 : :
12388 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12389 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12390 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12391 : 0 : return TEST_SKIPPED;
12392 : : }
12393 : :
12394 : 0 : return test_tls_record_proto_all(&flags);
12395 : : }
12396 : :
12397 : : static int
12398 : 0 : test_tls_1_2_record_proto_sgl(void)
12399 : : {
12400 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12401 : : }
12402 : :
12403 : : static int
12404 : 0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12405 : : {
12406 : 0 : struct tls_record_test_flags flags = {
12407 : : .nb_segs_in_mbuf = 5,
12408 : : .tls_version = tls_version,
12409 : : .skip_sess_destroy = true,
12410 : : .data_walkthrough = true
12411 : : };
12412 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12413 : : struct rte_cryptodev_info dev_info;
12414 : :
12415 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12416 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12417 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12418 : 0 : return TEST_SKIPPED;
12419 : : }
12420 : :
12421 : 0 : return test_tls_record_proto_all(&flags);
12422 : : }
12423 : :
12424 : : static int
12425 : 0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12426 : : {
12427 : 0 : struct tls_record_test_flags flags = {
12428 : : .nb_segs_in_mbuf = 5,
12429 : : .out_of_place = true,
12430 : : .tls_version = tls_version
12431 : : };
12432 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12433 : : struct rte_cryptodev_info dev_info;
12434 : :
12435 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12436 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12437 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12438 : 0 : return TEST_SKIPPED;
12439 : : }
12440 : :
12441 : 0 : return test_tls_record_proto_all(&flags);
12442 : : }
12443 : :
12444 : : static int
12445 : 0 : test_tls_1_2_record_proto_sgl_oop(void)
12446 : : {
12447 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12448 : : }
12449 : :
12450 : : static int
12451 : 0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12452 : : {
12453 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12454 : : }
12455 : :
12456 : : static int
12457 : 0 : test_tls_record_proto_corrupt_pkt(void)
12458 : : {
12459 : 0 : struct tls_record_test_flags flags = {
12460 : : .pkt_corruption = 1
12461 : : };
12462 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12463 : : struct rte_cryptodev_info dev_info;
12464 : :
12465 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12466 : :
12467 : 0 : return test_tls_record_proto_all(&flags);
12468 : : }
12469 : :
12470 : : static int
12471 : 0 : test_tls_record_proto_custom_content_type(void)
12472 : : {
12473 : 0 : struct tls_record_test_flags flags = {
12474 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12475 : : };
12476 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12477 : : struct rte_cryptodev_info dev_info;
12478 : :
12479 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12480 : :
12481 : 0 : return test_tls_record_proto_all(&flags);
12482 : : }
12483 : :
12484 : : static int
12485 : 0 : test_tls_record_proto_zero_len(void)
12486 : : {
12487 : 0 : struct tls_record_test_flags flags = {
12488 : : .zero_len = 1
12489 : : };
12490 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12491 : : struct rte_cryptodev_info dev_info;
12492 : :
12493 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12494 : :
12495 : 0 : return test_tls_record_proto_all(&flags);
12496 : : }
12497 : :
12498 : : static int
12499 : 0 : test_tls_record_proto_zero_len_non_app(void)
12500 : : {
12501 : 0 : struct tls_record_test_flags flags = {
12502 : : .zero_len = 1,
12503 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12504 : : };
12505 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12506 : : struct rte_cryptodev_info dev_info;
12507 : :
12508 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12509 : :
12510 : 0 : return test_tls_record_proto_all(&flags);
12511 : : }
12512 : :
12513 : : static int
12514 : 0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12515 : : enum rte_security_tls_version tls_version)
12516 : : {
12517 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12518 : : struct rte_cryptodev_info dev_info;
12519 : 0 : struct tls_record_test_flags flags = {
12520 : : .nb_segs_in_mbuf = num_segs,
12521 : : .tls_version = tls_version,
12522 : : .opt_padding = padding
12523 : : };
12524 : :
12525 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12526 : :
12527 : 0 : return test_tls_record_proto_all(&flags);
12528 : : }
12529 : :
12530 : : static int
12531 : 0 : test_tls_record_proto_dm_opt_padding(void)
12532 : : {
12533 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12534 : : }
12535 : :
12536 : : static int
12537 : 0 : test_tls_record_proto_dm_opt_padding_1(void)
12538 : : {
12539 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12540 : : }
12541 : :
12542 : : static int
12543 : 0 : test_tls_record_proto_sg_opt_padding(void)
12544 : : {
12545 : 0 : return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12546 : : }
12547 : :
12548 : : static int
12549 : 0 : test_tls_record_proto_sg_opt_padding_1(void)
12550 : : {
12551 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12552 : : }
12553 : :
12554 : : static int
12555 : 0 : test_tls_record_proto_sg_opt_padding_2(void)
12556 : : {
12557 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12558 : : }
12559 : :
12560 : : static int
12561 : 0 : test_tls_record_proto_sg_opt_padding_max(void)
12562 : : {
12563 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12564 : : }
12565 : :
12566 : : static int
12567 : 0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
12568 : : {
12569 : 0 : struct tls_record_test_flags flags = {
12570 : : .opt_padding = 8,
12571 : : .padding_corruption = true,
12572 : : .nb_segs_in_mbuf = 4,
12573 : : };
12574 : :
12575 : 0 : return test_tls_record_proto_all(&flags);
12576 : : }
12577 : :
12578 : : static int
12579 : 0 : test_dtls_1_2_record_proto_data_walkthrough(void)
12580 : : {
12581 : : struct tls_record_test_flags flags;
12582 : :
12583 : : memset(&flags, 0, sizeof(flags));
12584 : :
12585 : 0 : flags.data_walkthrough = true;
12586 : 0 : flags.skip_sess_destroy = true;
12587 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12588 : :
12589 : 0 : return test_tls_record_proto_all(&flags);
12590 : : }
12591 : :
12592 : : static int
12593 : 0 : test_dtls_1_2_record_proto_display_list(void)
12594 : : {
12595 : : struct tls_record_test_flags flags;
12596 : :
12597 : : memset(&flags, 0, sizeof(flags));
12598 : :
12599 : 0 : flags.display_alg = true;
12600 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12601 : :
12602 : 0 : return test_tls_record_proto_all(&flags);
12603 : : }
12604 : :
12605 : : static int
12606 : 0 : test_dtls_pkt_replay(const uint64_t seq_no[],
12607 : : bool replayed_pkt[], uint32_t nb_pkts,
12608 : : struct tls_record_test_flags *flags)
12609 : : {
12610 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12611 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12612 : : unsigned int i, idx, pass_cnt = 0;
12613 : : int ret;
12614 : :
12615 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12616 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12617 : : flags, td_outb, nb_pkts, 0);
12618 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12619 : 0 : continue;
12620 : :
12621 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++)
12622 : 0 : td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12623 : :
12624 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12625 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12626 : 0 : continue;
12627 : :
12628 [ # # ]: 0 : if (ret == TEST_FAILED)
12629 : : return TEST_FAILED;
12630 : :
12631 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12632 : :
12633 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
12634 : 0 : td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12635 : : /* Set antireplay flag for packets to be dropped */
12636 : 0 : td_inb[idx].ar_packet = replayed_pkt[idx];
12637 : : }
12638 : :
12639 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12640 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12641 : 0 : continue;
12642 : :
12643 [ # # ]: 0 : if (ret == TEST_FAILED)
12644 : : return TEST_FAILED;
12645 : :
12646 [ # # ]: 0 : if (flags->display_alg)
12647 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12648 : :
12649 : 0 : pass_cnt++;
12650 : : }
12651 : :
12652 [ # # ]: 0 : if (pass_cnt > 0)
12653 : : return TEST_SUCCESS;
12654 : : else
12655 : 0 : return TEST_SKIPPED;
12656 : : }
12657 : :
12658 : : static int
12659 : 0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12660 : : {
12661 : : struct tls_record_test_flags flags;
12662 : : uint32_t nb_pkts = 5;
12663 : : bool replayed_pkt[5];
12664 : : uint64_t seq_no[5];
12665 : :
12666 : : memset(&flags, 0, sizeof(flags));
12667 : :
12668 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12669 : 0 : flags.ar_win_size = winsz;
12670 : :
12671 : : /* 1. Advance the TOP of the window to WS * 2 */
12672 : 0 : seq_no[0] = winsz * 2;
12673 : : /* 2. Test sequence number within the new window(WS + 1) */
12674 : 0 : seq_no[1] = winsz + 1;
12675 : : /* 3. Test sequence number less than the window BOTTOM */
12676 : 0 : seq_no[2] = winsz;
12677 : : /* 4. Test sequence number in the middle of the window */
12678 : 0 : seq_no[3] = winsz + (winsz / 2);
12679 : : /* 5. Test replay of the packet in the middle of the window */
12680 : 0 : seq_no[4] = winsz + (winsz / 2);
12681 : :
12682 : 0 : replayed_pkt[0] = false;
12683 : 0 : replayed_pkt[1] = false;
12684 : 0 : replayed_pkt[2] = true;
12685 : 0 : replayed_pkt[3] = false;
12686 : 0 : replayed_pkt[4] = true;
12687 : :
12688 : 0 : return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12689 : : }
12690 : :
12691 : : static int
12692 : 0 : test_dtls_1_2_record_proto_antireplay64(void)
12693 : : {
12694 : 0 : return test_dtls_1_2_record_proto_antireplay(64);
12695 : : }
12696 : :
12697 : : static int
12698 : 0 : test_dtls_1_2_record_proto_antireplay128(void)
12699 : : {
12700 : 0 : return test_dtls_1_2_record_proto_antireplay(128);
12701 : : }
12702 : :
12703 : : static int
12704 : 0 : test_dtls_1_2_record_proto_antireplay256(void)
12705 : : {
12706 : 0 : return test_dtls_1_2_record_proto_antireplay(256);
12707 : : }
12708 : :
12709 : : static int
12710 : 0 : test_dtls_1_2_record_proto_antireplay512(void)
12711 : : {
12712 : 0 : return test_dtls_1_2_record_proto_antireplay(512);
12713 : : }
12714 : :
12715 : : static int
12716 : 0 : test_dtls_1_2_record_proto_antireplay1024(void)
12717 : : {
12718 : 0 : return test_dtls_1_2_record_proto_antireplay(1024);
12719 : : }
12720 : :
12721 : : static int
12722 : 0 : test_dtls_1_2_record_proto_antireplay2048(void)
12723 : : {
12724 : 0 : return test_dtls_1_2_record_proto_antireplay(2048);
12725 : : }
12726 : :
12727 : : static int
12728 : 0 : test_dtls_1_2_record_proto_antireplay4096(void)
12729 : : {
12730 : 0 : return test_dtls_1_2_record_proto_antireplay(4096);
12731 : : }
12732 : :
12733 : : static int
12734 : 0 : test_dtls_1_2_record_proto_sgl(void)
12735 : : {
12736 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12737 : : }
12738 : :
12739 : : static int
12740 : 0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12741 : : {
12742 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12743 : : }
12744 : :
12745 : : static int
12746 : 0 : test_dtls_1_2_record_proto_sgl_oop(void)
12747 : : {
12748 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12749 : : }
12750 : :
12751 : : static int
12752 : 0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
12753 : : {
12754 : 0 : struct tls_record_test_flags flags = {
12755 : : .pkt_corruption = 1,
12756 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12757 : : };
12758 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12759 : : struct rte_cryptodev_info dev_info;
12760 : :
12761 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12762 : :
12763 : 0 : return test_tls_record_proto_all(&flags);
12764 : : }
12765 : :
12766 : : static int
12767 : 0 : test_dtls_1_2_record_proto_custom_content_type(void)
12768 : : {
12769 : 0 : struct tls_record_test_flags flags = {
12770 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12771 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12772 : : };
12773 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12774 : : struct rte_cryptodev_info dev_info;
12775 : :
12776 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12777 : :
12778 : 0 : return test_tls_record_proto_all(&flags);
12779 : : }
12780 : :
12781 : : static int
12782 : 0 : test_dtls_1_2_record_proto_zero_len(void)
12783 : : {
12784 : 0 : struct tls_record_test_flags flags = {
12785 : : .zero_len = 1,
12786 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12787 : : };
12788 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12789 : : struct rte_cryptodev_info dev_info;
12790 : :
12791 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12792 : :
12793 : 0 : return test_tls_record_proto_all(&flags);
12794 : : }
12795 : :
12796 : : static int
12797 : 0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
12798 : : {
12799 : 0 : struct tls_record_test_flags flags = {
12800 : : .zero_len = 1,
12801 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12802 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12803 : : };
12804 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12805 : : struct rte_cryptodev_info dev_info;
12806 : :
12807 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12808 : :
12809 : 0 : return test_tls_record_proto_all(&flags);
12810 : : }
12811 : :
12812 : : static int
12813 : 0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
12814 : : {
12815 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12816 : : }
12817 : :
12818 : : static int
12819 : 0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12820 : : {
12821 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12822 : : }
12823 : :
12824 : : static int
12825 : 0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
12826 : : {
12827 : 0 : return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12828 : : }
12829 : :
12830 : : static int
12831 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12832 : : {
12833 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12834 : : }
12835 : :
12836 : : static int
12837 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12838 : : {
12839 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12840 : : }
12841 : :
12842 : : static int
12843 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12844 : : {
12845 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12846 : : }
12847 : :
12848 : : static int
12849 : 0 : test_tls_1_3_record_proto_display_list(void)
12850 : : {
12851 : : struct tls_record_test_flags flags;
12852 : :
12853 : : memset(&flags, 0, sizeof(flags));
12854 : :
12855 : 0 : flags.display_alg = true;
12856 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12857 : :
12858 : 0 : return test_tls_record_proto_all(&flags);
12859 : : }
12860 : :
12861 : : static int
12862 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12863 : : {
12864 : 0 : struct tls_record_test_flags flags = {
12865 : : .opt_padding = 8,
12866 : : .padding_corruption = true,
12867 : : .nb_segs_in_mbuf = 4,
12868 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12869 : : };
12870 : :
12871 : 0 : return test_tls_record_proto_all(&flags);
12872 : : }
12873 : :
12874 : : static int
12875 : 0 : test_tls_1_3_record_proto_corrupt_pkt(void)
12876 : : {
12877 : 0 : struct tls_record_test_flags flags = {
12878 : : .pkt_corruption = 1,
12879 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12880 : : };
12881 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12882 : : struct rte_cryptodev_info dev_info;
12883 : :
12884 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12885 : :
12886 : 0 : return test_tls_record_proto_all(&flags);
12887 : : }
12888 : :
12889 : : static int
12890 : 0 : test_tls_1_3_record_proto_custom_content_type(void)
12891 : : {
12892 : 0 : struct tls_record_test_flags flags = {
12893 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12894 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12895 : : };
12896 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12897 : : struct rte_cryptodev_info dev_info;
12898 : :
12899 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12900 : :
12901 : 0 : return test_tls_record_proto_all(&flags);
12902 : : }
12903 : :
12904 : : static int
12905 : 0 : test_tls_1_3_record_proto_zero_len(void)
12906 : : {
12907 : 0 : struct tls_record_test_flags flags = {
12908 : : .zero_len = 1,
12909 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12910 : : };
12911 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12912 : : struct rte_cryptodev_info dev_info;
12913 : :
12914 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12915 : :
12916 : 0 : return test_tls_record_proto_all(&flags);
12917 : : }
12918 : :
12919 : : static int
12920 : 0 : test_tls_1_3_record_proto_zero_len_non_app(void)
12921 : : {
12922 : 0 : struct tls_record_test_flags flags = {
12923 : : .zero_len = 1,
12924 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12925 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12926 : : };
12927 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12928 : : struct rte_cryptodev_info dev_info;
12929 : :
12930 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12931 : :
12932 : 0 : return test_tls_record_proto_all(&flags);
12933 : : }
12934 : :
12935 : : static int
12936 : 0 : test_tls_1_3_record_proto_dm_opt_padding(void)
12937 : : {
12938 : 0 : return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12939 : : }
12940 : :
12941 : : static int
12942 : 0 : test_tls_1_3_record_proto_sg_opt_padding(void)
12943 : : {
12944 : 0 : return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12945 : : }
12946 : :
12947 : : static int
12948 : 0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
12949 : : {
12950 : 0 : return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12951 : : }
12952 : :
12953 : : static int
12954 : 0 : test_tls_1_3_record_proto_data_walkthrough(void)
12955 : : {
12956 : : struct tls_record_test_flags flags;
12957 : :
12958 : : memset(&flags, 0, sizeof(flags));
12959 : :
12960 : 0 : flags.data_walkthrough = true;
12961 : 0 : flags.skip_sess_destroy = true;
12962 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12963 : :
12964 : 0 : return test_tls_record_proto_all(&flags);
12965 : : }
12966 : :
12967 : : static int
12968 : 0 : test_tls_1_3_record_proto_sgl(void)
12969 : : {
12970 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
12971 : : }
12972 : :
12973 : : static int
12974 : 0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
12975 : : {
12976 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
12977 : : }
12978 : :
12979 : : static int
12980 : 0 : test_tls_1_3_record_proto_sgl_oop(void)
12981 : : {
12982 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
12983 : : }
12984 : :
12985 : : #endif
12986 : :
12987 : : static int
12988 : 1 : test_cryptodev_error_recover_helper_check(void)
12989 : : {
12990 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12991 : : struct rte_cryptodev_info dev_info;
12992 : : uint64_t feat_flags;
12993 : : int ret;
12994 : :
12995 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12996 : 1 : feat_flags = dev_info.feature_flags;
12997 : :
12998 : : /* Skip the test if queue pair reset is not supported */
12999 : 1 : ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
13000 [ - + ]: 1 : if (ret == -ENOTSUP)
13001 : : return TEST_SKIPPED;
13002 : :
13003 [ # # ]: 0 : ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
13004 [ # # ]: 0 : if (ret == -ENOTSUP)
13005 : 0 : return TEST_SKIPPED;
13006 : :
13007 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
13008 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13009 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13010 : 0 : RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
13011 : 0 : return TEST_SKIPPED;
13012 : : }
13013 : :
13014 : : return 0;
13015 : : }
13016 : :
13017 : : static int
13018 : 0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
13019 : : {
13020 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13021 : : struct crypto_unittest_params *ut_params = &unittest_params;
13022 : : const struct blockcipher_test_data *tdata = test_data;
13023 : 0 : uint8_t *cipher_key = alloca(tdata->cipher_key.len);
13024 : : struct rte_crypto_sym_op *sym_op = NULL;
13025 : : struct rte_crypto_op *op = NULL;
13026 : : char *dst;
13027 : :
13028 : 0 : memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
13029 : 0 : ut_params->cipher_xform.next = NULL;
13030 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13031 : 0 : ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
13032 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13033 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
13034 : 0 : ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
13035 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13036 : 0 : ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
13037 : :
13038 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
13039 : : ts_params->session_mpool);
13040 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13041 : : return TEST_SKIPPED;
13042 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13043 : :
13044 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13045 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
13046 : :
13047 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
13048 [ # # ]: 0 : tdata->iv.len);
13049 : : sym_op = ut_params->op->sym;
13050 : 0 : sym_op->cipher.data.offset = tdata->cipher_offset;
13051 : 0 : sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
13052 : :
13053 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13054 : :
13055 [ # # ]: 0 : if (generate_err) {
13056 : 0 : ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
13057 [ # # ]: 0 : if (ut_params->ibuf == NULL)
13058 : : return TEST_FAILED;
13059 : 0 : crypto_err = CRYPTODEV_ERR_TRIGGERED;
13060 : : } else {
13061 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13062 : : }
13063 : :
13064 : : /* clear mbuf payload */
13065 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13066 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
13067 : :
13068 : 0 : dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
13069 : 0 : memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
13070 : :
13071 : 0 : sym_op->m_src = ut_params->ibuf;
13072 : 0 : sym_op->m_dst = NULL;
13073 : :
13074 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
13075 : :
13076 [ # # ]: 0 : if (generate_err) {
13077 : 0 : free(ut_params->ibuf);
13078 : 0 : ut_params->ibuf = NULL;
13079 [ # # ]: 0 : if (op == NULL) {
13080 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13081 : 0 : ut_params->sess = NULL;
13082 : 0 : return TEST_SUCCESS;
13083 : : } else {
13084 : : return TEST_FAILED;
13085 : : }
13086 : : }
13087 : :
13088 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13089 : : "crypto op processing failed");
13090 : :
13091 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
13092 : : tdata->ciphertext.len - tdata->cipher_offset,
13093 : : "Data not as expected");
13094 : :
13095 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13096 : 0 : ut_params->sess = NULL;
13097 : :
13098 : 0 : return TEST_SUCCESS;
13099 : : }
13100 : :
13101 : : /*
13102 : : * This unit test verifies the recovery of the cryptodev from any fatal error.
13103 : : * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
13104 : : * for every call to helper function.
13105 : : *
13106 : : * When the flag is set to 0, the helper function verifies the test data without generating any
13107 : : * errors, i.e: verifies the default behaviour of the cryptodev.
13108 : : *
13109 : : * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
13110 : : * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
13111 : : * is generated, it waits till the cryptodev is recoverd from the error.
13112 : : *
13113 : : * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
13114 : : * of cryptodev after the recovery.
13115 : : */
13116 : : static int
13117 : 1 : test_cryptodev_verify_error_recover(const void *test_data)
13118 : : {
13119 : : int ret = TEST_FAILED;
13120 : : int i, num_itr = 5;
13121 : :
13122 : 1 : ret = test_cryptodev_error_recover_helper_check();
13123 [ - + ]: 1 : if (ret)
13124 : : return ret;
13125 : :
13126 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
13127 : : RTE_CRYPTODEV_EVENT_ERROR,
13128 : : test_cryptodev_error_cb, NULL),
13129 : : "Failed to register Cryptodev callback");
13130 : :
13131 [ # # ]: 0 : for (i = 0; i < num_itr; i++) {
13132 : : int ticks = 0;
13133 : :
13134 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13135 : : test_data, false);
13136 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13137 : :
13138 : : /* Generate Error */
13139 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13140 : : test_data, true);
13141 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13142 : :
13143 : : /* Wait till cryptodev recovered from error */
13144 [ # # ]: 0 : while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
13145 : : rte_delay_ms(10);
13146 [ # # ]: 0 : if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
13147 : : return TEST_FAILED;
13148 : : }
13149 : : }
13150 [ # # ]: 0 : TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
13151 : :
13152 : : return ret;
13153 : : }
13154 : :
13155 : : static int
13156 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
13157 : : {
13158 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
13159 : : }
13160 : :
13161 : : static int
13162 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
13163 : : {
13164 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
13165 : : }
13166 : :
13167 : : static int
13168 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
13169 : : {
13170 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
13171 : : }
13172 : :
13173 : : static int
13174 : 1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
13175 : : {
13176 : 1 : return test_authenticated_encryption_helper(&gcm_test_case_3, true);
13177 : : }
13178 : :
13179 : : static int
13180 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
13181 : : {
13182 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
13183 : : }
13184 : :
13185 : : static int
13186 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
13187 : : {
13188 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
13189 : : }
13190 : :
13191 : : static int
13192 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
13193 : : {
13194 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
13195 : : }
13196 : :
13197 : : static int
13198 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
13199 : : {
13200 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
13201 : : }
13202 : :
13203 : : static int
13204 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
13205 : : {
13206 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
13207 : : }
13208 : :
13209 : : static int
13210 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
13211 : : {
13212 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
13213 : : }
13214 : :
13215 : : static int
13216 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
13217 : : {
13218 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
13219 : : }
13220 : :
13221 : : static int
13222 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
13223 : : {
13224 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
13225 : : }
13226 : :
13227 : : static int
13228 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
13229 : : {
13230 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
13231 : : }
13232 : :
13233 : : static int
13234 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
13235 : : {
13236 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
13237 : : }
13238 : :
13239 : : static int
13240 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
13241 : : {
13242 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
13243 : : }
13244 : :
13245 : : static int
13246 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
13247 : : {
13248 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
13249 : : }
13250 : :
13251 : : static int
13252 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
13253 : : {
13254 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
13255 : : }
13256 : :
13257 : : static int
13258 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
13259 : : {
13260 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
13261 : : }
13262 : :
13263 : : static int
13264 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
13265 : : {
13266 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
13267 : : }
13268 : :
13269 : : static int
13270 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
13271 : : {
13272 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
13273 : : }
13274 : :
13275 : : static int
13276 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
13277 : : {
13278 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
13279 : : }
13280 : :
13281 : : static int
13282 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
13283 : : {
13284 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
13285 : : }
13286 : :
13287 : : static int
13288 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
13289 : : {
13290 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
13291 : : }
13292 : :
13293 : : static int
13294 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
13295 : : {
13296 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
13297 : : }
13298 : :
13299 : : static int
13300 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
13301 : : {
13302 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
13303 : : }
13304 : :
13305 : : static int
13306 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
13307 : : {
13308 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
13309 : : }
13310 : :
13311 : : static int
13312 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13313 : : {
13314 : : struct aead_test_data tdata;
13315 : : int res;
13316 : :
13317 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13318 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13319 : 1 : tdata.iv.data[0] += 1;
13320 : : res = test_authenticated_encryption(&tdata);
13321 [ + - ]: 1 : if (res == TEST_SKIPPED)
13322 : : return res;
13323 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13324 : : return TEST_SUCCESS;
13325 : : }
13326 : :
13327 : : static int
13328 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13329 : : {
13330 : : struct aead_test_data tdata;
13331 : : int res;
13332 : :
13333 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13334 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13335 : 1 : tdata.plaintext.data[0] += 1;
13336 : : res = test_authenticated_encryption(&tdata);
13337 [ + - ]: 1 : if (res == TEST_SKIPPED)
13338 : : return res;
13339 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13340 : : return TEST_SUCCESS;
13341 : : }
13342 : :
13343 : : static int
13344 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13345 : : {
13346 : : struct aead_test_data tdata;
13347 : : int res;
13348 : :
13349 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13350 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13351 : 1 : tdata.ciphertext.data[0] += 1;
13352 : : res = test_authenticated_encryption(&tdata);
13353 [ + - ]: 1 : if (res == TEST_SKIPPED)
13354 : : return res;
13355 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13356 : : return TEST_SUCCESS;
13357 : : }
13358 : :
13359 : : static int
13360 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13361 : : {
13362 : : struct aead_test_data tdata;
13363 : : int res;
13364 : :
13365 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13366 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13367 : 1 : tdata.aad.len += 1;
13368 : : res = test_authenticated_encryption(&tdata);
13369 [ + - ]: 1 : if (res == TEST_SKIPPED)
13370 : : return res;
13371 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13372 : : return TEST_SUCCESS;
13373 : : }
13374 : :
13375 : : static int
13376 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13377 : : {
13378 : : struct aead_test_data tdata;
13379 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13380 : : int res;
13381 : :
13382 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13383 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13384 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13385 : 1 : aad[0] += 1;
13386 : 1 : tdata.aad.data = aad;
13387 : : res = test_authenticated_encryption(&tdata);
13388 [ + - ]: 1 : if (res == TEST_SKIPPED)
13389 : : return res;
13390 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13391 : : return TEST_SUCCESS;
13392 : : }
13393 : :
13394 : : static int
13395 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13396 : : {
13397 : : struct aead_test_data tdata;
13398 : : int res;
13399 : :
13400 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13401 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13402 : 1 : tdata.auth_tag.data[0] += 1;
13403 : : res = test_authenticated_encryption(&tdata);
13404 [ + - ]: 1 : if (res == TEST_SKIPPED)
13405 : : return res;
13406 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13407 : : return TEST_SUCCESS;
13408 : : }
13409 : :
13410 : : static int
13411 : 42 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13412 : : {
13413 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13414 : : struct crypto_unittest_params *ut_params = &unittest_params;
13415 : :
13416 : : int retval;
13417 : : uint8_t *plaintext;
13418 : : uint32_t i;
13419 : : struct rte_cryptodev_info dev_info;
13420 : :
13421 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13422 : 42 : uint64_t feat_flags = dev_info.feature_flags;
13423 : :
13424 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13425 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13426 : : printf("Device doesn't support RAW data-path APIs.\n");
13427 : 0 : return TEST_SKIPPED;
13428 : : }
13429 : :
13430 : : /* Verify the capabilities */
13431 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13432 : : const struct rte_cryptodev_symmetric_capability *capability;
13433 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13434 : 42 : cap_idx.algo.aead = tdata->algo;
13435 : 42 : capability = rte_cryptodev_sym_capability_get(
13436 : 42 : ts_params->valid_devs[0], &cap_idx);
13437 [ + - ]: 42 : if (capability == NULL)
13438 : : return TEST_SKIPPED;
13439 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
13440 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
13441 : 42 : tdata->aad.len, tdata->iv.len))
13442 : : return TEST_SKIPPED;
13443 : :
13444 : : /* Create AEAD session */
13445 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
13446 : 41 : tdata->algo,
13447 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13448 : 41 : tdata->key.data, tdata->key.len,
13449 : 41 : tdata->aad.len, tdata->auth_tag.len,
13450 : 41 : tdata->iv.len);
13451 [ + - ]: 41 : if (retval != TEST_SUCCESS)
13452 : : return retval;
13453 : :
13454 : : /* alloc mbuf and set payload */
13455 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
13456 [ - + ]: 2 : if (use_ext_mbuf) {
13457 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13458 : : AEAD_TEXT_MAX_LENGTH,
13459 : : 1 /* nb_segs */,
13460 : : NULL);
13461 : : } else {
13462 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13463 : : }
13464 : : /* Populate full size of add data */
13465 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13466 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13467 : : } else {
13468 [ + + ]: 39 : if (use_ext_mbuf) {
13469 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13470 : : AEAD_TEXT_MAX_LENGTH,
13471 : : 1 /* nb_segs */,
13472 : : NULL);
13473 : : } else {
13474 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13475 : : }
13476 : : }
13477 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13478 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
13479 : :
13480 : : /* Create AEAD operation */
13481 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13482 [ + - ]: 41 : if (retval < 0)
13483 : : return retval;
13484 : :
13485 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13486 : :
13487 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
13488 : :
13489 : : /* Process crypto operation */
13490 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13491 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13492 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13493 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13494 : : 0);
13495 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13496 : : return retval;
13497 : : } else
13498 [ + + ]: 41 : TEST_ASSERT_NOT_NULL(
13499 : : process_crypto_request(ts_params->valid_devs[0],
13500 : : ut_params->op), "failed to process sym crypto op");
13501 : :
13502 [ - + ]: 36 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13503 : : "crypto op processing failed");
13504 : :
13505 [ - + ]: 36 : if (ut_params->op->sym->m_dst)
13506 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13507 : : uint8_t *);
13508 : : else
13509 : 36 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13510 : : uint8_t *,
13511 : : ut_params->op->sym->cipher.data.offset);
13512 : :
13513 : 36 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13514 : :
13515 : : /* Validate obuf */
13516 [ + + ]: 37 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13517 : : plaintext,
13518 : : tdata->plaintext.data,
13519 : : tdata->plaintext.len,
13520 : : "Plaintext data not as expected");
13521 : :
13522 [ - + ]: 35 : TEST_ASSERT_EQUAL(ut_params->op->status,
13523 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13524 : : "Authentication failed");
13525 : :
13526 : : return 0;
13527 : : }
13528 : :
13529 : : static int
13530 : : test_authenticated_decryption(const struct aead_test_data *tdata)
13531 : : {
13532 : 41 : return test_authenticated_decryption_helper(tdata, false);
13533 : : }
13534 : :
13535 : : static int
13536 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
13537 : : {
13538 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
13539 : : }
13540 : :
13541 : : static int
13542 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
13543 : : {
13544 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
13545 : : }
13546 : :
13547 : : static int
13548 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
13549 : : {
13550 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
13551 : : }
13552 : :
13553 : : static int
13554 : 1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13555 : : {
13556 : 1 : return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13557 : : }
13558 : :
13559 : : static int
13560 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
13561 : : {
13562 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
13563 : : }
13564 : :
13565 : : static int
13566 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
13567 : : {
13568 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
13569 : : }
13570 : :
13571 : : static int
13572 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
13573 : : {
13574 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
13575 : : }
13576 : :
13577 : : static int
13578 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
13579 : : {
13580 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
13581 : : }
13582 : :
13583 : : static int
13584 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
13585 : : {
13586 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
13587 : : }
13588 : :
13589 : : static int
13590 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13591 : : {
13592 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
13593 : : }
13594 : :
13595 : : static int
13596 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
13597 : : {
13598 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
13599 : : }
13600 : :
13601 : : static int
13602 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
13603 : : {
13604 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
13605 : : }
13606 : :
13607 : : static int
13608 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
13609 : : {
13610 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
13611 : : }
13612 : :
13613 : : static int
13614 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
13615 : : {
13616 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
13617 : : }
13618 : :
13619 : : static int
13620 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
13621 : : {
13622 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
13623 : : }
13624 : :
13625 : : static int
13626 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
13627 : : {
13628 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
13629 : : }
13630 : :
13631 : : static int
13632 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
13633 : : {
13634 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
13635 : : }
13636 : :
13637 : : static int
13638 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
13639 : : {
13640 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
13641 : : }
13642 : :
13643 : : static int
13644 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
13645 : : {
13646 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
13647 : : }
13648 : :
13649 : : static int
13650 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
13651 : : {
13652 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
13653 : : }
13654 : :
13655 : : static int
13656 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
13657 : : {
13658 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
13659 : : }
13660 : :
13661 : : static int
13662 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
13663 : : {
13664 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
13665 : : }
13666 : :
13667 : : static int
13668 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
13669 : : {
13670 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
13671 : : }
13672 : :
13673 : : static int
13674 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
13675 : : {
13676 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
13677 : : }
13678 : :
13679 : : static int
13680 : 1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
13681 : : {
13682 : 1 : return test_authenticated_decryption(&gcm_test_case_256_8);
13683 : : }
13684 : :
13685 : : static int
13686 : 1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
13687 : : {
13688 : 1 : return test_authenticated_encryption(&gcm_test_case_256_8);
13689 : : }
13690 : :
13691 : : static int
13692 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
13693 : : {
13694 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
13695 : : }
13696 : :
13697 : : static int
13698 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
13699 : : {
13700 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
13701 : : }
13702 : :
13703 : : static int
13704 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13705 : : {
13706 : : struct aead_test_data tdata;
13707 : : int res;
13708 : :
13709 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13710 : 1 : tdata.iv.data[0] += 1;
13711 : : res = test_authenticated_decryption(&tdata);
13712 [ + - ]: 1 : if (res == TEST_SKIPPED)
13713 : : return res;
13714 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13715 : : return TEST_SUCCESS;
13716 : : }
13717 : :
13718 : : static int
13719 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13720 : : {
13721 : : struct aead_test_data tdata;
13722 : : int res;
13723 : :
13724 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13725 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13726 : 1 : tdata.plaintext.data[0] += 1;
13727 : : res = test_authenticated_decryption(&tdata);
13728 [ + - ]: 1 : if (res == TEST_SKIPPED)
13729 : : return res;
13730 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13731 : : return TEST_SUCCESS;
13732 : : }
13733 : :
13734 : : static int
13735 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13736 : : {
13737 : : struct aead_test_data tdata;
13738 : : int res;
13739 : :
13740 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13741 : 1 : tdata.ciphertext.data[0] += 1;
13742 : : res = test_authenticated_decryption(&tdata);
13743 [ + - ]: 1 : if (res == TEST_SKIPPED)
13744 : : return res;
13745 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13746 : : return TEST_SUCCESS;
13747 : : }
13748 : :
13749 : : static int
13750 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13751 : : {
13752 : : struct aead_test_data tdata;
13753 : : int res;
13754 : :
13755 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13756 : 1 : tdata.aad.len += 1;
13757 : : res = test_authenticated_decryption(&tdata);
13758 [ + - ]: 1 : if (res == TEST_SKIPPED)
13759 : : return res;
13760 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13761 : : return TEST_SUCCESS;
13762 : : }
13763 : :
13764 : : static int
13765 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13766 : : {
13767 : : struct aead_test_data tdata;
13768 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13769 : : int res;
13770 : :
13771 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13772 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13773 : 1 : aad[0] += 1;
13774 : 1 : tdata.aad.data = aad;
13775 : : res = test_authenticated_decryption(&tdata);
13776 [ + - ]: 1 : if (res == TEST_SKIPPED)
13777 : : return res;
13778 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13779 : : return TEST_SUCCESS;
13780 : : }
13781 : :
13782 : : static int
13783 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13784 : : {
13785 : : struct aead_test_data tdata;
13786 : : int res;
13787 : :
13788 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13789 : 1 : tdata.auth_tag.data[0] += 1;
13790 : : res = test_authenticated_decryption(&tdata);
13791 [ + - ]: 1 : if (res == TEST_SKIPPED)
13792 : : return res;
13793 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13794 : : return TEST_SUCCESS;
13795 : : }
13796 : :
13797 : : static int
13798 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13799 : : {
13800 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13801 : : struct crypto_unittest_params *ut_params = &unittest_params;
13802 : :
13803 : : uint32_t i;
13804 : : int retval;
13805 : : uint8_t *ciphertext, *auth_tag, *buffer_oop;
13806 : : uint16_t plaintext_pad_len;
13807 : : struct rte_cryptodev_info dev_info;
13808 : :
13809 : : /* Verify the capabilities */
13810 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13811 : : const struct rte_cryptodev_symmetric_capability *capability;
13812 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13813 : 1 : cap_idx.algo.aead = tdata->algo;
13814 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13815 [ + - ]: 1 : if (capability == NULL)
13816 : : return TEST_SKIPPED;
13817 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(
13818 : 1 : capability, tdata->key.len, tdata->auth_tag.len,
13819 : 1 : tdata->aad.len, tdata->iv.len))
13820 : : return TEST_SKIPPED;
13821 : :
13822 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13823 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13824 : :
13825 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13826 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13827 : : return TEST_SKIPPED;
13828 : :
13829 : : /* not supported with CPU crypto */
13830 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13831 : : return TEST_SKIPPED;
13832 : :
13833 : : /* Create AEAD session */
13834 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13835 : 1 : tdata->algo,
13836 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13837 : 1 : tdata->key.data, tdata->key.len,
13838 : 1 : tdata->aad.len, tdata->auth_tag.len,
13839 : 1 : tdata->iv.len);
13840 [ + - ]: 1 : if (retval < 0)
13841 : : return retval;
13842 : :
13843 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13844 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13845 : :
13846 : : /* clear mbuf payload */
13847 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13848 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13849 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13850 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13851 : :
13852 : : /* Create AEAD operation */
13853 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13854 [ + - ]: 1 : if (retval < 0)
13855 : : return retval;
13856 : :
13857 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13858 : :
13859 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13860 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13861 : :
13862 : : /* Process crypto operation */
13863 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13864 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13865 : : 0);
13866 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13867 : : return retval;
13868 : : } else
13869 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13870 : : ut_params->op), "failed to process sym crypto op");
13871 : :
13872 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13873 : : "crypto op processing failed");
13874 : :
13875 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13876 : :
13877 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13878 : : ut_params->op->sym->cipher.data.offset);
13879 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13880 : :
13881 : : /* Check if the data within the offset range is not overwritten in the OOP */
13882 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
13883 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
13884 [ - + ]: 16 : if (buffer_oop[i]) {
13885 : 0 : RTE_LOG(ERR, USER1,
13886 : : "Incorrect value of the output buffer header\n");
13887 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
13888 : 0 : ut_params->op->sym->cipher.data.offset);
13889 : 0 : return TEST_FAILED;
13890 : : }
13891 : : }
13892 : :
13893 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13894 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13895 : :
13896 : : /* Validate obuf */
13897 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13898 : : ciphertext,
13899 : : tdata->ciphertext.data,
13900 : : tdata->ciphertext.len,
13901 : : "Ciphertext data not as expected");
13902 : :
13903 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13904 : : auth_tag,
13905 : : tdata->auth_tag.data,
13906 : : tdata->auth_tag.len,
13907 : : "Generated auth tag not as expected");
13908 : :
13909 : : return 0;
13910 : :
13911 : : }
13912 : :
13913 : : static int
13914 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13915 : : {
13916 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
13917 : : }
13918 : :
13919 : : static int
13920 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13921 : : {
13922 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13923 : : struct crypto_unittest_params *ut_params = &unittest_params;
13924 : :
13925 : : uint32_t i;
13926 : : int retval;
13927 : : uint8_t *plaintext, *buffer_oop;
13928 : : struct rte_cryptodev_info dev_info;
13929 : :
13930 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13931 : : uint64_t feat_flags = dev_info.feature_flags;
13932 : :
13933 : : /* Verify the capabilities */
13934 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13935 : : const struct rte_cryptodev_symmetric_capability *capability;
13936 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13937 : 1 : cap_idx.algo.aead = tdata->algo;
13938 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13939 : :
13940 [ + - ]: 1 : if (capability == NULL)
13941 : : return TEST_SKIPPED;
13942 : :
13943 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13944 : 1 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13945 : : return TEST_SKIPPED;
13946 : :
13947 : : /* not supported with CPU crypto and raw data-path APIs*/
13948 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13949 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
13950 : : return TEST_SKIPPED;
13951 : :
13952 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13953 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13954 : : printf("Device does not support RAW data-path APIs.\n");
13955 : : return TEST_SKIPPED;
13956 : : }
13957 : :
13958 : : /* Create AEAD session */
13959 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13960 : 1 : tdata->algo,
13961 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13962 : 1 : tdata->key.data, tdata->key.len,
13963 : 1 : tdata->aad.len, tdata->auth_tag.len,
13964 : 1 : tdata->iv.len);
13965 [ + - ]: 1 : if (retval < 0)
13966 : : return retval;
13967 : :
13968 : : /* alloc mbuf and set payload */
13969 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13970 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13971 : :
13972 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13973 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13974 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13975 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13976 : :
13977 : : /* Create AEAD operation */
13978 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13979 [ + - ]: 1 : if (retval < 0)
13980 : : return retval;
13981 : :
13982 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13983 : :
13984 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13985 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13986 : :
13987 : : /* Process crypto operation */
13988 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13989 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13990 : : 0);
13991 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13992 : : return retval;
13993 : : } else
13994 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13995 : : ut_params->op), "failed to process sym crypto op");
13996 : :
13997 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13998 : : "crypto op processing failed");
13999 : :
14000 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
14001 : : ut_params->op->sym->cipher.data.offset);
14002 : :
14003 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14004 : :
14005 : : /* Check if the data within the offset range is not overwritten in the OOP */
14006 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
14007 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
14008 [ - + ]: 16 : if (buffer_oop[i]) {
14009 : 0 : RTE_LOG(ERR, USER1,
14010 : : "Incorrect value of the output buffer header\n");
14011 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
14012 : 0 : ut_params->op->sym->cipher.data.offset);
14013 : 0 : return TEST_FAILED;
14014 : : }
14015 : : }
14016 : : /* Validate obuf */
14017 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14018 : : plaintext,
14019 : : tdata->plaintext.data,
14020 : : tdata->plaintext.len,
14021 : : "Plaintext data not as expected");
14022 : :
14023 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14024 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14025 : : "Authentication failed");
14026 : : return 0;
14027 : : }
14028 : :
14029 : : static int
14030 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
14031 : : {
14032 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
14033 : : }
14034 : :
14035 : : static int
14036 : 1 : test_authenticated_encryption_sessionless(
14037 : : const struct aead_test_data *tdata)
14038 : : {
14039 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14040 : : struct crypto_unittest_params *ut_params = &unittest_params;
14041 : :
14042 : : int retval;
14043 : : uint8_t *ciphertext, *auth_tag;
14044 : : uint16_t plaintext_pad_len;
14045 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14046 : : struct rte_cryptodev_info dev_info;
14047 : :
14048 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14049 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14050 : :
14051 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14052 : : printf("Device doesn't support Sessionless ops.\n");
14053 : 0 : return TEST_SKIPPED;
14054 : : }
14055 : :
14056 : : /* not supported with CPU crypto */
14057 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14058 : : return TEST_SKIPPED;
14059 : :
14060 : : /* Verify the capabilities */
14061 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14062 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14063 : 1 : cap_idx.algo.aead = tdata->algo;
14064 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14065 : : &cap_idx) == NULL)
14066 : : return TEST_SKIPPED;
14067 : :
14068 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14069 : :
14070 : : /* clear mbuf payload */
14071 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14072 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14073 : :
14074 : : /* Create AEAD operation */
14075 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
14076 [ + - ]: 1 : if (retval < 0)
14077 : : return retval;
14078 : :
14079 : : /* Create GCM xform */
14080 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14081 : 1 : retval = create_aead_xform(ut_params->op,
14082 : 1 : tdata->algo,
14083 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
14084 : : key, tdata->key.len,
14085 : 1 : tdata->aad.len, tdata->auth_tag.len,
14086 : 1 : tdata->iv.len);
14087 [ + - ]: 1 : if (retval < 0)
14088 : : return retval;
14089 : :
14090 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14091 : :
14092 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14093 : : RTE_CRYPTO_OP_SESSIONLESS,
14094 : : "crypto op session type not sessionless");
14095 : :
14096 : : /* Process crypto operation */
14097 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14098 : : ut_params->op), "failed to process sym crypto op");
14099 : :
14100 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14101 : :
14102 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14103 : : "crypto op status not success");
14104 : :
14105 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14106 : :
14107 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14108 : : ut_params->op->sym->cipher.data.offset);
14109 : 1 : auth_tag = ciphertext + plaintext_pad_len;
14110 : :
14111 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
14112 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
14113 : :
14114 : : /* Validate obuf */
14115 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14116 : : ciphertext,
14117 : : tdata->ciphertext.data,
14118 : : tdata->ciphertext.len,
14119 : : "Ciphertext data not as expected");
14120 : :
14121 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14122 : : auth_tag,
14123 : : tdata->auth_tag.data,
14124 : : tdata->auth_tag.len,
14125 : : "Generated auth tag not as expected");
14126 : :
14127 : : return 0;
14128 : :
14129 : : }
14130 : :
14131 : : static int
14132 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
14133 : : {
14134 : 1 : return test_authenticated_encryption_sessionless(
14135 : : &gcm_test_case_5);
14136 : : }
14137 : :
14138 : : static int
14139 : 1 : test_authenticated_decryption_sessionless(
14140 : : const struct aead_test_data *tdata)
14141 : : {
14142 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14143 : : struct crypto_unittest_params *ut_params = &unittest_params;
14144 : :
14145 : : int retval;
14146 : : uint8_t *plaintext;
14147 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14148 : : struct rte_cryptodev_info dev_info;
14149 : :
14150 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14151 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14152 : :
14153 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14154 : : printf("Device doesn't support Sessionless ops.\n");
14155 : 0 : return TEST_SKIPPED;
14156 : : }
14157 : :
14158 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14159 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14160 : : printf("Device doesn't support RAW data-path APIs.\n");
14161 : 0 : return TEST_SKIPPED;
14162 : : }
14163 : :
14164 : : /* not supported with CPU crypto */
14165 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14166 : : return TEST_SKIPPED;
14167 : :
14168 : : /* Verify the capabilities */
14169 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14170 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14171 : 1 : cap_idx.algo.aead = tdata->algo;
14172 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14173 : : &cap_idx) == NULL)
14174 : : return TEST_SKIPPED;
14175 : :
14176 : : /* alloc mbuf and set payload */
14177 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14178 : :
14179 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14180 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14181 : :
14182 : : /* Create AEAD operation */
14183 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14184 [ + - ]: 1 : if (retval < 0)
14185 : : return retval;
14186 : :
14187 : : /* Create AEAD xform */
14188 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14189 : 1 : retval = create_aead_xform(ut_params->op,
14190 : 1 : tdata->algo,
14191 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
14192 : : key, tdata->key.len,
14193 : 1 : tdata->aad.len, tdata->auth_tag.len,
14194 : 1 : tdata->iv.len);
14195 [ + - ]: 1 : if (retval < 0)
14196 : : return retval;
14197 : :
14198 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14199 : :
14200 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14201 : : RTE_CRYPTO_OP_SESSIONLESS,
14202 : : "crypto op session type not sessionless");
14203 : :
14204 : : /* Process crypto operation */
14205 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14206 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14207 : : 0);
14208 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14209 : : return retval;
14210 : : } else
14211 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
14212 : : ts_params->valid_devs[0], ut_params->op),
14213 : : "failed to process sym crypto op");
14214 : :
14215 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14216 : :
14217 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14218 : : "crypto op status not success");
14219 : :
14220 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14221 : : ut_params->op->sym->cipher.data.offset);
14222 : :
14223 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14224 : :
14225 : : /* Validate obuf */
14226 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14227 : : plaintext,
14228 : : tdata->plaintext.data,
14229 : : tdata->plaintext.len,
14230 : : "Plaintext data not as expected");
14231 : :
14232 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14233 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14234 : : "Authentication failed");
14235 : : return 0;
14236 : : }
14237 : :
14238 : : static int
14239 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
14240 : : {
14241 : 1 : return test_authenticated_decryption_sessionless(
14242 : : &gcm_test_case_5);
14243 : : }
14244 : :
14245 : : static int
14246 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
14247 : : {
14248 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
14249 : : }
14250 : :
14251 : : static int
14252 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
14253 : : {
14254 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
14255 : : }
14256 : :
14257 : : static int
14258 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
14259 : : {
14260 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
14261 : : }
14262 : :
14263 : : static int
14264 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
14265 : : {
14266 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
14267 : : }
14268 : :
14269 : : static int
14270 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
14271 : : {
14272 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
14273 : : }
14274 : :
14275 : : static int
14276 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
14277 : : {
14278 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
14279 : : }
14280 : :
14281 : : static int
14282 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
14283 : : {
14284 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
14285 : : }
14286 : :
14287 : : static int
14288 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
14289 : : {
14290 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
14291 : : }
14292 : :
14293 : : static int
14294 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
14295 : : {
14296 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
14297 : : }
14298 : :
14299 : : static int
14300 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
14301 : : {
14302 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
14303 : : }
14304 : :
14305 : : static int
14306 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
14307 : : {
14308 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
14309 : : }
14310 : :
14311 : : static int
14312 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14313 : : {
14314 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
14315 : : }
14316 : :
14317 : : static int
14318 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14319 : : {
14320 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
14321 : : }
14322 : :
14323 : : static int
14324 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14325 : : {
14326 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
14327 : : }
14328 : :
14329 : : static int
14330 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14331 : : {
14332 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
14333 : : }
14334 : :
14335 : : static int
14336 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14337 : : {
14338 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
14339 : : }
14340 : :
14341 : : static int
14342 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14343 : : {
14344 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
14345 : : }
14346 : :
14347 : : static int
14348 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14349 : : {
14350 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
14351 : : }
14352 : :
14353 : : static int
14354 : 1 : test_stats(void)
14355 : : {
14356 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14357 : : struct rte_cryptodev_stats stats;
14358 : :
14359 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14360 : : return TEST_SKIPPED;
14361 : :
14362 : : /* Verify the capabilities */
14363 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14364 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14365 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14366 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14367 : : &cap_idx) == NULL)
14368 : : return TEST_SKIPPED;
14369 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14370 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14371 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14372 : : &cap_idx) == NULL)
14373 : : return TEST_SKIPPED;
14374 : :
14375 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14376 : : == -ENOTSUP)
14377 : : return TEST_SKIPPED;
14378 : :
14379 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14380 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14381 : : &stats) == -ENODEV),
14382 : : "rte_cryptodev_stats_get invalid dev failed");
14383 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14384 : : "rte_cryptodev_stats_get invalid Param failed");
14385 : :
14386 : : /* Test expected values */
14387 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
14388 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14389 : : &stats),
14390 : : "rte_cryptodev_stats_get failed");
14391 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14392 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
14393 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
14394 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
14395 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
14396 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14397 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
14398 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14399 : :
14400 : : /* invalid device but should ignore and not reset device stats*/
14401 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14402 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14403 : : &stats),
14404 : : "rte_cryptodev_stats_get failed");
14405 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14406 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14407 : :
14408 : : /* check that a valid reset clears stats */
14409 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14410 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14411 : : &stats),
14412 : : "rte_cryptodev_stats_get failed");
14413 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
14414 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14415 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
14416 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14417 : :
14418 : : return TEST_SUCCESS;
14419 : : }
14420 : :
14421 : : static int
14422 : 1 : test_device_reconfigure(void)
14423 : : {
14424 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14425 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14426 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14427 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14428 : 1 : .mp_session = ts_params->session_mpool
14429 : : };
14430 : : uint16_t qp_id, dev_id, num_devs = 0;
14431 : :
14432 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14433 : : "Need at least %d devices for test", 1);
14434 : :
14435 : 1 : dev_id = ts_params->valid_devs[0];
14436 : :
14437 : : /* Stop the device in case it's started so it can be configured */
14438 : 1 : rte_cryptodev_stop(dev_id);
14439 : :
14440 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14441 : : "Failed test for rte_cryptodev_configure: "
14442 : : "dev_num %u", dev_id);
14443 : :
14444 : : /* Reconfigure with same configure params */
14445 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14446 : : "Failed test for rte_cryptodev_configure: "
14447 : : "dev_num %u", dev_id);
14448 : :
14449 : : /* Reconfigure with just one queue pair */
14450 : 1 : ts_params->conf.nb_queue_pairs = 1;
14451 : :
14452 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14453 : : &ts_params->conf),
14454 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14455 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14456 : :
14457 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14458 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14459 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14460 : : rte_cryptodev_socket_id(
14461 : : ts_params->valid_devs[0])),
14462 : : "Failed test for "
14463 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14464 : : "%u on qp %u on cryptodev %u",
14465 : : qp_conf.nb_descriptors, qp_id,
14466 : : ts_params->valid_devs[0]);
14467 : : }
14468 : :
14469 : : /* Reconfigure with max number of queue pairs */
14470 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
14471 : :
14472 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14473 : : &ts_params->conf),
14474 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14475 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14476 : :
14477 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14478 : :
14479 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14480 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14481 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14482 : : rte_cryptodev_socket_id(
14483 : : ts_params->valid_devs[0])),
14484 : : "Failed test for "
14485 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14486 : : "%u on qp %u on cryptodev %u",
14487 : : qp_conf.nb_descriptors, qp_id,
14488 : : ts_params->valid_devs[0]);
14489 : : }
14490 : :
14491 : : /* Start the device */
14492 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14493 : : "Failed to start cryptodev %u",
14494 : : ts_params->valid_devs[0]);
14495 : :
14496 : : /* Test expected values */
14497 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14498 : : }
14499 : :
14500 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14501 : : struct crypto_unittest_params *ut_params,
14502 : : enum rte_crypto_auth_operation op,
14503 : : const struct HMAC_MD5_vector *test_case)
14504 : : {
14505 : : uint8_t key[64];
14506 : :
14507 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
14508 : :
14509 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14510 : 4 : ut_params->auth_xform.next = NULL;
14511 : 4 : ut_params->auth_xform.auth.op = op;
14512 : :
14513 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14514 : :
14515 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14516 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
14517 : 4 : ut_params->auth_xform.auth.key.data = key;
14518 : :
14519 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
14520 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14521 : : ts_params->session_mpool);
14522 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14523 : : return TEST_SKIPPED;
14524 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14525 : :
14526 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14527 : :
14528 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14529 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14530 : :
14531 : 4 : return 0;
14532 : : }
14533 : :
14534 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14535 : : const struct HMAC_MD5_vector *test_case,
14536 : : uint8_t **plaintext)
14537 : : {
14538 : : uint16_t plaintext_pad_len;
14539 : :
14540 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14541 : :
14542 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14543 : : 16);
14544 : :
14545 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14546 : : plaintext_pad_len);
14547 : 4 : memcpy(*plaintext, test_case->plaintext.data,
14548 : 4 : test_case->plaintext.len);
14549 : :
14550 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14551 : : ut_params->ibuf, MD5_DIGEST_LEN);
14552 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14553 : : "no room to append digest");
14554 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14555 : : ut_params->ibuf, plaintext_pad_len);
14556 : :
14557 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14558 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14559 [ - + ]: 2 : test_case->auth_tag.len);
14560 : : }
14561 : :
14562 : 4 : sym_op->auth.data.offset = 0;
14563 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
14564 : :
14565 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14566 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14567 : :
14568 : 4 : return 0;
14569 : : }
14570 : :
14571 : : static int
14572 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14573 : : {
14574 : : uint16_t plaintext_pad_len;
14575 : : uint8_t *plaintext, *auth_tag;
14576 : : int ret;
14577 : :
14578 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14579 : : struct crypto_unittest_params *ut_params = &unittest_params;
14580 : : struct rte_cryptodev_info dev_info;
14581 : :
14582 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14583 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14584 : :
14585 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14586 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14587 : : printf("Device doesn't support RAW data-path APIs.\n");
14588 : 0 : return TEST_SKIPPED;
14589 : : }
14590 : :
14591 : : /* Verify the capabilities */
14592 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14593 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14594 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14595 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14596 : : &cap_idx) == NULL)
14597 : : return TEST_SKIPPED;
14598 : :
14599 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14600 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14601 : : return TEST_FAILED;
14602 : :
14603 : : /* Generate Crypto op data structure */
14604 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14605 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14606 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14607 : : "Failed to allocate symmetric crypto operation struct");
14608 : :
14609 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14610 : : 16);
14611 : :
14612 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14613 : : return TEST_FAILED;
14614 : :
14615 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14616 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14617 : : ut_params->op);
14618 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14619 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14620 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14621 : : return ret;
14622 : : } else
14623 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14624 : : process_crypto_request(ts_params->valid_devs[0],
14625 : : ut_params->op),
14626 : : "failed to process sym crypto op");
14627 : :
14628 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14629 : : "crypto op processing failed");
14630 : :
14631 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
14632 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14633 : : uint8_t *, plaintext_pad_len);
14634 : : } else {
14635 : 2 : auth_tag = plaintext + plaintext_pad_len;
14636 : : }
14637 : :
14638 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14639 : : auth_tag,
14640 : : test_case->auth_tag.data,
14641 : : test_case->auth_tag.len,
14642 : : "HMAC_MD5 generated tag not as expected");
14643 : :
14644 : : return TEST_SUCCESS;
14645 : : }
14646 : :
14647 : : static int
14648 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14649 : : {
14650 : : uint8_t *plaintext;
14651 : : int ret;
14652 : :
14653 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14654 : : struct crypto_unittest_params *ut_params = &unittest_params;
14655 : : struct rte_cryptodev_info dev_info;
14656 : :
14657 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14658 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14659 : :
14660 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14661 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14662 : : printf("Device doesn't support RAW data-path APIs.\n");
14663 : 0 : return TEST_SKIPPED;
14664 : : }
14665 : :
14666 : : /* Verify the capabilities */
14667 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14668 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14669 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14670 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14671 : : &cap_idx) == NULL)
14672 : : return TEST_SKIPPED;
14673 : :
14674 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14675 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14676 : : return TEST_FAILED;
14677 : : }
14678 : :
14679 : : /* Generate Crypto op data structure */
14680 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14681 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14682 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14683 : : "Failed to allocate symmetric crypto operation struct");
14684 : :
14685 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14686 : : return TEST_FAILED;
14687 : :
14688 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14689 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14690 : : ut_params->op);
14691 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14692 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14693 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14694 : : return ret;
14695 : : } else
14696 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14697 : : process_crypto_request(ts_params->valid_devs[0],
14698 : : ut_params->op),
14699 : : "failed to process sym crypto op");
14700 : :
14701 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14702 : : "HMAC_MD5 crypto op processing failed");
14703 : :
14704 : : return TEST_SUCCESS;
14705 : : }
14706 : :
14707 : : static int
14708 : 1 : test_MD5_HMAC_generate_case_1(void)
14709 : : {
14710 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14711 : : }
14712 : :
14713 : : static int
14714 : 1 : test_MD5_HMAC_verify_case_1(void)
14715 : : {
14716 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14717 : : }
14718 : :
14719 : : static int
14720 : 1 : test_MD5_HMAC_generate_case_2(void)
14721 : : {
14722 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14723 : : }
14724 : :
14725 : : static int
14726 : 1 : test_MD5_HMAC_verify_case_2(void)
14727 : : {
14728 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14729 : : }
14730 : :
14731 : : static int
14732 : 1 : test_multi_session(void)
14733 : : {
14734 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14735 : : struct crypto_unittest_params *ut_params = &unittest_params;
14736 : : struct rte_cryptodev_info dev_info;
14737 : : int i, nb_sess, ret = TEST_SUCCESS;
14738 : : void **sessions;
14739 : :
14740 : : /* Verify the capabilities */
14741 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14742 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14743 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14744 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14745 : : &cap_idx) == NULL)
14746 : : return TEST_SKIPPED;
14747 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14748 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14749 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14750 : : &cap_idx) == NULL)
14751 : : return TEST_SKIPPED;
14752 : :
14753 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14754 : : aes_cbc_key, hmac_sha512_key);
14755 : :
14756 : :
14757 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14758 : :
14759 : 1 : sessions = rte_malloc(NULL,
14760 : : sizeof(void *) *
14761 : : (MAX_NB_SESSIONS + 1), 0);
14762 : :
14763 : : /* Create multiple crypto sessions*/
14764 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
14765 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
14766 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14767 : : ts_params->session_mpool);
14768 [ - + ]: 4 : if (sessions[i] == NULL) {
14769 : : nb_sess = i;
14770 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14771 : : ret = TEST_SKIPPED;
14772 : : else {
14773 : : ret = TEST_FAILED;
14774 : : printf("TestCase %s() line %d failed : "
14775 : : "Session creation failed at session number %u",
14776 : : __func__, __LINE__, i);
14777 : : }
14778 : : break;
14779 : : }
14780 : :
14781 : :
14782 : : /* Attempt to send a request on each session */
14783 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14784 : : sessions[i],
14785 : : ut_params,
14786 : : ts_params,
14787 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14788 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14789 : : aes_cbc_iv);
14790 : :
14791 : : /* free crypto operation structure */
14792 : 4 : rte_crypto_op_free(ut_params->op);
14793 : 4 : ut_params->op = NULL;
14794 : :
14795 : : /*
14796 : : * free mbuf - both obuf and ibuf are usually the same,
14797 : : * so check if they point at the same address is necessary,
14798 : : * to avoid freeing the mbuf twice.
14799 : : */
14800 [ + - ]: 4 : if (ut_params->obuf) {
14801 : 4 : rte_pktmbuf_free(ut_params->obuf);
14802 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
14803 : 4 : ut_params->ibuf = 0;
14804 : 4 : ut_params->obuf = 0;
14805 : : }
14806 [ - + ]: 4 : if (ut_params->ibuf) {
14807 : 0 : rte_pktmbuf_free(ut_params->ibuf);
14808 : 0 : ut_params->ibuf = 0;
14809 : : }
14810 : :
14811 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
14812 : 0 : i++;
14813 : 0 : break;
14814 : : }
14815 : : }
14816 : :
14817 : : nb_sess = i;
14818 : :
14819 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
14820 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14821 : 4 : sessions[i]);
14822 : : }
14823 : :
14824 : 1 : rte_free(sessions);
14825 : :
14826 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14827 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14828 : :
14829 : : return ret;
14830 : : }
14831 : :
14832 : : struct multi_session_params {
14833 : : struct crypto_unittest_params ut_params;
14834 : : uint8_t *cipher_key;
14835 : : uint8_t *hmac_key;
14836 : : const uint8_t *cipher;
14837 : : const uint8_t *digest;
14838 : : uint8_t *iv;
14839 : : };
14840 : :
14841 : : #define MB_SESSION_NUMBER 3
14842 : :
14843 : : static int
14844 : 1 : test_multi_session_random_usage(void)
14845 : : {
14846 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14847 : : struct rte_cryptodev_info dev_info;
14848 : : int index = 0, ret = TEST_SUCCESS;
14849 : : uint32_t nb_sess, i, j;
14850 : : void **sessions;
14851 : 1 : struct multi_session_params ut_paramz[] = {
14852 : :
14853 : : {
14854 : : .cipher_key = ms_aes_cbc_key0,
14855 : : .hmac_key = ms_hmac_key0,
14856 : : .cipher = ms_aes_cbc_cipher0,
14857 : : .digest = ms_hmac_digest0,
14858 : : .iv = ms_aes_cbc_iv0
14859 : : },
14860 : : {
14861 : : .cipher_key = ms_aes_cbc_key1,
14862 : : .hmac_key = ms_hmac_key1,
14863 : : .cipher = ms_aes_cbc_cipher1,
14864 : : .digest = ms_hmac_digest1,
14865 : : .iv = ms_aes_cbc_iv1
14866 : : },
14867 : : {
14868 : : .cipher_key = ms_aes_cbc_key2,
14869 : : .hmac_key = ms_hmac_key2,
14870 : : .cipher = ms_aes_cbc_cipher2,
14871 : : .digest = ms_hmac_digest2,
14872 : : .iv = ms_aes_cbc_iv2
14873 : : },
14874 : :
14875 : : };
14876 : :
14877 : : /* Verify the capabilities */
14878 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14879 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14880 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14881 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14882 : : &cap_idx) == NULL)
14883 : : return TEST_SKIPPED;
14884 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14885 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14886 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14887 : : &cap_idx) == NULL)
14888 : : return TEST_SKIPPED;
14889 : :
14890 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14891 : :
14892 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
14893 : : * MAX_NB_SESSIONS) + 1, 0);
14894 : :
14895 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
14896 : :
14897 : 3 : ut_paramz[i].ut_params = unittest_params;
14898 : :
14899 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14900 : : &ut_paramz[i].ut_params,
14901 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14902 : :
14903 : : /* Create multiple crypto sessions*/
14904 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
14905 : 3 : ts_params->valid_devs[0],
14906 : : &ut_paramz[i].ut_params.auth_xform,
14907 : : ts_params->session_mpool);
14908 [ - + ]: 3 : if (sessions[i] == NULL) {
14909 : : nb_sess = i;
14910 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14911 : : ret = TEST_SKIPPED;
14912 : : else {
14913 : : ret = TEST_FAILED;
14914 : : printf("TestCase %s() line %d failed : "
14915 : : "Session creation failed at session number %u",
14916 : : __func__, __LINE__, i);
14917 : : }
14918 : 0 : goto session_clear;
14919 : : }
14920 : :
14921 : : }
14922 : :
14923 : : nb_sess = i;
14924 : :
14925 : 1 : srand(time(NULL));
14926 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
14927 : :
14928 : 1 : j = rand() % MB_SESSION_NUMBER;
14929 : :
14930 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14931 : 1 : sessions[j],
14932 : : &ut_paramz[j].ut_params,
14933 : : ts_params, ut_paramz[j].cipher,
14934 : : ut_paramz[j].digest,
14935 : 1 : ut_paramz[j].iv);
14936 : :
14937 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
14938 : 1 : ut_paramz[j].ut_params.op = NULL;
14939 : :
14940 : : /*
14941 : : * free mbuf - both obuf and ibuf are usually the same,
14942 : : * so check if they point at the same address is necessary,
14943 : : * to avoid freeing the mbuf twice.
14944 : : */
14945 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
14946 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14947 : 1 : if (ut_paramz[j].ut_params.ibuf
14948 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
14949 : 1 : ut_paramz[j].ut_params.ibuf = 0;
14950 : 1 : ut_paramz[j].ut_params.obuf = 0;
14951 : : }
14952 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
14953 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14954 : 0 : ut_paramz[j].ut_params.ibuf = 0;
14955 : : }
14956 : :
14957 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
14958 : 1 : index = i;
14959 : 1 : break;
14960 : : }
14961 : : }
14962 : :
14963 : 0 : session_clear:
14964 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
14965 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14966 : 3 : sessions[i]);
14967 : : }
14968 : :
14969 : 1 : rte_free(sessions);
14970 : :
14971 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14972 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14973 : :
14974 : : return TEST_SUCCESS;
14975 : : }
14976 : :
14977 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14978 : : 0xab, 0xab, 0xab, 0xab,
14979 : : 0xab, 0xab, 0xab, 0xab,
14980 : : 0xab, 0xab, 0xab, 0xab};
14981 : :
14982 : : static int
14983 : 0 : test_null_invalid_operation(void)
14984 : : {
14985 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14986 : : struct crypto_unittest_params *ut_params = &unittest_params;
14987 : :
14988 : : /* This test is for NULL PMD only */
14989 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
14990 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14991 : : return TEST_SKIPPED;
14992 : :
14993 : : /* Setup Cipher Parameters */
14994 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14995 : 0 : ut_params->cipher_xform.next = NULL;
14996 : :
14997 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14998 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14999 : :
15000 : : /* Create Crypto session*/
15001 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15002 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15003 : : ts_params->session_mpool);
15004 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15005 : : return TEST_SKIPPED;
15006 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15007 : : "Session creation succeeded unexpectedly");
15008 : :
15009 : : /* Setup HMAC Parameters */
15010 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15011 : 0 : ut_params->auth_xform.next = NULL;
15012 : :
15013 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
15014 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15015 : :
15016 : : /* Create Crypto session*/
15017 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15018 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
15019 : : ts_params->session_mpool);
15020 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15021 : : return TEST_SKIPPED;
15022 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15023 : : "Session creation succeeded unexpectedly");
15024 : :
15025 : : return TEST_SUCCESS;
15026 : : }
15027 : :
15028 : :
15029 : : #define NULL_BURST_LENGTH (32)
15030 : :
15031 : : static int
15032 : 0 : test_null_burst_operation(void)
15033 : : {
15034 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15035 : : struct crypto_unittest_params *ut_params = &unittest_params;
15036 : :
15037 : : unsigned i, burst_len = NULL_BURST_LENGTH;
15038 : :
15039 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
15040 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
15041 : :
15042 : : /* This test is for NULL PMD only */
15043 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15044 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15045 : : return TEST_SKIPPED;
15046 : :
15047 : : /* Setup Cipher Parameters */
15048 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15049 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15050 : :
15051 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15052 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15053 : :
15054 : : /* Setup HMAC Parameters */
15055 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15056 : 0 : ut_params->auth_xform.next = NULL;
15057 : :
15058 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15059 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15060 : :
15061 : : /* Create Crypto session*/
15062 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15063 : 0 : ts_params->valid_devs[0],
15064 : : &ut_params->auth_xform,
15065 : : ts_params->session_mpool);
15066 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15067 : : return TEST_SKIPPED;
15068 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15069 : :
15070 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
15071 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
15072 : : burst_len, "failed to generate burst of crypto ops");
15073 : :
15074 : : /* Generate an operation for each mbuf in burst */
15075 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15076 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15077 : :
15078 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
15079 : :
15080 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
15081 : : sizeof(unsigned));
15082 : 0 : *data = i;
15083 : :
15084 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
15085 : :
15086 : 0 : burst[i]->sym->m_src = m;
15087 : : }
15088 : :
15089 : : /* Process crypto operation */
15090 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
15091 : : 0, burst, burst_len),
15092 : : burst_len,
15093 : : "Error enqueuing burst");
15094 : :
15095 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
15096 : : 0, burst_dequeued, burst_len),
15097 : : burst_len,
15098 : : "Error dequeuing burst");
15099 : :
15100 : :
15101 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15102 [ # # ]: 0 : TEST_ASSERT_EQUAL(
15103 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
15104 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
15105 : : uint32_t *),
15106 : : "data not as expected");
15107 : :
15108 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
15109 : 0 : rte_crypto_op_free(burst[i]);
15110 : : }
15111 : :
15112 : : return TEST_SUCCESS;
15113 : : }
15114 : :
15115 : : static uint16_t
15116 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15117 : : uint16_t nb_ops, void *user_param)
15118 : : {
15119 : : RTE_SET_USED(dev_id);
15120 : : RTE_SET_USED(qp_id);
15121 : : RTE_SET_USED(ops);
15122 : : RTE_SET_USED(user_param);
15123 : :
15124 : 0 : enq_cb_called = true;
15125 : : printf("crypto enqueue callback called\n");
15126 : 0 : return nb_ops;
15127 : : }
15128 : :
15129 : : static uint16_t
15130 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15131 : : uint16_t nb_ops, void *user_param)
15132 : : {
15133 : : RTE_SET_USED(dev_id);
15134 : : RTE_SET_USED(qp_id);
15135 : : RTE_SET_USED(ops);
15136 : : RTE_SET_USED(user_param);
15137 : :
15138 : 0 : deq_cb_called = true;
15139 : : printf("crypto dequeue callback called\n");
15140 : 0 : return nb_ops;
15141 : : }
15142 : :
15143 : : /*
15144 : : * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
15145 : : */
15146 : : static int
15147 : 0 : test_enqdeq_callback_null_cipher(void)
15148 : : {
15149 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15150 : : struct crypto_unittest_params *ut_params = &unittest_params;
15151 : :
15152 : : /* Setup Cipher Parameters */
15153 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15154 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15155 : :
15156 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15157 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15158 : :
15159 : : /* Setup Auth Parameters */
15160 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15161 : 0 : ut_params->auth_xform.next = NULL;
15162 : :
15163 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15164 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15165 : :
15166 : : /* Create Crypto session */
15167 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
15168 : : &ut_params->auth_xform, ts_params->session_mpool);
15169 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15170 : : return TEST_SKIPPED;
15171 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15172 : :
15173 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15174 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
15175 : :
15176 : : /* Allocate mbuf */
15177 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15178 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
15179 : :
15180 : : /* Append some random data */
15181 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
15182 : : "no room to append data");
15183 : :
15184 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15185 : :
15186 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15187 : :
15188 : : /* Process crypto operation */
15189 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
15190 : : "failed to process sym crypto op");
15191 : :
15192 : : return 0;
15193 : : }
15194 : :
15195 : : static int
15196 : 1 : test_enq_callback_setup(void)
15197 : : {
15198 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15199 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15200 : : struct rte_cryptodev_info dev_info;
15201 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15202 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15203 : : };
15204 : :
15205 : : struct rte_cryptodev_cb *cb;
15206 : : uint16_t qp_id = 0;
15207 : : int j = 0;
15208 : :
15209 : : /* Skip test if synchronous API is used */
15210 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15211 : : return TEST_SKIPPED;
15212 : :
15213 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15214 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15215 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15216 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15217 : : &cap_idx) == NULL)
15218 : : return TEST_SKIPPED;
15219 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15220 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15221 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15222 : : &cap_idx) == NULL)
15223 : : return TEST_SKIPPED;
15224 : :
15225 : : /* Stop the device in case it's started so it can be configured */
15226 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15227 : :
15228 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15229 : :
15230 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15231 : : &ts_params->conf),
15232 : : "Failed to configure cryptodev %u",
15233 : : ts_params->valid_devs[0]);
15234 : :
15235 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15236 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15237 : :
15238 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15239 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15240 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15241 : : "Failed test for "
15242 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15243 : : "%u on qp %u on cryptodev %u",
15244 : : qp_conf.nb_descriptors, qp_id,
15245 : : ts_params->valid_devs[0]);
15246 : :
15247 : 0 : enq_cb_called = false;
15248 : : /* Test with invalid crypto device */
15249 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
15250 : : qp_id, test_enq_callback, NULL);
15251 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15252 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15253 : : "rte_cryptodev_add_enq_callback() "
15254 : : "Not supported, skipped\n", __func__, __LINE__);
15255 : 0 : return TEST_SKIPPED;
15256 : : }
15257 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15258 : : "cryptodev %u did not fail",
15259 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15260 : :
15261 : : /* Test with invalid queue pair */
15262 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15263 : 0 : dev_info.max_nb_queue_pairs + 1,
15264 : : test_enq_callback, NULL);
15265 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15266 : : "cryptodev %u did not fail",
15267 : : dev_info.max_nb_queue_pairs + 1,
15268 : : ts_params->valid_devs[0]);
15269 : :
15270 : : /* Test with NULL callback */
15271 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15272 : : qp_id, NULL, NULL);
15273 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15274 : : "cryptodev %u did not fail",
15275 : : qp_id, ts_params->valid_devs[0]);
15276 : :
15277 : : /* Test with valid configuration */
15278 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15279 : : qp_id, test_enq_callback, NULL);
15280 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15281 : : "qp %u on cryptodev %u",
15282 : : qp_id, ts_params->valid_devs[0]);
15283 : :
15284 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15285 : :
15286 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
15287 : :
15288 : : /* Wait until callback not called. */
15289 [ # # # # ]: 0 : while (!enq_cb_called && (j++ < 10))
15290 : : rte_delay_ms(10);
15291 : :
15292 : : /* Test with invalid crypto device */
15293 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15294 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15295 : : "Expected call to fail as crypto device is invalid");
15296 : :
15297 : : /* Test with invalid queue pair */
15298 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15299 : : ts_params->valid_devs[0],
15300 : : dev_info.max_nb_queue_pairs + 1, cb),
15301 : : "Expected call to fail as queue pair is invalid");
15302 : :
15303 : : /* Test with NULL callback */
15304 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15305 : : ts_params->valid_devs[0], qp_id, NULL),
15306 : : "Expected call to fail as callback is NULL");
15307 : :
15308 : : /* Test with valid configuration */
15309 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
15310 : : ts_params->valid_devs[0], qp_id, cb),
15311 : : "Failed test to remove callback on "
15312 : : "qp %u on cryptodev %u",
15313 : : qp_id, ts_params->valid_devs[0]);
15314 : :
15315 [ # # ]: 0 : TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
15316 : :
15317 : : return TEST_SUCCESS;
15318 : : }
15319 : :
15320 : : static int
15321 : 1 : test_deq_callback_setup(void)
15322 : : {
15323 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15324 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15325 : : struct rte_cryptodev_info dev_info;
15326 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15327 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15328 : : };
15329 : :
15330 : : struct rte_cryptodev_cb *cb;
15331 : : uint16_t qp_id = 0;
15332 : : int j = 0;
15333 : :
15334 : : /* Skip test if synchronous API is used */
15335 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15336 : : return TEST_SKIPPED;
15337 : :
15338 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15339 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15340 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15341 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15342 : : &cap_idx) == NULL)
15343 : : return TEST_SKIPPED;
15344 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15345 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15346 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15347 : : &cap_idx) == NULL)
15348 : : return TEST_SKIPPED;
15349 : :
15350 : : /* Stop the device in case it's started so it can be configured */
15351 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15352 : :
15353 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15354 : :
15355 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15356 : : &ts_params->conf),
15357 : : "Failed to configure cryptodev %u",
15358 : : ts_params->valid_devs[0]);
15359 : :
15360 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15361 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15362 : :
15363 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15364 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15365 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15366 : : "Failed test for "
15367 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15368 : : "%u on qp %u on cryptodev %u",
15369 : : qp_conf.nb_descriptors, qp_id,
15370 : : ts_params->valid_devs[0]);
15371 : :
15372 : 0 : deq_cb_called = false;
15373 : : /* Test with invalid crypto device */
15374 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15375 : : qp_id, test_deq_callback, NULL);
15376 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15377 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15378 : : "rte_cryptodev_add_deq_callback() "
15379 : : "Not supported, skipped\n", __func__, __LINE__);
15380 : 0 : return TEST_SKIPPED;
15381 : : }
15382 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15383 : : "cryptodev %u did not fail",
15384 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15385 : :
15386 : : /* Test with invalid queue pair */
15387 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15388 : 0 : dev_info.max_nb_queue_pairs + 1,
15389 : : test_deq_callback, NULL);
15390 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15391 : : "cryptodev %u did not fail",
15392 : : dev_info.max_nb_queue_pairs + 1,
15393 : : ts_params->valid_devs[0]);
15394 : :
15395 : : /* Test with NULL callback */
15396 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15397 : : qp_id, NULL, NULL);
15398 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15399 : : "cryptodev %u did not fail",
15400 : : qp_id, ts_params->valid_devs[0]);
15401 : :
15402 : : /* Test with valid configuration */
15403 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15404 : : qp_id, test_deq_callback, NULL);
15405 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15406 : : "qp %u on cryptodev %u",
15407 : : qp_id, ts_params->valid_devs[0]);
15408 : :
15409 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15410 : :
15411 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15412 : :
15413 : : /* Wait until callback not called. */
15414 [ # # # # ]: 0 : while (!deq_cb_called && (j++ < 10))
15415 : : rte_delay_ms(10);
15416 : :
15417 : : /* Test with invalid crypto device */
15418 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15419 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15420 : : "Expected call to fail as crypto device is invalid");
15421 : :
15422 : : /* Test with invalid queue pair */
15423 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15424 : : ts_params->valid_devs[0],
15425 : : dev_info.max_nb_queue_pairs + 1, cb),
15426 : : "Expected call to fail as queue pair is invalid");
15427 : :
15428 : : /* Test with NULL callback */
15429 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15430 : : ts_params->valid_devs[0], qp_id, NULL),
15431 : : "Expected call to fail as callback is NULL");
15432 : :
15433 : : /* Test with valid configuration */
15434 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15435 : : ts_params->valid_devs[0], qp_id, cb),
15436 : : "Failed test to remove callback on "
15437 : : "qp %u on cryptodev %u",
15438 : : qp_id, ts_params->valid_devs[0]);
15439 : :
15440 [ # # ]: 0 : TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15441 : :
15442 : : return TEST_SUCCESS;
15443 : : }
15444 : :
15445 : : static void
15446 : : generate_gmac_large_plaintext(uint8_t *data)
15447 : : {
15448 : : uint16_t i;
15449 : :
15450 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15451 : 4082 : memcpy(&data[i], &data[0], 32);
15452 : : }
15453 : :
15454 : : static int
15455 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
15456 : : const struct gmac_test_data *tdata)
15457 : : {
15458 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15459 : : struct crypto_unittest_params *ut_params = &unittest_params;
15460 : : struct rte_crypto_sym_op *sym_op;
15461 : :
15462 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15463 : :
15464 : : /* Generate Crypto op data structure */
15465 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15466 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15467 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
15468 : : "Failed to allocate symmetric crypto operation struct");
15469 : :
15470 : : sym_op = ut_params->op->sym;
15471 : :
15472 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15473 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
15474 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15475 : : "no room to append digest");
15476 : :
15477 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15478 : : ut_params->ibuf, plaintext_pad_len);
15479 : :
15480 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15481 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15482 [ - + ]: 4 : tdata->gmac_tag.len);
15483 : 4 : debug_hexdump(stdout, "digest:",
15484 : 4 : sym_op->auth.digest.data,
15485 : 4 : tdata->gmac_tag.len);
15486 : : }
15487 : :
15488 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15489 : : uint8_t *, IV_OFFSET);
15490 : :
15491 [ - + ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15492 : :
15493 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15494 : :
15495 : 8 : sym_op->cipher.data.length = 0;
15496 : 8 : sym_op->cipher.data.offset = 0;
15497 : :
15498 : 8 : sym_op->auth.data.offset = 0;
15499 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
15500 : :
15501 : 8 : return 0;
15502 : : }
15503 : :
15504 : : static int
15505 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15506 : : const struct gmac_test_data *tdata,
15507 : : void *digest_mem, uint64_t digest_phys)
15508 : : {
15509 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15510 : : struct crypto_unittest_params *ut_params = &unittest_params;
15511 : : struct rte_crypto_sym_op *sym_op;
15512 : :
15513 : : /* Generate Crypto op data structure */
15514 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15515 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15516 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15517 : : "Failed to allocate symmetric crypto operation struct");
15518 : :
15519 : : sym_op = ut_params->op->sym;
15520 : :
15521 : 0 : sym_op->auth.digest.data = digest_mem;
15522 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15523 : : "no room to append digest");
15524 : :
15525 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
15526 : :
15527 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15528 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15529 [ # # ]: 0 : tdata->gmac_tag.len);
15530 : 0 : debug_hexdump(stdout, "digest:",
15531 : 0 : sym_op->auth.digest.data,
15532 : 0 : tdata->gmac_tag.len);
15533 : : }
15534 : :
15535 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15536 : : uint8_t *, IV_OFFSET);
15537 : :
15538 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15539 : :
15540 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15541 : :
15542 : 0 : sym_op->cipher.data.length = 0;
15543 : 0 : sym_op->cipher.data.offset = 0;
15544 : :
15545 : 0 : sym_op->auth.data.offset = 0;
15546 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
15547 : :
15548 : 0 : return 0;
15549 : : }
15550 : :
15551 : 8 : static int create_gmac_session(uint8_t dev_id,
15552 : : const struct gmac_test_data *tdata,
15553 : : enum rte_crypto_auth_operation auth_op)
15554 : : {
15555 : 8 : uint8_t *auth_key = alloca(tdata->key.len);
15556 : :
15557 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15558 : : struct crypto_unittest_params *ut_params = &unittest_params;
15559 : :
15560 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
15561 : :
15562 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15563 : 8 : ut_params->auth_xform.next = NULL;
15564 : :
15565 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15566 : 8 : ut_params->auth_xform.auth.op = auth_op;
15567 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15568 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
15569 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
15570 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15571 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15572 : :
15573 : :
15574 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15575 : : &ut_params->auth_xform, ts_params->session_mpool);
15576 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15577 : : return TEST_SKIPPED;
15578 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15579 : :
15580 : : return 0;
15581 : : }
15582 : :
15583 : : static int
15584 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15585 : : {
15586 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15587 : : struct crypto_unittest_params *ut_params = &unittest_params;
15588 : : struct rte_cryptodev_info dev_info;
15589 : :
15590 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15591 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15592 : :
15593 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15594 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15595 : : printf("Device doesn't support RAW data-path APIs.\n");
15596 : 0 : return TEST_SKIPPED;
15597 : : }
15598 : :
15599 : : int retval;
15600 : :
15601 : : uint8_t *auth_tag, *plaintext;
15602 : : uint16_t plaintext_pad_len;
15603 : :
15604 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15605 : : "No GMAC length in the source data");
15606 : :
15607 : : /* Verify the capabilities */
15608 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15609 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15610 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15611 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15612 : : &cap_idx) == NULL)
15613 : : return TEST_SKIPPED;
15614 : :
15615 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15616 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15617 : :
15618 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15619 : : return TEST_SKIPPED;
15620 [ + - ]: 4 : if (retval < 0)
15621 : : return retval;
15622 : :
15623 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15624 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15625 : : else
15626 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15627 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15628 : : "Failed to allocate input buffer in mempool");
15629 : :
15630 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15631 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15632 : :
15633 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15634 : : /*
15635 : : * Runtime generate the large plain text instead of use hard code
15636 : : * plain text vector. It is done to avoid create huge source file
15637 : : * with the test vector.
15638 : : */
15639 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15640 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15641 : :
15642 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15643 : : plaintext_pad_len);
15644 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15645 : :
15646 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15647 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15648 : 4 : tdata->plaintext.len);
15649 : :
15650 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15651 : : tdata);
15652 : :
15653 [ + - ]: 4 : if (retval < 0)
15654 : : return retval;
15655 : :
15656 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15657 : :
15658 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15659 : :
15660 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15661 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15662 : : ut_params->op);
15663 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15664 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15665 : : 0);
15666 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15667 : : return retval;
15668 : : } else
15669 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15670 : : process_crypto_request(ts_params->valid_devs[0],
15671 : : ut_params->op), "failed to process sym crypto op");
15672 : :
15673 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15674 : : "crypto op processing failed");
15675 : :
15676 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
15677 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15678 : : uint8_t *, plaintext_pad_len);
15679 : : } else {
15680 : 4 : auth_tag = plaintext + plaintext_pad_len;
15681 : : }
15682 : :
15683 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15684 : :
15685 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15686 : : auth_tag,
15687 : : tdata->gmac_tag.data,
15688 : : tdata->gmac_tag.len,
15689 : : "GMAC Generated auth tag not as expected");
15690 : :
15691 : : return 0;
15692 : : }
15693 : :
15694 : : static int
15695 : 1 : test_AES_GMAC_authentication_test_case_1(void)
15696 : : {
15697 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
15698 : : }
15699 : :
15700 : : static int
15701 : 1 : test_AES_GMAC_authentication_test_case_2(void)
15702 : : {
15703 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
15704 : : }
15705 : :
15706 : : static int
15707 : 1 : test_AES_GMAC_authentication_test_case_3(void)
15708 : : {
15709 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
15710 : : }
15711 : :
15712 : : static int
15713 : 1 : test_AES_GMAC_authentication_test_case_4(void)
15714 : : {
15715 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
15716 : : }
15717 : :
15718 : : static int
15719 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15720 : : {
15721 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15722 : : struct crypto_unittest_params *ut_params = &unittest_params;
15723 : : int retval;
15724 : : uint32_t plaintext_pad_len;
15725 : : uint8_t *plaintext;
15726 : : struct rte_cryptodev_info dev_info;
15727 : :
15728 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15729 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15730 : :
15731 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15732 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15733 : : printf("Device doesn't support RAW data-path APIs.\n");
15734 : 0 : return TEST_SKIPPED;
15735 : : }
15736 : :
15737 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15738 : : "No GMAC length in the source data");
15739 : :
15740 : : /* Verify the capabilities */
15741 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15742 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15743 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15744 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15745 : : &cap_idx) == NULL)
15746 : : return TEST_SKIPPED;
15747 : :
15748 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15749 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15750 : :
15751 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15752 : : return TEST_SKIPPED;
15753 [ + - ]: 4 : if (retval < 0)
15754 : : return retval;
15755 : :
15756 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15757 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15758 : : else
15759 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15760 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15761 : : "Failed to allocate input buffer in mempool");
15762 : :
15763 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15764 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15765 : :
15766 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15767 : :
15768 : : /*
15769 : : * Runtime generate the large plain text instead of use hard code
15770 : : * plain text vector. It is done to avoid create huge source file
15771 : : * with the test vector.
15772 : : */
15773 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15774 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15775 : :
15776 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15777 : : plaintext_pad_len);
15778 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15779 : :
15780 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15781 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15782 : 4 : tdata->plaintext.len);
15783 : :
15784 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15785 : : tdata);
15786 : :
15787 [ + - ]: 4 : if (retval < 0)
15788 : : return retval;
15789 : :
15790 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15791 : :
15792 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15793 : :
15794 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15795 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15796 : : ut_params->op);
15797 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15798 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15799 : : 0);
15800 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15801 : : return retval;
15802 : : } else
15803 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15804 : : process_crypto_request(ts_params->valid_devs[0],
15805 : : ut_params->op), "failed to process sym crypto op");
15806 : :
15807 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15808 : : "crypto op processing failed");
15809 : :
15810 : : return 0;
15811 : :
15812 : : }
15813 : :
15814 : : static int
15815 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
15816 : : {
15817 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15818 : : }
15819 : :
15820 : : static int
15821 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
15822 : : {
15823 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15824 : : }
15825 : :
15826 : : static int
15827 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
15828 : : {
15829 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15830 : : }
15831 : :
15832 : : static int
15833 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
15834 : : {
15835 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15836 : : }
15837 : :
15838 : : static int
15839 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15840 : : uint32_t fragsz)
15841 : : {
15842 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15843 : : struct crypto_unittest_params *ut_params = &unittest_params;
15844 : : struct rte_cryptodev_info dev_info;
15845 : : uint64_t feature_flags;
15846 : : unsigned int trn_data = 0;
15847 : : void *digest_mem = NULL;
15848 : : uint32_t segs = 1;
15849 : : unsigned int to_trn = 0;
15850 : : struct rte_mbuf *buf = NULL;
15851 : : uint8_t *auth_tag, *plaintext;
15852 : : int retval;
15853 : :
15854 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15855 : : "No GMAC length in the source data");
15856 : :
15857 : : /* Verify the capabilities */
15858 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15859 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15860 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15861 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15862 : : &cap_idx) == NULL)
15863 : : return TEST_SKIPPED;
15864 : :
15865 : : /* Check for any input SGL support */
15866 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15867 : 4 : feature_flags = dev_info.feature_flags;
15868 : :
15869 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15870 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15871 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15872 : : return TEST_SKIPPED;
15873 : :
15874 : 0 : if (fragsz > tdata->plaintext.len)
15875 : : fragsz = tdata->plaintext.len;
15876 : :
15877 : 0 : uint16_t plaintext_len = fragsz;
15878 : :
15879 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
15880 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15881 : :
15882 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15883 : : return TEST_SKIPPED;
15884 [ # # ]: 0 : if (retval < 0)
15885 : : return retval;
15886 : :
15887 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15888 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15889 : : "Failed to allocate input buffer in mempool");
15890 : :
15891 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15892 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15893 : :
15894 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15895 : : plaintext_len);
15896 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15897 : :
15898 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15899 : :
15900 : : trn_data += plaintext_len;
15901 : :
15902 : 0 : buf = ut_params->ibuf;
15903 : :
15904 : : /*
15905 : : * Loop until no more fragments
15906 : : */
15907 : :
15908 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15909 : 0 : ++segs;
15910 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15911 : : (tdata->plaintext.len - trn_data) : fragsz;
15912 : :
15913 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15914 : : buf = buf->next;
15915 : :
15916 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15917 : : rte_pktmbuf_tailroom(buf));
15918 : :
15919 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15920 : : to_trn);
15921 : :
15922 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15923 : : to_trn);
15924 : 0 : trn_data += to_trn;
15925 [ # # ]: 0 : if (trn_data == tdata->plaintext.len)
15926 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15927 : 0 : tdata->gmac_tag.len);
15928 : : }
15929 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
15930 : :
15931 : : /*
15932 : : * Place digest at the end of the last buffer
15933 : : */
15934 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15935 : :
15936 [ # # ]: 0 : if (!digest_mem) {
15937 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15938 : 0 : + tdata->gmac_tag.len);
15939 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15940 : : tdata->plaintext.len);
15941 : : }
15942 : :
15943 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15944 : : tdata, digest_mem, digest_phys);
15945 : :
15946 [ # # ]: 0 : if (retval < 0)
15947 : : return retval;
15948 : :
15949 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15950 : :
15951 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15952 : :
15953 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15954 : : return TEST_SKIPPED;
15955 : :
15956 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15957 : : process_crypto_request(ts_params->valid_devs[0],
15958 : : ut_params->op), "failed to process sym crypto op");
15959 : :
15960 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15961 : : "crypto op processing failed");
15962 : :
15963 : : auth_tag = digest_mem;
15964 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15965 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15966 : : auth_tag,
15967 : : tdata->gmac_tag.data,
15968 : : tdata->gmac_tag.len,
15969 : : "GMAC Generated auth tag not as expected");
15970 : :
15971 : : return 0;
15972 : : }
15973 : :
15974 : : /* Segment size not multiple of block size (16B) */
15975 : : static int
15976 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
15977 : : {
15978 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15979 : : }
15980 : :
15981 : : static int
15982 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
15983 : : {
15984 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15985 : : }
15986 : :
15987 : : static int
15988 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
15989 : : {
15990 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15991 : : }
15992 : :
15993 : : /* Segment size not multiple of block size (16B) */
15994 : : static int
15995 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
15996 : : {
15997 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15998 : : }
15999 : :
16000 : : struct test_crypto_vector {
16001 : : enum rte_crypto_cipher_algorithm crypto_algo;
16002 : : unsigned int cipher_offset;
16003 : : unsigned int cipher_len;
16004 : :
16005 : : struct {
16006 : : uint8_t data[64];
16007 : : unsigned int len;
16008 : : } cipher_key;
16009 : :
16010 : : struct {
16011 : : uint8_t data[64];
16012 : : unsigned int len;
16013 : : } iv;
16014 : :
16015 : : struct {
16016 : : const uint8_t *data;
16017 : : unsigned int len;
16018 : : } plaintext;
16019 : :
16020 : : struct {
16021 : : const uint8_t *data;
16022 : : unsigned int len;
16023 : : } ciphertext;
16024 : :
16025 : : enum rte_crypto_auth_algorithm auth_algo;
16026 : : unsigned int auth_offset;
16027 : :
16028 : : struct {
16029 : : uint8_t data[128];
16030 : : unsigned int len;
16031 : : } auth_key;
16032 : :
16033 : : struct {
16034 : : const uint8_t *data;
16035 : : unsigned int len;
16036 : : } aad;
16037 : :
16038 : : struct {
16039 : : uint8_t data[128];
16040 : : unsigned int len;
16041 : : } digest;
16042 : : };
16043 : :
16044 : : static const struct test_crypto_vector
16045 : : hmac_sha1_test_crypto_vector = {
16046 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16047 : : .plaintext = {
16048 : : .data = plaintext_hash,
16049 : : .len = 512
16050 : : },
16051 : : .auth_key = {
16052 : : .data = {
16053 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16054 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16055 : : 0xDE, 0xF4, 0xDE, 0xAD
16056 : : },
16057 : : .len = 20
16058 : : },
16059 : : .digest = {
16060 : : .data = {
16061 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
16062 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
16063 : : 0x3F, 0x91, 0x64, 0x59
16064 : : },
16065 : : .len = 20
16066 : : }
16067 : : };
16068 : :
16069 : : static const struct test_crypto_vector
16070 : : aes128_gmac_test_vector = {
16071 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
16072 : : .plaintext = {
16073 : : .data = plaintext_hash,
16074 : : .len = 512
16075 : : },
16076 : : .iv = {
16077 : : .data = {
16078 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16079 : : 0x08, 0x09, 0x0A, 0x0B
16080 : : },
16081 : : .len = 12
16082 : : },
16083 : : .auth_key = {
16084 : : .data = {
16085 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16086 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
16087 : : },
16088 : : .len = 16
16089 : : },
16090 : : .digest = {
16091 : : .data = {
16092 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
16093 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
16094 : : },
16095 : : .len = 16
16096 : : }
16097 : : };
16098 : :
16099 : : static const struct test_crypto_vector
16100 : : aes128cbc_hmac_sha1_test_vector = {
16101 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16102 : : .cipher_offset = 0,
16103 : : .cipher_len = 512,
16104 : : .cipher_key = {
16105 : : .data = {
16106 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16107 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16108 : : },
16109 : : .len = 16
16110 : : },
16111 : : .iv = {
16112 : : .data = {
16113 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16114 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16115 : : },
16116 : : .len = 16
16117 : : },
16118 : : .plaintext = {
16119 : : .data = plaintext_hash,
16120 : : .len = 512
16121 : : },
16122 : : .ciphertext = {
16123 : : .data = ciphertext512_aes128cbc,
16124 : : .len = 512
16125 : : },
16126 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16127 : : .auth_offset = 0,
16128 : : .auth_key = {
16129 : : .data = {
16130 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16131 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16132 : : 0xDE, 0xF4, 0xDE, 0xAD
16133 : : },
16134 : : .len = 20
16135 : : },
16136 : : .digest = {
16137 : : .data = {
16138 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
16139 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16140 : : 0x18, 0x8C, 0x1D, 0x32
16141 : : },
16142 : : .len = 20
16143 : : }
16144 : : };
16145 : :
16146 : : static const struct test_crypto_vector
16147 : : aes128cbc_hmac_sha1_aad_test_vector = {
16148 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16149 : : .cipher_offset = 8,
16150 : : .cipher_len = 496,
16151 : : .cipher_key = {
16152 : : .data = {
16153 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16154 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16155 : : },
16156 : : .len = 16
16157 : : },
16158 : : .iv = {
16159 : : .data = {
16160 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16161 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16162 : : },
16163 : : .len = 16
16164 : : },
16165 : : .plaintext = {
16166 : : .data = plaintext_hash,
16167 : : .len = 512
16168 : : },
16169 : : .ciphertext = {
16170 : : .data = ciphertext512_aes128cbc_aad,
16171 : : .len = 512
16172 : : },
16173 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16174 : : .auth_offset = 0,
16175 : : .auth_key = {
16176 : : .data = {
16177 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16178 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16179 : : 0xDE, 0xF4, 0xDE, 0xAD
16180 : : },
16181 : : .len = 20
16182 : : },
16183 : : .digest = {
16184 : : .data = {
16185 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
16186 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
16187 : : 0x62, 0x0F, 0xFB, 0x10
16188 : : },
16189 : : .len = 20
16190 : : }
16191 : : };
16192 : :
16193 : : static void
16194 : : data_corruption(uint8_t *data)
16195 : : {
16196 : 3 : data[0] += 1;
16197 : 3 : }
16198 : :
16199 : : static void
16200 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
16201 : : {
16202 : 3 : data[tag_offset] += 1;
16203 : 3 : }
16204 : :
16205 : : static int
16206 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
16207 : : uint8_t dev_id,
16208 : : const struct test_crypto_vector *reference,
16209 : : enum rte_crypto_auth_operation auth_op)
16210 : : {
16211 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16212 : 2 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16213 : :
16214 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16215 : :
16216 : : /* Setup Authentication Parameters */
16217 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16218 : 2 : ut_params->auth_xform.auth.op = auth_op;
16219 : 2 : ut_params->auth_xform.next = NULL;
16220 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16221 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16222 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
16223 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16224 : :
16225 : : /* Create Crypto session*/
16226 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16227 : : &ut_params->auth_xform,
16228 : : ts_params->session_mpool);
16229 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16230 : : return TEST_SKIPPED;
16231 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16232 : :
16233 : : return 0;
16234 : : }
16235 : :
16236 : : static int
16237 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
16238 : : uint8_t dev_id,
16239 : : const struct test_crypto_vector *reference,
16240 : : enum rte_crypto_auth_operation auth_op,
16241 : : enum rte_crypto_cipher_operation cipher_op)
16242 : : {
16243 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16244 : 4 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16245 : 4 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16246 : :
16247 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
16248 : : reference->cipher_key.len);
16249 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16250 : :
16251 : : /* Setup Authentication Parameters */
16252 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16253 : 4 : ut_params->auth_xform.auth.op = auth_op;
16254 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16255 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16256 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
16257 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16258 : :
16259 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
16260 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
16261 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
16262 : : } else {
16263 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16264 : :
16265 : : /* Setup Cipher Parameters */
16266 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16267 : 2 : ut_params->cipher_xform.next = NULL;
16268 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16269 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
16270 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16271 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16272 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16273 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16274 : : }
16275 : :
16276 : : /* Create Crypto session*/
16277 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16278 : : &ut_params->auth_xform,
16279 : : ts_params->session_mpool);
16280 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16281 : : return TEST_SKIPPED;
16282 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16283 : :
16284 : : return 0;
16285 : : }
16286 : :
16287 : : static int
16288 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
16289 : : struct crypto_unittest_params *ut_params,
16290 : : const struct test_crypto_vector *reference,
16291 : : unsigned int auth_generate)
16292 : : {
16293 : : /* Generate Crypto op data structure */
16294 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16295 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16296 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16297 : : "Failed to allocate pktmbuf offload");
16298 : :
16299 : : /* Set crypto operation data parameters */
16300 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16301 : :
16302 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16303 : :
16304 : : /* set crypto operation source mbuf */
16305 : 2 : sym_op->m_src = ut_params->ibuf;
16306 : :
16307 : : /* digest */
16308 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16309 : 2 : ut_params->ibuf, reference->digest.len);
16310 : :
16311 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16312 : : "no room to append auth tag");
16313 : :
16314 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16315 : : ut_params->ibuf, reference->plaintext.len);
16316 : :
16317 [ - + ]: 2 : if (auth_generate)
16318 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16319 : : else
16320 : 2 : memcpy(sym_op->auth.digest.data,
16321 : 2 : reference->digest.data,
16322 : 2 : reference->digest.len);
16323 : :
16324 : 2 : debug_hexdump(stdout, "digest:",
16325 : 2 : sym_op->auth.digest.data,
16326 : 2 : reference->digest.len);
16327 : :
16328 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16329 : 2 : sym_op->auth.data.offset = 0;
16330 : :
16331 : 2 : return 0;
16332 : : }
16333 : :
16334 : : static int
16335 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16336 : : struct crypto_unittest_params *ut_params,
16337 : : const struct test_crypto_vector *reference,
16338 : : unsigned int auth_generate)
16339 : : {
16340 : : /* Generate Crypto op data structure */
16341 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16342 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16343 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16344 : : "Failed to allocate pktmbuf offload");
16345 : :
16346 : : /* Set crypto operation data parameters */
16347 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16348 : :
16349 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16350 : :
16351 : : /* set crypto operation source mbuf */
16352 : 2 : sym_op->m_src = ut_params->ibuf;
16353 : :
16354 : : /* digest */
16355 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16356 : 2 : ut_params->ibuf, reference->digest.len);
16357 : :
16358 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16359 : : "no room to append auth tag");
16360 : :
16361 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16362 : : ut_params->ibuf, reference->ciphertext.len);
16363 : :
16364 [ - + ]: 2 : if (auth_generate)
16365 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16366 : : else
16367 : 2 : memcpy(sym_op->auth.digest.data,
16368 : 2 : reference->digest.data,
16369 : 2 : reference->digest.len);
16370 : :
16371 : 2 : debug_hexdump(stdout, "digest:",
16372 : 2 : sym_op->auth.digest.data,
16373 : 2 : reference->digest.len);
16374 : :
16375 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16376 [ - + ]: 2 : reference->iv.data, reference->iv.len);
16377 : :
16378 : 2 : sym_op->cipher.data.length = 0;
16379 : 2 : sym_op->cipher.data.offset = 0;
16380 : :
16381 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16382 : 2 : sym_op->auth.data.offset = 0;
16383 : :
16384 : 2 : return 0;
16385 : : }
16386 : :
16387 : : static int
16388 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16389 : : struct crypto_unittest_params *ut_params,
16390 : : const struct test_crypto_vector *reference,
16391 : : unsigned int auth_generate)
16392 : : {
16393 : : /* Generate Crypto op data structure */
16394 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16395 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16396 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
16397 : : "Failed to allocate pktmbuf offload");
16398 : :
16399 : : /* Set crypto operation data parameters */
16400 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16401 : :
16402 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16403 : :
16404 : : /* set crypto operation source mbuf */
16405 : 4 : sym_op->m_src = ut_params->ibuf;
16406 : :
16407 : : /* digest */
16408 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16409 : 4 : ut_params->ibuf, reference->digest.len);
16410 : :
16411 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16412 : : "no room to append auth tag");
16413 : :
16414 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16415 : : ut_params->ibuf, reference->ciphertext.len);
16416 : :
16417 [ - + ]: 4 : if (auth_generate)
16418 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16419 : : else
16420 : 4 : memcpy(sym_op->auth.digest.data,
16421 : 4 : reference->digest.data,
16422 : 4 : reference->digest.len);
16423 : :
16424 : 4 : debug_hexdump(stdout, "digest:",
16425 : 4 : sym_op->auth.digest.data,
16426 : 4 : reference->digest.len);
16427 : :
16428 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16429 [ - + ]: 4 : reference->iv.data, reference->iv.len);
16430 : :
16431 : 4 : sym_op->cipher.data.length = reference->cipher_len;
16432 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
16433 : :
16434 : 4 : sym_op->auth.data.length = reference->plaintext.len;
16435 : 4 : sym_op->auth.data.offset = reference->auth_offset;
16436 : :
16437 : 4 : return 0;
16438 : : }
16439 : :
16440 : : static int
16441 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16442 : : struct crypto_unittest_params *ut_params,
16443 : : const struct test_crypto_vector *reference)
16444 : : {
16445 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
16446 : : }
16447 : :
16448 : : static int
16449 : : create_auth_verify_GMAC_operation(
16450 : : struct crypto_testsuite_params *ts_params,
16451 : : struct crypto_unittest_params *ut_params,
16452 : : const struct test_crypto_vector *reference)
16453 : : {
16454 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16455 : : }
16456 : :
16457 : : static int
16458 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16459 : : struct crypto_unittest_params *ut_params,
16460 : : const struct test_crypto_vector *reference)
16461 : : {
16462 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16463 : : }
16464 : :
16465 : : static int
16466 : 2 : test_authentication_verify_fail_when_data_corruption(
16467 : : struct crypto_testsuite_params *ts_params,
16468 : : struct crypto_unittest_params *ut_params,
16469 : : const struct test_crypto_vector *reference,
16470 : : unsigned int data_corrupted)
16471 : : {
16472 : : int retval;
16473 : :
16474 : : uint8_t *plaintext;
16475 : : struct rte_cryptodev_info dev_info;
16476 : :
16477 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16478 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16479 : :
16480 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16481 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16482 : : printf("Device doesn't support RAW data-path APIs.\n");
16483 : 0 : return TEST_SKIPPED;
16484 : : }
16485 : :
16486 : : /* Verify the capabilities */
16487 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16488 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16489 : 2 : cap_idx.algo.auth = reference->auth_algo;
16490 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16491 : : &cap_idx) == NULL)
16492 : : return TEST_SKIPPED;
16493 : :
16494 : :
16495 : : /* Create session */
16496 : 2 : retval = create_auth_session(ut_params,
16497 : 2 : ts_params->valid_devs[0],
16498 : : reference,
16499 : : RTE_CRYPTO_AUTH_OP_VERIFY);
16500 : :
16501 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16502 : : return TEST_SKIPPED;
16503 [ + - ]: 2 : if (retval < 0)
16504 : : return retval;
16505 : :
16506 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16507 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16508 : : "Failed to allocate input buffer in mempool");
16509 : :
16510 : : /* clear mbuf payload */
16511 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16512 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16513 : :
16514 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16515 : 2 : reference->plaintext.len);
16516 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16517 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16518 : :
16519 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16520 : 2 : reference->plaintext.len);
16521 : :
16522 : : /* Create operation */
16523 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
16524 : :
16525 [ + - ]: 2 : if (retval < 0)
16526 : : return retval;
16527 : :
16528 [ + + ]: 2 : if (data_corrupted)
16529 : : data_corruption(plaintext);
16530 : : else
16531 : 1 : tag_corruption(plaintext, reference->plaintext.len);
16532 : :
16533 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16534 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16535 : : ut_params->op);
16536 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16537 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16538 : : "authentication not failed");
16539 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16540 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16541 : : 0);
16542 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16543 : : return retval;
16544 : : } else {
16545 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16546 : : ut_params->op);
16547 : : }
16548 [ - + ]: 2 : if (ut_params->op == NULL)
16549 : : return 0;
16550 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16551 : 0 : return 0;
16552 : :
16553 : : return -1;
16554 : : }
16555 : :
16556 : : static int
16557 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
16558 : : struct crypto_testsuite_params *ts_params,
16559 : : struct crypto_unittest_params *ut_params,
16560 : : const struct test_crypto_vector *reference,
16561 : : unsigned int data_corrupted)
16562 : : {
16563 : : int retval;
16564 : : uint8_t *plaintext;
16565 : : struct rte_cryptodev_info dev_info;
16566 : :
16567 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16568 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16569 : :
16570 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16571 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16572 : : printf("Device doesn't support RAW data-path APIs.\n");
16573 : 0 : return TEST_SKIPPED;
16574 : : }
16575 : :
16576 : : /* Verify the capabilities */
16577 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16578 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16579 : 2 : cap_idx.algo.auth = reference->auth_algo;
16580 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16581 : : &cap_idx) == NULL)
16582 : : return TEST_SKIPPED;
16583 : :
16584 : : /* Create session */
16585 : 2 : retval = create_auth_cipher_session(ut_params,
16586 : 2 : ts_params->valid_devs[0],
16587 : : reference,
16588 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16589 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16590 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16591 : : return TEST_SKIPPED;
16592 [ + - ]: 2 : if (retval < 0)
16593 : : return retval;
16594 : :
16595 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16596 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16597 : : "Failed to allocate input buffer in mempool");
16598 : :
16599 : : /* clear mbuf payload */
16600 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16601 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16602 : :
16603 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16604 : 2 : reference->plaintext.len);
16605 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16606 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16607 : :
16608 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16609 : 2 : reference->plaintext.len);
16610 : :
16611 : : /* Create operation */
16612 : : retval = create_auth_verify_GMAC_operation(ts_params,
16613 : : ut_params,
16614 : : reference);
16615 : :
16616 [ + - ]: 2 : if (retval < 0)
16617 : : return retval;
16618 : :
16619 [ + + ]: 2 : if (data_corrupted)
16620 : : data_corruption(plaintext);
16621 : : else
16622 : 1 : tag_corruption(plaintext, reference->aad.len);
16623 : :
16624 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16625 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16626 : : ut_params->op);
16627 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16628 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16629 : : "authentication not failed");
16630 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16631 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16632 : : 0);
16633 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16634 : 0 : return retval;
16635 : : } else {
16636 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16637 : : ut_params->op);
16638 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16639 : : }
16640 : :
16641 : : return 0;
16642 : : }
16643 : :
16644 : : static int
16645 : 2 : test_authenticated_decryption_fail_when_corruption(
16646 : : struct crypto_testsuite_params *ts_params,
16647 : : struct crypto_unittest_params *ut_params,
16648 : : const struct test_crypto_vector *reference,
16649 : : unsigned int data_corrupted)
16650 : : {
16651 : : int retval;
16652 : :
16653 : : uint8_t *ciphertext;
16654 : : struct rte_cryptodev_info dev_info;
16655 : :
16656 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16657 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16658 : :
16659 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16660 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16661 : : printf("Device doesn't support RAW data-path APIs.\n");
16662 : 0 : return TEST_SKIPPED;
16663 : : }
16664 : :
16665 : : /* Verify the capabilities */
16666 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16667 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16668 : 2 : cap_idx.algo.auth = reference->auth_algo;
16669 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16670 : : &cap_idx) == NULL)
16671 : : return TEST_SKIPPED;
16672 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16673 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
16674 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16675 : : &cap_idx) == NULL)
16676 : : return TEST_SKIPPED;
16677 : :
16678 : : /* Create session */
16679 : 2 : retval = create_auth_cipher_session(ut_params,
16680 : 2 : ts_params->valid_devs[0],
16681 : : reference,
16682 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16683 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16684 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16685 : : return TEST_SKIPPED;
16686 [ + - ]: 2 : if (retval < 0)
16687 : : return retval;
16688 : :
16689 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16690 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16691 : : "Failed to allocate input buffer in mempool");
16692 : :
16693 : : /* clear mbuf payload */
16694 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16695 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16696 : :
16697 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16698 : 2 : reference->ciphertext.len);
16699 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16700 : 2 : memcpy(ciphertext, reference->ciphertext.data,
16701 : 2 : reference->ciphertext.len);
16702 : :
16703 : : /* Create operation */
16704 : : retval = create_cipher_auth_verify_operation(ts_params,
16705 : : ut_params,
16706 : : reference);
16707 : :
16708 [ + - ]: 2 : if (retval < 0)
16709 : : return retval;
16710 : :
16711 [ + + ]: 2 : if (data_corrupted)
16712 : : data_corruption(ciphertext);
16713 : : else
16714 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
16715 : :
16716 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16717 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16718 : : ut_params->op);
16719 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16720 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16721 : : "authentication not failed");
16722 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16723 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16724 : : 0);
16725 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16726 : 0 : return retval;
16727 : : } else {
16728 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16729 : : ut_params->op);
16730 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16731 : : }
16732 : :
16733 : : return 0;
16734 : : }
16735 : :
16736 : : static int
16737 : 1 : test_authenticated_encrypt_with_esn(
16738 : : struct crypto_testsuite_params *ts_params,
16739 : : struct crypto_unittest_params *ut_params,
16740 : : const struct test_crypto_vector *reference)
16741 : : {
16742 : : int retval;
16743 : :
16744 : : uint8_t *authciphertext, *plaintext, *auth_tag;
16745 : : uint16_t plaintext_pad_len;
16746 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16747 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16748 : : struct rte_cryptodev_info dev_info;
16749 : :
16750 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16751 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16752 : :
16753 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16754 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16755 : : printf("Device doesn't support RAW data-path APIs.\n");
16756 : 0 : return TEST_SKIPPED;
16757 : : }
16758 : :
16759 : : /* Verify the capabilities */
16760 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16761 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16762 : 1 : cap_idx.algo.auth = reference->auth_algo;
16763 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16764 : : &cap_idx) == NULL)
16765 : : return TEST_SKIPPED;
16766 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16767 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16768 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16769 : : &cap_idx) == NULL)
16770 : : return TEST_SKIPPED;
16771 : :
16772 : : /* Create session */
16773 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16774 : 1 : reference->cipher_key.len);
16775 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16776 : :
16777 : : /* Setup Cipher Parameters */
16778 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16779 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16780 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16781 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16782 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16783 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16784 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16785 : :
16786 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
16787 : :
16788 : : /* Setup Authentication Parameters */
16789 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16790 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16791 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16792 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16793 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16794 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16795 : 1 : ut_params->auth_xform.next = NULL;
16796 : :
16797 : : /* Create Crypto session*/
16798 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16799 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
16800 : : ts_params->session_mpool);
16801 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16802 : : return TEST_SKIPPED;
16803 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16804 : :
16805 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16806 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16807 : : "Failed to allocate input buffer in mempool");
16808 : :
16809 : : /* clear mbuf payload */
16810 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16811 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16812 : :
16813 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16814 : 1 : reference->plaintext.len);
16815 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16816 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16817 : :
16818 : : /* Create operation */
16819 : 1 : retval = create_cipher_auth_operation(ts_params,
16820 : : ut_params,
16821 : : reference, 0);
16822 : :
16823 [ + - ]: 1 : if (retval < 0)
16824 : : return retval;
16825 : :
16826 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16827 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16828 : : ut_params->op);
16829 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16830 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16831 : : 0);
16832 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16833 : : return retval;
16834 : : } else
16835 : 1 : ut_params->op = process_crypto_request(
16836 : 1 : ts_params->valid_devs[0], ut_params->op);
16837 : :
16838 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16839 : :
16840 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16841 : : "crypto op processing failed");
16842 : :
16843 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16844 : :
16845 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16846 : : ut_params->op->sym->auth.data.offset);
16847 : 1 : auth_tag = authciphertext + plaintext_pad_len;
16848 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
16849 : 1 : reference->ciphertext.len);
16850 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16851 : :
16852 : : /* Validate obuf */
16853 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16854 : : authciphertext,
16855 : : reference->ciphertext.data,
16856 : : reference->ciphertext.len,
16857 : : "Ciphertext data not as expected");
16858 : :
16859 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16860 : : auth_tag,
16861 : : reference->digest.data,
16862 : : reference->digest.len,
16863 : : "Generated digest not as expected");
16864 : :
16865 : : return TEST_SUCCESS;
16866 : :
16867 : : }
16868 : :
16869 : : static int
16870 : 1 : test_authenticated_decrypt_with_esn(
16871 : : struct crypto_testsuite_params *ts_params,
16872 : : struct crypto_unittest_params *ut_params,
16873 : : const struct test_crypto_vector *reference)
16874 : : {
16875 : : int retval;
16876 : :
16877 : : uint8_t *ciphertext;
16878 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16879 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16880 : : struct rte_cryptodev_info dev_info;
16881 : :
16882 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16883 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16884 : :
16885 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16886 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16887 : : printf("Device doesn't support RAW data-path APIs.\n");
16888 : 0 : return TEST_SKIPPED;
16889 : : }
16890 : :
16891 : : /* Verify the capabilities */
16892 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16893 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16894 : 1 : cap_idx.algo.auth = reference->auth_algo;
16895 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16896 : : &cap_idx) == NULL)
16897 : : return TEST_SKIPPED;
16898 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16899 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16900 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16901 : : &cap_idx) == NULL)
16902 : : return TEST_SKIPPED;
16903 : :
16904 : : /* Create session */
16905 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16906 : 1 : reference->cipher_key.len);
16907 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16908 : :
16909 : : /* Setup Authentication Parameters */
16910 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16911 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16912 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16913 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16914 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16915 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16916 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16917 : :
16918 : : /* Setup Cipher Parameters */
16919 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16920 : 1 : ut_params->cipher_xform.next = NULL;
16921 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16922 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16923 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16924 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16925 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16926 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16927 : :
16928 : : /* Create Crypto session*/
16929 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16930 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
16931 : : ts_params->session_mpool);
16932 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16933 : : return TEST_SKIPPED;
16934 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16935 : :
16936 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16937 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16938 : : "Failed to allocate input buffer in mempool");
16939 : :
16940 : : /* clear mbuf payload */
16941 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16942 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16943 : :
16944 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16945 : 1 : reference->ciphertext.len);
16946 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16947 : 1 : memcpy(ciphertext, reference->ciphertext.data,
16948 : 1 : reference->ciphertext.len);
16949 : :
16950 : : /* Create operation */
16951 : : retval = create_cipher_auth_verify_operation(ts_params,
16952 : : ut_params,
16953 : : reference);
16954 : :
16955 [ + - ]: 1 : if (retval < 0)
16956 : : return retval;
16957 : :
16958 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16959 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16960 : : ut_params->op);
16961 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16962 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16963 : : 0);
16964 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16965 : : return retval;
16966 : : } else
16967 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16968 : : ut_params->op);
16969 : :
16970 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16971 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
16972 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16973 : : "crypto op processing passed");
16974 : :
16975 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
16976 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16977 : :
16978 : : return 0;
16979 : : }
16980 : :
16981 : : static int
16982 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16983 : : const struct aead_test_data *tdata,
16984 : : void *digest_mem, uint64_t digest_phys)
16985 : : {
16986 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16987 : : struct crypto_unittest_params *ut_params = &unittest_params;
16988 : :
16989 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
16990 : 1 : const unsigned int iv_len = tdata->iv.len;
16991 : 1 : unsigned int aad_len = tdata->aad.len;
16992 : : unsigned int aad_len_pad = 0;
16993 : :
16994 : : /* Generate Crypto op data structure */
16995 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16996 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16997 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
16998 : : "Failed to allocate symmetric crypto operation struct");
16999 : :
17000 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
17001 : :
17002 : 1 : sym_op->aead.digest.data = digest_mem;
17003 : :
17004 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
17005 : : "no room to append digest");
17006 : :
17007 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
17008 : :
17009 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
17010 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
17011 : : auth_tag_len);
17012 : 0 : debug_hexdump(stdout, "digest:",
17013 : 0 : sym_op->aead.digest.data,
17014 : : auth_tag_len);
17015 : : }
17016 : :
17017 : : /* Append aad data */
17018 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
17019 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17020 : : uint8_t *, IV_OFFSET);
17021 : :
17022 : : /* Copy IV 1 byte after the IV pointer, according to the API */
17023 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
17024 : :
17025 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
17026 : :
17027 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17028 : : ut_params->ibuf, aad_len);
17029 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17030 : : "no room to prepend aad");
17031 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17032 : : ut_params->ibuf);
17033 : :
17034 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
17035 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
17036 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17037 : :
17038 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17039 : 0 : debug_hexdump(stdout, "aad:",
17040 : 0 : sym_op->aead.aad.data, aad_len);
17041 : : } else {
17042 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17043 : : uint8_t *, IV_OFFSET);
17044 : :
17045 [ - + ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
17046 : :
17047 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
17048 : :
17049 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17050 : : ut_params->ibuf, aad_len_pad);
17051 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17052 : : "no room to prepend aad");
17053 [ - + ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17054 : : ut_params->ibuf);
17055 : :
17056 [ - + ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
17057 [ - + ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17058 : :
17059 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17060 : 1 : debug_hexdump(stdout, "aad:",
17061 : 1 : sym_op->aead.aad.data, aad_len);
17062 : : }
17063 : :
17064 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
17065 : 1 : sym_op->aead.data.offset = aad_len_pad;
17066 : :
17067 : 1 : return 0;
17068 : : }
17069 : :
17070 : : #define SGL_MAX_NO 16
17071 : :
17072 : : static int
17073 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
17074 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
17075 : : {
17076 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17077 : : struct crypto_unittest_params *ut_params = &unittest_params;
17078 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
17079 : : int retval;
17080 : : int to_trn = 0;
17081 : : int to_trn_tbl[SGL_MAX_NO];
17082 : : int segs = 1;
17083 : : unsigned int trn_data = 0;
17084 : : uint8_t *plaintext, *ciphertext, *auth_tag;
17085 : : struct rte_cryptodev_info dev_info;
17086 : :
17087 : : /* Verify the capabilities */
17088 : : struct rte_cryptodev_sym_capability_idx cap_idx;
17089 : : const struct rte_cryptodev_symmetric_capability *capability;
17090 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
17091 : 3 : cap_idx.algo.aead = tdata->algo;
17092 : 3 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
17093 [ + - ]: 3 : if (capability == NULL)
17094 : : return TEST_SKIPPED;
17095 [ + - ]: 3 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
17096 : 3 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
17097 : : return TEST_SKIPPED;
17098 : :
17099 : : /*
17100 : : * SGL not supported on AESNI_MB PMD CPU crypto,
17101 : : * OOP not supported on AESNI_GCM CPU crypto
17102 : : */
17103 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
17104 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
17105 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
17106 : : return TEST_SKIPPED;
17107 : :
17108 : : /* Detailed check for the particular SGL support flag */
17109 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
17110 [ - + ]: 3 : if (!oop) {
17111 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17112 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
17113 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
17114 : : return TEST_SKIPPED;
17115 : :
17116 : 0 : uint64_t feat_flags = dev_info.feature_flags;
17117 : :
17118 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
17119 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
17120 : : printf("Device doesn't support RAW data-path APIs.\n");
17121 : 0 : return TEST_SKIPPED;
17122 : : }
17123 : : } else {
17124 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17125 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
17126 : : tdata->plaintext.len;
17127 : : /* Raw data path API does not support OOP */
17128 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
17129 : : return TEST_SKIPPED;
17130 [ + + ]: 3 : if (sgl_in && !sgl_out) {
17131 [ + - ]: 1 : if (!(dev_info.feature_flags &
17132 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
17133 : : return TEST_SKIPPED;
17134 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
17135 [ # # ]: 0 : if (!(dev_info.feature_flags &
17136 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
17137 : : return TEST_SKIPPED;
17138 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
17139 [ - + ]: 2 : if (!(dev_info.feature_flags &
17140 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
17141 : : return TEST_SKIPPED;
17142 : : }
17143 : : }
17144 : :
17145 : 1 : if (fragsz > tdata->plaintext.len)
17146 : : fragsz = tdata->plaintext.len;
17147 : :
17148 : 1 : uint16_t plaintext_len = fragsz;
17149 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
17150 : :
17151 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
17152 : 0 : frag_size_oop = tdata->plaintext.len;
17153 : :
17154 : : int ecx = 0;
17155 : : void *digest_mem = NULL;
17156 : :
17157 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
17158 : :
17159 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
17160 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
17161 : : return 1;
17162 : : } else {
17163 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
17164 : : return 1;
17165 : : }
17166 : :
17167 : : /*
17168 : : * For out-of-place we need to alloc another mbuf
17169 : : */
17170 [ + - ]: 1 : if (oop) {
17171 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17172 : : rte_pktmbuf_append(ut_params->obuf,
17173 : 1 : frag_size_oop + prepend_len);
17174 : 1 : buf_oop = ut_params->obuf;
17175 : : }
17176 : :
17177 : : /* Create AEAD session */
17178 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
17179 : 1 : tdata->algo,
17180 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
17181 : 1 : tdata->key.data, tdata->key.len,
17182 : 1 : tdata->aad.len, tdata->auth_tag.len,
17183 : 1 : tdata->iv.len);
17184 [ + - ]: 1 : if (retval < 0)
17185 : : return retval;
17186 : :
17187 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17188 : :
17189 : : /* clear mbuf payload */
17190 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
17191 : : rte_pktmbuf_tailroom(ut_params->ibuf));
17192 : :
17193 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17194 : : plaintext_len);
17195 : :
17196 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
17197 : :
17198 : : trn_data += plaintext_len;
17199 : :
17200 : 1 : buf = ut_params->ibuf;
17201 : :
17202 : : /*
17203 : : * Loop until no more fragments
17204 : : */
17205 : :
17206 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
17207 : 5 : ++segs;
17208 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
17209 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
17210 : :
17211 : 5 : to_trn_tbl[ecx++] = to_trn;
17212 : :
17213 [ - + ]: 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17214 : : buf = buf->next;
17215 : :
17216 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
17217 : : rte_pktmbuf_tailroom(buf));
17218 : :
17219 : : /* OOP */
17220 [ - + ]: 5 : if (oop && !fragsz_oop) {
17221 : 0 : buf_last_oop = buf_oop->next =
17222 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17223 : : buf_oop = buf_oop->next;
17224 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17225 : : 0, rte_pktmbuf_tailroom(buf_oop));
17226 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
17227 : : }
17228 : :
17229 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
17230 : : to_trn);
17231 : :
17232 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
17233 : : to_trn);
17234 : 5 : trn_data += to_trn;
17235 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
17236 [ + - ]: 1 : if (oop) {
17237 [ - + ]: 1 : if (!fragsz_oop)
17238 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
17239 : 0 : tdata->auth_tag.len);
17240 : : } else
17241 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
17242 : 0 : tdata->auth_tag.len);
17243 : : }
17244 : : }
17245 : :
17246 : : uint64_t digest_phys = 0;
17247 : :
17248 : 1 : ut_params->ibuf->nb_segs = segs;
17249 : :
17250 : : segs = 1;
17251 [ + - ]: 1 : if (fragsz_oop && oop) {
17252 : : to_trn = 0;
17253 : : ecx = 0;
17254 : :
17255 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
17256 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17257 : 1 : tdata->auth_tag.len);
17258 : :
17259 : 1 : digest_phys = rte_pktmbuf_iova_offset(
17260 : : ut_params->obuf,
17261 : : tdata->plaintext.len + prepend_len);
17262 : : }
17263 : :
17264 : : trn_data = frag_size_oop;
17265 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
17266 : 0 : ++segs;
17267 : 0 : to_trn =
17268 : 0 : (tdata->plaintext.len - trn_data <
17269 : : frag_size_oop) ?
17270 : 0 : (tdata->plaintext.len - trn_data) :
17271 : : frag_size_oop;
17272 : :
17273 : 0 : to_trn_tbl[ecx++] = to_trn;
17274 : :
17275 : 0 : buf_last_oop = buf_oop->next =
17276 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17277 : : buf_oop = buf_oop->next;
17278 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17279 : : 0, rte_pktmbuf_tailroom(buf_oop));
17280 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
17281 : :
17282 : 0 : trn_data += to_trn;
17283 : :
17284 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
17285 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
17286 : 0 : tdata->auth_tag.len);
17287 : : }
17288 : : }
17289 : :
17290 : 1 : ut_params->obuf->nb_segs = segs;
17291 : : }
17292 : :
17293 : : /*
17294 : : * Place digest at the end of the last buffer
17295 : : */
17296 [ - + ]: 1 : if (!digest_phys)
17297 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
17298 [ - + ]: 1 : if (oop && buf_last_oop)
17299 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
17300 : :
17301 [ - + ]: 1 : if (!digest_mem && !oop) {
17302 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17303 : 0 : + tdata->auth_tag.len);
17304 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
17305 : : tdata->plaintext.len);
17306 : : }
17307 : :
17308 : : /* Create AEAD operation */
17309 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
17310 : : tdata, digest_mem, digest_phys);
17311 : :
17312 [ + - ]: 1 : if (retval < 0)
17313 : : return retval;
17314 : :
17315 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
17316 : :
17317 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
17318 [ + - ]: 1 : if (oop)
17319 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
17320 : :
17321 : : /* Process crypto operation */
17322 [ - + ]: 1 : if (oop == IN_PLACE &&
17323 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17324 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
17325 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17326 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
17327 : : 0);
17328 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17329 : : return retval;
17330 : : } else
17331 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
17332 : : process_crypto_request(ts_params->valid_devs[0],
17333 : : ut_params->op), "failed to process sym crypto op");
17334 : :
17335 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17336 : : "crypto op processing failed");
17337 : :
17338 : :
17339 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17340 : : uint8_t *, prepend_len);
17341 [ + - ]: 1 : if (oop) {
17342 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17343 : : uint8_t *, prepend_len);
17344 : : }
17345 : :
17346 [ + - ]: 1 : if (fragsz_oop)
17347 : : fragsz = fragsz_oop;
17348 : :
17349 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17350 : : ciphertext,
17351 : : tdata->ciphertext.data,
17352 : : fragsz,
17353 : : "Ciphertext data not as expected");
17354 : :
17355 : 1 : buf = ut_params->op->sym->m_src->next;
17356 [ + - ]: 1 : if (oop)
17357 : 1 : buf = ut_params->op->sym->m_dst->next;
17358 : :
17359 : : unsigned int off = fragsz;
17360 : :
17361 : : ecx = 0;
17362 [ - + ]: 1 : while (buf) {
17363 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
17364 : : uint8_t *);
17365 : :
17366 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17367 : : ciphertext,
17368 : : tdata->ciphertext.data + off,
17369 : : to_trn_tbl[ecx],
17370 : : "Ciphertext data not as expected");
17371 : :
17372 : 0 : off += to_trn_tbl[ecx++];
17373 : 0 : buf = buf->next;
17374 : : }
17375 : :
17376 : : auth_tag = digest_mem;
17377 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17378 : : auth_tag,
17379 : : tdata->auth_tag.data,
17380 : : tdata->auth_tag.len,
17381 : : "Generated auth tag not as expected");
17382 : :
17383 : : return 0;
17384 : : }
17385 : :
17386 : : static int
17387 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17388 : : {
17389 : 1 : return test_authenticated_encryption_SGL(
17390 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17391 : : }
17392 : :
17393 : : static int
17394 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17395 : : {
17396 : 1 : return test_authenticated_encryption_SGL(
17397 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17398 : : }
17399 : :
17400 : : static int
17401 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17402 : : {
17403 : 1 : return test_authenticated_encryption_SGL(
17404 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
17405 : : gcm_test_case_8.plaintext.len);
17406 : : }
17407 : :
17408 : : static int
17409 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17410 : : {
17411 : : /* This test is not for OPENSSL PMD */
17412 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17413 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17414 : : return TEST_SKIPPED;
17415 : :
17416 : 0 : return test_authenticated_encryption_SGL(
17417 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17418 : : }
17419 : :
17420 : : static int
17421 : : test_authentication_verify_fail_when_data_corrupted(
17422 : : struct crypto_testsuite_params *ts_params,
17423 : : struct crypto_unittest_params *ut_params,
17424 : : const struct test_crypto_vector *reference)
17425 : : {
17426 : 1 : return test_authentication_verify_fail_when_data_corruption(
17427 : : ts_params, ut_params, reference, 1);
17428 : : }
17429 : :
17430 : : static int
17431 : : test_authentication_verify_fail_when_tag_corrupted(
17432 : : struct crypto_testsuite_params *ts_params,
17433 : : struct crypto_unittest_params *ut_params,
17434 : : const struct test_crypto_vector *reference)
17435 : : {
17436 : 1 : return test_authentication_verify_fail_when_data_corruption(
17437 : : ts_params, ut_params, reference, 0);
17438 : : }
17439 : :
17440 : : static int
17441 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
17442 : : struct crypto_testsuite_params *ts_params,
17443 : : struct crypto_unittest_params *ut_params,
17444 : : const struct test_crypto_vector *reference)
17445 : : {
17446 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17447 : : ts_params, ut_params, reference, 1);
17448 : : }
17449 : :
17450 : : static int
17451 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
17452 : : struct crypto_testsuite_params *ts_params,
17453 : : struct crypto_unittest_params *ut_params,
17454 : : const struct test_crypto_vector *reference)
17455 : : {
17456 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17457 : : ts_params, ut_params, reference, 0);
17458 : : }
17459 : :
17460 : : static int
17461 : : test_authenticated_decryption_fail_when_data_corrupted(
17462 : : struct crypto_testsuite_params *ts_params,
17463 : : struct crypto_unittest_params *ut_params,
17464 : : const struct test_crypto_vector *reference)
17465 : : {
17466 : 1 : return test_authenticated_decryption_fail_when_corruption(
17467 : : ts_params, ut_params, reference, 1);
17468 : : }
17469 : :
17470 : : static int
17471 : : test_authenticated_decryption_fail_when_tag_corrupted(
17472 : : struct crypto_testsuite_params *ts_params,
17473 : : struct crypto_unittest_params *ut_params,
17474 : : const struct test_crypto_vector *reference)
17475 : : {
17476 : 1 : return test_authenticated_decryption_fail_when_corruption(
17477 : : ts_params, ut_params, reference, 0);
17478 : : }
17479 : :
17480 : : static int
17481 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17482 : : {
17483 : 1 : return test_authentication_verify_fail_when_data_corrupted(
17484 : : &testsuite_params, &unittest_params,
17485 : : &hmac_sha1_test_crypto_vector);
17486 : : }
17487 : :
17488 : : static int
17489 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17490 : : {
17491 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
17492 : : &testsuite_params, &unittest_params,
17493 : : &hmac_sha1_test_crypto_vector);
17494 : : }
17495 : :
17496 : : static int
17497 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17498 : : {
17499 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
17500 : : &testsuite_params, &unittest_params,
17501 : : &aes128_gmac_test_vector);
17502 : : }
17503 : :
17504 : : static int
17505 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17506 : : {
17507 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17508 : : &testsuite_params, &unittest_params,
17509 : : &aes128_gmac_test_vector);
17510 : : }
17511 : :
17512 : : static int
17513 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17514 : : {
17515 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
17516 : : &testsuite_params,
17517 : : &unittest_params,
17518 : : &aes128cbc_hmac_sha1_test_vector);
17519 : : }
17520 : :
17521 : : static int
17522 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17523 : : {
17524 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
17525 : : &testsuite_params,
17526 : : &unittest_params,
17527 : : &aes128cbc_hmac_sha1_test_vector);
17528 : : }
17529 : :
17530 : : static int
17531 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17532 : : {
17533 : 1 : return test_authenticated_encrypt_with_esn(
17534 : : &testsuite_params,
17535 : : &unittest_params,
17536 : : &aes128cbc_hmac_sha1_aad_test_vector);
17537 : : }
17538 : :
17539 : : static int
17540 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17541 : : {
17542 : 1 : return test_authenticated_decrypt_with_esn(
17543 : : &testsuite_params,
17544 : : &unittest_params,
17545 : : &aes128cbc_hmac_sha1_aad_test_vector);
17546 : : }
17547 : :
17548 : : static int
17549 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17550 : : {
17551 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17552 : : }
17553 : :
17554 : : static int
17555 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17556 : : {
17557 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17558 : : }
17559 : :
17560 : : static int
17561 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17562 : : {
17563 : 0 : return test_authenticated_encryption_SGL(
17564 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17565 : : chacha20_poly1305_case_2.plaintext.len);
17566 : : }
17567 : :
17568 : : static int
17569 : 0 : test_SM4_GCM_case_1(void)
17570 : : {
17571 : 0 : return test_authenticated_encryption(&sm4_gcm_case_1);
17572 : : }
17573 : :
17574 : : static int
17575 : 0 : test_SM4_GCM_case_2(void)
17576 : : {
17577 : 0 : return test_authenticated_encryption(&sm4_gcm_case_2);
17578 : : }
17579 : :
17580 : : static int
17581 : 0 : test_SM4_GCM_case_3(void)
17582 : : {
17583 : 0 : return test_authenticated_encryption(&sm4_gcm_case_3);
17584 : : }
17585 : :
17586 : : static int
17587 : 0 : test_SM4_GCM_case_4(void)
17588 : : {
17589 : 0 : return test_authenticated_encryption(&sm4_gcm_case_4);
17590 : : }
17591 : :
17592 : : static int
17593 : 0 : test_SM4_GCM_case_5(void)
17594 : : {
17595 : 0 : return test_authenticated_encryption(&sm4_gcm_case_5);
17596 : : }
17597 : :
17598 : : static int
17599 : 0 : test_SM4_GCM_case_6(void)
17600 : : {
17601 : 0 : return test_authenticated_encryption(&sm4_gcm_case_6);
17602 : : }
17603 : :
17604 : : static int
17605 : 0 : test_SM4_GCM_case_7(void)
17606 : : {
17607 : 0 : return test_authenticated_encryption(&sm4_gcm_case_7);
17608 : : }
17609 : :
17610 : : static int
17611 : 0 : test_SM4_GCM_case_8(void)
17612 : : {
17613 : 0 : return test_authenticated_encryption(&sm4_gcm_case_8);
17614 : : }
17615 : :
17616 : : static int
17617 : 0 : test_SM4_GCM_case_9(void)
17618 : : {
17619 : 0 : return test_authenticated_encryption(&sm4_gcm_case_9);
17620 : : }
17621 : :
17622 : : static int
17623 : 0 : test_SM4_GCM_case_10(void)
17624 : : {
17625 : 0 : return test_authenticated_encryption(&sm4_gcm_case_10);
17626 : : }
17627 : :
17628 : : static int
17629 : 0 : test_SM4_GCM_case_11(void)
17630 : : {
17631 : 0 : return test_authenticated_encryption(&sm4_gcm_case_11);
17632 : : }
17633 : :
17634 : : static int
17635 : 0 : test_SM4_GCM_case_12(void)
17636 : : {
17637 : 0 : return test_authenticated_encryption(&sm4_gcm_case_12);
17638 : : }
17639 : :
17640 : : static int
17641 : 0 : test_SM4_GCM_case_13(void)
17642 : : {
17643 : 0 : return test_authenticated_encryption(&sm4_gcm_case_13);
17644 : : }
17645 : :
17646 : : static int
17647 : 0 : test_SM4_GCM_case_14(void)
17648 : : {
17649 : 0 : return test_authenticated_encryption(&sm4_gcm_case_14);
17650 : : }
17651 : :
17652 : : static int
17653 : 0 : test_SM4_GCM_case_15(void)
17654 : : {
17655 : 0 : return test_authenticated_encryption(&sm4_gcm_case_15);
17656 : : }
17657 : :
17658 : : #ifdef RTE_CRYPTO_SCHEDULER
17659 : :
17660 : : /* global AESNI worker IDs for the scheduler test */
17661 : : uint8_t aesni_ids[2];
17662 : :
17663 : : static int
17664 : 0 : scheduler_testsuite_setup(void)
17665 : : {
17666 : : uint32_t i = 0;
17667 : : int32_t nb_devs, ret;
17668 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
17669 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17670 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
17671 : : uint16_t worker_core_count = 0;
17672 : : uint16_t socket_id = 0;
17673 : :
17674 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17675 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17676 : :
17677 : : /* Identify the Worker Cores
17678 : : * Use 2 worker cores for the device args
17679 : : */
17680 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
17681 [ # # ]: 0 : if (worker_core_count > 1)
17682 : : break;
17683 : : snprintf(vdev_args, sizeof(vdev_args),
17684 : : "%s%d", temp_str, i);
17685 : : strcpy(temp_str, vdev_args);
17686 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
17687 : 0 : worker_core_count++;
17688 : 0 : socket_id = rte_lcore_to_socket_id(i);
17689 : : }
17690 [ # # ]: 0 : if (worker_core_count != 2) {
17691 : 0 : RTE_LOG(ERR, USER1,
17692 : : "Cryptodev scheduler test require at least "
17693 : : "two worker cores to run. "
17694 : : "Please use the correct coremask.\n");
17695 : 0 : return TEST_FAILED;
17696 : : }
17697 : : strcpy(temp_str, vdev_args);
17698 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
17699 : : temp_str, socket_id);
17700 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17701 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
17702 : 0 : rte_cryptodev_driver_id_get(
17703 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17704 [ # # ]: 0 : if (nb_devs < 1) {
17705 : 0 : ret = rte_vdev_init(
17706 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17707 : : vdev_args);
17708 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17709 : : "Failed to create instance %u of pmd : %s",
17710 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17711 : : }
17712 : : }
17713 : 0 : return testsuite_setup();
17714 : : }
17715 : :
17716 : : static int
17717 : 0 : test_scheduler_attach_worker_op(void)
17718 : : {
17719 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17720 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17721 : : uint32_t i, nb_devs_attached = 0;
17722 : : int ret;
17723 : : char vdev_name[32];
17724 : 0 : unsigned int count = rte_cryptodev_count();
17725 : :
17726 : : /* create 2 AESNI_MB vdevs on top of existing devices */
17727 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17728 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17729 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17730 : : i);
17731 : 0 : ret = rte_vdev_init(vdev_name, NULL);
17732 : :
17733 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17734 : : "Failed to create instance %u of"
17735 : : " pmd : %s",
17736 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17737 : :
17738 : : if (ret < 0) {
17739 : : RTE_LOG(ERR, USER1,
17740 : : "Failed to create 2 AESNI MB PMDs.\n");
17741 : : return TEST_SKIPPED;
17742 : : }
17743 : : }
17744 : :
17745 : : /* attach 2 AESNI_MB cdevs */
17746 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17747 : : struct rte_cryptodev_info info;
17748 : : unsigned int session_size;
17749 : :
17750 : 0 : rte_cryptodev_info_get(i, &info);
17751 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
17752 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17753 : 0 : continue;
17754 : :
17755 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
17756 : : /*
17757 : : * Create the session mempool again, since now there are new devices
17758 : : * to use the mempool.
17759 : : */
17760 [ # # ]: 0 : if (ts_params->session_mpool) {
17761 : 0 : rte_mempool_free(ts_params->session_mpool);
17762 : 0 : ts_params->session_mpool = NULL;
17763 : : }
17764 : :
17765 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
17766 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17767 : 0 : RTE_LOG(ERR, USER1,
17768 : : "Device does not support "
17769 : : "at least %u sessions\n",
17770 : : MAX_NB_SESSIONS);
17771 : 0 : return TEST_FAILED;
17772 : : }
17773 : : /*
17774 : : * Create mempool with maximum number of sessions,
17775 : : * to include the session headers
17776 : : */
17777 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
17778 : 0 : ts_params->session_mpool =
17779 : 0 : rte_cryptodev_sym_session_pool_create(
17780 : : "test_sess_mp",
17781 : : MAX_NB_SESSIONS, session_size,
17782 : : 0, 0, SOCKET_ID_ANY);
17783 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17784 : : "session mempool allocation failed");
17785 : : }
17786 : :
17787 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
17788 : :
17789 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17790 : : (uint8_t)i);
17791 : :
17792 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17793 : : "Failed to attach device %u of pmd : %s", i,
17794 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17795 : :
17796 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
17797 : :
17798 : 0 : nb_devs_attached++;
17799 : : }
17800 : :
17801 : : return 0;
17802 : : }
17803 : :
17804 : : static int
17805 : 0 : test_scheduler_detach_worker_op(void)
17806 : : {
17807 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17808 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17809 : : uint32_t i;
17810 : : int ret;
17811 : :
17812 [ # # ]: 0 : for (i = 0; i < 2; i++) {
17813 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17814 : 0 : aesni_ids[i]);
17815 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17816 : : "Failed to detach device %u", aesni_ids[i]);
17817 : : }
17818 : :
17819 : : return 0;
17820 : : }
17821 : :
17822 : : static int
17823 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17824 : : {
17825 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17826 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17827 : : /* set mode */
17828 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
17829 : : scheduler_mode);
17830 : : }
17831 : :
17832 : : static int
17833 : 0 : test_scheduler_mode_roundrobin_op(void)
17834 : : {
17835 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17836 : : 0, "Failed to set roundrobin mode");
17837 : : return 0;
17838 : :
17839 : : }
17840 : :
17841 : : static int
17842 : 0 : test_scheduler_mode_multicore_op(void)
17843 : : {
17844 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17845 : : 0, "Failed to set multicore mode");
17846 : :
17847 : : return 0;
17848 : : }
17849 : :
17850 : : static int
17851 : 0 : test_scheduler_mode_failover_op(void)
17852 : : {
17853 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17854 : : 0, "Failed to set failover mode");
17855 : :
17856 : : return 0;
17857 : : }
17858 : :
17859 : : static int
17860 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
17861 : : {
17862 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17863 : : 0, "Failed to set pktsize mode");
17864 : :
17865 : : return 0;
17866 : : }
17867 : :
17868 : : static int
17869 : 0 : scheduler_multicore_testsuite_setup(void)
17870 : : {
17871 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17872 : : return TEST_SKIPPED;
17873 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17874 : 0 : return TEST_SKIPPED;
17875 : : return 0;
17876 : : }
17877 : :
17878 : : static int
17879 : 0 : scheduler_roundrobin_testsuite_setup(void)
17880 : : {
17881 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17882 : : return TEST_SKIPPED;
17883 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17884 : 0 : return TEST_SKIPPED;
17885 : : return 0;
17886 : : }
17887 : :
17888 : : static int
17889 : 0 : scheduler_failover_testsuite_setup(void)
17890 : : {
17891 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17892 : : return TEST_SKIPPED;
17893 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17894 : 0 : return TEST_SKIPPED;
17895 : : return 0;
17896 : : }
17897 : :
17898 : : static int
17899 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
17900 : : {
17901 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17902 : : return TEST_SKIPPED;
17903 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17904 : 0 : return TEST_SKIPPED;
17905 : : return 0;
17906 : : }
17907 : :
17908 : : static void
17909 : 0 : scheduler_mode_testsuite_teardown(void)
17910 : : {
17911 : 0 : test_scheduler_detach_worker_op();
17912 : 0 : }
17913 : :
17914 : : #endif /* RTE_CRYPTO_SCHEDULER */
17915 : :
17916 : : static struct unit_test_suite end_testsuite = {
17917 : : .suite_name = NULL,
17918 : : .setup = NULL,
17919 : : .teardown = NULL,
17920 : : .unit_test_suites = NULL
17921 : : };
17922 : :
17923 : : #ifdef RTE_LIB_SECURITY
17924 : : static struct unit_test_suite ipsec_proto_testsuite = {
17925 : : .suite_name = "IPsec Proto Unit Test Suite",
17926 : : .setup = ipsec_proto_testsuite_setup,
17927 : : .unit_test_cases = {
17928 : : TEST_CASE_NAMED_WITH_DATA(
17929 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17930 : : ut_setup_security, ut_teardown,
17931 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17932 : : TEST_CASE_NAMED_WITH_DATA(
17933 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17934 : : ut_setup_security, ut_teardown,
17935 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17936 : : TEST_CASE_NAMED_WITH_DATA(
17937 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17938 : : ut_setup_security, ut_teardown,
17939 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17940 : : TEST_CASE_NAMED_WITH_DATA(
17941 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17942 : : ut_setup_security, ut_teardown,
17943 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17944 : : TEST_CASE_NAMED_WITH_DATA(
17945 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17946 : : ut_setup_security, ut_teardown,
17947 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17948 : : TEST_CASE_NAMED_WITH_DATA(
17949 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17950 : : ut_setup_security, ut_teardown,
17951 : : test_ipsec_proto_known_vec,
17952 : : &pkt_aes_128_cbc_md5),
17953 : : TEST_CASE_NAMED_WITH_DATA(
17954 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
17955 : : ut_setup_security, ut_teardown,
17956 : : test_ipsec_proto_known_vec,
17957 : : &pkt_aes_128_ctr_hmac_sha256),
17958 : : TEST_CASE_NAMED_WITH_DATA(
17959 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
17960 : : ut_setup_security, ut_teardown,
17961 : : test_ipsec_proto_known_vec,
17962 : : &pkt_aes_128_ctr_hmac_sha384),
17963 : : TEST_CASE_NAMED_WITH_DATA(
17964 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
17965 : : ut_setup_security, ut_teardown,
17966 : : test_ipsec_proto_known_vec,
17967 : : &pkt_aes_128_ctr_hmac_sha512),
17968 : : TEST_CASE_NAMED_WITH_DATA(
17969 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
17970 : : ut_setup_security, ut_teardown,
17971 : : test_ipsec_proto_known_vec_inb,
17972 : : &pkt_aes_128_ctr_hmac_sha256),
17973 : : TEST_CASE_NAMED_WITH_DATA(
17974 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
17975 : : ut_setup_security, ut_teardown,
17976 : : test_ipsec_proto_known_vec_inb,
17977 : : &pkt_aes_128_ctr_hmac_sha384),
17978 : : TEST_CASE_NAMED_WITH_DATA(
17979 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
17980 : : ut_setup_security, ut_teardown,
17981 : : test_ipsec_proto_known_vec_inb,
17982 : : &pkt_aes_128_ctr_hmac_sha512),
17983 : : TEST_CASE_NAMED_WITH_DATA(
17984 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17985 : : ut_setup_security, ut_teardown,
17986 : : test_ipsec_proto_known_vec,
17987 : : &pkt_aes_128_cbc_hmac_sha256),
17988 : : TEST_CASE_NAMED_WITH_DATA(
17989 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17990 : : ut_setup_security, ut_teardown,
17991 : : test_ipsec_proto_known_vec,
17992 : : &pkt_aes_128_cbc_hmac_sha384),
17993 : : TEST_CASE_NAMED_WITH_DATA(
17994 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17995 : : ut_setup_security, ut_teardown,
17996 : : test_ipsec_proto_known_vec,
17997 : : &pkt_aes_128_cbc_hmac_sha512),
17998 : : TEST_CASE_NAMED_WITH_DATA(
17999 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18000 : : ut_setup_security, ut_teardown,
18001 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
18002 : : TEST_CASE_NAMED_WITH_DATA(
18003 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18004 : : ut_setup_security, ut_teardown,
18005 : : test_ipsec_proto_known_vec,
18006 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18007 : : TEST_CASE_NAMED_WITH_DATA(
18008 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18009 : : ut_setup_security, ut_teardown,
18010 : : test_ipsec_proto_known_vec,
18011 : : &pkt_null_aes_xcbc),
18012 : : TEST_CASE_NAMED_WITH_DATA(
18013 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18014 : : ut_setup_security, ut_teardown,
18015 : : test_ipsec_proto_known_vec,
18016 : : &pkt_des_cbc_hmac_sha256),
18017 : : TEST_CASE_NAMED_WITH_DATA(
18018 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18019 : : ut_setup_security, ut_teardown,
18020 : : test_ipsec_proto_known_vec,
18021 : : &pkt_des_cbc_hmac_sha384),
18022 : : TEST_CASE_NAMED_WITH_DATA(
18023 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18024 : : ut_setup_security, ut_teardown,
18025 : : test_ipsec_proto_known_vec,
18026 : : &pkt_des_cbc_hmac_sha512),
18027 : : TEST_CASE_NAMED_WITH_DATA(
18028 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18029 : : ut_setup_security, ut_teardown,
18030 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
18031 : : TEST_CASE_NAMED_WITH_DATA(
18032 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18033 : : ut_setup_security, ut_teardown,
18034 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
18035 : : TEST_CASE_NAMED_WITH_DATA(
18036 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18037 : : ut_setup_security, ut_teardown,
18038 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
18039 : : TEST_CASE_NAMED_WITH_DATA(
18040 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18041 : : ut_setup_security, ut_teardown,
18042 : : test_ipsec_proto_known_vec,
18043 : : &pkt_des_cbc_hmac_sha256_v6),
18044 : : TEST_CASE_NAMED_WITH_DATA(
18045 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18046 : : ut_setup_security, ut_teardown,
18047 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
18048 : : TEST_CASE_NAMED_WITH_DATA(
18049 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18050 : : ut_setup_security, ut_teardown,
18051 : : test_ipsec_proto_known_vec,
18052 : : &pkt_ah_tunnel_sha256),
18053 : : TEST_CASE_NAMED_WITH_DATA(
18054 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18055 : : ut_setup_security, ut_teardown,
18056 : : test_ipsec_proto_known_vec,
18057 : : &pkt_ah_transport_sha256),
18058 : : TEST_CASE_NAMED_WITH_DATA(
18059 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18060 : : ut_setup_security, ut_teardown,
18061 : : test_ipsec_proto_known_vec,
18062 : : &pkt_ah_ipv4_aes_gmac_128),
18063 : : TEST_CASE_NAMED_WITH_DATA(
18064 : : "Outbound fragmented packet",
18065 : : ut_setup_security, ut_teardown,
18066 : : test_ipsec_proto_known_vec_fragmented,
18067 : : &pkt_aes_128_gcm_frag),
18068 : : TEST_CASE_NAMED_WITH_DATA(
18069 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
18070 : : ut_setup_security, ut_teardown,
18071 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
18072 : : TEST_CASE_NAMED_WITH_DATA(
18073 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
18074 : : ut_setup_security, ut_teardown,
18075 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
18076 : : TEST_CASE_NAMED_WITH_DATA(
18077 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
18078 : : ut_setup_security, ut_teardown,
18079 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
18080 : : TEST_CASE_NAMED_WITH_DATA(
18081 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
18082 : : ut_setup_security, ut_teardown,
18083 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
18084 : : TEST_CASE_NAMED_WITH_DATA(
18085 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
18086 : : ut_setup_security, ut_teardown,
18087 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
18088 : : TEST_CASE_NAMED_WITH_DATA(
18089 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
18090 : : ut_setup_security, ut_teardown,
18091 : : test_ipsec_proto_known_vec_inb,
18092 : : &pkt_aes_128_cbc_md5),
18093 : : TEST_CASE_NAMED_WITH_DATA(
18094 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18095 : : ut_setup_security, ut_teardown,
18096 : : test_ipsec_proto_known_vec_inb,
18097 : : &pkt_aes_128_cbc_hmac_sha256),
18098 : : TEST_CASE_NAMED_WITH_DATA(
18099 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18100 : : ut_setup_security, ut_teardown,
18101 : : test_ipsec_proto_known_vec_inb,
18102 : : &pkt_aes_128_cbc_hmac_sha384),
18103 : : TEST_CASE_NAMED_WITH_DATA(
18104 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18105 : : ut_setup_security, ut_teardown,
18106 : : test_ipsec_proto_known_vec_inb,
18107 : : &pkt_aes_128_cbc_hmac_sha512),
18108 : : TEST_CASE_NAMED_WITH_DATA(
18109 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18110 : : ut_setup_security, ut_teardown,
18111 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
18112 : : TEST_CASE_NAMED_WITH_DATA(
18113 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18114 : : ut_setup_security, ut_teardown,
18115 : : test_ipsec_proto_known_vec_inb,
18116 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18117 : : TEST_CASE_NAMED_WITH_DATA(
18118 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18119 : : ut_setup_security, ut_teardown,
18120 : : test_ipsec_proto_known_vec_inb,
18121 : : &pkt_null_aes_xcbc),
18122 : : TEST_CASE_NAMED_WITH_DATA(
18123 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18124 : : ut_setup_security, ut_teardown,
18125 : : test_ipsec_proto_known_vec_inb,
18126 : : &pkt_des_cbc_hmac_sha256),
18127 : : TEST_CASE_NAMED_WITH_DATA(
18128 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18129 : : ut_setup_security, ut_teardown,
18130 : : test_ipsec_proto_known_vec_inb,
18131 : : &pkt_des_cbc_hmac_sha384),
18132 : : TEST_CASE_NAMED_WITH_DATA(
18133 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18134 : : ut_setup_security, ut_teardown,
18135 : : test_ipsec_proto_known_vec_inb,
18136 : : &pkt_des_cbc_hmac_sha512),
18137 : : TEST_CASE_NAMED_WITH_DATA(
18138 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18139 : : ut_setup_security, ut_teardown,
18140 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
18141 : : TEST_CASE_NAMED_WITH_DATA(
18142 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18143 : : ut_setup_security, ut_teardown,
18144 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
18145 : : TEST_CASE_NAMED_WITH_DATA(
18146 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18147 : : ut_setup_security, ut_teardown,
18148 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
18149 : : TEST_CASE_NAMED_WITH_DATA(
18150 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18151 : : ut_setup_security, ut_teardown,
18152 : : test_ipsec_proto_known_vec_inb,
18153 : : &pkt_des_cbc_hmac_sha256_v6),
18154 : : TEST_CASE_NAMED_WITH_DATA(
18155 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18156 : : ut_setup_security, ut_teardown,
18157 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
18158 : : TEST_CASE_NAMED_WITH_DATA(
18159 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18160 : : ut_setup_security, ut_teardown,
18161 : : test_ipsec_proto_known_vec_inb,
18162 : : &pkt_ah_tunnel_sha256),
18163 : : TEST_CASE_NAMED_WITH_DATA(
18164 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18165 : : ut_setup_security, ut_teardown,
18166 : : test_ipsec_proto_known_vec_inb,
18167 : : &pkt_ah_transport_sha256),
18168 : : TEST_CASE_NAMED_WITH_DATA(
18169 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18170 : : ut_setup_security, ut_teardown,
18171 : : test_ipsec_proto_known_vec_inb,
18172 : : &pkt_ah_ipv4_aes_gmac_128),
18173 : : TEST_CASE_NAMED_ST(
18174 : : "Combined test alg list",
18175 : : ut_setup_security, ut_teardown,
18176 : : test_ipsec_proto_display_list),
18177 : : TEST_CASE_NAMED_ST(
18178 : : "Combined test alg list (AH)",
18179 : : ut_setup_security, ut_teardown,
18180 : : test_ipsec_proto_ah_tunnel_ipv4),
18181 : : TEST_CASE_NAMED_ST(
18182 : : "IV generation",
18183 : : ut_setup_security, ut_teardown,
18184 : : test_ipsec_proto_iv_gen),
18185 : : TEST_CASE_NAMED_ST(
18186 : : "UDP encapsulation",
18187 : : ut_setup_security, ut_teardown,
18188 : : test_ipsec_proto_udp_encap),
18189 : : TEST_CASE_NAMED_ST(
18190 : : "UDP encapsulation with custom ports",
18191 : : ut_setup_security, ut_teardown,
18192 : : test_ipsec_proto_udp_encap_custom_ports),
18193 : : TEST_CASE_NAMED_ST(
18194 : : "UDP encapsulation ports verification test",
18195 : : ut_setup_security, ut_teardown,
18196 : : test_ipsec_proto_udp_ports_verify),
18197 : : TEST_CASE_NAMED_ST(
18198 : : "SA expiry packets soft",
18199 : : ut_setup_security, ut_teardown,
18200 : : test_ipsec_proto_sa_exp_pkts_soft),
18201 : : TEST_CASE_NAMED_ST(
18202 : : "SA expiry packets hard",
18203 : : ut_setup_security, ut_teardown,
18204 : : test_ipsec_proto_sa_exp_pkts_hard),
18205 : : TEST_CASE_NAMED_ST(
18206 : : "Negative test: ICV corruption",
18207 : : ut_setup_security, ut_teardown,
18208 : : test_ipsec_proto_err_icv_corrupt),
18209 : : TEST_CASE_NAMED_ST(
18210 : : "Tunnel dst addr verification",
18211 : : ut_setup_security, ut_teardown,
18212 : : test_ipsec_proto_tunnel_dst_addr_verify),
18213 : : TEST_CASE_NAMED_ST(
18214 : : "Tunnel src and dst addr verification",
18215 : : ut_setup_security, ut_teardown,
18216 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
18217 : : TEST_CASE_NAMED_ST(
18218 : : "Inner IP checksum",
18219 : : ut_setup_security, ut_teardown,
18220 : : test_ipsec_proto_inner_ip_csum),
18221 : : TEST_CASE_NAMED_ST(
18222 : : "Inner L4 checksum",
18223 : : ut_setup_security, ut_teardown,
18224 : : test_ipsec_proto_inner_l4_csum),
18225 : : TEST_CASE_NAMED_ST(
18226 : : "Tunnel IPv4 in IPv4",
18227 : : ut_setup_security, ut_teardown,
18228 : : test_ipsec_proto_tunnel_v4_in_v4),
18229 : : TEST_CASE_NAMED_ST(
18230 : : "Tunnel IPv6 in IPv6",
18231 : : ut_setup_security, ut_teardown,
18232 : : test_ipsec_proto_tunnel_v6_in_v6),
18233 : : TEST_CASE_NAMED_ST(
18234 : : "Tunnel IPv4 in IPv6",
18235 : : ut_setup_security, ut_teardown,
18236 : : test_ipsec_proto_tunnel_v4_in_v6),
18237 : : TEST_CASE_NAMED_ST(
18238 : : "Tunnel IPv6 in IPv4",
18239 : : ut_setup_security, ut_teardown,
18240 : : test_ipsec_proto_tunnel_v6_in_v4),
18241 : : TEST_CASE_NAMED_ST(
18242 : : "Transport IPv4",
18243 : : ut_setup_security, ut_teardown,
18244 : : test_ipsec_proto_transport_v4),
18245 : : TEST_CASE_NAMED_ST(
18246 : : "AH transport IPv4",
18247 : : ut_setup_security, ut_teardown,
18248 : : test_ipsec_proto_ah_transport_ipv4),
18249 : : TEST_CASE_NAMED_ST(
18250 : : "Transport l4 checksum",
18251 : : ut_setup_security, ut_teardown,
18252 : : test_ipsec_proto_transport_l4_csum),
18253 : : TEST_CASE_NAMED_ST(
18254 : : "Statistics: success",
18255 : : ut_setup_security, ut_teardown,
18256 : : test_ipsec_proto_stats),
18257 : : TEST_CASE_NAMED_ST(
18258 : : "Fragmented packet",
18259 : : ut_setup_security, ut_teardown,
18260 : : test_ipsec_proto_pkt_fragment),
18261 : : TEST_CASE_NAMED_ST(
18262 : : "Tunnel header copy DF (inner 0)",
18263 : : ut_setup_security, ut_teardown,
18264 : : test_ipsec_proto_copy_df_inner_0),
18265 : : TEST_CASE_NAMED_ST(
18266 : : "Tunnel header copy DF (inner 1)",
18267 : : ut_setup_security, ut_teardown,
18268 : : test_ipsec_proto_copy_df_inner_1),
18269 : : TEST_CASE_NAMED_ST(
18270 : : "Tunnel header set DF 0 (inner 1)",
18271 : : ut_setup_security, ut_teardown,
18272 : : test_ipsec_proto_set_df_0_inner_1),
18273 : : TEST_CASE_NAMED_ST(
18274 : : "Tunnel header set DF 1 (inner 0)",
18275 : : ut_setup_security, ut_teardown,
18276 : : test_ipsec_proto_set_df_1_inner_0),
18277 : : TEST_CASE_NAMED_ST(
18278 : : "Tunnel header IPv4 copy DSCP (inner 0)",
18279 : : ut_setup_security, ut_teardown,
18280 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
18281 : : TEST_CASE_NAMED_ST(
18282 : : "Tunnel header IPv4 copy DSCP (inner 1)",
18283 : : ut_setup_security, ut_teardown,
18284 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
18285 : : TEST_CASE_NAMED_ST(
18286 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
18287 : : ut_setup_security, ut_teardown,
18288 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
18289 : : TEST_CASE_NAMED_ST(
18290 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
18291 : : ut_setup_security, ut_teardown,
18292 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
18293 : : TEST_CASE_NAMED_ST(
18294 : : "Tunnel header IPv6 copy DSCP (inner 0)",
18295 : : ut_setup_security, ut_teardown,
18296 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
18297 : : TEST_CASE_NAMED_ST(
18298 : : "Tunnel header IPv6 copy DSCP (inner 1)",
18299 : : ut_setup_security, ut_teardown,
18300 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
18301 : : TEST_CASE_NAMED_ST(
18302 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
18303 : : ut_setup_security, ut_teardown,
18304 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
18305 : : TEST_CASE_NAMED_ST(
18306 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
18307 : : ut_setup_security, ut_teardown,
18308 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
18309 : : TEST_CASE_NAMED_WITH_DATA(
18310 : : "Antireplay with window size 1024",
18311 : : ut_setup_security, ut_teardown,
18312 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
18313 : : TEST_CASE_NAMED_WITH_DATA(
18314 : : "Antireplay with window size 2048",
18315 : : ut_setup_security, ut_teardown,
18316 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
18317 : : TEST_CASE_NAMED_WITH_DATA(
18318 : : "Antireplay with window size 4096",
18319 : : ut_setup_security, ut_teardown,
18320 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
18321 : : TEST_CASE_NAMED_WITH_DATA(
18322 : : "ESN and Antireplay with window size 1024",
18323 : : ut_setup_security, ut_teardown,
18324 : : test_ipsec_proto_pkt_esn_antireplay1024,
18325 : : &pkt_aes_128_gcm),
18326 : : TEST_CASE_NAMED_WITH_DATA(
18327 : : "ESN and Antireplay with window size 2048",
18328 : : ut_setup_security, ut_teardown,
18329 : : test_ipsec_proto_pkt_esn_antireplay2048,
18330 : : &pkt_aes_128_gcm),
18331 : : TEST_CASE_NAMED_WITH_DATA(
18332 : : "ESN and Antireplay with window size 4096",
18333 : : ut_setup_security, ut_teardown,
18334 : : test_ipsec_proto_pkt_esn_antireplay4096,
18335 : : &pkt_aes_128_gcm),
18336 : : TEST_CASE_NAMED_ST(
18337 : : "Tunnel header IPv4 decrement inner TTL",
18338 : : ut_setup_security, ut_teardown,
18339 : : test_ipsec_proto_ipv4_ttl_decrement),
18340 : : TEST_CASE_NAMED_ST(
18341 : : "Tunnel header IPv6 decrement inner hop limit",
18342 : : ut_setup_security, ut_teardown,
18343 : : test_ipsec_proto_ipv6_hop_limit_decrement),
18344 : : TEST_CASE_NAMED_ST(
18345 : : "Multi-segmented mode",
18346 : : ut_setup_security, ut_teardown,
18347 : : test_ipsec_proto_sgl),
18348 : : TEST_CASE_NAMED_ST(
18349 : : "Multi-segmented external mbuf mode",
18350 : : ut_setup_security, ut_teardown,
18351 : : test_ipsec_proto_sgl_ext_mbuf),
18352 : : TEST_CASE_NAMED_WITH_DATA(
18353 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
18354 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18355 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
18356 : : TEST_CASES_END() /**< NULL terminate unit test array */
18357 : : }
18358 : : };
18359 : :
18360 : : static struct unit_test_suite pdcp_proto_testsuite = {
18361 : : .suite_name = "PDCP Proto Unit Test Suite",
18362 : : .setup = pdcp_proto_testsuite_setup,
18363 : : .unit_test_cases = {
18364 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
18365 : : test_PDCP_PROTO_all),
18366 : : TEST_CASES_END() /**< NULL terminate unit test array */
18367 : : }
18368 : : };
18369 : :
18370 : : static struct unit_test_suite tls12_record_proto_testsuite = {
18371 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
18372 : : .setup = tls_record_proto_testsuite_setup,
18373 : : .unit_test_cases = {
18374 : : TEST_CASE_NAMED_WITH_DATA(
18375 : : "Write record known vector AES-GCM-128 (vector 1)",
18376 : : ut_setup_security, ut_teardown,
18377 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
18378 : : TEST_CASE_NAMED_WITH_DATA(
18379 : : "Write record known vector AES-GCM-128 (vector 2)",
18380 : : ut_setup_security, ut_teardown,
18381 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
18382 : : TEST_CASE_NAMED_WITH_DATA(
18383 : : "Write record known vector AES-GCM-256",
18384 : : ut_setup_security, ut_teardown,
18385 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
18386 : : TEST_CASE_NAMED_WITH_DATA(
18387 : : "Write record known vector AES-CBC-128-SHA1",
18388 : : ut_setup_security, ut_teardown,
18389 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
18390 : : TEST_CASE_NAMED_WITH_DATA(
18391 : : "Write record known vector AES-128-CBC-SHA256",
18392 : : ut_setup_security, ut_teardown,
18393 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
18394 : : TEST_CASE_NAMED_WITH_DATA(
18395 : : "Write record known vector AES-256-CBC-SHA1",
18396 : : ut_setup_security, ut_teardown,
18397 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
18398 : : TEST_CASE_NAMED_WITH_DATA(
18399 : : "Write record known vector AES-256-CBC-SHA256",
18400 : : ut_setup_security, ut_teardown,
18401 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
18402 : : TEST_CASE_NAMED_WITH_DATA(
18403 : : "Write record known vector AES-256-CBC-SHA384",
18404 : : ut_setup_security, ut_teardown,
18405 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
18406 : : TEST_CASE_NAMED_WITH_DATA(
18407 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18408 : : ut_setup_security, ut_teardown,
18409 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
18410 : : TEST_CASE_NAMED_WITH_DATA(
18411 : : "Write record known vector NULL-SHA1-HMAC",
18412 : : ut_setup_security, ut_teardown,
18413 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
18414 : : TEST_CASE_NAMED_WITH_DATA(
18415 : : "Write record known vector CHACHA20-POLY1305",
18416 : : ut_setup_security, ut_teardown,
18417 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
18418 : :
18419 : : TEST_CASE_NAMED_WITH_DATA(
18420 : : "Read record known vector AES-GCM-128 (vector 1)",
18421 : : ut_setup_security, ut_teardown,
18422 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
18423 : : TEST_CASE_NAMED_WITH_DATA(
18424 : : "Read record known vector AES-GCM-128 (vector 2)",
18425 : : ut_setup_security, ut_teardown,
18426 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
18427 : : TEST_CASE_NAMED_WITH_DATA(
18428 : : "Read record known vector AES-GCM-256",
18429 : : ut_setup_security, ut_teardown,
18430 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
18431 : : TEST_CASE_NAMED_WITH_DATA(
18432 : : "Read record known vector AES-128-CBC-SHA1",
18433 : : ut_setup_security, ut_teardown,
18434 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
18435 : : TEST_CASE_NAMED_WITH_DATA(
18436 : : "Read record known vector AES-128-CBC-SHA256",
18437 : : ut_setup_security, ut_teardown,
18438 : : test_tls_record_proto_known_vec_read,
18439 : : &tls_test_data_aes_128_cbc_sha256_hmac),
18440 : : TEST_CASE_NAMED_WITH_DATA(
18441 : : "Read record known vector AES-256-CBC-SHA1",
18442 : : ut_setup_security, ut_teardown,
18443 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
18444 : : TEST_CASE_NAMED_WITH_DATA(
18445 : : "Read record known vector AES-256-CBC-SHA256",
18446 : : ut_setup_security, ut_teardown,
18447 : : test_tls_record_proto_known_vec_read,
18448 : : &tls_test_data_aes_256_cbc_sha256_hmac),
18449 : : TEST_CASE_NAMED_WITH_DATA(
18450 : : "Read record known vector AES-256-CBC-SHA384",
18451 : : ut_setup_security, ut_teardown,
18452 : : test_tls_record_proto_known_vec_read,
18453 : : &tls_test_data_aes_256_cbc_sha384_hmac),
18454 : : TEST_CASE_NAMED_WITH_DATA(
18455 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18456 : : ut_setup_security, ut_teardown,
18457 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18458 : : TEST_CASE_NAMED_WITH_DATA(
18459 : : "Read record known vector NULL-SHA1-HMAC",
18460 : : ut_setup_security, ut_teardown,
18461 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18462 : : TEST_CASE_NAMED_WITH_DATA(
18463 : : "Read record known vector CHACHA20-POLY1305",
18464 : : ut_setup_security, ut_teardown,
18465 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18466 : :
18467 : : TEST_CASE_NAMED_ST(
18468 : : "Combined test alg list",
18469 : : ut_setup_security, ut_teardown,
18470 : : test_tls_1_2_record_proto_display_list),
18471 : : TEST_CASE_NAMED_ST(
18472 : : "Data walkthrough combined test alg list",
18473 : : ut_setup_security, ut_teardown,
18474 : : test_tls_1_2_record_proto_data_walkthrough),
18475 : : TEST_CASE_NAMED_ST(
18476 : : "Multi-segmented mode",
18477 : : ut_setup_security, ut_teardown,
18478 : : test_tls_1_2_record_proto_sgl),
18479 : : TEST_CASE_NAMED_ST(
18480 : : "Multi-segmented mode data walkthrough",
18481 : : ut_setup_security, ut_teardown,
18482 : : test_tls_1_2_record_proto_sgl_data_walkthrough),
18483 : : TEST_CASE_NAMED_ST(
18484 : : "Multi-segmented mode out of place",
18485 : : ut_setup_security, ut_teardown,
18486 : : test_tls_1_2_record_proto_sgl_oop),
18487 : : TEST_CASE_NAMED_ST(
18488 : : "TLS packet header corruption",
18489 : : ut_setup_security, ut_teardown,
18490 : : test_tls_record_proto_corrupt_pkt),
18491 : : TEST_CASE_NAMED_ST(
18492 : : "Custom content type",
18493 : : ut_setup_security, ut_teardown,
18494 : : test_tls_record_proto_custom_content_type),
18495 : : TEST_CASE_NAMED_ST(
18496 : : "Zero len TLS record with content type as app",
18497 : : ut_setup_security, ut_teardown,
18498 : : test_tls_record_proto_zero_len),
18499 : : TEST_CASE_NAMED_ST(
18500 : : "Zero len TLS record with content type as ctrl",
18501 : : ut_setup_security, ut_teardown,
18502 : : test_tls_record_proto_zero_len_non_app),
18503 : : TEST_CASE_NAMED_ST(
18504 : : "TLS record DM mode with optional padding < 2 blocks",
18505 : : ut_setup_security, ut_teardown,
18506 : : test_tls_record_proto_dm_opt_padding),
18507 : : TEST_CASE_NAMED_ST(
18508 : : "TLS record DM mode with optional padding > 2 blocks",
18509 : : ut_setup_security, ut_teardown,
18510 : : test_tls_record_proto_dm_opt_padding_1),
18511 : : TEST_CASE_NAMED_ST(
18512 : : "TLS record SG mode with optional padding < 2 blocks",
18513 : : ut_setup_security, ut_teardown,
18514 : : test_tls_record_proto_sg_opt_padding),
18515 : : TEST_CASE_NAMED_ST(
18516 : : "TLS record SG mode with optional padding > 2 blocks",
18517 : : ut_setup_security, ut_teardown,
18518 : : test_tls_record_proto_sg_opt_padding_1),
18519 : : TEST_CASE_NAMED_ST(
18520 : : "TLS record SG mode with optional padding > 2 blocks",
18521 : : ut_setup_security, ut_teardown,
18522 : : test_tls_record_proto_sg_opt_padding_2),
18523 : : TEST_CASE_NAMED_ST(
18524 : : "TLS record SG mode with optional padding > max range",
18525 : : ut_setup_security, ut_teardown,
18526 : : test_tls_record_proto_sg_opt_padding_max),
18527 : : TEST_CASE_NAMED_ST(
18528 : : "TLS record SG mode with padding corruption",
18529 : : ut_setup_security, ut_teardown,
18530 : : test_tls_record_proto_sg_opt_padding_corrupt),
18531 : : TEST_CASES_END() /**< NULL terminate unit test array */
18532 : : }
18533 : : };
18534 : :
18535 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
18536 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18537 : : .setup = tls_record_proto_testsuite_setup,
18538 : : .unit_test_cases = {
18539 : : TEST_CASE_NAMED_WITH_DATA(
18540 : : "Write record known vector AES-GCM-128",
18541 : : ut_setup_security, ut_teardown,
18542 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18543 : : TEST_CASE_NAMED_WITH_DATA(
18544 : : "Write record known vector AES-GCM-256",
18545 : : ut_setup_security, ut_teardown,
18546 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18547 : : TEST_CASE_NAMED_WITH_DATA(
18548 : : "Write record known vector AES-128-CBC-SHA1",
18549 : : ut_setup_security, ut_teardown,
18550 : : test_tls_record_proto_known_vec,
18551 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18552 : : TEST_CASE_NAMED_WITH_DATA(
18553 : : "Write record known vector AES-128-CBC-SHA256",
18554 : : ut_setup_security, ut_teardown,
18555 : : test_tls_record_proto_known_vec,
18556 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18557 : : TEST_CASE_NAMED_WITH_DATA(
18558 : : "Write record known vector AES-256-CBC-SHA1",
18559 : : ut_setup_security, ut_teardown,
18560 : : test_tls_record_proto_known_vec,
18561 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18562 : : TEST_CASE_NAMED_WITH_DATA(
18563 : : "Write record known vector AES-256-CBC-SHA256",
18564 : : ut_setup_security, ut_teardown,
18565 : : test_tls_record_proto_known_vec,
18566 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18567 : : TEST_CASE_NAMED_WITH_DATA(
18568 : : "Write record known vector AES-256-CBC-SHA384",
18569 : : ut_setup_security, ut_teardown,
18570 : : test_tls_record_proto_known_vec,
18571 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18572 : : TEST_CASE_NAMED_WITH_DATA(
18573 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18574 : : ut_setup_security, ut_teardown,
18575 : : test_tls_record_proto_known_vec,
18576 : : &dtls_test_data_3des_cbc_sha1_hmac),
18577 : : TEST_CASE_NAMED_WITH_DATA(
18578 : : "Write record known vector NULL-SHA1-HMAC",
18579 : : ut_setup_security, ut_teardown,
18580 : : test_tls_record_proto_known_vec,
18581 : : &dtls_test_data_null_cipher_sha1_hmac),
18582 : : TEST_CASE_NAMED_WITH_DATA(
18583 : : "Write record known vector CHACHA20-POLY1305",
18584 : : ut_setup_security, ut_teardown,
18585 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18586 : : TEST_CASE_NAMED_WITH_DATA(
18587 : : "Read record known vector AES-GCM-128",
18588 : : ut_setup_security, ut_teardown,
18589 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18590 : : TEST_CASE_NAMED_WITH_DATA(
18591 : : "Read record known vector AES-GCM-256",
18592 : : ut_setup_security, ut_teardown,
18593 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18594 : : TEST_CASE_NAMED_WITH_DATA(
18595 : : "Read record known vector AES-128-CBC-SHA1",
18596 : : ut_setup_security, ut_teardown,
18597 : : test_tls_record_proto_known_vec_read,
18598 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18599 : : TEST_CASE_NAMED_WITH_DATA(
18600 : : "Read record known vector AES-128-CBC-SHA256",
18601 : : ut_setup_security, ut_teardown,
18602 : : test_tls_record_proto_known_vec_read,
18603 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18604 : : TEST_CASE_NAMED_WITH_DATA(
18605 : : "Read record known vector AES-256-CBC-SHA1",
18606 : : ut_setup_security, ut_teardown,
18607 : : test_tls_record_proto_known_vec_read,
18608 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18609 : : TEST_CASE_NAMED_WITH_DATA(
18610 : : "Read record known vector AES-256-CBC-SHA256",
18611 : : ut_setup_security, ut_teardown,
18612 : : test_tls_record_proto_known_vec_read,
18613 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18614 : : TEST_CASE_NAMED_WITH_DATA(
18615 : : "Read record known vector AES-256-CBC-SHA384",
18616 : : ut_setup_security, ut_teardown,
18617 : : test_tls_record_proto_known_vec_read,
18618 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18619 : : TEST_CASE_NAMED_WITH_DATA(
18620 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18621 : : ut_setup_security, ut_teardown,
18622 : : test_tls_record_proto_known_vec_read,
18623 : : &dtls_test_data_3des_cbc_sha1_hmac),
18624 : : TEST_CASE_NAMED_WITH_DATA(
18625 : : "Read record known vector NULL-SHA1-HMAC",
18626 : : ut_setup_security, ut_teardown,
18627 : : test_tls_record_proto_known_vec_read,
18628 : : &dtls_test_data_null_cipher_sha1_hmac),
18629 : : TEST_CASE_NAMED_WITH_DATA(
18630 : : "Read record known vector CHACHA20-POLY1305",
18631 : : ut_setup_security, ut_teardown,
18632 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18633 : :
18634 : : TEST_CASE_NAMED_ST(
18635 : : "Combined test alg list",
18636 : : ut_setup_security, ut_teardown,
18637 : : test_dtls_1_2_record_proto_display_list),
18638 : : TEST_CASE_NAMED_ST(
18639 : : "Data walkthrough combined test alg list",
18640 : : ut_setup_security, ut_teardown,
18641 : : test_dtls_1_2_record_proto_data_walkthrough),
18642 : : TEST_CASE_NAMED_ST(
18643 : : "Multi-segmented mode",
18644 : : ut_setup_security, ut_teardown,
18645 : : test_dtls_1_2_record_proto_sgl),
18646 : : TEST_CASE_NAMED_ST(
18647 : : "Multi-segmented mode data walkthrough",
18648 : : ut_setup_security, ut_teardown,
18649 : : test_dtls_1_2_record_proto_sgl_data_walkthrough),
18650 : : TEST_CASE_NAMED_ST(
18651 : : "Multi-segmented mode out of place",
18652 : : ut_setup_security, ut_teardown,
18653 : : test_dtls_1_2_record_proto_sgl_oop),
18654 : : TEST_CASE_NAMED_ST(
18655 : : "Packet corruption",
18656 : : ut_setup_security, ut_teardown,
18657 : : test_dtls_1_2_record_proto_corrupt_pkt),
18658 : : TEST_CASE_NAMED_ST(
18659 : : "Custom content type",
18660 : : ut_setup_security, ut_teardown,
18661 : : test_dtls_1_2_record_proto_custom_content_type),
18662 : : TEST_CASE_NAMED_ST(
18663 : : "Zero len DTLS record with content type as app",
18664 : : ut_setup_security, ut_teardown,
18665 : : test_dtls_1_2_record_proto_zero_len),
18666 : : TEST_CASE_NAMED_ST(
18667 : : "Zero len DTLS record with content type as ctrl",
18668 : : ut_setup_security, ut_teardown,
18669 : : test_dtls_1_2_record_proto_zero_len_non_app),
18670 : : TEST_CASE_NAMED_ST(
18671 : : "Antireplay with window size 64",
18672 : : ut_setup_security, ut_teardown,
18673 : : test_dtls_1_2_record_proto_antireplay64),
18674 : : TEST_CASE_NAMED_ST(
18675 : : "Antireplay with window size 128",
18676 : : ut_setup_security, ut_teardown,
18677 : : test_dtls_1_2_record_proto_antireplay128),
18678 : : TEST_CASE_NAMED_ST(
18679 : : "Antireplay with window size 256",
18680 : : ut_setup_security, ut_teardown,
18681 : : test_dtls_1_2_record_proto_antireplay256),
18682 : : TEST_CASE_NAMED_ST(
18683 : : "Antireplay with window size 512",
18684 : : ut_setup_security, ut_teardown,
18685 : : test_dtls_1_2_record_proto_antireplay512),
18686 : : TEST_CASE_NAMED_ST(
18687 : : "Antireplay with window size 1024",
18688 : : ut_setup_security, ut_teardown,
18689 : : test_dtls_1_2_record_proto_antireplay1024),
18690 : : TEST_CASE_NAMED_ST(
18691 : : "Antireplay with window size 2048",
18692 : : ut_setup_security, ut_teardown,
18693 : : test_dtls_1_2_record_proto_antireplay2048),
18694 : : TEST_CASE_NAMED_ST(
18695 : : "Antireplay with window size 4096",
18696 : : ut_setup_security, ut_teardown,
18697 : : test_dtls_1_2_record_proto_antireplay4096),
18698 : : TEST_CASE_NAMED_ST(
18699 : : "DTLS record DM mode with optional padding < 2 blocks",
18700 : : ut_setup_security, ut_teardown,
18701 : : test_dtls_1_2_record_proto_dm_opt_padding),
18702 : : TEST_CASE_NAMED_ST(
18703 : : "DTLS record DM mode with optional padding > 2 blocks",
18704 : : ut_setup_security, ut_teardown,
18705 : : test_dtls_1_2_record_proto_dm_opt_padding_1),
18706 : : TEST_CASE_NAMED_ST(
18707 : : "DTLS record SG mode with optional padding < 2 blocks",
18708 : : ut_setup_security, ut_teardown,
18709 : : test_dtls_1_2_record_proto_sg_opt_padding),
18710 : : TEST_CASE_NAMED_ST(
18711 : : "DTLS record SG mode with optional padding > 2 blocks",
18712 : : ut_setup_security, ut_teardown,
18713 : : test_dtls_1_2_record_proto_sg_opt_padding_1),
18714 : : TEST_CASE_NAMED_ST(
18715 : : "DTLS record SG mode with optional padding > 2 blocks",
18716 : : ut_setup_security, ut_teardown,
18717 : : test_dtls_1_2_record_proto_sg_opt_padding_2),
18718 : : TEST_CASE_NAMED_ST(
18719 : : "DTLS record SG mode with optional padding > max range",
18720 : : ut_setup_security, ut_teardown,
18721 : : test_dtls_1_2_record_proto_sg_opt_padding_max),
18722 : : TEST_CASE_NAMED_ST(
18723 : : "DTLS record SG mode with padding corruption",
18724 : : ut_setup_security, ut_teardown,
18725 : : test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18726 : : TEST_CASES_END() /**< NULL terminate unit test array */
18727 : : }
18728 : : };
18729 : :
18730 : : static struct unit_test_suite tls13_record_proto_testsuite = {
18731 : : .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18732 : : .setup = tls_record_proto_testsuite_setup,
18733 : : .unit_test_cases = {
18734 : : TEST_CASE_NAMED_WITH_DATA(
18735 : : "Write record known vector AES-GCM-128",
18736 : : ut_setup_security, ut_teardown,
18737 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18738 : : TEST_CASE_NAMED_WITH_DATA(
18739 : : "Write record known vector AES-GCM-256",
18740 : : ut_setup_security, ut_teardown,
18741 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18742 : : TEST_CASE_NAMED_WITH_DATA(
18743 : : "Write record known vector CHACHA20-POLY1305",
18744 : : ut_setup_security, ut_teardown,
18745 : : test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18746 : :
18747 : : TEST_CASE_NAMED_WITH_DATA(
18748 : : "Read record known vector AES-GCM-128",
18749 : : ut_setup_security, ut_teardown,
18750 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18751 : : TEST_CASE_NAMED_WITH_DATA(
18752 : : "Read record known vector AES-GCM-256",
18753 : : ut_setup_security, ut_teardown,
18754 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18755 : : TEST_CASE_NAMED_WITH_DATA(
18756 : : "Read record known vector CHACHA20-POLY1305",
18757 : : ut_setup_security, ut_teardown,
18758 : : test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18759 : : TEST_CASE_NAMED_ST(
18760 : : "TLS-1.3 record header corruption",
18761 : : ut_setup_security, ut_teardown,
18762 : : test_tls_1_3_record_proto_corrupt_pkt),
18763 : : TEST_CASE_NAMED_ST(
18764 : : "TLS-1.3 record header with custom content type",
18765 : : ut_setup_security, ut_teardown,
18766 : : test_tls_1_3_record_proto_custom_content_type),
18767 : : TEST_CASE_NAMED_ST(
18768 : : "TLS-1.3 record with zero len and content type as app",
18769 : : ut_setup_security, ut_teardown,
18770 : : test_tls_1_3_record_proto_zero_len),
18771 : : TEST_CASE_NAMED_ST(
18772 : : "TLS-1.3 record with zero len and content type as ctrl",
18773 : : ut_setup_security, ut_teardown,
18774 : : test_tls_1_3_record_proto_zero_len_non_app),
18775 : : TEST_CASE_NAMED_ST(
18776 : : "TLS-1.3 record DM mode with optional padding",
18777 : : ut_setup_security, ut_teardown,
18778 : : test_tls_1_3_record_proto_dm_opt_padding),
18779 : : TEST_CASE_NAMED_ST(
18780 : : "TLS-1.3 record SG mode with optional padding - 1",
18781 : : ut_setup_security, ut_teardown,
18782 : : test_tls_1_3_record_proto_sg_opt_padding),
18783 : : TEST_CASE_NAMED_ST(
18784 : : "TLS-1.3 record SG mode with optional padding",
18785 : : ut_setup_security, ut_teardown,
18786 : : test_tls_1_3_record_proto_sg_opt_padding_1),
18787 : : TEST_CASE_NAMED_ST(
18788 : : "Combined test alg list",
18789 : : ut_setup_security, ut_teardown,
18790 : : test_tls_1_3_record_proto_display_list),
18791 : : TEST_CASE_NAMED_ST(
18792 : : "Data walkthrough combined test alg list",
18793 : : ut_setup_security, ut_teardown,
18794 : : test_tls_1_3_record_proto_data_walkthrough),
18795 : : TEST_CASE_NAMED_ST(
18796 : : "Multi-segmented mode",
18797 : : ut_setup_security, ut_teardown,
18798 : : test_tls_1_3_record_proto_sgl),
18799 : : TEST_CASE_NAMED_ST(
18800 : : "Multi-segmented mode data walkthrough",
18801 : : ut_setup_security, ut_teardown,
18802 : : test_tls_1_3_record_proto_sgl_data_walkthrough),
18803 : : TEST_CASE_NAMED_ST(
18804 : : "Multi-segmented mode out of place",
18805 : : ut_setup_security, ut_teardown,
18806 : : test_tls_1_3_record_proto_sgl_oop),
18807 : : TEST_CASES_END() /**< NULL terminate unit test array */
18808 : : }
18809 : : };
18810 : :
18811 : : #define ADD_UPLINK_TESTCASE(data) \
18812 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
18813 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
18814 : :
18815 : : #define ADD_DOWNLINK_TESTCASE(data) \
18816 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
18817 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
18818 : :
18819 : : static struct unit_test_suite docsis_proto_testsuite = {
18820 : : .suite_name = "DOCSIS Proto Unit Test Suite",
18821 : : .setup = docsis_proto_testsuite_setup,
18822 : : .unit_test_cases = {
18823 : : /* Uplink */
18824 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
18825 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
18826 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
18827 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
18828 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
18829 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
18830 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
18831 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
18832 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
18833 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
18834 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
18835 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
18836 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
18837 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
18838 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
18839 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
18840 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
18841 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
18842 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
18843 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
18844 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
18845 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
18846 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
18847 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
18848 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
18849 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
18850 : : /* Downlink */
18851 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18852 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18853 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18854 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18855 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18856 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18857 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18858 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18859 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18860 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18861 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18862 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18863 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18864 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18865 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18866 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18867 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18868 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18869 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18870 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18871 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18872 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18873 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18874 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18875 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18876 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18877 : : TEST_CASES_END() /**< NULL terminate unit test array */
18878 : : }
18879 : : };
18880 : : #endif
18881 : :
18882 : : static struct unit_test_suite cryptodev_gen_testsuite = {
18883 : : .suite_name = "Crypto General Unit Test Suite",
18884 : : .setup = crypto_gen_testsuite_setup,
18885 : : .unit_test_cases = {
18886 : : TEST_CASE_ST(ut_setup, ut_teardown,
18887 : : test_device_reconfigure),
18888 : : TEST_CASE_ST(ut_setup, ut_teardown,
18889 : : test_device_configure_invalid_dev_id),
18890 : : TEST_CASE_ST(ut_setup, ut_teardown,
18891 : : test_queue_pair_descriptor_setup),
18892 : : TEST_CASE_ST(ut_setup, ut_teardown,
18893 : : test_device_configure_invalid_queue_pair_ids),
18894 : : TEST_CASE_ST(ut_setup, ut_teardown,
18895 : : test_queue_pair_descriptor_count),
18896 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18897 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18898 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18899 : : TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
18900 : : test_cryptodev_verify_error_recover, &aes_test_data_4),
18901 : : TEST_CASES_END() /**< NULL terminate unit test array */
18902 : : }
18903 : : };
18904 : :
18905 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18906 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
18907 : : .setup = negative_hmac_sha1_testsuite_setup,
18908 : : .unit_test_cases = {
18909 : : /** Negative tests */
18910 : : TEST_CASE_ST(ut_setup, ut_teardown,
18911 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
18912 : : TEST_CASE_ST(ut_setup, ut_teardown,
18913 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18914 : : TEST_CASE_ST(ut_setup, ut_teardown,
18915 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18916 : : TEST_CASE_ST(ut_setup, ut_teardown,
18917 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18918 : :
18919 : : TEST_CASES_END() /**< NULL terminate unit test array */
18920 : : }
18921 : : };
18922 : :
18923 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
18924 : : .suite_name = "Multi Session Unit Test Suite",
18925 : : .setup = multi_session_testsuite_setup,
18926 : : .unit_test_cases = {
18927 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18928 : : TEST_CASE_ST(ut_setup, ut_teardown,
18929 : : test_multi_session_random_usage),
18930 : :
18931 : : TEST_CASES_END() /**< NULL terminate unit test array */
18932 : : }
18933 : : };
18934 : :
18935 : : static struct unit_test_suite cryptodev_null_testsuite = {
18936 : : .suite_name = "NULL Test Suite",
18937 : : .setup = null_testsuite_setup,
18938 : : .unit_test_cases = {
18939 : : TEST_CASE_ST(ut_setup, ut_teardown,
18940 : : test_null_invalid_operation),
18941 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
18942 : : TEST_CASES_END()
18943 : : }
18944 : : };
18945 : :
18946 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
18947 : : .suite_name = "AES CCM Authenticated Test Suite",
18948 : : .setup = aes_ccm_auth_testsuite_setup,
18949 : : .unit_test_cases = {
18950 : : /** AES CCM Authenticated Encryption 128 bits key*/
18951 : : TEST_CASE_ST(ut_setup, ut_teardown,
18952 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
18953 : : TEST_CASE_ST(ut_setup, ut_teardown,
18954 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
18955 : : TEST_CASE_ST(ut_setup, ut_teardown,
18956 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
18957 : :
18958 : : /** AES CCM Authenticated Decryption 128 bits key*/
18959 : : TEST_CASE_ST(ut_setup, ut_teardown,
18960 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
18961 : : TEST_CASE_ST(ut_setup, ut_teardown,
18962 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
18963 : : TEST_CASE_ST(ut_setup, ut_teardown,
18964 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
18965 : :
18966 : : /** AES CCM Authenticated Encryption 192 bits key */
18967 : : TEST_CASE_ST(ut_setup, ut_teardown,
18968 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
18969 : : TEST_CASE_ST(ut_setup, ut_teardown,
18970 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
18971 : : TEST_CASE_ST(ut_setup, ut_teardown,
18972 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
18973 : :
18974 : : /** AES CCM Authenticated Decryption 192 bits key*/
18975 : : TEST_CASE_ST(ut_setup, ut_teardown,
18976 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
18977 : : TEST_CASE_ST(ut_setup, ut_teardown,
18978 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
18979 : : TEST_CASE_ST(ut_setup, ut_teardown,
18980 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
18981 : :
18982 : : /** AES CCM Authenticated Encryption 256 bits key */
18983 : : TEST_CASE_ST(ut_setup, ut_teardown,
18984 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
18985 : : TEST_CASE_ST(ut_setup, ut_teardown,
18986 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
18987 : : TEST_CASE_ST(ut_setup, ut_teardown,
18988 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
18989 : :
18990 : : /** AES CCM Authenticated Decryption 256 bits key*/
18991 : : TEST_CASE_ST(ut_setup, ut_teardown,
18992 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
18993 : : TEST_CASE_ST(ut_setup, ut_teardown,
18994 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
18995 : : TEST_CASE_ST(ut_setup, ut_teardown,
18996 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
18997 : : TEST_CASES_END()
18998 : : }
18999 : : };
19000 : :
19001 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
19002 : : .suite_name = "AES GCM Authenticated Test Suite",
19003 : : .setup = aes_gcm_auth_testsuite_setup,
19004 : : .unit_test_cases = {
19005 : : /** AES GCM Authenticated Encryption */
19006 : : TEST_CASE_ST(ut_setup, ut_teardown,
19007 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
19008 : : TEST_CASE_ST(ut_setup, ut_teardown,
19009 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
19010 : : TEST_CASE_ST(ut_setup, ut_teardown,
19011 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
19012 : : TEST_CASE_ST(ut_setup, ut_teardown,
19013 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
19014 : : TEST_CASE_ST(ut_setup, ut_teardown,
19015 : : test_AES_GCM_authenticated_encryption_test_case_1),
19016 : : TEST_CASE_ST(ut_setup, ut_teardown,
19017 : : test_AES_GCM_authenticated_encryption_test_case_2),
19018 : : TEST_CASE_ST(ut_setup, ut_teardown,
19019 : : test_AES_GCM_authenticated_encryption_test_case_3),
19020 : : TEST_CASE_ST(ut_setup, ut_teardown,
19021 : : test_AES_GCM_authenticated_encryption_test_case_4),
19022 : : TEST_CASE_ST(ut_setup, ut_teardown,
19023 : : test_AES_GCM_authenticated_encryption_test_case_5),
19024 : : TEST_CASE_ST(ut_setup, ut_teardown,
19025 : : test_AES_GCM_authenticated_encryption_test_case_6),
19026 : : TEST_CASE_ST(ut_setup, ut_teardown,
19027 : : test_AES_GCM_authenticated_encryption_test_case_7),
19028 : : TEST_CASE_ST(ut_setup, ut_teardown,
19029 : : test_AES_GCM_authenticated_encryption_test_case_8),
19030 : : TEST_CASE_ST(ut_setup, ut_teardown,
19031 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
19032 : :
19033 : : /** AES GCM Authenticated Decryption */
19034 : : TEST_CASE_ST(ut_setup, ut_teardown,
19035 : : test_AES_GCM_authenticated_decryption_test_case_1),
19036 : : TEST_CASE_ST(ut_setup, ut_teardown,
19037 : : test_AES_GCM_authenticated_decryption_test_case_2),
19038 : : TEST_CASE_ST(ut_setup, ut_teardown,
19039 : : test_AES_GCM_authenticated_decryption_test_case_3),
19040 : : TEST_CASE_ST(ut_setup, ut_teardown,
19041 : : test_AES_GCM_authenticated_decryption_test_case_4),
19042 : : TEST_CASE_ST(ut_setup, ut_teardown,
19043 : : test_AES_GCM_authenticated_decryption_test_case_5),
19044 : : TEST_CASE_ST(ut_setup, ut_teardown,
19045 : : test_AES_GCM_authenticated_decryption_test_case_6),
19046 : : TEST_CASE_ST(ut_setup, ut_teardown,
19047 : : test_AES_GCM_authenticated_decryption_test_case_7),
19048 : : TEST_CASE_ST(ut_setup, ut_teardown,
19049 : : test_AES_GCM_authenticated_decryption_test_case_8),
19050 : : TEST_CASE_ST(ut_setup, ut_teardown,
19051 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
19052 : :
19053 : : /** AES GCM Authenticated Encryption 192 bits key */
19054 : : TEST_CASE_ST(ut_setup, ut_teardown,
19055 : : test_AES_GCM_auth_encryption_test_case_192_1),
19056 : : TEST_CASE_ST(ut_setup, ut_teardown,
19057 : : test_AES_GCM_auth_encryption_test_case_192_2),
19058 : : TEST_CASE_ST(ut_setup, ut_teardown,
19059 : : test_AES_GCM_auth_encryption_test_case_192_3),
19060 : : TEST_CASE_ST(ut_setup, ut_teardown,
19061 : : test_AES_GCM_auth_encryption_test_case_192_4),
19062 : : TEST_CASE_ST(ut_setup, ut_teardown,
19063 : : test_AES_GCM_auth_encryption_test_case_192_5),
19064 : : TEST_CASE_ST(ut_setup, ut_teardown,
19065 : : test_AES_GCM_auth_encryption_test_case_192_6),
19066 : : TEST_CASE_ST(ut_setup, ut_teardown,
19067 : : test_AES_GCM_auth_encryption_test_case_192_7),
19068 : :
19069 : : /** AES GCM Authenticated Decryption 192 bits key */
19070 : : TEST_CASE_ST(ut_setup, ut_teardown,
19071 : : test_AES_GCM_auth_decryption_test_case_192_1),
19072 : : TEST_CASE_ST(ut_setup, ut_teardown,
19073 : : test_AES_GCM_auth_decryption_test_case_192_2),
19074 : : TEST_CASE_ST(ut_setup, ut_teardown,
19075 : : test_AES_GCM_auth_decryption_test_case_192_3),
19076 : : TEST_CASE_ST(ut_setup, ut_teardown,
19077 : : test_AES_GCM_auth_decryption_test_case_192_4),
19078 : : TEST_CASE_ST(ut_setup, ut_teardown,
19079 : : test_AES_GCM_auth_decryption_test_case_192_5),
19080 : : TEST_CASE_ST(ut_setup, ut_teardown,
19081 : : test_AES_GCM_auth_decryption_test_case_192_6),
19082 : : TEST_CASE_ST(ut_setup, ut_teardown,
19083 : : test_AES_GCM_auth_decryption_test_case_192_7),
19084 : :
19085 : : /** AES GCM Authenticated Encryption 256 bits key */
19086 : : TEST_CASE_ST(ut_setup, ut_teardown,
19087 : : test_AES_GCM_auth_encryption_test_case_256_1),
19088 : : TEST_CASE_ST(ut_setup, ut_teardown,
19089 : : test_AES_GCM_auth_encryption_test_case_256_2),
19090 : : TEST_CASE_ST(ut_setup, ut_teardown,
19091 : : test_AES_GCM_auth_encryption_test_case_256_3),
19092 : : TEST_CASE_ST(ut_setup, ut_teardown,
19093 : : test_AES_GCM_auth_encryption_test_case_256_4),
19094 : : TEST_CASE_ST(ut_setup, ut_teardown,
19095 : : test_AES_GCM_auth_encryption_test_case_256_5),
19096 : : TEST_CASE_ST(ut_setup, ut_teardown,
19097 : : test_AES_GCM_auth_encryption_test_case_256_6),
19098 : : TEST_CASE_ST(ut_setup, ut_teardown,
19099 : : test_AES_GCM_auth_encryption_test_case_256_7),
19100 : : TEST_CASE_ST(ut_setup, ut_teardown,
19101 : : test_AES_GCM_auth_encryption_test_case_256_8),
19102 : :
19103 : : /** AES GCM Authenticated Decryption 256 bits key */
19104 : : TEST_CASE_ST(ut_setup, ut_teardown,
19105 : : test_AES_GCM_auth_decryption_test_case_256_1),
19106 : : TEST_CASE_ST(ut_setup, ut_teardown,
19107 : : test_AES_GCM_auth_decryption_test_case_256_2),
19108 : : TEST_CASE_ST(ut_setup, ut_teardown,
19109 : : test_AES_GCM_auth_decryption_test_case_256_3),
19110 : : TEST_CASE_ST(ut_setup, ut_teardown,
19111 : : test_AES_GCM_auth_decryption_test_case_256_4),
19112 : : TEST_CASE_ST(ut_setup, ut_teardown,
19113 : : test_AES_GCM_auth_decryption_test_case_256_5),
19114 : : TEST_CASE_ST(ut_setup, ut_teardown,
19115 : : test_AES_GCM_auth_decryption_test_case_256_6),
19116 : : TEST_CASE_ST(ut_setup, ut_teardown,
19117 : : test_AES_GCM_auth_decryption_test_case_256_7),
19118 : : TEST_CASE_ST(ut_setup, ut_teardown,
19119 : : test_AES_GCM_auth_decryption_test_case_256_8),
19120 : :
19121 : : /** AES GCM Authenticated Encryption big aad size */
19122 : : TEST_CASE_ST(ut_setup, ut_teardown,
19123 : : test_AES_GCM_auth_encryption_test_case_aad_1),
19124 : : TEST_CASE_ST(ut_setup, ut_teardown,
19125 : : test_AES_GCM_auth_encryption_test_case_aad_2),
19126 : :
19127 : : /** AES GCM Authenticated Decryption big aad size */
19128 : : TEST_CASE_ST(ut_setup, ut_teardown,
19129 : : test_AES_GCM_auth_decryption_test_case_aad_1),
19130 : : TEST_CASE_ST(ut_setup, ut_teardown,
19131 : : test_AES_GCM_auth_decryption_test_case_aad_2),
19132 : :
19133 : : /** Out of place tests */
19134 : : TEST_CASE_ST(ut_setup, ut_teardown,
19135 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
19136 : : TEST_CASE_ST(ut_setup, ut_teardown,
19137 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
19138 : :
19139 : : /** Session-less tests */
19140 : : TEST_CASE_ST(ut_setup, ut_teardown,
19141 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
19142 : : TEST_CASE_ST(ut_setup, ut_teardown,
19143 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
19144 : :
19145 : : /** AES GCM external mbuf tests */
19146 : : TEST_CASE_ST(ut_setup, ut_teardown,
19147 : : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
19148 : : TEST_CASE_ST(ut_setup, ut_teardown,
19149 : : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
19150 : :
19151 : : TEST_CASES_END()
19152 : : }
19153 : : };
19154 : :
19155 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
19156 : : .suite_name = "AES GMAC Authentication Test Suite",
19157 : : .setup = aes_gmac_auth_testsuite_setup,
19158 : : .unit_test_cases = {
19159 : : TEST_CASE_ST(ut_setup, ut_teardown,
19160 : : test_AES_GMAC_authentication_test_case_1),
19161 : : TEST_CASE_ST(ut_setup, ut_teardown,
19162 : : test_AES_GMAC_authentication_verify_test_case_1),
19163 : : TEST_CASE_ST(ut_setup, ut_teardown,
19164 : : test_AES_GMAC_authentication_test_case_2),
19165 : : TEST_CASE_ST(ut_setup, ut_teardown,
19166 : : test_AES_GMAC_authentication_verify_test_case_2),
19167 : : TEST_CASE_ST(ut_setup, ut_teardown,
19168 : : test_AES_GMAC_authentication_test_case_3),
19169 : : TEST_CASE_ST(ut_setup, ut_teardown,
19170 : : test_AES_GMAC_authentication_verify_test_case_3),
19171 : : TEST_CASE_ST(ut_setup, ut_teardown,
19172 : : test_AES_GMAC_authentication_test_case_4),
19173 : : TEST_CASE_ST(ut_setup, ut_teardown,
19174 : : test_AES_GMAC_authentication_verify_test_case_4),
19175 : : TEST_CASE_ST(ut_setup, ut_teardown,
19176 : : test_AES_GMAC_authentication_SGL_40B),
19177 : : TEST_CASE_ST(ut_setup, ut_teardown,
19178 : : test_AES_GMAC_authentication_SGL_80B),
19179 : : TEST_CASE_ST(ut_setup, ut_teardown,
19180 : : test_AES_GMAC_authentication_SGL_2048B),
19181 : : TEST_CASE_ST(ut_setup, ut_teardown,
19182 : : test_AES_GMAC_authentication_SGL_2047B),
19183 : :
19184 : : TEST_CASES_END()
19185 : : }
19186 : : };
19187 : :
19188 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
19189 : : .suite_name = "Chacha20-Poly1305 Test Suite",
19190 : : .setup = chacha20_poly1305_testsuite_setup,
19191 : : .unit_test_cases = {
19192 : : TEST_CASE_ST(ut_setup, ut_teardown,
19193 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
19194 : : TEST_CASE_ST(ut_setup, ut_teardown,
19195 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
19196 : : TEST_CASE_ST(ut_setup, ut_teardown,
19197 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
19198 : : TEST_CASES_END()
19199 : : }
19200 : : };
19201 : :
19202 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
19203 : : .suite_name = "SNOW 3G Test Suite",
19204 : : .setup = snow3g_testsuite_setup,
19205 : : .unit_test_cases = {
19206 : : /** SNOW 3G encrypt only (UEA2) */
19207 : : TEST_CASE_ST(ut_setup, ut_teardown,
19208 : : test_snow3g_encryption_test_case_1),
19209 : : TEST_CASE_ST(ut_setup, ut_teardown,
19210 : : test_snow3g_encryption_test_case_2),
19211 : : TEST_CASE_ST(ut_setup, ut_teardown,
19212 : : test_snow3g_encryption_test_case_3),
19213 : : TEST_CASE_ST(ut_setup, ut_teardown,
19214 : : test_snow3g_encryption_test_case_4),
19215 : : TEST_CASE_ST(ut_setup, ut_teardown,
19216 : : test_snow3g_encryption_test_case_5),
19217 : :
19218 : : TEST_CASE_ST(ut_setup, ut_teardown,
19219 : : test_snow3g_encryption_test_case_1_oop),
19220 : : TEST_CASE_ST(ut_setup, ut_teardown,
19221 : : test_snow3g_encryption_test_case_1_oop_sgl),
19222 : : TEST_CASE_ST(ut_setup, ut_teardown,
19223 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
19224 : : TEST_CASE_ST(ut_setup, ut_teardown,
19225 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
19226 : : TEST_CASE_ST(ut_setup, ut_teardown,
19227 : : test_snow3g_encryption_test_case_1_offset_oop),
19228 : : TEST_CASE_ST(ut_setup, ut_teardown,
19229 : : test_snow3g_decryption_test_case_1_oop),
19230 : :
19231 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
19232 : : TEST_CASE_ST(ut_setup, ut_teardown,
19233 : : test_snow3g_auth_cipher_test_case_1),
19234 : : TEST_CASE_ST(ut_setup, ut_teardown,
19235 : : test_snow3g_auth_cipher_test_case_2),
19236 : : TEST_CASE_ST(ut_setup, ut_teardown,
19237 : : test_snow3g_auth_cipher_test_case_2_oop),
19238 : : TEST_CASE_ST(ut_setup, ut_teardown,
19239 : : test_snow3g_auth_cipher_part_digest_enc),
19240 : : TEST_CASE_ST(ut_setup, ut_teardown,
19241 : : test_snow3g_auth_cipher_part_digest_enc_oop),
19242 : : TEST_CASE_ST(ut_setup, ut_teardown,
19243 : : test_snow3g_auth_cipher_test_case_3_sgl),
19244 : : TEST_CASE_ST(ut_setup, ut_teardown,
19245 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
19246 : : TEST_CASE_ST(ut_setup, ut_teardown,
19247 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
19248 : : TEST_CASE_ST(ut_setup, ut_teardown,
19249 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
19250 : : TEST_CASE_ST(ut_setup, ut_teardown,
19251 : : test_snow3g_auth_cipher_total_digest_enc_1),
19252 : : TEST_CASE_ST(ut_setup, ut_teardown,
19253 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
19254 : : TEST_CASE_ST(ut_setup, ut_teardown,
19255 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
19256 : : TEST_CASE_ST(ut_setup, ut_teardown,
19257 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
19258 : :
19259 : : /** SNOW 3G decrypt (UEA2), then verify auth */
19260 : : TEST_CASE_ST(ut_setup, ut_teardown,
19261 : : test_snow3g_auth_cipher_verify_test_case_1),
19262 : : TEST_CASE_ST(ut_setup, ut_teardown,
19263 : : test_snow3g_auth_cipher_verify_test_case_2),
19264 : : TEST_CASE_ST(ut_setup, ut_teardown,
19265 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
19266 : : TEST_CASE_ST(ut_setup, ut_teardown,
19267 : : test_snow3g_auth_cipher_verify_part_digest_enc),
19268 : : TEST_CASE_ST(ut_setup, ut_teardown,
19269 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
19270 : : TEST_CASE_ST(ut_setup, ut_teardown,
19271 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
19272 : : TEST_CASE_ST(ut_setup, ut_teardown,
19273 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
19274 : : TEST_CASE_ST(ut_setup, ut_teardown,
19275 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
19276 : : TEST_CASE_ST(ut_setup, ut_teardown,
19277 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
19278 : : TEST_CASE_ST(ut_setup, ut_teardown,
19279 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
19280 : : TEST_CASE_ST(ut_setup, ut_teardown,
19281 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
19282 : : TEST_CASE_ST(ut_setup, ut_teardown,
19283 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
19284 : : TEST_CASE_ST(ut_setup, ut_teardown,
19285 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
19286 : :
19287 : : /** SNOW 3G decrypt only (UEA2) */
19288 : : TEST_CASE_ST(ut_setup, ut_teardown,
19289 : : test_snow3g_decryption_test_case_1),
19290 : : TEST_CASE_ST(ut_setup, ut_teardown,
19291 : : test_snow3g_decryption_test_case_2),
19292 : : TEST_CASE_ST(ut_setup, ut_teardown,
19293 : : test_snow3g_decryption_test_case_3),
19294 : : TEST_CASE_ST(ut_setup, ut_teardown,
19295 : : test_snow3g_decryption_test_case_4),
19296 : : TEST_CASE_ST(ut_setup, ut_teardown,
19297 : : test_snow3g_decryption_test_case_5),
19298 : : TEST_CASE_ST(ut_setup, ut_teardown,
19299 : : test_snow3g_decryption_with_digest_test_case_1),
19300 : : TEST_CASE_ST(ut_setup, ut_teardown,
19301 : : test_snow3g_hash_generate_test_case_1),
19302 : : TEST_CASE_ST(ut_setup, ut_teardown,
19303 : : test_snow3g_hash_generate_test_case_2),
19304 : : TEST_CASE_ST(ut_setup, ut_teardown,
19305 : : test_snow3g_hash_generate_test_case_3),
19306 : :
19307 : : /* Tests with buffers which length is not byte-aligned */
19308 : : TEST_CASE_ST(ut_setup, ut_teardown,
19309 : : test_snow3g_hash_generate_test_case_4),
19310 : : TEST_CASE_ST(ut_setup, ut_teardown,
19311 : : test_snow3g_hash_generate_test_case_5),
19312 : : TEST_CASE_ST(ut_setup, ut_teardown,
19313 : : test_snow3g_hash_generate_test_case_6),
19314 : : TEST_CASE_ST(ut_setup, ut_teardown,
19315 : : test_snow3g_hash_verify_test_case_1),
19316 : : TEST_CASE_ST(ut_setup, ut_teardown,
19317 : : test_snow3g_hash_verify_test_case_2),
19318 : : TEST_CASE_ST(ut_setup, ut_teardown,
19319 : : test_snow3g_hash_verify_test_case_3),
19320 : :
19321 : : /* Tests with buffers which length is not byte-aligned */
19322 : : TEST_CASE_ST(ut_setup, ut_teardown,
19323 : : test_snow3g_hash_verify_test_case_4),
19324 : : TEST_CASE_ST(ut_setup, ut_teardown,
19325 : : test_snow3g_hash_verify_test_case_5),
19326 : : TEST_CASE_ST(ut_setup, ut_teardown,
19327 : : test_snow3g_hash_verify_test_case_6),
19328 : : TEST_CASE_ST(ut_setup, ut_teardown,
19329 : : test_snow3g_cipher_auth_test_case_1),
19330 : : TEST_CASE_ST(ut_setup, ut_teardown,
19331 : : test_snow3g_auth_cipher_with_digest_test_case_1),
19332 : : TEST_CASES_END()
19333 : : }
19334 : : };
19335 : :
19336 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
19337 : : .suite_name = "ZUC Test Suite",
19338 : : .setup = zuc_testsuite_setup,
19339 : : .unit_test_cases = {
19340 : : /** ZUC encrypt only (EEA3) */
19341 : : TEST_CASE_ST(ut_setup, ut_teardown,
19342 : : test_zuc_encryption_test_case_1),
19343 : : TEST_CASE_ST(ut_setup, ut_teardown,
19344 : : test_zuc_encryption_test_case_2),
19345 : : TEST_CASE_ST(ut_setup, ut_teardown,
19346 : : test_zuc_encryption_test_case_3),
19347 : : TEST_CASE_ST(ut_setup, ut_teardown,
19348 : : test_zuc_encryption_test_case_4),
19349 : : TEST_CASE_ST(ut_setup, ut_teardown,
19350 : : test_zuc_encryption_test_case_5),
19351 : : TEST_CASE_ST(ut_setup, ut_teardown,
19352 : : test_zuc_encryption_test_case_6_sgl),
19353 : :
19354 : : /** ZUC decrypt only (EEA3) */
19355 : : TEST_CASE_ST(ut_setup, ut_teardown,
19356 : : test_zuc_decryption_test_case_1),
19357 : : TEST_CASE_ST(ut_setup, ut_teardown,
19358 : : test_zuc_decryption_test_case_2),
19359 : : TEST_CASE_ST(ut_setup, ut_teardown,
19360 : : test_zuc_decryption_test_case_3),
19361 : : TEST_CASE_ST(ut_setup, ut_teardown,
19362 : : test_zuc_decryption_test_case_4),
19363 : : TEST_CASE_ST(ut_setup, ut_teardown,
19364 : : test_zuc_decryption_test_case_5),
19365 : : TEST_CASE_ST(ut_setup, ut_teardown,
19366 : : test_zuc_decryption_test_case_6_sgl),
19367 : :
19368 : : /** ZUC authenticate (EIA3) */
19369 : : TEST_CASE_ST(ut_setup, ut_teardown,
19370 : : test_zuc_hash_generate_test_case_1),
19371 : : TEST_CASE_ST(ut_setup, ut_teardown,
19372 : : test_zuc_hash_generate_test_case_2),
19373 : : TEST_CASE_ST(ut_setup, ut_teardown,
19374 : : test_zuc_hash_generate_test_case_3),
19375 : : TEST_CASE_ST(ut_setup, ut_teardown,
19376 : : test_zuc_hash_generate_test_case_4),
19377 : : TEST_CASE_ST(ut_setup, ut_teardown,
19378 : : test_zuc_hash_generate_test_case_5),
19379 : : TEST_CASE_ST(ut_setup, ut_teardown,
19380 : : test_zuc_hash_generate_test_case_6),
19381 : : TEST_CASE_ST(ut_setup, ut_teardown,
19382 : : test_zuc_hash_generate_test_case_7),
19383 : : TEST_CASE_ST(ut_setup, ut_teardown,
19384 : : test_zuc_hash_generate_test_case_8),
19385 : :
19386 : : /** ZUC verify (EIA3) */
19387 : : TEST_CASE_ST(ut_setup, ut_teardown,
19388 : : test_zuc_hash_verify_test_case_1),
19389 : : TEST_CASE_ST(ut_setup, ut_teardown,
19390 : : test_zuc_hash_verify_test_case_2),
19391 : : TEST_CASE_ST(ut_setup, ut_teardown,
19392 : : test_zuc_hash_verify_test_case_3),
19393 : : TEST_CASE_ST(ut_setup, ut_teardown,
19394 : : test_zuc_hash_verify_test_case_4),
19395 : : TEST_CASE_ST(ut_setup, ut_teardown,
19396 : : test_zuc_hash_verify_test_case_5),
19397 : : TEST_CASE_ST(ut_setup, ut_teardown,
19398 : : test_zuc_hash_verify_test_case_6),
19399 : : TEST_CASE_ST(ut_setup, ut_teardown,
19400 : : test_zuc_hash_verify_test_case_7),
19401 : : TEST_CASE_ST(ut_setup, ut_teardown,
19402 : : test_zuc_hash_verify_test_case_8),
19403 : :
19404 : : /** ZUC alg-chain (EEA3/EIA3) */
19405 : : TEST_CASE_ST(ut_setup, ut_teardown,
19406 : : test_zuc_cipher_auth_test_case_1),
19407 : : TEST_CASE_ST(ut_setup, ut_teardown,
19408 : : test_zuc_cipher_auth_test_case_2),
19409 : :
19410 : : /** ZUC generate auth, then encrypt (EEA3) */
19411 : : TEST_CASE_ST(ut_setup, ut_teardown,
19412 : : test_zuc_auth_cipher_test_case_1),
19413 : : TEST_CASE_ST(ut_setup, ut_teardown,
19414 : : test_zuc_auth_cipher_test_case_1_oop),
19415 : : TEST_CASE_ST(ut_setup, ut_teardown,
19416 : : test_zuc_auth_cipher_test_case_1_sgl),
19417 : : TEST_CASE_ST(ut_setup, ut_teardown,
19418 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
19419 : : TEST_CASE_ST(ut_setup, ut_teardown,
19420 : : test_zuc_auth_cipher_test_case_2),
19421 : : TEST_CASE_ST(ut_setup, ut_teardown,
19422 : : test_zuc_auth_cipher_test_case_2_oop),
19423 : :
19424 : : /** ZUC decrypt (EEA3), then verify auth */
19425 : : TEST_CASE_ST(ut_setup, ut_teardown,
19426 : : test_zuc_auth_cipher_verify_test_case_1),
19427 : : TEST_CASE_ST(ut_setup, ut_teardown,
19428 : : test_zuc_auth_cipher_verify_test_case_1_oop),
19429 : : TEST_CASE_ST(ut_setup, ut_teardown,
19430 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
19431 : : TEST_CASE_ST(ut_setup, ut_teardown,
19432 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
19433 : : TEST_CASE_ST(ut_setup, ut_teardown,
19434 : : test_zuc_auth_cipher_verify_test_case_2),
19435 : : TEST_CASE_ST(ut_setup, ut_teardown,
19436 : : test_zuc_auth_cipher_verify_test_case_2_oop),
19437 : :
19438 : : /** ZUC-256 encrypt only **/
19439 : : TEST_CASE_ST(ut_setup, ut_teardown,
19440 : : test_zuc256_encryption_test_case_1),
19441 : : TEST_CASE_ST(ut_setup, ut_teardown,
19442 : : test_zuc256_encryption_test_case_2),
19443 : :
19444 : : /** ZUC-256 decrypt only **/
19445 : : TEST_CASE_ST(ut_setup, ut_teardown,
19446 : : test_zuc256_decryption_test_case_1),
19447 : : TEST_CASE_ST(ut_setup, ut_teardown,
19448 : : test_zuc256_decryption_test_case_2),
19449 : :
19450 : : /** ZUC-256 authentication only **/
19451 : : TEST_CASE_ST(ut_setup, ut_teardown,
19452 : : test_zuc256_hash_generate_4b_tag_test_case_1),
19453 : : TEST_CASE_ST(ut_setup, ut_teardown,
19454 : : test_zuc256_hash_generate_4b_tag_test_case_2),
19455 : : TEST_CASE_ST(ut_setup, ut_teardown,
19456 : : test_zuc256_hash_generate_4b_tag_test_case_3),
19457 : : TEST_CASE_ST(ut_setup, ut_teardown,
19458 : : test_zuc256_hash_generate_8b_tag_test_case_1),
19459 : : TEST_CASE_ST(ut_setup, ut_teardown,
19460 : : test_zuc256_hash_generate_16b_tag_test_case_1),
19461 : :
19462 : : /** ZUC-256 authentication verify only **/
19463 : : TEST_CASE_ST(ut_setup, ut_teardown,
19464 : : test_zuc256_hash_verify_4b_tag_test_case_1),
19465 : : TEST_CASE_ST(ut_setup, ut_teardown,
19466 : : test_zuc256_hash_verify_4b_tag_test_case_2),
19467 : : TEST_CASE_ST(ut_setup, ut_teardown,
19468 : : test_zuc256_hash_verify_4b_tag_test_case_3),
19469 : : TEST_CASE_ST(ut_setup, ut_teardown,
19470 : : test_zuc256_hash_verify_8b_tag_test_case_1),
19471 : : TEST_CASE_ST(ut_setup, ut_teardown,
19472 : : test_zuc256_hash_verify_16b_tag_test_case_1),
19473 : :
19474 : : /** ZUC-256 encrypt and authenticate **/
19475 : : TEST_CASE_ST(ut_setup, ut_teardown,
19476 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
19477 : : TEST_CASE_ST(ut_setup, ut_teardown,
19478 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
19479 : : TEST_CASE_ST(ut_setup, ut_teardown,
19480 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
19481 : : TEST_CASE_ST(ut_setup, ut_teardown,
19482 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
19483 : :
19484 : : /** ZUC-256 generate auth, then encrypt */
19485 : : TEST_CASE_ST(ut_setup, ut_teardown,
19486 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
19487 : : TEST_CASE_ST(ut_setup, ut_teardown,
19488 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
19489 : : TEST_CASE_ST(ut_setup, ut_teardown,
19490 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
19491 : : TEST_CASE_ST(ut_setup, ut_teardown,
19492 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
19493 : :
19494 : : /** ZUC-256 decrypt, then verify auth */
19495 : : TEST_CASE_ST(ut_setup, ut_teardown,
19496 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19497 : : TEST_CASE_ST(ut_setup, ut_teardown,
19498 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19499 : : TEST_CASE_ST(ut_setup, ut_teardown,
19500 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19501 : : TEST_CASE_ST(ut_setup, ut_teardown,
19502 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19503 : :
19504 : : TEST_CASES_END()
19505 : : }
19506 : : };
19507 : :
19508 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
19509 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
19510 : : .setup = hmac_md5_auth_testsuite_setup,
19511 : : .unit_test_cases = {
19512 : : TEST_CASE_ST(ut_setup, ut_teardown,
19513 : : test_MD5_HMAC_generate_case_1),
19514 : : TEST_CASE_ST(ut_setup, ut_teardown,
19515 : : test_MD5_HMAC_verify_case_1),
19516 : : TEST_CASE_ST(ut_setup, ut_teardown,
19517 : : test_MD5_HMAC_generate_case_2),
19518 : : TEST_CASE_ST(ut_setup, ut_teardown,
19519 : : test_MD5_HMAC_verify_case_2),
19520 : : TEST_CASES_END()
19521 : : }
19522 : : };
19523 : :
19524 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
19525 : : .suite_name = "Kasumi Test Suite",
19526 : : .setup = kasumi_testsuite_setup,
19527 : : .unit_test_cases = {
19528 : : /** KASUMI hash only (UIA1) */
19529 : : TEST_CASE_ST(ut_setup, ut_teardown,
19530 : : test_kasumi_hash_generate_test_case_1),
19531 : : TEST_CASE_ST(ut_setup, ut_teardown,
19532 : : test_kasumi_hash_generate_test_case_2),
19533 : : TEST_CASE_ST(ut_setup, ut_teardown,
19534 : : test_kasumi_hash_generate_test_case_3),
19535 : : TEST_CASE_ST(ut_setup, ut_teardown,
19536 : : test_kasumi_hash_generate_test_case_4),
19537 : : TEST_CASE_ST(ut_setup, ut_teardown,
19538 : : test_kasumi_hash_generate_test_case_5),
19539 : : TEST_CASE_ST(ut_setup, ut_teardown,
19540 : : test_kasumi_hash_generate_test_case_6),
19541 : :
19542 : : TEST_CASE_ST(ut_setup, ut_teardown,
19543 : : test_kasumi_hash_verify_test_case_1),
19544 : : TEST_CASE_ST(ut_setup, ut_teardown,
19545 : : test_kasumi_hash_verify_test_case_2),
19546 : : TEST_CASE_ST(ut_setup, ut_teardown,
19547 : : test_kasumi_hash_verify_test_case_3),
19548 : : TEST_CASE_ST(ut_setup, ut_teardown,
19549 : : test_kasumi_hash_verify_test_case_4),
19550 : : TEST_CASE_ST(ut_setup, ut_teardown,
19551 : : test_kasumi_hash_verify_test_case_5),
19552 : :
19553 : : /** KASUMI encrypt only (UEA1) */
19554 : : TEST_CASE_ST(ut_setup, ut_teardown,
19555 : : test_kasumi_encryption_test_case_1),
19556 : : TEST_CASE_ST(ut_setup, ut_teardown,
19557 : : test_kasumi_encryption_test_case_1_sgl),
19558 : : TEST_CASE_ST(ut_setup, ut_teardown,
19559 : : test_kasumi_encryption_test_case_1_oop),
19560 : : TEST_CASE_ST(ut_setup, ut_teardown,
19561 : : test_kasumi_encryption_test_case_1_oop_sgl),
19562 : : TEST_CASE_ST(ut_setup, ut_teardown,
19563 : : test_kasumi_encryption_test_case_2),
19564 : : TEST_CASE_ST(ut_setup, ut_teardown,
19565 : : test_kasumi_encryption_test_case_3),
19566 : : TEST_CASE_ST(ut_setup, ut_teardown,
19567 : : test_kasumi_encryption_test_case_4),
19568 : : TEST_CASE_ST(ut_setup, ut_teardown,
19569 : : test_kasumi_encryption_test_case_5),
19570 : :
19571 : : /** KASUMI decrypt only (UEA1) */
19572 : : TEST_CASE_ST(ut_setup, ut_teardown,
19573 : : test_kasumi_decryption_test_case_1),
19574 : : TEST_CASE_ST(ut_setup, ut_teardown,
19575 : : test_kasumi_decryption_test_case_2),
19576 : : TEST_CASE_ST(ut_setup, ut_teardown,
19577 : : test_kasumi_decryption_test_case_3),
19578 : : TEST_CASE_ST(ut_setup, ut_teardown,
19579 : : test_kasumi_decryption_test_case_4),
19580 : : TEST_CASE_ST(ut_setup, ut_teardown,
19581 : : test_kasumi_decryption_test_case_5),
19582 : : TEST_CASE_ST(ut_setup, ut_teardown,
19583 : : test_kasumi_decryption_test_case_1_oop),
19584 : : TEST_CASE_ST(ut_setup, ut_teardown,
19585 : : test_kasumi_cipher_auth_test_case_1),
19586 : :
19587 : : /** KASUMI generate auth, then encrypt (F8) */
19588 : : TEST_CASE_ST(ut_setup, ut_teardown,
19589 : : test_kasumi_auth_cipher_test_case_1),
19590 : : TEST_CASE_ST(ut_setup, ut_teardown,
19591 : : test_kasumi_auth_cipher_test_case_2),
19592 : : TEST_CASE_ST(ut_setup, ut_teardown,
19593 : : test_kasumi_auth_cipher_test_case_2_oop),
19594 : : TEST_CASE_ST(ut_setup, ut_teardown,
19595 : : test_kasumi_auth_cipher_test_case_2_sgl),
19596 : : TEST_CASE_ST(ut_setup, ut_teardown,
19597 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
19598 : :
19599 : : /** KASUMI decrypt (F8), then verify auth */
19600 : : TEST_CASE_ST(ut_setup, ut_teardown,
19601 : : test_kasumi_auth_cipher_verify_test_case_1),
19602 : : TEST_CASE_ST(ut_setup, ut_teardown,
19603 : : test_kasumi_auth_cipher_verify_test_case_2),
19604 : : TEST_CASE_ST(ut_setup, ut_teardown,
19605 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
19606 : : TEST_CASE_ST(ut_setup, ut_teardown,
19607 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
19608 : : TEST_CASE_ST(ut_setup, ut_teardown,
19609 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19610 : :
19611 : : TEST_CASES_END()
19612 : : }
19613 : : };
19614 : :
19615 : : static struct unit_test_suite cryptodev_esn_testsuite = {
19616 : : .suite_name = "ESN Test Suite",
19617 : : .setup = esn_testsuite_setup,
19618 : : .unit_test_cases = {
19619 : : TEST_CASE_ST(ut_setup, ut_teardown,
19620 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19621 : : TEST_CASE_ST(ut_setup, ut_teardown,
19622 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19623 : : TEST_CASES_END()
19624 : : }
19625 : : };
19626 : :
19627 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
19628 : : .suite_name = "Negative AES GCM Test Suite",
19629 : : .setup = negative_aes_gcm_testsuite_setup,
19630 : : .unit_test_cases = {
19631 : : TEST_CASE_ST(ut_setup, ut_teardown,
19632 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
19633 : : TEST_CASE_ST(ut_setup, ut_teardown,
19634 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19635 : : TEST_CASE_ST(ut_setup, ut_teardown,
19636 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19637 : : TEST_CASE_ST(ut_setup, ut_teardown,
19638 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19639 : : TEST_CASE_ST(ut_setup, ut_teardown,
19640 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
19641 : : TEST_CASE_ST(ut_setup, ut_teardown,
19642 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
19643 : : TEST_CASE_ST(ut_setup, ut_teardown,
19644 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
19645 : : TEST_CASE_ST(ut_setup, ut_teardown,
19646 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19647 : : TEST_CASE_ST(ut_setup, ut_teardown,
19648 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19649 : : TEST_CASE_ST(ut_setup, ut_teardown,
19650 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19651 : : TEST_CASE_ST(ut_setup, ut_teardown,
19652 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
19653 : : TEST_CASE_ST(ut_setup, ut_teardown,
19654 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
19655 : :
19656 : : TEST_CASES_END()
19657 : : }
19658 : : };
19659 : :
19660 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
19661 : : .suite_name = "Negative AES GMAC Test Suite",
19662 : : .setup = negative_aes_gmac_testsuite_setup,
19663 : : .unit_test_cases = {
19664 : : TEST_CASE_ST(ut_setup, ut_teardown,
19665 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
19666 : : TEST_CASE_ST(ut_setup, ut_teardown,
19667 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
19668 : :
19669 : : TEST_CASES_END()
19670 : : }
19671 : : };
19672 : :
19673 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
19674 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19675 : : .setup = mixed_cipher_hash_testsuite_setup,
19676 : : .unit_test_cases = {
19677 : : /** AUTH AES CMAC + CIPHER AES CTR */
19678 : : TEST_CASE_ST(ut_setup, ut_teardown,
19679 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19680 : : TEST_CASE_ST(ut_setup, ut_teardown,
19681 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19682 : : TEST_CASE_ST(ut_setup, ut_teardown,
19683 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19684 : : TEST_CASE_ST(ut_setup, ut_teardown,
19685 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19686 : : TEST_CASE_ST(ut_setup, ut_teardown,
19687 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19688 : : TEST_CASE_ST(ut_setup, ut_teardown,
19689 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19690 : : TEST_CASE_ST(ut_setup, ut_teardown,
19691 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19692 : : TEST_CASE_ST(ut_setup, ut_teardown,
19693 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19694 : : TEST_CASE_ST(ut_setup, ut_teardown,
19695 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19696 : : TEST_CASE_ST(ut_setup, ut_teardown,
19697 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19698 : : TEST_CASE_ST(ut_setup, ut_teardown,
19699 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19700 : : TEST_CASE_ST(ut_setup, ut_teardown,
19701 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19702 : :
19703 : : /** AUTH ZUC + CIPHER SNOW3G */
19704 : : TEST_CASE_ST(ut_setup, ut_teardown,
19705 : : test_auth_zuc_cipher_snow_test_case_1),
19706 : : TEST_CASE_ST(ut_setup, ut_teardown,
19707 : : test_verify_auth_zuc_cipher_snow_test_case_1),
19708 : : TEST_CASE_ST(ut_setup, ut_teardown,
19709 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
19710 : : TEST_CASE_ST(ut_setup, ut_teardown,
19711 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19712 : : /** AUTH AES CMAC + CIPHER SNOW3G */
19713 : : TEST_CASE_ST(ut_setup, ut_teardown,
19714 : : test_auth_aes_cmac_cipher_snow_test_case_1),
19715 : : TEST_CASE_ST(ut_setup, ut_teardown,
19716 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19717 : : TEST_CASE_ST(ut_setup, ut_teardown,
19718 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19719 : : TEST_CASE_ST(ut_setup, ut_teardown,
19720 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19721 : : /** AUTH ZUC + CIPHER AES CTR */
19722 : : TEST_CASE_ST(ut_setup, ut_teardown,
19723 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
19724 : : TEST_CASE_ST(ut_setup, ut_teardown,
19725 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19726 : : TEST_CASE_ST(ut_setup, ut_teardown,
19727 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19728 : : TEST_CASE_ST(ut_setup, ut_teardown,
19729 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19730 : : /** AUTH SNOW3G + CIPHER AES CTR */
19731 : : TEST_CASE_ST(ut_setup, ut_teardown,
19732 : : test_auth_snow_cipher_aes_ctr_test_case_1),
19733 : : TEST_CASE_ST(ut_setup, ut_teardown,
19734 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19735 : : TEST_CASE_ST(ut_setup, ut_teardown,
19736 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19737 : : TEST_CASE_ST(ut_setup, ut_teardown,
19738 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19739 : : TEST_CASE_ST(ut_setup, ut_teardown,
19740 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19741 : : TEST_CASE_ST(ut_setup, ut_teardown,
19742 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19743 : : /** AUTH SNOW3G + CIPHER ZUC */
19744 : : TEST_CASE_ST(ut_setup, ut_teardown,
19745 : : test_auth_snow_cipher_zuc_test_case_1),
19746 : : TEST_CASE_ST(ut_setup, ut_teardown,
19747 : : test_verify_auth_snow_cipher_zuc_test_case_1),
19748 : : TEST_CASE_ST(ut_setup, ut_teardown,
19749 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
19750 : : TEST_CASE_ST(ut_setup, ut_teardown,
19751 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19752 : : /** AUTH AES CMAC + CIPHER ZUC */
19753 : : TEST_CASE_ST(ut_setup, ut_teardown,
19754 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
19755 : : TEST_CASE_ST(ut_setup, ut_teardown,
19756 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19757 : : TEST_CASE_ST(ut_setup, ut_teardown,
19758 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19759 : : TEST_CASE_ST(ut_setup, ut_teardown,
19760 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19761 : :
19762 : : /** AUTH NULL + CIPHER SNOW3G */
19763 : : TEST_CASE_ST(ut_setup, ut_teardown,
19764 : : test_auth_null_cipher_snow_test_case_1),
19765 : : TEST_CASE_ST(ut_setup, ut_teardown,
19766 : : test_verify_auth_null_cipher_snow_test_case_1),
19767 : : /** AUTH NULL + CIPHER ZUC */
19768 : : TEST_CASE_ST(ut_setup, ut_teardown,
19769 : : test_auth_null_cipher_zuc_test_case_1),
19770 : : TEST_CASE_ST(ut_setup, ut_teardown,
19771 : : test_verify_auth_null_cipher_zuc_test_case_1),
19772 : : /** AUTH SNOW3G + CIPHER NULL */
19773 : : TEST_CASE_ST(ut_setup, ut_teardown,
19774 : : test_auth_snow_cipher_null_test_case_1),
19775 : : TEST_CASE_ST(ut_setup, ut_teardown,
19776 : : test_verify_auth_snow_cipher_null_test_case_1),
19777 : : /** AUTH ZUC + CIPHER NULL */
19778 : : TEST_CASE_ST(ut_setup, ut_teardown,
19779 : : test_auth_zuc_cipher_null_test_case_1),
19780 : : TEST_CASE_ST(ut_setup, ut_teardown,
19781 : : test_verify_auth_zuc_cipher_null_test_case_1),
19782 : : /** AUTH NULL + CIPHER AES CTR */
19783 : : TEST_CASE_ST(ut_setup, ut_teardown,
19784 : : test_auth_null_cipher_aes_ctr_test_case_1),
19785 : : TEST_CASE_ST(ut_setup, ut_teardown,
19786 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
19787 : : /** AUTH AES CMAC + CIPHER NULL */
19788 : : TEST_CASE_ST(ut_setup, ut_teardown,
19789 : : test_auth_aes_cmac_cipher_null_test_case_1),
19790 : : TEST_CASE_ST(ut_setup, ut_teardown,
19791 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
19792 : : TEST_CASES_END()
19793 : : }
19794 : : };
19795 : :
19796 : : static struct unit_test_suite cryptodev_sm4_gcm_testsuite = {
19797 : : .suite_name = "SM4 GCM Test Suite",
19798 : : .setup = sm4_gcm_testsuite_setup,
19799 : : .unit_test_cases = {
19800 : : TEST_CASE_ST(ut_setup, ut_teardown,
19801 : : test_SM4_GCM_case_1),
19802 : : TEST_CASE_ST(ut_setup, ut_teardown,
19803 : : test_SM4_GCM_case_2),
19804 : : TEST_CASE_ST(ut_setup, ut_teardown,
19805 : : test_SM4_GCM_case_3),
19806 : : TEST_CASE_ST(ut_setup, ut_teardown,
19807 : : test_SM4_GCM_case_4),
19808 : : TEST_CASE_ST(ut_setup, ut_teardown,
19809 : : test_SM4_GCM_case_5),
19810 : : TEST_CASE_ST(ut_setup, ut_teardown,
19811 : : test_SM4_GCM_case_6),
19812 : : TEST_CASE_ST(ut_setup, ut_teardown,
19813 : : test_SM4_GCM_case_7),
19814 : : TEST_CASE_ST(ut_setup, ut_teardown,
19815 : : test_SM4_GCM_case_8),
19816 : : TEST_CASE_ST(ut_setup, ut_teardown,
19817 : : test_SM4_GCM_case_9),
19818 : : TEST_CASE_ST(ut_setup, ut_teardown,
19819 : : test_SM4_GCM_case_10),
19820 : : TEST_CASE_ST(ut_setup, ut_teardown,
19821 : : test_SM4_GCM_case_11),
19822 : : TEST_CASE_ST(ut_setup, ut_teardown,
19823 : : test_SM4_GCM_case_12),
19824 : : TEST_CASE_ST(ut_setup, ut_teardown,
19825 : : test_SM4_GCM_case_13),
19826 : : TEST_CASE_ST(ut_setup, ut_teardown,
19827 : : test_SM4_GCM_case_14),
19828 : : TEST_CASE_ST(ut_setup, ut_teardown,
19829 : : test_SM4_GCM_case_15),
19830 : : TEST_CASES_END()
19831 : : }
19832 : : };
19833 : :
19834 : : static int
19835 : 1 : run_cryptodev_testsuite(const char *pmd_name)
19836 : : {
19837 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
19838 : 1 : const enum blockcipher_test_type blk_suites[] = {
19839 : : BLKCIPHER_AES_CHAIN_TYPE,
19840 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
19841 : : BLKCIPHER_AES_DOCSIS_TYPE,
19842 : : BLKCIPHER_3DES_CHAIN_TYPE,
19843 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
19844 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
19845 : : BLKCIPHER_DES_DOCSIS_TYPE,
19846 : : BLKCIPHER_SM4_CHAIN_TYPE,
19847 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
19848 : : BLKCIPHER_AUTHONLY_TYPE};
19849 : 1 : struct unit_test_suite *static_suites[] = {
19850 : : &cryptodev_multi_session_testsuite,
19851 : : &cryptodev_null_testsuite,
19852 : : &cryptodev_aes_ccm_auth_testsuite,
19853 : : &cryptodev_aes_gcm_auth_testsuite,
19854 : : &cryptodev_aes_gmac_auth_testsuite,
19855 : : &cryptodev_snow3g_testsuite,
19856 : : &cryptodev_chacha20_poly1305_testsuite,
19857 : : &cryptodev_zuc_testsuite,
19858 : : &cryptodev_hmac_md5_auth_testsuite,
19859 : : &cryptodev_kasumi_testsuite,
19860 : : &cryptodev_esn_testsuite,
19861 : : &cryptodev_negative_aes_gcm_testsuite,
19862 : : &cryptodev_negative_aes_gmac_testsuite,
19863 : : &cryptodev_mixed_cipher_hash_testsuite,
19864 : : &cryptodev_negative_hmac_sha1_testsuite,
19865 : : &cryptodev_gen_testsuite,
19866 : : &cryptodev_sm4_gcm_testsuite,
19867 : : #ifdef RTE_LIB_SECURITY
19868 : : &ipsec_proto_testsuite,
19869 : : &pdcp_proto_testsuite,
19870 : : &docsis_proto_testsuite,
19871 : : &tls12_record_proto_testsuite,
19872 : : &dtls12_record_proto_testsuite,
19873 : : &tls13_record_proto_testsuite,
19874 : : #endif
19875 : : &end_testsuite
19876 : : };
19877 : : static struct unit_test_suite ts = {
19878 : : .suite_name = "Cryptodev Unit Test Suite",
19879 : : .setup = testsuite_setup,
19880 : : .teardown = testsuite_teardown,
19881 : : .unit_test_cases = {TEST_CASES_END()}
19882 : : };
19883 : :
19884 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
19885 : :
19886 [ - + ]: 1 : if (gbl_driver_id == -1) {
19887 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
19888 : 0 : return TEST_SKIPPED;
19889 : : }
19890 : :
19891 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19892 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
19893 : :
19894 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
19895 [ + + ]: 25 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19896 : 1 : ret = unit_test_suite_runner(&ts);
19897 : :
19898 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
19899 : 1 : free(ts.unit_test_suites);
19900 : 1 : return ret;
19901 : : }
19902 : :
19903 : : static int
19904 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
19905 : : {
19906 : : struct rte_cryptodev_info dev_info;
19907 : : uint8_t i, nb_devs;
19908 : : int driver_id;
19909 : :
19910 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
19911 [ # # ]: 0 : if (driver_id == -1) {
19912 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
19913 : 0 : return TEST_SKIPPED;
19914 : : }
19915 : :
19916 : 0 : nb_devs = rte_cryptodev_count();
19917 [ # # ]: 0 : if (nb_devs < 1) {
19918 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
19919 : 0 : return TEST_SKIPPED;
19920 : : }
19921 : :
19922 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
19923 : 0 : rte_cryptodev_info_get(i, &dev_info);
19924 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
19925 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
19926 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
19927 : : flag_name);
19928 : 0 : return TEST_SKIPPED;
19929 : : }
19930 : : return 0; /* found */
19931 : : }
19932 : : }
19933 : :
19934 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
19935 : 0 : return TEST_SKIPPED;
19936 : : }
19937 : :
19938 : : static int
19939 : 0 : test_cryptodev_qat(void)
19940 : : {
19941 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19942 : : }
19943 : :
19944 : : static int
19945 : 0 : test_cryptodev_uadk(void)
19946 : : {
19947 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
19948 : : }
19949 : :
19950 : : static int
19951 : 0 : test_cryptodev_virtio(void)
19952 : : {
19953 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
19954 : : }
19955 : :
19956 : : static int
19957 : 0 : test_cryptodev_virtio_user(void)
19958 : : {
19959 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_USER_PMD));
19960 : : }
19961 : :
19962 : : static int
19963 : 0 : test_cryptodev_aesni_mb(void)
19964 : : {
19965 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19966 : : }
19967 : :
19968 : : static int
19969 : 0 : test_cryptodev_cpu_aesni_mb(void)
19970 : : {
19971 : : int32_t rc;
19972 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19973 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19974 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19975 : 0 : gbl_action_type = at;
19976 : 0 : return rc;
19977 : : }
19978 : :
19979 : : static int
19980 : 0 : test_cryptodev_chacha_poly_mb(void)
19981 : : {
19982 : : int32_t rc;
19983 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19984 : 0 : rc = run_cryptodev_testsuite(
19985 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
19986 : 0 : gbl_action_type = at;
19987 : 0 : return rc;
19988 : : }
19989 : :
19990 : : static int
19991 : 1 : test_cryptodev_openssl(void)
19992 : : {
19993 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
19994 : : }
19995 : :
19996 : : static int
19997 : 0 : test_cryptodev_aesni_gcm(void)
19998 : : {
19999 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20000 : : }
20001 : :
20002 : : static int
20003 : 0 : test_cryptodev_cpu_aesni_gcm(void)
20004 : : {
20005 : : int32_t rc;
20006 : 0 : enum rte_security_session_action_type at = gbl_action_type;
20007 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
20008 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20009 : 0 : gbl_action_type = at;
20010 : 0 : return rc;
20011 : : }
20012 : :
20013 : : static int
20014 : 0 : test_cryptodev_mlx5(void)
20015 : : {
20016 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
20017 : : }
20018 : :
20019 : : static int
20020 : 0 : test_cryptodev_null(void)
20021 : : {
20022 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
20023 : : }
20024 : :
20025 : : static int
20026 : 0 : test_cryptodev_sw_snow3g(void)
20027 : : {
20028 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
20029 : : }
20030 : :
20031 : : static int
20032 : 0 : test_cryptodev_sw_kasumi(void)
20033 : : {
20034 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
20035 : : }
20036 : :
20037 : : static int
20038 : 0 : test_cryptodev_sw_zuc(void)
20039 : : {
20040 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
20041 : : }
20042 : :
20043 : : static int
20044 : 0 : test_cryptodev_armv8(void)
20045 : : {
20046 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
20047 : : }
20048 : :
20049 : : static int
20050 : 0 : test_cryptodev_mrvl(void)
20051 : : {
20052 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
20053 : : }
20054 : :
20055 : : #ifdef RTE_CRYPTO_SCHEDULER
20056 : :
20057 : : static int
20058 : 0 : test_cryptodev_scheduler(void)
20059 : : {
20060 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
20061 : 0 : const enum blockcipher_test_type blk_suites[] = {
20062 : : BLKCIPHER_AES_CHAIN_TYPE,
20063 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
20064 : : BLKCIPHER_AUTHONLY_TYPE
20065 : : };
20066 : : static struct unit_test_suite scheduler_multicore = {
20067 : : .suite_name = "Scheduler Multicore Unit Test Suite",
20068 : : .setup = scheduler_multicore_testsuite_setup,
20069 : : .teardown = scheduler_mode_testsuite_teardown,
20070 : : .unit_test_cases = {TEST_CASES_END()}
20071 : : };
20072 : : static struct unit_test_suite scheduler_round_robin = {
20073 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
20074 : : .setup = scheduler_roundrobin_testsuite_setup,
20075 : : .teardown = scheduler_mode_testsuite_teardown,
20076 : : .unit_test_cases = {TEST_CASES_END()}
20077 : : };
20078 : : static struct unit_test_suite scheduler_failover = {
20079 : : .suite_name = "Scheduler Failover Unit Test Suite",
20080 : : .setup = scheduler_failover_testsuite_setup,
20081 : : .teardown = scheduler_mode_testsuite_teardown,
20082 : : .unit_test_cases = {TEST_CASES_END()}
20083 : : };
20084 : : static struct unit_test_suite scheduler_pkt_size_distr = {
20085 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
20086 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
20087 : : .teardown = scheduler_mode_testsuite_teardown,
20088 : : .unit_test_cases = {TEST_CASES_END()}
20089 : : };
20090 : 0 : struct unit_test_suite *sched_mode_suites[] = {
20091 : : &scheduler_multicore,
20092 : : &scheduler_round_robin,
20093 : : &scheduler_failover,
20094 : : &scheduler_pkt_size_distr
20095 : : };
20096 : : static struct unit_test_suite scheduler_config = {
20097 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
20098 : : .unit_test_cases = {
20099 : : TEST_CASE(test_scheduler_attach_worker_op),
20100 : : TEST_CASE(test_scheduler_mode_multicore_op),
20101 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
20102 : : TEST_CASE(test_scheduler_mode_failover_op),
20103 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
20104 : : TEST_CASE(test_scheduler_detach_worker_op),
20105 : :
20106 : : TEST_CASES_END() /**< NULL terminate array */
20107 : : }
20108 : : };
20109 : 0 : struct unit_test_suite *static_suites[] = {
20110 : : &scheduler_config,
20111 : : &end_testsuite
20112 : : };
20113 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
20114 : : #ifdef RTE_LIB_SECURITY
20115 : : &docsis_proto_testsuite,
20116 : : #endif
20117 : : &end_testsuite
20118 : : };
20119 : : static struct unit_test_suite ts = {
20120 : : .suite_name = "Scheduler Unit Test Suite",
20121 : : .setup = scheduler_testsuite_setup,
20122 : : .teardown = testsuite_teardown,
20123 : : .unit_test_cases = {TEST_CASES_END()}
20124 : : };
20125 : :
20126 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
20127 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
20128 : :
20129 [ # # ]: 0 : if (gbl_driver_id == -1) {
20130 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
20131 : 0 : return TEST_SKIPPED;
20132 : : }
20133 : :
20134 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
20135 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
20136 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
20137 : 0 : return TEST_SKIPPED;
20138 : : }
20139 : :
20140 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20141 : : uint8_t blk_i = 0;
20142 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
20143 : : (struct unit_test_suite *) *
20144 : : (RTE_DIM(blk_suites) +
20145 : : RTE_DIM(sched_mode_static_suites) + 1));
20146 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20147 : : blk_suites, RTE_DIM(blk_suites));
20148 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20149 : : sched_mode_static_suites,
20150 : : RTE_DIM(sched_mode_static_suites));
20151 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
20152 : : }
20153 : :
20154 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
20155 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
20156 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
20157 : : RTE_DIM(sched_mode_suites));
20158 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
20159 : 0 : ret = unit_test_suite_runner(&ts);
20160 : :
20161 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20162 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
20163 : : (*sched_mode_suites[sched_i]),
20164 : : RTE_DIM(blk_suites));
20165 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
20166 : : }
20167 : 0 : free(ts.unit_test_suites);
20168 : 0 : return ret;
20169 : : }
20170 : :
20171 : 254 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
20172 : :
20173 : : #endif
20174 : :
20175 : : static int
20176 : 0 : test_cryptodev_dpaa2_sec(void)
20177 : : {
20178 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20179 : : }
20180 : :
20181 : : static int
20182 : 0 : test_cryptodev_dpaa_sec(void)
20183 : : {
20184 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20185 : : }
20186 : :
20187 : : static int
20188 : 0 : test_cryptodev_ccp(void)
20189 : : {
20190 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
20191 : : }
20192 : :
20193 : : static int
20194 : 0 : test_cryptodev_octeontx(void)
20195 : : {
20196 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
20197 : : }
20198 : :
20199 : : static int
20200 : 0 : test_cryptodev_caam_jr(void)
20201 : : {
20202 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
20203 : : }
20204 : :
20205 : : static int
20206 : 0 : test_cryptodev_nitrox(void)
20207 : : {
20208 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
20209 : : }
20210 : :
20211 : : static int
20212 : 0 : test_cryptodev_bcmfs(void)
20213 : : {
20214 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
20215 : : }
20216 : :
20217 : : static int
20218 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
20219 : : {
20220 : : int ret;
20221 : :
20222 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
20223 [ # # ]: 0 : if (ret)
20224 : : return ret;
20225 : :
20226 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
20227 : 0 : ret = run_cryptodev_testsuite(pmd_name);
20228 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
20229 : :
20230 : 0 : return ret;
20231 : : }
20232 : :
20233 : : static int
20234 : 0 : test_cryptodev_qat_raw_api(void)
20235 : : {
20236 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20237 : : }
20238 : :
20239 : : static int
20240 : 0 : test_cryptodev_cn9k(void)
20241 : : {
20242 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
20243 : : }
20244 : :
20245 : : static int
20246 : 0 : test_cryptodev_cn10k(void)
20247 : : {
20248 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20249 : : }
20250 : :
20251 : : static int
20252 : 0 : test_cryptodev_cn10k_raw_api(void)
20253 : : {
20254 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20255 : : }
20256 : :
20257 : : static int
20258 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
20259 : : {
20260 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20261 : : }
20262 : :
20263 : : static int
20264 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
20265 : : {
20266 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20267 : : }
20268 : :
20269 : : static int
20270 : 0 : test_cryptodev_zsda(void)
20271 : : {
20272 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZSDA_SYM_PMD));
20273 : : }
20274 : :
20275 : 254 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
20276 : : test_cryptodev_cn10k_raw_api);
20277 : 254 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
20278 : : test_cryptodev_dpaa2_sec_raw_api);
20279 : 254 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
20280 : : test_cryptodev_dpaa_sec_raw_api);
20281 : 254 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
20282 : : test_cryptodev_qat_raw_api);
20283 : 254 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
20284 : 254 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
20285 : 254 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
20286 : : test_cryptodev_cpu_aesni_mb);
20287 : 254 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
20288 : : test_cryptodev_chacha_poly_mb);
20289 : 254 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
20290 : 254 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
20291 : 254 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
20292 : : test_cryptodev_cpu_aesni_gcm);
20293 : 254 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
20294 : 254 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
20295 : 254 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
20296 : 254 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
20297 : 254 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
20298 : 254 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
20299 : 254 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
20300 : 254 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
20301 : 254 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
20302 : 254 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
20303 : 254 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
20304 : 254 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
20305 : 254 : REGISTER_DRIVER_TEST(cryptodev_virtio_user_autotest, test_cryptodev_virtio_user);
20306 : 254 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
20307 : 254 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
20308 : 254 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
20309 : 254 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
20310 : 254 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
20311 : 254 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
20312 : 254 : REGISTER_DRIVER_TEST(cryptodev_zsda_autotest, test_cryptodev_zsda);
|