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 : : 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 : 0 : struct rte_crypto_sym_vec vec = {0};
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 : 0 : struct rte_crypto_sym_vec symvec = {0};
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 : 0 : struct rte_crypto_sym_vec symvec = {0};
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 : : struct rte_mbuf *sgl_buf_head = sgl_buf;
3492 : :
3493 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3494 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3495 : 30 : sgl_buf = sgl_buf->next;
3496 : : }
3497 : :
3498 : : /* The last segment should be large enough to hold full digest */
3499 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3500 : : uint16_t next_data_len = 0;
3501 [ # # ]: 0 : if (sgl_buf->next != NULL) {
3502 : 0 : next_data_len = sgl_buf->next->data_len;
3503 : :
3504 : 0 : rte_pktmbuf_free(sgl_buf->next);
3505 : 0 : sgl_buf->next = NULL;
3506 : 0 : sgl_buf_head->nb_segs -= 1;
3507 : 0 : sgl_buf_head->pkt_len -= next_data_len;
3508 : : }
3509 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(
3510 : : sgl_buf_head, auth_tag_len - sgl_buf->data_len),
3511 : : "No room to append auth tag");
3512 : : }
3513 : :
3514 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3515 : : uint8_t *, remaining_off);
3516 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3517 : : remaining_off);
3518 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3519 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3520 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3521 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3522 : 0 : sgl_buf = sgl_buf->next;
3523 : : }
3524 : : }
3525 : :
3526 : : /* Copy digest for the verification */
3527 [ + + ]: 2 : if (verify)
3528 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3529 : :
3530 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3531 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3532 : : ut_params->op, uint8_t *, IV_OFFSET);
3533 : :
3534 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3535 : 2 : iv_ptr += cipher_iv_len;
3536 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3537 : :
3538 : : /* Only copy over the offset data needed from src to dst in OOP,
3539 : : * if the auth and cipher offsets are not aligned
3540 : : */
3541 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3542 [ # # ]: 0 : if (cipher_offset > auth_offset)
3543 : 0 : rte_memcpy(
3544 : 0 : rte_pktmbuf_mtod_offset(
3545 : : sym_op->m_dst,
3546 : : uint8_t *, auth_offset >> 3),
3547 : 0 : rte_pktmbuf_mtod_offset(
3548 : : sym_op->m_src,
3549 : : uint8_t *, auth_offset >> 3),
3550 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3551 : : }
3552 : :
3553 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3554 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3555 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3556 : 0 : sym_op->cipher.data.length = cipher_len;
3557 : 0 : sym_op->cipher.data.offset = cipher_offset;
3558 : : } else {
3559 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3560 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3561 : : }
3562 : :
3563 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3564 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3565 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3566 : 0 : sym_op->auth.data.length = auth_len;
3567 : 0 : sym_op->auth.data.offset = auth_offset;
3568 : : } else {
3569 : 2 : sym_op->auth.data.length = auth_len >> 3;
3570 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3571 : : }
3572 : :
3573 : : return 0;
3574 : : }
3575 : :
3576 : : static int
3577 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3578 : : {
3579 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3580 : : struct crypto_unittest_params *ut_params = &unittest_params;
3581 : :
3582 : : int retval;
3583 : : unsigned plaintext_pad_len;
3584 : : unsigned plaintext_len;
3585 : : uint8_t *plaintext;
3586 : : struct rte_cryptodev_info dev_info;
3587 : :
3588 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3589 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3590 : :
3591 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3592 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3593 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3594 : 0 : return TEST_SKIPPED;
3595 : : }
3596 : :
3597 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3598 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3599 : : printf("Device doesn't support RAW data-path APIs.\n");
3600 : 0 : return TEST_SKIPPED;
3601 : : }
3602 : :
3603 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3604 : : return TEST_SKIPPED;
3605 : :
3606 : : /* Verify the capabilities */
3607 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3608 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3609 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3610 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3611 : : &cap_idx) == NULL)
3612 : : return TEST_SKIPPED;
3613 : :
3614 : : /* Create SNOW 3G session */
3615 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3616 : 0 : tdata->key.data, tdata->key.len,
3617 : 0 : tdata->auth_iv.len, tdata->digest.len,
3618 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3619 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3620 [ # # ]: 0 : if (retval < 0)
3621 : : return retval;
3622 : :
3623 : : /* alloc mbuf and set payload */
3624 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3625 : :
3626 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3627 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3628 : :
3629 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3630 : : /* Append data which is padded to a multiple of */
3631 : : /* the algorithms block size */
3632 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3633 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3634 : : plaintext_pad_len);
3635 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3636 : :
3637 : : /* Create SNOW 3G operation */
3638 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3639 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3640 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3641 : 0 : tdata->validAuthLenInBits.len,
3642 : : 0);
3643 [ # # ]: 0 : if (retval < 0)
3644 : : return retval;
3645 : :
3646 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3647 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3648 : : 0);
3649 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3650 : : return retval;
3651 : : } else
3652 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3653 : : ut_params->op);
3654 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3655 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3656 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3657 : : uint8_t *,
3658 : : plaintext_pad_len);
3659 : :
3660 : : /* Validate obuf */
3661 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3662 : : ut_params->digest,
3663 : : tdata->digest.data,
3664 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3665 : : "SNOW 3G Generated auth tag not as expected");
3666 : :
3667 : : return 0;
3668 : : }
3669 : :
3670 : : static int
3671 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3672 : : {
3673 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3674 : : struct crypto_unittest_params *ut_params = &unittest_params;
3675 : :
3676 : : int retval;
3677 : : unsigned plaintext_pad_len;
3678 : : unsigned plaintext_len;
3679 : : uint8_t *plaintext;
3680 : : struct rte_cryptodev_info dev_info;
3681 : :
3682 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3683 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3684 : :
3685 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3686 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3687 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3688 : 0 : return TEST_SKIPPED;
3689 : : }
3690 : :
3691 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3692 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3693 : : printf("Device doesn't support RAW data-path APIs.\n");
3694 : 0 : return TEST_SKIPPED;
3695 : : }
3696 : :
3697 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3698 : : return TEST_SKIPPED;
3699 : :
3700 : : /* Verify the capabilities */
3701 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3702 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3703 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3704 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3705 : : &cap_idx) == NULL)
3706 : : return TEST_SKIPPED;
3707 : :
3708 : : /* Create SNOW 3G session */
3709 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3710 : 0 : tdata->key.data, tdata->key.len,
3711 : 0 : tdata->auth_iv.len, tdata->digest.len,
3712 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3713 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3714 [ # # ]: 0 : if (retval < 0)
3715 : : return retval;
3716 : : /* alloc mbuf and set payload */
3717 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3718 : :
3719 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3720 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3721 : :
3722 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3723 : : /* Append data which is padded to a multiple of */
3724 : : /* the algorithms block size */
3725 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3726 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3727 : : plaintext_pad_len);
3728 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3729 : :
3730 : : /* Create SNOW 3G operation */
3731 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3732 : 0 : tdata->digest.len,
3733 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3734 : : plaintext_pad_len,
3735 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3736 : 0 : tdata->validAuthLenInBits.len,
3737 : : 0);
3738 [ # # ]: 0 : if (retval < 0)
3739 : : return retval;
3740 : :
3741 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3742 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3743 : : 0);
3744 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3745 : : return retval;
3746 : : } else
3747 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3748 : : ut_params->op);
3749 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3750 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3751 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3752 : : uint8_t *,
3753 : : plaintext_pad_len);
3754 : :
3755 : : /* Validate obuf */
3756 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3757 : : return 0;
3758 : : else
3759 : 0 : return -1;
3760 : :
3761 : : return 0;
3762 : : }
3763 : :
3764 : : static int
3765 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3766 : : {
3767 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3768 : : struct crypto_unittest_params *ut_params = &unittest_params;
3769 : :
3770 : : int retval;
3771 : : unsigned plaintext_pad_len;
3772 : : unsigned plaintext_len;
3773 : : uint8_t *plaintext;
3774 : : struct rte_cryptodev_info dev_info;
3775 : :
3776 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3777 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3778 : :
3779 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3780 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3781 : : printf("Device doesn't support RAW data-path APIs.\n");
3782 : 0 : return TEST_SKIPPED;
3783 : : }
3784 : :
3785 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3786 : : return TEST_SKIPPED;
3787 : :
3788 : : /* Verify the capabilities */
3789 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3790 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3791 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3792 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3793 : : &cap_idx) == NULL)
3794 : : return TEST_SKIPPED;
3795 : :
3796 : : /* Create KASUMI session */
3797 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3798 : 0 : tdata->key.data, tdata->key.len,
3799 : 0 : 0, tdata->digest.len,
3800 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3801 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3802 [ # # ]: 0 : if (retval < 0)
3803 : : return retval;
3804 : :
3805 : : /* alloc mbuf and set payload */
3806 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3807 : :
3808 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3809 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3810 : :
3811 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3812 : : /* Append data which is padded to a multiple of */
3813 : : /* the algorithms block size */
3814 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3815 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3816 : : plaintext_pad_len);
3817 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3818 : :
3819 : : /* Create KASUMI operation */
3820 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3821 : : NULL, 0,
3822 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3823 : 0 : tdata->plaintext.len,
3824 : : 0);
3825 [ # # ]: 0 : if (retval < 0)
3826 : : return retval;
3827 : :
3828 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3829 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3830 : : ut_params->op);
3831 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3832 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3833 : : 0);
3834 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3835 : : return retval;
3836 : : } else
3837 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3838 : : ut_params->op);
3839 : :
3840 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3841 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3842 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3843 : : uint8_t *,
3844 : : plaintext_pad_len);
3845 : :
3846 : : /* Validate obuf */
3847 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3848 : : ut_params->digest,
3849 : : tdata->digest.data,
3850 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3851 : : "KASUMI Generated auth tag not as expected");
3852 : :
3853 : : return 0;
3854 : : }
3855 : :
3856 : : static int
3857 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3858 : : {
3859 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3860 : : struct crypto_unittest_params *ut_params = &unittest_params;
3861 : :
3862 : : int retval;
3863 : : unsigned plaintext_pad_len;
3864 : : unsigned plaintext_len;
3865 : : uint8_t *plaintext;
3866 : : struct rte_cryptodev_info dev_info;
3867 : :
3868 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3869 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3870 : :
3871 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3872 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3873 : : printf("Device doesn't support RAW data-path APIs.\n");
3874 : 0 : return TEST_SKIPPED;
3875 : : }
3876 : :
3877 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3878 : : return TEST_SKIPPED;
3879 : :
3880 : : /* Verify the capabilities */
3881 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3882 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3883 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3884 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3885 : : &cap_idx) == NULL)
3886 : : return TEST_SKIPPED;
3887 : :
3888 : : /* Create KASUMI session */
3889 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3890 : 0 : tdata->key.data, tdata->key.len,
3891 : 0 : 0, tdata->digest.len,
3892 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3893 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3894 [ # # ]: 0 : if (retval < 0)
3895 : : return retval;
3896 : : /* alloc mbuf and set payload */
3897 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3898 : :
3899 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3900 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3901 : :
3902 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3903 : : /* Append data which is padded to a multiple */
3904 : : /* of the algorithms block size */
3905 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3906 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3907 : : plaintext_pad_len);
3908 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3909 : :
3910 : : /* Create KASUMI operation */
3911 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3912 : 0 : tdata->digest.len,
3913 : : NULL, 0,
3914 : : plaintext_pad_len,
3915 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3916 : 0 : tdata->plaintext.len,
3917 : : 0);
3918 [ # # ]: 0 : if (retval < 0)
3919 : : return retval;
3920 : :
3921 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3922 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3923 : : 0);
3924 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3925 : : return retval;
3926 : : } else
3927 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3928 : : ut_params->op);
3929 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3930 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3931 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3932 : : uint8_t *,
3933 : : plaintext_pad_len);
3934 : :
3935 : : /* Validate obuf */
3936 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3937 : : return 0;
3938 : : else
3939 : 0 : return -1;
3940 : :
3941 : : return 0;
3942 : : }
3943 : :
3944 : : static int
3945 : 0 : test_snow3g_hash_generate_test_case_1(void)
3946 : : {
3947 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3948 : : }
3949 : :
3950 : : static int
3951 : 0 : test_snow3g_hash_generate_test_case_2(void)
3952 : : {
3953 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3954 : : }
3955 : :
3956 : : static int
3957 : 0 : test_snow3g_hash_generate_test_case_3(void)
3958 : : {
3959 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3960 : : }
3961 : :
3962 : : static int
3963 : 0 : test_snow3g_hash_generate_test_case_4(void)
3964 : : {
3965 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3966 : : }
3967 : :
3968 : : static int
3969 : 0 : test_snow3g_hash_generate_test_case_5(void)
3970 : : {
3971 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3972 : : }
3973 : :
3974 : : static int
3975 : 0 : test_snow3g_hash_generate_test_case_6(void)
3976 : : {
3977 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3978 : : }
3979 : :
3980 : : static int
3981 : 0 : test_snow3g_hash_verify_test_case_1(void)
3982 : : {
3983 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3984 : :
3985 : : }
3986 : :
3987 : : static int
3988 : 0 : test_snow3g_hash_verify_test_case_2(void)
3989 : : {
3990 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3991 : : }
3992 : :
3993 : : static int
3994 : 0 : test_snow3g_hash_verify_test_case_3(void)
3995 : : {
3996 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3997 : : }
3998 : :
3999 : : static int
4000 : 0 : test_snow3g_hash_verify_test_case_4(void)
4001 : : {
4002 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
4003 : : }
4004 : :
4005 : : static int
4006 : 0 : test_snow3g_hash_verify_test_case_5(void)
4007 : : {
4008 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
4009 : : }
4010 : :
4011 : : static int
4012 : 0 : test_snow3g_hash_verify_test_case_6(void)
4013 : : {
4014 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
4015 : : }
4016 : :
4017 : : static int
4018 : 0 : test_kasumi_hash_generate_test_case_1(void)
4019 : : {
4020 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
4021 : : }
4022 : :
4023 : : static int
4024 : 0 : test_kasumi_hash_generate_test_case_2(void)
4025 : : {
4026 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
4027 : : }
4028 : :
4029 : : static int
4030 : 0 : test_kasumi_hash_generate_test_case_3(void)
4031 : : {
4032 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
4033 : : }
4034 : :
4035 : : static int
4036 : 0 : test_kasumi_hash_generate_test_case_4(void)
4037 : : {
4038 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
4039 : : }
4040 : :
4041 : : static int
4042 : 0 : test_kasumi_hash_generate_test_case_5(void)
4043 : : {
4044 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
4045 : : }
4046 : :
4047 : : static int
4048 : 0 : test_kasumi_hash_generate_test_case_6(void)
4049 : : {
4050 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
4051 : : }
4052 : :
4053 : : static int
4054 : 0 : test_kasumi_hash_verify_test_case_1(void)
4055 : : {
4056 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
4057 : : }
4058 : :
4059 : : static int
4060 : 0 : test_kasumi_hash_verify_test_case_2(void)
4061 : : {
4062 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
4063 : : }
4064 : :
4065 : : static int
4066 : 0 : test_kasumi_hash_verify_test_case_3(void)
4067 : : {
4068 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
4069 : : }
4070 : :
4071 : : static int
4072 : 0 : test_kasumi_hash_verify_test_case_4(void)
4073 : : {
4074 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
4075 : : }
4076 : :
4077 : : static int
4078 : 0 : test_kasumi_hash_verify_test_case_5(void)
4079 : : {
4080 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
4081 : : }
4082 : :
4083 : : static int
4084 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
4085 : : {
4086 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4087 : : struct crypto_unittest_params *ut_params = &unittest_params;
4088 : :
4089 : : int retval;
4090 : : uint8_t *plaintext, *ciphertext;
4091 : : unsigned plaintext_pad_len;
4092 : : unsigned plaintext_len;
4093 : : struct rte_cryptodev_info dev_info;
4094 : :
4095 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4096 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4097 : :
4098 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4099 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4100 : : printf("Device doesn't support RAW data-path APIs.\n");
4101 : 0 : return TEST_SKIPPED;
4102 : : }
4103 : :
4104 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4105 : : return TEST_SKIPPED;
4106 : :
4107 : : /* Verify the capabilities */
4108 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4109 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4110 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4111 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4112 : : &cap_idx) == NULL)
4113 : : return TEST_SKIPPED;
4114 : :
4115 : : /* Create KASUMI session */
4116 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4117 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4118 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4119 : 0 : tdata->key.data, tdata->key.len,
4120 : 0 : tdata->cipher_iv.len);
4121 [ # # ]: 0 : if (retval < 0)
4122 : : return retval;
4123 : :
4124 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4125 : :
4126 : : /* Clear mbuf payload */
4127 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4128 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4129 : :
4130 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4131 : : /* Append data which is padded to a multiple */
4132 : : /* of the algorithms block size */
4133 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4134 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4135 : : plaintext_pad_len);
4136 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4137 : :
4138 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4139 : :
4140 : : /* Create KASUMI operation */
4141 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4142 : 0 : tdata->cipher_iv.len,
4143 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4144 : 0 : tdata->validCipherOffsetInBits.len);
4145 [ # # ]: 0 : if (retval < 0)
4146 : : return retval;
4147 : :
4148 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4149 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4150 : 0 : tdata->cipher_iv.len);
4151 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4152 : : return retval;
4153 : : } else
4154 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4155 : : ut_params->op);
4156 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4157 : :
4158 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4159 [ # # ]: 0 : if (ut_params->obuf)
4160 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4161 : : else
4162 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4163 : :
4164 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4165 : :
4166 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4167 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4168 : : /* Validate obuf */
4169 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4170 : : ciphertext,
4171 : : reference_ciphertext,
4172 : : tdata->validCipherLenInBits.len,
4173 : : "KASUMI Ciphertext data not as expected");
4174 : : return 0;
4175 : : }
4176 : :
4177 : : static int
4178 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4179 : : {
4180 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4181 : : struct crypto_unittest_params *ut_params = &unittest_params;
4182 : :
4183 : : int retval;
4184 : :
4185 : : unsigned int plaintext_pad_len;
4186 : : unsigned int plaintext_len;
4187 : :
4188 : : uint8_t buffer[10000];
4189 : : const uint8_t *ciphertext;
4190 : :
4191 : : struct rte_cryptodev_info dev_info;
4192 : :
4193 : : /* Verify the capabilities */
4194 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4195 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4196 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4197 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4198 : : &cap_idx) == NULL)
4199 : : return TEST_SKIPPED;
4200 : :
4201 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4202 : :
4203 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4204 : :
4205 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4206 : : printf("Device doesn't support in-place scatter-gather. "
4207 : : "Test Skipped.\n");
4208 : 0 : return TEST_SKIPPED;
4209 : : }
4210 : :
4211 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4212 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4213 : : printf("Device doesn't support RAW data-path APIs.\n");
4214 : 0 : return TEST_SKIPPED;
4215 : : }
4216 : :
4217 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4218 : : return TEST_SKIPPED;
4219 : :
4220 : : /* Create KASUMI session */
4221 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4222 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4223 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4224 : 0 : tdata->key.data, tdata->key.len,
4225 : 0 : tdata->cipher_iv.len);
4226 [ # # ]: 0 : if (retval < 0)
4227 : : return retval;
4228 : :
4229 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4230 : :
4231 : :
4232 : : /* Append data which is padded to a multiple */
4233 : : /* of the algorithms block size */
4234 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4235 : :
4236 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4237 : : plaintext_pad_len, 10, 0);
4238 : :
4239 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4240 : :
4241 : : /* Create KASUMI operation */
4242 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4243 : 0 : tdata->cipher_iv.len,
4244 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4245 : 0 : tdata->validCipherOffsetInBits.len);
4246 [ # # ]: 0 : if (retval < 0)
4247 : : return retval;
4248 : :
4249 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4250 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4251 : 0 : tdata->cipher_iv.len);
4252 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4253 : : return retval;
4254 : : } else
4255 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4256 : : ut_params->op);
4257 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4258 : :
4259 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4260 : :
4261 [ # # ]: 0 : if (ut_params->obuf)
4262 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4263 : : plaintext_len, buffer);
4264 : : else
4265 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4266 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4267 : : plaintext_len, buffer);
4268 : :
4269 : : /* Validate obuf */
4270 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4271 : :
4272 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4273 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4274 : : /* Validate obuf */
4275 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4276 : : ciphertext,
4277 : : reference_ciphertext,
4278 : : tdata->validCipherLenInBits.len,
4279 : : "KASUMI Ciphertext data not as expected");
4280 : : return 0;
4281 : : }
4282 : :
4283 : : static int
4284 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4285 : : {
4286 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4287 : : struct crypto_unittest_params *ut_params = &unittest_params;
4288 : :
4289 : : int retval;
4290 : : uint8_t *plaintext, *ciphertext;
4291 : : unsigned plaintext_pad_len;
4292 : : unsigned plaintext_len;
4293 : :
4294 : : /* Verify the capabilities */
4295 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4296 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4297 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4298 : : /* Data-path service does not support OOP */
4299 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4300 : : &cap_idx) == NULL)
4301 : : return TEST_SKIPPED;
4302 : :
4303 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4304 : : return TEST_SKIPPED;
4305 : :
4306 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4307 : : return TEST_SKIPPED;
4308 : :
4309 : : /* Create KASUMI session */
4310 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4311 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4312 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4313 : 0 : tdata->key.data, tdata->key.len,
4314 : 0 : tdata->cipher_iv.len);
4315 [ # # ]: 0 : if (retval < 0)
4316 : : return retval;
4317 : :
4318 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4319 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4320 : :
4321 : : /* Clear mbuf payload */
4322 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4323 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4324 : :
4325 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4326 : : /* Append data which is padded to a multiple */
4327 : : /* of the algorithms block size */
4328 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4329 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4330 : : plaintext_pad_len);
4331 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4332 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4333 : :
4334 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4335 : :
4336 : : /* Create KASUMI operation */
4337 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4338 : 0 : tdata->cipher_iv.len,
4339 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4340 : 0 : tdata->validCipherOffsetInBits.len);
4341 [ # # ]: 0 : if (retval < 0)
4342 : : return retval;
4343 : :
4344 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4345 : : ut_params->op);
4346 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4347 : :
4348 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4349 [ # # ]: 0 : if (ut_params->obuf)
4350 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4351 : : else
4352 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4353 : :
4354 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4355 : :
4356 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4357 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4358 : : /* Validate obuf */
4359 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4360 : : ciphertext,
4361 : : reference_ciphertext,
4362 : : tdata->validCipherLenInBits.len,
4363 : : "KASUMI Ciphertext data not as expected");
4364 : : return 0;
4365 : : }
4366 : :
4367 : : static int
4368 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4369 : : {
4370 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4371 : : struct crypto_unittest_params *ut_params = &unittest_params;
4372 : :
4373 : : int retval;
4374 : : unsigned int plaintext_pad_len;
4375 : : unsigned int plaintext_len;
4376 : :
4377 : : const uint8_t *ciphertext;
4378 : : uint8_t buffer[2048];
4379 : :
4380 : : struct rte_cryptodev_info dev_info;
4381 : :
4382 : : /* Verify the capabilities */
4383 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4384 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4385 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4386 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4387 : : &cap_idx) == NULL)
4388 : : return TEST_SKIPPED;
4389 : :
4390 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4391 : : return TEST_SKIPPED;
4392 : :
4393 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4394 : : return TEST_SKIPPED;
4395 : :
4396 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4397 : :
4398 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4399 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4400 : : printf("Device doesn't support out-of-place scatter-gather "
4401 : : "in both input and output mbufs. "
4402 : : "Test Skipped.\n");
4403 : 0 : return TEST_SKIPPED;
4404 : : }
4405 : :
4406 : : /* Create KASUMI session */
4407 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4408 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4409 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4410 : 0 : tdata->key.data, tdata->key.len,
4411 : 0 : tdata->cipher_iv.len);
4412 [ # # ]: 0 : if (retval < 0)
4413 : : return retval;
4414 : :
4415 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4416 : : /* Append data which is padded to a multiple */
4417 : : /* of the algorithms block size */
4418 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4419 : :
4420 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4421 : : plaintext_pad_len, 10, 0);
4422 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4423 : : plaintext_pad_len, 3, 0);
4424 : :
4425 : : /* Append data which is padded to a multiple */
4426 : : /* of the algorithms block size */
4427 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4428 : :
4429 : : /* Create KASUMI operation */
4430 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4431 : 0 : tdata->cipher_iv.len,
4432 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4433 : 0 : tdata->validCipherOffsetInBits.len);
4434 [ # # ]: 0 : if (retval < 0)
4435 : : return retval;
4436 : :
4437 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4438 : : ut_params->op);
4439 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4440 : :
4441 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4442 [ # # ]: 0 : if (ut_params->obuf)
4443 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4444 : : plaintext_pad_len, buffer);
4445 : : else
4446 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4447 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4448 : : plaintext_pad_len, buffer);
4449 : :
4450 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4451 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4452 : : /* Validate obuf */
4453 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4454 : : ciphertext,
4455 : : reference_ciphertext,
4456 : : tdata->validCipherLenInBits.len,
4457 : : "KASUMI Ciphertext data not as expected");
4458 : : return 0;
4459 : : }
4460 : :
4461 : :
4462 : : static int
4463 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4464 : : {
4465 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4466 : : struct crypto_unittest_params *ut_params = &unittest_params;
4467 : :
4468 : : int retval;
4469 : : uint8_t *ciphertext, *plaintext;
4470 : : unsigned ciphertext_pad_len;
4471 : : unsigned ciphertext_len;
4472 : :
4473 : : /* Verify the capabilities */
4474 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4475 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4476 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4477 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4478 : : &cap_idx) == NULL)
4479 : : return TEST_SKIPPED;
4480 : :
4481 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4482 : : return TEST_SKIPPED;
4483 : :
4484 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4485 : : return TEST_SKIPPED;
4486 : :
4487 : : /* Create KASUMI session */
4488 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4489 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4490 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4491 : 0 : tdata->key.data, tdata->key.len,
4492 : 0 : tdata->cipher_iv.len);
4493 [ # # ]: 0 : if (retval < 0)
4494 : : return retval;
4495 : :
4496 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4497 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4498 : :
4499 : : /* Clear mbuf payload */
4500 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4501 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4502 : :
4503 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4504 : : /* Append data which is padded to a multiple */
4505 : : /* of the algorithms block size */
4506 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4507 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4508 : : ciphertext_pad_len);
4509 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4510 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4511 : :
4512 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4513 : :
4514 : : /* Create KASUMI operation */
4515 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4516 : 0 : tdata->cipher_iv.len,
4517 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4518 : 0 : tdata->validCipherOffsetInBits.len);
4519 [ # # ]: 0 : if (retval < 0)
4520 : : return retval;
4521 : :
4522 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4523 : : ut_params->op);
4524 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4525 : :
4526 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4527 [ # # ]: 0 : if (ut_params->obuf)
4528 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4529 : : else
4530 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4531 : :
4532 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4533 : :
4534 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4535 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4536 : : /* Validate obuf */
4537 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4538 : : plaintext,
4539 : : reference_plaintext,
4540 : : tdata->validCipherLenInBits.len,
4541 : : "KASUMI Plaintext data not as expected");
4542 : : return 0;
4543 : : }
4544 : :
4545 : : static int
4546 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4547 : : {
4548 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4549 : : struct crypto_unittest_params *ut_params = &unittest_params;
4550 : :
4551 : : int retval;
4552 : : uint8_t *ciphertext, *plaintext;
4553 : : unsigned ciphertext_pad_len;
4554 : : unsigned ciphertext_len;
4555 : : struct rte_cryptodev_info dev_info;
4556 : :
4557 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4558 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4559 : :
4560 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4561 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4562 : : printf("Device doesn't support RAW data-path APIs.\n");
4563 : 0 : return TEST_SKIPPED;
4564 : : }
4565 : :
4566 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4567 : : return TEST_SKIPPED;
4568 : :
4569 : : /* Verify the capabilities */
4570 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4571 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4572 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4573 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4574 : : &cap_idx) == NULL)
4575 : : return TEST_SKIPPED;
4576 : :
4577 : : /* Create KASUMI session */
4578 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4579 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4580 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4581 : 0 : tdata->key.data, tdata->key.len,
4582 : 0 : tdata->cipher_iv.len);
4583 [ # # ]: 0 : if (retval < 0)
4584 : : return retval;
4585 : :
4586 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4587 : :
4588 : : /* Clear mbuf payload */
4589 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4590 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4591 : :
4592 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4593 : : /* Append data which is padded to a multiple */
4594 : : /* of the algorithms block size */
4595 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4596 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4597 : : ciphertext_pad_len);
4598 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4599 : :
4600 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4601 : :
4602 : : /* Create KASUMI operation */
4603 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4604 : 0 : tdata->cipher_iv.len,
4605 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4606 : 0 : tdata->validCipherOffsetInBits.len);
4607 [ # # ]: 0 : if (retval < 0)
4608 : : return retval;
4609 : :
4610 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4611 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4612 : : 0);
4613 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4614 : : return retval;
4615 : : } else
4616 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4617 : : ut_params->op);
4618 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4619 : :
4620 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4621 [ # # ]: 0 : if (ut_params->obuf)
4622 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4623 : : else
4624 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4625 : :
4626 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4627 : :
4628 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4629 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4630 : : /* Validate obuf */
4631 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4632 : : plaintext,
4633 : : reference_plaintext,
4634 : : tdata->validCipherLenInBits.len,
4635 : : "KASUMI Plaintext data not as expected");
4636 : : return 0;
4637 : : }
4638 : :
4639 : : static int
4640 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4641 : : {
4642 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4643 : : struct crypto_unittest_params *ut_params = &unittest_params;
4644 : :
4645 : : int retval;
4646 : : uint8_t *plaintext, *ciphertext;
4647 : : unsigned plaintext_pad_len;
4648 : : unsigned plaintext_len;
4649 : : struct rte_cryptodev_info dev_info;
4650 : :
4651 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4652 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4653 : :
4654 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4655 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4656 : : printf("Device doesn't support RAW data-path APIs.\n");
4657 : 0 : return TEST_SKIPPED;
4658 : : }
4659 : :
4660 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4661 : : return TEST_SKIPPED;
4662 : :
4663 : : /* Verify the capabilities */
4664 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4665 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4666 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4667 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4668 : : &cap_idx) == NULL)
4669 : : return TEST_SKIPPED;
4670 : :
4671 : : /* Create SNOW 3G session */
4672 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4673 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4674 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4675 : 0 : tdata->key.data, tdata->key.len,
4676 : 0 : tdata->cipher_iv.len);
4677 [ # # ]: 0 : if (retval < 0)
4678 : : return retval;
4679 : :
4680 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4681 : :
4682 : : /* Clear mbuf payload */
4683 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4684 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4685 : :
4686 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4687 : : /* Append data which is padded to a multiple of */
4688 : : /* the algorithms block size */
4689 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4690 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4691 : : plaintext_pad_len);
4692 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4693 : :
4694 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4695 : :
4696 : : /* Create SNOW 3G operation */
4697 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4698 : 0 : tdata->cipher_iv.len,
4699 : 0 : tdata->validCipherLenInBits.len,
4700 : : 0);
4701 [ # # ]: 0 : if (retval < 0)
4702 : : return retval;
4703 : :
4704 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4705 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4706 : 0 : tdata->cipher_iv.len);
4707 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4708 : : return retval;
4709 : : } else
4710 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4711 : : ut_params->op);
4712 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4713 : :
4714 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4715 [ # # ]: 0 : if (ut_params->obuf)
4716 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4717 : : else
4718 : : ciphertext = plaintext;
4719 : :
4720 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4721 : :
4722 : : /* Validate obuf */
4723 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4724 : : ciphertext,
4725 : : tdata->ciphertext.data,
4726 : : tdata->validDataLenInBits.len,
4727 : : "SNOW 3G Ciphertext data not as expected");
4728 : : return 0;
4729 : : }
4730 : :
4731 : :
4732 : : static int
4733 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4734 : : {
4735 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4736 : : struct crypto_unittest_params *ut_params = &unittest_params;
4737 : : uint8_t *plaintext, *ciphertext;
4738 : :
4739 : : int retval;
4740 : : unsigned plaintext_pad_len;
4741 : : unsigned plaintext_len;
4742 : : struct rte_cryptodev_info dev_info;
4743 : :
4744 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4745 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4746 : :
4747 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4748 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4749 : : printf("Device does not support RAW data-path APIs.\n");
4750 : 0 : return -ENOTSUP;
4751 : : }
4752 : :
4753 : : /* Verify the capabilities */
4754 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4755 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4756 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4757 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4758 : : &cap_idx) == NULL)
4759 : : return TEST_SKIPPED;
4760 : :
4761 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4762 : : return TEST_SKIPPED;
4763 : :
4764 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4765 : : return TEST_SKIPPED;
4766 : :
4767 : : /* Create SNOW 3G session */
4768 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4769 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4770 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4771 : 0 : tdata->key.data, tdata->key.len,
4772 : 0 : tdata->cipher_iv.len);
4773 [ # # ]: 0 : if (retval < 0)
4774 : : return retval;
4775 : :
4776 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4777 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4778 : :
4779 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4780 : : "Failed to allocate input buffer in mempool");
4781 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4782 : : "Failed to allocate output buffer in mempool");
4783 : :
4784 : : /* Clear mbuf payload */
4785 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4786 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4787 : :
4788 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4789 : : /* Append data which is padded to a multiple of */
4790 : : /* the algorithms block size */
4791 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4792 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4793 : : plaintext_pad_len);
4794 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4795 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4796 : :
4797 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4798 : :
4799 : : /* Create SNOW 3G operation */
4800 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4801 : 0 : tdata->cipher_iv.len,
4802 : 0 : tdata->validCipherLenInBits.len,
4803 : : 0);
4804 [ # # ]: 0 : if (retval < 0)
4805 : : return retval;
4806 : :
4807 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4808 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4809 : 0 : tdata->cipher_iv.len);
4810 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4811 : : return retval;
4812 : : } else
4813 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4814 : : ut_params->op);
4815 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4816 : :
4817 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4818 [ # # ]: 0 : if (ut_params->obuf)
4819 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4820 : : else
4821 : : ciphertext = plaintext;
4822 : :
4823 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4824 : :
4825 : : /* Validate obuf */
4826 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4827 : : ciphertext,
4828 : : tdata->ciphertext.data,
4829 : : tdata->validDataLenInBits.len,
4830 : : "SNOW 3G Ciphertext data not as expected");
4831 : : return 0;
4832 : : }
4833 : :
4834 : : static int
4835 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4836 : : uint8_t sgl_in, uint8_t sgl_out)
4837 : : {
4838 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4839 : : struct crypto_unittest_params *ut_params = &unittest_params;
4840 : :
4841 : : int retval;
4842 : : unsigned int plaintext_pad_len;
4843 : : unsigned int plaintext_len;
4844 : : uint8_t buffer[10000];
4845 : : const uint8_t *ciphertext;
4846 : :
4847 : : struct rte_cryptodev_info dev_info;
4848 : :
4849 : : /* Verify the capabilities */
4850 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4851 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4852 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4853 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4854 : : &cap_idx) == NULL)
4855 : : return TEST_SKIPPED;
4856 : :
4857 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4858 : : return TEST_SKIPPED;
4859 : :
4860 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4861 : : return TEST_SKIPPED;
4862 : :
4863 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4864 : :
4865 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4866 : :
4867 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4868 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4869 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4870 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4871 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4872 : : printf("Device doesn't support out-of-place scatter gather type. "
4873 : : "Test Skipped.\n");
4874 : 0 : return TEST_SKIPPED;
4875 : : }
4876 : :
4877 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4878 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4879 : : printf("Device does not support RAW data-path APIs.\n");
4880 : 0 : return -ENOTSUP;
4881 : : }
4882 : :
4883 : : /* Create SNOW 3G session */
4884 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4885 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4886 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4887 : 0 : tdata->key.data, tdata->key.len,
4888 : 0 : tdata->cipher_iv.len);
4889 [ # # ]: 0 : if (retval < 0)
4890 : : return retval;
4891 : :
4892 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4893 : : /* Append data which is padded to a multiple of */
4894 : : /* the algorithms block size */
4895 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4896 : :
4897 [ # # ]: 0 : if (sgl_in)
4898 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4899 : : plaintext_pad_len, 10, 0);
4900 : : else {
4901 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4902 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4903 : : }
4904 : :
4905 [ # # ]: 0 : if (sgl_out)
4906 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4907 : : plaintext_pad_len, 3, 0);
4908 : : else {
4909 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4910 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4911 : : }
4912 : :
4913 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4914 : : "Failed to allocate input buffer in mempool");
4915 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4916 : : "Failed to allocate output buffer in mempool");
4917 : :
4918 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4919 : :
4920 : : /* Create SNOW 3G operation */
4921 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4922 : 0 : tdata->cipher_iv.len,
4923 : 0 : tdata->validCipherLenInBits.len,
4924 : : 0);
4925 [ # # ]: 0 : if (retval < 0)
4926 : : return retval;
4927 : :
4928 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4929 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4930 : 0 : tdata->cipher_iv.len);
4931 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4932 : : return retval;
4933 : : } else
4934 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4935 : : ut_params->op);
4936 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4937 : :
4938 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4939 [ # # ]: 0 : if (ut_params->obuf)
4940 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4941 : : plaintext_len, buffer);
4942 : : else
4943 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4944 : : plaintext_len, buffer);
4945 : :
4946 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4947 : :
4948 : : /* Validate obuf */
4949 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4950 : : ciphertext,
4951 : : tdata->ciphertext.data,
4952 : : tdata->validDataLenInBits.len,
4953 : : "SNOW 3G Ciphertext data not as expected");
4954 : :
4955 : : return 0;
4956 : : }
4957 : :
4958 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4959 : : static void
4960 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4961 : : {
4962 : : uint8_t curr_byte, prev_byte;
4963 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4964 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4965 : : unsigned i;
4966 : :
4967 : 0 : prev_byte = buffer[0];
4968 : 0 : buffer[0] >>= offset;
4969 : :
4970 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4971 : 0 : curr_byte = buffer[i];
4972 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4973 : 0 : (curr_byte >> offset);
4974 : : prev_byte = curr_byte;
4975 : : }
4976 : 0 : }
4977 : :
4978 : : static int
4979 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4980 : : {
4981 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4982 : : struct crypto_unittest_params *ut_params = &unittest_params;
4983 : : uint8_t *plaintext, *ciphertext;
4984 : : int retval;
4985 : : uint32_t plaintext_len;
4986 : : uint32_t plaintext_pad_len;
4987 : : uint8_t extra_offset = 4;
4988 : : uint8_t *expected_ciphertext_shifted;
4989 : : struct rte_cryptodev_info dev_info;
4990 : :
4991 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4992 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4993 : :
4994 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4995 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4996 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4997 : 0 : return TEST_SKIPPED;
4998 : : }
4999 : :
5000 : : /* Verify the capabilities */
5001 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5002 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5003 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5004 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5005 : : &cap_idx) == NULL)
5006 : : return TEST_SKIPPED;
5007 : :
5008 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5009 : : return TEST_SKIPPED;
5010 : :
5011 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5012 : : return TEST_SKIPPED;
5013 : :
5014 : : /* Create SNOW 3G session */
5015 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5016 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5017 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5018 : 0 : tdata->key.data, tdata->key.len,
5019 : 0 : tdata->cipher_iv.len);
5020 [ # # ]: 0 : if (retval < 0)
5021 : : return retval;
5022 : :
5023 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5024 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5025 : :
5026 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5027 : : "Failed to allocate input buffer in mempool");
5028 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5029 : : "Failed to allocate output buffer in mempool");
5030 : :
5031 : : /* Clear mbuf payload */
5032 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5033 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5034 : :
5035 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
5036 : : /*
5037 : : * Append data which is padded to a
5038 : : * multiple of the algorithms block size
5039 : : */
5040 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5041 : :
5042 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
5043 : : plaintext_pad_len);
5044 : :
5045 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5046 : :
5047 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
5048 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
5049 : :
5050 : : #ifdef RTE_APP_TEST_DEBUG
5051 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
5052 : : #endif
5053 : : /* Create SNOW 3G operation */
5054 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5055 : 0 : tdata->cipher_iv.len,
5056 : 0 : tdata->validCipherLenInBits.len,
5057 : : extra_offset);
5058 [ # # ]: 0 : if (retval < 0)
5059 : : return retval;
5060 : :
5061 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5062 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5063 : 0 : tdata->cipher_iv.len);
5064 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5065 : : return retval;
5066 : : } else
5067 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5068 : : ut_params->op);
5069 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5070 : :
5071 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5072 [ # # ]: 0 : if (ut_params->obuf)
5073 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5074 : : else
5075 : : ciphertext = plaintext;
5076 : :
5077 : : #ifdef RTE_APP_TEST_DEBUG
5078 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5079 : : #endif
5080 : :
5081 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
5082 : :
5083 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
5084 : : "failed to reserve memory for ciphertext shifted\n");
5085 : :
5086 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
5087 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
5088 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
5089 : : extra_offset);
5090 : : /* Validate obuf */
5091 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
5092 : : ciphertext,
5093 : : expected_ciphertext_shifted,
5094 : : tdata->validDataLenInBits.len,
5095 : : extra_offset,
5096 : : "SNOW 3G Ciphertext data not as expected");
5097 : : return 0;
5098 : : }
5099 : :
5100 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
5101 : : {
5102 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5103 : : struct crypto_unittest_params *ut_params = &unittest_params;
5104 : :
5105 : : int retval;
5106 : :
5107 : : uint8_t *plaintext, *ciphertext;
5108 : : unsigned ciphertext_pad_len;
5109 : : unsigned ciphertext_len;
5110 : : struct rte_cryptodev_info dev_info;
5111 : :
5112 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5113 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5114 : :
5115 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5116 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5117 : : printf("Device doesn't support RAW data-path APIs.\n");
5118 : 0 : return TEST_SKIPPED;
5119 : : }
5120 : :
5121 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5122 : : return TEST_SKIPPED;
5123 : :
5124 : : /* Verify the capabilities */
5125 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5126 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5127 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5128 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5129 : : &cap_idx) == NULL)
5130 : : return TEST_SKIPPED;
5131 : :
5132 : : /* Create SNOW 3G session */
5133 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5134 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5135 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5136 : 0 : tdata->key.data, tdata->key.len,
5137 : 0 : tdata->cipher_iv.len);
5138 [ # # ]: 0 : if (retval < 0)
5139 : : return retval;
5140 : :
5141 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5142 : :
5143 : : /* Clear mbuf payload */
5144 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5145 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5146 : :
5147 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5148 : : /* Append data which is padded to a multiple of */
5149 : : /* the algorithms block size */
5150 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5151 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5152 : : ciphertext_pad_len);
5153 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5154 : :
5155 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5156 : :
5157 : : /* Create SNOW 3G operation */
5158 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5159 : 0 : tdata->cipher_iv.len,
5160 : 0 : tdata->validCipherLenInBits.len,
5161 : 0 : tdata->cipher.offset_bits);
5162 [ # # ]: 0 : if (retval < 0)
5163 : : return retval;
5164 : :
5165 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5166 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5167 : 0 : tdata->cipher_iv.len);
5168 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5169 : : return retval;
5170 : : } else
5171 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5172 : : ut_params->op);
5173 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5174 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5175 [ # # ]: 0 : if (ut_params->obuf)
5176 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5177 : : else
5178 : : plaintext = ciphertext;
5179 : :
5180 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5181 : :
5182 : : /* Validate obuf */
5183 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5184 : : tdata->plaintext.data,
5185 : : tdata->validDataLenInBits.len,
5186 : : "SNOW 3G Plaintext data not as expected");
5187 : : return 0;
5188 : : }
5189 : :
5190 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5191 : : {
5192 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5193 : : struct crypto_unittest_params *ut_params = &unittest_params;
5194 : :
5195 : : int retval;
5196 : :
5197 : : uint8_t *plaintext, *ciphertext;
5198 : : unsigned ciphertext_pad_len;
5199 : : unsigned ciphertext_len;
5200 : : struct rte_cryptodev_info dev_info;
5201 : :
5202 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5203 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5204 : :
5205 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5206 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5207 : : printf("Device does not support RAW data-path APIs.\n");
5208 : 0 : return -ENOTSUP;
5209 : : }
5210 : : /* Verify the capabilities */
5211 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5212 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5213 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5214 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5215 : : &cap_idx) == NULL)
5216 : : return TEST_SKIPPED;
5217 : :
5218 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5219 : : return TEST_SKIPPED;
5220 : :
5221 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5222 : : return TEST_SKIPPED;
5223 : :
5224 : : /* Create SNOW 3G session */
5225 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5226 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5227 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5228 : 0 : tdata->key.data, tdata->key.len,
5229 : 0 : tdata->cipher_iv.len);
5230 [ # # ]: 0 : if (retval < 0)
5231 : : return retval;
5232 : :
5233 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5234 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5235 : :
5236 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5237 : : "Failed to allocate input buffer");
5238 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5239 : : "Failed to allocate output buffer");
5240 : :
5241 : : /* Clear mbuf payload */
5242 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5243 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5244 : :
5245 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5246 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5247 : :
5248 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5249 : : /* Append data which is padded to a multiple of */
5250 : : /* the algorithms block size */
5251 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5252 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5253 : : ciphertext_pad_len);
5254 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5255 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5256 : :
5257 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5258 : :
5259 : : /* Create SNOW 3G operation */
5260 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5261 : 0 : tdata->cipher_iv.len,
5262 : 0 : tdata->validCipherLenInBits.len,
5263 : : 0);
5264 [ # # ]: 0 : if (retval < 0)
5265 : : return retval;
5266 : :
5267 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5268 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5269 : 0 : tdata->cipher_iv.len);
5270 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5271 : : return retval;
5272 : : } else
5273 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5274 : : ut_params->op);
5275 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5276 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5277 [ # # ]: 0 : if (ut_params->obuf)
5278 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5279 : : else
5280 : : plaintext = ciphertext;
5281 : :
5282 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5283 : :
5284 : : /* Validate obuf */
5285 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5286 : : tdata->plaintext.data,
5287 : : tdata->validDataLenInBits.len,
5288 : : "SNOW 3G Plaintext data not as expected");
5289 : : return 0;
5290 : : }
5291 : :
5292 : : static int
5293 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5294 : : {
5295 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5296 : : struct crypto_unittest_params *ut_params = &unittest_params;
5297 : :
5298 : : int retval;
5299 : :
5300 : : uint8_t *plaintext, *ciphertext;
5301 : : unsigned int plaintext_pad_len;
5302 : : unsigned int plaintext_len;
5303 : :
5304 : : struct rte_cryptodev_info dev_info;
5305 : :
5306 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5307 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5308 : :
5309 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5310 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
5311 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
5312 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
5313 : 0 : return TEST_SKIPPED;
5314 : : }
5315 : :
5316 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5317 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5318 : : printf("Device doesn't support RAW data-path APIs.\n");
5319 : 0 : return TEST_SKIPPED;
5320 : : }
5321 : :
5322 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5323 : : return TEST_SKIPPED;
5324 : :
5325 : : /* Check if device supports ZUC EEA3 */
5326 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5327 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
5328 : : return TEST_SKIPPED;
5329 : :
5330 : : /* Check if device supports ZUC EIA3 */
5331 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5332 : 0 : tdata->key.len, tdata->auth_iv.len,
5333 : 0 : tdata->digest.len) < 0)
5334 : : return TEST_SKIPPED;
5335 : :
5336 : : /* Create ZUC session */
5337 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
5338 : 0 : ts_params->valid_devs[0],
5339 : : tdata);
5340 [ # # ]: 0 : if (retval != 0)
5341 : : return retval;
5342 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5343 : :
5344 : : /* clear mbuf payload */
5345 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5346 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5347 : :
5348 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5349 : : /* Append data which is padded to a multiple of */
5350 : : /* the algorithms block size */
5351 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5352 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5353 : : plaintext_pad_len);
5354 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5355 : :
5356 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5357 : :
5358 : : /* Create ZUC operation */
5359 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
5360 [ # # ]: 0 : if (retval < 0)
5361 : : return retval;
5362 : :
5363 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5364 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5365 : 0 : tdata->cipher_iv.len);
5366 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5367 : : return retval;
5368 : : } else
5369 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5370 : : ut_params->op);
5371 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5372 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5373 [ # # ]: 0 : if (ut_params->obuf)
5374 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5375 : : else
5376 : : ciphertext = plaintext;
5377 : :
5378 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5379 : : /* Validate obuf */
5380 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5381 : : ciphertext,
5382 : : tdata->ciphertext.data,
5383 : : tdata->validDataLenInBits.len,
5384 : : "ZUC Ciphertext data not as expected");
5385 : :
5386 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5387 : : uint8_t *,
5388 : : plaintext_pad_len);
5389 : :
5390 : : /* Validate obuf */
5391 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5392 : : ut_params->digest,
5393 : : tdata->digest.data,
5394 : : tdata->digest.len,
5395 : : "ZUC Generated auth tag not as expected");
5396 : : return 0;
5397 : : }
5398 : :
5399 : : static int
5400 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5401 : : {
5402 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5403 : : struct crypto_unittest_params *ut_params = &unittest_params;
5404 : :
5405 : : int retval;
5406 : :
5407 : : uint8_t *plaintext, *ciphertext;
5408 : : unsigned plaintext_pad_len;
5409 : : unsigned plaintext_len;
5410 : : struct rte_cryptodev_info dev_info;
5411 : :
5412 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5413 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5414 : :
5415 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5416 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5417 : : printf("Device doesn't support RAW data-path APIs.\n");
5418 : 0 : return TEST_SKIPPED;
5419 : : }
5420 : :
5421 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5422 : : return TEST_SKIPPED;
5423 : :
5424 : : /* Verify the capabilities */
5425 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5426 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5427 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5428 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5429 : : &cap_idx) == NULL)
5430 : : return TEST_SKIPPED;
5431 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5432 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5433 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5434 : : &cap_idx) == NULL)
5435 : : return TEST_SKIPPED;
5436 : :
5437 : : /* Create SNOW 3G session */
5438 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5439 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5440 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5441 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5442 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5443 : : tdata->key.data, tdata->key.len,
5444 : 0 : tdata->key.data, tdata->key.len,
5445 : 0 : tdata->auth_iv.len, tdata->digest.len,
5446 : 0 : tdata->cipher_iv.len);
5447 [ # # ]: 0 : if (retval != 0)
5448 : : return retval;
5449 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5450 : :
5451 : : /* clear mbuf payload */
5452 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5453 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5454 : :
5455 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5456 : : /* Append data which is padded to a multiple of */
5457 : : /* the algorithms block size */
5458 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5459 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5460 : : plaintext_pad_len);
5461 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5462 : :
5463 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5464 : :
5465 : : /* Create SNOW 3G operation */
5466 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5467 : 0 : tdata->digest.len, tdata->auth_iv.data,
5468 : 0 : tdata->auth_iv.len,
5469 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5470 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5471 : 0 : tdata->validCipherLenInBits.len,
5472 : : 0,
5473 : 0 : tdata->validAuthLenInBits.len,
5474 : : 0
5475 : : );
5476 [ # # ]: 0 : if (retval < 0)
5477 : : return retval;
5478 : :
5479 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5480 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5481 : 0 : tdata->cipher_iv.len);
5482 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5483 : : return retval;
5484 : : } else
5485 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5486 : : ut_params->op);
5487 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5488 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5489 [ # # ]: 0 : if (ut_params->obuf)
5490 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5491 : : else
5492 : : ciphertext = plaintext;
5493 : :
5494 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5495 : : /* Validate obuf */
5496 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5497 : : ciphertext,
5498 : : tdata->ciphertext.data,
5499 : : tdata->validDataLenInBits.len,
5500 : : "SNOW 3G Ciphertext data not as expected");
5501 : :
5502 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5503 : : uint8_t *,
5504 : : plaintext_pad_len);
5505 : :
5506 : : /* Validate obuf */
5507 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5508 : : ut_params->digest,
5509 : : tdata->digest.data,
5510 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5511 : : "SNOW 3G Generated auth tag not as expected");
5512 : : return 0;
5513 : : }
5514 : :
5515 : : static int
5516 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5517 : : uint8_t op_mode, uint8_t verify)
5518 : : {
5519 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5520 : : struct crypto_unittest_params *ut_params = &unittest_params;
5521 : :
5522 : : int retval;
5523 : :
5524 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5525 : : unsigned int plaintext_pad_len;
5526 : : unsigned int plaintext_len;
5527 : : unsigned int ciphertext_pad_len;
5528 : : unsigned int ciphertext_len;
5529 : : unsigned int digest_offset;
5530 : :
5531 : : struct rte_cryptodev_info dev_info;
5532 : :
5533 : : /* Verify the capabilities */
5534 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5535 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5536 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5537 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5538 : : &cap_idx) == NULL)
5539 : : return TEST_SKIPPED;
5540 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5541 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5542 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5543 : : &cap_idx) == NULL)
5544 : : return TEST_SKIPPED;
5545 : :
5546 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5547 : : return TEST_SKIPPED;
5548 : :
5549 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5550 : :
5551 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5552 : :
5553 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5554 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5555 : : printf("Device doesn't support digest encrypted.\n");
5556 : 0 : return TEST_SKIPPED;
5557 : : }
5558 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5559 : : return TEST_SKIPPED;
5560 : : }
5561 : :
5562 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5563 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5564 : : printf("Device doesn't support RAW data-path APIs.\n");
5565 : 0 : return TEST_SKIPPED;
5566 : : }
5567 : :
5568 : : /* Create SNOW 3G session */
5569 : 0 : retval = create_wireless_algo_auth_cipher_session(
5570 : 0 : ts_params->valid_devs[0],
5571 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5572 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5573 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5574 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5575 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5576 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5577 : : tdata->key.data, tdata->key.len,
5578 : 0 : tdata->key.data, tdata->key.len,
5579 : 0 : tdata->auth_iv.len, tdata->digest.len,
5580 : 0 : tdata->cipher_iv.len);
5581 [ # # ]: 0 : if (retval != 0)
5582 : : return retval;
5583 : :
5584 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5585 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5586 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5587 : :
5588 : : /* clear mbuf payload */
5589 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5590 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5591 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5592 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5593 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5594 : :
5595 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5596 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5597 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5598 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5599 : :
5600 [ # # ]: 0 : if (verify) {
5601 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5602 : : ciphertext_pad_len);
5603 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5604 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5605 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5606 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5607 : : ciphertext_len);
5608 : : } else {
5609 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5610 : : plaintext_pad_len);
5611 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5612 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5613 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5614 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5615 : : }
5616 : :
5617 : : /* Create SNOW 3G operation */
5618 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5619 : 0 : tdata->digest.data, tdata->digest.len,
5620 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5621 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5622 : 0 : (tdata->digest.offset_bytes == 0 ?
5623 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5624 : : : tdata->digest.offset_bytes),
5625 : 0 : tdata->validCipherLenInBits.len,
5626 : 0 : tdata->cipher.offset_bits,
5627 : 0 : tdata->validAuthLenInBits.len,
5628 [ # # ]: 0 : tdata->auth.offset_bits,
5629 : : op_mode, 0, verify);
5630 : :
5631 [ # # ]: 0 : if (retval < 0)
5632 : : return retval;
5633 : :
5634 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5635 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5636 : 0 : tdata->cipher_iv.len);
5637 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5638 : : return retval;
5639 : : } else
5640 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5641 : : ut_params->op);
5642 : :
5643 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5644 : :
5645 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5646 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5647 : :
5648 [ # # ]: 0 : if (verify) {
5649 [ # # ]: 0 : if (ut_params->obuf)
5650 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5651 : : uint8_t *);
5652 : : else
5653 : 0 : plaintext = ciphertext +
5654 : 0 : (tdata->cipher.offset_bits >> 3);
5655 : :
5656 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5657 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5658 : 0 : debug_hexdump(stdout, "plaintext expected:",
5659 : 0 : tdata->plaintext.data,
5660 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5661 : : } else {
5662 [ # # ]: 0 : if (ut_params->obuf)
5663 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5664 : : uint8_t *);
5665 : : else
5666 : : ciphertext = plaintext;
5667 : :
5668 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5669 : : ciphertext_len);
5670 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5671 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5672 : :
5673 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5674 : : digest_offset = plaintext_pad_len;
5675 : : else
5676 : : digest_offset = tdata->digest.offset_bytes;
5677 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5678 : : uint8_t *, digest_offset);
5679 : :
5680 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5681 : 0 : tdata->digest.len);
5682 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5683 : 0 : tdata->digest.len);
5684 : : }
5685 : :
5686 : : /* Validate obuf */
5687 [ # # ]: 0 : if (verify) {
5688 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5689 : : plaintext,
5690 : : tdata->plaintext.data,
5691 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5692 : : (tdata->digest.len << 3)),
5693 : : tdata->cipher.offset_bits,
5694 : : "SNOW 3G Plaintext data not as expected");
5695 : : } else {
5696 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5697 : : ciphertext,
5698 : : tdata->ciphertext.data,
5699 : : (tdata->validDataLenInBits.len -
5700 : : tdata->cipher.offset_bits),
5701 : : tdata->cipher.offset_bits,
5702 : : "SNOW 3G Ciphertext data not as expected");
5703 : :
5704 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5705 : : ut_params->digest,
5706 : : tdata->digest.data,
5707 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5708 : : "SNOW 3G Generated auth tag not as expected");
5709 : : }
5710 : : return 0;
5711 : : }
5712 : :
5713 : : static int
5714 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5715 : : uint8_t op_mode, uint8_t verify)
5716 : : {
5717 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5718 : : struct crypto_unittest_params *ut_params = &unittest_params;
5719 : :
5720 : : int retval;
5721 : :
5722 : : const uint8_t *plaintext = NULL;
5723 : : const uint8_t *ciphertext = NULL;
5724 : : const uint8_t *digest = NULL;
5725 : : unsigned int plaintext_pad_len;
5726 : : unsigned int plaintext_len;
5727 : : unsigned int ciphertext_pad_len;
5728 : : unsigned int ciphertext_len;
5729 : : uint8_t buffer[10000];
5730 : : uint8_t digest_buffer[10000];
5731 : :
5732 : : struct rte_cryptodev_info dev_info;
5733 : :
5734 : : /* Verify the capabilities */
5735 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5736 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5737 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5738 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5739 : : &cap_idx) == NULL)
5740 : : return TEST_SKIPPED;
5741 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5742 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5743 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5744 : : &cap_idx) == NULL)
5745 : : return TEST_SKIPPED;
5746 : :
5747 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5748 : : return TEST_SKIPPED;
5749 : :
5750 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5751 : :
5752 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5753 : :
5754 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5755 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5756 : : printf("Device doesn't support in-place scatter-gather "
5757 : : "in both input and output mbufs.\n");
5758 : 0 : return TEST_SKIPPED;
5759 : : }
5760 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5761 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5762 : : printf("Device doesn't support RAW data-path APIs.\n");
5763 : 0 : return TEST_SKIPPED;
5764 : : }
5765 : : } else {
5766 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5767 : : return TEST_SKIPPED;
5768 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5769 : : printf("Device doesn't support out-of-place scatter-gather "
5770 : : "in both input and output mbufs.\n");
5771 : 0 : return TEST_SKIPPED;
5772 : : }
5773 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5774 : : printf("Device doesn't support digest encrypted.\n");
5775 : 0 : return TEST_SKIPPED;
5776 : : }
5777 : : }
5778 : :
5779 : : /* Create SNOW 3G session */
5780 : 0 : retval = create_wireless_algo_auth_cipher_session(
5781 : 0 : ts_params->valid_devs[0],
5782 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5783 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5784 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5785 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5786 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5787 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5788 : : tdata->key.data, tdata->key.len,
5789 : 0 : tdata->key.data, tdata->key.len,
5790 : 0 : tdata->auth_iv.len, tdata->digest.len,
5791 : 0 : tdata->cipher_iv.len);
5792 : :
5793 [ # # ]: 0 : if (retval != 0)
5794 : : return retval;
5795 : :
5796 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5797 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5798 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5799 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5800 : :
5801 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5802 : : plaintext_pad_len, 15, 0);
5803 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5804 : : "Failed to allocate input buffer in mempool");
5805 : :
5806 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5807 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5808 : : plaintext_pad_len, 15, 0);
5809 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5810 : : "Failed to allocate output buffer in mempool");
5811 : : }
5812 : :
5813 [ # # ]: 0 : if (verify) {
5814 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5815 : 0 : tdata->ciphertext.data);
5816 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5817 : : ciphertext_len, buffer);
5818 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5819 : : ciphertext_len);
5820 : : } else {
5821 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5822 : 0 : tdata->plaintext.data);
5823 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5824 : : plaintext_len, buffer);
5825 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5826 : : plaintext_len);
5827 : : }
5828 : : memset(buffer, 0, sizeof(buffer));
5829 : :
5830 : : /* Create SNOW 3G operation */
5831 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5832 : 0 : tdata->digest.data, tdata->digest.len,
5833 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5834 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5835 : 0 : (tdata->digest.offset_bytes == 0 ?
5836 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5837 : : : tdata->digest.offset_bytes),
5838 : 0 : tdata->validCipherLenInBits.len,
5839 : 0 : tdata->cipher.offset_bits,
5840 : 0 : tdata->validAuthLenInBits.len,
5841 [ # # ]: 0 : tdata->auth.offset_bits,
5842 : : op_mode, 1, verify);
5843 : :
5844 [ # # ]: 0 : if (retval < 0)
5845 : : return retval;
5846 : :
5847 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5848 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5849 : 0 : tdata->cipher_iv.len);
5850 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5851 : : return retval;
5852 : : } else
5853 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5854 : : ut_params->op);
5855 : :
5856 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5857 : :
5858 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5859 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5860 : :
5861 [ # # ]: 0 : if (verify) {
5862 [ # # ]: 0 : if (ut_params->obuf)
5863 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5864 : : plaintext_len, buffer);
5865 : : else
5866 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5867 : : plaintext_len, buffer);
5868 : :
5869 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5870 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5871 : 0 : debug_hexdump(stdout, "plaintext expected:",
5872 : 0 : tdata->plaintext.data,
5873 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5874 : : } else {
5875 [ # # ]: 0 : if (ut_params->obuf)
5876 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5877 : : ciphertext_len, buffer);
5878 : : else
5879 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5880 : : ciphertext_len, buffer);
5881 : :
5882 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5883 : : ciphertext_len);
5884 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5885 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5886 : :
5887 [ # # ]: 0 : if (ut_params->obuf)
5888 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5889 : 0 : (tdata->digest.offset_bytes == 0 ?
5890 : : plaintext_pad_len : tdata->digest.offset_bytes),
5891 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5892 : : else
5893 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5894 : 0 : (tdata->digest.offset_bytes == 0 ?
5895 : : plaintext_pad_len : tdata->digest.offset_bytes),
5896 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5897 : :
5898 : 0 : debug_hexdump(stdout, "digest:", digest,
5899 : 0 : tdata->digest.len);
5900 : 0 : debug_hexdump(stdout, "digest expected:",
5901 : 0 : tdata->digest.data, tdata->digest.len);
5902 : : }
5903 : :
5904 : : /* Validate obuf */
5905 [ # # ]: 0 : if (verify) {
5906 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5907 : : plaintext,
5908 : : tdata->plaintext.data,
5909 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5910 : : (tdata->digest.len << 3)),
5911 : : tdata->cipher.offset_bits,
5912 : : "SNOW 3G Plaintext data not as expected");
5913 : : } else {
5914 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5915 : : ciphertext,
5916 : : tdata->ciphertext.data,
5917 : : (tdata->validDataLenInBits.len -
5918 : : tdata->cipher.offset_bits),
5919 : : tdata->cipher.offset_bits,
5920 : : "SNOW 3G Ciphertext data not as expected");
5921 : :
5922 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5923 : : digest,
5924 : : tdata->digest.data,
5925 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5926 : : "SNOW 3G Generated auth tag not as expected");
5927 : : }
5928 : : return 0;
5929 : : }
5930 : :
5931 : : static int
5932 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5933 : : uint8_t op_mode, uint8_t verify)
5934 : : {
5935 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5936 : : struct crypto_unittest_params *ut_params = &unittest_params;
5937 : :
5938 : : int retval;
5939 : :
5940 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5941 : : unsigned int plaintext_pad_len;
5942 : : unsigned int plaintext_len;
5943 : : unsigned int ciphertext_pad_len;
5944 : : unsigned int ciphertext_len;
5945 : : unsigned int digest_offset;
5946 : :
5947 : : struct rte_cryptodev_info dev_info;
5948 : :
5949 : : /* Verify the capabilities */
5950 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5951 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5952 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5953 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5954 : : &cap_idx) == NULL)
5955 : : return TEST_SKIPPED;
5956 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5957 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5958 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5959 : : &cap_idx) == NULL)
5960 : : return TEST_SKIPPED;
5961 : :
5962 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5963 : :
5964 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5965 : :
5966 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5967 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5968 : : printf("Device doesn't support RAW data-path APIs.\n");
5969 : 0 : return TEST_SKIPPED;
5970 : : }
5971 : :
5972 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5973 : : return TEST_SKIPPED;
5974 : :
5975 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5976 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5977 : : return TEST_SKIPPED;
5978 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5979 : : printf("Device doesn't support digest encrypted.\n");
5980 : 0 : return TEST_SKIPPED;
5981 : : }
5982 : : }
5983 : :
5984 : : /* Create KASUMI session */
5985 : 0 : retval = create_wireless_algo_auth_cipher_session(
5986 : 0 : ts_params->valid_devs[0],
5987 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5988 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5989 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5990 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5991 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5992 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5993 : : tdata->key.data, tdata->key.len,
5994 : 0 : tdata->key.data, tdata->key.len,
5995 : 0 : 0, tdata->digest.len,
5996 : 0 : tdata->cipher_iv.len);
5997 : :
5998 [ # # ]: 0 : if (retval != 0)
5999 : : return retval;
6000 : :
6001 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6002 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6003 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6004 : :
6005 : : /* clear mbuf payload */
6006 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6007 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6008 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6009 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6010 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6011 : :
6012 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6013 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6014 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6015 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6016 : :
6017 [ # # ]: 0 : if (verify) {
6018 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6019 : : ciphertext_pad_len);
6020 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6021 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6022 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6023 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6024 : : ciphertext_len);
6025 : : } else {
6026 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6027 : : plaintext_pad_len);
6028 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6029 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6030 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6031 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6032 : : plaintext_len);
6033 : : }
6034 : :
6035 : : /* Create KASUMI operation */
6036 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6037 : 0 : tdata->digest.data, tdata->digest.len,
6038 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6039 : : NULL, 0,
6040 : 0 : (tdata->digest.offset_bytes == 0 ?
6041 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6042 : : : tdata->digest.offset_bytes),
6043 : 0 : tdata->validCipherLenInBits.len,
6044 : 0 : tdata->validCipherOffsetInBits.len,
6045 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6046 : : 0,
6047 : : op_mode, 0, verify);
6048 : :
6049 [ # # ]: 0 : if (retval < 0)
6050 : : return retval;
6051 : :
6052 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6053 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6054 : 0 : tdata->cipher_iv.len);
6055 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6056 : : return retval;
6057 : : } else
6058 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6059 : : ut_params->op);
6060 : :
6061 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6062 : :
6063 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6064 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6065 : :
6066 : :
6067 [ # # ]: 0 : if (verify) {
6068 [ # # ]: 0 : if (ut_params->obuf)
6069 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6070 : : uint8_t *);
6071 : : else
6072 : : plaintext = ciphertext;
6073 : :
6074 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6075 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6076 : 0 : debug_hexdump(stdout, "plaintext expected:",
6077 : 0 : tdata->plaintext.data,
6078 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6079 : : } else {
6080 [ # # ]: 0 : if (ut_params->obuf)
6081 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6082 : : uint8_t *);
6083 : : else
6084 : : ciphertext = plaintext;
6085 : :
6086 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6087 : : ciphertext_len);
6088 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6089 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6090 : :
6091 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6092 : : digest_offset = plaintext_pad_len;
6093 : : else
6094 : : digest_offset = tdata->digest.offset_bytes;
6095 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6096 : : uint8_t *, digest_offset);
6097 : :
6098 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6099 : 0 : tdata->digest.len);
6100 : 0 : debug_hexdump(stdout, "digest expected:",
6101 : 0 : tdata->digest.data, tdata->digest.len);
6102 : : }
6103 : :
6104 : : /* Validate obuf */
6105 [ # # ]: 0 : if (verify) {
6106 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6107 : : plaintext,
6108 : : tdata->plaintext.data,
6109 : : tdata->plaintext.len >> 3,
6110 : : "KASUMI Plaintext data not as expected");
6111 : : } else {
6112 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6113 : : ciphertext,
6114 : : tdata->ciphertext.data,
6115 : : tdata->ciphertext.len >> 3,
6116 : : "KASUMI Ciphertext data not as expected");
6117 : :
6118 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6119 : : ut_params->digest,
6120 : : tdata->digest.data,
6121 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6122 : : "KASUMI Generated auth tag not as expected");
6123 : : }
6124 : : return 0;
6125 : : }
6126 : :
6127 : : static int
6128 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6129 : : uint8_t op_mode, uint8_t verify)
6130 : : {
6131 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6132 : : struct crypto_unittest_params *ut_params = &unittest_params;
6133 : :
6134 : : int retval;
6135 : :
6136 : : const uint8_t *plaintext = NULL;
6137 : : const uint8_t *ciphertext = NULL;
6138 : : const uint8_t *digest = NULL;
6139 : : unsigned int plaintext_pad_len;
6140 : : unsigned int plaintext_len;
6141 : : unsigned int ciphertext_pad_len;
6142 : : unsigned int ciphertext_len;
6143 : : uint8_t buffer[10000];
6144 : : uint8_t digest_buffer[10000];
6145 : :
6146 : : struct rte_cryptodev_info dev_info;
6147 : :
6148 : : /* Verify the capabilities */
6149 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6150 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6151 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6152 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6153 : : &cap_idx) == NULL)
6154 : : return TEST_SKIPPED;
6155 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6156 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6157 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6158 : : &cap_idx) == NULL)
6159 : : return TEST_SKIPPED;
6160 : :
6161 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6162 : : return TEST_SKIPPED;
6163 : :
6164 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6165 : :
6166 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6167 : :
6168 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6169 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6170 : : printf("Device doesn't support in-place scatter-gather "
6171 : : "in both input and output mbufs.\n");
6172 : 0 : return TEST_SKIPPED;
6173 : : }
6174 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6175 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6176 : : printf("Device doesn't support RAW data-path APIs.\n");
6177 : 0 : return TEST_SKIPPED;
6178 : : }
6179 : : } else {
6180 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6181 : : return TEST_SKIPPED;
6182 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6183 : : printf("Device doesn't support out-of-place scatter-gather "
6184 : : "in both input and output mbufs.\n");
6185 : 0 : return TEST_SKIPPED;
6186 : : }
6187 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6188 : : printf("Device doesn't support digest encrypted.\n");
6189 : 0 : return TEST_SKIPPED;
6190 : : }
6191 : : }
6192 : :
6193 : : /* Create KASUMI session */
6194 : 0 : retval = create_wireless_algo_auth_cipher_session(
6195 : 0 : ts_params->valid_devs[0],
6196 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6197 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6198 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6199 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6200 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6201 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6202 : : tdata->key.data, tdata->key.len,
6203 : 0 : tdata->key.data, tdata->key.len,
6204 : 0 : 0, tdata->digest.len,
6205 : 0 : tdata->cipher_iv.len);
6206 : :
6207 [ # # ]: 0 : if (retval != 0)
6208 : : return retval;
6209 : :
6210 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6211 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6212 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6213 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6214 : :
6215 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6216 : : plaintext_pad_len, 15, 0);
6217 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6218 : : "Failed to allocate input buffer in mempool");
6219 : :
6220 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6221 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6222 : : plaintext_pad_len, 15, 0);
6223 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6224 : : "Failed to allocate output buffer in mempool");
6225 : : }
6226 : :
6227 [ # # ]: 0 : if (verify) {
6228 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6229 : 0 : tdata->ciphertext.data);
6230 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6231 : : ciphertext_len, buffer);
6232 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6233 : : ciphertext_len);
6234 : : } else {
6235 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6236 : 0 : tdata->plaintext.data);
6237 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6238 : : plaintext_len, buffer);
6239 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6240 : : plaintext_len);
6241 : : }
6242 : : memset(buffer, 0, sizeof(buffer));
6243 : :
6244 : : /* Create KASUMI operation */
6245 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6246 : 0 : tdata->digest.data, tdata->digest.len,
6247 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6248 : : NULL, 0,
6249 : 0 : (tdata->digest.offset_bytes == 0 ?
6250 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6251 : : : tdata->digest.offset_bytes),
6252 : 0 : tdata->validCipherLenInBits.len,
6253 : 0 : tdata->validCipherOffsetInBits.len,
6254 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6255 : : 0,
6256 : : op_mode, 1, verify);
6257 : :
6258 [ # # ]: 0 : if (retval < 0)
6259 : : return retval;
6260 : :
6261 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6262 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6263 : 0 : tdata->cipher_iv.len);
6264 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6265 : : return retval;
6266 : : } else
6267 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6268 : : ut_params->op);
6269 : :
6270 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6271 : :
6272 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6273 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6274 : :
6275 [ # # ]: 0 : if (verify) {
6276 [ # # ]: 0 : if (ut_params->obuf)
6277 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6278 : : plaintext_len, buffer);
6279 : : else
6280 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6281 : : plaintext_len, buffer);
6282 : :
6283 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6284 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6285 : 0 : debug_hexdump(stdout, "plaintext expected:",
6286 : 0 : tdata->plaintext.data,
6287 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6288 : : } else {
6289 [ # # ]: 0 : if (ut_params->obuf)
6290 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6291 : : ciphertext_len, buffer);
6292 : : else
6293 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6294 : : ciphertext_len, buffer);
6295 : :
6296 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6297 : : ciphertext_len);
6298 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6299 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6300 : :
6301 [ # # ]: 0 : if (ut_params->obuf)
6302 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6303 : 0 : (tdata->digest.offset_bytes == 0 ?
6304 : : plaintext_pad_len : tdata->digest.offset_bytes),
6305 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6306 : : else
6307 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6308 : 0 : (tdata->digest.offset_bytes == 0 ?
6309 : : plaintext_pad_len : tdata->digest.offset_bytes),
6310 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6311 : :
6312 : 0 : debug_hexdump(stdout, "digest:", digest,
6313 : 0 : tdata->digest.len);
6314 : 0 : debug_hexdump(stdout, "digest expected:",
6315 : 0 : tdata->digest.data, tdata->digest.len);
6316 : : }
6317 : :
6318 : : /* Validate obuf */
6319 [ # # ]: 0 : if (verify) {
6320 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6321 : : plaintext,
6322 : : tdata->plaintext.data,
6323 : : tdata->plaintext.len >> 3,
6324 : : "KASUMI Plaintext data not as expected");
6325 : : } else {
6326 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6327 : : ciphertext,
6328 : : tdata->ciphertext.data,
6329 : : tdata->validDataLenInBits.len,
6330 : : "KASUMI Ciphertext data not as expected");
6331 : :
6332 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6333 : : digest,
6334 : : tdata->digest.data,
6335 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6336 : : "KASUMI Generated auth tag not as expected");
6337 : : }
6338 : : return 0;
6339 : : }
6340 : :
6341 : : static int
6342 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6343 : : {
6344 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6345 : : struct crypto_unittest_params *ut_params = &unittest_params;
6346 : :
6347 : : int retval;
6348 : :
6349 : : uint8_t *plaintext, *ciphertext;
6350 : : unsigned plaintext_pad_len;
6351 : : unsigned plaintext_len;
6352 : : struct rte_cryptodev_info dev_info;
6353 : :
6354 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6355 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6356 : :
6357 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6358 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6359 : : printf("Device doesn't support RAW data-path APIs.\n");
6360 : 0 : return TEST_SKIPPED;
6361 : : }
6362 : :
6363 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6364 : : return TEST_SKIPPED;
6365 : :
6366 : : /* Verify the capabilities */
6367 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6368 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6369 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6370 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6371 : : &cap_idx) == NULL)
6372 : : return TEST_SKIPPED;
6373 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6374 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6375 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6376 : : &cap_idx) == NULL)
6377 : : return TEST_SKIPPED;
6378 : :
6379 : : /* Create KASUMI session */
6380 : 0 : retval = create_wireless_algo_cipher_auth_session(
6381 : 0 : ts_params->valid_devs[0],
6382 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6383 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6384 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6385 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6386 : : tdata->key.data, tdata->key.len,
6387 : 0 : tdata->key.data, tdata->key.len,
6388 : 0 : 0, tdata->digest.len,
6389 : 0 : tdata->cipher_iv.len);
6390 [ # # ]: 0 : if (retval != 0)
6391 : : return retval;
6392 : :
6393 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6394 : :
6395 : : /* clear mbuf payload */
6396 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6397 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6398 : :
6399 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6400 : : /* Append data which is padded to a multiple of */
6401 : : /* the algorithms block size */
6402 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6403 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6404 : : plaintext_pad_len);
6405 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6406 : :
6407 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6408 : :
6409 : : /* Create KASUMI operation */
6410 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6411 : 0 : tdata->digest.len, NULL, 0,
6412 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6413 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6414 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6415 : 0 : tdata->validCipherOffsetInBits.len,
6416 : 0 : tdata->validAuthLenInBits.len,
6417 : : 0
6418 : : );
6419 [ # # ]: 0 : if (retval < 0)
6420 : : return retval;
6421 : :
6422 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6423 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6424 : 0 : tdata->cipher_iv.len);
6425 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6426 : : return retval;
6427 : : } else
6428 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6429 : : ut_params->op);
6430 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6431 : :
6432 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6433 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6434 : : else
6435 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6436 : :
6437 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6438 : : tdata->validCipherOffsetInBits.len >> 3);
6439 : :
6440 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6441 : : uint8_t *,
6442 : : plaintext_pad_len);
6443 : :
6444 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6445 : : (tdata->validCipherOffsetInBits.len >> 3);
6446 : : /* Validate obuf */
6447 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6448 : : ciphertext,
6449 : : reference_ciphertext,
6450 : : tdata->validCipherLenInBits.len,
6451 : : "KASUMI Ciphertext data not as expected");
6452 : :
6453 : : /* Validate obuf */
6454 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6455 : : ut_params->digest,
6456 : : tdata->digest.data,
6457 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6458 : : "KASUMI Generated auth tag not as expected");
6459 : : return 0;
6460 : : }
6461 : :
6462 : : static int
6463 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6464 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6465 : : const uint16_t key_size, const uint16_t iv_size)
6466 : : {
6467 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6468 : : const struct rte_cryptodev_symmetric_capability *cap;
6469 : :
6470 : : /* Check if device supports the algorithm */
6471 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6472 : 0 : cap_idx.algo.cipher = cipher_algo;
6473 : :
6474 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6475 : : &cap_idx);
6476 : :
6477 [ # # ]: 0 : if (cap == NULL)
6478 : : return -1;
6479 : :
6480 : : /* Check if device supports key size and IV size */
6481 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6482 : : iv_size) < 0) {
6483 : 0 : return -1;
6484 : : }
6485 : :
6486 : : return 0;
6487 : : }
6488 : :
6489 : : static int
6490 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6491 : : const enum rte_crypto_auth_algorithm auth_algo,
6492 : : const uint16_t key_size, const uint16_t iv_size,
6493 : : const uint16_t tag_size)
6494 : : {
6495 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6496 : : const struct rte_cryptodev_symmetric_capability *cap;
6497 : :
6498 : : /* Check if device supports the algorithm */
6499 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6500 : 0 : cap_idx.algo.auth = auth_algo;
6501 : :
6502 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6503 : : &cap_idx);
6504 : :
6505 [ # # ]: 0 : if (cap == NULL)
6506 : : return -1;
6507 : :
6508 : : /* Check if device supports key size and IV size */
6509 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6510 : : tag_size, iv_size) < 0) {
6511 : 0 : return -1;
6512 : : }
6513 : :
6514 : : return 0;
6515 : : }
6516 : :
6517 : : static int
6518 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6519 : : enum rte_crypto_cipher_operation direction)
6520 : : {
6521 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6522 : : struct crypto_unittest_params *ut_params = &unittest_params;
6523 : :
6524 : : int retval;
6525 : : uint8_t *plaintext = NULL;
6526 : : uint8_t *ciphertext = NULL;
6527 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6528 : : unsigned int plaintext_len = 0;
6529 : : unsigned int ciphertext_len = 0;
6530 : : struct rte_cryptodev_info dev_info;
6531 : :
6532 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6533 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6534 : :
6535 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6536 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6537 : : printf("Device doesn't support RAW data-path APIs.\n");
6538 : 0 : return TEST_SKIPPED;
6539 : : }
6540 : :
6541 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6542 : : return TEST_SKIPPED;
6543 : :
6544 : : /* Check if device supports ZUC EEA3 */
6545 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6546 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6547 : : return TEST_SKIPPED;
6548 : :
6549 : : /* Create ZUC session */
6550 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6551 : : direction,
6552 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6553 : 0 : tdata->key.data, tdata->key.len,
6554 : 0 : tdata->cipher_iv.len);
6555 [ # # ]: 0 : if (retval != 0)
6556 : : return retval;
6557 : :
6558 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6559 : :
6560 : : /* Clear mbuf payload */
6561 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6562 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6563 : :
6564 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6565 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6566 : : /* Append data which is padded to a multiple */
6567 : : /* of the algorithms block size */
6568 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6569 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6570 : : plaintext_pad_len);
6571 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6572 : :
6573 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6574 : : } else {
6575 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6576 : : /* Append data which is padded to a multiple */
6577 : : /* of the algorithms block size */
6578 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6579 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6580 : : ciphertext_pad_len);
6581 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6582 : :
6583 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6584 : : }
6585 : :
6586 : : /* Create ZUC operation */
6587 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6588 : 0 : tdata->cipher_iv.len,
6589 : 0 : tdata->plaintext.len,
6590 : 0 : tdata->validCipherOffsetInBits.len);
6591 [ # # ]: 0 : if (retval < 0)
6592 : : return retval;
6593 : :
6594 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6595 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6596 : 0 : tdata->cipher_iv.len);
6597 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6598 : : return retval;
6599 : : } else
6600 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6601 : : ut_params->op);
6602 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6603 : :
6604 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6605 : :
6606 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6607 [ # # ]: 0 : if (ut_params->obuf)
6608 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6609 : : else
6610 : : ciphertext = plaintext;
6611 : :
6612 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6613 : :
6614 : : /* Validate obuf */
6615 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6616 : : ciphertext,
6617 : : tdata->ciphertext.data,
6618 : : tdata->validCipherLenInBits.len,
6619 : : "ZUC Ciphertext data not as expected");
6620 : : } else {
6621 [ # # ]: 0 : if (ut_params->obuf)
6622 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6623 : : else
6624 : : plaintext = ciphertext;
6625 : :
6626 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6627 : :
6628 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6629 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6630 : :
6631 : : /* Validate obuf */
6632 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6633 : : plaintext,
6634 : : reference_plaintext,
6635 : : tdata->validCipherLenInBits.len,
6636 : : "ZUC Plaintext data not as expected");
6637 : : }
6638 : :
6639 : : return 0;
6640 : : }
6641 : :
6642 : : static int
6643 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6644 : : enum rte_crypto_cipher_operation direction)
6645 : : {
6646 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6647 : : struct crypto_unittest_params *ut_params = &unittest_params;
6648 : :
6649 : : int retval;
6650 : :
6651 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6652 : : unsigned int plaintext_len = 0;
6653 : : unsigned int ciphertext_len = 0;
6654 : : const uint8_t *ciphertext, *plaintext;
6655 : : uint8_t buffer[2048];
6656 : : struct rte_cryptodev_info dev_info;
6657 : :
6658 : : /* Check if device supports ZUC EEA3 */
6659 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6660 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6661 : : return TEST_SKIPPED;
6662 : :
6663 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6664 : : return TEST_SKIPPED;
6665 : :
6666 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6667 : :
6668 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6669 : :
6670 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6671 : : printf("Device doesn't support in-place scatter-gather. "
6672 : : "Test Skipped.\n");
6673 : 0 : return TEST_SKIPPED;
6674 : : }
6675 : :
6676 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6677 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6678 : : printf("Device doesn't support RAW data-path APIs.\n");
6679 : 0 : return TEST_SKIPPED;
6680 : : }
6681 : :
6682 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6683 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6684 : :
6685 : : /* Append data which is padded to a multiple */
6686 : : /* of the algorithms block size */
6687 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6688 : :
6689 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6690 : : plaintext_pad_len, 10, 0);
6691 : :
6692 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6693 : 0 : tdata->plaintext.data);
6694 : : } else {
6695 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6696 : :
6697 : : /* Append data which is padded to a multiple */
6698 : : /* of the algorithms block size */
6699 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6700 : :
6701 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6702 : : ciphertext_pad_len, 10, 0);
6703 : :
6704 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6705 : 0 : tdata->ciphertext.data);
6706 : :
6707 : : }
6708 : :
6709 : : /* Create ZUC session */
6710 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6711 : : direction,
6712 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6713 : 0 : tdata->key.data, tdata->key.len,
6714 : 0 : tdata->cipher_iv.len);
6715 [ # # ]: 0 : if (retval < 0)
6716 : : return retval;
6717 : :
6718 : : /* Clear mbuf payload */
6719 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6720 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6721 : : else
6722 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6723 : :
6724 : : /* Create ZUC operation */
6725 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6726 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6727 : 0 : tdata->validCipherOffsetInBits.len);
6728 [ # # ]: 0 : if (retval < 0)
6729 : : return retval;
6730 : :
6731 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6732 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6733 : 0 : tdata->cipher_iv.len);
6734 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6735 : : return retval;
6736 : : } else
6737 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6738 : : ut_params->op);
6739 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6740 : :
6741 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6742 : :
6743 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6744 [ # # ]: 0 : if (ut_params->obuf)
6745 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6746 : : 0, plaintext_len, buffer);
6747 : : else
6748 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6749 : : 0, plaintext_len, buffer);
6750 : :
6751 : : /* Validate obuf */
6752 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6753 : :
6754 : : /* Validate obuf */
6755 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6756 : : ciphertext,
6757 : : tdata->ciphertext.data,
6758 : : tdata->validCipherLenInBits.len,
6759 : : "ZUC Ciphertext data not as expected");
6760 : : } else {
6761 [ # # ]: 0 : if (ut_params->obuf)
6762 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6763 : : 0, ciphertext_len, buffer);
6764 : : else
6765 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6766 : : 0, ciphertext_len, buffer);
6767 : :
6768 : : /* Validate obuf */
6769 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6770 : :
6771 : : /* Validate obuf */
6772 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6773 : : plaintext,
6774 : : tdata->plaintext.data,
6775 : : tdata->validCipherLenInBits.len,
6776 : : "ZUC Plaintext data not as expected");
6777 : : }
6778 : :
6779 : : return 0;
6780 : : }
6781 : :
6782 : : static int
6783 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6784 : : enum rte_crypto_auth_operation auth_op)
6785 : : {
6786 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6787 : : struct crypto_unittest_params *ut_params = &unittest_params;
6788 : :
6789 : : int retval;
6790 : : unsigned plaintext_pad_len;
6791 : : unsigned plaintext_len;
6792 : : uint8_t *plaintext;
6793 : :
6794 : : struct rte_cryptodev_info dev_info;
6795 : :
6796 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6797 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6798 : :
6799 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6800 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6801 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6802 : 0 : return TEST_SKIPPED;
6803 : : }
6804 : :
6805 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6806 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6807 : : printf("Device doesn't support RAW data-path APIs.\n");
6808 : 0 : return TEST_SKIPPED;
6809 : : }
6810 : :
6811 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6812 : : return TEST_SKIPPED;
6813 : :
6814 : : /* Check if device supports ZUC EIA3 */
6815 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6816 : 0 : tdata->key.len, tdata->auth_iv.len,
6817 : 0 : tdata->digest.len) < 0)
6818 : : return TEST_SKIPPED;
6819 : :
6820 : : /* Create ZUC session */
6821 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6822 : 0 : tdata->key.data, tdata->key.len,
6823 : 0 : tdata->auth_iv.len, tdata->digest.len,
6824 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6825 [ # # ]: 0 : if (retval != 0)
6826 : : return retval;
6827 : :
6828 : : /* alloc mbuf and set payload */
6829 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6830 : :
6831 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6832 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6833 : :
6834 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6835 : : /* Append data which is padded to a multiple of */
6836 : : /* the algorithms block size */
6837 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6838 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6839 : : plaintext_pad_len);
6840 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6841 : :
6842 : : /* Create ZUC operation */
6843 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6844 : 0 : tdata->digest.len,
6845 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6846 : : plaintext_pad_len,
6847 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6848 [ # # ]: 0 : if (retval < 0)
6849 : : return retval;
6850 : :
6851 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6852 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6853 : : 0);
6854 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6855 : : return retval;
6856 : : } else
6857 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6858 : : ut_params->op);
6859 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6860 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6861 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6862 : : uint8_t *,
6863 : : plaintext_pad_len);
6864 : :
6865 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6866 : : /* Validate obuf */
6867 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6868 : : ut_params->digest,
6869 : : tdata->digest.data,
6870 : : tdata->digest.len,
6871 : : "ZUC Generated auth tag not as expected");
6872 : : return 0;
6873 : : }
6874 : :
6875 : : /* Validate obuf */
6876 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6877 : : return 0;
6878 : : else
6879 : 0 : return -1;
6880 : :
6881 : : return 0;
6882 : : }
6883 : :
6884 : : static int
6885 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6886 : : uint8_t op_mode, uint8_t verify)
6887 : : {
6888 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6889 : : struct crypto_unittest_params *ut_params = &unittest_params;
6890 : :
6891 : : int retval;
6892 : :
6893 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6894 : : unsigned int plaintext_pad_len;
6895 : : unsigned int plaintext_len;
6896 : : unsigned int ciphertext_pad_len;
6897 : : unsigned int ciphertext_len;
6898 : : unsigned int digest_offset;
6899 : :
6900 : : struct rte_cryptodev_info dev_info;
6901 : :
6902 : : /* Check if device supports ZUC EEA3 */
6903 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6904 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6905 : : return TEST_SKIPPED;
6906 : :
6907 : : /* Check if device supports ZUC EIA3 */
6908 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6909 : 0 : tdata->key.len, tdata->auth_iv.len,
6910 : 0 : tdata->digest.len) < 0)
6911 : : return TEST_SKIPPED;
6912 : :
6913 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6914 : : return TEST_SKIPPED;
6915 : :
6916 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6917 : :
6918 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6919 : :
6920 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6921 : : printf("Device doesn't support digest encrypted.\n");
6922 : 0 : return TEST_SKIPPED;
6923 : : }
6924 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6925 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6926 : : printf("Device doesn't support in-place scatter-gather "
6927 : : "in both input and output mbufs.\n");
6928 : 0 : return TEST_SKIPPED;
6929 : : }
6930 : :
6931 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6932 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6933 : : printf("Device doesn't support RAW data-path APIs.\n");
6934 : 0 : return TEST_SKIPPED;
6935 : : }
6936 : : } else {
6937 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6938 : : return TEST_SKIPPED;
6939 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6940 : : printf("Device doesn't support out-of-place scatter-gather "
6941 : : "in both input and output mbufs.\n");
6942 : 0 : return TEST_SKIPPED;
6943 : : }
6944 : : }
6945 : :
6946 : : /* Create ZUC session */
6947 : 0 : retval = create_wireless_algo_auth_cipher_session(
6948 : 0 : ts_params->valid_devs[0],
6949 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6950 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6951 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6952 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6953 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6954 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6955 : : tdata->key.data, tdata->key.len,
6956 : 0 : tdata->key.data, tdata->key.len,
6957 : 0 : tdata->auth_iv.len, tdata->digest.len,
6958 : 0 : tdata->cipher_iv.len);
6959 : :
6960 [ # # ]: 0 : if (retval != 0)
6961 : : return retval;
6962 : :
6963 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6964 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6965 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6966 : :
6967 : : /* clear mbuf payload */
6968 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6969 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6970 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6971 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6972 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6973 : :
6974 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6975 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6976 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6977 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6978 : :
6979 [ # # ]: 0 : if (verify) {
6980 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6981 : : ciphertext_pad_len);
6982 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6983 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6984 : : ciphertext_len);
6985 : : } else {
6986 : : /* make sure enough space to cover partial digest verify case */
6987 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6988 : : ciphertext_pad_len);
6989 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6990 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6991 : : plaintext_len);
6992 : : }
6993 : :
6994 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6995 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6996 : :
6997 : : /* Create ZUC operation */
6998 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6999 : 0 : tdata->digest.data, tdata->digest.len,
7000 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7001 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7002 : 0 : (tdata->digest.offset_bytes == 0 ?
7003 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7004 : : : tdata->digest.offset_bytes),
7005 : 0 : tdata->validCipherLenInBits.len,
7006 : 0 : tdata->validCipherOffsetInBits.len,
7007 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7008 : : 0,
7009 : : op_mode, 0, verify);
7010 : :
7011 [ # # ]: 0 : if (retval < 0)
7012 : : return retval;
7013 : :
7014 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7015 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7016 : 0 : tdata->cipher_iv.len);
7017 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7018 : : return retval;
7019 : : } else
7020 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7021 : : ut_params->op);
7022 : :
7023 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7024 : :
7025 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7026 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7027 : :
7028 : :
7029 [ # # ]: 0 : if (verify) {
7030 [ # # ]: 0 : if (ut_params->obuf)
7031 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7032 : : uint8_t *);
7033 : : else
7034 : : plaintext = ciphertext;
7035 : :
7036 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7037 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7038 : 0 : debug_hexdump(stdout, "plaintext expected:",
7039 : 0 : tdata->plaintext.data,
7040 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7041 : : } else {
7042 [ # # ]: 0 : if (ut_params->obuf)
7043 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7044 : : uint8_t *);
7045 : : else
7046 : : ciphertext = plaintext;
7047 : :
7048 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7049 : : ciphertext_len);
7050 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7051 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7052 : :
7053 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
7054 : : digest_offset = plaintext_pad_len;
7055 : : else
7056 : : digest_offset = tdata->digest.offset_bytes;
7057 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
7058 : : uint8_t *, digest_offset);
7059 : :
7060 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
7061 : 0 : tdata->digest.len);
7062 : 0 : debug_hexdump(stdout, "digest expected:",
7063 : 0 : tdata->digest.data, tdata->digest.len);
7064 : : }
7065 : :
7066 : : /* Validate obuf */
7067 [ # # ]: 0 : if (verify) {
7068 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7069 : : plaintext,
7070 : : tdata->plaintext.data,
7071 : : tdata->plaintext.len >> 3,
7072 : : "ZUC Plaintext data not as expected");
7073 : : } else {
7074 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7075 : : ciphertext,
7076 : : tdata->ciphertext.data,
7077 : : tdata->ciphertext.len >> 3,
7078 : : "ZUC Ciphertext data not as expected");
7079 : :
7080 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7081 : : ut_params->digest,
7082 : : tdata->digest.data,
7083 : : tdata->digest.len,
7084 : : "ZUC Generated auth tag not as expected");
7085 : : }
7086 : : return 0;
7087 : : }
7088 : :
7089 : : static int
7090 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
7091 : : uint8_t op_mode, uint8_t verify)
7092 : : {
7093 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7094 : : struct crypto_unittest_params *ut_params = &unittest_params;
7095 : :
7096 : : int retval;
7097 : :
7098 : : const uint8_t *plaintext = NULL;
7099 : : const uint8_t *ciphertext = NULL;
7100 : : const uint8_t *digest = NULL;
7101 : : unsigned int plaintext_pad_len;
7102 : : unsigned int plaintext_len;
7103 : : unsigned int ciphertext_pad_len;
7104 : : unsigned int ciphertext_len;
7105 : : uint8_t buffer[10000];
7106 : : uint8_t digest_buffer[10000];
7107 : :
7108 : : struct rte_cryptodev_info dev_info;
7109 : :
7110 : : /* Check if device supports ZUC EEA3 */
7111 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
7112 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
7113 : : return TEST_SKIPPED;
7114 : :
7115 : : /* Check if device supports ZUC EIA3 */
7116 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
7117 : 0 : tdata->key.len, tdata->auth_iv.len,
7118 : 0 : tdata->digest.len) < 0)
7119 : : return TEST_SKIPPED;
7120 : :
7121 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7122 : : return TEST_SKIPPED;
7123 : :
7124 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7125 : :
7126 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7127 : :
7128 [ # # ]: 0 : if (op_mode == IN_PLACE) {
7129 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7130 : : printf("Device doesn't support in-place scatter-gather "
7131 : : "in both input and output mbufs.\n");
7132 : 0 : return TEST_SKIPPED;
7133 : : }
7134 : :
7135 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7136 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7137 : : printf("Device doesn't support RAW data-path APIs.\n");
7138 : 0 : return TEST_SKIPPED;
7139 : : }
7140 : : } else {
7141 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7142 : : return TEST_SKIPPED;
7143 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7144 : : printf("Device doesn't support out-of-place scatter-gather "
7145 : : "in both input and output mbufs.\n");
7146 : 0 : return TEST_SKIPPED;
7147 : : }
7148 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7149 : : printf("Device doesn't support digest encrypted.\n");
7150 : 0 : return TEST_SKIPPED;
7151 : : }
7152 : : }
7153 : :
7154 : : /* Create ZUC session */
7155 : 0 : retval = create_wireless_algo_auth_cipher_session(
7156 : 0 : ts_params->valid_devs[0],
7157 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7158 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7159 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7160 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
7161 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
7162 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
7163 : : tdata->key.data, tdata->key.len,
7164 : 0 : tdata->key.data, tdata->key.len,
7165 : 0 : tdata->auth_iv.len, tdata->digest.len,
7166 : 0 : tdata->cipher_iv.len);
7167 : :
7168 [ # # ]: 0 : if (retval != 0)
7169 : : return retval;
7170 : :
7171 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7172 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
7173 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7174 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7175 : :
7176 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7177 : : plaintext_pad_len, 15, 0);
7178 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7179 : : "Failed to allocate input buffer in mempool");
7180 : :
7181 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
7182 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7183 : : plaintext_pad_len, 15, 0);
7184 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
7185 : : "Failed to allocate output buffer in mempool");
7186 : : }
7187 : :
7188 [ # # ]: 0 : if (verify) {
7189 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7190 : 0 : tdata->ciphertext.data);
7191 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7192 : : ciphertext_len, buffer);
7193 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7194 : : ciphertext_len);
7195 : : } else {
7196 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7197 : 0 : tdata->plaintext.data);
7198 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7199 : : plaintext_len, buffer);
7200 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7201 : : plaintext_len);
7202 : : }
7203 : : memset(buffer, 0, sizeof(buffer));
7204 : :
7205 : : /* Create ZUC operation */
7206 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7207 : 0 : tdata->digest.data, tdata->digest.len,
7208 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7209 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7210 : 0 : (tdata->digest.offset_bytes == 0 ?
7211 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7212 : : : tdata->digest.offset_bytes),
7213 : 0 : tdata->validCipherLenInBits.len,
7214 : 0 : tdata->validCipherOffsetInBits.len,
7215 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7216 : : 0,
7217 : : op_mode, 1, verify);
7218 : :
7219 [ # # ]: 0 : if (retval < 0)
7220 : : return retval;
7221 : :
7222 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7223 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7224 : 0 : tdata->cipher_iv.len);
7225 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7226 : : return retval;
7227 : : } else
7228 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7229 : : ut_params->op);
7230 : :
7231 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7232 : :
7233 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7234 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7235 : :
7236 [ # # ]: 0 : if (verify) {
7237 [ # # ]: 0 : if (ut_params->obuf)
7238 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7239 : : plaintext_len, buffer);
7240 : : else
7241 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7242 : : plaintext_len, buffer);
7243 : :
7244 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7245 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7246 : 0 : debug_hexdump(stdout, "plaintext expected:",
7247 : 0 : tdata->plaintext.data,
7248 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7249 : : } else {
7250 [ # # ]: 0 : if (ut_params->obuf)
7251 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7252 : : ciphertext_len, buffer);
7253 : : else
7254 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7255 : : ciphertext_len, buffer);
7256 : :
7257 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7258 : : ciphertext_len);
7259 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7260 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7261 : :
7262 [ # # ]: 0 : if (ut_params->obuf)
7263 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
7264 : 0 : (tdata->digest.offset_bytes == 0 ?
7265 : : plaintext_pad_len : tdata->digest.offset_bytes),
7266 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7267 : : else
7268 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
7269 : 0 : (tdata->digest.offset_bytes == 0 ?
7270 : : plaintext_pad_len : tdata->digest.offset_bytes),
7271 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7272 : :
7273 : 0 : debug_hexdump(stdout, "digest:", digest,
7274 : 0 : tdata->digest.len);
7275 : 0 : debug_hexdump(stdout, "digest expected:",
7276 : 0 : tdata->digest.data, tdata->digest.len);
7277 : : }
7278 : :
7279 : : /* Validate obuf */
7280 [ # # ]: 0 : if (verify) {
7281 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7282 : : plaintext,
7283 : : tdata->plaintext.data,
7284 : : tdata->plaintext.len >> 3,
7285 : : "ZUC Plaintext data not as expected");
7286 : : } else {
7287 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7288 : : ciphertext,
7289 : : tdata->ciphertext.data,
7290 : : tdata->validDataLenInBits.len,
7291 : : "ZUC Ciphertext data not as expected");
7292 : :
7293 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7294 : : digest,
7295 : : tdata->digest.data,
7296 : : tdata->digest.len,
7297 : : "ZUC Generated auth tag not as expected");
7298 : : }
7299 : : return 0;
7300 : : }
7301 : :
7302 : : static int
7303 : 0 : test_kasumi_encryption_test_case_1(void)
7304 : : {
7305 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
7306 : : }
7307 : :
7308 : : static int
7309 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
7310 : : {
7311 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7312 : : }
7313 : :
7314 : : static int
7315 : 0 : test_kasumi_encryption_test_case_1_oop(void)
7316 : : {
7317 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
7318 : : }
7319 : :
7320 : : static int
7321 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
7322 : : {
7323 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7324 : : }
7325 : :
7326 : : static int
7327 : 0 : test_kasumi_encryption_test_case_2(void)
7328 : : {
7329 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
7330 : : }
7331 : :
7332 : : static int
7333 : 0 : test_kasumi_encryption_test_case_3(void)
7334 : : {
7335 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
7336 : : }
7337 : :
7338 : : static int
7339 : 0 : test_kasumi_encryption_test_case_4(void)
7340 : : {
7341 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
7342 : : }
7343 : :
7344 : : static int
7345 : 0 : test_kasumi_encryption_test_case_5(void)
7346 : : {
7347 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
7348 : : }
7349 : :
7350 : : static int
7351 : 0 : test_kasumi_decryption_test_case_1(void)
7352 : : {
7353 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
7354 : : }
7355 : :
7356 : : static int
7357 : 0 : test_kasumi_decryption_test_case_1_oop(void)
7358 : : {
7359 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
7360 : : }
7361 : :
7362 : : static int
7363 : 0 : test_kasumi_decryption_test_case_2(void)
7364 : : {
7365 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
7366 : : }
7367 : :
7368 : : static int
7369 : 0 : test_kasumi_decryption_test_case_3(void)
7370 : : {
7371 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7372 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7373 : : return TEST_SKIPPED;
7374 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7375 : : }
7376 : :
7377 : : static int
7378 : 0 : test_kasumi_decryption_test_case_4(void)
7379 : : {
7380 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7381 : : }
7382 : :
7383 : : static int
7384 : 0 : test_kasumi_decryption_test_case_5(void)
7385 : : {
7386 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7387 : : }
7388 : : static int
7389 : 0 : test_snow3g_encryption_test_case_1(void)
7390 : : {
7391 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7392 : : }
7393 : :
7394 : : static int
7395 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7396 : : {
7397 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7398 : : }
7399 : :
7400 : : static int
7401 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7402 : : {
7403 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7404 : : }
7405 : :
7406 : : static int
7407 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7408 : : {
7409 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7410 : : }
7411 : :
7412 : : static int
7413 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7414 : : {
7415 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7416 : : }
7417 : :
7418 : : static int
7419 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7420 : : {
7421 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7422 : : }
7423 : :
7424 : : static int
7425 : 0 : test_snow3g_encryption_test_case_2(void)
7426 : : {
7427 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7428 : : }
7429 : :
7430 : : static int
7431 : 0 : test_snow3g_encryption_test_case_3(void)
7432 : : {
7433 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7434 : : }
7435 : :
7436 : : static int
7437 : 0 : test_snow3g_encryption_test_case_4(void)
7438 : : {
7439 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7440 : : }
7441 : :
7442 : : static int
7443 : 0 : test_snow3g_encryption_test_case_5(void)
7444 : : {
7445 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7446 : : }
7447 : :
7448 : : static int
7449 : 0 : test_snow3g_decryption_test_case_1(void)
7450 : : {
7451 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7452 : : }
7453 : :
7454 : : static int
7455 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7456 : : {
7457 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7458 : : }
7459 : :
7460 : : static int
7461 : 0 : test_snow3g_decryption_test_case_2(void)
7462 : : {
7463 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7464 : : }
7465 : :
7466 : : static int
7467 : 0 : test_snow3g_decryption_test_case_3(void)
7468 : : {
7469 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7470 : : }
7471 : :
7472 : : static int
7473 : 0 : test_snow3g_decryption_test_case_4(void)
7474 : : {
7475 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7476 : : }
7477 : :
7478 : : static int
7479 : 0 : test_snow3g_decryption_test_case_5(void)
7480 : : {
7481 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7482 : : }
7483 : :
7484 : : /*
7485 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7486 : : * Pattern digest from snow3g_test_data must be allocated as
7487 : : * 4 last bytes in plaintext.
7488 : : */
7489 : : static void
7490 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7491 : : struct snow3g_hash_test_data *output)
7492 : : {
7493 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7494 : 0 : output->key.len = pattern->key.len;
7495 : :
7496 : 0 : memcpy(output->key.data,
7497 : 0 : pattern->key.data, pattern->key.len);
7498 : :
7499 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7500 : :
7501 : 0 : memcpy(output->auth_iv.data,
7502 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7503 : :
7504 : 0 : output->plaintext.len = pattern->plaintext.len;
7505 : :
7506 : 0 : memcpy(output->plaintext.data,
7507 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7508 : :
7509 : 0 : output->digest.len = pattern->digest.len;
7510 : :
7511 : 0 : memcpy(output->digest.data,
7512 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7513 : : pattern->digest.len);
7514 : :
7515 : 0 : output->validAuthLenInBits.len =
7516 : 0 : pattern->validAuthLenInBits.len;
7517 : : }
7518 : 0 : }
7519 : :
7520 : : /*
7521 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7522 : : */
7523 : : static int
7524 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7525 : : {
7526 : : int ret;
7527 : : struct snow3g_hash_test_data snow3g_hash_data;
7528 : : struct rte_cryptodev_info dev_info;
7529 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7530 : :
7531 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7532 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7533 : :
7534 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7535 : : printf("Device doesn't support encrypted digest operations.\n");
7536 : 0 : return TEST_SKIPPED;
7537 : : }
7538 : :
7539 : : /*
7540 : : * Function prepare data for hash verification test case.
7541 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7542 : : */
7543 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7544 : :
7545 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7546 [ # # ]: 0 : if (ret != 0)
7547 : : return ret;
7548 : :
7549 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7550 : : }
7551 : :
7552 : : static int
7553 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7554 : : {
7555 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7556 : : }
7557 : :
7558 : : static int
7559 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7560 : : {
7561 : 0 : return test_snow3g_auth_cipher(
7562 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7563 : : }
7564 : :
7565 : : static int
7566 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7567 : : {
7568 : 0 : return test_snow3g_auth_cipher(
7569 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7570 : : }
7571 : :
7572 : : static int
7573 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7574 : : {
7575 : 0 : return test_snow3g_auth_cipher(
7576 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7577 : : }
7578 : :
7579 : : static int
7580 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7581 : : {
7582 : 0 : return test_snow3g_auth_cipher(
7583 : : &snow3g_auth_cipher_partial_digest_encryption,
7584 : : IN_PLACE, 0);
7585 : : }
7586 : :
7587 : : static int
7588 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7589 : : {
7590 : 0 : return test_snow3g_auth_cipher(
7591 : : &snow3g_auth_cipher_partial_digest_encryption,
7592 : : OUT_OF_PLACE, 0);
7593 : : }
7594 : :
7595 : : static int
7596 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7597 : : {
7598 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7599 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7600 : : return TEST_SKIPPED;
7601 : 0 : return test_snow3g_auth_cipher_sgl(
7602 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7603 : : }
7604 : :
7605 : : static int
7606 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7607 : : {
7608 : 0 : return test_snow3g_auth_cipher_sgl(
7609 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7610 : : }
7611 : :
7612 : : static int
7613 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7614 : : {
7615 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7616 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7617 : : return TEST_SKIPPED;
7618 : 0 : return test_snow3g_auth_cipher_sgl(
7619 : : &snow3g_auth_cipher_partial_digest_encryption,
7620 : : IN_PLACE, 0);
7621 : : }
7622 : :
7623 : : static int
7624 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7625 : : {
7626 : 0 : return test_snow3g_auth_cipher_sgl(
7627 : : &snow3g_auth_cipher_partial_digest_encryption,
7628 : : OUT_OF_PLACE, 0);
7629 : : }
7630 : :
7631 : : static int
7632 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7633 : : {
7634 : 0 : return test_snow3g_auth_cipher(
7635 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7636 : : }
7637 : :
7638 : : static int
7639 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7640 : : {
7641 : 0 : return test_snow3g_auth_cipher(
7642 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7643 : : }
7644 : :
7645 : : static int
7646 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7647 : : {
7648 : 0 : return test_snow3g_auth_cipher_sgl(
7649 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7650 : : }
7651 : :
7652 : : static int
7653 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7654 : : {
7655 : 0 : return test_snow3g_auth_cipher_sgl(
7656 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7657 : : }
7658 : :
7659 : : static int
7660 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7661 : : {
7662 : 0 : return test_snow3g_auth_cipher(
7663 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7664 : : }
7665 : :
7666 : : static int
7667 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7668 : : {
7669 : 0 : return test_snow3g_auth_cipher(
7670 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7671 : : }
7672 : :
7673 : : static int
7674 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7675 : : {
7676 : 0 : return test_snow3g_auth_cipher(
7677 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7678 : : }
7679 : :
7680 : : static int
7681 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7682 : : {
7683 : 0 : return test_snow3g_auth_cipher(
7684 : : &snow3g_auth_cipher_partial_digest_encryption,
7685 : : IN_PLACE, 1);
7686 : : }
7687 : :
7688 : : static int
7689 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7690 : : {
7691 : 0 : return test_snow3g_auth_cipher(
7692 : : &snow3g_auth_cipher_partial_digest_encryption,
7693 : : OUT_OF_PLACE, 1);
7694 : : }
7695 : :
7696 : : static int
7697 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7698 : : {
7699 : 0 : return test_snow3g_auth_cipher_sgl(
7700 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7701 : : }
7702 : :
7703 : : static int
7704 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7705 : : {
7706 : 0 : return test_snow3g_auth_cipher_sgl(
7707 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7708 : : }
7709 : :
7710 : : static int
7711 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7712 : : {
7713 : 0 : return test_snow3g_auth_cipher_sgl(
7714 : : &snow3g_auth_cipher_partial_digest_encryption,
7715 : : IN_PLACE, 1);
7716 : : }
7717 : :
7718 : : static int
7719 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7720 : : {
7721 : 0 : return test_snow3g_auth_cipher_sgl(
7722 : : &snow3g_auth_cipher_partial_digest_encryption,
7723 : : OUT_OF_PLACE, 1);
7724 : : }
7725 : :
7726 : : static int
7727 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7728 : : {
7729 : 0 : return test_snow3g_auth_cipher(
7730 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7731 : : }
7732 : :
7733 : : static int
7734 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7735 : : {
7736 : 0 : return test_snow3g_auth_cipher(
7737 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7738 : : }
7739 : :
7740 : : static int
7741 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7742 : : {
7743 : 0 : return test_snow3g_auth_cipher_sgl(
7744 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7745 : : }
7746 : :
7747 : : static int
7748 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7749 : : {
7750 : 0 : return test_snow3g_auth_cipher_sgl(
7751 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7752 : : }
7753 : :
7754 : : static int
7755 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7756 : : {
7757 : 0 : return test_snow3g_auth_cipher(
7758 : : &snow3g_test_case_7, IN_PLACE, 0);
7759 : : }
7760 : :
7761 : : static int
7762 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7763 : : {
7764 : 0 : return test_kasumi_auth_cipher(
7765 : : &kasumi_test_case_3, IN_PLACE, 0);
7766 : : }
7767 : :
7768 : : static int
7769 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7770 : : {
7771 : 0 : return test_kasumi_auth_cipher(
7772 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7773 : : }
7774 : :
7775 : : static int
7776 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7777 : : {
7778 : 0 : return test_kasumi_auth_cipher(
7779 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7780 : : }
7781 : :
7782 : : static int
7783 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7784 : : {
7785 : 0 : return test_kasumi_auth_cipher_sgl(
7786 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7787 : : }
7788 : :
7789 : : static int
7790 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7791 : : {
7792 : 0 : return test_kasumi_auth_cipher_sgl(
7793 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7794 : : }
7795 : :
7796 : : static int
7797 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7798 : : {
7799 : 0 : return test_kasumi_auth_cipher(
7800 : : &kasumi_test_case_3, IN_PLACE, 1);
7801 : : }
7802 : :
7803 : : static int
7804 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7805 : : {
7806 : 0 : return test_kasumi_auth_cipher(
7807 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7808 : : }
7809 : :
7810 : : static int
7811 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7812 : : {
7813 : 0 : return test_kasumi_auth_cipher(
7814 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7815 : : }
7816 : :
7817 : : static int
7818 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7819 : : {
7820 : 0 : return test_kasumi_auth_cipher_sgl(
7821 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7822 : : }
7823 : :
7824 : : static int
7825 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7826 : : {
7827 : 0 : return test_kasumi_auth_cipher_sgl(
7828 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7829 : : }
7830 : :
7831 : : static int
7832 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7833 : : {
7834 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7835 : : }
7836 : :
7837 : : static int
7838 : 0 : test_zuc_encryption_test_case_1(void)
7839 : : {
7840 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7841 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7842 : : }
7843 : :
7844 : : static int
7845 : 0 : test_zuc_encryption_test_case_2(void)
7846 : : {
7847 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7848 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7849 : : }
7850 : :
7851 : : static int
7852 : 0 : test_zuc_encryption_test_case_3(void)
7853 : : {
7854 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7855 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7856 : : }
7857 : :
7858 : : static int
7859 : 0 : test_zuc_encryption_test_case_4(void)
7860 : : {
7861 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7862 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7863 : : }
7864 : :
7865 : : static int
7866 : 0 : test_zuc_encryption_test_case_5(void)
7867 : : {
7868 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7869 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7870 : : }
7871 : :
7872 : : static int
7873 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7874 : : {
7875 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7876 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7877 : : }
7878 : :
7879 : : static int
7880 : 0 : test_zuc_decryption_test_case_1(void)
7881 : : {
7882 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7883 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7884 : : }
7885 : :
7886 : : static int
7887 : 0 : test_zuc_decryption_test_case_2(void)
7888 : : {
7889 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7890 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7891 : : }
7892 : :
7893 : : static int
7894 : 0 : test_zuc_decryption_test_case_3(void)
7895 : : {
7896 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7897 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7898 : : }
7899 : :
7900 : : static int
7901 : 0 : test_zuc_decryption_test_case_4(void)
7902 : : {
7903 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7904 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7905 : : }
7906 : :
7907 : : static int
7908 : 0 : test_zuc_decryption_test_case_5(void)
7909 : : {
7910 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7911 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7912 : : }
7913 : :
7914 : : static int
7915 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7916 : : {
7917 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7918 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7919 : : }
7920 : :
7921 : : static int
7922 : 0 : test_zuc_hash_generate_test_case_1(void)
7923 : : {
7924 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7925 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7926 : : }
7927 : :
7928 : : static int
7929 : 0 : test_zuc_hash_generate_test_case_2(void)
7930 : : {
7931 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7932 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7933 : : }
7934 : :
7935 : : static int
7936 : 0 : test_zuc_hash_generate_test_case_3(void)
7937 : : {
7938 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7939 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7940 : : }
7941 : :
7942 : : static int
7943 : 0 : test_zuc_hash_generate_test_case_4(void)
7944 : : {
7945 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7946 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7947 : : }
7948 : :
7949 : : static int
7950 : 0 : test_zuc_hash_generate_test_case_5(void)
7951 : : {
7952 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7953 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7954 : : }
7955 : :
7956 : : static int
7957 : 0 : test_zuc_hash_generate_test_case_6(void)
7958 : : {
7959 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7960 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7961 : : }
7962 : :
7963 : : static int
7964 : 0 : test_zuc_hash_generate_test_case_7(void)
7965 : : {
7966 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7967 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7968 : : }
7969 : :
7970 : : static int
7971 : 0 : test_zuc_hash_generate_test_case_8(void)
7972 : : {
7973 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7974 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7975 : : }
7976 : :
7977 : : static int
7978 : 0 : test_zuc_hash_verify_test_case_1(void)
7979 : : {
7980 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7981 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7982 : : }
7983 : :
7984 : : static int
7985 : 0 : test_zuc_hash_verify_test_case_2(void)
7986 : : {
7987 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7988 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7989 : : }
7990 : :
7991 : : static int
7992 : 0 : test_zuc_hash_verify_test_case_3(void)
7993 : : {
7994 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7995 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7996 : : }
7997 : :
7998 : : static int
7999 : 0 : test_zuc_hash_verify_test_case_4(void)
8000 : : {
8001 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
8002 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8003 : : }
8004 : :
8005 : : static int
8006 : 0 : test_zuc_hash_verify_test_case_5(void)
8007 : : {
8008 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
8009 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8010 : : }
8011 : :
8012 : : static int
8013 : 0 : test_zuc_hash_verify_test_case_6(void)
8014 : : {
8015 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
8016 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8017 : : }
8018 : :
8019 : : static int
8020 : 0 : test_zuc_hash_verify_test_case_7(void)
8021 : : {
8022 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
8023 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8024 : : }
8025 : :
8026 : : static int
8027 : 0 : test_zuc_hash_verify_test_case_8(void)
8028 : : {
8029 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
8030 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8031 : : }
8032 : :
8033 : : static int
8034 : 0 : test_zuc_cipher_auth_test_case_1(void)
8035 : : {
8036 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
8037 : : }
8038 : :
8039 : : static int
8040 : 0 : test_zuc_cipher_auth_test_case_2(void)
8041 : : {
8042 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
8043 : : }
8044 : :
8045 : : static int
8046 : 0 : test_zuc_auth_cipher_test_case_1(void)
8047 : : {
8048 : 0 : return test_zuc_auth_cipher(
8049 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8050 : : }
8051 : :
8052 : : static int
8053 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
8054 : : {
8055 : 0 : return test_zuc_auth_cipher(
8056 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8057 : : }
8058 : :
8059 : : static int
8060 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
8061 : : {
8062 : 0 : return test_zuc_auth_cipher_sgl(
8063 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8064 : : }
8065 : :
8066 : : static int
8067 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
8068 : : {
8069 : 0 : return test_zuc_auth_cipher_sgl(
8070 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8071 : : }
8072 : :
8073 : : static int
8074 : 0 : test_zuc_auth_cipher_test_case_2(void)
8075 : : {
8076 : 0 : return test_zuc_auth_cipher(
8077 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
8078 : : }
8079 : :
8080 : : static int
8081 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
8082 : : {
8083 : 0 : return test_zuc_auth_cipher(
8084 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
8085 : : }
8086 : :
8087 : : static int
8088 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
8089 : : {
8090 : 0 : return test_zuc_auth_cipher(
8091 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8092 : : }
8093 : :
8094 : : static int
8095 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
8096 : : {
8097 : 0 : return test_zuc_auth_cipher(
8098 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8099 : : }
8100 : :
8101 : : static int
8102 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
8103 : : {
8104 : 0 : return test_zuc_auth_cipher_sgl(
8105 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8106 : : }
8107 : :
8108 : : static int
8109 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
8110 : : {
8111 : 0 : return test_zuc_auth_cipher_sgl(
8112 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8113 : : }
8114 : :
8115 : : static int
8116 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
8117 : : {
8118 : 0 : return test_zuc_auth_cipher(
8119 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
8120 : : }
8121 : :
8122 : : static int
8123 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
8124 : : {
8125 : 0 : return test_zuc_auth_cipher(
8126 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8127 : : }
8128 : :
8129 : : static int
8130 : 0 : test_zuc256_encryption_test_case_1(void)
8131 : : {
8132 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8133 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8134 : : }
8135 : :
8136 : : static int
8137 : 0 : test_zuc256_encryption_test_case_2(void)
8138 : : {
8139 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8140 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8141 : : }
8142 : :
8143 : : static int
8144 : 0 : test_zuc256_decryption_test_case_1(void)
8145 : : {
8146 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8147 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8148 : : }
8149 : :
8150 : : static int
8151 : 0 : test_zuc256_decryption_test_case_2(void)
8152 : : {
8153 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8154 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8155 : : }
8156 : :
8157 : : static int
8158 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
8159 : : {
8160 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8161 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8162 : : }
8163 : :
8164 : : static int
8165 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
8166 : : {
8167 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8168 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8169 : : }
8170 : :
8171 : : static int
8172 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
8173 : : {
8174 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8175 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8176 : : }
8177 : :
8178 : : static int
8179 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
8180 : : {
8181 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8182 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8183 : : }
8184 : :
8185 : : static int
8186 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
8187 : : {
8188 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8189 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8190 : : }
8191 : :
8192 : : static int
8193 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
8194 : : {
8195 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8196 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8197 : : }
8198 : :
8199 : : static int
8200 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
8201 : : {
8202 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8203 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8204 : : }
8205 : :
8206 : : static int
8207 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
8208 : : {
8209 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8210 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8211 : : }
8212 : :
8213 : : static int
8214 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
8215 : : {
8216 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8217 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8218 : : }
8219 : :
8220 : : static int
8221 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
8222 : : {
8223 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8224 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8225 : : }
8226 : :
8227 : : static int
8228 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8229 : : {
8230 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8231 : : }
8232 : :
8233 : : static int
8234 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8235 : : {
8236 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8237 : : }
8238 : :
8239 : : static int
8240 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8241 : : {
8242 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8243 : : }
8244 : :
8245 : : static int
8246 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8247 : : {
8248 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8249 : : }
8250 : :
8251 : : static int
8252 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8253 : : {
8254 : 0 : return test_zuc_auth_cipher(
8255 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8256 : : }
8257 : :
8258 : : static int
8259 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8260 : : {
8261 : 0 : return test_zuc_auth_cipher(
8262 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8263 : : }
8264 : :
8265 : : static int
8266 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8267 : : {
8268 : 0 : return test_zuc_auth_cipher(
8269 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8270 : : }
8271 : :
8272 : : static int
8273 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8274 : : {
8275 : 0 : return test_zuc_auth_cipher(
8276 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8277 : : }
8278 : :
8279 : : static int
8280 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8281 : : {
8282 : 0 : return test_zuc_auth_cipher(
8283 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8284 : : }
8285 : :
8286 : : static int
8287 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8288 : : {
8289 : 0 : return test_zuc_auth_cipher(
8290 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8291 : : }
8292 : :
8293 : : static int
8294 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8295 : : {
8296 : 0 : return test_zuc_auth_cipher(
8297 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8298 : : }
8299 : :
8300 : : static int
8301 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8302 : : {
8303 : 0 : return test_zuc_auth_cipher(
8304 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8305 : : }
8306 : :
8307 : : static int
8308 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8309 : : {
8310 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
8311 : :
8312 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8313 : :
8314 : : /* Check if device supports particular cipher algorithm */
8315 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8316 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
8317 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8318 : : return TEST_SKIPPED;
8319 : :
8320 : : /* Check if device supports particular hash algorithm */
8321 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8322 : 24 : cap_idx.algo.auth = tdata->auth_algo;
8323 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8324 : 12 : return TEST_SKIPPED;
8325 : :
8326 : : return 0;
8327 : : }
8328 : :
8329 : : static int
8330 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8331 : : uint8_t op_mode, uint8_t verify)
8332 : : {
8333 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8334 : : struct crypto_unittest_params *ut_params = &unittest_params;
8335 : :
8336 : : int retval;
8337 : :
8338 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
8339 : : unsigned int plaintext_pad_len;
8340 : : unsigned int plaintext_len;
8341 : : unsigned int ciphertext_pad_len;
8342 : : unsigned int ciphertext_len;
8343 : : unsigned int digest_offset;
8344 : :
8345 : : struct rte_cryptodev_info dev_info;
8346 : : struct rte_crypto_op *op;
8347 : :
8348 : : /* Check if device supports particular algorithms separately */
8349 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
8350 : : return TEST_SKIPPED;
8351 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8352 : : return TEST_SKIPPED;
8353 : :
8354 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8355 : : return TEST_SKIPPED;
8356 : :
8357 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8358 : :
8359 : 8 : uint64_t feat_flags = dev_info.feature_flags;
8360 : :
8361 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8362 : : printf("Device doesn't support digest encrypted.\n");
8363 : 8 : return TEST_SKIPPED;
8364 : : }
8365 : :
8366 : : /* Create the session */
8367 [ # # ]: 0 : if (verify)
8368 : 0 : retval = create_wireless_algo_cipher_auth_session(
8369 : 0 : ts_params->valid_devs[0],
8370 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8371 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8372 : 0 : tdata->auth_algo,
8373 : 0 : tdata->cipher_algo,
8374 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8375 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8376 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8377 : 0 : tdata->cipher_iv.len);
8378 : : else
8379 : 0 : retval = create_wireless_algo_auth_cipher_session(
8380 : 0 : ts_params->valid_devs[0],
8381 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8382 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8383 : 0 : tdata->auth_algo,
8384 : 0 : tdata->cipher_algo,
8385 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8386 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8387 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8388 : 0 : tdata->cipher_iv.len);
8389 [ # # ]: 0 : if (retval != 0)
8390 : : return retval;
8391 : :
8392 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8393 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8394 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8395 : :
8396 : : /* clear mbuf payload */
8397 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8398 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8399 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8400 : :
8401 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8402 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8403 : : }
8404 : :
8405 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8406 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8407 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8408 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8409 : :
8410 [ # # ]: 0 : if (verify) {
8411 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8412 : : ciphertext_pad_len);
8413 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8414 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8415 : : ciphertext_len);
8416 : : } else {
8417 : : /* make sure enough space to cover partial digest verify case */
8418 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8419 : : ciphertext_pad_len);
8420 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8421 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8422 : : }
8423 : :
8424 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8425 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8426 : :
8427 : : /* Create the operation */
8428 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8429 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8430 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8431 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8432 : 0 : (tdata->digest_enc.offset == 0 ?
8433 : : plaintext_pad_len
8434 : : : tdata->digest_enc.offset),
8435 : 0 : tdata->validCipherLen.len_bits,
8436 : 0 : tdata->cipher.offset_bits,
8437 : 0 : tdata->validAuthLen.len_bits,
8438 [ # # ]: 0 : tdata->auth.offset_bits,
8439 : : op_mode, 0, verify);
8440 : :
8441 [ # # ]: 0 : if (retval < 0)
8442 : : return retval;
8443 : :
8444 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8445 : :
8446 : : /* Check if the op failed because the device doesn't */
8447 : : /* support this particular combination of algorithms */
8448 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8449 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8450 : : printf("Device doesn't support this mixed combination. "
8451 : : "Test Skipped.\n");
8452 : 0 : return TEST_SKIPPED;
8453 : : }
8454 : 0 : ut_params->op = op;
8455 : :
8456 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8457 : :
8458 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8459 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8460 : :
8461 [ # # ]: 0 : if (verify) {
8462 [ # # ]: 0 : if (ut_params->obuf)
8463 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8464 : : uint8_t *);
8465 : : else
8466 : 0 : plaintext = ciphertext +
8467 : 0 : (tdata->cipher.offset_bits >> 3);
8468 : :
8469 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8470 : 0 : tdata->plaintext.len_bits >> 3);
8471 : 0 : debug_hexdump(stdout, "plaintext expected:",
8472 : 0 : tdata->plaintext.data,
8473 : 0 : tdata->plaintext.len_bits >> 3);
8474 : : } else {
8475 [ # # ]: 0 : if (ut_params->obuf)
8476 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8477 : : uint8_t *);
8478 : : else
8479 : : ciphertext = plaintext;
8480 : :
8481 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8482 : : ciphertext_len);
8483 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8484 : 0 : tdata->ciphertext.data,
8485 : 0 : tdata->ciphertext.len_bits >> 3);
8486 : :
8487 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8488 : : digest_offset = plaintext_pad_len;
8489 : : else
8490 : : digest_offset = tdata->digest_enc.offset;
8491 : :
8492 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8493 : : uint8_t *, digest_offset);
8494 : :
8495 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8496 : 0 : tdata->digest_enc.len);
8497 : 0 : debug_hexdump(stdout, "digest expected:",
8498 : : tdata->digest_enc.data,
8499 : 0 : tdata->digest_enc.len);
8500 : : }
8501 : :
8502 [ # # ]: 0 : if (!verify) {
8503 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8504 : : ut_params->digest,
8505 : : tdata->digest_enc.data,
8506 : : tdata->digest_enc.len,
8507 : : "Generated auth tag not as expected");
8508 : : }
8509 : :
8510 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8511 [ # # ]: 0 : if (verify) {
8512 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8513 : : plaintext,
8514 : : tdata->plaintext.data,
8515 : : tdata->plaintext.len_bits >> 3,
8516 : : "Plaintext data not as expected");
8517 : : } else {
8518 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8519 : : ciphertext,
8520 : : tdata->ciphertext.data,
8521 : : tdata->validDataLen.len_bits,
8522 : : "Ciphertext data not as expected");
8523 : : }
8524 : : }
8525 : :
8526 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8527 : : "crypto op processing failed");
8528 : :
8529 : : return 0;
8530 : : }
8531 : :
8532 : : static int
8533 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8534 : : uint8_t op_mode, uint8_t verify)
8535 : : {
8536 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8537 : : struct crypto_unittest_params *ut_params = &unittest_params;
8538 : :
8539 : : int retval;
8540 : :
8541 : : const uint8_t *plaintext = NULL;
8542 : : const uint8_t *ciphertext = NULL;
8543 : : const uint8_t *digest = NULL;
8544 : : unsigned int plaintext_pad_len;
8545 : : unsigned int plaintext_len;
8546 : : unsigned int ciphertext_pad_len;
8547 : : unsigned int ciphertext_len;
8548 : : uint8_t buffer[10000];
8549 : : uint8_t digest_buffer[10000];
8550 : :
8551 : : struct rte_cryptodev_info dev_info;
8552 : : struct rte_crypto_op *op;
8553 : :
8554 : : /* Check if device supports particular algorithms */
8555 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8556 : : return TEST_SKIPPED;
8557 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8558 : : return TEST_SKIPPED;
8559 : :
8560 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8561 : :
8562 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8563 : :
8564 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8565 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8566 : : printf("Device doesn't support in-place scatter-gather "
8567 : : "in both input and output mbufs.\n");
8568 : 0 : return TEST_SKIPPED;
8569 : : }
8570 : : } else {
8571 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8572 : : printf("Device doesn't support out-of-place scatter-gather "
8573 : : "in both input and output mbufs.\n");
8574 : 2 : return TEST_SKIPPED;
8575 : : }
8576 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8577 : : printf("Device doesn't support digest encrypted.\n");
8578 : 0 : return TEST_SKIPPED;
8579 : : }
8580 : : }
8581 : :
8582 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8583 : : return TEST_SKIPPED;
8584 : :
8585 : : /* Create the session */
8586 [ + + ]: 2 : if (verify)
8587 : 1 : retval = create_wireless_algo_cipher_auth_session(
8588 : 1 : ts_params->valid_devs[0],
8589 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8590 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8591 : 1 : tdata->auth_algo,
8592 : 1 : tdata->cipher_algo,
8593 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8594 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8595 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8596 : 1 : tdata->cipher_iv.len);
8597 : : else
8598 : 1 : retval = create_wireless_algo_auth_cipher_session(
8599 : 1 : ts_params->valid_devs[0],
8600 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8601 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8602 : 1 : tdata->auth_algo,
8603 : 1 : tdata->cipher_algo,
8604 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8605 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8606 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8607 : 1 : tdata->cipher_iv.len);
8608 [ + - ]: 2 : if (retval != 0)
8609 : : return retval;
8610 : :
8611 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8612 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8613 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8614 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8615 : :
8616 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8617 : : ciphertext_pad_len, 15, 0);
8618 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8619 : : "Failed to allocate input buffer in mempool");
8620 : :
8621 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8622 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8623 : : plaintext_pad_len, 15, 0);
8624 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8625 : : "Failed to allocate output buffer in mempool");
8626 : : }
8627 : :
8628 [ + + ]: 2 : if (verify) {
8629 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8630 : 1 : tdata->ciphertext.data);
8631 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8632 : : ciphertext_len, buffer);
8633 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8634 : : ciphertext_len);
8635 : : } else {
8636 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8637 : 1 : tdata->plaintext.data);
8638 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8639 : : plaintext_len, buffer);
8640 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8641 : : plaintext_len);
8642 : : }
8643 : : memset(buffer, 0, sizeof(buffer));
8644 : :
8645 : : /* Create the operation */
8646 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8647 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8648 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8649 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8650 : 2 : (tdata->digest_enc.offset == 0 ?
8651 : : plaintext_pad_len
8652 : : : tdata->digest_enc.offset),
8653 : 2 : tdata->validCipherLen.len_bits,
8654 : 2 : tdata->cipher.offset_bits,
8655 : 2 : tdata->validAuthLen.len_bits,
8656 [ + - ]: 2 : tdata->auth.offset_bits,
8657 : : op_mode, 1, verify);
8658 : :
8659 [ + - ]: 2 : if (retval < 0)
8660 : : return retval;
8661 : :
8662 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8663 : :
8664 : : /* Check if the op failed because the device doesn't */
8665 : : /* support this particular combination of algorithms */
8666 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8667 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8668 : : printf("Device doesn't support this mixed combination. "
8669 : : "Test Skipped.\n");
8670 : 0 : return TEST_SKIPPED;
8671 : : }
8672 : 2 : ut_params->op = op;
8673 : :
8674 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8675 : :
8676 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8677 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8678 : :
8679 [ + + ]: 2 : if (verify) {
8680 [ + - ]: 1 : if (ut_params->obuf)
8681 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8682 : : plaintext_len, buffer);
8683 : : else
8684 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8685 : : plaintext_len, buffer);
8686 : :
8687 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8688 : 1 : (tdata->plaintext.len_bits >> 3) -
8689 : 1 : tdata->digest_enc.len);
8690 : 1 : debug_hexdump(stdout, "plaintext expected:",
8691 : 1 : tdata->plaintext.data,
8692 : 1 : (tdata->plaintext.len_bits >> 3) -
8693 : 1 : tdata->digest_enc.len);
8694 : : } else {
8695 [ + - ]: 1 : if (ut_params->obuf)
8696 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8697 : : ciphertext_len, buffer);
8698 : : else
8699 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8700 : : ciphertext_len, buffer);
8701 : :
8702 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8703 : : ciphertext_len);
8704 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8705 : 1 : tdata->ciphertext.data,
8706 : 1 : tdata->ciphertext.len_bits >> 3);
8707 : :
8708 [ + - ]: 1 : if (ut_params->obuf)
8709 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8710 : 1 : (tdata->digest_enc.offset == 0 ?
8711 : : plaintext_pad_len :
8712 : : tdata->digest_enc.offset),
8713 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8714 : : else
8715 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8716 : 0 : (tdata->digest_enc.offset == 0 ?
8717 : : plaintext_pad_len :
8718 : : tdata->digest_enc.offset),
8719 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8720 : :
8721 : 1 : debug_hexdump(stdout, "digest:", digest,
8722 : 1 : tdata->digest_enc.len);
8723 : 1 : debug_hexdump(stdout, "digest expected:",
8724 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8725 : : }
8726 : :
8727 [ + + ]: 2 : if (!verify) {
8728 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8729 : : digest,
8730 : : tdata->digest_enc.data,
8731 : : tdata->digest_enc.len,
8732 : : "Generated auth tag not as expected");
8733 : : }
8734 : :
8735 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8736 [ + + ]: 2 : if (verify) {
8737 [ - + + - : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- + ]
8738 : : plaintext,
8739 : : tdata->plaintext.data,
8740 : : tdata->plaintext.len_bits >> 3,
8741 : : "Plaintext data not as expected");
8742 : : } else {
8743 [ - + - + : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- - ]
8744 : : ciphertext,
8745 : : tdata->ciphertext.data,
8746 : : tdata->validDataLen.len_bits,
8747 : : "Ciphertext data not as expected");
8748 : : }
8749 : : }
8750 : :
8751 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8752 : : "crypto op processing failed");
8753 : :
8754 : : return 0;
8755 : : }
8756 : :
8757 : : /** AUTH AES CMAC + CIPHER AES CTR */
8758 : :
8759 : : static int
8760 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8761 : : {
8762 : 1 : return test_mixed_auth_cipher(
8763 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8764 : : }
8765 : :
8766 : : static int
8767 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8768 : : {
8769 : 1 : return test_mixed_auth_cipher(
8770 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8771 : : }
8772 : :
8773 : : static int
8774 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8775 : : {
8776 : 1 : return test_mixed_auth_cipher_sgl(
8777 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8778 : : }
8779 : :
8780 : : static int
8781 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8782 : : {
8783 : 1 : return test_mixed_auth_cipher_sgl(
8784 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8785 : : }
8786 : :
8787 : : static int
8788 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8789 : : {
8790 : 1 : return test_mixed_auth_cipher(
8791 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8792 : : }
8793 : :
8794 : : static int
8795 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8796 : : {
8797 : 1 : return test_mixed_auth_cipher(
8798 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8799 : : }
8800 : :
8801 : : static int
8802 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8803 : : {
8804 : 1 : return test_mixed_auth_cipher(
8805 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8806 : : }
8807 : :
8808 : : static int
8809 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8810 : : {
8811 : 1 : return test_mixed_auth_cipher(
8812 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8813 : : }
8814 : :
8815 : : static int
8816 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8817 : : {
8818 : 1 : return test_mixed_auth_cipher(
8819 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8820 : : }
8821 : :
8822 : : static int
8823 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8824 : : {
8825 : 1 : return test_mixed_auth_cipher_sgl(
8826 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8827 : : }
8828 : :
8829 : : static int
8830 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8831 : : {
8832 : 1 : return test_mixed_auth_cipher_sgl(
8833 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8834 : : }
8835 : :
8836 : : static int
8837 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8838 : : {
8839 : 1 : return test_mixed_auth_cipher(
8840 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8841 : : }
8842 : :
8843 : : /** MIXED AUTH + CIPHER */
8844 : :
8845 : : static int
8846 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8847 : : {
8848 : 1 : return test_mixed_auth_cipher(
8849 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8850 : : }
8851 : :
8852 : : static int
8853 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8854 : : {
8855 : 1 : return test_mixed_auth_cipher(
8856 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8857 : : }
8858 : :
8859 : : static int
8860 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8861 : : {
8862 : 1 : return test_mixed_auth_cipher(
8863 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8864 : : }
8865 : :
8866 : : static int
8867 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8868 : : {
8869 : 1 : return test_mixed_auth_cipher(
8870 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8871 : : }
8872 : :
8873 : :
8874 : : static int
8875 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8876 : : {
8877 : 1 : return test_mixed_auth_cipher(
8878 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8879 : : }
8880 : :
8881 : : static int
8882 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8883 : : {
8884 : 1 : return test_mixed_auth_cipher(
8885 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8886 : : }
8887 : :
8888 : : static int
8889 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8890 : : {
8891 : 1 : return test_mixed_auth_cipher(
8892 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8893 : : }
8894 : :
8895 : : static int
8896 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8897 : : {
8898 : 1 : return test_mixed_auth_cipher(
8899 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8900 : : }
8901 : :
8902 : : static int
8903 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8904 : : {
8905 : 1 : return test_mixed_auth_cipher(
8906 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8907 : : }
8908 : :
8909 : : static int
8910 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8911 : : {
8912 : 1 : return test_mixed_auth_cipher(
8913 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8914 : : }
8915 : :
8916 : : static int
8917 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8918 : : {
8919 : 1 : return test_mixed_auth_cipher(
8920 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8921 : : }
8922 : :
8923 : : static int
8924 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8925 : : {
8926 : 1 : return test_mixed_auth_cipher(
8927 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8928 : : }
8929 : :
8930 : : static int
8931 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8932 : : {
8933 : 1 : return test_mixed_auth_cipher(
8934 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8935 : : }
8936 : :
8937 : : static int
8938 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8939 : : {
8940 : 1 : return test_mixed_auth_cipher(
8941 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8942 : : }
8943 : :
8944 : : static int
8945 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8946 : : {
8947 : 1 : return test_mixed_auth_cipher_sgl(
8948 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8949 : : }
8950 : :
8951 : : static int
8952 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8953 : : {
8954 : 1 : return test_mixed_auth_cipher(
8955 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8956 : : }
8957 : :
8958 : : static int
8959 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8960 : : {
8961 : 1 : return test_mixed_auth_cipher_sgl(
8962 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8963 : : }
8964 : :
8965 : : static int
8966 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8967 : : {
8968 : 1 : return test_mixed_auth_cipher(
8969 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8970 : : }
8971 : :
8972 : : static int
8973 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8974 : : {
8975 : 1 : return test_mixed_auth_cipher(
8976 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8977 : : }
8978 : :
8979 : : static int
8980 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8981 : : {
8982 : 1 : return test_mixed_auth_cipher(
8983 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8984 : : }
8985 : :
8986 : : static int
8987 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8988 : : {
8989 : 1 : return test_mixed_auth_cipher(
8990 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8991 : : }
8992 : :
8993 : : static int
8994 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8995 : : {
8996 : 1 : return test_mixed_auth_cipher(
8997 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8998 : : }
8999 : :
9000 : : static int
9001 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
9002 : : {
9003 : 1 : return test_mixed_auth_cipher(
9004 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9005 : : }
9006 : :
9007 : : static int
9008 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
9009 : : {
9010 : 1 : return test_mixed_auth_cipher(
9011 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9012 : : }
9013 : : static int
9014 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9015 : : {
9016 : 1 : return test_mixed_auth_cipher(
9017 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
9018 : : }
9019 : :
9020 : : static int
9021 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9022 : : {
9023 : 1 : return test_mixed_auth_cipher(
9024 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
9025 : : }
9026 : :
9027 : : static int
9028 : 1 : test_auth_null_cipher_snow_test_case_1(void)
9029 : : {
9030 : 1 : return test_mixed_auth_cipher(
9031 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
9032 : : }
9033 : :
9034 : : static int
9035 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
9036 : : {
9037 : 1 : return test_mixed_auth_cipher(
9038 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
9039 : : }
9040 : :
9041 : : static int
9042 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
9043 : : {
9044 : 1 : return test_mixed_auth_cipher(
9045 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9046 : : }
9047 : :
9048 : : static int
9049 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
9050 : : {
9051 : 1 : return test_mixed_auth_cipher(
9052 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9053 : : }
9054 : :
9055 : : static int
9056 : 1 : test_auth_snow_cipher_null_test_case_1(void)
9057 : : {
9058 : 1 : return test_mixed_auth_cipher(
9059 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9060 : : }
9061 : :
9062 : : static int
9063 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
9064 : : {
9065 : 1 : return test_mixed_auth_cipher(
9066 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9067 : : }
9068 : :
9069 : : static int
9070 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
9071 : : {
9072 : 1 : return test_mixed_auth_cipher(
9073 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9074 : : }
9075 : :
9076 : : static int
9077 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
9078 : : {
9079 : 1 : return test_mixed_auth_cipher(
9080 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9081 : : }
9082 : :
9083 : : static int
9084 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
9085 : : {
9086 : 1 : return test_mixed_auth_cipher(
9087 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
9088 : : }
9089 : :
9090 : : static int
9091 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
9092 : : {
9093 : 1 : return test_mixed_auth_cipher(
9094 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
9095 : : }
9096 : :
9097 : : static int
9098 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
9099 : : {
9100 : 1 : return test_mixed_auth_cipher(
9101 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9102 : : }
9103 : :
9104 : : static int
9105 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
9106 : : {
9107 : 1 : return test_mixed_auth_cipher(
9108 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9109 : : }
9110 : :
9111 : : /* ***** AEAD algorithm Tests ***** */
9112 : :
9113 : : static int
9114 : 85 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
9115 : : enum rte_crypto_aead_operation op,
9116 : : const uint8_t *key, const uint8_t key_len,
9117 : : const uint16_t aad_len, const uint8_t auth_len,
9118 : : uint8_t iv_len)
9119 : : {
9120 : 85 : uint8_t *aead_key = alloca(key_len);
9121 : :
9122 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9123 : : struct crypto_unittest_params *ut_params = &unittest_params;
9124 : :
9125 : : memcpy(aead_key, key, key_len);
9126 : :
9127 : : /* Setup AEAD Parameters */
9128 : 85 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9129 : 85 : ut_params->aead_xform.next = NULL;
9130 : 85 : ut_params->aead_xform.aead.algo = algo;
9131 : 85 : ut_params->aead_xform.aead.op = op;
9132 : 85 : ut_params->aead_xform.aead.key.data = aead_key;
9133 : 85 : ut_params->aead_xform.aead.key.length = key_len;
9134 : 85 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9135 : 85 : ut_params->aead_xform.aead.iv.length = iv_len;
9136 : 85 : ut_params->aead_xform.aead.digest_length = auth_len;
9137 : 85 : ut_params->aead_xform.aead.aad_length = aad_len;
9138 : :
9139 : 85 : debug_hexdump(stdout, "key:", key, key_len);
9140 : :
9141 : : /* Create Crypto session*/
9142 : 85 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9143 : : &ut_params->aead_xform, ts_params->session_mpool);
9144 [ - + - - ]: 85 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9145 : : return TEST_SKIPPED;
9146 [ - + ]: 85 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9147 : : return 0;
9148 : : }
9149 : :
9150 : : static int
9151 : 2 : create_aead_xform(struct rte_crypto_op *op,
9152 : : enum rte_crypto_aead_algorithm algo,
9153 : : enum rte_crypto_aead_operation aead_op,
9154 : : uint8_t *key, const uint8_t key_len,
9155 : : const uint8_t aad_len, const uint8_t auth_len,
9156 : : uint8_t iv_len)
9157 : : {
9158 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9159 : : "failed to allocate space for crypto transform");
9160 : :
9161 : : struct rte_crypto_sym_op *sym_op = op->sym;
9162 : :
9163 : : /* Setup AEAD Parameters */
9164 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9165 : 2 : sym_op->xform->next = NULL;
9166 : 2 : sym_op->xform->aead.algo = algo;
9167 : 2 : sym_op->xform->aead.op = aead_op;
9168 : 2 : sym_op->xform->aead.key.data = key;
9169 : 2 : sym_op->xform->aead.key.length = key_len;
9170 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
9171 : 2 : sym_op->xform->aead.iv.length = iv_len;
9172 : 2 : sym_op->xform->aead.digest_length = auth_len;
9173 : 2 : sym_op->xform->aead.aad_length = aad_len;
9174 : :
9175 : 2 : debug_hexdump(stdout, "key:", key, key_len);
9176 : :
9177 : : return 0;
9178 : : }
9179 : :
9180 : : static int
9181 : 86 : create_aead_operation(enum rte_crypto_aead_operation op,
9182 : : const struct aead_test_data *tdata)
9183 : : {
9184 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9185 : : struct crypto_unittest_params *ut_params = &unittest_params;
9186 : :
9187 : : uint8_t *plaintext, *ciphertext;
9188 : : unsigned int aad_pad_len, plaintext_pad_len;
9189 : :
9190 : : /* Generate Crypto op data structure */
9191 : 86 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9192 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9193 [ - + ]: 86 : TEST_ASSERT_NOT_NULL(ut_params->op,
9194 : : "Failed to allocate symmetric crypto operation struct");
9195 : :
9196 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9197 : :
9198 : : /* Append aad data */
9199 [ + + ]: 86 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9200 : 18 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9201 : 18 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9202 : : aad_pad_len);
9203 [ - + ]: 18 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9204 : : "no room to append aad");
9205 : :
9206 : 18 : sym_op->aead.aad.phys_addr =
9207 : 18 : rte_pktmbuf_iova(ut_params->ibuf);
9208 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9209 : 18 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9210 : 18 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9211 : 18 : tdata->aad.len);
9212 : :
9213 : : /* Append IV at the end of the crypto operation*/
9214 : 18 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9215 : : uint8_t *, IV_OFFSET);
9216 : :
9217 : : /* Copy IV 1 byte after the IV pointer, according to the API */
9218 [ - + ]: 18 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9219 : 18 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
9220 : 18 : tdata->iv.len);
9221 : : } else {
9222 : 68 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9223 : 68 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9224 : : aad_pad_len);
9225 [ - + ]: 68 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9226 : : "no room to append aad");
9227 : :
9228 : 68 : sym_op->aead.aad.phys_addr =
9229 : 68 : rte_pktmbuf_iova(ut_params->ibuf);
9230 : 68 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9231 : 68 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9232 : 68 : tdata->aad.len);
9233 : :
9234 : : /* Append IV at the end of the crypto operation*/
9235 : 68 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9236 : : uint8_t *, IV_OFFSET);
9237 : :
9238 [ - + ]: 68 : if (tdata->iv.len == 0) {
9239 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9240 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
9241 : : AES_GCM_J0_LENGTH);
9242 : : } else {
9243 [ - + ]: 68 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9244 : 68 : debug_hexdump(stdout, "iv:", iv_ptr,
9245 : 68 : tdata->iv.len);
9246 : : }
9247 : : }
9248 : :
9249 : : /* Append plaintext/ciphertext */
9250 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9251 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9252 : 43 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9253 : : plaintext_pad_len);
9254 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9255 : :
9256 : 43 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9257 : 43 : debug_hexdump(stdout, "plaintext:", plaintext,
9258 : 43 : tdata->plaintext.len);
9259 : :
9260 [ + + ]: 43 : if (ut_params->obuf) {
9261 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
9262 : : ut_params->obuf,
9263 : 1 : plaintext_pad_len + aad_pad_len);
9264 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
9265 : : "no room to append ciphertext");
9266 : :
9267 : 1 : memset(ciphertext + aad_pad_len, 0,
9268 : 1 : tdata->ciphertext.len);
9269 : : }
9270 : : } else {
9271 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9272 : 43 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9273 : : plaintext_pad_len);
9274 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(ciphertext,
9275 : : "no room to append ciphertext");
9276 : :
9277 : 43 : memcpy(ciphertext, tdata->ciphertext.data,
9278 : 43 : tdata->ciphertext.len);
9279 : 43 : debug_hexdump(stdout, "ciphertext:", ciphertext,
9280 : 43 : tdata->ciphertext.len);
9281 : :
9282 [ + + ]: 43 : if (ut_params->obuf) {
9283 : : plaintext = (uint8_t *)rte_pktmbuf_append(
9284 : : ut_params->obuf,
9285 : 1 : plaintext_pad_len + aad_pad_len);
9286 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
9287 : : "no room to append plaintext");
9288 : :
9289 : 1 : memset(plaintext + aad_pad_len, 0,
9290 : 1 : tdata->plaintext.len);
9291 : : }
9292 : : }
9293 : :
9294 : : /* Append digest data */
9295 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9296 : 42 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9297 : 43 : ut_params->obuf ? ut_params->obuf :
9298 : : ut_params->ibuf,
9299 [ + + ]: 43 : tdata->auth_tag.len);
9300 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9301 : : "no room to append digest");
9302 [ + + ]: 43 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9303 [ + + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9304 : : ut_params->obuf ? ut_params->obuf :
9305 : : ut_params->ibuf,
9306 : : plaintext_pad_len +
9307 : : aad_pad_len);
9308 : : } else {
9309 : 86 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9310 : 43 : ut_params->ibuf, tdata->auth_tag.len);
9311 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9312 : : "no room to append digest");
9313 [ - + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9314 : : ut_params->ibuf,
9315 : : plaintext_pad_len + aad_pad_len);
9316 : :
9317 : 43 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9318 [ - + ]: 43 : tdata->auth_tag.len);
9319 : 43 : debug_hexdump(stdout, "digest:",
9320 : 43 : sym_op->aead.digest.data,
9321 : 43 : tdata->auth_tag.len);
9322 : : }
9323 : :
9324 : 86 : sym_op->aead.data.length = tdata->plaintext.len;
9325 : 86 : sym_op->aead.data.offset = aad_pad_len;
9326 : :
9327 : 86 : return 0;
9328 : : }
9329 : :
9330 : : static int
9331 : 42 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9332 : : {
9333 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9334 : : struct crypto_unittest_params *ut_params = &unittest_params;
9335 : :
9336 : : int retval;
9337 : : uint8_t *ciphertext, *auth_tag;
9338 : : uint16_t plaintext_pad_len;
9339 : : uint32_t i;
9340 : : struct rte_cryptodev_info dev_info;
9341 : :
9342 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9343 : 42 : uint64_t feat_flags = dev_info.feature_flags;
9344 : :
9345 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9346 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9347 : : printf("Device doesn't support RAW data-path APIs.\n");
9348 : 0 : return TEST_SKIPPED;
9349 : : }
9350 : :
9351 : : /* Verify the capabilities */
9352 : : struct rte_cryptodev_sym_capability_idx cap_idx;
9353 : : const struct rte_cryptodev_symmetric_capability *capability;
9354 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9355 : 42 : cap_idx.algo.aead = tdata->algo;
9356 : 42 : capability = rte_cryptodev_sym_capability_get(
9357 : 42 : ts_params->valid_devs[0], &cap_idx);
9358 [ + - ]: 42 : if (capability == NULL)
9359 : : return TEST_SKIPPED;
9360 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
9361 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
9362 : 42 : tdata->aad.len, tdata->iv.len))
9363 : : return TEST_SKIPPED;
9364 : :
9365 : : /* Create AEAD session */
9366 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
9367 : 41 : tdata->algo,
9368 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
9369 : 41 : tdata->key.data, tdata->key.len,
9370 : 41 : tdata->aad.len, tdata->auth_tag.len,
9371 : 41 : tdata->iv.len);
9372 [ + - ]: 41 : if (retval != TEST_SUCCESS)
9373 : : return retval;
9374 : :
9375 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
9376 [ - + ]: 2 : if (use_ext_mbuf) {
9377 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9378 : : AEAD_TEXT_MAX_LENGTH,
9379 : : 1 /* nb_segs */,
9380 : : NULL);
9381 : : } else {
9382 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9383 : : }
9384 : : /* Populate full size of add data */
9385 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9386 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9387 : : } else {
9388 [ + + ]: 39 : if (use_ext_mbuf) {
9389 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9390 : : AEAD_TEXT_MAX_LENGTH,
9391 : : 1 /* nb_segs */,
9392 : : NULL);
9393 : : } else {
9394 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9395 : : }
9396 : : }
9397 : :
9398 : : /* clear mbuf payload */
9399 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9400 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
9401 : :
9402 : : /* Create AEAD operation */
9403 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9404 [ + - ]: 41 : if (retval < 0)
9405 : : return retval;
9406 : :
9407 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9408 : :
9409 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
9410 : :
9411 : : /* Process crypto operation */
9412 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9413 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9414 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9415 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9416 : : 0);
9417 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9418 : : return retval;
9419 : : } else
9420 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(
9421 : : process_crypto_request(ts_params->valid_devs[0],
9422 : : ut_params->op), "failed to process sym crypto op");
9423 : :
9424 [ - + ]: 41 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9425 : : "crypto op processing failed");
9426 : :
9427 : 41 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9428 : :
9429 [ - + ]: 41 : if (ut_params->op->sym->m_dst) {
9430 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9431 : : uint8_t *);
9432 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9433 : : uint8_t *, plaintext_pad_len);
9434 : : } else {
9435 : 41 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9436 : : uint8_t *,
9437 : : ut_params->op->sym->cipher.data.offset);
9438 : 41 : auth_tag = ciphertext + plaintext_pad_len;
9439 : : }
9440 : :
9441 : 41 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9442 : 41 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9443 : :
9444 : : /* Validate obuf */
9445 [ + + ]: 44 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9446 : : ciphertext,
9447 : : tdata->ciphertext.data,
9448 : : tdata->ciphertext.len,
9449 : : "Ciphertext data not as expected");
9450 : :
9451 [ + + ]: 41 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9452 : : auth_tag,
9453 : : tdata->auth_tag.data,
9454 : : tdata->auth_tag.len,
9455 : : "Generated auth tag not as expected");
9456 : :
9457 : : return 0;
9458 : :
9459 : : }
9460 : :
9461 : : static int
9462 : : test_authenticated_encryption(const struct aead_test_data *tdata)
9463 : : {
9464 : 41 : return test_authenticated_encryption_helper(tdata, false);
9465 : : }
9466 : :
9467 : : #ifdef RTE_LIB_SECURITY
9468 : : static int
9469 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9470 : : enum rte_security_session_protocol proto)
9471 : : {
9472 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9473 : :
9474 : : const struct rte_security_capability *capabilities;
9475 : : const struct rte_security_capability *capability;
9476 : : uint16_t i = 0;
9477 : :
9478 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9479 : :
9480 : :
9481 : 0 : capabilities = rte_security_capabilities_get(ctx);
9482 : :
9483 [ # # ]: 0 : if (capabilities == NULL)
9484 : : return -ENOTSUP;
9485 : :
9486 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9487 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9488 [ # # ]: 0 : if (capability->action == action &&
9489 [ # # ]: 0 : capability->protocol == proto)
9490 : : return 0;
9491 : : }
9492 : :
9493 : : return -ENOTSUP;
9494 : : }
9495 : :
9496 : : /* Basic algorithm run function for async inplace mode.
9497 : : * Creates a session from input parameters and runs one operation
9498 : : * on input_vec. Checks the output of the crypto operation against
9499 : : * output_vec.
9500 : : */
9501 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9502 : : enum rte_crypto_auth_operation opa,
9503 : : const uint8_t *input_vec, unsigned int input_vec_len,
9504 : : const uint8_t *output_vec,
9505 : : unsigned int output_vec_len,
9506 : : enum rte_crypto_cipher_algorithm cipher_alg,
9507 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9508 : : enum rte_crypto_auth_algorithm auth_alg,
9509 : : const uint8_t *auth_key, uint32_t auth_key_len,
9510 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9511 : : uint8_t packet_direction, uint8_t sn_size,
9512 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9513 : : {
9514 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9515 : : struct crypto_unittest_params *ut_params = &unittest_params;
9516 : : uint8_t *plaintext;
9517 : : int ret = TEST_SUCCESS;
9518 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9519 : : struct rte_cryptodev_info dev_info;
9520 : : uint64_t feat_flags;
9521 : :
9522 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9523 : 0 : feat_flags = dev_info.feature_flags;
9524 : :
9525 : : /* Verify the capabilities */
9526 : : struct rte_security_capability_idx sec_cap_idx;
9527 : :
9528 : 0 : sec_cap_idx.action = ut_params->type;
9529 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9530 : 0 : sec_cap_idx.pdcp.domain = domain;
9531 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9532 : : return TEST_SKIPPED;
9533 : :
9534 : : /* Generate test mbuf data */
9535 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9536 : :
9537 : : /* clear mbuf payload */
9538 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9539 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9540 : :
9541 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9542 : : input_vec_len);
9543 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9544 : :
9545 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9546 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9547 : : printf("Device does not support RAW data-path APIs.\n");
9548 : 0 : return TEST_SKIPPED;
9549 : : }
9550 : : /* Out of place support */
9551 [ # # ]: 0 : if (oop) {
9552 : : /*
9553 : : * For out-of-place we need to alloc another mbuf
9554 : : */
9555 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9556 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9557 : : }
9558 : :
9559 : : /* Setup Cipher Parameters */
9560 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9561 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9562 : 0 : ut_params->cipher_xform.cipher.op = opc;
9563 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9564 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9565 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9566 : : packet_direction ? 4 : 0;
9567 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9568 : :
9569 : : /* Setup HMAC Parameters if ICV header is required */
9570 [ # # ]: 0 : if (auth_alg != 0) {
9571 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9572 : 0 : ut_params->auth_xform.next = NULL;
9573 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9574 : 0 : ut_params->auth_xform.auth.op = opa;
9575 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9576 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9577 : :
9578 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9579 : : } else {
9580 : 0 : ut_params->cipher_xform.next = NULL;
9581 : : }
9582 : :
9583 : 0 : struct rte_security_session_conf sess_conf = {
9584 : 0 : .action_type = ut_params->type,
9585 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9586 : : {.pdcp = {
9587 : : .bearer = bearer,
9588 : : .domain = domain,
9589 : : .pkt_dir = packet_direction,
9590 : : .sn_size = sn_size,
9591 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9592 : : /**
9593 : : * hfn can be set as pdcp_test_hfn[i]
9594 : : * if hfn_ovrd is not set. Here, PDCP
9595 : : * packet direction is just used to
9596 : : * run half of the cases with session
9597 : : * HFN and other half with per packet
9598 : : * HFN.
9599 : : */
9600 : : .hfn_threshold = hfn_threshold,
9601 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9602 : : .sdap_enabled = sdap,
9603 : : } },
9604 : : .crypto_xform = &ut_params->cipher_xform
9605 : : };
9606 : :
9607 : : /* Create security session */
9608 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9609 : : &sess_conf, ts_params->session_mpool);
9610 : :
9611 [ # # ]: 0 : if (!ut_params->sec_session) {
9612 : : printf("TestCase %s()-%d line %d failed %s: ",
9613 : : __func__, i, __LINE__, "Failed to allocate session");
9614 : : ret = TEST_FAILED;
9615 : 0 : goto on_err;
9616 : : }
9617 : :
9618 : : /* Generate crypto op data structure */
9619 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9620 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9621 [ # # ]: 0 : if (!ut_params->op) {
9622 : : printf("TestCase %s()-%d line %d failed %s: ",
9623 : : __func__, i, __LINE__,
9624 : : "Failed to allocate symmetric crypto operation struct");
9625 : : ret = TEST_FAILED;
9626 : 0 : goto on_err;
9627 : : }
9628 : :
9629 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9630 : : uint32_t *, IV_OFFSET);
9631 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9632 : :
9633 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9634 : :
9635 : : /* set crypto operation source mbuf */
9636 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9637 [ # # ]: 0 : if (oop)
9638 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9639 : :
9640 : : /* Process crypto operation */
9641 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9642 : : /* filling lengths */
9643 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9644 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9645 : :
9646 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9647 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9648 : : return ret;
9649 : : } else {
9650 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9651 : : }
9652 [ # # ]: 0 : if (ut_params->op == NULL) {
9653 : : printf("TestCase %s()-%d line %d failed %s: ",
9654 : : __func__, i, __LINE__,
9655 : : "failed to process sym crypto op");
9656 : : ret = TEST_FAILED;
9657 : 0 : goto on_err;
9658 : : }
9659 : :
9660 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9661 : : printf("TestCase %s()-%d line %d failed %s: ",
9662 : : __func__, i, __LINE__, "crypto op processing failed");
9663 : : ret = TEST_FAILED;
9664 : 0 : goto on_err;
9665 : : }
9666 : :
9667 : : /* Validate obuf */
9668 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9669 : : uint8_t *);
9670 [ # # ]: 0 : if (oop) {
9671 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9672 : : uint8_t *);
9673 : : }
9674 : :
9675 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9676 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9677 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9678 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9679 : : ret = TEST_FAILED;
9680 : 0 : goto on_err;
9681 : : }
9682 : :
9683 : 0 : on_err:
9684 : 0 : rte_crypto_op_free(ut_params->op);
9685 : 0 : ut_params->op = NULL;
9686 : :
9687 [ # # ]: 0 : if (ut_params->sec_session)
9688 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9689 : 0 : ut_params->sec_session = NULL;
9690 : :
9691 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9692 : 0 : ut_params->ibuf = NULL;
9693 [ # # ]: 0 : if (oop) {
9694 : 0 : rte_pktmbuf_free(ut_params->obuf);
9695 : 0 : ut_params->obuf = NULL;
9696 : : }
9697 : :
9698 : : return ret;
9699 : : }
9700 : :
9701 : : static int
9702 : 0 : test_pdcp_proto_SGL(int i, int oop,
9703 : : enum rte_crypto_cipher_operation opc,
9704 : : enum rte_crypto_auth_operation opa,
9705 : : uint8_t *input_vec,
9706 : : unsigned int input_vec_len,
9707 : : uint8_t *output_vec,
9708 : : unsigned int output_vec_len,
9709 : : uint32_t fragsz,
9710 : : uint32_t fragsz_oop)
9711 : : {
9712 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9713 : : struct crypto_unittest_params *ut_params = &unittest_params;
9714 : : uint8_t *plaintext;
9715 : : struct rte_mbuf *buf, *buf_oop = NULL;
9716 : : int ret = TEST_SUCCESS;
9717 : : int to_trn = 0;
9718 : : int to_trn_tbl[16];
9719 : : int segs = 1;
9720 : : unsigned int trn_data = 0;
9721 : : struct rte_cryptodev_info dev_info;
9722 : : uint64_t feat_flags;
9723 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9724 : : struct rte_mbuf *temp_mbuf;
9725 : :
9726 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9727 : 0 : feat_flags = dev_info.feature_flags;
9728 : :
9729 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9730 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9731 : : printf("Device does not support RAW data-path APIs.\n");
9732 : 0 : return -ENOTSUP;
9733 : : }
9734 : : /* Verify the capabilities */
9735 : : struct rte_security_capability_idx sec_cap_idx;
9736 : :
9737 : 0 : sec_cap_idx.action = ut_params->type;
9738 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9739 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9740 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9741 : : return TEST_SKIPPED;
9742 : :
9743 : : if (fragsz > input_vec_len)
9744 : : fragsz = input_vec_len;
9745 : :
9746 : 0 : uint16_t plaintext_len = fragsz;
9747 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9748 : :
9749 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9750 : 0 : frag_size_oop = output_vec_len;
9751 : :
9752 : : int ecx = 0;
9753 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9754 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9755 : : return 1;
9756 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9757 : : return 1;
9758 : :
9759 : : /* Out of place support */
9760 [ # # ]: 0 : if (oop) {
9761 : : /*
9762 : : * For out-of-place we need to alloc another mbuf
9763 : : */
9764 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9765 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9766 : 0 : buf_oop = ut_params->obuf;
9767 : : }
9768 : :
9769 : : /* Generate test mbuf data */
9770 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9771 : :
9772 : : /* clear mbuf payload */
9773 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9774 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9775 : :
9776 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9777 : : plaintext_len);
9778 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9779 : : trn_data += plaintext_len;
9780 : :
9781 : 0 : buf = ut_params->ibuf;
9782 : :
9783 : : /*
9784 : : * Loop until no more fragments
9785 : : */
9786 : :
9787 [ # # ]: 0 : while (trn_data < input_vec_len) {
9788 : 0 : ++segs;
9789 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9790 : 0 : (input_vec_len - trn_data) : fragsz;
9791 : :
9792 : 0 : to_trn_tbl[ecx++] = to_trn;
9793 : :
9794 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9795 : : buf = buf->next;
9796 : :
9797 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9798 : : rte_pktmbuf_tailroom(buf));
9799 : :
9800 : : /* OOP */
9801 [ # # ]: 0 : if (oop && !fragsz_oop) {
9802 [ # # ]: 0 : buf_oop->next =
9803 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9804 : : buf_oop = buf_oop->next;
9805 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9806 : : 0, rte_pktmbuf_tailroom(buf_oop));
9807 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "Output buffer not initialized");
9808 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
9809 : : }
9810 : :
9811 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9812 : : to_trn);
9813 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
9814 : :
9815 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9816 : 0 : trn_data += to_trn;
9817 : : }
9818 : :
9819 : 0 : ut_params->ibuf->nb_segs = segs;
9820 : :
9821 : : segs = 1;
9822 [ # # ]: 0 : if (fragsz_oop && oop) {
9823 : : to_trn = 0;
9824 : : ecx = 0;
9825 : :
9826 : 0 : trn_data = frag_size_oop;
9827 [ # # ]: 0 : while (trn_data < output_vec_len) {
9828 : 0 : ++segs;
9829 : 0 : to_trn =
9830 : 0 : (output_vec_len - trn_data <
9831 : : frag_size_oop) ?
9832 : 0 : (output_vec_len - trn_data) :
9833 : : frag_size_oop;
9834 : :
9835 : 0 : to_trn_tbl[ecx++] = to_trn;
9836 : :
9837 : 0 : buf_oop->next =
9838 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9839 : : buf_oop = buf_oop->next;
9840 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9841 : : 0, rte_pktmbuf_tailroom(buf_oop));
9842 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
9843 : :
9844 : 0 : trn_data += to_trn;
9845 : : }
9846 : 0 : ut_params->obuf->nb_segs = segs;
9847 : : }
9848 : :
9849 : : /* Setup Cipher Parameters */
9850 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9851 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9852 : 0 : ut_params->cipher_xform.cipher.op = opc;
9853 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9854 : 0 : ut_params->cipher_xform.cipher.key.length =
9855 : 0 : pdcp_test_params[i].cipher_key_len;
9856 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9857 : :
9858 : : /* Setup HMAC Parameters if ICV header is required */
9859 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9860 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9861 : 0 : ut_params->auth_xform.next = NULL;
9862 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9863 : 0 : ut_params->auth_xform.auth.op = opa;
9864 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9865 : 0 : ut_params->auth_xform.auth.key.length =
9866 : 0 : pdcp_test_params[i].auth_key_len;
9867 : :
9868 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9869 : : } else {
9870 : 0 : ut_params->cipher_xform.next = NULL;
9871 : : }
9872 : :
9873 : 0 : struct rte_security_session_conf sess_conf = {
9874 : 0 : .action_type = ut_params->type,
9875 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9876 : : {.pdcp = {
9877 : 0 : .bearer = pdcp_test_bearer[i],
9878 : 0 : .domain = pdcp_test_params[i].domain,
9879 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9880 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9881 : 0 : .hfn = pdcp_test_hfn[i],
9882 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9883 : : .hfn_ovrd = 0,
9884 : : } },
9885 : : .crypto_xform = &ut_params->cipher_xform
9886 : : };
9887 : :
9888 : : /* Create security session */
9889 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9890 : : &sess_conf, ts_params->session_mpool);
9891 : :
9892 [ # # ]: 0 : if (!ut_params->sec_session) {
9893 : : printf("TestCase %s()-%d line %d failed %s: ",
9894 : : __func__, i, __LINE__, "Failed to allocate session");
9895 : : ret = TEST_FAILED;
9896 : 0 : goto on_err;
9897 : : }
9898 : :
9899 : : /* Generate crypto op data structure */
9900 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9901 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9902 [ # # ]: 0 : if (!ut_params->op) {
9903 : : printf("TestCase %s()-%d line %d failed %s: ",
9904 : : __func__, i, __LINE__,
9905 : : "Failed to allocate symmetric crypto operation struct");
9906 : : ret = TEST_FAILED;
9907 : 0 : goto on_err;
9908 : : }
9909 : :
9910 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9911 : :
9912 : : /* set crypto operation source mbuf */
9913 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9914 [ # # ]: 0 : if (oop)
9915 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9916 : :
9917 : : /* Process crypto operation */
9918 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9919 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9920 : : /* filling lengths */
9921 [ # # ]: 0 : while (temp_mbuf) {
9922 : 0 : ut_params->op->sym->cipher.data.length
9923 : 0 : += temp_mbuf->pkt_len;
9924 : 0 : ut_params->op->sym->auth.data.length
9925 : 0 : += temp_mbuf->pkt_len;
9926 : 0 : temp_mbuf = temp_mbuf->next;
9927 : : }
9928 : :
9929 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9930 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9931 : : return ret;
9932 : : } else {
9933 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9934 : : ut_params->op);
9935 : : }
9936 [ # # ]: 0 : if (ut_params->op == NULL) {
9937 : : printf("TestCase %s()-%d line %d failed %s: ",
9938 : : __func__, i, __LINE__,
9939 : : "failed to process sym crypto op");
9940 : : ret = TEST_FAILED;
9941 : 0 : goto on_err;
9942 : : }
9943 : :
9944 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9945 : : printf("TestCase %s()-%d line %d failed %s: ",
9946 : : __func__, i, __LINE__, "crypto op processing failed");
9947 : : ret = TEST_FAILED;
9948 : 0 : goto on_err;
9949 : : }
9950 : :
9951 : : /* Validate obuf */
9952 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9953 : : uint8_t *);
9954 [ # # ]: 0 : if (oop) {
9955 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9956 : : uint8_t *);
9957 : : }
9958 [ # # ]: 0 : if (fragsz_oop)
9959 : 0 : fragsz = frag_size_oop;
9960 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9961 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9962 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9963 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9964 : : ret = TEST_FAILED;
9965 : 0 : goto on_err;
9966 : : }
9967 : :
9968 : 0 : buf = ut_params->op->sym->m_src->next;
9969 [ # # ]: 0 : if (oop)
9970 : 0 : buf = ut_params->op->sym->m_dst->next;
9971 : :
9972 : : unsigned int off = fragsz;
9973 : :
9974 : : ecx = 0;
9975 [ # # ]: 0 : while (buf) {
9976 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9977 : : uint8_t *);
9978 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9979 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9980 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9981 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9982 : : to_trn_tbl[ecx]);
9983 : : ret = TEST_FAILED;
9984 : 0 : goto on_err;
9985 : : }
9986 : 0 : off += to_trn_tbl[ecx++];
9987 : 0 : buf = buf->next;
9988 : : }
9989 : 0 : on_err:
9990 : 0 : rte_crypto_op_free(ut_params->op);
9991 : 0 : ut_params->op = NULL;
9992 : :
9993 [ # # ]: 0 : if (ut_params->sec_session)
9994 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9995 : 0 : ut_params->sec_session = NULL;
9996 : :
9997 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9998 : 0 : ut_params->ibuf = NULL;
9999 [ # # ]: 0 : if (oop) {
10000 : 0 : rte_pktmbuf_free(ut_params->obuf);
10001 : 0 : ut_params->obuf = NULL;
10002 : : }
10003 : :
10004 : : return ret;
10005 : : }
10006 : :
10007 : : int
10008 : 0 : test_pdcp_proto_cplane_encap(int i)
10009 : : {
10010 : 0 : return test_pdcp_proto(
10011 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10012 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10013 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10014 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10015 : 0 : pdcp_test_params[i].cipher_key_len,
10016 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10017 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10018 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10019 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10020 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10021 : : }
10022 : :
10023 : : int
10024 : 0 : test_pdcp_proto_uplane_encap(int i)
10025 : : {
10026 : 0 : return test_pdcp_proto(
10027 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10028 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10029 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10030 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10031 : 0 : pdcp_test_params[i].cipher_key_len,
10032 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10033 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10034 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10035 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10036 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10037 : : }
10038 : :
10039 : : int
10040 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
10041 : : {
10042 : 0 : return test_pdcp_proto(
10043 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10044 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10045 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10046 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10047 : 0 : pdcp_test_params[i].cipher_key_len,
10048 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10049 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10050 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10051 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10052 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10053 : : }
10054 : :
10055 : : int
10056 : 0 : test_pdcp_proto_cplane_decap(int i)
10057 : : {
10058 : 0 : return test_pdcp_proto(
10059 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10060 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10061 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10062 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10063 : 0 : pdcp_test_params[i].cipher_key_len,
10064 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10065 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10066 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10067 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10068 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10069 : : }
10070 : :
10071 : : int
10072 : 0 : test_pdcp_proto_uplane_decap(int i)
10073 : : {
10074 : 0 : return test_pdcp_proto(
10075 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10076 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10077 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10078 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10079 : 0 : pdcp_test_params[i].cipher_key_len,
10080 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10081 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10082 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10083 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10084 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10085 : : }
10086 : :
10087 : : int
10088 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
10089 : : {
10090 : 0 : return test_pdcp_proto(
10091 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10092 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10093 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10094 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10095 : 0 : pdcp_test_params[i].cipher_key_len,
10096 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10097 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10098 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10099 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10100 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10101 : : }
10102 : :
10103 : : static int
10104 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
10105 : : {
10106 : : /* i can be used for running any PDCP case
10107 : : * In this case it is uplane 12-bit AES-SNOW DL encap
10108 : : */
10109 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
10110 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
10111 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10112 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10113 : : pdcp_test_data_in[i],
10114 : : pdcp_test_data_in_len[i],
10115 : : pdcp_test_data_out[i],
10116 : 0 : pdcp_test_data_in_len[i]+4,
10117 : : 32, 0);
10118 : : }
10119 : : static int
10120 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
10121 : : {
10122 : : /* i can be used for running any PDCP case
10123 : : * In this case it is uplane 18-bit NULL-NULL DL encap
10124 : : */
10125 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10126 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10127 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10128 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10129 : : pdcp_test_data_in[i],
10130 : : pdcp_test_data_in_len[i],
10131 : : pdcp_test_data_out[i],
10132 : 0 : pdcp_test_data_in_len[i]+4,
10133 : : 32, 128);
10134 : : }
10135 : : static int
10136 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
10137 : : {
10138 : : /* i can be used for running any PDCP case
10139 : : * In this case it is uplane 18-bit AES DL encap
10140 : : */
10141 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10142 : : + DOWNLINK;
10143 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10144 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10145 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10146 : : pdcp_test_data_in[i],
10147 : : pdcp_test_data_in_len[i],
10148 : : pdcp_test_data_out[i],
10149 : : pdcp_test_data_in_len[i],
10150 : : 32, 40);
10151 : : }
10152 : : static int
10153 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
10154 : : {
10155 : : /* i can be used for running any PDCP case
10156 : : * In this case it is cplane 12-bit AES-ZUC DL encap
10157 : : */
10158 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10159 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10160 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10161 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10162 : : pdcp_test_data_in[i],
10163 : : pdcp_test_data_in_len[i],
10164 : : pdcp_test_data_out[i],
10165 : 0 : pdcp_test_data_in_len[i]+4,
10166 : : 128, 32);
10167 : : }
10168 : :
10169 : : static int
10170 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
10171 : : {
10172 : : int i = 0, size = 0;
10173 : : int err, all_err = TEST_SUCCESS;
10174 : : const struct pdcp_sdap_test *cur_test;
10175 : :
10176 : : size = RTE_DIM(list_pdcp_sdap_tests);
10177 : :
10178 [ # # ]: 0 : for (i = 0; i < size; i++) {
10179 : : cur_test = &list_pdcp_sdap_tests[i];
10180 : 0 : err = test_pdcp_proto(
10181 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10182 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10183 : 0 : cur_test->in_len, cur_test->data_out,
10184 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10185 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
10186 : 0 : cur_test->param.cipher_key_len,
10187 : 0 : cur_test->param.auth_alg,
10188 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10189 : 0 : cur_test->bearer, cur_test->param.domain,
10190 : 0 : cur_test->packet_direction, cur_test->sn_size,
10191 : 0 : cur_test->hfn,
10192 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10193 [ # # ]: 0 : if (err) {
10194 : : printf("\t%d) %s: Encapsulation failed\n",
10195 : 0 : cur_test->test_idx,
10196 : 0 : cur_test->param.name);
10197 : : err = TEST_FAILED;
10198 : : } else {
10199 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10200 : 0 : cur_test->param.name);
10201 : : err = TEST_SUCCESS;
10202 : : }
10203 : 0 : all_err += err;
10204 : : }
10205 : :
10206 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10207 : :
10208 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10209 : : }
10210 : :
10211 : : static int
10212 : 0 : test_PDCP_PROTO_short_mac(void)
10213 : : {
10214 : : int i = 0, size = 0;
10215 : : int err, all_err = TEST_SUCCESS;
10216 : : const struct pdcp_short_mac_test *cur_test;
10217 : :
10218 : : size = RTE_DIM(list_pdcp_smac_tests);
10219 : :
10220 [ # # ]: 0 : for (i = 0; i < size; i++) {
10221 : : cur_test = &list_pdcp_smac_tests[i];
10222 : 0 : err = test_pdcp_proto(
10223 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10224 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10225 : 0 : cur_test->in_len, cur_test->data_out,
10226 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10227 : : RTE_CRYPTO_CIPHER_NULL, NULL,
10228 : 0 : 0, cur_test->param.auth_alg,
10229 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10230 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
10231 : : 0, 0, 0);
10232 [ # # ]: 0 : if (err) {
10233 : : printf("\t%d) %s: Short MAC test failed\n",
10234 : 0 : cur_test->test_idx,
10235 : 0 : cur_test->param.name);
10236 : : err = TEST_FAILED;
10237 : : } else {
10238 : : printf("\t%d) %s: Short MAC test PASS\n",
10239 : 0 : cur_test->test_idx,
10240 : 0 : cur_test->param.name);
10241 : 0 : rte_hexdump(stdout, "MAC I",
10242 : 0 : cur_test->data_out + cur_test->in_len + 2,
10243 : : 2);
10244 : : err = TEST_SUCCESS;
10245 : : }
10246 : 0 : all_err += err;
10247 : : }
10248 : :
10249 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10250 : :
10251 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10252 : :
10253 : : }
10254 : :
10255 : : static int
10256 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
10257 : : {
10258 : : int i = 0, size = 0;
10259 : : int err, all_err = TEST_SUCCESS;
10260 : : const struct pdcp_sdap_test *cur_test;
10261 : :
10262 : : size = RTE_DIM(list_pdcp_sdap_tests);
10263 : :
10264 [ # # ]: 0 : for (i = 0; i < size; i++) {
10265 : : cur_test = &list_pdcp_sdap_tests[i];
10266 : 0 : err = test_pdcp_proto(
10267 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10268 : : RTE_CRYPTO_AUTH_OP_VERIFY,
10269 : 0 : cur_test->data_out,
10270 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10271 : 0 : cur_test->data_in, cur_test->in_len,
10272 : 0 : cur_test->param.cipher_alg,
10273 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
10274 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
10275 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
10276 : 0 : cur_test->param.domain, cur_test->packet_direction,
10277 : 0 : cur_test->sn_size, cur_test->hfn,
10278 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10279 [ # # ]: 0 : if (err) {
10280 : : printf("\t%d) %s: Decapsulation failed\n",
10281 : 0 : cur_test->test_idx,
10282 : 0 : cur_test->param.name);
10283 : : err = TEST_FAILED;
10284 : : } else {
10285 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10286 : 0 : cur_test->param.name);
10287 : : err = TEST_SUCCESS;
10288 : : }
10289 : 0 : all_err += err;
10290 : : }
10291 : :
10292 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10293 : :
10294 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10295 : : }
10296 : :
10297 : : static int
10298 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10299 : : struct crypto_unittest_params *ut_params,
10300 : : struct rte_security_ipsec_xform *ipsec_xform,
10301 : : const struct ipsec_test_data *td,
10302 : : const struct ipsec_test_flags *flags,
10303 : : int pkt_num)
10304 : : {
10305 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10306 : : enum rte_security_ipsec_sa_direction dir;
10307 : : int ret;
10308 : :
10309 : 0 : dir = ipsec_xform->direction;
10310 : :
10311 : : /* Generate crypto op data structure */
10312 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10313 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10314 [ # # ]: 0 : if (!ut_params->op) {
10315 : : printf("Could not allocate crypto op");
10316 : 0 : return TEST_FAILED;
10317 : : }
10318 : :
10319 : : /* Attach session to operation */
10320 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10321 : :
10322 : : /* Set crypto operation mbufs */
10323 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10324 : 0 : ut_params->op->sym->m_dst = NULL;
10325 : :
10326 : : /* Copy IV in crypto operation when IV generation is disabled */
10327 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10328 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10329 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10330 : : uint8_t *,
10331 : : IV_OFFSET);
10332 : : int len;
10333 : :
10334 [ # # ]: 0 : if (td->aead)
10335 : 0 : len = td->xform.aead.aead.iv.length;
10336 [ # # ]: 0 : else if (td->aes_gmac)
10337 : 0 : len = td->xform.chain.auth.auth.iv.length;
10338 : : else
10339 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10340 : :
10341 : 0 : memcpy(iv, td->iv.data, len);
10342 : : }
10343 : :
10344 : : /* Process crypto operation */
10345 : 0 : process_crypto_request(dev_id, ut_params->op);
10346 : :
10347 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10348 : :
10349 : 0 : rte_crypto_op_free(ut_params->op);
10350 : 0 : ut_params->op = NULL;
10351 : :
10352 : 0 : return ret;
10353 : : }
10354 : :
10355 : : static int
10356 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10357 : : struct crypto_unittest_params *ut_params,
10358 : : void *ctx)
10359 : : {
10360 : : uint64_t timeout, userdata;
10361 : : struct rte_ether_hdr *hdr;
10362 : : struct rte_mbuf *m;
10363 : : void **sec_sess;
10364 : : int ret;
10365 : :
10366 : : RTE_SET_USED(ts_params);
10367 : :
10368 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10369 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10370 : :
10371 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10372 : 0 : ut_params->ibuf->port = 0;
10373 : :
10374 : 0 : sec_sess = &ut_params->sec_session;
10375 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10376 : :
10377 [ # # ]: 0 : if (ret != 1)
10378 : : return TEST_FAILED;
10379 : :
10380 : 0 : ut_params->ibuf = NULL;
10381 : :
10382 : : /* Add a timeout for 1 s */
10383 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10384 : :
10385 : : do {
10386 : : /* Get packet from port 0, queue 0 */
10387 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10388 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10389 : :
10390 [ # # ]: 0 : if (ret == 0) {
10391 : : printf("Could not receive packets from ethdev\n");
10392 : 0 : return TEST_FAILED;
10393 : : }
10394 : :
10395 [ # # ]: 0 : if (m == NULL) {
10396 : : printf("Received mbuf is NULL\n");
10397 : 0 : return TEST_FAILED;
10398 : : }
10399 : :
10400 : 0 : ut_params->ibuf = m;
10401 : :
10402 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10403 : : printf("Received packet is not Rx security processed\n");
10404 : 0 : return TEST_FAILED;
10405 : : }
10406 : :
10407 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10408 : : printf("Received packet has failed Rx security processing\n");
10409 : 0 : return TEST_FAILED;
10410 : : }
10411 : :
10412 : : /*
10413 : : * 'ut_params' is set as userdata. Verify that the field is returned
10414 : : * correctly.
10415 : : */
10416 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10417 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10418 : : printf("Userdata retrieved not matching expected\n");
10419 : 0 : return TEST_FAILED;
10420 : : }
10421 : :
10422 : : /* Trim L2 header */
10423 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10424 : :
10425 : : return TEST_SUCCESS;
10426 : : }
10427 : :
10428 : : static int
10429 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10430 : : struct ipsec_test_data res_d[],
10431 : : int nb_td,
10432 : : bool silent,
10433 : : const struct ipsec_test_flags *flags)
10434 : : {
10435 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10436 : : 0x0000, 0x001a};
10437 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10438 : : 0xe82c, 0x4887};
10439 : : const struct rte_ipv4_hdr *ipv4 =
10440 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10441 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10442 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10443 : : struct crypto_unittest_params *ut_params = &unittest_params;
10444 : : struct rte_security_capability_idx sec_cap_idx;
10445 : : const struct rte_security_capability *sec_cap;
10446 : : struct rte_security_ipsec_xform ipsec_xform;
10447 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10448 : : enum rte_security_ipsec_sa_direction dir;
10449 : : struct ipsec_test_data *res_d_tmp = NULL;
10450 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10451 : : int salt_len, i, ret = TEST_SUCCESS;
10452 : : void *ctx;
10453 : : uint32_t src, dst;
10454 : : uint32_t verify;
10455 : :
10456 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10457 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10458 : :
10459 : : /* Use first test data to create session */
10460 : :
10461 : : /* Copy IPsec xform */
10462 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10463 : :
10464 : 0 : dir = ipsec_xform.direction;
10465 : 0 : verify = flags->tunnel_hdr_verify;
10466 : :
10467 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10468 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10469 : :
10470 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10471 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10472 : 0 : src += 1;
10473 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10474 : 0 : dst += 1;
10475 : : }
10476 : :
10477 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10478 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10479 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10480 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10481 : : sizeof(src));
10482 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10483 : : sizeof(dst));
10484 : :
10485 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10486 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10487 : :
10488 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10489 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10490 : :
10491 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10492 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10493 : :
10494 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10495 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10496 : : TEST_IPSEC_DSCP_VAL;
10497 : :
10498 : : } else {
10499 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10500 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10501 : :
10502 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10503 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10504 : : TEST_IPSEC_DSCP_VAL;
10505 : :
10506 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10507 : : sizeof(v6_src));
10508 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10509 : : sizeof(v6_dst));
10510 : : }
10511 : : }
10512 : :
10513 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10514 : :
10515 : 0 : sec_cap_idx.action = ut_params->type;
10516 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10517 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10518 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10519 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10520 : :
10521 [ # # ]: 0 : if (flags->udp_encap)
10522 : 0 : ipsec_xform.options.udp_encap = 1;
10523 : :
10524 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10525 [ # # ]: 0 : if (sec_cap == NULL)
10526 : : return TEST_SKIPPED;
10527 : :
10528 : : /* Copy cipher session parameters */
10529 [ # # ]: 0 : if (td[0].aead) {
10530 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10531 : : sizeof(ut_params->aead_xform));
10532 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10533 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10534 : :
10535 : : /* Verify crypto capabilities */
10536 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10537 [ # # ]: 0 : if (!silent)
10538 : 0 : RTE_LOG(INFO, USER1,
10539 : : "Crypto capabilities not supported\n");
10540 : 0 : return TEST_SKIPPED;
10541 : : }
10542 [ # # ]: 0 : } else if (td[0].auth_only) {
10543 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10544 : : sizeof(ut_params->auth_xform));
10545 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10546 : :
10547 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10548 [ # # ]: 0 : if (!silent)
10549 : 0 : RTE_LOG(INFO, USER1,
10550 : : "Auth crypto capabilities not supported\n");
10551 : 0 : return TEST_SKIPPED;
10552 : : }
10553 : : } else {
10554 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10555 : : sizeof(ut_params->cipher_xform));
10556 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10557 : : sizeof(ut_params->auth_xform));
10558 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10559 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10560 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10561 : :
10562 : : /* Verify crypto capabilities */
10563 : :
10564 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10565 [ # # ]: 0 : if (!silent)
10566 : 0 : RTE_LOG(INFO, USER1,
10567 : : "Cipher crypto capabilities not supported\n");
10568 : 0 : return TEST_SKIPPED;
10569 : : }
10570 : :
10571 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10572 [ # # ]: 0 : if (!silent)
10573 : 0 : RTE_LOG(INFO, USER1,
10574 : : "Auth crypto capabilities not supported\n");
10575 : 0 : return TEST_SKIPPED;
10576 : : }
10577 : : }
10578 : :
10579 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10580 : : return TEST_SKIPPED;
10581 : :
10582 : 0 : struct rte_security_session_conf sess_conf = {
10583 : 0 : .action_type = ut_params->type,
10584 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10585 : : };
10586 : :
10587 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac ||
10588 [ # # ]: 0 : (td[0].xform.chain.cipher.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR)) {
10589 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10590 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10591 : : }
10592 : :
10593 [ # # ]: 0 : if (td[0].aead) {
10594 : 0 : sess_conf.ipsec = ipsec_xform;
10595 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10596 [ # # ]: 0 : } else if (td[0].auth_only) {
10597 : 0 : sess_conf.ipsec = ipsec_xform;
10598 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10599 : : } else {
10600 : 0 : sess_conf.ipsec = ipsec_xform;
10601 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10602 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10603 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10604 : : } else {
10605 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10606 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10607 : : }
10608 : : }
10609 : :
10610 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10611 : 0 : sess_conf.userdata = ut_params;
10612 : :
10613 : : /* Create security session */
10614 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10615 : : ts_params->session_mpool);
10616 : :
10617 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10618 : : return TEST_SKIPPED;
10619 : :
10620 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10621 [ # # # # ]: 0 : if (flags->antireplay &&
10622 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10623 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10624 : 0 : ret = rte_security_session_update(ctx,
10625 : : ut_params->sec_session, &sess_conf);
10626 [ # # ]: 0 : if (ret) {
10627 : : printf("Could not update sequence number in "
10628 : : "session\n");
10629 : 0 : return TEST_SKIPPED;
10630 : : }
10631 : : }
10632 : :
10633 : : /* Copy test data before modification */
10634 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10635 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10636 : : ret = TEST_FAILED;
10637 : 0 : goto mbuf_free;
10638 : : }
10639 : :
10640 : : /* Setup source mbuf payload */
10641 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10642 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10643 : 0 : td[i].input_text.len, nb_segs, input_text);
10644 : : } else {
10645 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10646 : 0 : td[i].input_text.len, nb_segs, 0);
10647 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10648 : : }
10649 : :
10650 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10651 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10652 : : ctx);
10653 : : else
10654 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10655 : : ut_params,
10656 : : &ipsec_xform,
10657 : : &td[i], flags,
10658 : : i + 1);
10659 : :
10660 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10661 : 0 : goto mbuf_free;
10662 : :
10663 [ # # ]: 0 : if (res_d != NULL)
10664 : 0 : res_d_tmp = &res_d[i];
10665 : :
10666 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10667 : : res_d_tmp, silent, flags);
10668 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10669 : 0 : goto mbuf_free;
10670 : :
10671 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10672 : : flags, dir);
10673 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10674 : 0 : goto mbuf_free;
10675 : :
10676 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10677 : 0 : ut_params->ibuf = NULL;
10678 : : }
10679 : :
10680 : 0 : mbuf_free:
10681 [ # # ]: 0 : if (flags->use_ext_mbuf)
10682 : 0 : ext_mbuf_memzone_free(nb_segs);
10683 : :
10684 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10685 : 0 : ut_params->ibuf = NULL;
10686 : :
10687 [ # # ]: 0 : if (ut_params->sec_session)
10688 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10689 : 0 : ut_params->sec_session = NULL;
10690 : :
10691 : 0 : return ret;
10692 : : }
10693 : :
10694 : : static int
10695 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10696 : : {
10697 : : struct ipsec_test_data td_outb;
10698 : : struct ipsec_test_flags flags;
10699 : :
10700 : : memset(&flags, 0, sizeof(flags));
10701 : :
10702 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10703 : :
10704 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10705 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10706 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10707 : : /* Disable IV gen to be able to test with known vectors */
10708 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10709 : : }
10710 : :
10711 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10712 : : }
10713 : :
10714 : : static int
10715 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10716 : : {
10717 : : struct ipsec_test_data td_outb;
10718 : : struct ipsec_test_flags flags;
10719 : :
10720 : : memset(&flags, 0, sizeof(flags));
10721 [ # # ]: 0 : flags.use_ext_mbuf = true;
10722 : :
10723 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10724 : :
10725 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10726 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10727 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10728 : : /* Disable IV gen to be able to test with known vectors */
10729 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10730 : : }
10731 : :
10732 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10733 : : }
10734 : :
10735 : : static int
10736 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10737 : : {
10738 : : const struct ipsec_test_data *td = test_data;
10739 : : struct ipsec_test_flags flags;
10740 : : struct ipsec_test_data td_inb;
10741 : :
10742 : : memset(&flags, 0, sizeof(flags));
10743 : :
10744 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10745 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10746 : : else
10747 : : memcpy(&td_inb, td, sizeof(td_inb));
10748 : :
10749 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10750 : : }
10751 : :
10752 : : static int
10753 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10754 : : {
10755 : : struct ipsec_test_data td_outb;
10756 : : struct ipsec_test_flags flags;
10757 : :
10758 : : memset(&flags, 0, sizeof(flags));
10759 : 0 : flags.fragment = true;
10760 : :
10761 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10762 : :
10763 : : /* Disable IV gen to be able to test with known vectors */
10764 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10765 : :
10766 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10767 : : }
10768 : :
10769 : : static int
10770 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10771 : : {
10772 : : const struct ipsec_test_data *td = test_data;
10773 : : struct ipsec_test_flags flags;
10774 : : struct ipsec_test_data td_inb;
10775 : :
10776 : : memset(&flags, 0, sizeof(flags));
10777 : 0 : flags.rx_inject = true;
10778 : :
10779 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10780 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10781 : : else
10782 : : memcpy(&td_inb, td, sizeof(td_inb));
10783 : :
10784 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10785 : : }
10786 : :
10787 : : static int
10788 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10789 : : {
10790 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10791 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10792 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10793 : : int ret;
10794 : :
10795 [ # # ]: 0 : if (flags->iv_gen ||
10796 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10797 : : flags->sa_expiry_pkts_hard)
10798 : : nb_pkts = TEST_SEC_PKTS_MAX;
10799 : :
10800 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10801 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10802 : : sec_alg_list[i].param2,
10803 : : flags,
10804 : : td_outb,
10805 : : nb_pkts);
10806 : :
10807 [ # # ]: 0 : if (!td_outb->aead) {
10808 : : enum rte_crypto_cipher_algorithm cipher_alg;
10809 : : enum rte_crypto_auth_algorithm auth_alg;
10810 : :
10811 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10812 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10813 : :
10814 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10815 : 0 : continue;
10816 : :
10817 : : /* ICV is not applicable for NULL auth */
10818 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10819 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10820 : 0 : continue;
10821 : :
10822 : : /* IV is not applicable for NULL cipher */
10823 [ # # # # ]: 0 : if (flags->iv_gen &&
10824 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10825 : 0 : continue;
10826 : : }
10827 : :
10828 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10829 : : flags);
10830 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10831 : 0 : continue;
10832 : :
10833 [ # # ]: 0 : if (ret == TEST_FAILED)
10834 : : return TEST_FAILED;
10835 : :
10836 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10837 : :
10838 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10839 : : flags);
10840 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10841 : 0 : continue;
10842 : :
10843 [ # # ]: 0 : if (ret == TEST_FAILED)
10844 : : return TEST_FAILED;
10845 : :
10846 [ # # ]: 0 : if (flags->display_alg)
10847 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10848 : :
10849 : 0 : pass_cnt++;
10850 : : }
10851 : :
10852 [ # # ]: 0 : if (pass_cnt > 0)
10853 : : return TEST_SUCCESS;
10854 : : else
10855 : 0 : return TEST_SKIPPED;
10856 : : }
10857 : :
10858 : : static int
10859 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10860 : : {
10861 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10862 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10863 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10864 : : int ret;
10865 : :
10866 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10867 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10868 : : sec_auth_only_alg_list[i].param2,
10869 : : flags,
10870 : : td_outb,
10871 : : nb_pkts);
10872 : :
10873 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10874 : : flags);
10875 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10876 : 0 : continue;
10877 : :
10878 [ # # ]: 0 : if (ret == TEST_FAILED)
10879 : : return TEST_FAILED;
10880 : :
10881 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10882 : :
10883 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10884 : : flags);
10885 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10886 : 0 : continue;
10887 : :
10888 [ # # ]: 0 : if (ret == TEST_FAILED)
10889 : : return TEST_FAILED;
10890 : :
10891 [ # # ]: 0 : if (flags->display_alg)
10892 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10893 : : sec_auth_only_alg_list[i].param2);
10894 : :
10895 : 0 : pass_cnt++;
10896 : : }
10897 : :
10898 [ # # ]: 0 : if (pass_cnt > 0)
10899 : : return TEST_SUCCESS;
10900 : : else
10901 : 0 : return TEST_SKIPPED;
10902 : : }
10903 : :
10904 : : static int
10905 : 0 : test_ipsec_proto_display_list(void)
10906 : : {
10907 : : struct ipsec_test_flags flags;
10908 : :
10909 : : memset(&flags, 0, sizeof(flags));
10910 : :
10911 : 0 : flags.display_alg = true;
10912 : :
10913 : 0 : return test_ipsec_proto_all(&flags);
10914 : : }
10915 : :
10916 : : static int
10917 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10918 : : {
10919 : : struct ipsec_test_flags flags;
10920 : :
10921 : : memset(&flags, 0, sizeof(flags));
10922 : :
10923 : 0 : flags.ah = true;
10924 : 0 : flags.display_alg = true;
10925 : :
10926 : 0 : return test_ipsec_ah_proto_all(&flags);
10927 : : }
10928 : :
10929 : : static int
10930 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10931 : : {
10932 : : struct ipsec_test_flags flags;
10933 : :
10934 : : memset(&flags, 0, sizeof(flags));
10935 : :
10936 : 0 : flags.ah = true;
10937 : 0 : flags.transport = true;
10938 : :
10939 : 0 : return test_ipsec_ah_proto_all(&flags);
10940 : : }
10941 : :
10942 : : static int
10943 : 0 : test_ipsec_proto_iv_gen(void)
10944 : : {
10945 : : struct ipsec_test_flags flags;
10946 : :
10947 : : memset(&flags, 0, sizeof(flags));
10948 : :
10949 : 0 : flags.iv_gen = true;
10950 : :
10951 : 0 : return test_ipsec_proto_all(&flags);
10952 : : }
10953 : :
10954 : : static int
10955 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10956 : : {
10957 : : struct ipsec_test_flags flags;
10958 : :
10959 : : memset(&flags, 0, sizeof(flags));
10960 : :
10961 : 0 : flags.sa_expiry_pkts_soft = true;
10962 : :
10963 : 0 : return test_ipsec_proto_all(&flags);
10964 : : }
10965 : :
10966 : : static int
10967 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10968 : : {
10969 : : struct ipsec_test_flags flags;
10970 : :
10971 : : memset(&flags, 0, sizeof(flags));
10972 : :
10973 : 0 : flags.sa_expiry_pkts_hard = true;
10974 : :
10975 : 0 : return test_ipsec_proto_all(&flags);
10976 : : }
10977 : :
10978 : : static int
10979 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10980 : : {
10981 : : struct ipsec_test_flags flags;
10982 : :
10983 : : memset(&flags, 0, sizeof(flags));
10984 : :
10985 : 0 : flags.icv_corrupt = true;
10986 : :
10987 : 0 : return test_ipsec_proto_all(&flags);
10988 : : }
10989 : :
10990 : : static int
10991 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10992 : : {
10993 : : struct ipsec_test_flags flags;
10994 : :
10995 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10996 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10997 : : return TEST_SKIPPED;
10998 : :
10999 : : memset(&flags, 0, sizeof(flags));
11000 : :
11001 : 0 : flags.udp_encap = true;
11002 : 0 : flags.udp_encap_custom_ports = true;
11003 : :
11004 : 0 : return test_ipsec_proto_all(&flags);
11005 : : }
11006 : :
11007 : : static int
11008 : 0 : test_ipsec_proto_udp_encap(void)
11009 : : {
11010 : : struct ipsec_test_flags flags;
11011 : :
11012 : : memset(&flags, 0, sizeof(flags));
11013 : :
11014 : 0 : flags.udp_encap = true;
11015 : :
11016 : 0 : return test_ipsec_proto_all(&flags);
11017 : : }
11018 : :
11019 : : static int
11020 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
11021 : : {
11022 : : struct ipsec_test_flags flags;
11023 : :
11024 : : memset(&flags, 0, sizeof(flags));
11025 : :
11026 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
11027 : :
11028 : 0 : return test_ipsec_proto_all(&flags);
11029 : : }
11030 : :
11031 : : static int
11032 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
11033 : : {
11034 : : struct ipsec_test_flags flags;
11035 : :
11036 : : memset(&flags, 0, sizeof(flags));
11037 : :
11038 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
11039 : :
11040 : 0 : return test_ipsec_proto_all(&flags);
11041 : : }
11042 : :
11043 : : static int
11044 : 0 : test_ipsec_proto_udp_ports_verify(void)
11045 : : {
11046 : : struct ipsec_test_flags flags;
11047 : :
11048 : : memset(&flags, 0, sizeof(flags));
11049 : :
11050 : 0 : flags.udp_encap = true;
11051 : 0 : flags.udp_ports_verify = true;
11052 : :
11053 : 0 : return test_ipsec_proto_all(&flags);
11054 : : }
11055 : :
11056 : : static int
11057 : 0 : test_ipsec_proto_inner_ip_csum(void)
11058 : : {
11059 : : struct ipsec_test_flags flags;
11060 : :
11061 : : memset(&flags, 0, sizeof(flags));
11062 : :
11063 : 0 : flags.ip_csum = true;
11064 : :
11065 : 0 : return test_ipsec_proto_all(&flags);
11066 : : }
11067 : :
11068 : : static int
11069 : 0 : test_ipsec_proto_inner_l4_csum(void)
11070 : : {
11071 : : struct ipsec_test_flags flags;
11072 : :
11073 : : memset(&flags, 0, sizeof(flags));
11074 : :
11075 : 0 : flags.l4_csum = true;
11076 : :
11077 : 0 : return test_ipsec_proto_all(&flags);
11078 : : }
11079 : :
11080 : : static int
11081 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
11082 : : {
11083 : : struct ipsec_test_flags flags;
11084 : :
11085 : : memset(&flags, 0, sizeof(flags));
11086 : :
11087 : : flags.ipv6 = false;
11088 : : flags.tunnel_ipv6 = false;
11089 : :
11090 : 0 : return test_ipsec_proto_all(&flags);
11091 : : }
11092 : :
11093 : : static int
11094 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
11095 : : {
11096 : : struct ipsec_test_flags flags;
11097 : :
11098 : : memset(&flags, 0, sizeof(flags));
11099 : :
11100 : 0 : flags.ipv6 = true;
11101 : 0 : flags.tunnel_ipv6 = true;
11102 : :
11103 : 0 : return test_ipsec_proto_all(&flags);
11104 : : }
11105 : :
11106 : : static int
11107 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
11108 : : {
11109 : : struct ipsec_test_flags flags;
11110 : :
11111 : : memset(&flags, 0, sizeof(flags));
11112 : :
11113 : : flags.ipv6 = false;
11114 : 0 : flags.tunnel_ipv6 = true;
11115 : :
11116 : 0 : return test_ipsec_proto_all(&flags);
11117 : : }
11118 : :
11119 : : static int
11120 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
11121 : : {
11122 : : struct ipsec_test_flags flags;
11123 : :
11124 : : memset(&flags, 0, sizeof(flags));
11125 : :
11126 : 0 : flags.ipv6 = true;
11127 : : flags.tunnel_ipv6 = false;
11128 : :
11129 : 0 : return test_ipsec_proto_all(&flags);
11130 : : }
11131 : :
11132 : : static int
11133 : 0 : test_ipsec_proto_transport_v4(void)
11134 : : {
11135 : : struct ipsec_test_flags flags;
11136 : :
11137 : : memset(&flags, 0, sizeof(flags));
11138 : :
11139 : : flags.ipv6 = false;
11140 : 0 : flags.transport = true;
11141 : :
11142 : 0 : return test_ipsec_proto_all(&flags);
11143 : : }
11144 : :
11145 : : static int
11146 : 0 : test_ipsec_proto_transport_l4_csum(void)
11147 : : {
11148 : 0 : struct ipsec_test_flags flags = {
11149 : : .l4_csum = true,
11150 : : .transport = true,
11151 : : };
11152 : :
11153 : 0 : return test_ipsec_proto_all(&flags);
11154 : : }
11155 : :
11156 : : static int
11157 : 0 : test_ipsec_proto_stats(void)
11158 : : {
11159 : : struct ipsec_test_flags flags;
11160 : :
11161 : : memset(&flags, 0, sizeof(flags));
11162 : :
11163 : 0 : flags.stats_success = true;
11164 : :
11165 : 0 : return test_ipsec_proto_all(&flags);
11166 : : }
11167 : :
11168 : : static int
11169 : 0 : test_ipsec_proto_pkt_fragment(void)
11170 : : {
11171 : : struct ipsec_test_flags flags;
11172 : :
11173 : : memset(&flags, 0, sizeof(flags));
11174 : :
11175 : 0 : flags.fragment = true;
11176 : :
11177 : 0 : return test_ipsec_proto_all(&flags);
11178 : :
11179 : : }
11180 : :
11181 : : static int
11182 : 0 : test_ipsec_proto_copy_df_inner_0(void)
11183 : : {
11184 : : struct ipsec_test_flags flags;
11185 : :
11186 : : memset(&flags, 0, sizeof(flags));
11187 : :
11188 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11189 : :
11190 : 0 : return test_ipsec_proto_all(&flags);
11191 : : }
11192 : :
11193 : : static int
11194 : 0 : test_ipsec_proto_copy_df_inner_1(void)
11195 : : {
11196 : : struct ipsec_test_flags flags;
11197 : :
11198 : : memset(&flags, 0, sizeof(flags));
11199 : :
11200 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11201 : :
11202 : 0 : return test_ipsec_proto_all(&flags);
11203 : : }
11204 : :
11205 : : static int
11206 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
11207 : : {
11208 : : struct ipsec_test_flags flags;
11209 : :
11210 : : memset(&flags, 0, sizeof(flags));
11211 : :
11212 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11213 : :
11214 : 0 : return test_ipsec_proto_all(&flags);
11215 : : }
11216 : :
11217 : : static int
11218 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
11219 : : {
11220 : : struct ipsec_test_flags flags;
11221 : :
11222 : : memset(&flags, 0, sizeof(flags));
11223 : :
11224 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11225 : :
11226 : 0 : return test_ipsec_proto_all(&flags);
11227 : : }
11228 : :
11229 : : static int
11230 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11231 : : {
11232 : : struct ipsec_test_flags flags;
11233 : :
11234 : : memset(&flags, 0, sizeof(flags));
11235 : :
11236 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11237 : :
11238 : 0 : return test_ipsec_proto_all(&flags);
11239 : : }
11240 : :
11241 : : static int
11242 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11243 : : {
11244 : : struct ipsec_test_flags flags;
11245 : :
11246 : : memset(&flags, 0, sizeof(flags));
11247 : :
11248 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11249 : :
11250 : 0 : return test_ipsec_proto_all(&flags);
11251 : : }
11252 : :
11253 : : static int
11254 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11255 : : {
11256 : : struct ipsec_test_flags flags;
11257 : :
11258 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11259 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11260 : : return TEST_SKIPPED;
11261 : :
11262 : : memset(&flags, 0, sizeof(flags));
11263 : :
11264 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11265 : :
11266 : 0 : return test_ipsec_proto_all(&flags);
11267 : : }
11268 : :
11269 : : static int
11270 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11271 : : {
11272 : : struct ipsec_test_flags flags;
11273 : :
11274 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11275 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11276 : : return TEST_SKIPPED;
11277 : :
11278 : : memset(&flags, 0, sizeof(flags));
11279 : :
11280 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11281 : :
11282 : 0 : return test_ipsec_proto_all(&flags);
11283 : : }
11284 : :
11285 : : static int
11286 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11287 : : {
11288 : : struct ipsec_test_flags flags;
11289 : :
11290 : : memset(&flags, 0, sizeof(flags));
11291 : :
11292 : 0 : flags.ipv6 = true;
11293 : 0 : flags.tunnel_ipv6 = true;
11294 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11295 : :
11296 : 0 : return test_ipsec_proto_all(&flags);
11297 : : }
11298 : :
11299 : : static int
11300 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11301 : : {
11302 : : struct ipsec_test_flags flags;
11303 : :
11304 : : memset(&flags, 0, sizeof(flags));
11305 : :
11306 : 0 : flags.ipv6 = true;
11307 : 0 : flags.tunnel_ipv6 = true;
11308 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11309 : :
11310 : 0 : return test_ipsec_proto_all(&flags);
11311 : : }
11312 : :
11313 : : static int
11314 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11315 : : {
11316 : : struct ipsec_test_flags flags;
11317 : :
11318 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11319 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11320 : : return TEST_SKIPPED;
11321 : :
11322 : : memset(&flags, 0, sizeof(flags));
11323 : :
11324 : 0 : flags.ipv6 = true;
11325 : 0 : flags.tunnel_ipv6 = true;
11326 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11327 : :
11328 : 0 : return test_ipsec_proto_all(&flags);
11329 : : }
11330 : :
11331 : : static int
11332 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11333 : : {
11334 : : struct ipsec_test_flags flags;
11335 : :
11336 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11337 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11338 : : return TEST_SKIPPED;
11339 : :
11340 : : memset(&flags, 0, sizeof(flags));
11341 : :
11342 : 0 : flags.ipv6 = true;
11343 : 0 : flags.tunnel_ipv6 = true;
11344 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11345 : :
11346 : 0 : return test_ipsec_proto_all(&flags);
11347 : : }
11348 : :
11349 : : static int
11350 : 0 : test_ipsec_proto_sgl(void)
11351 : : {
11352 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11353 : : struct rte_cryptodev_info dev_info;
11354 : :
11355 : 0 : struct ipsec_test_flags flags = {
11356 : : .nb_segs_in_mbuf = 5
11357 : : };
11358 : :
11359 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11360 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11361 : : printf("Device doesn't support in-place scatter-gather. "
11362 : : "Test Skipped.\n");
11363 : 0 : return TEST_SKIPPED;
11364 : : }
11365 : :
11366 : 0 : return test_ipsec_proto_all(&flags);
11367 : : }
11368 : :
11369 : : static int
11370 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11371 : : {
11372 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11373 : : struct rte_cryptodev_info dev_info;
11374 : :
11375 : 0 : struct ipsec_test_flags flags = {
11376 : : .nb_segs_in_mbuf = 5,
11377 : : .use_ext_mbuf = 1
11378 : : };
11379 : :
11380 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11381 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11382 : : printf("Device doesn't support in-place scatter-gather. "
11383 : : "Test Skipped.\n");
11384 : 0 : return TEST_SKIPPED;
11385 : : }
11386 : :
11387 : 0 : return test_ipsec_proto_all(&flags);
11388 : : }
11389 : :
11390 : : static int
11391 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11392 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11393 : : uint64_t winsz)
11394 : : {
11395 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11396 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11397 : : struct ipsec_test_flags flags;
11398 : : uint32_t i = 0, ret = 0;
11399 : :
11400 [ # # ]: 0 : if (nb_pkts == 0)
11401 : : return TEST_FAILED;
11402 : :
11403 : : memset(&flags, 0, sizeof(flags));
11404 : 0 : flags.antireplay = true;
11405 : :
11406 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11407 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11408 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11409 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11410 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11411 : : }
11412 : :
11413 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11414 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11415 : :
11416 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11417 : : &flags);
11418 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11419 : : return ret;
11420 : :
11421 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11422 : :
11423 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11424 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11425 : : /* Set antireplay flag for packets to be dropped */
11426 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11427 : : }
11428 : :
11429 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11430 : : &flags);
11431 : :
11432 : 0 : return ret;
11433 : : }
11434 : :
11435 : : static int
11436 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11437 : : {
11438 : :
11439 : : uint32_t nb_pkts = 5;
11440 : : bool replayed_pkt[5];
11441 : : uint64_t esn[5];
11442 : :
11443 : : /* 1. Advance the TOP of the window to WS * 2 */
11444 : 0 : esn[0] = winsz * 2;
11445 : : /* 2. Test sequence number within the new window(WS + 1) */
11446 : 0 : esn[1] = winsz + 1;
11447 : : /* 3. Test sequence number less than the window BOTTOM */
11448 : 0 : esn[2] = winsz;
11449 : : /* 4. Test sequence number in the middle of the window */
11450 : 0 : esn[3] = winsz + (winsz / 2);
11451 : : /* 5. Test replay of the packet in the middle of the window */
11452 : 0 : esn[4] = winsz + (winsz / 2);
11453 : :
11454 : 0 : replayed_pkt[0] = false;
11455 : 0 : replayed_pkt[1] = false;
11456 : 0 : replayed_pkt[2] = true;
11457 : 0 : replayed_pkt[3] = false;
11458 : 0 : replayed_pkt[4] = true;
11459 : :
11460 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11461 : : false, winsz);
11462 : : }
11463 : :
11464 : : static int
11465 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11466 : : {
11467 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11468 : : }
11469 : :
11470 : : static int
11471 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11472 : : {
11473 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11474 : : }
11475 : :
11476 : : static int
11477 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11478 : : {
11479 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11480 : : }
11481 : :
11482 : : static int
11483 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11484 : : {
11485 : :
11486 : : uint32_t nb_pkts = 7;
11487 : : bool replayed_pkt[7];
11488 : : uint64_t esn[7];
11489 : :
11490 : : /* Set the initial sequence number */
11491 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11492 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11493 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11494 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11495 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11496 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11497 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11498 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11499 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11500 : : /* 5. Test with duplicate sequence number within
11501 : : * new window (1<<32 - 1)
11502 : : */
11503 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11504 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11505 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11506 : :
11507 : 0 : replayed_pkt[0] = false;
11508 : 0 : replayed_pkt[1] = false;
11509 : 0 : replayed_pkt[2] = false;
11510 : 0 : replayed_pkt[3] = false;
11511 : 0 : replayed_pkt[4] = false;
11512 : 0 : replayed_pkt[5] = true;
11513 : 0 : replayed_pkt[6] = true;
11514 : :
11515 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11516 : : true, winsz);
11517 : : }
11518 : :
11519 : : static int
11520 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11521 : : {
11522 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11523 : : }
11524 : :
11525 : : static int
11526 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11527 : : {
11528 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11529 : : }
11530 : :
11531 : : static int
11532 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11533 : : {
11534 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11535 : : }
11536 : :
11537 : : static int
11538 : 0 : test_PDCP_PROTO_all(void)
11539 : : {
11540 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11541 : : struct crypto_unittest_params *ut_params = &unittest_params;
11542 : : struct rte_cryptodev_info dev_info;
11543 : : int status;
11544 : :
11545 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11546 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11547 : :
11548 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11549 : : return TEST_SKIPPED;
11550 : :
11551 : : /* Set action type */
11552 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11553 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11554 : : gbl_action_type;
11555 : :
11556 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11557 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11558 : : return TEST_SKIPPED;
11559 : :
11560 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11561 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11562 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11563 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11564 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11565 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11566 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11567 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11568 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11569 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11570 : 0 : status += test_PDCP_PROTO_short_mac();
11571 : :
11572 [ # # ]: 0 : if (status)
11573 : : return TEST_FAILED;
11574 : : else
11575 : 0 : return TEST_SUCCESS;
11576 : : }
11577 : :
11578 : : static int
11579 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11580 : : {
11581 : 0 : struct ipsec_test_flags flags = {
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_ipsec_proto_ipv6_hop_limit_decrement(void)
11590 : : {
11591 : 0 : struct ipsec_test_flags flags = {
11592 : : .ipv6 = true,
11593 : : .dec_ttl_or_hop_limit = true
11594 : : };
11595 : :
11596 : 0 : return test_ipsec_proto_all(&flags);
11597 : : }
11598 : :
11599 : : static int
11600 : 0 : test_docsis_proto_uplink(const void *data)
11601 : : {
11602 : : const struct docsis_test_data *d_td = data;
11603 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11604 : : struct crypto_unittest_params *ut_params = &unittest_params;
11605 : : uint8_t *plaintext = NULL;
11606 : : uint8_t *ciphertext = NULL;
11607 : : uint8_t *iv_ptr;
11608 : : int32_t cipher_len, crc_len;
11609 : : uint32_t crc_data_len;
11610 : : int ret = TEST_SUCCESS;
11611 : :
11612 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11613 : :
11614 : : /* Verify the capabilities */
11615 : : struct rte_security_capability_idx sec_cap_idx;
11616 : : const struct rte_security_capability *sec_cap;
11617 : : const struct rte_cryptodev_capabilities *crypto_cap;
11618 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11619 : : int j = 0;
11620 : :
11621 : : /* Set action type */
11622 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11623 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11624 : : gbl_action_type;
11625 : :
11626 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11627 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11628 : : return TEST_SKIPPED;
11629 : :
11630 : 0 : sec_cap_idx.action = ut_params->type;
11631 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11632 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11633 : :
11634 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11635 [ # # ]: 0 : if (sec_cap == NULL)
11636 : : return TEST_SKIPPED;
11637 : :
11638 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11639 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11640 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11641 : : crypto_cap->sym.xform_type ==
11642 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11643 : : crypto_cap->sym.cipher.algo ==
11644 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11645 : 0 : sym_cap = &crypto_cap->sym;
11646 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11647 : 0 : d_td->key.len,
11648 : 0 : d_td->iv.len) == 0)
11649 : : break;
11650 : : }
11651 : : }
11652 : :
11653 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11654 : : return TEST_SKIPPED;
11655 : :
11656 : : /* Setup source mbuf payload */
11657 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11658 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11659 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11660 : :
11661 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11662 : 0 : d_td->ciphertext.len);
11663 : :
11664 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11665 : :
11666 : : /* Setup cipher session parameters */
11667 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11668 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11669 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11670 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11671 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11672 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11673 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11674 : 0 : ut_params->cipher_xform.next = NULL;
11675 : :
11676 : : /* Setup DOCSIS session parameters */
11677 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11678 : :
11679 : 0 : struct rte_security_session_conf sess_conf = {
11680 : 0 : .action_type = ut_params->type,
11681 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11682 : : .docsis = ut_params->docsis_xform,
11683 : : .crypto_xform = &ut_params->cipher_xform,
11684 : : };
11685 : :
11686 : : /* Create security session */
11687 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11688 : : ts_params->session_mpool);
11689 : :
11690 [ # # ]: 0 : if (!ut_params->sec_session) {
11691 : : printf("Test function %s line %u: failed to allocate session\n",
11692 : : __func__, __LINE__);
11693 : : ret = TEST_FAILED;
11694 : 0 : goto on_err;
11695 : : }
11696 : :
11697 : : /* Generate crypto op data structure */
11698 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11699 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11700 [ # # ]: 0 : if (!ut_params->op) {
11701 : : printf("Test function %s line %u: failed to allocate symmetric "
11702 : : "crypto operation\n", __func__, __LINE__);
11703 : : ret = TEST_FAILED;
11704 : 0 : goto on_err;
11705 : : }
11706 : :
11707 : : /* Setup CRC operation parameters */
11708 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11709 : 0 : (d_td->ciphertext.len -
11710 : 0 : d_td->ciphertext.crc_offset -
11711 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11712 : : 0;
11713 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11714 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11715 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11716 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11717 : :
11718 : : /* Setup cipher operation parameters */
11719 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11720 : 0 : (d_td->ciphertext.len -
11721 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11722 : : 0;
11723 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11724 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11725 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11726 : :
11727 : : /* Setup cipher IV */
11728 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11729 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11730 : :
11731 : : /* Attach session to operation */
11732 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11733 : :
11734 : : /* Set crypto operation mbufs */
11735 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11736 : 0 : ut_params->op->sym->m_dst = NULL;
11737 : :
11738 : : /* Process crypto operation */
11739 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11740 : : NULL) {
11741 : : printf("Test function %s line %u: failed to process security "
11742 : : "crypto op\n", __func__, __LINE__);
11743 : : ret = TEST_FAILED;
11744 : 0 : goto on_err;
11745 : : }
11746 : :
11747 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11748 : : printf("Test function %s line %u: failed to process crypto op\n",
11749 : : __func__, __LINE__);
11750 : : ret = TEST_FAILED;
11751 : 0 : goto on_err;
11752 : : }
11753 : :
11754 : : /* Validate plaintext */
11755 : : plaintext = ciphertext;
11756 : :
11757 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11758 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11759 : : printf("Test function %s line %u: plaintext not as expected\n",
11760 : : __func__, __LINE__);
11761 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11762 : 0 : d_td->plaintext.len);
11763 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11764 : : ret = TEST_FAILED;
11765 : 0 : goto on_err;
11766 : : }
11767 : :
11768 : 0 : on_err:
11769 : 0 : rte_crypto_op_free(ut_params->op);
11770 : 0 : ut_params->op = NULL;
11771 : :
11772 [ # # ]: 0 : if (ut_params->sec_session)
11773 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11774 : 0 : ut_params->sec_session = NULL;
11775 : :
11776 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11777 : 0 : ut_params->ibuf = NULL;
11778 : :
11779 : 0 : return ret;
11780 : : }
11781 : :
11782 : : static int
11783 : 0 : test_docsis_proto_downlink(const void *data)
11784 : : {
11785 : : const struct docsis_test_data *d_td = data;
11786 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11787 : : struct crypto_unittest_params *ut_params = &unittest_params;
11788 : : uint8_t *plaintext = NULL;
11789 : : uint8_t *ciphertext = NULL;
11790 : : uint8_t *iv_ptr;
11791 : : int32_t cipher_len, crc_len;
11792 : : int ret = TEST_SUCCESS;
11793 : :
11794 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11795 : :
11796 : : /* Verify the capabilities */
11797 : : struct rte_security_capability_idx sec_cap_idx;
11798 : : const struct rte_security_capability *sec_cap;
11799 : : const struct rte_cryptodev_capabilities *crypto_cap;
11800 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11801 : : int j = 0;
11802 : :
11803 : : /* Set action type */
11804 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11805 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11806 : : gbl_action_type;
11807 : :
11808 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11809 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11810 : : return TEST_SKIPPED;
11811 : :
11812 : 0 : sec_cap_idx.action = ut_params->type;
11813 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11814 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11815 : :
11816 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11817 [ # # ]: 0 : if (sec_cap == NULL)
11818 : : return TEST_SKIPPED;
11819 : :
11820 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11821 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11822 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11823 : : crypto_cap->sym.xform_type ==
11824 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11825 : : crypto_cap->sym.cipher.algo ==
11826 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11827 : 0 : sym_cap = &crypto_cap->sym;
11828 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11829 : 0 : d_td->key.len,
11830 : 0 : d_td->iv.len) == 0)
11831 : : break;
11832 : : }
11833 : : }
11834 : :
11835 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11836 : : return TEST_SKIPPED;
11837 : :
11838 : : /* Setup source mbuf payload */
11839 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11840 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11841 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11842 : :
11843 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11844 : 0 : d_td->plaintext.len);
11845 : :
11846 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11847 : :
11848 : : /* Setup cipher session parameters */
11849 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11850 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11851 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11852 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11853 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11854 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11855 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11856 : 0 : ut_params->cipher_xform.next = NULL;
11857 : :
11858 : : /* Setup DOCSIS session parameters */
11859 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11860 : :
11861 : 0 : struct rte_security_session_conf sess_conf = {
11862 : 0 : .action_type = ut_params->type,
11863 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11864 : : .docsis = ut_params->docsis_xform,
11865 : : .crypto_xform = &ut_params->cipher_xform,
11866 : : };
11867 : :
11868 : : /* Create security session */
11869 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11870 : : ts_params->session_mpool);
11871 : :
11872 [ # # ]: 0 : if (!ut_params->sec_session) {
11873 : : printf("Test function %s line %u: failed to allocate session\n",
11874 : : __func__, __LINE__);
11875 : : ret = TEST_FAILED;
11876 : 0 : goto on_err;
11877 : : }
11878 : :
11879 : : /* Generate crypto op data structure */
11880 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11881 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11882 [ # # ]: 0 : if (!ut_params->op) {
11883 : : printf("Test function %s line %u: failed to allocate symmetric "
11884 : : "crypto operation\n", __func__, __LINE__);
11885 : : ret = TEST_FAILED;
11886 : 0 : goto on_err;
11887 : : }
11888 : :
11889 : : /* Setup CRC operation parameters */
11890 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11891 : 0 : (d_td->plaintext.len -
11892 : 0 : d_td->plaintext.crc_offset -
11893 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11894 : : 0;
11895 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11896 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11897 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11898 : :
11899 : : /* Setup cipher operation parameters */
11900 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11901 : 0 : (d_td->plaintext.len -
11902 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11903 : : 0;
11904 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11905 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11906 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11907 : :
11908 : : /* Setup cipher IV */
11909 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11910 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11911 : :
11912 : : /* Attach session to operation */
11913 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11914 : :
11915 : : /* Set crypto operation mbufs */
11916 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11917 : 0 : ut_params->op->sym->m_dst = NULL;
11918 : :
11919 : : /* Process crypto operation */
11920 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11921 : : NULL) {
11922 : : printf("Test function %s line %u: failed to process crypto op\n",
11923 : : __func__, __LINE__);
11924 : : ret = TEST_FAILED;
11925 : 0 : goto on_err;
11926 : : }
11927 : :
11928 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11929 : : printf("Test function %s line %u: crypto op processing failed\n",
11930 : : __func__, __LINE__);
11931 : : ret = TEST_FAILED;
11932 : 0 : goto on_err;
11933 : : }
11934 : :
11935 : : /* Validate ciphertext */
11936 : : ciphertext = plaintext;
11937 : :
11938 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11939 : : printf("Test function %s line %u: plaintext not as expected\n",
11940 : : __func__, __LINE__);
11941 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11942 : 0 : d_td->ciphertext.len);
11943 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11944 : : ret = TEST_FAILED;
11945 : 0 : goto on_err;
11946 : : }
11947 : :
11948 : 0 : on_err:
11949 : 0 : rte_crypto_op_free(ut_params->op);
11950 : 0 : ut_params->op = NULL;
11951 : :
11952 [ # # ]: 0 : if (ut_params->sec_session)
11953 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11954 : 0 : ut_params->sec_session = NULL;
11955 : :
11956 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11957 : 0 : ut_params->ibuf = NULL;
11958 : :
11959 : 0 : return ret;
11960 : : }
11961 : :
11962 : : static void
11963 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11964 : : struct rte_security_tls_record_xform *tls_record_xform)
11965 : : {
11966 : : unsigned int imp_nonce_len;
11967 : : uint8_t *imp_nonce;
11968 : :
11969 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11970 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11971 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11972 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11973 : 0 : break;
11974 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11975 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11976 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11977 : 0 : break;
11978 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
11979 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11980 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11981 : 0 : break;
11982 : : default:
11983 : : return;
11984 : : }
11985 : :
11986 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11987 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11988 : : }
11989 : :
11990 : : static int
11991 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
11992 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
11993 : : const struct tls_record_test_flags *flags)
11994 : : {
11995 : 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11996 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11997 : : struct crypto_unittest_params *ut_params = &unittest_params;
11998 : : struct rte_security_tls_record_xform tls_record_xform;
11999 : : struct rte_security_capability_idx sec_cap_idx;
12000 : : const struct rte_security_capability *sec_cap;
12001 : : struct tls_record_test_data *res_d_tmp = NULL;
12002 : : enum rte_security_tls_sess_type sess_type;
12003 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
12004 : : struct rte_security_ctx *ctx;
12005 : : int i, ret = TEST_SUCCESS;
12006 : :
12007 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
12008 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
12009 : :
12010 : : /* Use first test data to create session */
12011 : :
12012 : : /* Copy TLS record xform */
12013 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
12014 : :
12015 : 0 : sess_type = tls_record_xform.type;
12016 : :
12017 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12018 : :
12019 : 0 : sec_cap_idx.action = ut_params->type;
12020 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
12021 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
12022 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
12023 : :
12024 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
12025 [ # # ]: 0 : if (sec_cap == NULL)
12026 : : return TEST_SKIPPED;
12027 : :
12028 : : /* Copy cipher session parameters */
12029 [ # # ]: 0 : if (td[0].aead) {
12030 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
12031 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
12032 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
12033 : :
12034 : : /* Verify crypto capabilities */
12035 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
12036 [ # # ]: 0 : if (!silent)
12037 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
12038 : 0 : return TEST_SKIPPED;
12039 : : }
12040 : : } else {
12041 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
12042 : : sizeof(ut_params->cipher_xform));
12043 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
12044 : : sizeof(ut_params->auth_xform));
12045 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
12046 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12047 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
12048 : :
12049 : : /* Verify crypto capabilities */
12050 : :
12051 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
12052 [ # # ]: 0 : if (!silent)
12053 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
12054 : 0 : return TEST_SKIPPED;
12055 : : }
12056 : :
12057 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
12058 [ # # ]: 0 : if (!silent)
12059 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
12060 : 0 : return TEST_SKIPPED;
12061 : : }
12062 : : }
12063 : :
12064 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
12065 : : return TEST_SKIPPED;
12066 : :
12067 : 0 : struct rte_security_session_conf sess_conf = {
12068 : 0 : .action_type = ut_params->type,
12069 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
12070 : : };
12071 : :
12072 : : if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
12073 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
12074 : : sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
12075 : :
12076 [ # # ]: 0 : if (td[0].aead)
12077 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
12078 : :
12079 [ # # ]: 0 : if (flags->opt_padding)
12080 : 0 : tls_record_xform.options.extra_padding_enable = 1;
12081 : :
12082 : 0 : sess_conf.tls_record = tls_record_xform;
12083 : :
12084 [ # # ]: 0 : if (td[0].aead) {
12085 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
12086 : : } else {
12087 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
12088 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
12089 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
12090 : : } else {
12091 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
12092 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
12093 : : }
12094 : : }
12095 : :
12096 [ # # ]: 0 : if (ut_params->sec_session == NULL) {
12097 : : /* Create security session */
12098 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
12099 : : ts_params->session_mpool);
12100 : : }
12101 : :
12102 [ # # ]: 0 : if (ut_params->sec_session == NULL)
12103 : : return TEST_SKIPPED;
12104 : :
12105 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
12106 [ # # # # ]: 0 : if (flags->ar_win_size &&
12107 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
12108 : 0 : sess_conf.tls_record.dtls_1_2.seq_no =
12109 : 0 : td[i].tls_record_xform.dtls_1_2.seq_no;
12110 : 0 : ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
12111 [ # # ]: 0 : if (ret) {
12112 : : printf("Could not update sequence number in session\n");
12113 : 0 : return TEST_SKIPPED;
12114 : : }
12115 : : }
12116 : :
12117 : : /* Setup source mbuf payload */
12118 : 0 : ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12119 : 0 : ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
12120 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
12121 [ # # ]: 0 : if (flags->out_of_place)
12122 : 0 : ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12123 : 0 : ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
12124 : : 0);
12125 : : else
12126 : 0 : ut_params->obuf = NULL;
12127 : :
12128 : : /* Generate crypto op data structure */
12129 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12130 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12131 [ # # ]: 0 : if (ut_params->op == NULL) {
12132 : : printf("Could not allocate crypto op");
12133 : : ret = TEST_FAILED;
12134 : 0 : goto crypto_op_free;
12135 : : }
12136 : :
12137 : : /* Attach session to operation */
12138 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
12139 : :
12140 : : /* Set crypto operation mbufs */
12141 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12142 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12143 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
12144 : :
12145 [ # # ]: 0 : if (flags->opt_padding)
12146 : 0 : ut_params->op->aux_flags = flags->opt_padding;
12147 : :
12148 : : /* Copy IV in crypto operation when IV generation is disabled */
12149 [ # # ]: 0 : if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12150 [ # # ]: 0 : (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12151 [ # # ]: 0 : (tls_record_xform.options.iv_gen_disable == 1)) {
12152 : : uint8_t *iv;
12153 : : int len;
12154 : :
12155 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12156 [ # # ]: 0 : if (td[i].aead)
12157 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
12158 : : else
12159 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
12160 : 0 : memcpy(iv, td[i].iv.data, len);
12161 : : }
12162 : :
12163 : : /* Process crypto operation */
12164 : 0 : process_crypto_request(dev_id, ut_params->op);
12165 : :
12166 : 0 : ret = test_tls_record_status_check(ut_params->op, &td[i]);
12167 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12168 : 0 : goto crypto_op_free;
12169 : :
12170 [ # # ]: 0 : if (res_d != NULL)
12171 : 0 : res_d_tmp = &res_d[i];
12172 : :
12173 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12174 [ # # ]: 0 : struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12175 : : ut_params->ibuf;
12176 : :
12177 : 0 : ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12178 : : silent, flags);
12179 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12180 : 0 : goto crypto_op_free;
12181 : : }
12182 : :
12183 : 0 : rte_crypto_op_free(ut_params->op);
12184 : 0 : ut_params->op = NULL;
12185 : :
12186 [ # # ]: 0 : if (flags->out_of_place) {
12187 : 0 : rte_pktmbuf_free(ut_params->obuf);
12188 : 0 : ut_params->obuf = NULL;
12189 : : }
12190 : :
12191 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12192 : 0 : ut_params->ibuf = NULL;
12193 : : }
12194 : :
12195 : 0 : crypto_op_free:
12196 : 0 : rte_crypto_op_free(ut_params->op);
12197 : 0 : ut_params->op = NULL;
12198 : :
12199 [ # # ]: 0 : if (flags->out_of_place) {
12200 : 0 : rte_pktmbuf_free(ut_params->obuf);
12201 : 0 : ut_params->obuf = NULL;
12202 : : }
12203 : :
12204 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12205 : 0 : ut_params->ibuf = NULL;
12206 : :
12207 [ # # # # ]: 0 : if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12208 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
12209 : 0 : ut_params->sec_session = NULL;
12210 : : }
12211 : :
12212 : : RTE_SET_USED(flags);
12213 : :
12214 : : return ret;
12215 : : }
12216 : :
12217 : : static int
12218 : 0 : test_tls_record_proto_known_vec(const void *test_data)
12219 : : {
12220 : : struct tls_record_test_data td_write;
12221 : : struct tls_record_test_flags flags;
12222 : :
12223 : : memset(&flags, 0, sizeof(flags));
12224 : :
12225 : : memcpy(&td_write, test_data, sizeof(td_write));
12226 : :
12227 : : /* Disable IV gen to be able to test with known vectors */
12228 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
12229 : :
12230 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12231 : : }
12232 : :
12233 : : static int
12234 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
12235 : : {
12236 : : const struct tls_record_test_data *td = test_data;
12237 : : struct tls_record_test_flags flags;
12238 : : struct tls_record_test_data td_inb;
12239 : :
12240 : : memset(&flags, 0, sizeof(flags));
12241 : :
12242 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12243 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
12244 : : else
12245 : : memcpy(&td_inb, td, sizeof(td_inb));
12246 : :
12247 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12248 : : }
12249 : :
12250 : : static int
12251 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12252 : : {
12253 : : unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12254 : : struct crypto_unittest_params *ut_params = &unittest_params;
12255 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12256 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12257 : : void *sec_session_outb = NULL;
12258 : : void *sec_session_inb = NULL;
12259 : : int ret;
12260 : :
12261 [ # # # ]: 0 : switch (flags->tls_version) {
12262 : : case RTE_SECURITY_VERSION_TLS_1_2:
12263 : : max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12264 : : break;
12265 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
12266 : : max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12267 : 0 : break;
12268 : : case RTE_SECURITY_VERSION_DTLS_1_2:
12269 : : max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12270 : : break;
12271 : 0 : default:
12272 : : max_payload_len = 0;
12273 : : }
12274 : :
12275 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12276 : : payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12277 [ # # ]: 0 : if (flags->nb_segs_in_mbuf)
12278 : 0 : payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12279 : :
12280 [ # # ]: 0 : if (flags->zero_len)
12281 : : payload_len = 0;
12282 : 0 : again:
12283 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12284 : : flags, td_outb, nb_pkts, payload_len);
12285 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12286 : 0 : continue;
12287 : :
12288 [ # # ]: 0 : if (flags->skip_sess_destroy)
12289 : 0 : ut_params->sec_session = sec_session_outb;
12290 : :
12291 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12292 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12293 : 0 : continue;
12294 : :
12295 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_outb == NULL)
12296 : 0 : sec_session_outb = ut_params->sec_session;
12297 : :
12298 [ # # # # ]: 0 : if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
12299 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12300 : : return TEST_FAILED;
12301 : 0 : goto skip_decrypt;
12302 [ # # ]: 0 : } else if (ret == TEST_FAILED) {
12303 : : return TEST_FAILED;
12304 : : }
12305 : :
12306 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12307 : :
12308 [ # # ]: 0 : if (flags->skip_sess_destroy)
12309 : 0 : ut_params->sec_session = sec_session_inb;
12310 : :
12311 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12312 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12313 : 0 : continue;
12314 : :
12315 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_inb == NULL)
12316 : 0 : sec_session_inb = ut_params->sec_session;
12317 : :
12318 [ # # # # ]: 0 : if (flags->pkt_corruption || flags->padding_corruption) {
12319 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12320 : : return TEST_FAILED;
12321 : : } else {
12322 [ # # ]: 0 : if (ret == TEST_FAILED)
12323 : : return TEST_FAILED;
12324 : : }
12325 : :
12326 : 0 : skip_decrypt:
12327 [ # # # # ]: 0 : if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12328 : 0 : goto again;
12329 : :
12330 [ # # ]: 0 : if (flags->display_alg)
12331 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12332 : :
12333 [ # # ]: 0 : if (flags->skip_sess_destroy) {
12334 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
12335 : : struct rte_security_ctx *ctx;
12336 : :
12337 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12338 [ # # ]: 0 : if (sec_session_inb != NULL) {
12339 : 0 : rte_security_session_destroy(ctx, sec_session_inb);
12340 : : sec_session_inb = NULL;
12341 : : }
12342 [ # # ]: 0 : if (sec_session_outb != NULL) {
12343 : 0 : rte_security_session_destroy(ctx, sec_session_outb);
12344 : : sec_session_outb = NULL;
12345 : : }
12346 : 0 : ut_params->sec_session = NULL;
12347 : : }
12348 : :
12349 : 0 : pass_cnt++;
12350 : : }
12351 : :
12352 [ # # ]: 0 : if (flags->data_walkthrough)
12353 : : printf("\t Min payload size: %d, Max payload size: %d\n",
12354 : : TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
12355 : :
12356 [ # # ]: 0 : if (pass_cnt > 0)
12357 : : return TEST_SUCCESS;
12358 : : else
12359 : 0 : return TEST_SKIPPED;
12360 : : }
12361 : :
12362 : : static int
12363 : 0 : test_tls_1_2_record_proto_data_walkthrough(void)
12364 : : {
12365 : : struct tls_record_test_flags flags;
12366 : :
12367 : : memset(&flags, 0, sizeof(flags));
12368 : :
12369 : 0 : flags.data_walkthrough = true;
12370 : 0 : flags.skip_sess_destroy = true;
12371 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12372 : :
12373 : 0 : return test_tls_record_proto_all(&flags);
12374 : : }
12375 : :
12376 : : static int
12377 : 0 : test_tls_1_2_record_proto_display_list(void)
12378 : : {
12379 : : struct tls_record_test_flags flags;
12380 : :
12381 : : memset(&flags, 0, sizeof(flags));
12382 : :
12383 : 0 : flags.display_alg = true;
12384 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12385 : :
12386 : 0 : return test_tls_record_proto_all(&flags);
12387 : : }
12388 : :
12389 : : static int
12390 : 0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12391 : : {
12392 : 0 : struct tls_record_test_flags flags = {
12393 : : .nb_segs_in_mbuf = 5,
12394 : : .tls_version = tls_version
12395 : : };
12396 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12397 : : struct rte_cryptodev_info dev_info;
12398 : :
12399 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12400 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12401 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12402 : 0 : return TEST_SKIPPED;
12403 : : }
12404 : :
12405 : 0 : return test_tls_record_proto_all(&flags);
12406 : : }
12407 : :
12408 : : static int
12409 : 0 : test_tls_1_2_record_proto_sgl(void)
12410 : : {
12411 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12412 : : }
12413 : :
12414 : : static int
12415 : 0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12416 : : {
12417 : 0 : struct tls_record_test_flags flags = {
12418 : : .nb_segs_in_mbuf = 5,
12419 : : .tls_version = tls_version,
12420 : : .skip_sess_destroy = true,
12421 : : .data_walkthrough = true
12422 : : };
12423 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12424 : : struct rte_cryptodev_info dev_info;
12425 : :
12426 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12427 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12428 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12429 : 0 : return TEST_SKIPPED;
12430 : : }
12431 : :
12432 : 0 : return test_tls_record_proto_all(&flags);
12433 : : }
12434 : :
12435 : : static int
12436 : 0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12437 : : {
12438 : 0 : struct tls_record_test_flags flags = {
12439 : : .nb_segs_in_mbuf = 5,
12440 : : .out_of_place = true,
12441 : : .tls_version = tls_version
12442 : : };
12443 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12444 : : struct rte_cryptodev_info dev_info;
12445 : :
12446 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12447 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12448 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12449 : 0 : return TEST_SKIPPED;
12450 : : }
12451 : :
12452 : 0 : return test_tls_record_proto_all(&flags);
12453 : : }
12454 : :
12455 : : static int
12456 : 0 : test_tls_1_2_record_proto_sgl_oop(void)
12457 : : {
12458 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12459 : : }
12460 : :
12461 : : static int
12462 : 0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12463 : : {
12464 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12465 : : }
12466 : :
12467 : : static int
12468 : 0 : test_tls_record_proto_corrupt_pkt(void)
12469 : : {
12470 : 0 : struct tls_record_test_flags flags = {
12471 : : .pkt_corruption = 1
12472 : : };
12473 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12474 : : struct rte_cryptodev_info dev_info;
12475 : :
12476 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12477 : :
12478 : 0 : return test_tls_record_proto_all(&flags);
12479 : : }
12480 : :
12481 : : static int
12482 : 0 : test_tls_record_proto_custom_content_type(void)
12483 : : {
12484 : 0 : struct tls_record_test_flags flags = {
12485 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12486 : : };
12487 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12488 : : struct rte_cryptodev_info dev_info;
12489 : :
12490 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12491 : :
12492 : 0 : return test_tls_record_proto_all(&flags);
12493 : : }
12494 : :
12495 : : static int
12496 : 0 : test_tls_record_proto_zero_len(void)
12497 : : {
12498 : 0 : struct tls_record_test_flags flags = {
12499 : : .zero_len = 1
12500 : : };
12501 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12502 : : struct rte_cryptodev_info dev_info;
12503 : :
12504 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12505 : :
12506 : 0 : return test_tls_record_proto_all(&flags);
12507 : : }
12508 : :
12509 : : static int
12510 : 0 : test_tls_record_proto_zero_len_non_app(void)
12511 : : {
12512 : 0 : struct tls_record_test_flags flags = {
12513 : : .zero_len = 1,
12514 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12515 : : };
12516 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12517 : : struct rte_cryptodev_info dev_info;
12518 : :
12519 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12520 : :
12521 : 0 : return test_tls_record_proto_all(&flags);
12522 : : }
12523 : :
12524 : : static int
12525 : 0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12526 : : enum rte_security_tls_version tls_version)
12527 : : {
12528 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12529 : : struct rte_cryptodev_info dev_info;
12530 : 0 : struct tls_record_test_flags flags = {
12531 : : .nb_segs_in_mbuf = num_segs,
12532 : : .tls_version = tls_version,
12533 : : .opt_padding = padding
12534 : : };
12535 : :
12536 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12537 : :
12538 : 0 : return test_tls_record_proto_all(&flags);
12539 : : }
12540 : :
12541 : : static int
12542 : 0 : test_tls_record_proto_dm_opt_padding(void)
12543 : : {
12544 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12545 : : }
12546 : :
12547 : : static int
12548 : 0 : test_tls_record_proto_dm_opt_padding_1(void)
12549 : : {
12550 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12551 : : }
12552 : :
12553 : : static int
12554 : 0 : test_tls_record_proto_sg_opt_padding(void)
12555 : : {
12556 : 0 : return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12557 : : }
12558 : :
12559 : : static int
12560 : 0 : test_tls_record_proto_sg_opt_padding_1(void)
12561 : : {
12562 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12563 : : }
12564 : :
12565 : : static int
12566 : 0 : test_tls_record_proto_sg_opt_padding_2(void)
12567 : : {
12568 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12569 : : }
12570 : :
12571 : : static int
12572 : 0 : test_tls_record_proto_sg_opt_padding_max(void)
12573 : : {
12574 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12575 : : }
12576 : :
12577 : : static int
12578 : 0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
12579 : : {
12580 : 0 : struct tls_record_test_flags flags = {
12581 : : .opt_padding = 8,
12582 : : .padding_corruption = true,
12583 : : .nb_segs_in_mbuf = 4,
12584 : : };
12585 : :
12586 : 0 : return test_tls_record_proto_all(&flags);
12587 : : }
12588 : :
12589 : : static int
12590 : 0 : test_dtls_1_2_record_proto_data_walkthrough(void)
12591 : : {
12592 : : struct tls_record_test_flags flags;
12593 : :
12594 : : memset(&flags, 0, sizeof(flags));
12595 : :
12596 : 0 : flags.data_walkthrough = true;
12597 : 0 : flags.skip_sess_destroy = true;
12598 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12599 : :
12600 : 0 : return test_tls_record_proto_all(&flags);
12601 : : }
12602 : :
12603 : : static int
12604 : 0 : test_dtls_1_2_record_proto_display_list(void)
12605 : : {
12606 : : struct tls_record_test_flags flags;
12607 : :
12608 : : memset(&flags, 0, sizeof(flags));
12609 : :
12610 : 0 : flags.display_alg = true;
12611 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12612 : :
12613 : 0 : return test_tls_record_proto_all(&flags);
12614 : : }
12615 : :
12616 : : static int
12617 : 0 : test_dtls_pkt_replay(const uint64_t seq_no[],
12618 : : bool replayed_pkt[], uint32_t nb_pkts,
12619 : : struct tls_record_test_flags *flags)
12620 : : {
12621 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12622 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12623 : : unsigned int i, idx, pass_cnt = 0;
12624 : : int ret;
12625 : :
12626 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12627 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12628 : : flags, td_outb, nb_pkts, 0);
12629 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12630 : 0 : continue;
12631 : :
12632 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++)
12633 : 0 : td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12634 : :
12635 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12636 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12637 : 0 : continue;
12638 : :
12639 [ # # ]: 0 : if (ret == TEST_FAILED)
12640 : : return TEST_FAILED;
12641 : :
12642 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12643 : :
12644 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
12645 : 0 : td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12646 : : /* Set antireplay flag for packets to be dropped */
12647 : 0 : td_inb[idx].ar_packet = replayed_pkt[idx];
12648 : : }
12649 : :
12650 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12651 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12652 : 0 : continue;
12653 : :
12654 [ # # ]: 0 : if (ret == TEST_FAILED)
12655 : : return TEST_FAILED;
12656 : :
12657 [ # # ]: 0 : if (flags->display_alg)
12658 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12659 : :
12660 : 0 : pass_cnt++;
12661 : : }
12662 : :
12663 [ # # ]: 0 : if (pass_cnt > 0)
12664 : : return TEST_SUCCESS;
12665 : : else
12666 : 0 : return TEST_SKIPPED;
12667 : : }
12668 : :
12669 : : static int
12670 : 0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12671 : : {
12672 : : struct tls_record_test_flags flags;
12673 : : uint32_t nb_pkts = 5;
12674 : : bool replayed_pkt[5];
12675 : : uint64_t seq_no[5];
12676 : :
12677 : : memset(&flags, 0, sizeof(flags));
12678 : :
12679 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12680 : 0 : flags.ar_win_size = winsz;
12681 : :
12682 : : /* 1. Advance the TOP of the window to WS * 2 */
12683 : 0 : seq_no[0] = winsz * 2;
12684 : : /* 2. Test sequence number within the new window(WS + 1) */
12685 : 0 : seq_no[1] = winsz + 1;
12686 : : /* 3. Test sequence number less than the window BOTTOM */
12687 : 0 : seq_no[2] = winsz;
12688 : : /* 4. Test sequence number in the middle of the window */
12689 : 0 : seq_no[3] = winsz + (winsz / 2);
12690 : : /* 5. Test replay of the packet in the middle of the window */
12691 : 0 : seq_no[4] = winsz + (winsz / 2);
12692 : :
12693 : 0 : replayed_pkt[0] = false;
12694 : 0 : replayed_pkt[1] = false;
12695 : 0 : replayed_pkt[2] = true;
12696 : 0 : replayed_pkt[3] = false;
12697 : 0 : replayed_pkt[4] = true;
12698 : :
12699 : 0 : return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12700 : : }
12701 : :
12702 : : static int
12703 : 0 : test_dtls_1_2_record_proto_antireplay64(void)
12704 : : {
12705 : 0 : return test_dtls_1_2_record_proto_antireplay(64);
12706 : : }
12707 : :
12708 : : static int
12709 : 0 : test_dtls_1_2_record_proto_antireplay128(void)
12710 : : {
12711 : 0 : return test_dtls_1_2_record_proto_antireplay(128);
12712 : : }
12713 : :
12714 : : static int
12715 : 0 : test_dtls_1_2_record_proto_antireplay256(void)
12716 : : {
12717 : 0 : return test_dtls_1_2_record_proto_antireplay(256);
12718 : : }
12719 : :
12720 : : static int
12721 : 0 : test_dtls_1_2_record_proto_antireplay512(void)
12722 : : {
12723 : 0 : return test_dtls_1_2_record_proto_antireplay(512);
12724 : : }
12725 : :
12726 : : static int
12727 : 0 : test_dtls_1_2_record_proto_antireplay1024(void)
12728 : : {
12729 : 0 : return test_dtls_1_2_record_proto_antireplay(1024);
12730 : : }
12731 : :
12732 : : static int
12733 : 0 : test_dtls_1_2_record_proto_antireplay2048(void)
12734 : : {
12735 : 0 : return test_dtls_1_2_record_proto_antireplay(2048);
12736 : : }
12737 : :
12738 : : static int
12739 : 0 : test_dtls_1_2_record_proto_antireplay4096(void)
12740 : : {
12741 : 0 : return test_dtls_1_2_record_proto_antireplay(4096);
12742 : : }
12743 : :
12744 : : static int
12745 : 0 : test_dtls_1_2_record_proto_sgl(void)
12746 : : {
12747 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12748 : : }
12749 : :
12750 : : static int
12751 : 0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12752 : : {
12753 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12754 : : }
12755 : :
12756 : : static int
12757 : 0 : test_dtls_1_2_record_proto_sgl_oop(void)
12758 : : {
12759 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12760 : : }
12761 : :
12762 : : static int
12763 : 0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
12764 : : {
12765 : 0 : struct tls_record_test_flags flags = {
12766 : : .pkt_corruption = 1,
12767 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12768 : : };
12769 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12770 : : struct rte_cryptodev_info dev_info;
12771 : :
12772 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12773 : :
12774 : 0 : return test_tls_record_proto_all(&flags);
12775 : : }
12776 : :
12777 : : static int
12778 : 0 : test_dtls_1_2_record_proto_custom_content_type(void)
12779 : : {
12780 : 0 : struct tls_record_test_flags flags = {
12781 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12782 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12783 : : };
12784 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12785 : : struct rte_cryptodev_info dev_info;
12786 : :
12787 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12788 : :
12789 : 0 : return test_tls_record_proto_all(&flags);
12790 : : }
12791 : :
12792 : : static int
12793 : 0 : test_dtls_1_2_record_proto_zero_len(void)
12794 : : {
12795 : 0 : struct tls_record_test_flags flags = {
12796 : : .zero_len = 1,
12797 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12798 : : };
12799 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12800 : : struct rte_cryptodev_info dev_info;
12801 : :
12802 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12803 : :
12804 : 0 : return test_tls_record_proto_all(&flags);
12805 : : }
12806 : :
12807 : : static int
12808 : 0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
12809 : : {
12810 : 0 : struct tls_record_test_flags flags = {
12811 : : .zero_len = 1,
12812 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12813 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12814 : : };
12815 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12816 : : struct rte_cryptodev_info dev_info;
12817 : :
12818 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12819 : :
12820 : 0 : return test_tls_record_proto_all(&flags);
12821 : : }
12822 : :
12823 : : static int
12824 : 0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
12825 : : {
12826 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12827 : : }
12828 : :
12829 : : static int
12830 : 0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12831 : : {
12832 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12833 : : }
12834 : :
12835 : : static int
12836 : 0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
12837 : : {
12838 : 0 : return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12839 : : }
12840 : :
12841 : : static int
12842 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12843 : : {
12844 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12845 : : }
12846 : :
12847 : : static int
12848 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12849 : : {
12850 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12851 : : }
12852 : :
12853 : : static int
12854 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12855 : : {
12856 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12857 : : }
12858 : :
12859 : : static int
12860 : 0 : test_tls_1_3_record_proto_display_list(void)
12861 : : {
12862 : : struct tls_record_test_flags flags;
12863 : :
12864 : : memset(&flags, 0, sizeof(flags));
12865 : :
12866 : 0 : flags.display_alg = true;
12867 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12868 : :
12869 : 0 : return test_tls_record_proto_all(&flags);
12870 : : }
12871 : :
12872 : : static int
12873 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12874 : : {
12875 : 0 : struct tls_record_test_flags flags = {
12876 : : .opt_padding = 8,
12877 : : .padding_corruption = true,
12878 : : .nb_segs_in_mbuf = 4,
12879 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12880 : : };
12881 : :
12882 : 0 : return test_tls_record_proto_all(&flags);
12883 : : }
12884 : :
12885 : : static int
12886 : 0 : test_tls_1_3_record_proto_corrupt_pkt(void)
12887 : : {
12888 : 0 : struct tls_record_test_flags flags = {
12889 : : .pkt_corruption = 1,
12890 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12891 : : };
12892 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12893 : : struct rte_cryptodev_info dev_info;
12894 : :
12895 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12896 : :
12897 : 0 : return test_tls_record_proto_all(&flags);
12898 : : }
12899 : :
12900 : : static int
12901 : 0 : test_tls_1_3_record_proto_custom_content_type(void)
12902 : : {
12903 : 0 : struct tls_record_test_flags flags = {
12904 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12905 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12906 : : };
12907 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12908 : : struct rte_cryptodev_info dev_info;
12909 : :
12910 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12911 : :
12912 : 0 : return test_tls_record_proto_all(&flags);
12913 : : }
12914 : :
12915 : : static int
12916 : 0 : test_tls_1_3_record_proto_zero_len(void)
12917 : : {
12918 : 0 : struct tls_record_test_flags flags = {
12919 : : .zero_len = 1,
12920 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12921 : : };
12922 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12923 : : struct rte_cryptodev_info dev_info;
12924 : :
12925 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12926 : :
12927 : 0 : return test_tls_record_proto_all(&flags);
12928 : : }
12929 : :
12930 : : static int
12931 : 0 : test_tls_1_3_record_proto_zero_len_non_app(void)
12932 : : {
12933 : 0 : struct tls_record_test_flags flags = {
12934 : : .zero_len = 1,
12935 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12936 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12937 : : };
12938 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12939 : : struct rte_cryptodev_info dev_info;
12940 : :
12941 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12942 : :
12943 : 0 : return test_tls_record_proto_all(&flags);
12944 : : }
12945 : :
12946 : : static int
12947 : 0 : test_tls_1_3_record_proto_dm_opt_padding(void)
12948 : : {
12949 : 0 : return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12950 : : }
12951 : :
12952 : : static int
12953 : 0 : test_tls_1_3_record_proto_sg_opt_padding(void)
12954 : : {
12955 : 0 : return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12956 : : }
12957 : :
12958 : : static int
12959 : 0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
12960 : : {
12961 : 0 : return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12962 : : }
12963 : :
12964 : : static int
12965 : 0 : test_tls_1_3_record_proto_data_walkthrough(void)
12966 : : {
12967 : : struct tls_record_test_flags flags;
12968 : :
12969 : : memset(&flags, 0, sizeof(flags));
12970 : :
12971 : 0 : flags.data_walkthrough = true;
12972 : 0 : flags.skip_sess_destroy = true;
12973 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12974 : :
12975 : 0 : return test_tls_record_proto_all(&flags);
12976 : : }
12977 : :
12978 : : static int
12979 : 0 : test_tls_1_3_record_proto_sgl(void)
12980 : : {
12981 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
12982 : : }
12983 : :
12984 : : static int
12985 : 0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
12986 : : {
12987 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
12988 : : }
12989 : :
12990 : : static int
12991 : 0 : test_tls_1_3_record_proto_sgl_oop(void)
12992 : : {
12993 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
12994 : : }
12995 : :
12996 : : #endif
12997 : :
12998 : : static int
12999 : 1 : test_cryptodev_error_recover_helper_check(void)
13000 : : {
13001 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13002 : : struct rte_cryptodev_info dev_info;
13003 : : uint64_t feat_flags;
13004 : : int ret;
13005 : :
13006 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13007 : 1 : feat_flags = dev_info.feature_flags;
13008 : :
13009 : : /* Skip the test if queue pair reset is not supported */
13010 : 1 : ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
13011 [ - + ]: 1 : if (ret == -ENOTSUP)
13012 : : return TEST_SKIPPED;
13013 : :
13014 [ # # ]: 0 : ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
13015 [ # # ]: 0 : if (ret == -ENOTSUP)
13016 : 0 : return TEST_SKIPPED;
13017 : :
13018 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
13019 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13020 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13021 : 0 : RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
13022 : 0 : return TEST_SKIPPED;
13023 : : }
13024 : :
13025 : : return 0;
13026 : : }
13027 : :
13028 : : static int
13029 : 0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
13030 : : {
13031 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13032 : : struct crypto_unittest_params *ut_params = &unittest_params;
13033 : : const struct blockcipher_test_data *tdata = test_data;
13034 : 0 : uint8_t *cipher_key = alloca(tdata->cipher_key.len);
13035 : : struct rte_crypto_sym_op *sym_op = NULL;
13036 : : struct rte_crypto_op *op = NULL;
13037 : : char *dst;
13038 : :
13039 : 0 : memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
13040 : 0 : ut_params->cipher_xform.next = NULL;
13041 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13042 : 0 : ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
13043 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13044 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
13045 : 0 : ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
13046 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13047 : 0 : ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
13048 : :
13049 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
13050 : : ts_params->session_mpool);
13051 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13052 : : return TEST_SKIPPED;
13053 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13054 : :
13055 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13056 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
13057 : :
13058 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
13059 [ # # ]: 0 : tdata->iv.len);
13060 : : sym_op = ut_params->op->sym;
13061 : 0 : sym_op->cipher.data.offset = tdata->cipher_offset;
13062 : 0 : sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
13063 : :
13064 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13065 : :
13066 [ # # ]: 0 : if (generate_err) {
13067 : 0 : ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
13068 [ # # ]: 0 : if (ut_params->ibuf == NULL)
13069 : : return TEST_FAILED;
13070 : 0 : crypto_err = CRYPTODEV_ERR_TRIGGERED;
13071 : : } else {
13072 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13073 : : }
13074 : :
13075 : : /* clear mbuf payload */
13076 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13077 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
13078 : :
13079 : 0 : dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
13080 : 0 : memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
13081 : :
13082 : 0 : sym_op->m_src = ut_params->ibuf;
13083 : 0 : sym_op->m_dst = NULL;
13084 : :
13085 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
13086 : :
13087 [ # # ]: 0 : if (generate_err) {
13088 : 0 : free(ut_params->ibuf);
13089 : 0 : ut_params->ibuf = NULL;
13090 [ # # ]: 0 : if (op == NULL) {
13091 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13092 : 0 : ut_params->sess = NULL;
13093 : 0 : return TEST_SUCCESS;
13094 : : } else {
13095 : : return TEST_FAILED;
13096 : : }
13097 : : }
13098 : :
13099 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13100 : : "crypto op processing failed");
13101 : :
13102 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
13103 : : tdata->ciphertext.len - tdata->cipher_offset,
13104 : : "Data not as expected");
13105 : :
13106 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13107 : 0 : ut_params->sess = NULL;
13108 : :
13109 : 0 : return TEST_SUCCESS;
13110 : : }
13111 : :
13112 : : /*
13113 : : * This unit test verifies the recovery of the cryptodev from any fatal error.
13114 : : * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
13115 : : * for every call to helper function.
13116 : : *
13117 : : * When the flag is set to 0, the helper function verifies the test data without generating any
13118 : : * errors, i.e: verifies the default behaviour of the cryptodev.
13119 : : *
13120 : : * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
13121 : : * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
13122 : : * is generated, it waits till the cryptodev is recoverd from the error.
13123 : : *
13124 : : * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
13125 : : * of cryptodev after the recovery.
13126 : : */
13127 : : static int
13128 : 1 : test_cryptodev_verify_error_recover(const void *test_data)
13129 : : {
13130 : : int ret = TEST_FAILED;
13131 : : int i, num_itr = 5;
13132 : :
13133 : 1 : ret = test_cryptodev_error_recover_helper_check();
13134 [ - + ]: 1 : if (ret)
13135 : : return ret;
13136 : :
13137 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
13138 : : RTE_CRYPTODEV_EVENT_ERROR,
13139 : : test_cryptodev_error_cb, NULL),
13140 : : "Failed to register Cryptodev callback");
13141 : :
13142 [ # # ]: 0 : for (i = 0; i < num_itr; i++) {
13143 : : int ticks = 0;
13144 : :
13145 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13146 : : test_data, false);
13147 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13148 : :
13149 : : /* Generate Error */
13150 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13151 : : test_data, true);
13152 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13153 : :
13154 : : /* Wait till cryptodev recovered from error */
13155 [ # # ]: 0 : while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
13156 : : rte_delay_ms(10);
13157 [ # # ]: 0 : if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
13158 : : return TEST_FAILED;
13159 : : }
13160 : : }
13161 [ # # ]: 0 : TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
13162 : :
13163 : : return ret;
13164 : : }
13165 : :
13166 : : static int
13167 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
13168 : : {
13169 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
13170 : : }
13171 : :
13172 : : static int
13173 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
13174 : : {
13175 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
13176 : : }
13177 : :
13178 : : static int
13179 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
13180 : : {
13181 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
13182 : : }
13183 : :
13184 : : static int
13185 : 1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
13186 : : {
13187 : 1 : return test_authenticated_encryption_helper(&gcm_test_case_3, true);
13188 : : }
13189 : :
13190 : : static int
13191 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
13192 : : {
13193 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
13194 : : }
13195 : :
13196 : : static int
13197 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
13198 : : {
13199 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
13200 : : }
13201 : :
13202 : : static int
13203 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
13204 : : {
13205 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
13206 : : }
13207 : :
13208 : : static int
13209 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
13210 : : {
13211 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
13212 : : }
13213 : :
13214 : : static int
13215 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
13216 : : {
13217 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
13218 : : }
13219 : :
13220 : : static int
13221 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
13222 : : {
13223 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
13224 : : }
13225 : :
13226 : : static int
13227 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
13228 : : {
13229 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
13230 : : }
13231 : :
13232 : : static int
13233 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
13234 : : {
13235 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
13236 : : }
13237 : :
13238 : : static int
13239 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
13240 : : {
13241 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
13242 : : }
13243 : :
13244 : : static int
13245 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
13246 : : {
13247 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
13248 : : }
13249 : :
13250 : : static int
13251 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
13252 : : {
13253 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
13254 : : }
13255 : :
13256 : : static int
13257 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
13258 : : {
13259 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
13260 : : }
13261 : :
13262 : : static int
13263 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
13264 : : {
13265 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
13266 : : }
13267 : :
13268 : : static int
13269 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
13270 : : {
13271 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
13272 : : }
13273 : :
13274 : : static int
13275 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
13276 : : {
13277 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
13278 : : }
13279 : :
13280 : : static int
13281 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
13282 : : {
13283 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
13284 : : }
13285 : :
13286 : : static int
13287 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
13288 : : {
13289 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
13290 : : }
13291 : :
13292 : : static int
13293 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
13294 : : {
13295 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
13296 : : }
13297 : :
13298 : : static int
13299 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
13300 : : {
13301 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
13302 : : }
13303 : :
13304 : : static int
13305 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
13306 : : {
13307 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
13308 : : }
13309 : :
13310 : : static int
13311 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
13312 : : {
13313 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
13314 : : }
13315 : :
13316 : : static int
13317 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
13318 : : {
13319 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
13320 : : }
13321 : :
13322 : : static int
13323 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13324 : : {
13325 : : struct aead_test_data tdata;
13326 : : int res;
13327 : :
13328 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13329 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13330 : 1 : tdata.iv.data[0] += 1;
13331 : : res = test_authenticated_encryption(&tdata);
13332 [ + - ]: 1 : if (res == TEST_SKIPPED)
13333 : : return res;
13334 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13335 : : return TEST_SUCCESS;
13336 : : }
13337 : :
13338 : : static int
13339 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13340 : : {
13341 : : struct aead_test_data tdata;
13342 : : int res;
13343 : :
13344 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13345 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13346 : 1 : tdata.plaintext.data[0] += 1;
13347 : : res = test_authenticated_encryption(&tdata);
13348 [ + - ]: 1 : if (res == TEST_SKIPPED)
13349 : : return res;
13350 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13351 : : return TEST_SUCCESS;
13352 : : }
13353 : :
13354 : : static int
13355 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13356 : : {
13357 : : struct aead_test_data tdata;
13358 : : int res;
13359 : :
13360 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13361 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13362 : 1 : tdata.ciphertext.data[0] += 1;
13363 : : res = test_authenticated_encryption(&tdata);
13364 [ + - ]: 1 : if (res == TEST_SKIPPED)
13365 : : return res;
13366 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13367 : : return TEST_SUCCESS;
13368 : : }
13369 : :
13370 : : static int
13371 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13372 : : {
13373 : : struct aead_test_data tdata;
13374 : : int res;
13375 : :
13376 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13377 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13378 : 1 : tdata.aad.len += 1;
13379 : : res = test_authenticated_encryption(&tdata);
13380 [ + - ]: 1 : if (res == TEST_SKIPPED)
13381 : : return res;
13382 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13383 : : return TEST_SUCCESS;
13384 : : }
13385 : :
13386 : : static int
13387 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13388 : : {
13389 : : struct aead_test_data tdata;
13390 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13391 : : int res;
13392 : :
13393 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13394 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13395 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13396 : 1 : aad[0] += 1;
13397 : 1 : tdata.aad.data = aad;
13398 : : res = test_authenticated_encryption(&tdata);
13399 [ + - ]: 1 : if (res == TEST_SKIPPED)
13400 : : return res;
13401 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13402 : : return TEST_SUCCESS;
13403 : : }
13404 : :
13405 : : static int
13406 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13407 : : {
13408 : : struct aead_test_data tdata;
13409 : : int res;
13410 : :
13411 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13412 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13413 : 1 : tdata.auth_tag.data[0] += 1;
13414 : : res = test_authenticated_encryption(&tdata);
13415 [ + - ]: 1 : if (res == TEST_SKIPPED)
13416 : : return res;
13417 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13418 : : return TEST_SUCCESS;
13419 : : }
13420 : :
13421 : : static int
13422 : 42 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13423 : : {
13424 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13425 : : struct crypto_unittest_params *ut_params = &unittest_params;
13426 : :
13427 : : int retval;
13428 : : uint8_t *plaintext;
13429 : : uint32_t i;
13430 : : struct rte_cryptodev_info dev_info;
13431 : :
13432 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13433 : 42 : uint64_t feat_flags = dev_info.feature_flags;
13434 : :
13435 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13436 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13437 : : printf("Device doesn't support RAW data-path APIs.\n");
13438 : 0 : return TEST_SKIPPED;
13439 : : }
13440 : :
13441 : : /* Verify the capabilities */
13442 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13443 : : const struct rte_cryptodev_symmetric_capability *capability;
13444 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13445 : 42 : cap_idx.algo.aead = tdata->algo;
13446 : 42 : capability = rte_cryptodev_sym_capability_get(
13447 : 42 : ts_params->valid_devs[0], &cap_idx);
13448 [ + - ]: 42 : if (capability == NULL)
13449 : : return TEST_SKIPPED;
13450 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
13451 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
13452 : 42 : tdata->aad.len, tdata->iv.len))
13453 : : return TEST_SKIPPED;
13454 : :
13455 : : /* Create AEAD session */
13456 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
13457 : 41 : tdata->algo,
13458 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13459 : 41 : tdata->key.data, tdata->key.len,
13460 : 41 : tdata->aad.len, tdata->auth_tag.len,
13461 : 41 : tdata->iv.len);
13462 [ + - ]: 41 : if (retval != TEST_SUCCESS)
13463 : : return retval;
13464 : :
13465 : : /* alloc mbuf and set payload */
13466 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
13467 [ - + ]: 2 : if (use_ext_mbuf) {
13468 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13469 : : AEAD_TEXT_MAX_LENGTH,
13470 : : 1 /* nb_segs */,
13471 : : NULL);
13472 : : } else {
13473 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13474 : : }
13475 : : /* Populate full size of add data */
13476 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13477 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13478 : : } else {
13479 [ + + ]: 39 : if (use_ext_mbuf) {
13480 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13481 : : AEAD_TEXT_MAX_LENGTH,
13482 : : 1 /* nb_segs */,
13483 : : NULL);
13484 : : } else {
13485 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13486 : : }
13487 : : }
13488 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13489 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
13490 : :
13491 : : /* Create AEAD operation */
13492 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13493 [ + - ]: 41 : if (retval < 0)
13494 : : return retval;
13495 : :
13496 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13497 : :
13498 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
13499 : :
13500 : : /* Process crypto operation */
13501 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13502 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13503 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13504 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13505 : : 0);
13506 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13507 : : return retval;
13508 : : } else
13509 [ + + ]: 41 : TEST_ASSERT_NOT_NULL(
13510 : : process_crypto_request(ts_params->valid_devs[0],
13511 : : ut_params->op), "failed to process sym crypto op");
13512 : :
13513 [ - + ]: 36 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13514 : : "crypto op processing failed");
13515 : :
13516 [ - + ]: 36 : if (ut_params->op->sym->m_dst)
13517 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13518 : : uint8_t *);
13519 : : else
13520 : 36 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13521 : : uint8_t *,
13522 : : ut_params->op->sym->cipher.data.offset);
13523 : :
13524 : 36 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13525 : :
13526 : : /* Validate obuf */
13527 [ + + ]: 37 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13528 : : plaintext,
13529 : : tdata->plaintext.data,
13530 : : tdata->plaintext.len,
13531 : : "Plaintext data not as expected");
13532 : :
13533 [ - + ]: 35 : TEST_ASSERT_EQUAL(ut_params->op->status,
13534 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13535 : : "Authentication failed");
13536 : :
13537 : : return 0;
13538 : : }
13539 : :
13540 : : static int
13541 : : test_authenticated_decryption(const struct aead_test_data *tdata)
13542 : : {
13543 : 41 : return test_authenticated_decryption_helper(tdata, false);
13544 : : }
13545 : :
13546 : : static int
13547 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
13548 : : {
13549 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
13550 : : }
13551 : :
13552 : : static int
13553 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
13554 : : {
13555 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
13556 : : }
13557 : :
13558 : : static int
13559 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
13560 : : {
13561 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
13562 : : }
13563 : :
13564 : : static int
13565 : 1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13566 : : {
13567 : 1 : return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13568 : : }
13569 : :
13570 : : static int
13571 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
13572 : : {
13573 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
13574 : : }
13575 : :
13576 : : static int
13577 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
13578 : : {
13579 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
13580 : : }
13581 : :
13582 : : static int
13583 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
13584 : : {
13585 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
13586 : : }
13587 : :
13588 : : static int
13589 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
13590 : : {
13591 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
13592 : : }
13593 : :
13594 : : static int
13595 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
13596 : : {
13597 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
13598 : : }
13599 : :
13600 : : static int
13601 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13602 : : {
13603 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
13604 : : }
13605 : :
13606 : : static int
13607 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
13608 : : {
13609 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
13610 : : }
13611 : :
13612 : : static int
13613 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
13614 : : {
13615 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
13616 : : }
13617 : :
13618 : : static int
13619 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
13620 : : {
13621 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
13622 : : }
13623 : :
13624 : : static int
13625 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
13626 : : {
13627 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
13628 : : }
13629 : :
13630 : : static int
13631 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
13632 : : {
13633 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
13634 : : }
13635 : :
13636 : : static int
13637 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
13638 : : {
13639 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
13640 : : }
13641 : :
13642 : : static int
13643 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
13644 : : {
13645 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
13646 : : }
13647 : :
13648 : : static int
13649 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
13650 : : {
13651 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
13652 : : }
13653 : :
13654 : : static int
13655 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
13656 : : {
13657 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
13658 : : }
13659 : :
13660 : : static int
13661 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
13662 : : {
13663 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
13664 : : }
13665 : :
13666 : : static int
13667 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
13668 : : {
13669 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
13670 : : }
13671 : :
13672 : : static int
13673 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
13674 : : {
13675 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
13676 : : }
13677 : :
13678 : : static int
13679 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
13680 : : {
13681 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
13682 : : }
13683 : :
13684 : : static int
13685 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
13686 : : {
13687 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
13688 : : }
13689 : :
13690 : : static int
13691 : 1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
13692 : : {
13693 : 1 : return test_authenticated_decryption(&gcm_test_case_256_8);
13694 : : }
13695 : :
13696 : : static int
13697 : 1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
13698 : : {
13699 : 1 : return test_authenticated_encryption(&gcm_test_case_256_8);
13700 : : }
13701 : :
13702 : : static int
13703 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
13704 : : {
13705 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
13706 : : }
13707 : :
13708 : : static int
13709 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
13710 : : {
13711 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
13712 : : }
13713 : :
13714 : : static int
13715 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13716 : : {
13717 : : struct aead_test_data tdata;
13718 : : int res;
13719 : :
13720 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13721 : 1 : tdata.iv.data[0] += 1;
13722 : : res = test_authenticated_decryption(&tdata);
13723 [ + - ]: 1 : if (res == TEST_SKIPPED)
13724 : : return res;
13725 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13726 : : return TEST_SUCCESS;
13727 : : }
13728 : :
13729 : : static int
13730 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13731 : : {
13732 : : struct aead_test_data tdata;
13733 : : int res;
13734 : :
13735 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13736 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13737 : 1 : tdata.plaintext.data[0] += 1;
13738 : : res = test_authenticated_decryption(&tdata);
13739 [ + - ]: 1 : if (res == TEST_SKIPPED)
13740 : : return res;
13741 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13742 : : return TEST_SUCCESS;
13743 : : }
13744 : :
13745 : : static int
13746 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13747 : : {
13748 : : struct aead_test_data tdata;
13749 : : int res;
13750 : :
13751 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13752 : 1 : tdata.ciphertext.data[0] += 1;
13753 : : res = test_authenticated_decryption(&tdata);
13754 [ + - ]: 1 : if (res == TEST_SKIPPED)
13755 : : return res;
13756 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13757 : : return TEST_SUCCESS;
13758 : : }
13759 : :
13760 : : static int
13761 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13762 : : {
13763 : : struct aead_test_data tdata;
13764 : : int res;
13765 : :
13766 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13767 : 1 : tdata.aad.len += 1;
13768 : : res = test_authenticated_decryption(&tdata);
13769 [ + - ]: 1 : if (res == TEST_SKIPPED)
13770 : : return res;
13771 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13772 : : return TEST_SUCCESS;
13773 : : }
13774 : :
13775 : : static int
13776 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13777 : : {
13778 : : struct aead_test_data tdata;
13779 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13780 : : int res;
13781 : :
13782 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13783 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13784 : 1 : aad[0] += 1;
13785 : 1 : tdata.aad.data = aad;
13786 : : res = test_authenticated_decryption(&tdata);
13787 [ + - ]: 1 : if (res == TEST_SKIPPED)
13788 : : return res;
13789 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13790 : : return TEST_SUCCESS;
13791 : : }
13792 : :
13793 : : static int
13794 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13795 : : {
13796 : : struct aead_test_data tdata;
13797 : : int res;
13798 : :
13799 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13800 : 1 : tdata.auth_tag.data[0] += 1;
13801 : : res = test_authenticated_decryption(&tdata);
13802 [ + - ]: 1 : if (res == TEST_SKIPPED)
13803 : : return res;
13804 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13805 : : return TEST_SUCCESS;
13806 : : }
13807 : :
13808 : : static int
13809 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13810 : : {
13811 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13812 : : struct crypto_unittest_params *ut_params = &unittest_params;
13813 : :
13814 : : uint32_t i;
13815 : : int retval;
13816 : : uint8_t *ciphertext, *auth_tag, *buffer_oop;
13817 : : uint16_t plaintext_pad_len;
13818 : : struct rte_cryptodev_info dev_info;
13819 : :
13820 : : /* Verify the capabilities */
13821 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13822 : : const struct rte_cryptodev_symmetric_capability *capability;
13823 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13824 : 1 : cap_idx.algo.aead = tdata->algo;
13825 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13826 [ + - ]: 1 : if (capability == NULL)
13827 : : return TEST_SKIPPED;
13828 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(
13829 : 1 : capability, tdata->key.len, tdata->auth_tag.len,
13830 : 1 : tdata->aad.len, tdata->iv.len))
13831 : : return TEST_SKIPPED;
13832 : :
13833 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13834 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13835 : :
13836 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13837 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13838 : : return TEST_SKIPPED;
13839 : :
13840 : : /* not supported with CPU crypto */
13841 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13842 : : return TEST_SKIPPED;
13843 : :
13844 : : /* Create AEAD session */
13845 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13846 : 1 : tdata->algo,
13847 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13848 : 1 : tdata->key.data, tdata->key.len,
13849 : 1 : tdata->aad.len, tdata->auth_tag.len,
13850 : 1 : tdata->iv.len);
13851 [ + - ]: 1 : if (retval < 0)
13852 : : return retval;
13853 : :
13854 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13855 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13856 : :
13857 : : /* clear mbuf payload */
13858 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13859 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13860 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13861 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13862 : :
13863 : : /* Create AEAD operation */
13864 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13865 [ + - ]: 1 : if (retval < 0)
13866 : : return retval;
13867 : :
13868 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13869 : :
13870 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13871 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13872 : :
13873 : : /* Process crypto operation */
13874 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13875 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13876 : : 0);
13877 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13878 : : return retval;
13879 : : } else
13880 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13881 : : ut_params->op), "failed to process sym crypto op");
13882 : :
13883 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13884 : : "crypto op processing failed");
13885 : :
13886 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13887 : :
13888 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13889 : : ut_params->op->sym->cipher.data.offset);
13890 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13891 : :
13892 : : /* Check if the data within the offset range is not overwritten in the OOP */
13893 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
13894 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
13895 [ - + ]: 16 : if (buffer_oop[i]) {
13896 : 0 : RTE_LOG(ERR, USER1,
13897 : : "Incorrect value of the output buffer header\n");
13898 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
13899 : 0 : ut_params->op->sym->cipher.data.offset);
13900 : 0 : return TEST_FAILED;
13901 : : }
13902 : : }
13903 : :
13904 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13905 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13906 : :
13907 : : /* Validate obuf */
13908 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13909 : : ciphertext,
13910 : : tdata->ciphertext.data,
13911 : : tdata->ciphertext.len,
13912 : : "Ciphertext data not as expected");
13913 : :
13914 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13915 : : auth_tag,
13916 : : tdata->auth_tag.data,
13917 : : tdata->auth_tag.len,
13918 : : "Generated auth tag not as expected");
13919 : :
13920 : : return 0;
13921 : :
13922 : : }
13923 : :
13924 : : static int
13925 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13926 : : {
13927 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
13928 : : }
13929 : :
13930 : : static int
13931 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13932 : : {
13933 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13934 : : struct crypto_unittest_params *ut_params = &unittest_params;
13935 : :
13936 : : uint32_t i;
13937 : : int retval;
13938 : : uint8_t *plaintext, *buffer_oop;
13939 : : struct rte_cryptodev_info dev_info;
13940 : :
13941 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13942 : : uint64_t feat_flags = dev_info.feature_flags;
13943 : :
13944 : : /* Verify the capabilities */
13945 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13946 : : const struct rte_cryptodev_symmetric_capability *capability;
13947 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13948 : 1 : cap_idx.algo.aead = tdata->algo;
13949 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13950 : :
13951 [ + - ]: 1 : if (capability == NULL)
13952 : : return TEST_SKIPPED;
13953 : :
13954 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13955 : 1 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13956 : : return TEST_SKIPPED;
13957 : :
13958 : : /* not supported with CPU crypto and raw data-path APIs*/
13959 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13960 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
13961 : : return TEST_SKIPPED;
13962 : :
13963 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13964 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13965 : : printf("Device does not support RAW data-path APIs.\n");
13966 : : return TEST_SKIPPED;
13967 : : }
13968 : :
13969 : : /* Create AEAD session */
13970 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13971 : 1 : tdata->algo,
13972 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13973 : 1 : tdata->key.data, tdata->key.len,
13974 : 1 : tdata->aad.len, tdata->auth_tag.len,
13975 : 1 : tdata->iv.len);
13976 [ + - ]: 1 : if (retval < 0)
13977 : : return retval;
13978 : :
13979 : : /* alloc mbuf and set payload */
13980 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13981 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13982 : :
13983 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13984 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13985 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13986 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13987 : :
13988 : : /* Create AEAD operation */
13989 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13990 [ + - ]: 1 : if (retval < 0)
13991 : : return retval;
13992 : :
13993 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13994 : :
13995 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13996 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13997 : :
13998 : : /* Process crypto operation */
13999 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14000 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14001 : : 0);
14002 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14003 : : return retval;
14004 : : } else
14005 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14006 : : ut_params->op), "failed to process sym crypto op");
14007 : :
14008 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14009 : : "crypto op processing failed");
14010 : :
14011 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
14012 : : ut_params->op->sym->cipher.data.offset);
14013 : :
14014 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14015 : :
14016 : : /* Check if the data within the offset range is not overwritten in the OOP */
14017 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
14018 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
14019 [ - + ]: 16 : if (buffer_oop[i]) {
14020 : 0 : RTE_LOG(ERR, USER1,
14021 : : "Incorrect value of the output buffer header\n");
14022 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
14023 : 0 : ut_params->op->sym->cipher.data.offset);
14024 : 0 : return TEST_FAILED;
14025 : : }
14026 : : }
14027 : : /* Validate obuf */
14028 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14029 : : plaintext,
14030 : : tdata->plaintext.data,
14031 : : tdata->plaintext.len,
14032 : : "Plaintext data not as expected");
14033 : :
14034 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14035 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14036 : : "Authentication failed");
14037 : : return 0;
14038 : : }
14039 : :
14040 : : static int
14041 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
14042 : : {
14043 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
14044 : : }
14045 : :
14046 : : static int
14047 : 1 : test_authenticated_encryption_sessionless(
14048 : : const struct aead_test_data *tdata)
14049 : : {
14050 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14051 : : struct crypto_unittest_params *ut_params = &unittest_params;
14052 : :
14053 : : int retval;
14054 : : uint8_t *ciphertext, *auth_tag;
14055 : : uint16_t plaintext_pad_len;
14056 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14057 : : struct rte_cryptodev_info dev_info;
14058 : :
14059 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14060 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14061 : :
14062 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14063 : : printf("Device doesn't support Sessionless ops.\n");
14064 : 0 : return TEST_SKIPPED;
14065 : : }
14066 : :
14067 : : /* not supported with CPU crypto */
14068 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14069 : : return TEST_SKIPPED;
14070 : :
14071 : : /* Verify the capabilities */
14072 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14073 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14074 : 1 : cap_idx.algo.aead = tdata->algo;
14075 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14076 : : &cap_idx) == NULL)
14077 : : return TEST_SKIPPED;
14078 : :
14079 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14080 : :
14081 : : /* clear mbuf payload */
14082 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14083 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14084 : :
14085 : : /* Create AEAD operation */
14086 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
14087 [ + - ]: 1 : if (retval < 0)
14088 : : return retval;
14089 : :
14090 : : /* Create GCM xform */
14091 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14092 : 1 : retval = create_aead_xform(ut_params->op,
14093 : 1 : tdata->algo,
14094 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
14095 : : key, tdata->key.len,
14096 : 1 : tdata->aad.len, tdata->auth_tag.len,
14097 : 1 : tdata->iv.len);
14098 [ + - ]: 1 : if (retval < 0)
14099 : : return retval;
14100 : :
14101 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14102 : :
14103 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14104 : : RTE_CRYPTO_OP_SESSIONLESS,
14105 : : "crypto op session type not sessionless");
14106 : :
14107 : : /* Process crypto operation */
14108 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14109 : : ut_params->op), "failed to process sym crypto op");
14110 : :
14111 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14112 : :
14113 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14114 : : "crypto op status not success");
14115 : :
14116 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14117 : :
14118 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14119 : : ut_params->op->sym->cipher.data.offset);
14120 : 1 : auth_tag = ciphertext + plaintext_pad_len;
14121 : :
14122 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
14123 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
14124 : :
14125 : : /* Validate obuf */
14126 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14127 : : ciphertext,
14128 : : tdata->ciphertext.data,
14129 : : tdata->ciphertext.len,
14130 : : "Ciphertext data not as expected");
14131 : :
14132 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14133 : : auth_tag,
14134 : : tdata->auth_tag.data,
14135 : : tdata->auth_tag.len,
14136 : : "Generated auth tag not as expected");
14137 : :
14138 : : return 0;
14139 : :
14140 : : }
14141 : :
14142 : : static int
14143 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
14144 : : {
14145 : 1 : return test_authenticated_encryption_sessionless(
14146 : : &gcm_test_case_5);
14147 : : }
14148 : :
14149 : : static int
14150 : 1 : test_authenticated_decryption_sessionless(
14151 : : const struct aead_test_data *tdata)
14152 : : {
14153 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14154 : : struct crypto_unittest_params *ut_params = &unittest_params;
14155 : :
14156 : : int retval;
14157 : : uint8_t *plaintext;
14158 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14159 : : struct rte_cryptodev_info dev_info;
14160 : :
14161 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14162 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14163 : :
14164 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14165 : : printf("Device doesn't support Sessionless ops.\n");
14166 : 0 : return TEST_SKIPPED;
14167 : : }
14168 : :
14169 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14170 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14171 : : printf("Device doesn't support RAW data-path APIs.\n");
14172 : 0 : return TEST_SKIPPED;
14173 : : }
14174 : :
14175 : : /* not supported with CPU crypto */
14176 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14177 : : return TEST_SKIPPED;
14178 : :
14179 : : /* Verify the capabilities */
14180 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14181 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14182 : 1 : cap_idx.algo.aead = tdata->algo;
14183 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14184 : : &cap_idx) == NULL)
14185 : : return TEST_SKIPPED;
14186 : :
14187 : : /* alloc mbuf and set payload */
14188 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14189 : :
14190 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14191 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14192 : :
14193 : : /* Create AEAD operation */
14194 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14195 [ + - ]: 1 : if (retval < 0)
14196 : : return retval;
14197 : :
14198 : : /* Create AEAD xform */
14199 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14200 : 1 : retval = create_aead_xform(ut_params->op,
14201 : 1 : tdata->algo,
14202 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
14203 : : key, tdata->key.len,
14204 : 1 : tdata->aad.len, tdata->auth_tag.len,
14205 : 1 : tdata->iv.len);
14206 [ + - ]: 1 : if (retval < 0)
14207 : : return retval;
14208 : :
14209 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14210 : :
14211 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14212 : : RTE_CRYPTO_OP_SESSIONLESS,
14213 : : "crypto op session type not sessionless");
14214 : :
14215 : : /* Process crypto operation */
14216 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14217 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14218 : : 0);
14219 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14220 : : return retval;
14221 : : } else
14222 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
14223 : : ts_params->valid_devs[0], ut_params->op),
14224 : : "failed to process sym crypto op");
14225 : :
14226 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14227 : :
14228 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14229 : : "crypto op status not success");
14230 : :
14231 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14232 : : ut_params->op->sym->cipher.data.offset);
14233 : :
14234 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14235 : :
14236 : : /* Validate obuf */
14237 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14238 : : plaintext,
14239 : : tdata->plaintext.data,
14240 : : tdata->plaintext.len,
14241 : : "Plaintext data not as expected");
14242 : :
14243 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14244 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14245 : : "Authentication failed");
14246 : : return 0;
14247 : : }
14248 : :
14249 : : static int
14250 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
14251 : : {
14252 : 1 : return test_authenticated_decryption_sessionless(
14253 : : &gcm_test_case_5);
14254 : : }
14255 : :
14256 : : static int
14257 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
14258 : : {
14259 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
14260 : : }
14261 : :
14262 : : static int
14263 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
14264 : : {
14265 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
14266 : : }
14267 : :
14268 : : static int
14269 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
14270 : : {
14271 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
14272 : : }
14273 : :
14274 : : static int
14275 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
14276 : : {
14277 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
14278 : : }
14279 : :
14280 : : static int
14281 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
14282 : : {
14283 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
14284 : : }
14285 : :
14286 : : static int
14287 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
14288 : : {
14289 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
14290 : : }
14291 : :
14292 : : static int
14293 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
14294 : : {
14295 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
14296 : : }
14297 : :
14298 : : static int
14299 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
14300 : : {
14301 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
14302 : : }
14303 : :
14304 : : static int
14305 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
14306 : : {
14307 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
14308 : : }
14309 : :
14310 : : static int
14311 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
14312 : : {
14313 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
14314 : : }
14315 : :
14316 : : static int
14317 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
14318 : : {
14319 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
14320 : : }
14321 : :
14322 : : static int
14323 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14324 : : {
14325 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
14326 : : }
14327 : :
14328 : : static int
14329 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14330 : : {
14331 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
14332 : : }
14333 : :
14334 : : static int
14335 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14336 : : {
14337 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
14338 : : }
14339 : :
14340 : : static int
14341 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14342 : : {
14343 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
14344 : : }
14345 : :
14346 : : static int
14347 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14348 : : {
14349 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
14350 : : }
14351 : :
14352 : : static int
14353 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14354 : : {
14355 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
14356 : : }
14357 : :
14358 : : static int
14359 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14360 : : {
14361 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
14362 : : }
14363 : :
14364 : : static int
14365 : 1 : test_stats(void)
14366 : : {
14367 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14368 : : struct rte_cryptodev_stats stats;
14369 : :
14370 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14371 : : return TEST_SKIPPED;
14372 : :
14373 : : /* Verify the capabilities */
14374 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14375 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14376 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14377 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14378 : : &cap_idx) == NULL)
14379 : : return TEST_SKIPPED;
14380 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14381 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14382 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14383 : : &cap_idx) == NULL)
14384 : : return TEST_SKIPPED;
14385 : :
14386 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14387 : : == -ENOTSUP)
14388 : : return TEST_SKIPPED;
14389 : :
14390 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14391 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14392 : : &stats) == -ENODEV),
14393 : : "rte_cryptodev_stats_get invalid dev failed");
14394 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14395 : : "rte_cryptodev_stats_get invalid Param failed");
14396 : :
14397 : : /* Test expected values */
14398 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
14399 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14400 : : &stats),
14401 : : "rte_cryptodev_stats_get failed");
14402 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14403 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
14404 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
14405 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
14406 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
14407 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14408 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
14409 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14410 : :
14411 : : /* invalid device but should ignore and not reset device stats*/
14412 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14413 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14414 : : &stats),
14415 : : "rte_cryptodev_stats_get failed");
14416 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14417 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14418 : :
14419 : : /* check that a valid reset clears stats */
14420 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14421 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14422 : : &stats),
14423 : : "rte_cryptodev_stats_get failed");
14424 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
14425 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14426 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
14427 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14428 : :
14429 : : return TEST_SUCCESS;
14430 : : }
14431 : :
14432 : : static int
14433 : 1 : test_device_reconfigure(void)
14434 : : {
14435 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14436 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14437 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14438 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14439 : 1 : .mp_session = ts_params->session_mpool
14440 : : };
14441 : : uint16_t qp_id, dev_id, num_devs = 0;
14442 : :
14443 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14444 : : "Need at least %d devices for test", 1);
14445 : :
14446 : 1 : dev_id = ts_params->valid_devs[0];
14447 : :
14448 : : /* Stop the device in case it's started so it can be configured */
14449 : 1 : rte_cryptodev_stop(dev_id);
14450 : :
14451 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14452 : : "Failed test for rte_cryptodev_configure: "
14453 : : "dev_num %u", dev_id);
14454 : :
14455 : : /* Reconfigure with same configure params */
14456 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14457 : : "Failed test for rte_cryptodev_configure: "
14458 : : "dev_num %u", dev_id);
14459 : :
14460 : : /* Reconfigure with just one queue pair */
14461 : 1 : ts_params->conf.nb_queue_pairs = 1;
14462 : :
14463 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14464 : : &ts_params->conf),
14465 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14466 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14467 : :
14468 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14469 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14470 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14471 : : rte_cryptodev_socket_id(
14472 : : ts_params->valid_devs[0])),
14473 : : "Failed test for "
14474 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14475 : : "%u on qp %u on cryptodev %u",
14476 : : qp_conf.nb_descriptors, qp_id,
14477 : : ts_params->valid_devs[0]);
14478 : : }
14479 : :
14480 : : /* Reconfigure with max number of queue pairs */
14481 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
14482 : :
14483 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14484 : : &ts_params->conf),
14485 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14486 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14487 : :
14488 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14489 : :
14490 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14491 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14492 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14493 : : rte_cryptodev_socket_id(
14494 : : ts_params->valid_devs[0])),
14495 : : "Failed test for "
14496 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14497 : : "%u on qp %u on cryptodev %u",
14498 : : qp_conf.nb_descriptors, qp_id,
14499 : : ts_params->valid_devs[0]);
14500 : : }
14501 : :
14502 : : /* Start the device */
14503 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14504 : : "Failed to start cryptodev %u",
14505 : : ts_params->valid_devs[0]);
14506 : :
14507 : : /* Test expected values */
14508 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14509 : : }
14510 : :
14511 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14512 : : struct crypto_unittest_params *ut_params,
14513 : : enum rte_crypto_auth_operation op,
14514 : : const struct HMAC_MD5_vector *test_case)
14515 : : {
14516 : : uint8_t key[64];
14517 : :
14518 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
14519 : :
14520 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14521 : 4 : ut_params->auth_xform.next = NULL;
14522 : 4 : ut_params->auth_xform.auth.op = op;
14523 : :
14524 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14525 : :
14526 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14527 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
14528 : 4 : ut_params->auth_xform.auth.key.data = key;
14529 : :
14530 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
14531 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14532 : : ts_params->session_mpool);
14533 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14534 : : return TEST_SKIPPED;
14535 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14536 : :
14537 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14538 : :
14539 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14540 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14541 : :
14542 : 4 : return 0;
14543 : : }
14544 : :
14545 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14546 : : const struct HMAC_MD5_vector *test_case,
14547 : : uint8_t **plaintext)
14548 : : {
14549 : : uint16_t plaintext_pad_len;
14550 : :
14551 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14552 : :
14553 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14554 : : 16);
14555 : :
14556 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14557 : : plaintext_pad_len);
14558 : 4 : memcpy(*plaintext, test_case->plaintext.data,
14559 : 4 : test_case->plaintext.len);
14560 : :
14561 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14562 : : ut_params->ibuf, MD5_DIGEST_LEN);
14563 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14564 : : "no room to append digest");
14565 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14566 : : ut_params->ibuf, plaintext_pad_len);
14567 : :
14568 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14569 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14570 [ - + ]: 2 : test_case->auth_tag.len);
14571 : : }
14572 : :
14573 : 4 : sym_op->auth.data.offset = 0;
14574 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
14575 : :
14576 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14577 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14578 : :
14579 : 4 : return 0;
14580 : : }
14581 : :
14582 : : static int
14583 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14584 : : {
14585 : : uint16_t plaintext_pad_len;
14586 : : uint8_t *plaintext, *auth_tag;
14587 : : int ret;
14588 : :
14589 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14590 : : struct crypto_unittest_params *ut_params = &unittest_params;
14591 : : struct rte_cryptodev_info dev_info;
14592 : :
14593 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14594 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14595 : :
14596 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14597 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14598 : : printf("Device doesn't support RAW data-path APIs.\n");
14599 : 0 : return TEST_SKIPPED;
14600 : : }
14601 : :
14602 : : /* Verify the capabilities */
14603 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14604 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14605 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14606 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14607 : : &cap_idx) == NULL)
14608 : : return TEST_SKIPPED;
14609 : :
14610 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14611 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14612 : : return TEST_FAILED;
14613 : :
14614 : : /* Generate Crypto op data structure */
14615 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14616 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14617 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14618 : : "Failed to allocate symmetric crypto operation struct");
14619 : :
14620 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14621 : : 16);
14622 : :
14623 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14624 : : return TEST_FAILED;
14625 : :
14626 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14627 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14628 : : ut_params->op);
14629 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14630 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14631 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14632 : : return ret;
14633 : : } else
14634 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14635 : : process_crypto_request(ts_params->valid_devs[0],
14636 : : ut_params->op),
14637 : : "failed to process sym crypto op");
14638 : :
14639 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14640 : : "crypto op processing failed");
14641 : :
14642 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
14643 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14644 : : uint8_t *, plaintext_pad_len);
14645 : : } else {
14646 : 2 : auth_tag = plaintext + plaintext_pad_len;
14647 : : }
14648 : :
14649 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14650 : : auth_tag,
14651 : : test_case->auth_tag.data,
14652 : : test_case->auth_tag.len,
14653 : : "HMAC_MD5 generated tag not as expected");
14654 : :
14655 : : return TEST_SUCCESS;
14656 : : }
14657 : :
14658 : : static int
14659 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14660 : : {
14661 : : uint8_t *plaintext;
14662 : : int ret;
14663 : :
14664 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14665 : : struct crypto_unittest_params *ut_params = &unittest_params;
14666 : : struct rte_cryptodev_info dev_info;
14667 : :
14668 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14669 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14670 : :
14671 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14672 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14673 : : printf("Device doesn't support RAW data-path APIs.\n");
14674 : 0 : return TEST_SKIPPED;
14675 : : }
14676 : :
14677 : : /* Verify the capabilities */
14678 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14679 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14680 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14681 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14682 : : &cap_idx) == NULL)
14683 : : return TEST_SKIPPED;
14684 : :
14685 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14686 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14687 : : return TEST_FAILED;
14688 : : }
14689 : :
14690 : : /* Generate Crypto op data structure */
14691 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14692 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14693 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14694 : : "Failed to allocate symmetric crypto operation struct");
14695 : :
14696 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14697 : : return TEST_FAILED;
14698 : :
14699 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14700 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14701 : : ut_params->op);
14702 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14703 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14704 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14705 : : return ret;
14706 : : } else
14707 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14708 : : process_crypto_request(ts_params->valid_devs[0],
14709 : : ut_params->op),
14710 : : "failed to process sym crypto op");
14711 : :
14712 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14713 : : "HMAC_MD5 crypto op processing failed");
14714 : :
14715 : : return TEST_SUCCESS;
14716 : : }
14717 : :
14718 : : static int
14719 : 1 : test_MD5_HMAC_generate_case_1(void)
14720 : : {
14721 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14722 : : }
14723 : :
14724 : : static int
14725 : 1 : test_MD5_HMAC_verify_case_1(void)
14726 : : {
14727 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14728 : : }
14729 : :
14730 : : static int
14731 : 1 : test_MD5_HMAC_generate_case_2(void)
14732 : : {
14733 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14734 : : }
14735 : :
14736 : : static int
14737 : 1 : test_MD5_HMAC_verify_case_2(void)
14738 : : {
14739 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14740 : : }
14741 : :
14742 : : static int
14743 : 1 : test_multi_session(void)
14744 : : {
14745 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14746 : : struct crypto_unittest_params *ut_params = &unittest_params;
14747 : : struct rte_cryptodev_info dev_info;
14748 : : int i, nb_sess, ret = TEST_SUCCESS;
14749 : : void **sessions;
14750 : :
14751 : : /* Verify the capabilities */
14752 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14753 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14754 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14755 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14756 : : &cap_idx) == NULL)
14757 : : return TEST_SKIPPED;
14758 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14759 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14760 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14761 : : &cap_idx) == NULL)
14762 : : return TEST_SKIPPED;
14763 : :
14764 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14765 : : aes_cbc_key, hmac_sha512_key);
14766 : :
14767 : :
14768 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14769 : :
14770 : 1 : sessions = rte_malloc(NULL,
14771 : : sizeof(void *) *
14772 : : (MAX_NB_SESSIONS + 1), 0);
14773 : :
14774 : : /* Create multiple crypto sessions*/
14775 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
14776 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
14777 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14778 : : ts_params->session_mpool);
14779 [ - + ]: 4 : if (sessions[i] == NULL) {
14780 : : nb_sess = i;
14781 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14782 : : ret = TEST_SKIPPED;
14783 : : else {
14784 : : ret = TEST_FAILED;
14785 : : printf("TestCase %s() line %d failed : "
14786 : : "Session creation failed at session number %u",
14787 : : __func__, __LINE__, i);
14788 : : }
14789 : : break;
14790 : : }
14791 : :
14792 : :
14793 : : /* Attempt to send a request on each session */
14794 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14795 : : sessions[i],
14796 : : ut_params,
14797 : : ts_params,
14798 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14799 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14800 : : aes_cbc_iv);
14801 : :
14802 : : /* free crypto operation structure */
14803 : 4 : rte_crypto_op_free(ut_params->op);
14804 : 4 : ut_params->op = NULL;
14805 : :
14806 : : /*
14807 : : * free mbuf - both obuf and ibuf are usually the same,
14808 : : * so check if they point at the same address is necessary,
14809 : : * to avoid freeing the mbuf twice.
14810 : : */
14811 [ + - ]: 4 : if (ut_params->obuf) {
14812 : 4 : rte_pktmbuf_free(ut_params->obuf);
14813 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
14814 : 4 : ut_params->ibuf = 0;
14815 : 4 : ut_params->obuf = 0;
14816 : : }
14817 [ - + ]: 4 : if (ut_params->ibuf) {
14818 : 0 : rte_pktmbuf_free(ut_params->ibuf);
14819 : 0 : ut_params->ibuf = 0;
14820 : : }
14821 : :
14822 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
14823 : 0 : i++;
14824 : 0 : break;
14825 : : }
14826 : : }
14827 : :
14828 : : nb_sess = i;
14829 : :
14830 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
14831 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14832 : 4 : sessions[i]);
14833 : : }
14834 : :
14835 : 1 : rte_free(sessions);
14836 : :
14837 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14838 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14839 : :
14840 : : return ret;
14841 : : }
14842 : :
14843 : : struct multi_session_params {
14844 : : struct crypto_unittest_params ut_params;
14845 : : uint8_t *cipher_key;
14846 : : uint8_t *hmac_key;
14847 : : const uint8_t *cipher;
14848 : : const uint8_t *digest;
14849 : : uint8_t *iv;
14850 : : };
14851 : :
14852 : : #define MB_SESSION_NUMBER 3
14853 : :
14854 : : static int
14855 : 1 : test_multi_session_random_usage(void)
14856 : : {
14857 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14858 : : struct rte_cryptodev_info dev_info;
14859 : : int index = 0, ret = TEST_SUCCESS;
14860 : : uint32_t nb_sess, i, j;
14861 : : void **sessions;
14862 : 1 : struct multi_session_params ut_paramz[] = {
14863 : :
14864 : : {
14865 : : .cipher_key = ms_aes_cbc_key0,
14866 : : .hmac_key = ms_hmac_key0,
14867 : : .cipher = ms_aes_cbc_cipher0,
14868 : : .digest = ms_hmac_digest0,
14869 : : .iv = ms_aes_cbc_iv0
14870 : : },
14871 : : {
14872 : : .cipher_key = ms_aes_cbc_key1,
14873 : : .hmac_key = ms_hmac_key1,
14874 : : .cipher = ms_aes_cbc_cipher1,
14875 : : .digest = ms_hmac_digest1,
14876 : : .iv = ms_aes_cbc_iv1
14877 : : },
14878 : : {
14879 : : .cipher_key = ms_aes_cbc_key2,
14880 : : .hmac_key = ms_hmac_key2,
14881 : : .cipher = ms_aes_cbc_cipher2,
14882 : : .digest = ms_hmac_digest2,
14883 : : .iv = ms_aes_cbc_iv2
14884 : : },
14885 : :
14886 : : };
14887 : :
14888 : : /* Verify the capabilities */
14889 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14890 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14891 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14892 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14893 : : &cap_idx) == NULL)
14894 : : return TEST_SKIPPED;
14895 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14896 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14897 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14898 : : &cap_idx) == NULL)
14899 : : return TEST_SKIPPED;
14900 : :
14901 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14902 : :
14903 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
14904 : : * MAX_NB_SESSIONS) + 1, 0);
14905 : :
14906 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
14907 : :
14908 : 3 : ut_paramz[i].ut_params = unittest_params;
14909 : :
14910 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14911 : : &ut_paramz[i].ut_params,
14912 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14913 : :
14914 : : /* Create multiple crypto sessions*/
14915 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
14916 : 3 : ts_params->valid_devs[0],
14917 : : &ut_paramz[i].ut_params.auth_xform,
14918 : : ts_params->session_mpool);
14919 [ - + ]: 3 : if (sessions[i] == NULL) {
14920 : : nb_sess = i;
14921 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14922 : : ret = TEST_SKIPPED;
14923 : : else {
14924 : : ret = TEST_FAILED;
14925 : : printf("TestCase %s() line %d failed : "
14926 : : "Session creation failed at session number %u",
14927 : : __func__, __LINE__, i);
14928 : : }
14929 : 0 : goto session_clear;
14930 : : }
14931 : :
14932 : : }
14933 : :
14934 : : nb_sess = i;
14935 : :
14936 : 1 : srand(time(NULL));
14937 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
14938 : :
14939 : 1 : j = rand() % MB_SESSION_NUMBER;
14940 : :
14941 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14942 : 1 : sessions[j],
14943 : : &ut_paramz[j].ut_params,
14944 : : ts_params, ut_paramz[j].cipher,
14945 : : ut_paramz[j].digest,
14946 : 1 : ut_paramz[j].iv);
14947 : :
14948 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
14949 : 1 : ut_paramz[j].ut_params.op = NULL;
14950 : :
14951 : : /*
14952 : : * free mbuf - both obuf and ibuf are usually the same,
14953 : : * so check if they point at the same address is necessary,
14954 : : * to avoid freeing the mbuf twice.
14955 : : */
14956 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
14957 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14958 : 1 : if (ut_paramz[j].ut_params.ibuf
14959 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
14960 : 1 : ut_paramz[j].ut_params.ibuf = 0;
14961 : 1 : ut_paramz[j].ut_params.obuf = 0;
14962 : : }
14963 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
14964 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14965 : 0 : ut_paramz[j].ut_params.ibuf = 0;
14966 : : }
14967 : :
14968 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
14969 : 1 : index = i;
14970 : 1 : break;
14971 : : }
14972 : : }
14973 : :
14974 : 0 : session_clear:
14975 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
14976 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14977 : 3 : sessions[i]);
14978 : : }
14979 : :
14980 : 1 : rte_free(sessions);
14981 : :
14982 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14983 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14984 : :
14985 : : return TEST_SUCCESS;
14986 : : }
14987 : :
14988 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14989 : : 0xab, 0xab, 0xab, 0xab,
14990 : : 0xab, 0xab, 0xab, 0xab,
14991 : : 0xab, 0xab, 0xab, 0xab};
14992 : :
14993 : : static int
14994 : 0 : test_null_invalid_operation(void)
14995 : : {
14996 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14997 : : struct crypto_unittest_params *ut_params = &unittest_params;
14998 : :
14999 : : /* This test is for NULL PMD only */
15000 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15001 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15002 : : return TEST_SKIPPED;
15003 : :
15004 : : /* Setup Cipher Parameters */
15005 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15006 : 0 : ut_params->cipher_xform.next = NULL;
15007 : :
15008 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
15009 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15010 : :
15011 : : /* Create Crypto session*/
15012 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15013 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15014 : : ts_params->session_mpool);
15015 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15016 : : return TEST_SKIPPED;
15017 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15018 : : "Session creation succeeded unexpectedly");
15019 : :
15020 : : /* Setup HMAC Parameters */
15021 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15022 : 0 : ut_params->auth_xform.next = NULL;
15023 : :
15024 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
15025 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15026 : :
15027 : : /* Create Crypto session*/
15028 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15029 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
15030 : : ts_params->session_mpool);
15031 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15032 : : return TEST_SKIPPED;
15033 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15034 : : "Session creation succeeded unexpectedly");
15035 : :
15036 : : return TEST_SUCCESS;
15037 : : }
15038 : :
15039 : :
15040 : : #define NULL_BURST_LENGTH (32)
15041 : :
15042 : : static int
15043 : 0 : test_null_burst_operation(void)
15044 : : {
15045 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15046 : : struct crypto_unittest_params *ut_params = &unittest_params;
15047 : :
15048 : : unsigned i, burst_len = NULL_BURST_LENGTH;
15049 : :
15050 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
15051 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
15052 : :
15053 : : /* This test is for NULL PMD only */
15054 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15055 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15056 : : return TEST_SKIPPED;
15057 : :
15058 : : /* Setup Cipher Parameters */
15059 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15060 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15061 : :
15062 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15063 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15064 : :
15065 : : /* Setup HMAC Parameters */
15066 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15067 : 0 : ut_params->auth_xform.next = NULL;
15068 : :
15069 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15070 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15071 : :
15072 : : /* Create Crypto session*/
15073 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15074 : 0 : ts_params->valid_devs[0],
15075 : : &ut_params->auth_xform,
15076 : : ts_params->session_mpool);
15077 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15078 : : return TEST_SKIPPED;
15079 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15080 : :
15081 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
15082 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
15083 : : burst_len, "failed to generate burst of crypto ops");
15084 : :
15085 : : /* Generate an operation for each mbuf in burst */
15086 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15087 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15088 : :
15089 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
15090 : :
15091 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
15092 : : sizeof(unsigned));
15093 : 0 : *data = i;
15094 : :
15095 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
15096 : :
15097 : 0 : burst[i]->sym->m_src = m;
15098 : : }
15099 : :
15100 : : /* Process crypto operation */
15101 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
15102 : : 0, burst, burst_len),
15103 : : burst_len,
15104 : : "Error enqueuing burst");
15105 : :
15106 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
15107 : : 0, burst_dequeued, burst_len),
15108 : : burst_len,
15109 : : "Error dequeuing burst");
15110 : :
15111 : :
15112 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15113 [ # # ]: 0 : TEST_ASSERT_EQUAL(
15114 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
15115 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
15116 : : uint32_t *),
15117 : : "data not as expected");
15118 : :
15119 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
15120 : 0 : rte_crypto_op_free(burst[i]);
15121 : : }
15122 : :
15123 : : return TEST_SUCCESS;
15124 : : }
15125 : :
15126 : : static uint16_t
15127 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15128 : : uint16_t nb_ops, void *user_param)
15129 : : {
15130 : : RTE_SET_USED(dev_id);
15131 : : RTE_SET_USED(qp_id);
15132 : : RTE_SET_USED(ops);
15133 : : RTE_SET_USED(user_param);
15134 : :
15135 : 0 : enq_cb_called = true;
15136 : : printf("crypto enqueue callback called\n");
15137 : 0 : return nb_ops;
15138 : : }
15139 : :
15140 : : static uint16_t
15141 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15142 : : uint16_t nb_ops, void *user_param)
15143 : : {
15144 : : RTE_SET_USED(dev_id);
15145 : : RTE_SET_USED(qp_id);
15146 : : RTE_SET_USED(ops);
15147 : : RTE_SET_USED(user_param);
15148 : :
15149 : 0 : deq_cb_called = true;
15150 : : printf("crypto dequeue callback called\n");
15151 : 0 : return nb_ops;
15152 : : }
15153 : :
15154 : : /*
15155 : : * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
15156 : : */
15157 : : static int
15158 : 0 : test_enqdeq_callback_null_cipher(void)
15159 : : {
15160 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15161 : : struct crypto_unittest_params *ut_params = &unittest_params;
15162 : :
15163 : : /* Setup Cipher Parameters */
15164 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15165 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15166 : :
15167 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15168 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15169 : :
15170 : : /* Setup Auth Parameters */
15171 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15172 : 0 : ut_params->auth_xform.next = NULL;
15173 : :
15174 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15175 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15176 : :
15177 : : /* Create Crypto session */
15178 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
15179 : : &ut_params->auth_xform, ts_params->session_mpool);
15180 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15181 : : return TEST_SKIPPED;
15182 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15183 : :
15184 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15185 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
15186 : :
15187 : : /* Allocate mbuf */
15188 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15189 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
15190 : :
15191 : : /* Append some random data */
15192 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
15193 : : "no room to append data");
15194 : :
15195 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15196 : :
15197 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15198 : :
15199 : : /* Process crypto operation */
15200 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
15201 : : "failed to process sym crypto op");
15202 : :
15203 : : return 0;
15204 : : }
15205 : :
15206 : : static int
15207 : 1 : test_enq_callback_setup(void)
15208 : : {
15209 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15210 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15211 : : struct rte_cryptodev_info dev_info;
15212 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15213 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15214 : : };
15215 : :
15216 : : struct rte_cryptodev_cb *cb;
15217 : : uint16_t qp_id = 0;
15218 : : int j = 0;
15219 : :
15220 : : /* Skip test if synchronous API is used */
15221 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15222 : : return TEST_SKIPPED;
15223 : :
15224 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15225 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15226 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15227 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15228 : : &cap_idx) == NULL)
15229 : : return TEST_SKIPPED;
15230 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15231 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15232 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15233 : : &cap_idx) == NULL)
15234 : : return TEST_SKIPPED;
15235 : :
15236 : : /* Stop the device in case it's started so it can be configured */
15237 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15238 : :
15239 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15240 : :
15241 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15242 : : &ts_params->conf),
15243 : : "Failed to configure cryptodev %u",
15244 : : ts_params->valid_devs[0]);
15245 : :
15246 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15247 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15248 : :
15249 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15250 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15251 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15252 : : "Failed test for "
15253 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15254 : : "%u on qp %u on cryptodev %u",
15255 : : qp_conf.nb_descriptors, qp_id,
15256 : : ts_params->valid_devs[0]);
15257 : :
15258 : 0 : enq_cb_called = false;
15259 : : /* Test with invalid crypto device */
15260 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
15261 : : qp_id, test_enq_callback, NULL);
15262 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15263 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15264 : : "rte_cryptodev_add_enq_callback() "
15265 : : "Not supported, skipped\n", __func__, __LINE__);
15266 : 0 : return TEST_SKIPPED;
15267 : : }
15268 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15269 : : "cryptodev %u did not fail",
15270 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15271 : :
15272 : : /* Test with invalid queue pair */
15273 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15274 : 0 : dev_info.max_nb_queue_pairs + 1,
15275 : : test_enq_callback, NULL);
15276 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15277 : : "cryptodev %u did not fail",
15278 : : dev_info.max_nb_queue_pairs + 1,
15279 : : ts_params->valid_devs[0]);
15280 : :
15281 : : /* Test with NULL callback */
15282 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15283 : : qp_id, NULL, NULL);
15284 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15285 : : "cryptodev %u did not fail",
15286 : : qp_id, ts_params->valid_devs[0]);
15287 : :
15288 : : /* Test with valid configuration */
15289 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15290 : : qp_id, test_enq_callback, NULL);
15291 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15292 : : "qp %u on cryptodev %u",
15293 : : qp_id, ts_params->valid_devs[0]);
15294 : :
15295 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15296 : :
15297 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
15298 : :
15299 : : /* Wait until callback not called. */
15300 [ # # # # ]: 0 : while (!enq_cb_called && (j++ < 10))
15301 : : rte_delay_ms(10);
15302 : :
15303 : : /* Test with invalid crypto device */
15304 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15305 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15306 : : "Expected call to fail as crypto device is invalid");
15307 : :
15308 : : /* Test with invalid queue pair */
15309 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15310 : : ts_params->valid_devs[0],
15311 : : dev_info.max_nb_queue_pairs + 1, cb),
15312 : : "Expected call to fail as queue pair is invalid");
15313 : :
15314 : : /* Test with NULL callback */
15315 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15316 : : ts_params->valid_devs[0], qp_id, NULL),
15317 : : "Expected call to fail as callback is NULL");
15318 : :
15319 : : /* Test with valid configuration */
15320 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
15321 : : ts_params->valid_devs[0], qp_id, cb),
15322 : : "Failed test to remove callback on "
15323 : : "qp %u on cryptodev %u",
15324 : : qp_id, ts_params->valid_devs[0]);
15325 : :
15326 [ # # ]: 0 : TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
15327 : :
15328 : : return TEST_SUCCESS;
15329 : : }
15330 : :
15331 : : static int
15332 : 1 : test_deq_callback_setup(void)
15333 : : {
15334 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15335 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15336 : : struct rte_cryptodev_info dev_info;
15337 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15338 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15339 : : };
15340 : :
15341 : : struct rte_cryptodev_cb *cb;
15342 : : uint16_t qp_id = 0;
15343 : : int j = 0;
15344 : :
15345 : : /* Skip test if synchronous API is used */
15346 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15347 : : return TEST_SKIPPED;
15348 : :
15349 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15350 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15351 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15352 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15353 : : &cap_idx) == NULL)
15354 : : return TEST_SKIPPED;
15355 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15356 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15357 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15358 : : &cap_idx) == NULL)
15359 : : return TEST_SKIPPED;
15360 : :
15361 : : /* Stop the device in case it's started so it can be configured */
15362 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15363 : :
15364 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15365 : :
15366 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15367 : : &ts_params->conf),
15368 : : "Failed to configure cryptodev %u",
15369 : : ts_params->valid_devs[0]);
15370 : :
15371 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15372 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15373 : :
15374 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15375 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15376 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15377 : : "Failed test for "
15378 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15379 : : "%u on qp %u on cryptodev %u",
15380 : : qp_conf.nb_descriptors, qp_id,
15381 : : ts_params->valid_devs[0]);
15382 : :
15383 : 0 : deq_cb_called = false;
15384 : : /* Test with invalid crypto device */
15385 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15386 : : qp_id, test_deq_callback, NULL);
15387 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15388 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15389 : : "rte_cryptodev_add_deq_callback() "
15390 : : "Not supported, skipped\n", __func__, __LINE__);
15391 : 0 : return TEST_SKIPPED;
15392 : : }
15393 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15394 : : "cryptodev %u did not fail",
15395 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15396 : :
15397 : : /* Test with invalid queue pair */
15398 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15399 : 0 : dev_info.max_nb_queue_pairs + 1,
15400 : : test_deq_callback, NULL);
15401 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15402 : : "cryptodev %u did not fail",
15403 : : dev_info.max_nb_queue_pairs + 1,
15404 : : ts_params->valid_devs[0]);
15405 : :
15406 : : /* Test with NULL callback */
15407 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15408 : : qp_id, NULL, NULL);
15409 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15410 : : "cryptodev %u did not fail",
15411 : : qp_id, ts_params->valid_devs[0]);
15412 : :
15413 : : /* Test with valid configuration */
15414 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15415 : : qp_id, test_deq_callback, NULL);
15416 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15417 : : "qp %u on cryptodev %u",
15418 : : qp_id, ts_params->valid_devs[0]);
15419 : :
15420 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15421 : :
15422 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15423 : :
15424 : : /* Wait until callback not called. */
15425 [ # # # # ]: 0 : while (!deq_cb_called && (j++ < 10))
15426 : : rte_delay_ms(10);
15427 : :
15428 : : /* Test with invalid crypto device */
15429 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15430 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15431 : : "Expected call to fail as crypto device is invalid");
15432 : :
15433 : : /* Test with invalid queue pair */
15434 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15435 : : ts_params->valid_devs[0],
15436 : : dev_info.max_nb_queue_pairs + 1, cb),
15437 : : "Expected call to fail as queue pair is invalid");
15438 : :
15439 : : /* Test with NULL callback */
15440 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15441 : : ts_params->valid_devs[0], qp_id, NULL),
15442 : : "Expected call to fail as callback is NULL");
15443 : :
15444 : : /* Test with valid configuration */
15445 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15446 : : ts_params->valid_devs[0], qp_id, cb),
15447 : : "Failed test to remove callback on "
15448 : : "qp %u on cryptodev %u",
15449 : : qp_id, ts_params->valid_devs[0]);
15450 : :
15451 [ # # ]: 0 : TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15452 : :
15453 : : return TEST_SUCCESS;
15454 : : }
15455 : :
15456 : : static void
15457 : : generate_gmac_large_plaintext(uint8_t *data)
15458 : : {
15459 : : uint16_t i;
15460 : :
15461 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15462 : 4082 : memcpy(&data[i], &data[0], 32);
15463 : : }
15464 : :
15465 : : static int
15466 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
15467 : : const struct gmac_test_data *tdata)
15468 : : {
15469 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15470 : : struct crypto_unittest_params *ut_params = &unittest_params;
15471 : : struct rte_crypto_sym_op *sym_op;
15472 : :
15473 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15474 : :
15475 : : /* Generate Crypto op data structure */
15476 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15477 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15478 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
15479 : : "Failed to allocate symmetric crypto operation struct");
15480 : :
15481 : : sym_op = ut_params->op->sym;
15482 : :
15483 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15484 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
15485 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15486 : : "no room to append digest");
15487 : :
15488 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15489 : : ut_params->ibuf, plaintext_pad_len);
15490 : :
15491 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15492 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15493 [ - + ]: 4 : tdata->gmac_tag.len);
15494 : 4 : debug_hexdump(stdout, "digest:",
15495 : 4 : sym_op->auth.digest.data,
15496 : 4 : tdata->gmac_tag.len);
15497 : : }
15498 : :
15499 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15500 : : uint8_t *, IV_OFFSET);
15501 : :
15502 [ - + ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15503 : :
15504 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15505 : :
15506 : 8 : sym_op->cipher.data.length = 0;
15507 : 8 : sym_op->cipher.data.offset = 0;
15508 : :
15509 : 8 : sym_op->auth.data.offset = 0;
15510 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
15511 : :
15512 : 8 : return 0;
15513 : : }
15514 : :
15515 : : static int
15516 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15517 : : const struct gmac_test_data *tdata,
15518 : : void *digest_mem, uint64_t digest_phys)
15519 : : {
15520 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15521 : : struct crypto_unittest_params *ut_params = &unittest_params;
15522 : : struct rte_crypto_sym_op *sym_op;
15523 : :
15524 : : /* Generate Crypto op data structure */
15525 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15526 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15527 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15528 : : "Failed to allocate symmetric crypto operation struct");
15529 : :
15530 : : sym_op = ut_params->op->sym;
15531 : :
15532 : 0 : sym_op->auth.digest.data = digest_mem;
15533 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15534 : : "no room to append digest");
15535 : :
15536 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
15537 : :
15538 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15539 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15540 [ # # ]: 0 : tdata->gmac_tag.len);
15541 : 0 : debug_hexdump(stdout, "digest:",
15542 : 0 : sym_op->auth.digest.data,
15543 : 0 : tdata->gmac_tag.len);
15544 : : }
15545 : :
15546 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15547 : : uint8_t *, IV_OFFSET);
15548 : :
15549 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15550 : :
15551 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15552 : :
15553 : 0 : sym_op->cipher.data.length = 0;
15554 : 0 : sym_op->cipher.data.offset = 0;
15555 : :
15556 : 0 : sym_op->auth.data.offset = 0;
15557 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
15558 : :
15559 : 0 : return 0;
15560 : : }
15561 : :
15562 : 8 : static int create_gmac_session(uint8_t dev_id,
15563 : : const struct gmac_test_data *tdata,
15564 : : enum rte_crypto_auth_operation auth_op)
15565 : : {
15566 : 8 : uint8_t *auth_key = alloca(tdata->key.len);
15567 : :
15568 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15569 : : struct crypto_unittest_params *ut_params = &unittest_params;
15570 : :
15571 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
15572 : :
15573 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15574 : 8 : ut_params->auth_xform.next = NULL;
15575 : :
15576 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15577 : 8 : ut_params->auth_xform.auth.op = auth_op;
15578 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15579 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
15580 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
15581 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15582 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15583 : :
15584 : :
15585 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15586 : : &ut_params->auth_xform, ts_params->session_mpool);
15587 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15588 : : return TEST_SKIPPED;
15589 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15590 : :
15591 : : return 0;
15592 : : }
15593 : :
15594 : : static int
15595 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15596 : : {
15597 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15598 : : struct crypto_unittest_params *ut_params = &unittest_params;
15599 : : struct rte_cryptodev_info dev_info;
15600 : :
15601 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15602 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15603 : :
15604 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15605 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15606 : : printf("Device doesn't support RAW data-path APIs.\n");
15607 : 0 : return TEST_SKIPPED;
15608 : : }
15609 : :
15610 : : int retval;
15611 : :
15612 : : uint8_t *auth_tag, *plaintext;
15613 : : uint16_t plaintext_pad_len;
15614 : :
15615 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15616 : : "No GMAC length in the source data");
15617 : :
15618 : : /* Verify the capabilities */
15619 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15620 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15621 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15622 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15623 : : &cap_idx) == NULL)
15624 : : return TEST_SKIPPED;
15625 : :
15626 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15627 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15628 : :
15629 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15630 : : return TEST_SKIPPED;
15631 [ + - ]: 4 : if (retval < 0)
15632 : : return retval;
15633 : :
15634 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15635 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15636 : : else
15637 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15638 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15639 : : "Failed to allocate input buffer in mempool");
15640 : :
15641 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15642 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15643 : :
15644 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15645 : : /*
15646 : : * Runtime generate the large plain text instead of use hard code
15647 : : * plain text vector. It is done to avoid create huge source file
15648 : : * with the test vector.
15649 : : */
15650 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15651 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15652 : :
15653 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15654 : : plaintext_pad_len);
15655 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15656 : :
15657 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15658 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15659 : 4 : tdata->plaintext.len);
15660 : :
15661 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15662 : : tdata);
15663 : :
15664 [ + - ]: 4 : if (retval < 0)
15665 : : return retval;
15666 : :
15667 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15668 : :
15669 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15670 : :
15671 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15672 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15673 : : ut_params->op);
15674 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15675 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15676 : : 0);
15677 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15678 : : return retval;
15679 : : } else
15680 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15681 : : process_crypto_request(ts_params->valid_devs[0],
15682 : : ut_params->op), "failed to process sym crypto op");
15683 : :
15684 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15685 : : "crypto op processing failed");
15686 : :
15687 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
15688 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15689 : : uint8_t *, plaintext_pad_len);
15690 : : } else {
15691 : 4 : auth_tag = plaintext + plaintext_pad_len;
15692 : : }
15693 : :
15694 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15695 : :
15696 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15697 : : auth_tag,
15698 : : tdata->gmac_tag.data,
15699 : : tdata->gmac_tag.len,
15700 : : "GMAC Generated auth tag not as expected");
15701 : :
15702 : : return 0;
15703 : : }
15704 : :
15705 : : static int
15706 : 1 : test_AES_GMAC_authentication_test_case_1(void)
15707 : : {
15708 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
15709 : : }
15710 : :
15711 : : static int
15712 : 1 : test_AES_GMAC_authentication_test_case_2(void)
15713 : : {
15714 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
15715 : : }
15716 : :
15717 : : static int
15718 : 1 : test_AES_GMAC_authentication_test_case_3(void)
15719 : : {
15720 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
15721 : : }
15722 : :
15723 : : static int
15724 : 1 : test_AES_GMAC_authentication_test_case_4(void)
15725 : : {
15726 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
15727 : : }
15728 : :
15729 : : static int
15730 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15731 : : {
15732 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15733 : : struct crypto_unittest_params *ut_params = &unittest_params;
15734 : : int retval;
15735 : : uint32_t plaintext_pad_len;
15736 : : uint8_t *plaintext;
15737 : : struct rte_cryptodev_info dev_info;
15738 : :
15739 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15740 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15741 : :
15742 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15743 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15744 : : printf("Device doesn't support RAW data-path APIs.\n");
15745 : 0 : return TEST_SKIPPED;
15746 : : }
15747 : :
15748 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15749 : : "No GMAC length in the source data");
15750 : :
15751 : : /* Verify the capabilities */
15752 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15753 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15754 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15755 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15756 : : &cap_idx) == NULL)
15757 : : return TEST_SKIPPED;
15758 : :
15759 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15760 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15761 : :
15762 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15763 : : return TEST_SKIPPED;
15764 [ + - ]: 4 : if (retval < 0)
15765 : : return retval;
15766 : :
15767 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15768 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15769 : : else
15770 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15771 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15772 : : "Failed to allocate input buffer in mempool");
15773 : :
15774 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15775 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15776 : :
15777 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15778 : :
15779 : : /*
15780 : : * Runtime generate the large plain text instead of use hard code
15781 : : * plain text vector. It is done to avoid create huge source file
15782 : : * with the test vector.
15783 : : */
15784 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15785 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15786 : :
15787 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15788 : : plaintext_pad_len);
15789 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15790 : :
15791 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15792 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15793 : 4 : tdata->plaintext.len);
15794 : :
15795 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15796 : : tdata);
15797 : :
15798 [ + - ]: 4 : if (retval < 0)
15799 : : return retval;
15800 : :
15801 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15802 : :
15803 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15804 : :
15805 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15806 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15807 : : ut_params->op);
15808 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15809 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15810 : : 0);
15811 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15812 : : return retval;
15813 : : } else
15814 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15815 : : process_crypto_request(ts_params->valid_devs[0],
15816 : : ut_params->op), "failed to process sym crypto op");
15817 : :
15818 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15819 : : "crypto op processing failed");
15820 : :
15821 : : return 0;
15822 : :
15823 : : }
15824 : :
15825 : : static int
15826 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
15827 : : {
15828 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15829 : : }
15830 : :
15831 : : static int
15832 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
15833 : : {
15834 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15835 : : }
15836 : :
15837 : : static int
15838 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
15839 : : {
15840 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15841 : : }
15842 : :
15843 : : static int
15844 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
15845 : : {
15846 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15847 : : }
15848 : :
15849 : : static int
15850 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15851 : : uint32_t fragsz)
15852 : : {
15853 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15854 : : struct crypto_unittest_params *ut_params = &unittest_params;
15855 : : struct rte_cryptodev_info dev_info;
15856 : : uint64_t feature_flags;
15857 : : unsigned int trn_data = 0;
15858 : : void *digest_mem = NULL;
15859 : : uint32_t segs = 1;
15860 : : unsigned int to_trn = 0;
15861 : : struct rte_mbuf *buf = NULL;
15862 : : uint8_t *auth_tag, *plaintext;
15863 : : int retval;
15864 : :
15865 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15866 : : "No GMAC length in the source data");
15867 : :
15868 : : /* Verify the capabilities */
15869 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15870 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15871 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15872 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15873 : : &cap_idx) == NULL)
15874 : : return TEST_SKIPPED;
15875 : :
15876 : : /* Check for any input SGL support */
15877 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15878 : 4 : feature_flags = dev_info.feature_flags;
15879 : :
15880 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15881 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15882 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15883 : : return TEST_SKIPPED;
15884 : :
15885 : 0 : if (fragsz > tdata->plaintext.len)
15886 : : fragsz = tdata->plaintext.len;
15887 : :
15888 : 0 : uint16_t plaintext_len = fragsz;
15889 : :
15890 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
15891 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15892 : :
15893 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15894 : : return TEST_SKIPPED;
15895 [ # # ]: 0 : if (retval < 0)
15896 : : return retval;
15897 : :
15898 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15899 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15900 : : "Failed to allocate input buffer in mempool");
15901 : :
15902 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15903 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15904 : :
15905 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15906 : : plaintext_len);
15907 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15908 : :
15909 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15910 : :
15911 : : trn_data += plaintext_len;
15912 : :
15913 : 0 : buf = ut_params->ibuf;
15914 : :
15915 : : /*
15916 : : * Loop until no more fragments
15917 : : */
15918 : :
15919 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15920 : 0 : ++segs;
15921 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15922 : : (tdata->plaintext.len - trn_data) : fragsz;
15923 : :
15924 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15925 : : buf = buf->next;
15926 : :
15927 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15928 : : rte_pktmbuf_tailroom(buf));
15929 : :
15930 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15931 : : to_trn);
15932 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
15933 : :
15934 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15935 : : to_trn);
15936 : 0 : trn_data += to_trn;
15937 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15938 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15939 : 0 : tdata->gmac_tag.len);
15940 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append digest data");
15941 : : }
15942 : : }
15943 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
15944 : :
15945 : : /*
15946 : : * Place digest at the end of the last buffer
15947 : : */
15948 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15949 : :
15950 [ # # ]: 0 : if (!digest_mem) {
15951 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15952 : 0 : + tdata->gmac_tag.len);
15953 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15954 : : tdata->plaintext.len);
15955 : : }
15956 : :
15957 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15958 : : tdata, digest_mem, digest_phys);
15959 : :
15960 [ # # ]: 0 : if (retval < 0)
15961 : : return retval;
15962 : :
15963 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15964 : :
15965 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15966 : :
15967 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15968 : : return TEST_SKIPPED;
15969 : :
15970 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15971 : : process_crypto_request(ts_params->valid_devs[0],
15972 : : ut_params->op), "failed to process sym crypto op");
15973 : :
15974 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15975 : : "crypto op processing failed");
15976 : :
15977 : : auth_tag = digest_mem;
15978 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15979 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15980 : : auth_tag,
15981 : : tdata->gmac_tag.data,
15982 : : tdata->gmac_tag.len,
15983 : : "GMAC Generated auth tag not as expected");
15984 : :
15985 : : return 0;
15986 : : }
15987 : :
15988 : : /* Segment size not multiple of block size (16B) */
15989 : : static int
15990 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
15991 : : {
15992 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15993 : : }
15994 : :
15995 : : static int
15996 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
15997 : : {
15998 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15999 : : }
16000 : :
16001 : : static int
16002 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
16003 : : {
16004 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
16005 : : }
16006 : :
16007 : : /* Segment size not multiple of block size (16B) */
16008 : : static int
16009 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
16010 : : {
16011 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
16012 : : }
16013 : :
16014 : : struct test_crypto_vector {
16015 : : enum rte_crypto_cipher_algorithm crypto_algo;
16016 : : unsigned int cipher_offset;
16017 : : unsigned int cipher_len;
16018 : :
16019 : : struct {
16020 : : uint8_t data[64];
16021 : : unsigned int len;
16022 : : } cipher_key;
16023 : :
16024 : : struct {
16025 : : uint8_t data[64];
16026 : : unsigned int len;
16027 : : } iv;
16028 : :
16029 : : struct {
16030 : : const uint8_t *data;
16031 : : unsigned int len;
16032 : : } plaintext;
16033 : :
16034 : : struct {
16035 : : const uint8_t *data;
16036 : : unsigned int len;
16037 : : } ciphertext;
16038 : :
16039 : : enum rte_crypto_auth_algorithm auth_algo;
16040 : : unsigned int auth_offset;
16041 : :
16042 : : struct {
16043 : : uint8_t data[128];
16044 : : unsigned int len;
16045 : : } auth_key;
16046 : :
16047 : : struct {
16048 : : const uint8_t *data;
16049 : : unsigned int len;
16050 : : } aad;
16051 : :
16052 : : struct {
16053 : : uint8_t data[128];
16054 : : unsigned int len;
16055 : : } digest;
16056 : : };
16057 : :
16058 : : static const struct test_crypto_vector
16059 : : hmac_sha1_test_crypto_vector = {
16060 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16061 : : .plaintext = {
16062 : : .data = plaintext_hash,
16063 : : .len = 512
16064 : : },
16065 : : .auth_key = {
16066 : : .data = {
16067 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16068 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16069 : : 0xDE, 0xF4, 0xDE, 0xAD
16070 : : },
16071 : : .len = 20
16072 : : },
16073 : : .digest = {
16074 : : .data = {
16075 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
16076 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
16077 : : 0x3F, 0x91, 0x64, 0x59
16078 : : },
16079 : : .len = 20
16080 : : }
16081 : : };
16082 : :
16083 : : static const struct test_crypto_vector
16084 : : aes128_gmac_test_vector = {
16085 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
16086 : : .plaintext = {
16087 : : .data = plaintext_hash,
16088 : : .len = 512
16089 : : },
16090 : : .iv = {
16091 : : .data = {
16092 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16093 : : 0x08, 0x09, 0x0A, 0x0B
16094 : : },
16095 : : .len = 12
16096 : : },
16097 : : .auth_key = {
16098 : : .data = {
16099 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16100 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
16101 : : },
16102 : : .len = 16
16103 : : },
16104 : : .digest = {
16105 : : .data = {
16106 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
16107 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
16108 : : },
16109 : : .len = 16
16110 : : }
16111 : : };
16112 : :
16113 : : static const struct test_crypto_vector
16114 : : aes128cbc_hmac_sha1_test_vector = {
16115 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16116 : : .cipher_offset = 0,
16117 : : .cipher_len = 512,
16118 : : .cipher_key = {
16119 : : .data = {
16120 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16121 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16122 : : },
16123 : : .len = 16
16124 : : },
16125 : : .iv = {
16126 : : .data = {
16127 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16128 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16129 : : },
16130 : : .len = 16
16131 : : },
16132 : : .plaintext = {
16133 : : .data = plaintext_hash,
16134 : : .len = 512
16135 : : },
16136 : : .ciphertext = {
16137 : : .data = ciphertext512_aes128cbc,
16138 : : .len = 512
16139 : : },
16140 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16141 : : .auth_offset = 0,
16142 : : .auth_key = {
16143 : : .data = {
16144 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16145 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16146 : : 0xDE, 0xF4, 0xDE, 0xAD
16147 : : },
16148 : : .len = 20
16149 : : },
16150 : : .digest = {
16151 : : .data = {
16152 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
16153 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16154 : : 0x18, 0x8C, 0x1D, 0x32
16155 : : },
16156 : : .len = 20
16157 : : }
16158 : : };
16159 : :
16160 : : static const struct test_crypto_vector
16161 : : aes128cbc_hmac_sha1_aad_test_vector = {
16162 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16163 : : .cipher_offset = 8,
16164 : : .cipher_len = 496,
16165 : : .cipher_key = {
16166 : : .data = {
16167 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16168 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16169 : : },
16170 : : .len = 16
16171 : : },
16172 : : .iv = {
16173 : : .data = {
16174 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16175 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16176 : : },
16177 : : .len = 16
16178 : : },
16179 : : .plaintext = {
16180 : : .data = plaintext_hash,
16181 : : .len = 512
16182 : : },
16183 : : .ciphertext = {
16184 : : .data = ciphertext512_aes128cbc_aad,
16185 : : .len = 512
16186 : : },
16187 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16188 : : .auth_offset = 0,
16189 : : .auth_key = {
16190 : : .data = {
16191 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16192 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16193 : : 0xDE, 0xF4, 0xDE, 0xAD
16194 : : },
16195 : : .len = 20
16196 : : },
16197 : : .digest = {
16198 : : .data = {
16199 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
16200 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
16201 : : 0x62, 0x0F, 0xFB, 0x10
16202 : : },
16203 : : .len = 20
16204 : : }
16205 : : };
16206 : :
16207 : : static void
16208 : : data_corruption(uint8_t *data)
16209 : : {
16210 : 3 : data[0] += 1;
16211 : 3 : }
16212 : :
16213 : : static void
16214 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
16215 : : {
16216 : 3 : data[tag_offset] += 1;
16217 : 3 : }
16218 : :
16219 : : static int
16220 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
16221 : : uint8_t dev_id,
16222 : : const struct test_crypto_vector *reference,
16223 : : enum rte_crypto_auth_operation auth_op)
16224 : : {
16225 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16226 : 2 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16227 : :
16228 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16229 : :
16230 : : /* Setup Authentication Parameters */
16231 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16232 : 2 : ut_params->auth_xform.auth.op = auth_op;
16233 : 2 : ut_params->auth_xform.next = NULL;
16234 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16235 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16236 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
16237 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16238 : :
16239 : : /* Create Crypto session*/
16240 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16241 : : &ut_params->auth_xform,
16242 : : ts_params->session_mpool);
16243 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16244 : : return TEST_SKIPPED;
16245 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16246 : :
16247 : : return 0;
16248 : : }
16249 : :
16250 : : static int
16251 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
16252 : : uint8_t dev_id,
16253 : : const struct test_crypto_vector *reference,
16254 : : enum rte_crypto_auth_operation auth_op,
16255 : : enum rte_crypto_cipher_operation cipher_op)
16256 : : {
16257 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16258 : 4 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16259 : 4 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16260 : :
16261 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
16262 : : reference->cipher_key.len);
16263 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16264 : :
16265 : : /* Setup Authentication Parameters */
16266 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16267 : 4 : ut_params->auth_xform.auth.op = auth_op;
16268 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16269 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16270 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
16271 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16272 : :
16273 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
16274 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
16275 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
16276 : : } else {
16277 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16278 : :
16279 : : /* Setup Cipher Parameters */
16280 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16281 : 2 : ut_params->cipher_xform.next = NULL;
16282 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16283 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
16284 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16285 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16286 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16287 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16288 : : }
16289 : :
16290 : : /* Create Crypto session*/
16291 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16292 : : &ut_params->auth_xform,
16293 : : ts_params->session_mpool);
16294 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16295 : : return TEST_SKIPPED;
16296 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16297 : :
16298 : : return 0;
16299 : : }
16300 : :
16301 : : static int
16302 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
16303 : : struct crypto_unittest_params *ut_params,
16304 : : const struct test_crypto_vector *reference,
16305 : : unsigned int auth_generate)
16306 : : {
16307 : : /* Generate Crypto op data structure */
16308 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16309 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16310 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16311 : : "Failed to allocate pktmbuf offload");
16312 : :
16313 : : /* Set crypto operation data parameters */
16314 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16315 : :
16316 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16317 : :
16318 : : /* set crypto operation source mbuf */
16319 : 2 : sym_op->m_src = ut_params->ibuf;
16320 : :
16321 : : /* digest */
16322 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16323 : 2 : ut_params->ibuf, reference->digest.len);
16324 : :
16325 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16326 : : "no room to append auth tag");
16327 : :
16328 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16329 : : ut_params->ibuf, reference->plaintext.len);
16330 : :
16331 [ - + ]: 2 : if (auth_generate)
16332 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16333 : : else
16334 : 2 : memcpy(sym_op->auth.digest.data,
16335 : 2 : reference->digest.data,
16336 : 2 : reference->digest.len);
16337 : :
16338 : 2 : debug_hexdump(stdout, "digest:",
16339 : 2 : sym_op->auth.digest.data,
16340 : 2 : reference->digest.len);
16341 : :
16342 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16343 : 2 : sym_op->auth.data.offset = 0;
16344 : :
16345 : 2 : return 0;
16346 : : }
16347 : :
16348 : : static int
16349 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16350 : : struct crypto_unittest_params *ut_params,
16351 : : const struct test_crypto_vector *reference,
16352 : : unsigned int auth_generate)
16353 : : {
16354 : : /* Generate Crypto op data structure */
16355 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16356 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16357 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16358 : : "Failed to allocate pktmbuf offload");
16359 : :
16360 : : /* Set crypto operation data parameters */
16361 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16362 : :
16363 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16364 : :
16365 : : /* set crypto operation source mbuf */
16366 : 2 : sym_op->m_src = ut_params->ibuf;
16367 : :
16368 : : /* digest */
16369 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16370 : 2 : ut_params->ibuf, reference->digest.len);
16371 : :
16372 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16373 : : "no room to append auth tag");
16374 : :
16375 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16376 : : ut_params->ibuf, reference->ciphertext.len);
16377 : :
16378 [ - + ]: 2 : if (auth_generate)
16379 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16380 : : else
16381 : 2 : memcpy(sym_op->auth.digest.data,
16382 : 2 : reference->digest.data,
16383 : 2 : reference->digest.len);
16384 : :
16385 : 2 : debug_hexdump(stdout, "digest:",
16386 : 2 : sym_op->auth.digest.data,
16387 : 2 : reference->digest.len);
16388 : :
16389 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16390 [ - + ]: 2 : reference->iv.data, reference->iv.len);
16391 : :
16392 : 2 : sym_op->cipher.data.length = 0;
16393 : 2 : sym_op->cipher.data.offset = 0;
16394 : :
16395 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16396 : 2 : sym_op->auth.data.offset = 0;
16397 : :
16398 : 2 : return 0;
16399 : : }
16400 : :
16401 : : static int
16402 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16403 : : struct crypto_unittest_params *ut_params,
16404 : : const struct test_crypto_vector *reference,
16405 : : unsigned int auth_generate)
16406 : : {
16407 : : /* Generate Crypto op data structure */
16408 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16409 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16410 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
16411 : : "Failed to allocate pktmbuf offload");
16412 : :
16413 : : /* Set crypto operation data parameters */
16414 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16415 : :
16416 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16417 : :
16418 : : /* set crypto operation source mbuf */
16419 : 4 : sym_op->m_src = ut_params->ibuf;
16420 : :
16421 : : /* digest */
16422 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16423 : 4 : ut_params->ibuf, reference->digest.len);
16424 : :
16425 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16426 : : "no room to append auth tag");
16427 : :
16428 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16429 : : ut_params->ibuf, reference->ciphertext.len);
16430 : :
16431 [ - + ]: 4 : if (auth_generate)
16432 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16433 : : else
16434 : 4 : memcpy(sym_op->auth.digest.data,
16435 : 4 : reference->digest.data,
16436 : 4 : reference->digest.len);
16437 : :
16438 : 4 : debug_hexdump(stdout, "digest:",
16439 : 4 : sym_op->auth.digest.data,
16440 : 4 : reference->digest.len);
16441 : :
16442 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16443 [ - + ]: 4 : reference->iv.data, reference->iv.len);
16444 : :
16445 : 4 : sym_op->cipher.data.length = reference->cipher_len;
16446 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
16447 : :
16448 : 4 : sym_op->auth.data.length = reference->plaintext.len;
16449 : 4 : sym_op->auth.data.offset = reference->auth_offset;
16450 : :
16451 : 4 : return 0;
16452 : : }
16453 : :
16454 : : static int
16455 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16456 : : struct crypto_unittest_params *ut_params,
16457 : : const struct test_crypto_vector *reference)
16458 : : {
16459 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
16460 : : }
16461 : :
16462 : : static int
16463 : : create_auth_verify_GMAC_operation(
16464 : : struct crypto_testsuite_params *ts_params,
16465 : : struct crypto_unittest_params *ut_params,
16466 : : const struct test_crypto_vector *reference)
16467 : : {
16468 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16469 : : }
16470 : :
16471 : : static int
16472 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16473 : : struct crypto_unittest_params *ut_params,
16474 : : const struct test_crypto_vector *reference)
16475 : : {
16476 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16477 : : }
16478 : :
16479 : : static int
16480 : 2 : test_authentication_verify_fail_when_data_corruption(
16481 : : struct crypto_testsuite_params *ts_params,
16482 : : struct crypto_unittest_params *ut_params,
16483 : : const struct test_crypto_vector *reference,
16484 : : unsigned int data_corrupted)
16485 : : {
16486 : : int retval;
16487 : :
16488 : : uint8_t *plaintext;
16489 : : struct rte_cryptodev_info dev_info;
16490 : :
16491 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16492 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16493 : :
16494 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16495 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16496 : : printf("Device doesn't support RAW data-path APIs.\n");
16497 : 0 : return TEST_SKIPPED;
16498 : : }
16499 : :
16500 : : /* Verify the capabilities */
16501 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16502 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16503 : 2 : cap_idx.algo.auth = reference->auth_algo;
16504 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16505 : : &cap_idx) == NULL)
16506 : : return TEST_SKIPPED;
16507 : :
16508 : :
16509 : : /* Create session */
16510 : 2 : retval = create_auth_session(ut_params,
16511 : 2 : ts_params->valid_devs[0],
16512 : : reference,
16513 : : RTE_CRYPTO_AUTH_OP_VERIFY);
16514 : :
16515 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16516 : : return TEST_SKIPPED;
16517 [ + - ]: 2 : if (retval < 0)
16518 : : return retval;
16519 : :
16520 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16521 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16522 : : "Failed to allocate input buffer in mempool");
16523 : :
16524 : : /* clear mbuf payload */
16525 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16526 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16527 : :
16528 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16529 : 2 : reference->plaintext.len);
16530 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16531 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16532 : :
16533 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16534 : 2 : reference->plaintext.len);
16535 : :
16536 : : /* Create operation */
16537 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
16538 : :
16539 [ + - ]: 2 : if (retval < 0)
16540 : : return retval;
16541 : :
16542 [ + + ]: 2 : if (data_corrupted)
16543 : : data_corruption(plaintext);
16544 : : else
16545 : 1 : tag_corruption(plaintext, reference->plaintext.len);
16546 : :
16547 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16548 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16549 : : ut_params->op);
16550 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16551 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16552 : : "authentication not failed");
16553 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16554 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16555 : : 0);
16556 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16557 : : return retval;
16558 : : } else {
16559 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16560 : : ut_params->op);
16561 : : }
16562 [ - + ]: 2 : if (ut_params->op == NULL)
16563 : : return 0;
16564 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16565 : 0 : return 0;
16566 : :
16567 : : return -1;
16568 : : }
16569 : :
16570 : : static int
16571 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
16572 : : struct crypto_testsuite_params *ts_params,
16573 : : struct crypto_unittest_params *ut_params,
16574 : : const struct test_crypto_vector *reference,
16575 : : unsigned int data_corrupted)
16576 : : {
16577 : : int retval;
16578 : : uint8_t *plaintext;
16579 : : struct rte_cryptodev_info dev_info;
16580 : :
16581 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16582 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16583 : :
16584 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16585 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16586 : : printf("Device doesn't support RAW data-path APIs.\n");
16587 : 0 : return TEST_SKIPPED;
16588 : : }
16589 : :
16590 : : /* Verify the capabilities */
16591 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16592 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16593 : 2 : cap_idx.algo.auth = reference->auth_algo;
16594 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16595 : : &cap_idx) == NULL)
16596 : : return TEST_SKIPPED;
16597 : :
16598 : : /* Create session */
16599 : 2 : retval = create_auth_cipher_session(ut_params,
16600 : 2 : ts_params->valid_devs[0],
16601 : : reference,
16602 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16603 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16604 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16605 : : return TEST_SKIPPED;
16606 [ + - ]: 2 : if (retval < 0)
16607 : : return retval;
16608 : :
16609 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16610 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16611 : : "Failed to allocate input buffer in mempool");
16612 : :
16613 : : /* clear mbuf payload */
16614 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16615 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16616 : :
16617 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16618 : 2 : reference->plaintext.len);
16619 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16620 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16621 : :
16622 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16623 : 2 : reference->plaintext.len);
16624 : :
16625 : : /* Create operation */
16626 : : retval = create_auth_verify_GMAC_operation(ts_params,
16627 : : ut_params,
16628 : : reference);
16629 : :
16630 [ + - ]: 2 : if (retval < 0)
16631 : : return retval;
16632 : :
16633 [ + + ]: 2 : if (data_corrupted)
16634 : : data_corruption(plaintext);
16635 : : else
16636 : 1 : tag_corruption(plaintext, reference->aad.len);
16637 : :
16638 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16639 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16640 : : ut_params->op);
16641 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16642 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16643 : : "authentication not failed");
16644 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16645 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16646 : : 0);
16647 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16648 : 0 : return retval;
16649 : : } else {
16650 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16651 : : ut_params->op);
16652 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16653 : : }
16654 : :
16655 : : return 0;
16656 : : }
16657 : :
16658 : : static int
16659 : 2 : test_authenticated_decryption_fail_when_corruption(
16660 : : struct crypto_testsuite_params *ts_params,
16661 : : struct crypto_unittest_params *ut_params,
16662 : : const struct test_crypto_vector *reference,
16663 : : unsigned int data_corrupted)
16664 : : {
16665 : : int retval;
16666 : :
16667 : : uint8_t *ciphertext;
16668 : : struct rte_cryptodev_info dev_info;
16669 : :
16670 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16671 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16672 : :
16673 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16674 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16675 : : printf("Device doesn't support RAW data-path APIs.\n");
16676 : 0 : return TEST_SKIPPED;
16677 : : }
16678 : :
16679 : : /* Verify the capabilities */
16680 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16681 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16682 : 2 : cap_idx.algo.auth = reference->auth_algo;
16683 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16684 : : &cap_idx) == NULL)
16685 : : return TEST_SKIPPED;
16686 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16687 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
16688 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16689 : : &cap_idx) == NULL)
16690 : : return TEST_SKIPPED;
16691 : :
16692 : : /* Create session */
16693 : 2 : retval = create_auth_cipher_session(ut_params,
16694 : 2 : ts_params->valid_devs[0],
16695 : : reference,
16696 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16697 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16698 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16699 : : return TEST_SKIPPED;
16700 [ + - ]: 2 : if (retval < 0)
16701 : : return retval;
16702 : :
16703 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16704 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16705 : : "Failed to allocate input buffer in mempool");
16706 : :
16707 : : /* clear mbuf payload */
16708 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16709 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16710 : :
16711 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16712 : 2 : reference->ciphertext.len);
16713 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16714 : 2 : memcpy(ciphertext, reference->ciphertext.data,
16715 : 2 : reference->ciphertext.len);
16716 : :
16717 : : /* Create operation */
16718 : : retval = create_cipher_auth_verify_operation(ts_params,
16719 : : ut_params,
16720 : : reference);
16721 : :
16722 [ + - ]: 2 : if (retval < 0)
16723 : : return retval;
16724 : :
16725 [ + + ]: 2 : if (data_corrupted)
16726 : : data_corruption(ciphertext);
16727 : : else
16728 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
16729 : :
16730 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16731 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16732 : : ut_params->op);
16733 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16734 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16735 : : "authentication not failed");
16736 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16737 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16738 : : 0);
16739 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16740 : 0 : return retval;
16741 : : } else {
16742 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16743 : : ut_params->op);
16744 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16745 : : }
16746 : :
16747 : : return 0;
16748 : : }
16749 : :
16750 : : static int
16751 : 1 : test_authenticated_encrypt_with_esn(
16752 : : struct crypto_testsuite_params *ts_params,
16753 : : struct crypto_unittest_params *ut_params,
16754 : : const struct test_crypto_vector *reference)
16755 : : {
16756 : : int retval;
16757 : :
16758 : : uint8_t *authciphertext, *plaintext, *auth_tag;
16759 : : uint16_t plaintext_pad_len;
16760 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16761 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16762 : : struct rte_cryptodev_info dev_info;
16763 : :
16764 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16765 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16766 : :
16767 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16768 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16769 : : printf("Device doesn't support RAW data-path APIs.\n");
16770 : 0 : return TEST_SKIPPED;
16771 : : }
16772 : :
16773 : : /* Verify the capabilities */
16774 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16775 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16776 : 1 : cap_idx.algo.auth = reference->auth_algo;
16777 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16778 : : &cap_idx) == NULL)
16779 : : return TEST_SKIPPED;
16780 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16781 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16782 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16783 : : &cap_idx) == NULL)
16784 : : return TEST_SKIPPED;
16785 : :
16786 : : /* Create session */
16787 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16788 : 1 : reference->cipher_key.len);
16789 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16790 : :
16791 : : /* Setup Cipher Parameters */
16792 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16793 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16794 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16795 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16796 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16797 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16798 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16799 : :
16800 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
16801 : :
16802 : : /* Setup Authentication Parameters */
16803 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16804 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16805 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16806 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16807 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16808 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16809 : 1 : ut_params->auth_xform.next = NULL;
16810 : :
16811 : : /* Create Crypto session*/
16812 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16813 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
16814 : : ts_params->session_mpool);
16815 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16816 : : return TEST_SKIPPED;
16817 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16818 : :
16819 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16820 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16821 : : "Failed to allocate input buffer in mempool");
16822 : :
16823 : : /* clear mbuf payload */
16824 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16825 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16826 : :
16827 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16828 : 1 : reference->plaintext.len);
16829 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16830 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16831 : :
16832 : : /* Create operation */
16833 : 1 : retval = create_cipher_auth_operation(ts_params,
16834 : : ut_params,
16835 : : reference, 0);
16836 : :
16837 [ + - ]: 1 : if (retval < 0)
16838 : : return retval;
16839 : :
16840 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16841 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16842 : : ut_params->op);
16843 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16844 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16845 : : 0);
16846 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16847 : : return retval;
16848 : : } else
16849 : 1 : ut_params->op = process_crypto_request(
16850 : 1 : ts_params->valid_devs[0], ut_params->op);
16851 : :
16852 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16853 : :
16854 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16855 : : "crypto op processing failed");
16856 : :
16857 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16858 : :
16859 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16860 : : ut_params->op->sym->auth.data.offset);
16861 : 1 : auth_tag = authciphertext + plaintext_pad_len;
16862 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
16863 : 1 : reference->ciphertext.len);
16864 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16865 : :
16866 : : /* Validate obuf */
16867 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16868 : : authciphertext,
16869 : : reference->ciphertext.data,
16870 : : reference->ciphertext.len,
16871 : : "Ciphertext data not as expected");
16872 : :
16873 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16874 : : auth_tag,
16875 : : reference->digest.data,
16876 : : reference->digest.len,
16877 : : "Generated digest not as expected");
16878 : :
16879 : : return TEST_SUCCESS;
16880 : :
16881 : : }
16882 : :
16883 : : static int
16884 : 1 : test_authenticated_decrypt_with_esn(
16885 : : struct crypto_testsuite_params *ts_params,
16886 : : struct crypto_unittest_params *ut_params,
16887 : : const struct test_crypto_vector *reference)
16888 : : {
16889 : : int retval;
16890 : :
16891 : : uint8_t *ciphertext;
16892 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16893 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16894 : : struct rte_cryptodev_info dev_info;
16895 : :
16896 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16897 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16898 : :
16899 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16900 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16901 : : printf("Device doesn't support RAW data-path APIs.\n");
16902 : 0 : return TEST_SKIPPED;
16903 : : }
16904 : :
16905 : : /* Verify the capabilities */
16906 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16907 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16908 : 1 : cap_idx.algo.auth = reference->auth_algo;
16909 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16910 : : &cap_idx) == NULL)
16911 : : return TEST_SKIPPED;
16912 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16913 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16914 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16915 : : &cap_idx) == NULL)
16916 : : return TEST_SKIPPED;
16917 : :
16918 : : /* Create session */
16919 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16920 : 1 : reference->cipher_key.len);
16921 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16922 : :
16923 : : /* Setup Authentication Parameters */
16924 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16925 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16926 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16927 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16928 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16929 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16930 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16931 : :
16932 : : /* Setup Cipher Parameters */
16933 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16934 : 1 : ut_params->cipher_xform.next = NULL;
16935 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16936 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16937 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16938 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16939 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16940 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16941 : :
16942 : : /* Create Crypto session*/
16943 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16944 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
16945 : : ts_params->session_mpool);
16946 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16947 : : return TEST_SKIPPED;
16948 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16949 : :
16950 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16951 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16952 : : "Failed to allocate input buffer in mempool");
16953 : :
16954 : : /* clear mbuf payload */
16955 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16956 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16957 : :
16958 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16959 : 1 : reference->ciphertext.len);
16960 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16961 : 1 : memcpy(ciphertext, reference->ciphertext.data,
16962 : 1 : reference->ciphertext.len);
16963 : :
16964 : : /* Create operation */
16965 : : retval = create_cipher_auth_verify_operation(ts_params,
16966 : : ut_params,
16967 : : reference);
16968 : :
16969 [ + - ]: 1 : if (retval < 0)
16970 : : return retval;
16971 : :
16972 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16973 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16974 : : ut_params->op);
16975 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16976 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16977 : : 0);
16978 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16979 : : return retval;
16980 : : } else
16981 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16982 : : ut_params->op);
16983 : :
16984 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16985 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
16986 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16987 : : "crypto op processing passed");
16988 : :
16989 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
16990 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16991 : :
16992 : : return 0;
16993 : : }
16994 : :
16995 : : static int
16996 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16997 : : const struct aead_test_data *tdata,
16998 : : void *digest_mem, uint64_t digest_phys)
16999 : : {
17000 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17001 : : struct crypto_unittest_params *ut_params = &unittest_params;
17002 : :
17003 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
17004 : 1 : const unsigned int iv_len = tdata->iv.len;
17005 : 1 : unsigned int aad_len = tdata->aad.len;
17006 : : unsigned int aad_len_pad = 0;
17007 : :
17008 : : /* Generate Crypto op data structure */
17009 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
17010 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
17011 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
17012 : : "Failed to allocate symmetric crypto operation struct");
17013 : :
17014 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
17015 : :
17016 : 1 : sym_op->aead.digest.data = digest_mem;
17017 : :
17018 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
17019 : : "no room to append digest");
17020 : :
17021 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
17022 : :
17023 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
17024 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
17025 : : auth_tag_len);
17026 : 0 : debug_hexdump(stdout, "digest:",
17027 : 0 : sym_op->aead.digest.data,
17028 : : auth_tag_len);
17029 : : }
17030 : :
17031 : : /* Append aad data */
17032 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
17033 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17034 : : uint8_t *, IV_OFFSET);
17035 : :
17036 : : /* Copy IV 1 byte after the IV pointer, according to the API */
17037 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
17038 : :
17039 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
17040 : :
17041 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17042 : : ut_params->ibuf, aad_len);
17043 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17044 : : "no room to prepend aad");
17045 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17046 : : ut_params->ibuf);
17047 : :
17048 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
17049 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
17050 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17051 : :
17052 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17053 : 0 : debug_hexdump(stdout, "aad:",
17054 : 0 : sym_op->aead.aad.data, aad_len);
17055 : : } else {
17056 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17057 : : uint8_t *, IV_OFFSET);
17058 : :
17059 [ - + ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
17060 : :
17061 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
17062 : :
17063 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17064 : : ut_params->ibuf, aad_len_pad);
17065 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17066 : : "no room to prepend aad");
17067 [ - + ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17068 : : ut_params->ibuf);
17069 : :
17070 [ - + ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
17071 [ - + ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17072 : :
17073 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17074 : 1 : debug_hexdump(stdout, "aad:",
17075 : 1 : sym_op->aead.aad.data, aad_len);
17076 : : }
17077 : :
17078 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
17079 : 1 : sym_op->aead.data.offset = aad_len_pad;
17080 : :
17081 : 1 : return 0;
17082 : : }
17083 : :
17084 : : #define SGL_MAX_NO 16
17085 : :
17086 : : static int
17087 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
17088 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
17089 : : {
17090 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17091 : : struct crypto_unittest_params *ut_params = &unittest_params;
17092 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
17093 : : int retval;
17094 : : int to_trn = 0;
17095 : : int to_trn_tbl[SGL_MAX_NO];
17096 : : int segs = 1;
17097 : : unsigned int trn_data = 0;
17098 : : uint8_t *plaintext, *ciphertext, *auth_tag;
17099 : : struct rte_cryptodev_info dev_info;
17100 : :
17101 : : /* Verify the capabilities */
17102 : : struct rte_cryptodev_sym_capability_idx cap_idx;
17103 : : const struct rte_cryptodev_symmetric_capability *capability;
17104 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
17105 : 3 : cap_idx.algo.aead = tdata->algo;
17106 : 3 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
17107 [ + - ]: 3 : if (capability == NULL)
17108 : : return TEST_SKIPPED;
17109 [ + - ]: 3 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
17110 : 3 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
17111 : : return TEST_SKIPPED;
17112 : :
17113 : : /*
17114 : : * SGL not supported on AESNI_MB PMD CPU crypto,
17115 : : * OOP not supported on AESNI_GCM CPU crypto
17116 : : */
17117 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
17118 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
17119 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
17120 : : return TEST_SKIPPED;
17121 : :
17122 : : /* Detailed check for the particular SGL support flag */
17123 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
17124 [ - + ]: 3 : if (!oop) {
17125 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17126 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
17127 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
17128 : : return TEST_SKIPPED;
17129 : :
17130 : 0 : uint64_t feat_flags = dev_info.feature_flags;
17131 : :
17132 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
17133 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
17134 : : printf("Device doesn't support RAW data-path APIs.\n");
17135 : 0 : return TEST_SKIPPED;
17136 : : }
17137 : : } else {
17138 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17139 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
17140 : : tdata->plaintext.len;
17141 : : /* Raw data path API does not support OOP */
17142 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
17143 : : return TEST_SKIPPED;
17144 [ + + ]: 3 : if (sgl_in && !sgl_out) {
17145 [ + - ]: 1 : if (!(dev_info.feature_flags &
17146 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
17147 : : return TEST_SKIPPED;
17148 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
17149 [ # # ]: 0 : if (!(dev_info.feature_flags &
17150 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
17151 : : return TEST_SKIPPED;
17152 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
17153 [ - + ]: 2 : if (!(dev_info.feature_flags &
17154 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
17155 : : return TEST_SKIPPED;
17156 : : }
17157 : : }
17158 : :
17159 : 1 : if (fragsz > tdata->plaintext.len)
17160 : : fragsz = tdata->plaintext.len;
17161 : :
17162 : 1 : uint16_t plaintext_len = fragsz;
17163 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
17164 : :
17165 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
17166 : 0 : frag_size_oop = tdata->plaintext.len;
17167 : :
17168 : : int ecx = 0;
17169 : : void *digest_mem = NULL;
17170 : :
17171 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
17172 : :
17173 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
17174 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
17175 : : return 1;
17176 : : } else {
17177 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
17178 : : return 1;
17179 : : }
17180 : :
17181 : : /*
17182 : : * For out-of-place we need to alloc another mbuf
17183 : : */
17184 [ + - ]: 1 : if (oop) {
17185 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17186 : : rte_pktmbuf_append(ut_params->obuf,
17187 : 1 : frag_size_oop + prepend_len);
17188 : 1 : buf_oop = ut_params->obuf;
17189 : : }
17190 : :
17191 : : /* Create AEAD session */
17192 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
17193 : 1 : tdata->algo,
17194 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
17195 : 1 : tdata->key.data, tdata->key.len,
17196 : 1 : tdata->aad.len, tdata->auth_tag.len,
17197 : 1 : tdata->iv.len);
17198 [ + - ]: 1 : if (retval < 0)
17199 : : return retval;
17200 : :
17201 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17202 : :
17203 : : /* clear mbuf payload */
17204 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
17205 : : rte_pktmbuf_tailroom(ut_params->ibuf));
17206 : :
17207 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17208 : : plaintext_len);
17209 : :
17210 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
17211 : :
17212 : : trn_data += plaintext_len;
17213 : :
17214 : 1 : buf = ut_params->ibuf;
17215 : :
17216 : : /*
17217 : : * Loop until no more fragments
17218 : : */
17219 : :
17220 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
17221 : 5 : ++segs;
17222 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
17223 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
17224 : :
17225 : 5 : to_trn_tbl[ecx++] = to_trn;
17226 : :
17227 [ - + ]: 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17228 : : buf = buf->next;
17229 : :
17230 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
17231 : : rte_pktmbuf_tailroom(buf));
17232 : :
17233 : : /* OOP */
17234 [ - + ]: 5 : if (oop && !fragsz_oop) {
17235 : 0 : buf_last_oop = buf_oop->next =
17236 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17237 : : buf_oop = buf_oop->next;
17238 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17239 : : 0, rte_pktmbuf_tailroom(buf_oop));
17240 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
17241 : : }
17242 : :
17243 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17244 : : to_trn);
17245 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
17246 : :
17247 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
17248 : : to_trn);
17249 : 5 : trn_data += to_trn;
17250 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
17251 [ + - ]: 1 : if (oop) {
17252 [ - + ]: 1 : if (!fragsz_oop) {
17253 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17254 : 0 : tdata->auth_tag.len);
17255 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17256 : : }
17257 : : } else {
17258 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17259 : 0 : tdata->auth_tag.len);
17260 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17261 : : }
17262 : : }
17263 : : }
17264 : :
17265 : : uint64_t digest_phys = 0;
17266 : :
17267 : 1 : ut_params->ibuf->nb_segs = segs;
17268 : :
17269 : : segs = 1;
17270 [ + - ]: 1 : if (fragsz_oop && oop) {
17271 : : to_trn = 0;
17272 : : ecx = 0;
17273 : :
17274 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
17275 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17276 : 1 : tdata->auth_tag.len);
17277 : :
17278 : 1 : digest_phys = rte_pktmbuf_iova_offset(
17279 : : ut_params->obuf,
17280 : : tdata->plaintext.len + prepend_len);
17281 : : }
17282 : :
17283 : : trn_data = frag_size_oop;
17284 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
17285 : 0 : ++segs;
17286 : 0 : to_trn =
17287 : 0 : (tdata->plaintext.len - trn_data <
17288 : : frag_size_oop) ?
17289 : 0 : (tdata->plaintext.len - trn_data) :
17290 : : frag_size_oop;
17291 : :
17292 : 0 : to_trn_tbl[ecx++] = to_trn;
17293 : :
17294 : 0 : buf_last_oop = buf_oop->next =
17295 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17296 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(buf_oop->next, "Unexpected end of chain");
17297 : : buf_oop = buf_oop->next;
17298 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17299 : : 0, rte_pktmbuf_tailroom(buf_oop));
17300 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
17301 : :
17302 : 0 : trn_data += to_trn;
17303 : :
17304 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
17305 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17306 : 0 : tdata->auth_tag.len);
17307 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17308 : : }
17309 : : }
17310 : :
17311 : 1 : ut_params->obuf->nb_segs = segs;
17312 : : }
17313 : :
17314 : : /*
17315 : : * Place digest at the end of the last buffer
17316 : : */
17317 [ - + ]: 1 : if (!digest_phys)
17318 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
17319 [ - + ]: 1 : if (oop && buf_last_oop)
17320 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
17321 : :
17322 [ - + ]: 1 : if (!digest_mem && !oop) {
17323 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17324 : 0 : + tdata->auth_tag.len);
17325 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
17326 : : tdata->plaintext.len);
17327 : : }
17328 : :
17329 : : /* Create AEAD operation */
17330 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
17331 : : tdata, digest_mem, digest_phys);
17332 : :
17333 [ + - ]: 1 : if (retval < 0)
17334 : : return retval;
17335 : :
17336 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
17337 : :
17338 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
17339 [ + - ]: 1 : if (oop)
17340 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
17341 : :
17342 : : /* Process crypto operation */
17343 [ - + ]: 1 : if (oop == IN_PLACE &&
17344 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17345 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
17346 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17347 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
17348 : : 0);
17349 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17350 : : return retval;
17351 : : } else
17352 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
17353 : : process_crypto_request(ts_params->valid_devs[0],
17354 : : ut_params->op), "failed to process sym crypto op");
17355 : :
17356 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17357 : : "crypto op processing failed");
17358 : :
17359 : :
17360 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17361 : : uint8_t *, prepend_len);
17362 [ + - ]: 1 : if (oop) {
17363 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17364 : : uint8_t *, prepend_len);
17365 : : }
17366 : :
17367 [ + - ]: 1 : if (fragsz_oop)
17368 : : fragsz = fragsz_oop;
17369 : :
17370 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17371 : : ciphertext,
17372 : : tdata->ciphertext.data,
17373 : : fragsz,
17374 : : "Ciphertext data not as expected");
17375 : :
17376 : 1 : buf = ut_params->op->sym->m_src->next;
17377 [ + - ]: 1 : if (oop)
17378 : 1 : buf = ut_params->op->sym->m_dst->next;
17379 : :
17380 : : unsigned int off = fragsz;
17381 : :
17382 : : ecx = 0;
17383 [ - + ]: 1 : while (buf) {
17384 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
17385 : : uint8_t *);
17386 : :
17387 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17388 : : ciphertext,
17389 : : tdata->ciphertext.data + off,
17390 : : to_trn_tbl[ecx],
17391 : : "Ciphertext data not as expected");
17392 : :
17393 : 0 : off += to_trn_tbl[ecx++];
17394 : 0 : buf = buf->next;
17395 : : }
17396 : :
17397 : : auth_tag = digest_mem;
17398 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17399 : : auth_tag,
17400 : : tdata->auth_tag.data,
17401 : : tdata->auth_tag.len,
17402 : : "Generated auth tag not as expected");
17403 : :
17404 : : return 0;
17405 : : }
17406 : :
17407 : : static int
17408 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17409 : : {
17410 : 1 : return test_authenticated_encryption_SGL(
17411 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17412 : : }
17413 : :
17414 : : static int
17415 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17416 : : {
17417 : 1 : return test_authenticated_encryption_SGL(
17418 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17419 : : }
17420 : :
17421 : : static int
17422 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17423 : : {
17424 : 1 : return test_authenticated_encryption_SGL(
17425 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
17426 : : gcm_test_case_8.plaintext.len);
17427 : : }
17428 : :
17429 : : static int
17430 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17431 : : {
17432 : : /* This test is not for OPENSSL PMD */
17433 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17434 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17435 : : return TEST_SKIPPED;
17436 : :
17437 : 0 : return test_authenticated_encryption_SGL(
17438 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17439 : : }
17440 : :
17441 : : static int
17442 : : test_authentication_verify_fail_when_data_corrupted(
17443 : : struct crypto_testsuite_params *ts_params,
17444 : : struct crypto_unittest_params *ut_params,
17445 : : const struct test_crypto_vector *reference)
17446 : : {
17447 : 1 : return test_authentication_verify_fail_when_data_corruption(
17448 : : ts_params, ut_params, reference, 1);
17449 : : }
17450 : :
17451 : : static int
17452 : : test_authentication_verify_fail_when_tag_corrupted(
17453 : : struct crypto_testsuite_params *ts_params,
17454 : : struct crypto_unittest_params *ut_params,
17455 : : const struct test_crypto_vector *reference)
17456 : : {
17457 : 1 : return test_authentication_verify_fail_when_data_corruption(
17458 : : ts_params, ut_params, reference, 0);
17459 : : }
17460 : :
17461 : : static int
17462 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
17463 : : struct crypto_testsuite_params *ts_params,
17464 : : struct crypto_unittest_params *ut_params,
17465 : : const struct test_crypto_vector *reference)
17466 : : {
17467 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17468 : : ts_params, ut_params, reference, 1);
17469 : : }
17470 : :
17471 : : static int
17472 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
17473 : : struct crypto_testsuite_params *ts_params,
17474 : : struct crypto_unittest_params *ut_params,
17475 : : const struct test_crypto_vector *reference)
17476 : : {
17477 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17478 : : ts_params, ut_params, reference, 0);
17479 : : }
17480 : :
17481 : : static int
17482 : : test_authenticated_decryption_fail_when_data_corrupted(
17483 : : struct crypto_testsuite_params *ts_params,
17484 : : struct crypto_unittest_params *ut_params,
17485 : : const struct test_crypto_vector *reference)
17486 : : {
17487 : 1 : return test_authenticated_decryption_fail_when_corruption(
17488 : : ts_params, ut_params, reference, 1);
17489 : : }
17490 : :
17491 : : static int
17492 : : test_authenticated_decryption_fail_when_tag_corrupted(
17493 : : struct crypto_testsuite_params *ts_params,
17494 : : struct crypto_unittest_params *ut_params,
17495 : : const struct test_crypto_vector *reference)
17496 : : {
17497 : 1 : return test_authenticated_decryption_fail_when_corruption(
17498 : : ts_params, ut_params, reference, 0);
17499 : : }
17500 : :
17501 : : static int
17502 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17503 : : {
17504 : 1 : return test_authentication_verify_fail_when_data_corrupted(
17505 : : &testsuite_params, &unittest_params,
17506 : : &hmac_sha1_test_crypto_vector);
17507 : : }
17508 : :
17509 : : static int
17510 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17511 : : {
17512 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
17513 : : &testsuite_params, &unittest_params,
17514 : : &hmac_sha1_test_crypto_vector);
17515 : : }
17516 : :
17517 : : static int
17518 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17519 : : {
17520 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
17521 : : &testsuite_params, &unittest_params,
17522 : : &aes128_gmac_test_vector);
17523 : : }
17524 : :
17525 : : static int
17526 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17527 : : {
17528 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17529 : : &testsuite_params, &unittest_params,
17530 : : &aes128_gmac_test_vector);
17531 : : }
17532 : :
17533 : : static int
17534 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17535 : : {
17536 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
17537 : : &testsuite_params,
17538 : : &unittest_params,
17539 : : &aes128cbc_hmac_sha1_test_vector);
17540 : : }
17541 : :
17542 : : static int
17543 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17544 : : {
17545 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
17546 : : &testsuite_params,
17547 : : &unittest_params,
17548 : : &aes128cbc_hmac_sha1_test_vector);
17549 : : }
17550 : :
17551 : : static int
17552 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17553 : : {
17554 : 1 : return test_authenticated_encrypt_with_esn(
17555 : : &testsuite_params,
17556 : : &unittest_params,
17557 : : &aes128cbc_hmac_sha1_aad_test_vector);
17558 : : }
17559 : :
17560 : : static int
17561 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17562 : : {
17563 : 1 : return test_authenticated_decrypt_with_esn(
17564 : : &testsuite_params,
17565 : : &unittest_params,
17566 : : &aes128cbc_hmac_sha1_aad_test_vector);
17567 : : }
17568 : :
17569 : : static int
17570 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17571 : : {
17572 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17573 : : }
17574 : :
17575 : : static int
17576 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17577 : : {
17578 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17579 : : }
17580 : :
17581 : : static int
17582 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17583 : : {
17584 : 0 : return test_authenticated_encryption_SGL(
17585 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17586 : : chacha20_poly1305_case_2.plaintext.len);
17587 : : }
17588 : :
17589 : : static int
17590 : 0 : test_SM4_GCM_case_1(void)
17591 : : {
17592 : 0 : return test_authenticated_encryption(&sm4_gcm_case_1);
17593 : : }
17594 : :
17595 : : static int
17596 : 0 : test_SM4_GCM_case_2(void)
17597 : : {
17598 : 0 : return test_authenticated_encryption(&sm4_gcm_case_2);
17599 : : }
17600 : :
17601 : : static int
17602 : 0 : test_SM4_GCM_case_3(void)
17603 : : {
17604 : 0 : return test_authenticated_encryption(&sm4_gcm_case_3);
17605 : : }
17606 : :
17607 : : static int
17608 : 0 : test_SM4_GCM_case_4(void)
17609 : : {
17610 : 0 : return test_authenticated_encryption(&sm4_gcm_case_4);
17611 : : }
17612 : :
17613 : : static int
17614 : 0 : test_SM4_GCM_case_5(void)
17615 : : {
17616 : 0 : return test_authenticated_encryption(&sm4_gcm_case_5);
17617 : : }
17618 : :
17619 : : static int
17620 : 0 : test_SM4_GCM_case_6(void)
17621 : : {
17622 : 0 : return test_authenticated_encryption(&sm4_gcm_case_6);
17623 : : }
17624 : :
17625 : : static int
17626 : 0 : test_SM4_GCM_case_7(void)
17627 : : {
17628 : 0 : return test_authenticated_encryption(&sm4_gcm_case_7);
17629 : : }
17630 : :
17631 : : static int
17632 : 0 : test_SM4_GCM_case_8(void)
17633 : : {
17634 : 0 : return test_authenticated_encryption(&sm4_gcm_case_8);
17635 : : }
17636 : :
17637 : : static int
17638 : 0 : test_SM4_GCM_case_9(void)
17639 : : {
17640 : 0 : return test_authenticated_encryption(&sm4_gcm_case_9);
17641 : : }
17642 : :
17643 : : static int
17644 : 0 : test_SM4_GCM_case_10(void)
17645 : : {
17646 : 0 : return test_authenticated_encryption(&sm4_gcm_case_10);
17647 : : }
17648 : :
17649 : : static int
17650 : 0 : test_SM4_GCM_case_11(void)
17651 : : {
17652 : 0 : return test_authenticated_encryption(&sm4_gcm_case_11);
17653 : : }
17654 : :
17655 : : static int
17656 : 0 : test_SM4_GCM_case_12(void)
17657 : : {
17658 : 0 : return test_authenticated_encryption(&sm4_gcm_case_12);
17659 : : }
17660 : :
17661 : : static int
17662 : 0 : test_SM4_GCM_case_13(void)
17663 : : {
17664 : 0 : return test_authenticated_encryption(&sm4_gcm_case_13);
17665 : : }
17666 : :
17667 : : static int
17668 : 0 : test_SM4_GCM_case_14(void)
17669 : : {
17670 : 0 : return test_authenticated_encryption(&sm4_gcm_case_14);
17671 : : }
17672 : :
17673 : : static int
17674 : 0 : test_SM4_GCM_case_15(void)
17675 : : {
17676 : 0 : return test_authenticated_encryption(&sm4_gcm_case_15);
17677 : : }
17678 : :
17679 : : #ifdef RTE_CRYPTO_SCHEDULER
17680 : :
17681 : : /* global AESNI worker IDs for the scheduler test */
17682 : : uint8_t aesni_ids[2];
17683 : :
17684 : : static int
17685 : 0 : scheduler_testsuite_setup(void)
17686 : : {
17687 : : uint32_t i = 0;
17688 : : int32_t nb_devs, ret;
17689 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
17690 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17691 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
17692 : : uint16_t worker_core_count = 0;
17693 : : uint16_t socket_id = 0;
17694 : :
17695 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17696 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17697 : :
17698 : : /* Identify the Worker Cores
17699 : : * Use 2 worker cores for the device args
17700 : : */
17701 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
17702 [ # # ]: 0 : if (worker_core_count > 1)
17703 : : break;
17704 : : snprintf(vdev_args, sizeof(vdev_args),
17705 : : "%s%d", temp_str, i);
17706 : : strcpy(temp_str, vdev_args);
17707 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
17708 : 0 : worker_core_count++;
17709 : 0 : socket_id = rte_lcore_to_socket_id(i);
17710 : : }
17711 [ # # ]: 0 : if (worker_core_count != 2) {
17712 : 0 : RTE_LOG(ERR, USER1,
17713 : : "Cryptodev scheduler test require at least "
17714 : : "two worker cores to run. "
17715 : : "Please use the correct coremask.\n");
17716 : 0 : return TEST_FAILED;
17717 : : }
17718 : : strcpy(temp_str, vdev_args);
17719 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
17720 : : temp_str, socket_id);
17721 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17722 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
17723 : 0 : rte_cryptodev_driver_id_get(
17724 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17725 [ # # ]: 0 : if (nb_devs < 1) {
17726 : 0 : ret = rte_vdev_init(
17727 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17728 : : vdev_args);
17729 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17730 : : "Failed to create instance %u of pmd : %s",
17731 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17732 : : }
17733 : : }
17734 : 0 : return testsuite_setup();
17735 : : }
17736 : :
17737 : : static int
17738 : 0 : test_scheduler_attach_worker_op(void)
17739 : : {
17740 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17741 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17742 : : uint32_t i, nb_devs_attached = 0;
17743 : : int ret;
17744 : : char vdev_name[32];
17745 : 0 : unsigned int count = rte_cryptodev_count();
17746 : :
17747 : : /* create 2 AESNI_MB vdevs on top of existing devices */
17748 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17749 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17750 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17751 : : i);
17752 : 0 : ret = rte_vdev_init(vdev_name, NULL);
17753 : :
17754 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17755 : : "Failed to create instance %u of"
17756 : : " pmd : %s",
17757 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17758 : :
17759 : : if (ret < 0) {
17760 : : RTE_LOG(ERR, USER1,
17761 : : "Failed to create 2 AESNI MB PMDs.\n");
17762 : : return TEST_SKIPPED;
17763 : : }
17764 : : }
17765 : :
17766 : : /* attach 2 AESNI_MB cdevs */
17767 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17768 : : struct rte_cryptodev_info info;
17769 : : unsigned int session_size;
17770 : :
17771 : 0 : rte_cryptodev_info_get(i, &info);
17772 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
17773 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17774 : 0 : continue;
17775 : :
17776 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
17777 : : /*
17778 : : * Create the session mempool again, since now there are new devices
17779 : : * to use the mempool.
17780 : : */
17781 [ # # ]: 0 : if (ts_params->session_mpool) {
17782 : 0 : rte_mempool_free(ts_params->session_mpool);
17783 : 0 : ts_params->session_mpool = NULL;
17784 : : }
17785 : :
17786 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
17787 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17788 : 0 : RTE_LOG(ERR, USER1,
17789 : : "Device does not support "
17790 : : "at least %u sessions\n",
17791 : : MAX_NB_SESSIONS);
17792 : 0 : return TEST_FAILED;
17793 : : }
17794 : : /*
17795 : : * Create mempool with maximum number of sessions,
17796 : : * to include the session headers
17797 : : */
17798 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
17799 : 0 : ts_params->session_mpool =
17800 : 0 : rte_cryptodev_sym_session_pool_create(
17801 : : "test_sess_mp",
17802 : : MAX_NB_SESSIONS, session_size,
17803 : : 0, 0, SOCKET_ID_ANY);
17804 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17805 : : "session mempool allocation failed");
17806 : : }
17807 : :
17808 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
17809 : :
17810 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17811 : : (uint8_t)i);
17812 : :
17813 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17814 : : "Failed to attach device %u of pmd : %s", i,
17815 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17816 : :
17817 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
17818 : :
17819 : 0 : nb_devs_attached++;
17820 : : }
17821 : :
17822 : : return 0;
17823 : : }
17824 : :
17825 : : static int
17826 : 0 : test_scheduler_detach_worker_op(void)
17827 : : {
17828 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17829 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17830 : : uint32_t i;
17831 : : int ret;
17832 : :
17833 [ # # ]: 0 : for (i = 0; i < 2; i++) {
17834 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17835 : 0 : aesni_ids[i]);
17836 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17837 : : "Failed to detach device %u", aesni_ids[i]);
17838 : : }
17839 : :
17840 : : return 0;
17841 : : }
17842 : :
17843 : : static int
17844 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17845 : : {
17846 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17847 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17848 : : /* set mode */
17849 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
17850 : : scheduler_mode);
17851 : : }
17852 : :
17853 : : static int
17854 : 0 : test_scheduler_mode_roundrobin_op(void)
17855 : : {
17856 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17857 : : 0, "Failed to set roundrobin mode");
17858 : : return 0;
17859 : :
17860 : : }
17861 : :
17862 : : static int
17863 : 0 : test_scheduler_mode_multicore_op(void)
17864 : : {
17865 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17866 : : 0, "Failed to set multicore mode");
17867 : :
17868 : : return 0;
17869 : : }
17870 : :
17871 : : static int
17872 : 0 : test_scheduler_mode_failover_op(void)
17873 : : {
17874 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17875 : : 0, "Failed to set failover mode");
17876 : :
17877 : : return 0;
17878 : : }
17879 : :
17880 : : static int
17881 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
17882 : : {
17883 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17884 : : 0, "Failed to set pktsize mode");
17885 : :
17886 : : return 0;
17887 : : }
17888 : :
17889 : : static int
17890 : 0 : scheduler_multicore_testsuite_setup(void)
17891 : : {
17892 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17893 : : return TEST_SKIPPED;
17894 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17895 : 0 : return TEST_SKIPPED;
17896 : : return 0;
17897 : : }
17898 : :
17899 : : static int
17900 : 0 : scheduler_roundrobin_testsuite_setup(void)
17901 : : {
17902 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17903 : : return TEST_SKIPPED;
17904 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17905 : 0 : return TEST_SKIPPED;
17906 : : return 0;
17907 : : }
17908 : :
17909 : : static int
17910 : 0 : scheduler_failover_testsuite_setup(void)
17911 : : {
17912 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17913 : : return TEST_SKIPPED;
17914 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17915 : 0 : return TEST_SKIPPED;
17916 : : return 0;
17917 : : }
17918 : :
17919 : : static int
17920 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
17921 : : {
17922 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17923 : : return TEST_SKIPPED;
17924 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17925 : 0 : return TEST_SKIPPED;
17926 : : return 0;
17927 : : }
17928 : :
17929 : : static void
17930 : 0 : scheduler_mode_testsuite_teardown(void)
17931 : : {
17932 : 0 : test_scheduler_detach_worker_op();
17933 : 0 : }
17934 : :
17935 : : #endif /* RTE_CRYPTO_SCHEDULER */
17936 : :
17937 : : static struct unit_test_suite end_testsuite = {
17938 : : .suite_name = NULL,
17939 : : .setup = NULL,
17940 : : .teardown = NULL,
17941 : : .unit_test_suites = NULL
17942 : : };
17943 : :
17944 : : #ifdef RTE_LIB_SECURITY
17945 : : static struct unit_test_suite ipsec_proto_testsuite = {
17946 : : .suite_name = "IPsec Proto Unit Test Suite",
17947 : : .setup = ipsec_proto_testsuite_setup,
17948 : : .unit_test_cases = {
17949 : : TEST_CASE_NAMED_WITH_DATA(
17950 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17951 : : ut_setup_security, ut_teardown,
17952 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17953 : : TEST_CASE_NAMED_WITH_DATA(
17954 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17955 : : ut_setup_security, ut_teardown,
17956 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17957 : : TEST_CASE_NAMED_WITH_DATA(
17958 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17959 : : ut_setup_security, ut_teardown,
17960 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17961 : : TEST_CASE_NAMED_WITH_DATA(
17962 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17963 : : ut_setup_security, ut_teardown,
17964 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17965 : : TEST_CASE_NAMED_WITH_DATA(
17966 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17967 : : ut_setup_security, ut_teardown,
17968 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17969 : : TEST_CASE_NAMED_WITH_DATA(
17970 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17971 : : ut_setup_security, ut_teardown,
17972 : : test_ipsec_proto_known_vec,
17973 : : &pkt_aes_128_cbc_md5),
17974 : : TEST_CASE_NAMED_WITH_DATA(
17975 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
17976 : : ut_setup_security, ut_teardown,
17977 : : test_ipsec_proto_known_vec,
17978 : : &pkt_aes_128_ctr_hmac_sha256),
17979 : : TEST_CASE_NAMED_WITH_DATA(
17980 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
17981 : : ut_setup_security, ut_teardown,
17982 : : test_ipsec_proto_known_vec,
17983 : : &pkt_aes_128_ctr_hmac_sha384),
17984 : : TEST_CASE_NAMED_WITH_DATA(
17985 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
17986 : : ut_setup_security, ut_teardown,
17987 : : test_ipsec_proto_known_vec,
17988 : : &pkt_aes_128_ctr_hmac_sha512),
17989 : : TEST_CASE_NAMED_WITH_DATA(
17990 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
17991 : : ut_setup_security, ut_teardown,
17992 : : test_ipsec_proto_known_vec_inb,
17993 : : &pkt_aes_128_ctr_hmac_sha256),
17994 : : TEST_CASE_NAMED_WITH_DATA(
17995 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
17996 : : ut_setup_security, ut_teardown,
17997 : : test_ipsec_proto_known_vec_inb,
17998 : : &pkt_aes_128_ctr_hmac_sha384),
17999 : : TEST_CASE_NAMED_WITH_DATA(
18000 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
18001 : : ut_setup_security, ut_teardown,
18002 : : test_ipsec_proto_known_vec_inb,
18003 : : &pkt_aes_128_ctr_hmac_sha512),
18004 : : TEST_CASE_NAMED_WITH_DATA(
18005 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18006 : : ut_setup_security, ut_teardown,
18007 : : test_ipsec_proto_known_vec,
18008 : : &pkt_aes_128_cbc_hmac_sha256),
18009 : : TEST_CASE_NAMED_WITH_DATA(
18010 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18011 : : ut_setup_security, ut_teardown,
18012 : : test_ipsec_proto_known_vec,
18013 : : &pkt_aes_128_cbc_hmac_sha384),
18014 : : TEST_CASE_NAMED_WITH_DATA(
18015 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18016 : : ut_setup_security, ut_teardown,
18017 : : test_ipsec_proto_known_vec,
18018 : : &pkt_aes_128_cbc_hmac_sha512),
18019 : : TEST_CASE_NAMED_WITH_DATA(
18020 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18021 : : ut_setup_security, ut_teardown,
18022 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
18023 : : TEST_CASE_NAMED_WITH_DATA(
18024 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18025 : : ut_setup_security, ut_teardown,
18026 : : test_ipsec_proto_known_vec,
18027 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18028 : : TEST_CASE_NAMED_WITH_DATA(
18029 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18030 : : ut_setup_security, ut_teardown,
18031 : : test_ipsec_proto_known_vec,
18032 : : &pkt_null_aes_xcbc),
18033 : : TEST_CASE_NAMED_WITH_DATA(
18034 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18035 : : ut_setup_security, ut_teardown,
18036 : : test_ipsec_proto_known_vec,
18037 : : &pkt_des_cbc_hmac_sha256),
18038 : : TEST_CASE_NAMED_WITH_DATA(
18039 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18040 : : ut_setup_security, ut_teardown,
18041 : : test_ipsec_proto_known_vec,
18042 : : &pkt_des_cbc_hmac_sha384),
18043 : : TEST_CASE_NAMED_WITH_DATA(
18044 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18045 : : ut_setup_security, ut_teardown,
18046 : : test_ipsec_proto_known_vec,
18047 : : &pkt_des_cbc_hmac_sha512),
18048 : : TEST_CASE_NAMED_WITH_DATA(
18049 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18050 : : ut_setup_security, ut_teardown,
18051 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
18052 : : TEST_CASE_NAMED_WITH_DATA(
18053 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18054 : : ut_setup_security, ut_teardown,
18055 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
18056 : : TEST_CASE_NAMED_WITH_DATA(
18057 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18058 : : ut_setup_security, ut_teardown,
18059 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
18060 : : TEST_CASE_NAMED_WITH_DATA(
18061 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18062 : : ut_setup_security, ut_teardown,
18063 : : test_ipsec_proto_known_vec,
18064 : : &pkt_des_cbc_hmac_sha256_v6),
18065 : : TEST_CASE_NAMED_WITH_DATA(
18066 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18067 : : ut_setup_security, ut_teardown,
18068 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
18069 : : TEST_CASE_NAMED_WITH_DATA(
18070 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18071 : : ut_setup_security, ut_teardown,
18072 : : test_ipsec_proto_known_vec,
18073 : : &pkt_ah_tunnel_sha256),
18074 : : TEST_CASE_NAMED_WITH_DATA(
18075 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18076 : : ut_setup_security, ut_teardown,
18077 : : test_ipsec_proto_known_vec,
18078 : : &pkt_ah_transport_sha256),
18079 : : TEST_CASE_NAMED_WITH_DATA(
18080 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18081 : : ut_setup_security, ut_teardown,
18082 : : test_ipsec_proto_known_vec,
18083 : : &pkt_ah_ipv4_aes_gmac_128),
18084 : : TEST_CASE_NAMED_WITH_DATA(
18085 : : "Outbound fragmented packet",
18086 : : ut_setup_security, ut_teardown,
18087 : : test_ipsec_proto_known_vec_fragmented,
18088 : : &pkt_aes_128_gcm_frag),
18089 : : TEST_CASE_NAMED_WITH_DATA(
18090 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
18091 : : ut_setup_security, ut_teardown,
18092 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
18093 : : TEST_CASE_NAMED_WITH_DATA(
18094 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
18095 : : ut_setup_security, ut_teardown,
18096 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
18097 : : TEST_CASE_NAMED_WITH_DATA(
18098 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
18099 : : ut_setup_security, ut_teardown,
18100 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
18101 : : TEST_CASE_NAMED_WITH_DATA(
18102 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
18103 : : ut_setup_security, ut_teardown,
18104 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
18105 : : TEST_CASE_NAMED_WITH_DATA(
18106 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
18107 : : ut_setup_security, ut_teardown,
18108 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
18109 : : TEST_CASE_NAMED_WITH_DATA(
18110 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
18111 : : ut_setup_security, ut_teardown,
18112 : : test_ipsec_proto_known_vec_inb,
18113 : : &pkt_aes_128_cbc_md5),
18114 : : TEST_CASE_NAMED_WITH_DATA(
18115 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18116 : : ut_setup_security, ut_teardown,
18117 : : test_ipsec_proto_known_vec_inb,
18118 : : &pkt_aes_128_cbc_hmac_sha256),
18119 : : TEST_CASE_NAMED_WITH_DATA(
18120 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18121 : : ut_setup_security, ut_teardown,
18122 : : test_ipsec_proto_known_vec_inb,
18123 : : &pkt_aes_128_cbc_hmac_sha384),
18124 : : TEST_CASE_NAMED_WITH_DATA(
18125 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18126 : : ut_setup_security, ut_teardown,
18127 : : test_ipsec_proto_known_vec_inb,
18128 : : &pkt_aes_128_cbc_hmac_sha512),
18129 : : TEST_CASE_NAMED_WITH_DATA(
18130 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18131 : : ut_setup_security, ut_teardown,
18132 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
18133 : : TEST_CASE_NAMED_WITH_DATA(
18134 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18135 : : ut_setup_security, ut_teardown,
18136 : : test_ipsec_proto_known_vec_inb,
18137 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18138 : : TEST_CASE_NAMED_WITH_DATA(
18139 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18140 : : ut_setup_security, ut_teardown,
18141 : : test_ipsec_proto_known_vec_inb,
18142 : : &pkt_null_aes_xcbc),
18143 : : TEST_CASE_NAMED_WITH_DATA(
18144 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18145 : : ut_setup_security, ut_teardown,
18146 : : test_ipsec_proto_known_vec_inb,
18147 : : &pkt_des_cbc_hmac_sha256),
18148 : : TEST_CASE_NAMED_WITH_DATA(
18149 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18150 : : ut_setup_security, ut_teardown,
18151 : : test_ipsec_proto_known_vec_inb,
18152 : : &pkt_des_cbc_hmac_sha384),
18153 : : TEST_CASE_NAMED_WITH_DATA(
18154 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18155 : : ut_setup_security, ut_teardown,
18156 : : test_ipsec_proto_known_vec_inb,
18157 : : &pkt_des_cbc_hmac_sha512),
18158 : : TEST_CASE_NAMED_WITH_DATA(
18159 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18160 : : ut_setup_security, ut_teardown,
18161 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
18162 : : TEST_CASE_NAMED_WITH_DATA(
18163 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18164 : : ut_setup_security, ut_teardown,
18165 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
18166 : : TEST_CASE_NAMED_WITH_DATA(
18167 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18168 : : ut_setup_security, ut_teardown,
18169 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
18170 : : TEST_CASE_NAMED_WITH_DATA(
18171 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18172 : : ut_setup_security, ut_teardown,
18173 : : test_ipsec_proto_known_vec_inb,
18174 : : &pkt_des_cbc_hmac_sha256_v6),
18175 : : TEST_CASE_NAMED_WITH_DATA(
18176 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18177 : : ut_setup_security, ut_teardown,
18178 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
18179 : : TEST_CASE_NAMED_WITH_DATA(
18180 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18181 : : ut_setup_security, ut_teardown,
18182 : : test_ipsec_proto_known_vec_inb,
18183 : : &pkt_ah_tunnel_sha256),
18184 : : TEST_CASE_NAMED_WITH_DATA(
18185 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18186 : : ut_setup_security, ut_teardown,
18187 : : test_ipsec_proto_known_vec_inb,
18188 : : &pkt_ah_transport_sha256),
18189 : : TEST_CASE_NAMED_WITH_DATA(
18190 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18191 : : ut_setup_security, ut_teardown,
18192 : : test_ipsec_proto_known_vec_inb,
18193 : : &pkt_ah_ipv4_aes_gmac_128),
18194 : : TEST_CASE_NAMED_ST(
18195 : : "Combined test alg list",
18196 : : ut_setup_security, ut_teardown,
18197 : : test_ipsec_proto_display_list),
18198 : : TEST_CASE_NAMED_ST(
18199 : : "Combined test alg list (AH)",
18200 : : ut_setup_security, ut_teardown,
18201 : : test_ipsec_proto_ah_tunnel_ipv4),
18202 : : TEST_CASE_NAMED_ST(
18203 : : "IV generation",
18204 : : ut_setup_security, ut_teardown,
18205 : : test_ipsec_proto_iv_gen),
18206 : : TEST_CASE_NAMED_ST(
18207 : : "UDP encapsulation",
18208 : : ut_setup_security, ut_teardown,
18209 : : test_ipsec_proto_udp_encap),
18210 : : TEST_CASE_NAMED_ST(
18211 : : "UDP encapsulation with custom ports",
18212 : : ut_setup_security, ut_teardown,
18213 : : test_ipsec_proto_udp_encap_custom_ports),
18214 : : TEST_CASE_NAMED_ST(
18215 : : "UDP encapsulation ports verification test",
18216 : : ut_setup_security, ut_teardown,
18217 : : test_ipsec_proto_udp_ports_verify),
18218 : : TEST_CASE_NAMED_ST(
18219 : : "SA expiry packets soft",
18220 : : ut_setup_security, ut_teardown,
18221 : : test_ipsec_proto_sa_exp_pkts_soft),
18222 : : TEST_CASE_NAMED_ST(
18223 : : "SA expiry packets hard",
18224 : : ut_setup_security, ut_teardown,
18225 : : test_ipsec_proto_sa_exp_pkts_hard),
18226 : : TEST_CASE_NAMED_ST(
18227 : : "Negative test: ICV corruption",
18228 : : ut_setup_security, ut_teardown,
18229 : : test_ipsec_proto_err_icv_corrupt),
18230 : : TEST_CASE_NAMED_ST(
18231 : : "Tunnel dst addr verification",
18232 : : ut_setup_security, ut_teardown,
18233 : : test_ipsec_proto_tunnel_dst_addr_verify),
18234 : : TEST_CASE_NAMED_ST(
18235 : : "Tunnel src and dst addr verification",
18236 : : ut_setup_security, ut_teardown,
18237 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
18238 : : TEST_CASE_NAMED_ST(
18239 : : "Inner IP checksum",
18240 : : ut_setup_security, ut_teardown,
18241 : : test_ipsec_proto_inner_ip_csum),
18242 : : TEST_CASE_NAMED_ST(
18243 : : "Inner L4 checksum",
18244 : : ut_setup_security, ut_teardown,
18245 : : test_ipsec_proto_inner_l4_csum),
18246 : : TEST_CASE_NAMED_ST(
18247 : : "Tunnel IPv4 in IPv4",
18248 : : ut_setup_security, ut_teardown,
18249 : : test_ipsec_proto_tunnel_v4_in_v4),
18250 : : TEST_CASE_NAMED_ST(
18251 : : "Tunnel IPv6 in IPv6",
18252 : : ut_setup_security, ut_teardown,
18253 : : test_ipsec_proto_tunnel_v6_in_v6),
18254 : : TEST_CASE_NAMED_ST(
18255 : : "Tunnel IPv4 in IPv6",
18256 : : ut_setup_security, ut_teardown,
18257 : : test_ipsec_proto_tunnel_v4_in_v6),
18258 : : TEST_CASE_NAMED_ST(
18259 : : "Tunnel IPv6 in IPv4",
18260 : : ut_setup_security, ut_teardown,
18261 : : test_ipsec_proto_tunnel_v6_in_v4),
18262 : : TEST_CASE_NAMED_ST(
18263 : : "Transport IPv4",
18264 : : ut_setup_security, ut_teardown,
18265 : : test_ipsec_proto_transport_v4),
18266 : : TEST_CASE_NAMED_ST(
18267 : : "AH transport IPv4",
18268 : : ut_setup_security, ut_teardown,
18269 : : test_ipsec_proto_ah_transport_ipv4),
18270 : : TEST_CASE_NAMED_ST(
18271 : : "Transport l4 checksum",
18272 : : ut_setup_security, ut_teardown,
18273 : : test_ipsec_proto_transport_l4_csum),
18274 : : TEST_CASE_NAMED_ST(
18275 : : "Statistics: success",
18276 : : ut_setup_security, ut_teardown,
18277 : : test_ipsec_proto_stats),
18278 : : TEST_CASE_NAMED_ST(
18279 : : "Fragmented packet",
18280 : : ut_setup_security, ut_teardown,
18281 : : test_ipsec_proto_pkt_fragment),
18282 : : TEST_CASE_NAMED_ST(
18283 : : "Tunnel header copy DF (inner 0)",
18284 : : ut_setup_security, ut_teardown,
18285 : : test_ipsec_proto_copy_df_inner_0),
18286 : : TEST_CASE_NAMED_ST(
18287 : : "Tunnel header copy DF (inner 1)",
18288 : : ut_setup_security, ut_teardown,
18289 : : test_ipsec_proto_copy_df_inner_1),
18290 : : TEST_CASE_NAMED_ST(
18291 : : "Tunnel header set DF 0 (inner 1)",
18292 : : ut_setup_security, ut_teardown,
18293 : : test_ipsec_proto_set_df_0_inner_1),
18294 : : TEST_CASE_NAMED_ST(
18295 : : "Tunnel header set DF 1 (inner 0)",
18296 : : ut_setup_security, ut_teardown,
18297 : : test_ipsec_proto_set_df_1_inner_0),
18298 : : TEST_CASE_NAMED_ST(
18299 : : "Tunnel header IPv4 copy DSCP (inner 0)",
18300 : : ut_setup_security, ut_teardown,
18301 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
18302 : : TEST_CASE_NAMED_ST(
18303 : : "Tunnel header IPv4 copy DSCP (inner 1)",
18304 : : ut_setup_security, ut_teardown,
18305 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
18306 : : TEST_CASE_NAMED_ST(
18307 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
18308 : : ut_setup_security, ut_teardown,
18309 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
18310 : : TEST_CASE_NAMED_ST(
18311 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
18312 : : ut_setup_security, ut_teardown,
18313 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
18314 : : TEST_CASE_NAMED_ST(
18315 : : "Tunnel header IPv6 copy DSCP (inner 0)",
18316 : : ut_setup_security, ut_teardown,
18317 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
18318 : : TEST_CASE_NAMED_ST(
18319 : : "Tunnel header IPv6 copy DSCP (inner 1)",
18320 : : ut_setup_security, ut_teardown,
18321 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
18322 : : TEST_CASE_NAMED_ST(
18323 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
18324 : : ut_setup_security, ut_teardown,
18325 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
18326 : : TEST_CASE_NAMED_ST(
18327 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
18328 : : ut_setup_security, ut_teardown,
18329 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
18330 : : TEST_CASE_NAMED_WITH_DATA(
18331 : : "Antireplay with window size 1024",
18332 : : ut_setup_security, ut_teardown,
18333 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
18334 : : TEST_CASE_NAMED_WITH_DATA(
18335 : : "Antireplay with window size 2048",
18336 : : ut_setup_security, ut_teardown,
18337 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
18338 : : TEST_CASE_NAMED_WITH_DATA(
18339 : : "Antireplay with window size 4096",
18340 : : ut_setup_security, ut_teardown,
18341 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
18342 : : TEST_CASE_NAMED_WITH_DATA(
18343 : : "ESN and Antireplay with window size 1024",
18344 : : ut_setup_security, ut_teardown,
18345 : : test_ipsec_proto_pkt_esn_antireplay1024,
18346 : : &pkt_aes_128_gcm),
18347 : : TEST_CASE_NAMED_WITH_DATA(
18348 : : "ESN and Antireplay with window size 2048",
18349 : : ut_setup_security, ut_teardown,
18350 : : test_ipsec_proto_pkt_esn_antireplay2048,
18351 : : &pkt_aes_128_gcm),
18352 : : TEST_CASE_NAMED_WITH_DATA(
18353 : : "ESN and Antireplay with window size 4096",
18354 : : ut_setup_security, ut_teardown,
18355 : : test_ipsec_proto_pkt_esn_antireplay4096,
18356 : : &pkt_aes_128_gcm),
18357 : : TEST_CASE_NAMED_ST(
18358 : : "Tunnel header IPv4 decrement inner TTL",
18359 : : ut_setup_security, ut_teardown,
18360 : : test_ipsec_proto_ipv4_ttl_decrement),
18361 : : TEST_CASE_NAMED_ST(
18362 : : "Tunnel header IPv6 decrement inner hop limit",
18363 : : ut_setup_security, ut_teardown,
18364 : : test_ipsec_proto_ipv6_hop_limit_decrement),
18365 : : TEST_CASE_NAMED_ST(
18366 : : "Multi-segmented mode",
18367 : : ut_setup_security, ut_teardown,
18368 : : test_ipsec_proto_sgl),
18369 : : TEST_CASE_NAMED_ST(
18370 : : "Multi-segmented external mbuf mode",
18371 : : ut_setup_security, ut_teardown,
18372 : : test_ipsec_proto_sgl_ext_mbuf),
18373 : : TEST_CASE_NAMED_WITH_DATA(
18374 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
18375 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18376 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
18377 : : TEST_CASES_END() /**< NULL terminate unit test array */
18378 : : }
18379 : : };
18380 : :
18381 : : static struct unit_test_suite pdcp_proto_testsuite = {
18382 : : .suite_name = "PDCP Proto Unit Test Suite",
18383 : : .setup = pdcp_proto_testsuite_setup,
18384 : : .unit_test_cases = {
18385 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
18386 : : test_PDCP_PROTO_all),
18387 : : TEST_CASES_END() /**< NULL terminate unit test array */
18388 : : }
18389 : : };
18390 : :
18391 : : static struct unit_test_suite tls12_record_proto_testsuite = {
18392 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
18393 : : .setup = tls_record_proto_testsuite_setup,
18394 : : .unit_test_cases = {
18395 : : TEST_CASE_NAMED_WITH_DATA(
18396 : : "Write record known vector AES-GCM-128 (vector 1)",
18397 : : ut_setup_security, ut_teardown,
18398 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
18399 : : TEST_CASE_NAMED_WITH_DATA(
18400 : : "Write record known vector AES-GCM-128 (vector 2)",
18401 : : ut_setup_security, ut_teardown,
18402 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
18403 : : TEST_CASE_NAMED_WITH_DATA(
18404 : : "Write record known vector AES-GCM-256",
18405 : : ut_setup_security, ut_teardown,
18406 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
18407 : : TEST_CASE_NAMED_WITH_DATA(
18408 : : "Write record known vector AES-CBC-128-SHA1",
18409 : : ut_setup_security, ut_teardown,
18410 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
18411 : : TEST_CASE_NAMED_WITH_DATA(
18412 : : "Write record known vector AES-128-CBC-SHA256",
18413 : : ut_setup_security, ut_teardown,
18414 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
18415 : : TEST_CASE_NAMED_WITH_DATA(
18416 : : "Write record known vector AES-256-CBC-SHA1",
18417 : : ut_setup_security, ut_teardown,
18418 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
18419 : : TEST_CASE_NAMED_WITH_DATA(
18420 : : "Write record known vector AES-256-CBC-SHA256",
18421 : : ut_setup_security, ut_teardown,
18422 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
18423 : : TEST_CASE_NAMED_WITH_DATA(
18424 : : "Write record known vector AES-256-CBC-SHA384",
18425 : : ut_setup_security, ut_teardown,
18426 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
18427 : : TEST_CASE_NAMED_WITH_DATA(
18428 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18429 : : ut_setup_security, ut_teardown,
18430 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
18431 : : TEST_CASE_NAMED_WITH_DATA(
18432 : : "Write record known vector NULL-SHA1-HMAC",
18433 : : ut_setup_security, ut_teardown,
18434 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
18435 : : TEST_CASE_NAMED_WITH_DATA(
18436 : : "Write record known vector CHACHA20-POLY1305",
18437 : : ut_setup_security, ut_teardown,
18438 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
18439 : :
18440 : : TEST_CASE_NAMED_WITH_DATA(
18441 : : "Read record known vector AES-GCM-128 (vector 1)",
18442 : : ut_setup_security, ut_teardown,
18443 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
18444 : : TEST_CASE_NAMED_WITH_DATA(
18445 : : "Read record known vector AES-GCM-128 (vector 2)",
18446 : : ut_setup_security, ut_teardown,
18447 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
18448 : : TEST_CASE_NAMED_WITH_DATA(
18449 : : "Read record known vector AES-GCM-256",
18450 : : ut_setup_security, ut_teardown,
18451 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
18452 : : TEST_CASE_NAMED_WITH_DATA(
18453 : : "Read record known vector AES-128-CBC-SHA1",
18454 : : ut_setup_security, ut_teardown,
18455 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
18456 : : TEST_CASE_NAMED_WITH_DATA(
18457 : : "Read record known vector AES-128-CBC-SHA256",
18458 : : ut_setup_security, ut_teardown,
18459 : : test_tls_record_proto_known_vec_read,
18460 : : &tls_test_data_aes_128_cbc_sha256_hmac),
18461 : : TEST_CASE_NAMED_WITH_DATA(
18462 : : "Read record known vector AES-256-CBC-SHA1",
18463 : : ut_setup_security, ut_teardown,
18464 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
18465 : : TEST_CASE_NAMED_WITH_DATA(
18466 : : "Read record known vector AES-256-CBC-SHA256",
18467 : : ut_setup_security, ut_teardown,
18468 : : test_tls_record_proto_known_vec_read,
18469 : : &tls_test_data_aes_256_cbc_sha256_hmac),
18470 : : TEST_CASE_NAMED_WITH_DATA(
18471 : : "Read record known vector AES-256-CBC-SHA384",
18472 : : ut_setup_security, ut_teardown,
18473 : : test_tls_record_proto_known_vec_read,
18474 : : &tls_test_data_aes_256_cbc_sha384_hmac),
18475 : : TEST_CASE_NAMED_WITH_DATA(
18476 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18477 : : ut_setup_security, ut_teardown,
18478 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18479 : : TEST_CASE_NAMED_WITH_DATA(
18480 : : "Read record known vector NULL-SHA1-HMAC",
18481 : : ut_setup_security, ut_teardown,
18482 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18483 : : TEST_CASE_NAMED_WITH_DATA(
18484 : : "Read record known vector CHACHA20-POLY1305",
18485 : : ut_setup_security, ut_teardown,
18486 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18487 : :
18488 : : TEST_CASE_NAMED_ST(
18489 : : "Combined test alg list",
18490 : : ut_setup_security, ut_teardown,
18491 : : test_tls_1_2_record_proto_display_list),
18492 : : TEST_CASE_NAMED_ST(
18493 : : "Data walkthrough combined test alg list",
18494 : : ut_setup_security, ut_teardown,
18495 : : test_tls_1_2_record_proto_data_walkthrough),
18496 : : TEST_CASE_NAMED_ST(
18497 : : "Multi-segmented mode",
18498 : : ut_setup_security, ut_teardown,
18499 : : test_tls_1_2_record_proto_sgl),
18500 : : TEST_CASE_NAMED_ST(
18501 : : "Multi-segmented mode data walkthrough",
18502 : : ut_setup_security, ut_teardown,
18503 : : test_tls_1_2_record_proto_sgl_data_walkthrough),
18504 : : TEST_CASE_NAMED_ST(
18505 : : "Multi-segmented mode out of place",
18506 : : ut_setup_security, ut_teardown,
18507 : : test_tls_1_2_record_proto_sgl_oop),
18508 : : TEST_CASE_NAMED_ST(
18509 : : "TLS packet header corruption",
18510 : : ut_setup_security, ut_teardown,
18511 : : test_tls_record_proto_corrupt_pkt),
18512 : : TEST_CASE_NAMED_ST(
18513 : : "Custom content type",
18514 : : ut_setup_security, ut_teardown,
18515 : : test_tls_record_proto_custom_content_type),
18516 : : TEST_CASE_NAMED_ST(
18517 : : "Zero len TLS record with content type as app",
18518 : : ut_setup_security, ut_teardown,
18519 : : test_tls_record_proto_zero_len),
18520 : : TEST_CASE_NAMED_ST(
18521 : : "Zero len TLS record with content type as ctrl",
18522 : : ut_setup_security, ut_teardown,
18523 : : test_tls_record_proto_zero_len_non_app),
18524 : : TEST_CASE_NAMED_ST(
18525 : : "TLS record DM mode with optional padding < 2 blocks",
18526 : : ut_setup_security, ut_teardown,
18527 : : test_tls_record_proto_dm_opt_padding),
18528 : : TEST_CASE_NAMED_ST(
18529 : : "TLS record DM mode with optional padding > 2 blocks",
18530 : : ut_setup_security, ut_teardown,
18531 : : test_tls_record_proto_dm_opt_padding_1),
18532 : : TEST_CASE_NAMED_ST(
18533 : : "TLS record SG mode with optional padding < 2 blocks",
18534 : : ut_setup_security, ut_teardown,
18535 : : test_tls_record_proto_sg_opt_padding),
18536 : : TEST_CASE_NAMED_ST(
18537 : : "TLS record SG mode with optional padding > 2 blocks",
18538 : : ut_setup_security, ut_teardown,
18539 : : test_tls_record_proto_sg_opt_padding_1),
18540 : : TEST_CASE_NAMED_ST(
18541 : : "TLS record SG mode with optional padding > 2 blocks",
18542 : : ut_setup_security, ut_teardown,
18543 : : test_tls_record_proto_sg_opt_padding_2),
18544 : : TEST_CASE_NAMED_ST(
18545 : : "TLS record SG mode with optional padding > max range",
18546 : : ut_setup_security, ut_teardown,
18547 : : test_tls_record_proto_sg_opt_padding_max),
18548 : : TEST_CASE_NAMED_ST(
18549 : : "TLS record SG mode with padding corruption",
18550 : : ut_setup_security, ut_teardown,
18551 : : test_tls_record_proto_sg_opt_padding_corrupt),
18552 : : TEST_CASES_END() /**< NULL terminate unit test array */
18553 : : }
18554 : : };
18555 : :
18556 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
18557 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18558 : : .setup = tls_record_proto_testsuite_setup,
18559 : : .unit_test_cases = {
18560 : : TEST_CASE_NAMED_WITH_DATA(
18561 : : "Write record known vector AES-GCM-128",
18562 : : ut_setup_security, ut_teardown,
18563 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18564 : : TEST_CASE_NAMED_WITH_DATA(
18565 : : "Write record known vector AES-GCM-256",
18566 : : ut_setup_security, ut_teardown,
18567 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18568 : : TEST_CASE_NAMED_WITH_DATA(
18569 : : "Write record known vector AES-128-CBC-SHA1",
18570 : : ut_setup_security, ut_teardown,
18571 : : test_tls_record_proto_known_vec,
18572 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18573 : : TEST_CASE_NAMED_WITH_DATA(
18574 : : "Write record known vector AES-128-CBC-SHA256",
18575 : : ut_setup_security, ut_teardown,
18576 : : test_tls_record_proto_known_vec,
18577 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18578 : : TEST_CASE_NAMED_WITH_DATA(
18579 : : "Write record known vector AES-256-CBC-SHA1",
18580 : : ut_setup_security, ut_teardown,
18581 : : test_tls_record_proto_known_vec,
18582 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18583 : : TEST_CASE_NAMED_WITH_DATA(
18584 : : "Write record known vector AES-256-CBC-SHA256",
18585 : : ut_setup_security, ut_teardown,
18586 : : test_tls_record_proto_known_vec,
18587 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18588 : : TEST_CASE_NAMED_WITH_DATA(
18589 : : "Write record known vector AES-256-CBC-SHA384",
18590 : : ut_setup_security, ut_teardown,
18591 : : test_tls_record_proto_known_vec,
18592 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18593 : : TEST_CASE_NAMED_WITH_DATA(
18594 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18595 : : ut_setup_security, ut_teardown,
18596 : : test_tls_record_proto_known_vec,
18597 : : &dtls_test_data_3des_cbc_sha1_hmac),
18598 : : TEST_CASE_NAMED_WITH_DATA(
18599 : : "Write record known vector NULL-SHA1-HMAC",
18600 : : ut_setup_security, ut_teardown,
18601 : : test_tls_record_proto_known_vec,
18602 : : &dtls_test_data_null_cipher_sha1_hmac),
18603 : : TEST_CASE_NAMED_WITH_DATA(
18604 : : "Write record known vector CHACHA20-POLY1305",
18605 : : ut_setup_security, ut_teardown,
18606 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18607 : : TEST_CASE_NAMED_WITH_DATA(
18608 : : "Read record known vector AES-GCM-128",
18609 : : ut_setup_security, ut_teardown,
18610 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18611 : : TEST_CASE_NAMED_WITH_DATA(
18612 : : "Read record known vector AES-GCM-256",
18613 : : ut_setup_security, ut_teardown,
18614 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18615 : : TEST_CASE_NAMED_WITH_DATA(
18616 : : "Read record known vector AES-128-CBC-SHA1",
18617 : : ut_setup_security, ut_teardown,
18618 : : test_tls_record_proto_known_vec_read,
18619 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18620 : : TEST_CASE_NAMED_WITH_DATA(
18621 : : "Read record known vector AES-128-CBC-SHA256",
18622 : : ut_setup_security, ut_teardown,
18623 : : test_tls_record_proto_known_vec_read,
18624 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18625 : : TEST_CASE_NAMED_WITH_DATA(
18626 : : "Read record known vector AES-256-CBC-SHA1",
18627 : : ut_setup_security, ut_teardown,
18628 : : test_tls_record_proto_known_vec_read,
18629 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18630 : : TEST_CASE_NAMED_WITH_DATA(
18631 : : "Read record known vector AES-256-CBC-SHA256",
18632 : : ut_setup_security, ut_teardown,
18633 : : test_tls_record_proto_known_vec_read,
18634 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18635 : : TEST_CASE_NAMED_WITH_DATA(
18636 : : "Read record known vector AES-256-CBC-SHA384",
18637 : : ut_setup_security, ut_teardown,
18638 : : test_tls_record_proto_known_vec_read,
18639 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18640 : : TEST_CASE_NAMED_WITH_DATA(
18641 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18642 : : ut_setup_security, ut_teardown,
18643 : : test_tls_record_proto_known_vec_read,
18644 : : &dtls_test_data_3des_cbc_sha1_hmac),
18645 : : TEST_CASE_NAMED_WITH_DATA(
18646 : : "Read record known vector NULL-SHA1-HMAC",
18647 : : ut_setup_security, ut_teardown,
18648 : : test_tls_record_proto_known_vec_read,
18649 : : &dtls_test_data_null_cipher_sha1_hmac),
18650 : : TEST_CASE_NAMED_WITH_DATA(
18651 : : "Read record known vector CHACHA20-POLY1305",
18652 : : ut_setup_security, ut_teardown,
18653 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18654 : :
18655 : : TEST_CASE_NAMED_ST(
18656 : : "Combined test alg list",
18657 : : ut_setup_security, ut_teardown,
18658 : : test_dtls_1_2_record_proto_display_list),
18659 : : TEST_CASE_NAMED_ST(
18660 : : "Data walkthrough combined test alg list",
18661 : : ut_setup_security, ut_teardown,
18662 : : test_dtls_1_2_record_proto_data_walkthrough),
18663 : : TEST_CASE_NAMED_ST(
18664 : : "Multi-segmented mode",
18665 : : ut_setup_security, ut_teardown,
18666 : : test_dtls_1_2_record_proto_sgl),
18667 : : TEST_CASE_NAMED_ST(
18668 : : "Multi-segmented mode data walkthrough",
18669 : : ut_setup_security, ut_teardown,
18670 : : test_dtls_1_2_record_proto_sgl_data_walkthrough),
18671 : : TEST_CASE_NAMED_ST(
18672 : : "Multi-segmented mode out of place",
18673 : : ut_setup_security, ut_teardown,
18674 : : test_dtls_1_2_record_proto_sgl_oop),
18675 : : TEST_CASE_NAMED_ST(
18676 : : "Packet corruption",
18677 : : ut_setup_security, ut_teardown,
18678 : : test_dtls_1_2_record_proto_corrupt_pkt),
18679 : : TEST_CASE_NAMED_ST(
18680 : : "Custom content type",
18681 : : ut_setup_security, ut_teardown,
18682 : : test_dtls_1_2_record_proto_custom_content_type),
18683 : : TEST_CASE_NAMED_ST(
18684 : : "Zero len DTLS record with content type as app",
18685 : : ut_setup_security, ut_teardown,
18686 : : test_dtls_1_2_record_proto_zero_len),
18687 : : TEST_CASE_NAMED_ST(
18688 : : "Zero len DTLS record with content type as ctrl",
18689 : : ut_setup_security, ut_teardown,
18690 : : test_dtls_1_2_record_proto_zero_len_non_app),
18691 : : TEST_CASE_NAMED_ST(
18692 : : "Antireplay with window size 64",
18693 : : ut_setup_security, ut_teardown,
18694 : : test_dtls_1_2_record_proto_antireplay64),
18695 : : TEST_CASE_NAMED_ST(
18696 : : "Antireplay with window size 128",
18697 : : ut_setup_security, ut_teardown,
18698 : : test_dtls_1_2_record_proto_antireplay128),
18699 : : TEST_CASE_NAMED_ST(
18700 : : "Antireplay with window size 256",
18701 : : ut_setup_security, ut_teardown,
18702 : : test_dtls_1_2_record_proto_antireplay256),
18703 : : TEST_CASE_NAMED_ST(
18704 : : "Antireplay with window size 512",
18705 : : ut_setup_security, ut_teardown,
18706 : : test_dtls_1_2_record_proto_antireplay512),
18707 : : TEST_CASE_NAMED_ST(
18708 : : "Antireplay with window size 1024",
18709 : : ut_setup_security, ut_teardown,
18710 : : test_dtls_1_2_record_proto_antireplay1024),
18711 : : TEST_CASE_NAMED_ST(
18712 : : "Antireplay with window size 2048",
18713 : : ut_setup_security, ut_teardown,
18714 : : test_dtls_1_2_record_proto_antireplay2048),
18715 : : TEST_CASE_NAMED_ST(
18716 : : "Antireplay with window size 4096",
18717 : : ut_setup_security, ut_teardown,
18718 : : test_dtls_1_2_record_proto_antireplay4096),
18719 : : TEST_CASE_NAMED_ST(
18720 : : "DTLS record DM mode with optional padding < 2 blocks",
18721 : : ut_setup_security, ut_teardown,
18722 : : test_dtls_1_2_record_proto_dm_opt_padding),
18723 : : TEST_CASE_NAMED_ST(
18724 : : "DTLS record DM mode with optional padding > 2 blocks",
18725 : : ut_setup_security, ut_teardown,
18726 : : test_dtls_1_2_record_proto_dm_opt_padding_1),
18727 : : TEST_CASE_NAMED_ST(
18728 : : "DTLS record SG mode with optional padding < 2 blocks",
18729 : : ut_setup_security, ut_teardown,
18730 : : test_dtls_1_2_record_proto_sg_opt_padding),
18731 : : TEST_CASE_NAMED_ST(
18732 : : "DTLS record SG mode with optional padding > 2 blocks",
18733 : : ut_setup_security, ut_teardown,
18734 : : test_dtls_1_2_record_proto_sg_opt_padding_1),
18735 : : TEST_CASE_NAMED_ST(
18736 : : "DTLS record SG mode with optional padding > 2 blocks",
18737 : : ut_setup_security, ut_teardown,
18738 : : test_dtls_1_2_record_proto_sg_opt_padding_2),
18739 : : TEST_CASE_NAMED_ST(
18740 : : "DTLS record SG mode with optional padding > max range",
18741 : : ut_setup_security, ut_teardown,
18742 : : test_dtls_1_2_record_proto_sg_opt_padding_max),
18743 : : TEST_CASE_NAMED_ST(
18744 : : "DTLS record SG mode with padding corruption",
18745 : : ut_setup_security, ut_teardown,
18746 : : test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18747 : : TEST_CASES_END() /**< NULL terminate unit test array */
18748 : : }
18749 : : };
18750 : :
18751 : : static struct unit_test_suite tls13_record_proto_testsuite = {
18752 : : .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18753 : : .setup = tls_record_proto_testsuite_setup,
18754 : : .unit_test_cases = {
18755 : : TEST_CASE_NAMED_WITH_DATA(
18756 : : "Write record known vector AES-GCM-128",
18757 : : ut_setup_security, ut_teardown,
18758 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18759 : : TEST_CASE_NAMED_WITH_DATA(
18760 : : "Write record known vector AES-GCM-256",
18761 : : ut_setup_security, ut_teardown,
18762 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18763 : : TEST_CASE_NAMED_WITH_DATA(
18764 : : "Write record known vector CHACHA20-POLY1305",
18765 : : ut_setup_security, ut_teardown,
18766 : : test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18767 : :
18768 : : TEST_CASE_NAMED_WITH_DATA(
18769 : : "Read record known vector AES-GCM-128",
18770 : : ut_setup_security, ut_teardown,
18771 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18772 : : TEST_CASE_NAMED_WITH_DATA(
18773 : : "Read record known vector AES-GCM-256",
18774 : : ut_setup_security, ut_teardown,
18775 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18776 : : TEST_CASE_NAMED_WITH_DATA(
18777 : : "Read record known vector CHACHA20-POLY1305",
18778 : : ut_setup_security, ut_teardown,
18779 : : test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18780 : : TEST_CASE_NAMED_ST(
18781 : : "TLS-1.3 record header corruption",
18782 : : ut_setup_security, ut_teardown,
18783 : : test_tls_1_3_record_proto_corrupt_pkt),
18784 : : TEST_CASE_NAMED_ST(
18785 : : "TLS-1.3 record header with custom content type",
18786 : : ut_setup_security, ut_teardown,
18787 : : test_tls_1_3_record_proto_custom_content_type),
18788 : : TEST_CASE_NAMED_ST(
18789 : : "TLS-1.3 record with zero len and content type as app",
18790 : : ut_setup_security, ut_teardown,
18791 : : test_tls_1_3_record_proto_zero_len),
18792 : : TEST_CASE_NAMED_ST(
18793 : : "TLS-1.3 record with zero len and content type as ctrl",
18794 : : ut_setup_security, ut_teardown,
18795 : : test_tls_1_3_record_proto_zero_len_non_app),
18796 : : TEST_CASE_NAMED_ST(
18797 : : "TLS-1.3 record DM mode with optional padding",
18798 : : ut_setup_security, ut_teardown,
18799 : : test_tls_1_3_record_proto_dm_opt_padding),
18800 : : TEST_CASE_NAMED_ST(
18801 : : "TLS-1.3 record SG mode with optional padding - 1",
18802 : : ut_setup_security, ut_teardown,
18803 : : test_tls_1_3_record_proto_sg_opt_padding),
18804 : : TEST_CASE_NAMED_ST(
18805 : : "TLS-1.3 record SG mode with optional padding",
18806 : : ut_setup_security, ut_teardown,
18807 : : test_tls_1_3_record_proto_sg_opt_padding_1),
18808 : : TEST_CASE_NAMED_ST(
18809 : : "Combined test alg list",
18810 : : ut_setup_security, ut_teardown,
18811 : : test_tls_1_3_record_proto_display_list),
18812 : : TEST_CASE_NAMED_ST(
18813 : : "Data walkthrough combined test alg list",
18814 : : ut_setup_security, ut_teardown,
18815 : : test_tls_1_3_record_proto_data_walkthrough),
18816 : : TEST_CASE_NAMED_ST(
18817 : : "Multi-segmented mode",
18818 : : ut_setup_security, ut_teardown,
18819 : : test_tls_1_3_record_proto_sgl),
18820 : : TEST_CASE_NAMED_ST(
18821 : : "Multi-segmented mode data walkthrough",
18822 : : ut_setup_security, ut_teardown,
18823 : : test_tls_1_3_record_proto_sgl_data_walkthrough),
18824 : : TEST_CASE_NAMED_ST(
18825 : : "Multi-segmented mode out of place",
18826 : : ut_setup_security, ut_teardown,
18827 : : test_tls_1_3_record_proto_sgl_oop),
18828 : : TEST_CASES_END() /**< NULL terminate unit test array */
18829 : : }
18830 : : };
18831 : :
18832 : : #define ADD_UPLINK_TESTCASE(data) \
18833 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
18834 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
18835 : :
18836 : : #define ADD_DOWNLINK_TESTCASE(data) \
18837 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
18838 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
18839 : :
18840 : : static struct unit_test_suite docsis_proto_testsuite = {
18841 : : .suite_name = "DOCSIS Proto Unit Test Suite",
18842 : : .setup = docsis_proto_testsuite_setup,
18843 : : .unit_test_cases = {
18844 : : /* Uplink */
18845 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
18846 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
18847 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
18848 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
18849 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
18850 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
18851 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
18852 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
18853 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
18854 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
18855 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
18856 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
18857 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
18858 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
18859 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
18860 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
18861 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
18862 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
18863 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
18864 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
18865 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
18866 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
18867 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
18868 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
18869 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
18870 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
18871 : : /* Downlink */
18872 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18873 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18874 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18875 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18876 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18877 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18878 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18879 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18880 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18881 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18882 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18883 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18884 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18885 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18886 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18887 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18888 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18889 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18890 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18891 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18892 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18893 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18894 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18895 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18896 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18897 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18898 : : TEST_CASES_END() /**< NULL terminate unit test array */
18899 : : }
18900 : : };
18901 : : #endif
18902 : :
18903 : : static struct unit_test_suite cryptodev_gen_testsuite = {
18904 : : .suite_name = "Crypto General Unit Test Suite",
18905 : : .setup = crypto_gen_testsuite_setup,
18906 : : .unit_test_cases = {
18907 : : TEST_CASE_ST(ut_setup, ut_teardown,
18908 : : test_device_reconfigure),
18909 : : TEST_CASE_ST(ut_setup, ut_teardown,
18910 : : test_device_configure_invalid_dev_id),
18911 : : TEST_CASE_ST(ut_setup, ut_teardown,
18912 : : test_queue_pair_descriptor_setup),
18913 : : TEST_CASE_ST(ut_setup, ut_teardown,
18914 : : test_device_configure_invalid_queue_pair_ids),
18915 : : TEST_CASE_ST(ut_setup, ut_teardown,
18916 : : test_queue_pair_descriptor_count),
18917 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18918 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18919 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18920 : : TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
18921 : : test_cryptodev_verify_error_recover, &aes_test_data_4),
18922 : : TEST_CASES_END() /**< NULL terminate unit test array */
18923 : : }
18924 : : };
18925 : :
18926 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18927 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
18928 : : .setup = negative_hmac_sha1_testsuite_setup,
18929 : : .unit_test_cases = {
18930 : : /** Negative tests */
18931 : : TEST_CASE_ST(ut_setup, ut_teardown,
18932 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
18933 : : TEST_CASE_ST(ut_setup, ut_teardown,
18934 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18935 : : TEST_CASE_ST(ut_setup, ut_teardown,
18936 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18937 : : TEST_CASE_ST(ut_setup, ut_teardown,
18938 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18939 : :
18940 : : TEST_CASES_END() /**< NULL terminate unit test array */
18941 : : }
18942 : : };
18943 : :
18944 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
18945 : : .suite_name = "Multi Session Unit Test Suite",
18946 : : .setup = multi_session_testsuite_setup,
18947 : : .unit_test_cases = {
18948 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18949 : : TEST_CASE_ST(ut_setup, ut_teardown,
18950 : : test_multi_session_random_usage),
18951 : :
18952 : : TEST_CASES_END() /**< NULL terminate unit test array */
18953 : : }
18954 : : };
18955 : :
18956 : : static struct unit_test_suite cryptodev_null_testsuite = {
18957 : : .suite_name = "NULL Test Suite",
18958 : : .setup = null_testsuite_setup,
18959 : : .unit_test_cases = {
18960 : : TEST_CASE_ST(ut_setup, ut_teardown,
18961 : : test_null_invalid_operation),
18962 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
18963 : : TEST_CASES_END()
18964 : : }
18965 : : };
18966 : :
18967 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
18968 : : .suite_name = "AES CCM Authenticated Test Suite",
18969 : : .setup = aes_ccm_auth_testsuite_setup,
18970 : : .unit_test_cases = {
18971 : : /** AES CCM Authenticated Encryption 128 bits key*/
18972 : : TEST_CASE_ST(ut_setup, ut_teardown,
18973 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
18974 : : TEST_CASE_ST(ut_setup, ut_teardown,
18975 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
18976 : : TEST_CASE_ST(ut_setup, ut_teardown,
18977 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
18978 : :
18979 : : /** AES CCM Authenticated Decryption 128 bits key*/
18980 : : TEST_CASE_ST(ut_setup, ut_teardown,
18981 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
18982 : : TEST_CASE_ST(ut_setup, ut_teardown,
18983 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
18984 : : TEST_CASE_ST(ut_setup, ut_teardown,
18985 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
18986 : :
18987 : : /** AES CCM Authenticated Encryption 192 bits key */
18988 : : TEST_CASE_ST(ut_setup, ut_teardown,
18989 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
18990 : : TEST_CASE_ST(ut_setup, ut_teardown,
18991 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
18992 : : TEST_CASE_ST(ut_setup, ut_teardown,
18993 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
18994 : :
18995 : : /** AES CCM Authenticated Decryption 192 bits key*/
18996 : : TEST_CASE_ST(ut_setup, ut_teardown,
18997 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
18998 : : TEST_CASE_ST(ut_setup, ut_teardown,
18999 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
19000 : : TEST_CASE_ST(ut_setup, ut_teardown,
19001 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
19002 : :
19003 : : /** AES CCM Authenticated Encryption 256 bits key */
19004 : : TEST_CASE_ST(ut_setup, ut_teardown,
19005 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
19006 : : TEST_CASE_ST(ut_setup, ut_teardown,
19007 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
19008 : : TEST_CASE_ST(ut_setup, ut_teardown,
19009 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
19010 : :
19011 : : /** AES CCM Authenticated Decryption 256 bits key*/
19012 : : TEST_CASE_ST(ut_setup, ut_teardown,
19013 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
19014 : : TEST_CASE_ST(ut_setup, ut_teardown,
19015 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
19016 : : TEST_CASE_ST(ut_setup, ut_teardown,
19017 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
19018 : : TEST_CASES_END()
19019 : : }
19020 : : };
19021 : :
19022 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
19023 : : .suite_name = "AES GCM Authenticated Test Suite",
19024 : : .setup = aes_gcm_auth_testsuite_setup,
19025 : : .unit_test_cases = {
19026 : : /** AES GCM Authenticated Encryption */
19027 : : TEST_CASE_ST(ut_setup, ut_teardown,
19028 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
19029 : : TEST_CASE_ST(ut_setup, ut_teardown,
19030 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
19031 : : TEST_CASE_ST(ut_setup, ut_teardown,
19032 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
19033 : : TEST_CASE_ST(ut_setup, ut_teardown,
19034 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
19035 : : TEST_CASE_ST(ut_setup, ut_teardown,
19036 : : test_AES_GCM_authenticated_encryption_test_case_1),
19037 : : TEST_CASE_ST(ut_setup, ut_teardown,
19038 : : test_AES_GCM_authenticated_encryption_test_case_2),
19039 : : TEST_CASE_ST(ut_setup, ut_teardown,
19040 : : test_AES_GCM_authenticated_encryption_test_case_3),
19041 : : TEST_CASE_ST(ut_setup, ut_teardown,
19042 : : test_AES_GCM_authenticated_encryption_test_case_4),
19043 : : TEST_CASE_ST(ut_setup, ut_teardown,
19044 : : test_AES_GCM_authenticated_encryption_test_case_5),
19045 : : TEST_CASE_ST(ut_setup, ut_teardown,
19046 : : test_AES_GCM_authenticated_encryption_test_case_6),
19047 : : TEST_CASE_ST(ut_setup, ut_teardown,
19048 : : test_AES_GCM_authenticated_encryption_test_case_7),
19049 : : TEST_CASE_ST(ut_setup, ut_teardown,
19050 : : test_AES_GCM_authenticated_encryption_test_case_8),
19051 : : TEST_CASE_ST(ut_setup, ut_teardown,
19052 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
19053 : :
19054 : : /** AES GCM Authenticated Decryption */
19055 : : TEST_CASE_ST(ut_setup, ut_teardown,
19056 : : test_AES_GCM_authenticated_decryption_test_case_1),
19057 : : TEST_CASE_ST(ut_setup, ut_teardown,
19058 : : test_AES_GCM_authenticated_decryption_test_case_2),
19059 : : TEST_CASE_ST(ut_setup, ut_teardown,
19060 : : test_AES_GCM_authenticated_decryption_test_case_3),
19061 : : TEST_CASE_ST(ut_setup, ut_teardown,
19062 : : test_AES_GCM_authenticated_decryption_test_case_4),
19063 : : TEST_CASE_ST(ut_setup, ut_teardown,
19064 : : test_AES_GCM_authenticated_decryption_test_case_5),
19065 : : TEST_CASE_ST(ut_setup, ut_teardown,
19066 : : test_AES_GCM_authenticated_decryption_test_case_6),
19067 : : TEST_CASE_ST(ut_setup, ut_teardown,
19068 : : test_AES_GCM_authenticated_decryption_test_case_7),
19069 : : TEST_CASE_ST(ut_setup, ut_teardown,
19070 : : test_AES_GCM_authenticated_decryption_test_case_8),
19071 : : TEST_CASE_ST(ut_setup, ut_teardown,
19072 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
19073 : :
19074 : : /** AES GCM Authenticated Encryption 192 bits key */
19075 : : TEST_CASE_ST(ut_setup, ut_teardown,
19076 : : test_AES_GCM_auth_encryption_test_case_192_1),
19077 : : TEST_CASE_ST(ut_setup, ut_teardown,
19078 : : test_AES_GCM_auth_encryption_test_case_192_2),
19079 : : TEST_CASE_ST(ut_setup, ut_teardown,
19080 : : test_AES_GCM_auth_encryption_test_case_192_3),
19081 : : TEST_CASE_ST(ut_setup, ut_teardown,
19082 : : test_AES_GCM_auth_encryption_test_case_192_4),
19083 : : TEST_CASE_ST(ut_setup, ut_teardown,
19084 : : test_AES_GCM_auth_encryption_test_case_192_5),
19085 : : TEST_CASE_ST(ut_setup, ut_teardown,
19086 : : test_AES_GCM_auth_encryption_test_case_192_6),
19087 : : TEST_CASE_ST(ut_setup, ut_teardown,
19088 : : test_AES_GCM_auth_encryption_test_case_192_7),
19089 : :
19090 : : /** AES GCM Authenticated Decryption 192 bits key */
19091 : : TEST_CASE_ST(ut_setup, ut_teardown,
19092 : : test_AES_GCM_auth_decryption_test_case_192_1),
19093 : : TEST_CASE_ST(ut_setup, ut_teardown,
19094 : : test_AES_GCM_auth_decryption_test_case_192_2),
19095 : : TEST_CASE_ST(ut_setup, ut_teardown,
19096 : : test_AES_GCM_auth_decryption_test_case_192_3),
19097 : : TEST_CASE_ST(ut_setup, ut_teardown,
19098 : : test_AES_GCM_auth_decryption_test_case_192_4),
19099 : : TEST_CASE_ST(ut_setup, ut_teardown,
19100 : : test_AES_GCM_auth_decryption_test_case_192_5),
19101 : : TEST_CASE_ST(ut_setup, ut_teardown,
19102 : : test_AES_GCM_auth_decryption_test_case_192_6),
19103 : : TEST_CASE_ST(ut_setup, ut_teardown,
19104 : : test_AES_GCM_auth_decryption_test_case_192_7),
19105 : :
19106 : : /** AES GCM Authenticated Encryption 256 bits key */
19107 : : TEST_CASE_ST(ut_setup, ut_teardown,
19108 : : test_AES_GCM_auth_encryption_test_case_256_1),
19109 : : TEST_CASE_ST(ut_setup, ut_teardown,
19110 : : test_AES_GCM_auth_encryption_test_case_256_2),
19111 : : TEST_CASE_ST(ut_setup, ut_teardown,
19112 : : test_AES_GCM_auth_encryption_test_case_256_3),
19113 : : TEST_CASE_ST(ut_setup, ut_teardown,
19114 : : test_AES_GCM_auth_encryption_test_case_256_4),
19115 : : TEST_CASE_ST(ut_setup, ut_teardown,
19116 : : test_AES_GCM_auth_encryption_test_case_256_5),
19117 : : TEST_CASE_ST(ut_setup, ut_teardown,
19118 : : test_AES_GCM_auth_encryption_test_case_256_6),
19119 : : TEST_CASE_ST(ut_setup, ut_teardown,
19120 : : test_AES_GCM_auth_encryption_test_case_256_7),
19121 : : TEST_CASE_ST(ut_setup, ut_teardown,
19122 : : test_AES_GCM_auth_encryption_test_case_256_8),
19123 : :
19124 : : /** AES GCM Authenticated Decryption 256 bits key */
19125 : : TEST_CASE_ST(ut_setup, ut_teardown,
19126 : : test_AES_GCM_auth_decryption_test_case_256_1),
19127 : : TEST_CASE_ST(ut_setup, ut_teardown,
19128 : : test_AES_GCM_auth_decryption_test_case_256_2),
19129 : : TEST_CASE_ST(ut_setup, ut_teardown,
19130 : : test_AES_GCM_auth_decryption_test_case_256_3),
19131 : : TEST_CASE_ST(ut_setup, ut_teardown,
19132 : : test_AES_GCM_auth_decryption_test_case_256_4),
19133 : : TEST_CASE_ST(ut_setup, ut_teardown,
19134 : : test_AES_GCM_auth_decryption_test_case_256_5),
19135 : : TEST_CASE_ST(ut_setup, ut_teardown,
19136 : : test_AES_GCM_auth_decryption_test_case_256_6),
19137 : : TEST_CASE_ST(ut_setup, ut_teardown,
19138 : : test_AES_GCM_auth_decryption_test_case_256_7),
19139 : : TEST_CASE_ST(ut_setup, ut_teardown,
19140 : : test_AES_GCM_auth_decryption_test_case_256_8),
19141 : :
19142 : : /** AES GCM Authenticated Encryption big aad size */
19143 : : TEST_CASE_ST(ut_setup, ut_teardown,
19144 : : test_AES_GCM_auth_encryption_test_case_aad_1),
19145 : : TEST_CASE_ST(ut_setup, ut_teardown,
19146 : : test_AES_GCM_auth_encryption_test_case_aad_2),
19147 : :
19148 : : /** AES GCM Authenticated Decryption big aad size */
19149 : : TEST_CASE_ST(ut_setup, ut_teardown,
19150 : : test_AES_GCM_auth_decryption_test_case_aad_1),
19151 : : TEST_CASE_ST(ut_setup, ut_teardown,
19152 : : test_AES_GCM_auth_decryption_test_case_aad_2),
19153 : :
19154 : : /** Out of place tests */
19155 : : TEST_CASE_ST(ut_setup, ut_teardown,
19156 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
19157 : : TEST_CASE_ST(ut_setup, ut_teardown,
19158 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
19159 : :
19160 : : /** Session-less tests */
19161 : : TEST_CASE_ST(ut_setup, ut_teardown,
19162 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
19163 : : TEST_CASE_ST(ut_setup, ut_teardown,
19164 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
19165 : :
19166 : : /** AES GCM external mbuf tests */
19167 : : TEST_CASE_ST(ut_setup, ut_teardown,
19168 : : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
19169 : : TEST_CASE_ST(ut_setup, ut_teardown,
19170 : : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
19171 : :
19172 : : TEST_CASES_END()
19173 : : }
19174 : : };
19175 : :
19176 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
19177 : : .suite_name = "AES GMAC Authentication Test Suite",
19178 : : .setup = aes_gmac_auth_testsuite_setup,
19179 : : .unit_test_cases = {
19180 : : TEST_CASE_ST(ut_setup, ut_teardown,
19181 : : test_AES_GMAC_authentication_test_case_1),
19182 : : TEST_CASE_ST(ut_setup, ut_teardown,
19183 : : test_AES_GMAC_authentication_verify_test_case_1),
19184 : : TEST_CASE_ST(ut_setup, ut_teardown,
19185 : : test_AES_GMAC_authentication_test_case_2),
19186 : : TEST_CASE_ST(ut_setup, ut_teardown,
19187 : : test_AES_GMAC_authentication_verify_test_case_2),
19188 : : TEST_CASE_ST(ut_setup, ut_teardown,
19189 : : test_AES_GMAC_authentication_test_case_3),
19190 : : TEST_CASE_ST(ut_setup, ut_teardown,
19191 : : test_AES_GMAC_authentication_verify_test_case_3),
19192 : : TEST_CASE_ST(ut_setup, ut_teardown,
19193 : : test_AES_GMAC_authentication_test_case_4),
19194 : : TEST_CASE_ST(ut_setup, ut_teardown,
19195 : : test_AES_GMAC_authentication_verify_test_case_4),
19196 : : TEST_CASE_ST(ut_setup, ut_teardown,
19197 : : test_AES_GMAC_authentication_SGL_40B),
19198 : : TEST_CASE_ST(ut_setup, ut_teardown,
19199 : : test_AES_GMAC_authentication_SGL_80B),
19200 : : TEST_CASE_ST(ut_setup, ut_teardown,
19201 : : test_AES_GMAC_authentication_SGL_2048B),
19202 : : TEST_CASE_ST(ut_setup, ut_teardown,
19203 : : test_AES_GMAC_authentication_SGL_2047B),
19204 : :
19205 : : TEST_CASES_END()
19206 : : }
19207 : : };
19208 : :
19209 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
19210 : : .suite_name = "Chacha20-Poly1305 Test Suite",
19211 : : .setup = chacha20_poly1305_testsuite_setup,
19212 : : .unit_test_cases = {
19213 : : TEST_CASE_ST(ut_setup, ut_teardown,
19214 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
19215 : : TEST_CASE_ST(ut_setup, ut_teardown,
19216 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
19217 : : TEST_CASE_ST(ut_setup, ut_teardown,
19218 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
19219 : : TEST_CASES_END()
19220 : : }
19221 : : };
19222 : :
19223 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
19224 : : .suite_name = "SNOW 3G Test Suite",
19225 : : .setup = snow3g_testsuite_setup,
19226 : : .unit_test_cases = {
19227 : : /** SNOW 3G encrypt only (UEA2) */
19228 : : TEST_CASE_ST(ut_setup, ut_teardown,
19229 : : test_snow3g_encryption_test_case_1),
19230 : : TEST_CASE_ST(ut_setup, ut_teardown,
19231 : : test_snow3g_encryption_test_case_2),
19232 : : TEST_CASE_ST(ut_setup, ut_teardown,
19233 : : test_snow3g_encryption_test_case_3),
19234 : : TEST_CASE_ST(ut_setup, ut_teardown,
19235 : : test_snow3g_encryption_test_case_4),
19236 : : TEST_CASE_ST(ut_setup, ut_teardown,
19237 : : test_snow3g_encryption_test_case_5),
19238 : :
19239 : : TEST_CASE_ST(ut_setup, ut_teardown,
19240 : : test_snow3g_encryption_test_case_1_oop),
19241 : : TEST_CASE_ST(ut_setup, ut_teardown,
19242 : : test_snow3g_encryption_test_case_1_oop_sgl),
19243 : : TEST_CASE_ST(ut_setup, ut_teardown,
19244 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
19245 : : TEST_CASE_ST(ut_setup, ut_teardown,
19246 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
19247 : : TEST_CASE_ST(ut_setup, ut_teardown,
19248 : : test_snow3g_encryption_test_case_1_offset_oop),
19249 : : TEST_CASE_ST(ut_setup, ut_teardown,
19250 : : test_snow3g_decryption_test_case_1_oop),
19251 : :
19252 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
19253 : : TEST_CASE_ST(ut_setup, ut_teardown,
19254 : : test_snow3g_auth_cipher_test_case_1),
19255 : : TEST_CASE_ST(ut_setup, ut_teardown,
19256 : : test_snow3g_auth_cipher_test_case_2),
19257 : : TEST_CASE_ST(ut_setup, ut_teardown,
19258 : : test_snow3g_auth_cipher_test_case_2_oop),
19259 : : TEST_CASE_ST(ut_setup, ut_teardown,
19260 : : test_snow3g_auth_cipher_part_digest_enc),
19261 : : TEST_CASE_ST(ut_setup, ut_teardown,
19262 : : test_snow3g_auth_cipher_part_digest_enc_oop),
19263 : : TEST_CASE_ST(ut_setup, ut_teardown,
19264 : : test_snow3g_auth_cipher_test_case_3_sgl),
19265 : : TEST_CASE_ST(ut_setup, ut_teardown,
19266 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
19267 : : TEST_CASE_ST(ut_setup, ut_teardown,
19268 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
19269 : : TEST_CASE_ST(ut_setup, ut_teardown,
19270 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
19271 : : TEST_CASE_ST(ut_setup, ut_teardown,
19272 : : test_snow3g_auth_cipher_total_digest_enc_1),
19273 : : TEST_CASE_ST(ut_setup, ut_teardown,
19274 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
19275 : : TEST_CASE_ST(ut_setup, ut_teardown,
19276 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
19277 : : TEST_CASE_ST(ut_setup, ut_teardown,
19278 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
19279 : :
19280 : : /** SNOW 3G decrypt (UEA2), then verify auth */
19281 : : TEST_CASE_ST(ut_setup, ut_teardown,
19282 : : test_snow3g_auth_cipher_verify_test_case_1),
19283 : : TEST_CASE_ST(ut_setup, ut_teardown,
19284 : : test_snow3g_auth_cipher_verify_test_case_2),
19285 : : TEST_CASE_ST(ut_setup, ut_teardown,
19286 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
19287 : : TEST_CASE_ST(ut_setup, ut_teardown,
19288 : : test_snow3g_auth_cipher_verify_part_digest_enc),
19289 : : TEST_CASE_ST(ut_setup, ut_teardown,
19290 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
19291 : : TEST_CASE_ST(ut_setup, ut_teardown,
19292 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
19293 : : TEST_CASE_ST(ut_setup, ut_teardown,
19294 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
19295 : : TEST_CASE_ST(ut_setup, ut_teardown,
19296 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
19297 : : TEST_CASE_ST(ut_setup, ut_teardown,
19298 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
19299 : : TEST_CASE_ST(ut_setup, ut_teardown,
19300 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
19301 : : TEST_CASE_ST(ut_setup, ut_teardown,
19302 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
19303 : : TEST_CASE_ST(ut_setup, ut_teardown,
19304 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
19305 : : TEST_CASE_ST(ut_setup, ut_teardown,
19306 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
19307 : :
19308 : : /** SNOW 3G decrypt only (UEA2) */
19309 : : TEST_CASE_ST(ut_setup, ut_teardown,
19310 : : test_snow3g_decryption_test_case_1),
19311 : : TEST_CASE_ST(ut_setup, ut_teardown,
19312 : : test_snow3g_decryption_test_case_2),
19313 : : TEST_CASE_ST(ut_setup, ut_teardown,
19314 : : test_snow3g_decryption_test_case_3),
19315 : : TEST_CASE_ST(ut_setup, ut_teardown,
19316 : : test_snow3g_decryption_test_case_4),
19317 : : TEST_CASE_ST(ut_setup, ut_teardown,
19318 : : test_snow3g_decryption_test_case_5),
19319 : : TEST_CASE_ST(ut_setup, ut_teardown,
19320 : : test_snow3g_decryption_with_digest_test_case_1),
19321 : : TEST_CASE_ST(ut_setup, ut_teardown,
19322 : : test_snow3g_hash_generate_test_case_1),
19323 : : TEST_CASE_ST(ut_setup, ut_teardown,
19324 : : test_snow3g_hash_generate_test_case_2),
19325 : : TEST_CASE_ST(ut_setup, ut_teardown,
19326 : : test_snow3g_hash_generate_test_case_3),
19327 : :
19328 : : /* Tests with buffers which length is not byte-aligned */
19329 : : TEST_CASE_ST(ut_setup, ut_teardown,
19330 : : test_snow3g_hash_generate_test_case_4),
19331 : : TEST_CASE_ST(ut_setup, ut_teardown,
19332 : : test_snow3g_hash_generate_test_case_5),
19333 : : TEST_CASE_ST(ut_setup, ut_teardown,
19334 : : test_snow3g_hash_generate_test_case_6),
19335 : : TEST_CASE_ST(ut_setup, ut_teardown,
19336 : : test_snow3g_hash_verify_test_case_1),
19337 : : TEST_CASE_ST(ut_setup, ut_teardown,
19338 : : test_snow3g_hash_verify_test_case_2),
19339 : : TEST_CASE_ST(ut_setup, ut_teardown,
19340 : : test_snow3g_hash_verify_test_case_3),
19341 : :
19342 : : /* Tests with buffers which length is not byte-aligned */
19343 : : TEST_CASE_ST(ut_setup, ut_teardown,
19344 : : test_snow3g_hash_verify_test_case_4),
19345 : : TEST_CASE_ST(ut_setup, ut_teardown,
19346 : : test_snow3g_hash_verify_test_case_5),
19347 : : TEST_CASE_ST(ut_setup, ut_teardown,
19348 : : test_snow3g_hash_verify_test_case_6),
19349 : : TEST_CASE_ST(ut_setup, ut_teardown,
19350 : : test_snow3g_cipher_auth_test_case_1),
19351 : : TEST_CASE_ST(ut_setup, ut_teardown,
19352 : : test_snow3g_auth_cipher_with_digest_test_case_1),
19353 : : TEST_CASES_END()
19354 : : }
19355 : : };
19356 : :
19357 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
19358 : : .suite_name = "ZUC Test Suite",
19359 : : .setup = zuc_testsuite_setup,
19360 : : .unit_test_cases = {
19361 : : /** ZUC encrypt only (EEA3) */
19362 : : TEST_CASE_ST(ut_setup, ut_teardown,
19363 : : test_zuc_encryption_test_case_1),
19364 : : TEST_CASE_ST(ut_setup, ut_teardown,
19365 : : test_zuc_encryption_test_case_2),
19366 : : TEST_CASE_ST(ut_setup, ut_teardown,
19367 : : test_zuc_encryption_test_case_3),
19368 : : TEST_CASE_ST(ut_setup, ut_teardown,
19369 : : test_zuc_encryption_test_case_4),
19370 : : TEST_CASE_ST(ut_setup, ut_teardown,
19371 : : test_zuc_encryption_test_case_5),
19372 : : TEST_CASE_ST(ut_setup, ut_teardown,
19373 : : test_zuc_encryption_test_case_6_sgl),
19374 : :
19375 : : /** ZUC decrypt only (EEA3) */
19376 : : TEST_CASE_ST(ut_setup, ut_teardown,
19377 : : test_zuc_decryption_test_case_1),
19378 : : TEST_CASE_ST(ut_setup, ut_teardown,
19379 : : test_zuc_decryption_test_case_2),
19380 : : TEST_CASE_ST(ut_setup, ut_teardown,
19381 : : test_zuc_decryption_test_case_3),
19382 : : TEST_CASE_ST(ut_setup, ut_teardown,
19383 : : test_zuc_decryption_test_case_4),
19384 : : TEST_CASE_ST(ut_setup, ut_teardown,
19385 : : test_zuc_decryption_test_case_5),
19386 : : TEST_CASE_ST(ut_setup, ut_teardown,
19387 : : test_zuc_decryption_test_case_6_sgl),
19388 : :
19389 : : /** ZUC authenticate (EIA3) */
19390 : : TEST_CASE_ST(ut_setup, ut_teardown,
19391 : : test_zuc_hash_generate_test_case_1),
19392 : : TEST_CASE_ST(ut_setup, ut_teardown,
19393 : : test_zuc_hash_generate_test_case_2),
19394 : : TEST_CASE_ST(ut_setup, ut_teardown,
19395 : : test_zuc_hash_generate_test_case_3),
19396 : : TEST_CASE_ST(ut_setup, ut_teardown,
19397 : : test_zuc_hash_generate_test_case_4),
19398 : : TEST_CASE_ST(ut_setup, ut_teardown,
19399 : : test_zuc_hash_generate_test_case_5),
19400 : : TEST_CASE_ST(ut_setup, ut_teardown,
19401 : : test_zuc_hash_generate_test_case_6),
19402 : : TEST_CASE_ST(ut_setup, ut_teardown,
19403 : : test_zuc_hash_generate_test_case_7),
19404 : : TEST_CASE_ST(ut_setup, ut_teardown,
19405 : : test_zuc_hash_generate_test_case_8),
19406 : :
19407 : : /** ZUC verify (EIA3) */
19408 : : TEST_CASE_ST(ut_setup, ut_teardown,
19409 : : test_zuc_hash_verify_test_case_1),
19410 : : TEST_CASE_ST(ut_setup, ut_teardown,
19411 : : test_zuc_hash_verify_test_case_2),
19412 : : TEST_CASE_ST(ut_setup, ut_teardown,
19413 : : test_zuc_hash_verify_test_case_3),
19414 : : TEST_CASE_ST(ut_setup, ut_teardown,
19415 : : test_zuc_hash_verify_test_case_4),
19416 : : TEST_CASE_ST(ut_setup, ut_teardown,
19417 : : test_zuc_hash_verify_test_case_5),
19418 : : TEST_CASE_ST(ut_setup, ut_teardown,
19419 : : test_zuc_hash_verify_test_case_6),
19420 : : TEST_CASE_ST(ut_setup, ut_teardown,
19421 : : test_zuc_hash_verify_test_case_7),
19422 : : TEST_CASE_ST(ut_setup, ut_teardown,
19423 : : test_zuc_hash_verify_test_case_8),
19424 : :
19425 : : /** ZUC alg-chain (EEA3/EIA3) */
19426 : : TEST_CASE_ST(ut_setup, ut_teardown,
19427 : : test_zuc_cipher_auth_test_case_1),
19428 : : TEST_CASE_ST(ut_setup, ut_teardown,
19429 : : test_zuc_cipher_auth_test_case_2),
19430 : :
19431 : : /** ZUC generate auth, then encrypt (EEA3) */
19432 : : TEST_CASE_ST(ut_setup, ut_teardown,
19433 : : test_zuc_auth_cipher_test_case_1),
19434 : : TEST_CASE_ST(ut_setup, ut_teardown,
19435 : : test_zuc_auth_cipher_test_case_1_oop),
19436 : : TEST_CASE_ST(ut_setup, ut_teardown,
19437 : : test_zuc_auth_cipher_test_case_1_sgl),
19438 : : TEST_CASE_ST(ut_setup, ut_teardown,
19439 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
19440 : : TEST_CASE_ST(ut_setup, ut_teardown,
19441 : : test_zuc_auth_cipher_test_case_2),
19442 : : TEST_CASE_ST(ut_setup, ut_teardown,
19443 : : test_zuc_auth_cipher_test_case_2_oop),
19444 : :
19445 : : /** ZUC decrypt (EEA3), then verify auth */
19446 : : TEST_CASE_ST(ut_setup, ut_teardown,
19447 : : test_zuc_auth_cipher_verify_test_case_1),
19448 : : TEST_CASE_ST(ut_setup, ut_teardown,
19449 : : test_zuc_auth_cipher_verify_test_case_1_oop),
19450 : : TEST_CASE_ST(ut_setup, ut_teardown,
19451 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
19452 : : TEST_CASE_ST(ut_setup, ut_teardown,
19453 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
19454 : : TEST_CASE_ST(ut_setup, ut_teardown,
19455 : : test_zuc_auth_cipher_verify_test_case_2),
19456 : : TEST_CASE_ST(ut_setup, ut_teardown,
19457 : : test_zuc_auth_cipher_verify_test_case_2_oop),
19458 : :
19459 : : /** ZUC-256 encrypt only **/
19460 : : TEST_CASE_ST(ut_setup, ut_teardown,
19461 : : test_zuc256_encryption_test_case_1),
19462 : : TEST_CASE_ST(ut_setup, ut_teardown,
19463 : : test_zuc256_encryption_test_case_2),
19464 : :
19465 : : /** ZUC-256 decrypt only **/
19466 : : TEST_CASE_ST(ut_setup, ut_teardown,
19467 : : test_zuc256_decryption_test_case_1),
19468 : : TEST_CASE_ST(ut_setup, ut_teardown,
19469 : : test_zuc256_decryption_test_case_2),
19470 : :
19471 : : /** ZUC-256 authentication only **/
19472 : : TEST_CASE_ST(ut_setup, ut_teardown,
19473 : : test_zuc256_hash_generate_4b_tag_test_case_1),
19474 : : TEST_CASE_ST(ut_setup, ut_teardown,
19475 : : test_zuc256_hash_generate_4b_tag_test_case_2),
19476 : : TEST_CASE_ST(ut_setup, ut_teardown,
19477 : : test_zuc256_hash_generate_4b_tag_test_case_3),
19478 : : TEST_CASE_ST(ut_setup, ut_teardown,
19479 : : test_zuc256_hash_generate_8b_tag_test_case_1),
19480 : : TEST_CASE_ST(ut_setup, ut_teardown,
19481 : : test_zuc256_hash_generate_16b_tag_test_case_1),
19482 : :
19483 : : /** ZUC-256 authentication verify only **/
19484 : : TEST_CASE_ST(ut_setup, ut_teardown,
19485 : : test_zuc256_hash_verify_4b_tag_test_case_1),
19486 : : TEST_CASE_ST(ut_setup, ut_teardown,
19487 : : test_zuc256_hash_verify_4b_tag_test_case_2),
19488 : : TEST_CASE_ST(ut_setup, ut_teardown,
19489 : : test_zuc256_hash_verify_4b_tag_test_case_3),
19490 : : TEST_CASE_ST(ut_setup, ut_teardown,
19491 : : test_zuc256_hash_verify_8b_tag_test_case_1),
19492 : : TEST_CASE_ST(ut_setup, ut_teardown,
19493 : : test_zuc256_hash_verify_16b_tag_test_case_1),
19494 : :
19495 : : /** ZUC-256 encrypt and authenticate **/
19496 : : TEST_CASE_ST(ut_setup, ut_teardown,
19497 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
19498 : : TEST_CASE_ST(ut_setup, ut_teardown,
19499 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
19500 : : TEST_CASE_ST(ut_setup, ut_teardown,
19501 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
19502 : : TEST_CASE_ST(ut_setup, ut_teardown,
19503 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
19504 : :
19505 : : /** ZUC-256 generate auth, then encrypt */
19506 : : TEST_CASE_ST(ut_setup, ut_teardown,
19507 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
19508 : : TEST_CASE_ST(ut_setup, ut_teardown,
19509 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
19510 : : TEST_CASE_ST(ut_setup, ut_teardown,
19511 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
19512 : : TEST_CASE_ST(ut_setup, ut_teardown,
19513 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
19514 : :
19515 : : /** ZUC-256 decrypt, then verify auth */
19516 : : TEST_CASE_ST(ut_setup, ut_teardown,
19517 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19518 : : TEST_CASE_ST(ut_setup, ut_teardown,
19519 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19520 : : TEST_CASE_ST(ut_setup, ut_teardown,
19521 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19522 : : TEST_CASE_ST(ut_setup, ut_teardown,
19523 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19524 : :
19525 : : TEST_CASES_END()
19526 : : }
19527 : : };
19528 : :
19529 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
19530 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
19531 : : .setup = hmac_md5_auth_testsuite_setup,
19532 : : .unit_test_cases = {
19533 : : TEST_CASE_ST(ut_setup, ut_teardown,
19534 : : test_MD5_HMAC_generate_case_1),
19535 : : TEST_CASE_ST(ut_setup, ut_teardown,
19536 : : test_MD5_HMAC_verify_case_1),
19537 : : TEST_CASE_ST(ut_setup, ut_teardown,
19538 : : test_MD5_HMAC_generate_case_2),
19539 : : TEST_CASE_ST(ut_setup, ut_teardown,
19540 : : test_MD5_HMAC_verify_case_2),
19541 : : TEST_CASES_END()
19542 : : }
19543 : : };
19544 : :
19545 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
19546 : : .suite_name = "Kasumi Test Suite",
19547 : : .setup = kasumi_testsuite_setup,
19548 : : .unit_test_cases = {
19549 : : /** KASUMI hash only (UIA1) */
19550 : : TEST_CASE_ST(ut_setup, ut_teardown,
19551 : : test_kasumi_hash_generate_test_case_1),
19552 : : TEST_CASE_ST(ut_setup, ut_teardown,
19553 : : test_kasumi_hash_generate_test_case_2),
19554 : : TEST_CASE_ST(ut_setup, ut_teardown,
19555 : : test_kasumi_hash_generate_test_case_3),
19556 : : TEST_CASE_ST(ut_setup, ut_teardown,
19557 : : test_kasumi_hash_generate_test_case_4),
19558 : : TEST_CASE_ST(ut_setup, ut_teardown,
19559 : : test_kasumi_hash_generate_test_case_5),
19560 : : TEST_CASE_ST(ut_setup, ut_teardown,
19561 : : test_kasumi_hash_generate_test_case_6),
19562 : :
19563 : : TEST_CASE_ST(ut_setup, ut_teardown,
19564 : : test_kasumi_hash_verify_test_case_1),
19565 : : TEST_CASE_ST(ut_setup, ut_teardown,
19566 : : test_kasumi_hash_verify_test_case_2),
19567 : : TEST_CASE_ST(ut_setup, ut_teardown,
19568 : : test_kasumi_hash_verify_test_case_3),
19569 : : TEST_CASE_ST(ut_setup, ut_teardown,
19570 : : test_kasumi_hash_verify_test_case_4),
19571 : : TEST_CASE_ST(ut_setup, ut_teardown,
19572 : : test_kasumi_hash_verify_test_case_5),
19573 : :
19574 : : /** KASUMI encrypt only (UEA1) */
19575 : : TEST_CASE_ST(ut_setup, ut_teardown,
19576 : : test_kasumi_encryption_test_case_1),
19577 : : TEST_CASE_ST(ut_setup, ut_teardown,
19578 : : test_kasumi_encryption_test_case_1_sgl),
19579 : : TEST_CASE_ST(ut_setup, ut_teardown,
19580 : : test_kasumi_encryption_test_case_1_oop),
19581 : : TEST_CASE_ST(ut_setup, ut_teardown,
19582 : : test_kasumi_encryption_test_case_1_oop_sgl),
19583 : : TEST_CASE_ST(ut_setup, ut_teardown,
19584 : : test_kasumi_encryption_test_case_2),
19585 : : TEST_CASE_ST(ut_setup, ut_teardown,
19586 : : test_kasumi_encryption_test_case_3),
19587 : : TEST_CASE_ST(ut_setup, ut_teardown,
19588 : : test_kasumi_encryption_test_case_4),
19589 : : TEST_CASE_ST(ut_setup, ut_teardown,
19590 : : test_kasumi_encryption_test_case_5),
19591 : :
19592 : : /** KASUMI decrypt only (UEA1) */
19593 : : TEST_CASE_ST(ut_setup, ut_teardown,
19594 : : test_kasumi_decryption_test_case_1),
19595 : : TEST_CASE_ST(ut_setup, ut_teardown,
19596 : : test_kasumi_decryption_test_case_2),
19597 : : TEST_CASE_ST(ut_setup, ut_teardown,
19598 : : test_kasumi_decryption_test_case_3),
19599 : : TEST_CASE_ST(ut_setup, ut_teardown,
19600 : : test_kasumi_decryption_test_case_4),
19601 : : TEST_CASE_ST(ut_setup, ut_teardown,
19602 : : test_kasumi_decryption_test_case_5),
19603 : : TEST_CASE_ST(ut_setup, ut_teardown,
19604 : : test_kasumi_decryption_test_case_1_oop),
19605 : : TEST_CASE_ST(ut_setup, ut_teardown,
19606 : : test_kasumi_cipher_auth_test_case_1),
19607 : :
19608 : : /** KASUMI generate auth, then encrypt (F8) */
19609 : : TEST_CASE_ST(ut_setup, ut_teardown,
19610 : : test_kasumi_auth_cipher_test_case_1),
19611 : : TEST_CASE_ST(ut_setup, ut_teardown,
19612 : : test_kasumi_auth_cipher_test_case_2),
19613 : : TEST_CASE_ST(ut_setup, ut_teardown,
19614 : : test_kasumi_auth_cipher_test_case_2_oop),
19615 : : TEST_CASE_ST(ut_setup, ut_teardown,
19616 : : test_kasumi_auth_cipher_test_case_2_sgl),
19617 : : TEST_CASE_ST(ut_setup, ut_teardown,
19618 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
19619 : :
19620 : : /** KASUMI decrypt (F8), then verify auth */
19621 : : TEST_CASE_ST(ut_setup, ut_teardown,
19622 : : test_kasumi_auth_cipher_verify_test_case_1),
19623 : : TEST_CASE_ST(ut_setup, ut_teardown,
19624 : : test_kasumi_auth_cipher_verify_test_case_2),
19625 : : TEST_CASE_ST(ut_setup, ut_teardown,
19626 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
19627 : : TEST_CASE_ST(ut_setup, ut_teardown,
19628 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
19629 : : TEST_CASE_ST(ut_setup, ut_teardown,
19630 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19631 : :
19632 : : TEST_CASES_END()
19633 : : }
19634 : : };
19635 : :
19636 : : static struct unit_test_suite cryptodev_esn_testsuite = {
19637 : : .suite_name = "ESN Test Suite",
19638 : : .setup = esn_testsuite_setup,
19639 : : .unit_test_cases = {
19640 : : TEST_CASE_ST(ut_setup, ut_teardown,
19641 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19642 : : TEST_CASE_ST(ut_setup, ut_teardown,
19643 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19644 : : TEST_CASES_END()
19645 : : }
19646 : : };
19647 : :
19648 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
19649 : : .suite_name = "Negative AES GCM Test Suite",
19650 : : .setup = negative_aes_gcm_testsuite_setup,
19651 : : .unit_test_cases = {
19652 : : TEST_CASE_ST(ut_setup, ut_teardown,
19653 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
19654 : : TEST_CASE_ST(ut_setup, ut_teardown,
19655 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19656 : : TEST_CASE_ST(ut_setup, ut_teardown,
19657 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19658 : : TEST_CASE_ST(ut_setup, ut_teardown,
19659 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19660 : : TEST_CASE_ST(ut_setup, ut_teardown,
19661 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
19662 : : TEST_CASE_ST(ut_setup, ut_teardown,
19663 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
19664 : : TEST_CASE_ST(ut_setup, ut_teardown,
19665 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
19666 : : TEST_CASE_ST(ut_setup, ut_teardown,
19667 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19668 : : TEST_CASE_ST(ut_setup, ut_teardown,
19669 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19670 : : TEST_CASE_ST(ut_setup, ut_teardown,
19671 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19672 : : TEST_CASE_ST(ut_setup, ut_teardown,
19673 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
19674 : : TEST_CASE_ST(ut_setup, ut_teardown,
19675 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
19676 : :
19677 : : TEST_CASES_END()
19678 : : }
19679 : : };
19680 : :
19681 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
19682 : : .suite_name = "Negative AES GMAC Test Suite",
19683 : : .setup = negative_aes_gmac_testsuite_setup,
19684 : : .unit_test_cases = {
19685 : : TEST_CASE_ST(ut_setup, ut_teardown,
19686 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
19687 : : TEST_CASE_ST(ut_setup, ut_teardown,
19688 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
19689 : :
19690 : : TEST_CASES_END()
19691 : : }
19692 : : };
19693 : :
19694 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
19695 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19696 : : .setup = mixed_cipher_hash_testsuite_setup,
19697 : : .unit_test_cases = {
19698 : : /** AUTH AES CMAC + CIPHER AES CTR */
19699 : : TEST_CASE_ST(ut_setup, ut_teardown,
19700 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19701 : : TEST_CASE_ST(ut_setup, ut_teardown,
19702 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19703 : : TEST_CASE_ST(ut_setup, ut_teardown,
19704 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19705 : : TEST_CASE_ST(ut_setup, ut_teardown,
19706 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19707 : : TEST_CASE_ST(ut_setup, ut_teardown,
19708 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19709 : : TEST_CASE_ST(ut_setup, ut_teardown,
19710 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19711 : : TEST_CASE_ST(ut_setup, ut_teardown,
19712 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19713 : : TEST_CASE_ST(ut_setup, ut_teardown,
19714 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19715 : : TEST_CASE_ST(ut_setup, ut_teardown,
19716 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19717 : : TEST_CASE_ST(ut_setup, ut_teardown,
19718 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19719 : : TEST_CASE_ST(ut_setup, ut_teardown,
19720 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19721 : : TEST_CASE_ST(ut_setup, ut_teardown,
19722 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19723 : :
19724 : : /** AUTH ZUC + CIPHER SNOW3G */
19725 : : TEST_CASE_ST(ut_setup, ut_teardown,
19726 : : test_auth_zuc_cipher_snow_test_case_1),
19727 : : TEST_CASE_ST(ut_setup, ut_teardown,
19728 : : test_verify_auth_zuc_cipher_snow_test_case_1),
19729 : : TEST_CASE_ST(ut_setup, ut_teardown,
19730 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
19731 : : TEST_CASE_ST(ut_setup, ut_teardown,
19732 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19733 : : /** AUTH AES CMAC + CIPHER SNOW3G */
19734 : : TEST_CASE_ST(ut_setup, ut_teardown,
19735 : : test_auth_aes_cmac_cipher_snow_test_case_1),
19736 : : TEST_CASE_ST(ut_setup, ut_teardown,
19737 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19738 : : TEST_CASE_ST(ut_setup, ut_teardown,
19739 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19740 : : TEST_CASE_ST(ut_setup, ut_teardown,
19741 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19742 : : /** AUTH ZUC + CIPHER AES CTR */
19743 : : TEST_CASE_ST(ut_setup, ut_teardown,
19744 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
19745 : : TEST_CASE_ST(ut_setup, ut_teardown,
19746 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19747 : : TEST_CASE_ST(ut_setup, ut_teardown,
19748 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19749 : : TEST_CASE_ST(ut_setup, ut_teardown,
19750 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19751 : : /** AUTH SNOW3G + CIPHER AES CTR */
19752 : : TEST_CASE_ST(ut_setup, ut_teardown,
19753 : : test_auth_snow_cipher_aes_ctr_test_case_1),
19754 : : TEST_CASE_ST(ut_setup, ut_teardown,
19755 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19756 : : TEST_CASE_ST(ut_setup, ut_teardown,
19757 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19758 : : TEST_CASE_ST(ut_setup, ut_teardown,
19759 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19760 : : TEST_CASE_ST(ut_setup, ut_teardown,
19761 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19762 : : TEST_CASE_ST(ut_setup, ut_teardown,
19763 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19764 : : /** AUTH SNOW3G + CIPHER ZUC */
19765 : : TEST_CASE_ST(ut_setup, ut_teardown,
19766 : : test_auth_snow_cipher_zuc_test_case_1),
19767 : : TEST_CASE_ST(ut_setup, ut_teardown,
19768 : : test_verify_auth_snow_cipher_zuc_test_case_1),
19769 : : TEST_CASE_ST(ut_setup, ut_teardown,
19770 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
19771 : : TEST_CASE_ST(ut_setup, ut_teardown,
19772 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19773 : : /** AUTH AES CMAC + CIPHER ZUC */
19774 : : TEST_CASE_ST(ut_setup, ut_teardown,
19775 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
19776 : : TEST_CASE_ST(ut_setup, ut_teardown,
19777 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19778 : : TEST_CASE_ST(ut_setup, ut_teardown,
19779 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19780 : : TEST_CASE_ST(ut_setup, ut_teardown,
19781 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19782 : :
19783 : : /** AUTH NULL + CIPHER SNOW3G */
19784 : : TEST_CASE_ST(ut_setup, ut_teardown,
19785 : : test_auth_null_cipher_snow_test_case_1),
19786 : : TEST_CASE_ST(ut_setup, ut_teardown,
19787 : : test_verify_auth_null_cipher_snow_test_case_1),
19788 : : /** AUTH NULL + CIPHER ZUC */
19789 : : TEST_CASE_ST(ut_setup, ut_teardown,
19790 : : test_auth_null_cipher_zuc_test_case_1),
19791 : : TEST_CASE_ST(ut_setup, ut_teardown,
19792 : : test_verify_auth_null_cipher_zuc_test_case_1),
19793 : : /** AUTH SNOW3G + CIPHER NULL */
19794 : : TEST_CASE_ST(ut_setup, ut_teardown,
19795 : : test_auth_snow_cipher_null_test_case_1),
19796 : : TEST_CASE_ST(ut_setup, ut_teardown,
19797 : : test_verify_auth_snow_cipher_null_test_case_1),
19798 : : /** AUTH ZUC + CIPHER NULL */
19799 : : TEST_CASE_ST(ut_setup, ut_teardown,
19800 : : test_auth_zuc_cipher_null_test_case_1),
19801 : : TEST_CASE_ST(ut_setup, ut_teardown,
19802 : : test_verify_auth_zuc_cipher_null_test_case_1),
19803 : : /** AUTH NULL + CIPHER AES CTR */
19804 : : TEST_CASE_ST(ut_setup, ut_teardown,
19805 : : test_auth_null_cipher_aes_ctr_test_case_1),
19806 : : TEST_CASE_ST(ut_setup, ut_teardown,
19807 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
19808 : : /** AUTH AES CMAC + CIPHER NULL */
19809 : : TEST_CASE_ST(ut_setup, ut_teardown,
19810 : : test_auth_aes_cmac_cipher_null_test_case_1),
19811 : : TEST_CASE_ST(ut_setup, ut_teardown,
19812 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
19813 : : TEST_CASES_END()
19814 : : }
19815 : : };
19816 : :
19817 : : static struct unit_test_suite cryptodev_sm4_gcm_testsuite = {
19818 : : .suite_name = "SM4 GCM Test Suite",
19819 : : .setup = sm4_gcm_testsuite_setup,
19820 : : .unit_test_cases = {
19821 : : TEST_CASE_ST(ut_setup, ut_teardown,
19822 : : test_SM4_GCM_case_1),
19823 : : TEST_CASE_ST(ut_setup, ut_teardown,
19824 : : test_SM4_GCM_case_2),
19825 : : TEST_CASE_ST(ut_setup, ut_teardown,
19826 : : test_SM4_GCM_case_3),
19827 : : TEST_CASE_ST(ut_setup, ut_teardown,
19828 : : test_SM4_GCM_case_4),
19829 : : TEST_CASE_ST(ut_setup, ut_teardown,
19830 : : test_SM4_GCM_case_5),
19831 : : TEST_CASE_ST(ut_setup, ut_teardown,
19832 : : test_SM4_GCM_case_6),
19833 : : TEST_CASE_ST(ut_setup, ut_teardown,
19834 : : test_SM4_GCM_case_7),
19835 : : TEST_CASE_ST(ut_setup, ut_teardown,
19836 : : test_SM4_GCM_case_8),
19837 : : TEST_CASE_ST(ut_setup, ut_teardown,
19838 : : test_SM4_GCM_case_9),
19839 : : TEST_CASE_ST(ut_setup, ut_teardown,
19840 : : test_SM4_GCM_case_10),
19841 : : TEST_CASE_ST(ut_setup, ut_teardown,
19842 : : test_SM4_GCM_case_11),
19843 : : TEST_CASE_ST(ut_setup, ut_teardown,
19844 : : test_SM4_GCM_case_12),
19845 : : TEST_CASE_ST(ut_setup, ut_teardown,
19846 : : test_SM4_GCM_case_13),
19847 : : TEST_CASE_ST(ut_setup, ut_teardown,
19848 : : test_SM4_GCM_case_14),
19849 : : TEST_CASE_ST(ut_setup, ut_teardown,
19850 : : test_SM4_GCM_case_15),
19851 : : TEST_CASES_END()
19852 : : }
19853 : : };
19854 : :
19855 : : static int
19856 : 1 : run_cryptodev_testsuite(const char *pmd_name)
19857 : : {
19858 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
19859 : 1 : const enum blockcipher_test_type blk_suites[] = {
19860 : : BLKCIPHER_AES_CHAIN_TYPE,
19861 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
19862 : : BLKCIPHER_AES_DOCSIS_TYPE,
19863 : : BLKCIPHER_3DES_CHAIN_TYPE,
19864 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
19865 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
19866 : : BLKCIPHER_DES_DOCSIS_TYPE,
19867 : : BLKCIPHER_SM4_CHAIN_TYPE,
19868 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
19869 : : BLKCIPHER_AUTHONLY_TYPE};
19870 : 1 : struct unit_test_suite *static_suites[] = {
19871 : : &cryptodev_multi_session_testsuite,
19872 : : &cryptodev_null_testsuite,
19873 : : &cryptodev_aes_ccm_auth_testsuite,
19874 : : &cryptodev_aes_gcm_auth_testsuite,
19875 : : &cryptodev_aes_gmac_auth_testsuite,
19876 : : &cryptodev_snow3g_testsuite,
19877 : : &cryptodev_chacha20_poly1305_testsuite,
19878 : : &cryptodev_zuc_testsuite,
19879 : : &cryptodev_hmac_md5_auth_testsuite,
19880 : : &cryptodev_kasumi_testsuite,
19881 : : &cryptodev_esn_testsuite,
19882 : : &cryptodev_negative_aes_gcm_testsuite,
19883 : : &cryptodev_negative_aes_gmac_testsuite,
19884 : : &cryptodev_mixed_cipher_hash_testsuite,
19885 : : &cryptodev_negative_hmac_sha1_testsuite,
19886 : : &cryptodev_gen_testsuite,
19887 : : &cryptodev_sm4_gcm_testsuite,
19888 : : #ifdef RTE_LIB_SECURITY
19889 : : &ipsec_proto_testsuite,
19890 : : &pdcp_proto_testsuite,
19891 : : &docsis_proto_testsuite,
19892 : : &tls12_record_proto_testsuite,
19893 : : &dtls12_record_proto_testsuite,
19894 : : &tls13_record_proto_testsuite,
19895 : : #endif
19896 : : &end_testsuite
19897 : : };
19898 : : static struct unit_test_suite ts = {
19899 : : .suite_name = "Cryptodev Unit Test Suite",
19900 : : .setup = testsuite_setup,
19901 : : .teardown = testsuite_teardown,
19902 : : .unit_test_cases = {TEST_CASES_END()}
19903 : : };
19904 : :
19905 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
19906 : :
19907 [ - + ]: 1 : if (gbl_driver_id == -1) {
19908 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
19909 : 0 : return TEST_SKIPPED;
19910 : : }
19911 : :
19912 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19913 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
19914 : :
19915 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
19916 [ + + ]: 25 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19917 : 1 : ret = unit_test_suite_runner(&ts);
19918 : :
19919 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
19920 : 1 : free(ts.unit_test_suites);
19921 : 1 : return ret;
19922 : : }
19923 : :
19924 : : static int
19925 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
19926 : : {
19927 : : struct rte_cryptodev_info dev_info;
19928 : : uint8_t i, nb_devs;
19929 : : int driver_id;
19930 : :
19931 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
19932 [ # # ]: 0 : if (driver_id == -1) {
19933 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
19934 : 0 : return TEST_SKIPPED;
19935 : : }
19936 : :
19937 : 0 : nb_devs = rte_cryptodev_count();
19938 [ # # ]: 0 : if (nb_devs < 1) {
19939 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
19940 : 0 : return TEST_SKIPPED;
19941 : : }
19942 : :
19943 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
19944 : 0 : rte_cryptodev_info_get(i, &dev_info);
19945 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
19946 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
19947 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
19948 : : flag_name);
19949 : 0 : return TEST_SKIPPED;
19950 : : }
19951 : : return 0; /* found */
19952 : : }
19953 : : }
19954 : :
19955 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
19956 : 0 : return TEST_SKIPPED;
19957 : : }
19958 : :
19959 : : static int
19960 : 0 : test_cryptodev_qat(void)
19961 : : {
19962 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19963 : : }
19964 : :
19965 : : static int
19966 : 0 : test_cryptodev_uadk(void)
19967 : : {
19968 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
19969 : : }
19970 : :
19971 : : static int
19972 : 0 : test_cryptodev_virtio(void)
19973 : : {
19974 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
19975 : : }
19976 : :
19977 : : static int
19978 : 0 : test_cryptodev_virtio_user(void)
19979 : : {
19980 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_USER_PMD));
19981 : : }
19982 : :
19983 : : static int
19984 : 0 : test_cryptodev_aesni_mb(void)
19985 : : {
19986 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19987 : : }
19988 : :
19989 : : static int
19990 : 0 : test_cryptodev_cpu_aesni_mb(void)
19991 : : {
19992 : : int32_t rc;
19993 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19994 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19995 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19996 : 0 : gbl_action_type = at;
19997 : 0 : return rc;
19998 : : }
19999 : :
20000 : : static int
20001 : 0 : test_cryptodev_chacha_poly_mb(void)
20002 : : {
20003 : : int32_t rc;
20004 : 0 : enum rte_security_session_action_type at = gbl_action_type;
20005 : 0 : rc = run_cryptodev_testsuite(
20006 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
20007 : 0 : gbl_action_type = at;
20008 : 0 : return rc;
20009 : : }
20010 : :
20011 : : static int
20012 : 1 : test_cryptodev_openssl(void)
20013 : : {
20014 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
20015 : : }
20016 : :
20017 : : static int
20018 : 0 : test_cryptodev_aesni_gcm(void)
20019 : : {
20020 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20021 : : }
20022 : :
20023 : : static int
20024 : 0 : test_cryptodev_cpu_aesni_gcm(void)
20025 : : {
20026 : : int32_t rc;
20027 : 0 : enum rte_security_session_action_type at = gbl_action_type;
20028 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
20029 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20030 : 0 : gbl_action_type = at;
20031 : 0 : return rc;
20032 : : }
20033 : :
20034 : : static int
20035 : 0 : test_cryptodev_mlx5(void)
20036 : : {
20037 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
20038 : : }
20039 : :
20040 : : static int
20041 : 0 : test_cryptodev_null(void)
20042 : : {
20043 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
20044 : : }
20045 : :
20046 : : static int
20047 : 0 : test_cryptodev_sw_snow3g(void)
20048 : : {
20049 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
20050 : : }
20051 : :
20052 : : static int
20053 : 0 : test_cryptodev_sw_kasumi(void)
20054 : : {
20055 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
20056 : : }
20057 : :
20058 : : static int
20059 : 0 : test_cryptodev_sw_zuc(void)
20060 : : {
20061 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
20062 : : }
20063 : :
20064 : : static int
20065 : 0 : test_cryptodev_armv8(void)
20066 : : {
20067 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
20068 : : }
20069 : :
20070 : : static int
20071 : 0 : test_cryptodev_mrvl(void)
20072 : : {
20073 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
20074 : : }
20075 : :
20076 : : #ifdef RTE_CRYPTO_SCHEDULER
20077 : :
20078 : : static int
20079 : 0 : test_cryptodev_scheduler(void)
20080 : : {
20081 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
20082 : 0 : const enum blockcipher_test_type blk_suites[] = {
20083 : : BLKCIPHER_AES_CHAIN_TYPE,
20084 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
20085 : : BLKCIPHER_AUTHONLY_TYPE
20086 : : };
20087 : : static struct unit_test_suite scheduler_multicore = {
20088 : : .suite_name = "Scheduler Multicore Unit Test Suite",
20089 : : .setup = scheduler_multicore_testsuite_setup,
20090 : : .teardown = scheduler_mode_testsuite_teardown,
20091 : : .unit_test_cases = {TEST_CASES_END()}
20092 : : };
20093 : : static struct unit_test_suite scheduler_round_robin = {
20094 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
20095 : : .setup = scheduler_roundrobin_testsuite_setup,
20096 : : .teardown = scheduler_mode_testsuite_teardown,
20097 : : .unit_test_cases = {TEST_CASES_END()}
20098 : : };
20099 : : static struct unit_test_suite scheduler_failover = {
20100 : : .suite_name = "Scheduler Failover Unit Test Suite",
20101 : : .setup = scheduler_failover_testsuite_setup,
20102 : : .teardown = scheduler_mode_testsuite_teardown,
20103 : : .unit_test_cases = {TEST_CASES_END()}
20104 : : };
20105 : : static struct unit_test_suite scheduler_pkt_size_distr = {
20106 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
20107 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
20108 : : .teardown = scheduler_mode_testsuite_teardown,
20109 : : .unit_test_cases = {TEST_CASES_END()}
20110 : : };
20111 : 0 : struct unit_test_suite *sched_mode_suites[] = {
20112 : : &scheduler_multicore,
20113 : : &scheduler_round_robin,
20114 : : &scheduler_failover,
20115 : : &scheduler_pkt_size_distr
20116 : : };
20117 : : static struct unit_test_suite scheduler_config = {
20118 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
20119 : : .unit_test_cases = {
20120 : : TEST_CASE(test_scheduler_attach_worker_op),
20121 : : TEST_CASE(test_scheduler_mode_multicore_op),
20122 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
20123 : : TEST_CASE(test_scheduler_mode_failover_op),
20124 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
20125 : : TEST_CASE(test_scheduler_detach_worker_op),
20126 : :
20127 : : TEST_CASES_END() /**< NULL terminate array */
20128 : : }
20129 : : };
20130 : 0 : struct unit_test_suite *static_suites[] = {
20131 : : &scheduler_config,
20132 : : &end_testsuite
20133 : : };
20134 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
20135 : : #ifdef RTE_LIB_SECURITY
20136 : : &docsis_proto_testsuite,
20137 : : #endif
20138 : : &end_testsuite
20139 : : };
20140 : : static struct unit_test_suite ts = {
20141 : : .suite_name = "Scheduler Unit Test Suite",
20142 : : .setup = scheduler_testsuite_setup,
20143 : : .teardown = testsuite_teardown,
20144 : : .unit_test_cases = {TEST_CASES_END()}
20145 : : };
20146 : :
20147 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
20148 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
20149 : :
20150 [ # # ]: 0 : if (gbl_driver_id == -1) {
20151 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
20152 : 0 : return TEST_SKIPPED;
20153 : : }
20154 : :
20155 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
20156 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
20157 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
20158 : 0 : return TEST_SKIPPED;
20159 : : }
20160 : :
20161 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20162 : : uint8_t blk_i = 0;
20163 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
20164 : : (struct unit_test_suite *) *
20165 : : (RTE_DIM(blk_suites) +
20166 : : RTE_DIM(sched_mode_static_suites) + 1));
20167 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20168 : : blk_suites, RTE_DIM(blk_suites));
20169 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20170 : : sched_mode_static_suites,
20171 : : RTE_DIM(sched_mode_static_suites));
20172 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
20173 : : }
20174 : :
20175 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
20176 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
20177 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
20178 : : RTE_DIM(sched_mode_suites));
20179 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
20180 : 0 : ret = unit_test_suite_runner(&ts);
20181 : :
20182 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20183 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
20184 : : (*sched_mode_suites[sched_i]),
20185 : : RTE_DIM(blk_suites));
20186 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
20187 : : }
20188 : 0 : free(ts.unit_test_suites);
20189 : 0 : return ret;
20190 : : }
20191 : :
20192 : 253 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
20193 : :
20194 : : #endif
20195 : :
20196 : : static int
20197 : 0 : test_cryptodev_dpaa2_sec(void)
20198 : : {
20199 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20200 : : }
20201 : :
20202 : : static int
20203 : 0 : test_cryptodev_dpaa_sec(void)
20204 : : {
20205 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20206 : : }
20207 : :
20208 : : static int
20209 : 0 : test_cryptodev_ccp(void)
20210 : : {
20211 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
20212 : : }
20213 : :
20214 : : static int
20215 : 0 : test_cryptodev_octeontx(void)
20216 : : {
20217 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
20218 : : }
20219 : :
20220 : : static int
20221 : 0 : test_cryptodev_caam_jr(void)
20222 : : {
20223 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
20224 : : }
20225 : :
20226 : : static int
20227 : 0 : test_cryptodev_nitrox(void)
20228 : : {
20229 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
20230 : : }
20231 : :
20232 : : static int
20233 : 0 : test_cryptodev_bcmfs(void)
20234 : : {
20235 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
20236 : : }
20237 : :
20238 : : static int
20239 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
20240 : : {
20241 : : int ret;
20242 : :
20243 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
20244 [ # # ]: 0 : if (ret)
20245 : : return ret;
20246 : :
20247 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
20248 : 0 : ret = run_cryptodev_testsuite(pmd_name);
20249 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
20250 : :
20251 : 0 : return ret;
20252 : : }
20253 : :
20254 : : static int
20255 : 0 : test_cryptodev_qat_raw_api(void)
20256 : : {
20257 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20258 : : }
20259 : :
20260 : : static int
20261 : 0 : test_cryptodev_cn9k(void)
20262 : : {
20263 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
20264 : : }
20265 : :
20266 : : static int
20267 : 0 : test_cryptodev_cn10k(void)
20268 : : {
20269 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20270 : : }
20271 : :
20272 : : static int
20273 : 0 : test_cryptodev_cn10k_raw_api(void)
20274 : : {
20275 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20276 : : }
20277 : :
20278 : : static int
20279 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
20280 : : {
20281 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20282 : : }
20283 : :
20284 : : static int
20285 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
20286 : : {
20287 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20288 : : }
20289 : :
20290 : : static int
20291 : 0 : test_cryptodev_zsda(void)
20292 : : {
20293 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZSDA_SYM_PMD));
20294 : : }
20295 : :
20296 : 253 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
20297 : : test_cryptodev_cn10k_raw_api);
20298 : 253 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
20299 : : test_cryptodev_dpaa2_sec_raw_api);
20300 : 253 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
20301 : : test_cryptodev_dpaa_sec_raw_api);
20302 : 253 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
20303 : : test_cryptodev_qat_raw_api);
20304 : 253 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
20305 : 253 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
20306 : 253 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
20307 : : test_cryptodev_cpu_aesni_mb);
20308 : 253 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
20309 : : test_cryptodev_chacha_poly_mb);
20310 : 253 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
20311 : 253 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
20312 : 253 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
20313 : : test_cryptodev_cpu_aesni_gcm);
20314 : 253 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
20315 : 253 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
20316 : 253 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
20317 : 253 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
20318 : 253 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
20319 : 253 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
20320 : 253 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
20321 : 253 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
20322 : 253 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
20323 : 253 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
20324 : 253 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
20325 : 253 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
20326 : 253 : REGISTER_DRIVER_TEST(cryptodev_virtio_user_autotest, test_cryptodev_virtio_user);
20327 : 253 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
20328 : 253 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
20329 : 253 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
20330 : 253 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
20331 : 253 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
20332 : 253 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
20333 : 253 : REGISTER_DRIVER_TEST(cryptodev_zsda_autotest, test_cryptodev_zsda);
|