Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2015-2020 Intel Corporation
3 : : * Copyright 2020 NXP
4 : : */
5 : :
6 : : #include <stdbool.h>
7 : : #include <time.h>
8 : :
9 : : #include <rte_common.h>
10 : : #include <rte_hexdump.h>
11 : : #include <rte_mbuf.h>
12 : : #include <rte_malloc.h>
13 : : #include <rte_memcpy.h>
14 : : #include <rte_pause.h>
15 : : #include <rte_bus_vdev.h>
16 : : #include <rte_ether.h>
17 : : #include <rte_errno.h>
18 : :
19 : : #include <rte_crypto.h>
20 : : #include <rte_cryptodev.h>
21 : : #include <rte_ethdev.h>
22 : : #include <rte_ip.h>
23 : : #include <rte_string_fns.h>
24 : : #include <rte_tcp.h>
25 : : #include <rte_tls.h>
26 : : #include <rte_udp.h>
27 : :
28 : : #ifdef RTE_CRYPTO_SCHEDULER
29 : : #include <rte_cryptodev_scheduler.h>
30 : : #include <rte_cryptodev_scheduler_operations.h>
31 : : #endif
32 : :
33 : : #include <rte_lcore.h>
34 : :
35 : : #include "test.h"
36 : : #include "test_cryptodev.h"
37 : :
38 : : #include "test_cryptodev_blockcipher.h"
39 : : #include "test_cryptodev_aes_test_vectors.h"
40 : : #include "test_cryptodev_des_test_vectors.h"
41 : : #include "test_cryptodev_hash_test_vectors.h"
42 : : #include "test_cryptodev_kasumi_test_vectors.h"
43 : : #include "test_cryptodev_kasumi_hash_test_vectors.h"
44 : : #include "test_cryptodev_snow3g_test_vectors.h"
45 : : #include "test_cryptodev_snow3g_hash_test_vectors.h"
46 : : #include "test_cryptodev_zuc_test_vectors.h"
47 : : #include "test_cryptodev_aead_test_vectors.h"
48 : : #include "test_cryptodev_hmac_test_vectors.h"
49 : : #include "test_cryptodev_mixed_test_vectors.h"
50 : : #include "test_cryptodev_sm4_test_vectors.h"
51 : : #include "test_cryptodev_nxan_test_vectors.h"
52 : : #ifdef RTE_LIB_SECURITY
53 : : #include "test_cryptodev_security_ipsec.h"
54 : : #include "test_cryptodev_security_ipsec_test_vectors.h"
55 : : #include "test_cryptodev_security_pdcp_test_vectors.h"
56 : : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
57 : : #include "test_cryptodev_security_pdcp_test_func.h"
58 : : #include "test_cryptodev_security_docsis_test_vectors.h"
59 : : #include "test_cryptodev_security_tls_record.h"
60 : : #include "test_security_proto.h"
61 : :
62 : : #define SDAP_DISABLED 0
63 : : #define SDAP_ENABLED 1
64 : : #endif
65 : :
66 : : #define VDEV_ARGS_SIZE 100
67 : : #define MAX_NB_SESSIONS 4
68 : :
69 : : #define MAX_RAW_DEQUEUE_COUNT 65535
70 : :
71 : : #define IN_PLACE 0
72 : : #define OUT_OF_PLACE 1
73 : :
74 : : #define QP_DRAIN_TIMEOUT 100
75 : : #define HW_ERR_RECOVER_TIMEOUT 500
76 : :
77 : : static int gbl_driver_id;
78 : :
79 : : enum rte_security_session_action_type gbl_action_type =
80 : : RTE_SECURITY_ACTION_TYPE_NONE;
81 : :
82 : : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
83 : :
84 : : struct crypto_unittest_params {
85 : : struct rte_crypto_sym_xform cipher_xform;
86 : : struct rte_crypto_sym_xform auth_xform;
87 : : struct rte_crypto_sym_xform aead_xform;
88 : : #ifdef RTE_LIB_SECURITY
89 : : struct rte_security_docsis_xform docsis_xform;
90 : : #endif
91 : :
92 : : union {
93 : : void *sess;
94 : : #ifdef RTE_LIB_SECURITY
95 : : void *sec_session;
96 : : #endif
97 : : };
98 : : #ifdef RTE_LIB_SECURITY
99 : : enum rte_security_session_action_type type;
100 : : #endif
101 : : struct rte_crypto_op *op;
102 : :
103 : : struct rte_mbuf *obuf, *ibuf;
104 : :
105 : : uint8_t *digest;
106 : : };
107 : :
108 : : #define ALIGN_POW2_ROUNDUP(num, align) \
109 : : (((num) + (align) - 1) & ~((align) - 1))
110 : :
111 : : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
112 : : for (j = 0; j < num_child_ts; index++, j++) \
113 : : parent_ts.unit_test_suites[index] = child_ts[j]
114 : :
115 : : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
116 : : for (j = 0; j < num_blk_types; index++, j++) \
117 : : parent_ts.unit_test_suites[index] = \
118 : : build_blockcipher_test_suite(blk_types[j])
119 : :
120 : : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
121 : : for (j = index; j < index + num_blk_types; j++) \
122 : : free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
123 : :
124 : : /*
125 : : * Forward declarations.
126 : : */
127 : : static int
128 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
129 : : struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
130 : : uint8_t *hmac_key);
131 : :
132 : : static int
133 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
134 : : struct crypto_unittest_params *ut_params,
135 : : struct crypto_testsuite_params *ts_param,
136 : : const uint8_t *cipher,
137 : : const uint8_t *digest,
138 : : const uint8_t *iv);
139 : :
140 : : static int
141 : : security_proto_supported(enum rte_security_session_action_type action,
142 : : enum rte_security_session_protocol proto);
143 : :
144 : : static int
145 : : dev_configure_and_start(uint64_t ff_disable);
146 : :
147 : : static int
148 : : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
149 : : const enum rte_crypto_cipher_algorithm cipher_algo,
150 : : const uint16_t key_size, const uint16_t iv_size);
151 : :
152 : : static int
153 : : check_auth_capability(const struct crypto_testsuite_params *ts_params,
154 : : const enum rte_crypto_auth_algorithm auth_algo,
155 : : const uint16_t key_size, const uint16_t iv_size,
156 : : const uint16_t tag_size);
157 : :
158 : : static struct rte_mbuf *
159 : 7 : setup_test_string(struct rte_mempool *mpool,
160 : : const char *string, size_t len, uint8_t blocksize)
161 : : {
162 : 7 : struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
163 [ - + ]: 7 : size_t t_len = len - (blocksize ? (len % blocksize) : 0);
164 : :
165 [ + - ]: 7 : if (m) {
166 : : char *dst;
167 : :
168 : 7 : memset(m->buf_addr, 0, m->buf_len);
169 : 7 : dst = rte_pktmbuf_append(m, t_len);
170 [ - + ]: 7 : if (!dst) {
171 : 0 : rte_pktmbuf_free(m);
172 : 0 : return NULL;
173 : : }
174 [ + - ]: 7 : if (string != NULL)
175 : : rte_memcpy(dst, string, t_len);
176 : : else
177 : : memset(dst, 0, t_len);
178 : : }
179 : :
180 : : return m;
181 : : }
182 : :
183 : : /* Get number of bytes in X bits (rounding up) */
184 : : static uint32_t
185 : : ceil_byte_length(uint32_t num_bits)
186 : : {
187 : 4 : if (num_bits % 8)
188 : 0 : return ((num_bits >> 3) + 1);
189 : : else
190 : 4 : return (num_bits >> 3);
191 : : }
192 : :
193 : : static void
194 : 0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
195 : : uint8_t is_op_success)
196 : : {
197 : : struct rte_crypto_op *op = user_data;
198 [ # # ]: 0 : op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
199 : : RTE_CRYPTO_OP_STATUS_ERROR;
200 : 0 : }
201 : :
202 : : static struct crypto_testsuite_params testsuite_params = { NULL };
203 : : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
204 : : static struct crypto_unittest_params unittest_params;
205 : : static bool enq_cb_called;
206 : : static bool deq_cb_called;
207 : :
208 : : enum cryptodev_err_state {
209 : : CRYPTODEV_ERR_CLEARED,
210 : : CRYPTODEV_ERR_TRIGGERED,
211 : : CRYPTODEV_ERR_UNRECOVERABLE,
212 : : };
213 : :
214 : : static enum cryptodev_err_state crypto_err = CRYPTODEV_ERR_CLEARED;
215 : :
216 : : static void
217 : 0 : test_cryptodev_error_cb(uint8_t dev_id, enum rte_cryptodev_event_type event, void *cb_arg)
218 : : {
219 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
220 : : uint16_t qp_id;
221 : : int ticks = 0;
222 : : int ret = 0;
223 : :
224 : : RTE_SET_USED(event);
225 : : RTE_SET_USED(cb_arg);
226 : :
227 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
228 : 0 : ret = rte_cryptodev_queue_pair_event_error_query(dev_id, qp_id);
229 [ # # ]: 0 : if (ret)
230 : : break;
231 : : }
232 [ # # ]: 0 : if (ret == 1) {
233 : : /* Wait for the queue to be completely drained */
234 [ # # # # ]: 0 : while (rte_cryptodev_qp_depth_used(dev_id, qp_id) != 0) {
235 : : rte_delay_ms(10);
236 : 0 : ticks++;
237 [ # # ]: 0 : if (ticks > QP_DRAIN_TIMEOUT) {
238 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
239 : 0 : return;
240 : : }
241 : : }
242 [ # # ]: 0 : if (rte_cryptodev_queue_pair_reset(dev_id, qp_id, NULL, 0)) {
243 : 0 : crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
244 : 0 : return;
245 : : }
246 : : }
247 : :
248 : 0 : crypto_err = CRYPTODEV_ERR_CLEARED;
249 : : }
250 : :
251 : : static struct rte_mbuf *
252 : 0 : create_mbuf_from_heap(int pkt_len, uint8_t pattern)
253 : : {
254 : : struct rte_mbuf *m = NULL;
255 : : uint8_t *dst;
256 : :
257 : 0 : m = calloc(1, MBUF_SIZE);
258 [ # # ]: 0 : if (m == NULL) {
259 : : printf("Cannot create mbuf from heap");
260 : 0 : return NULL;
261 : : }
262 : :
263 : : /* Set the default values to the mbuf */
264 : 0 : m->nb_segs = 1;
265 : 0 : m->port = RTE_MBUF_PORT_INVALID;
266 : 0 : m->buf_len = MBUF_SIZE - sizeof(struct rte_mbuf) - RTE_PKTMBUF_HEADROOM;
267 : : rte_pktmbuf_reset_headroom(m);
268 : : __rte_mbuf_sanity_check(m, 1);
269 : :
270 : 0 : m->buf_addr = (char *)m + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
271 : :
272 : 0 : memset(m->buf_addr, pattern, m->buf_len);
273 : 0 : dst = (uint8_t *)rte_pktmbuf_append(m, pkt_len);
274 [ # # ]: 0 : if (dst == NULL) {
275 : : printf("Cannot append %d bytes to the mbuf\n", pkt_len);
276 : 0 : free(m);
277 : 0 : return NULL;
278 : : }
279 : :
280 : : return m;
281 : : }
282 : :
283 : : int
284 : 0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
285 : : struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
286 : : uint8_t len_in_bits, uint8_t cipher_iv_len)
287 : : {
288 : 0 : struct rte_crypto_sym_op *sop = op->sym;
289 : 0 : struct rte_crypto_op *ret_op = NULL;
290 : : struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
291 : : struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
292 : : union rte_crypto_sym_ofs ofs;
293 : 0 : struct rte_crypto_sym_vec vec = {0};
294 : : struct rte_crypto_sgl sgl, dest_sgl;
295 : : uint32_t max_len;
296 : : union rte_cryptodev_session_ctx sess;
297 : : uint64_t auth_end_iova;
298 : : uint32_t count = 0;
299 : : struct rte_crypto_raw_dp_ctx *ctx;
300 : : uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
301 : : auth_len = 0;
302 : : int32_t n;
303 : : uint32_t n_success;
304 : : int ctx_service_size;
305 : 0 : int32_t status = 0;
306 : : int enqueue_status, dequeue_status;
307 : : struct crypto_unittest_params *ut_params = &unittest_params;
308 : 0 : int is_sgl = sop->m_src->nb_segs > 1;
309 : : int ret = TEST_SUCCESS, is_oop = 0;
310 : :
311 : 0 : ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
312 [ # # ]: 0 : if (ctx_service_size < 0)
313 : : return TEST_SKIPPED;
314 : :
315 : 0 : ctx = malloc(ctx_service_size);
316 [ # # ]: 0 : if (ctx == NULL)
317 : : return TEST_FAILED;
318 : :
319 : : /* Both are enums, setting crypto_sess will suit any session type */
320 : 0 : sess.crypto_sess = op->sym->session;
321 : :
322 : 0 : ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
323 [ # # ]: 0 : if (ret == -ENOTSUP) {
324 : : ret = TEST_SKIPPED;
325 : 0 : goto exit;
326 [ # # ]: 0 : } else if (ret) {
327 : : ret = TEST_FAILED;
328 : 0 : goto exit;
329 : : }
330 : :
331 : 0 : cipher_iv.iova = 0;
332 : 0 : cipher_iv.va = NULL;
333 : 0 : aad_auth_iv.iova = 0;
334 : 0 : aad_auth_iv.va = NULL;
335 : 0 : digest.iova = 0;
336 : 0 : digest.va = NULL;
337 : 0 : sgl.vec = data_vec;
338 : 0 : vec.num = 1;
339 : 0 : vec.src_sgl = &sgl;
340 : 0 : vec.iv = &cipher_iv;
341 : 0 : vec.digest = &digest;
342 : 0 : vec.aad = &aad_auth_iv;
343 : 0 : vec.status = &status;
344 : :
345 : 0 : ofs.raw = 0;
346 : :
347 [ # # # # ]: 0 : if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
348 : : is_oop = 1;
349 : :
350 [ # # ]: 0 : if (is_cipher && is_auth) {
351 : 0 : cipher_offset = sop->cipher.data.offset;
352 : 0 : cipher_len = sop->cipher.data.length;
353 : 0 : auth_offset = sop->auth.data.offset;
354 : 0 : auth_len = sop->auth.data.length;
355 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len,
356 : : auth_offset + auth_len);
357 [ # # ]: 0 : if (len_in_bits) {
358 : 0 : max_len = max_len >> 3;
359 : 0 : cipher_offset = cipher_offset >> 3;
360 : 0 : auth_offset = auth_offset >> 3;
361 : 0 : cipher_len = cipher_len >> 3;
362 : 0 : auth_len = auth_len >> 3;
363 : : }
364 : 0 : ofs.ofs.cipher.head = cipher_offset;
365 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
366 : 0 : ofs.ofs.auth.head = auth_offset;
367 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
368 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
369 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
370 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
371 : : op, void *, IV_OFFSET + cipher_iv_len);
372 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
373 : : cipher_iv_len);
374 : 0 : digest.va = (void *)sop->auth.digest.data;
375 : 0 : digest.iova = sop->auth.digest.phys_addr;
376 : :
377 [ # # ]: 0 : if (is_sgl) {
378 : 0 : uint32_t remaining_off = auth_offset + auth_len;
379 : 0 : struct rte_mbuf *sgl_buf = sop->m_src;
380 [ # # ]: 0 : if (is_oop)
381 : : sgl_buf = sop->m_dst;
382 : :
383 : 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
384 [ # # # # ]: 0 : && sgl_buf->next != NULL) {
385 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
386 : : sgl_buf = sgl_buf->next;
387 : : }
388 : :
389 : 0 : auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
390 : : sgl_buf, remaining_off);
391 : : } else {
392 : 0 : auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
393 : 0 : auth_offset + auth_len;
394 : : }
395 : : /* Then check if digest-encrypted conditions are met */
396 [ # # # # ]: 0 : if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
397 [ # # ]: 0 : (digest.iova == auth_end_iova) && is_sgl)
398 : 0 : max_len = RTE_MAX(max_len,
399 : : auth_offset + auth_len +
400 : : ut_params->auth_xform.auth.digest_length);
401 : :
402 [ # # ]: 0 : } else if (is_cipher) {
403 : 0 : cipher_offset = sop->cipher.data.offset;
404 : 0 : cipher_len = sop->cipher.data.length;
405 : 0 : max_len = cipher_len + cipher_offset;
406 [ # # ]: 0 : if (len_in_bits) {
407 : 0 : max_len = max_len >> 3;
408 : 0 : cipher_offset = cipher_offset >> 3;
409 : 0 : cipher_len = cipher_len >> 3;
410 : : }
411 : 0 : ofs.ofs.cipher.head = cipher_offset;
412 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
413 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
414 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
415 : :
416 [ # # ]: 0 : } else if (is_auth) {
417 : 0 : auth_offset = sop->auth.data.offset;
418 : 0 : auth_len = sop->auth.data.length;
419 : 0 : max_len = auth_len + auth_offset;
420 [ # # ]: 0 : if (len_in_bits) {
421 : 0 : max_len = max_len >> 3;
422 : 0 : auth_offset = auth_offset >> 3;
423 : 0 : auth_len = auth_len >> 3;
424 : : }
425 : 0 : ofs.ofs.auth.head = auth_offset;
426 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
427 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
428 : : op, void *, IV_OFFSET + cipher_iv_len);
429 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
430 : : cipher_iv_len);
431 : 0 : digest.va = (void *)sop->auth.digest.data;
432 : 0 : digest.iova = sop->auth.digest.phys_addr;
433 : :
434 : : } else { /* aead */
435 : 0 : cipher_offset = sop->aead.data.offset;
436 : 0 : cipher_len = sop->aead.data.length;
437 : 0 : max_len = cipher_len + cipher_offset;
438 [ # # ]: 0 : if (len_in_bits) {
439 : 0 : max_len = max_len >> 3;
440 : 0 : cipher_offset = cipher_offset >> 3;
441 : 0 : cipher_len = cipher_len >> 3;
442 : : }
443 : 0 : ofs.ofs.cipher.head = cipher_offset;
444 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
445 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
446 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
447 : 0 : aad_auth_iv.va = (void *)sop->aead.aad.data;
448 : 0 : aad_auth_iv.iova = sop->aead.aad.phys_addr;
449 : 0 : digest.va = (void *)sop->aead.digest.data;
450 : 0 : digest.iova = sop->aead.digest.phys_addr;
451 : : }
452 : :
453 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
454 : : data_vec, RTE_DIM(data_vec));
455 [ # # # # ]: 0 : if (n < 0 || n > sop->m_src->nb_segs) {
456 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
457 : 0 : goto exit;
458 : : }
459 : :
460 : 0 : sgl.num = n;
461 : : /* Out of place */
462 [ # # ]: 0 : if (is_oop) {
463 : 0 : dest_sgl.vec = dest_data_vec;
464 : 0 : vec.dest_sgl = &dest_sgl;
465 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
466 : : dest_data_vec, RTE_DIM(dest_data_vec));
467 [ # # # # ]: 0 : if (n < 0 || n > sop->m_dst->nb_segs) {
468 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
469 : 0 : goto exit;
470 : : }
471 : 0 : dest_sgl.num = n;
472 : : } else
473 : 0 : vec.dest_sgl = NULL;
474 : :
475 [ # # ]: 0 : if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
476 : : &enqueue_status) < 1) {
477 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
478 : 0 : goto exit;
479 : : }
480 : :
481 [ # # ]: 0 : if (enqueue_status == 0) {
482 : 0 : status = rte_cryptodev_raw_enqueue_done(ctx, 1);
483 [ # # ]: 0 : if (status < 0) {
484 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
485 : 0 : goto exit;
486 : : }
487 [ # # ]: 0 : } else if (enqueue_status < 0) {
488 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
489 : 0 : goto exit;
490 : : }
491 : :
492 : 0 : n = n_success = 0;
493 [ # # # # ]: 0 : while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
494 : 0 : n = rte_cryptodev_raw_dequeue_burst(ctx,
495 : : NULL, 1, post_process_raw_dp_op,
496 : : (void **)&ret_op, 0, &n_success,
497 : : &dequeue_status);
498 [ # # ]: 0 : if (dequeue_status < 0) {
499 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
500 : 0 : goto exit;
501 : : }
502 [ # # ]: 0 : if (n == 0)
503 : : rte_pause();
504 : : }
505 : :
506 [ # # # # ]: 0 : if (n == 1 && dequeue_status == 0) {
507 [ # # ]: 0 : if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
508 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
509 : 0 : goto exit;
510 : : }
511 : : }
512 : :
513 [ # # # # ]: 0 : op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
514 [ # # ]: 0 : ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
515 [ # # ]: 0 : n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
516 : : RTE_CRYPTO_OP_STATUS_SUCCESS;
517 : :
518 : 0 : exit:
519 : 0 : free(ctx);
520 : 0 : return ret;
521 : : }
522 : :
523 : : static void
524 : 0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
525 : : {
526 : : int32_t n, st;
527 : : struct rte_crypto_sym_op *sop;
528 : : union rte_crypto_sym_ofs ofs;
529 : : struct rte_crypto_sgl sgl;
530 : 0 : struct rte_crypto_sym_vec symvec = {0};
531 : : struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
532 : : struct rte_crypto_vec vec[UINT8_MAX];
533 : :
534 : : sop = op->sym;
535 : :
536 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
537 : : sop->aead.data.length, vec, RTE_DIM(vec));
538 : :
539 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
540 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
541 : 0 : return;
542 : : }
543 : :
544 : 0 : sgl.vec = vec;
545 : 0 : sgl.num = n;
546 : 0 : symvec.src_sgl = &sgl;
547 : 0 : symvec.iv = &iv_ptr;
548 : 0 : symvec.digest = &digest_ptr;
549 : 0 : symvec.aad = &aad_ptr;
550 : 0 : symvec.status = &st;
551 : 0 : symvec.num = 1;
552 : :
553 : : /* for CPU crypto the IOVA address is not required */
554 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
555 : 0 : digest_ptr.va = (void *)sop->aead.digest.data;
556 : 0 : aad_ptr.va = (void *)sop->aead.aad.data;
557 : :
558 : 0 : ofs.raw = 0;
559 : :
560 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
561 : : &symvec);
562 : :
563 [ # # ]: 0 : if (n != 1)
564 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
565 : : else
566 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
567 : : }
568 : :
569 : : static void
570 : 0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
571 : : {
572 : : int32_t n, st;
573 : : struct rte_crypto_sym_op *sop;
574 : : union rte_crypto_sym_ofs ofs;
575 : : struct rte_crypto_sgl sgl;
576 : 0 : struct rte_crypto_sym_vec symvec = {0};
577 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
578 : : struct rte_crypto_vec vec[UINT8_MAX];
579 : :
580 : : sop = op->sym;
581 : :
582 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
583 : : sop->auth.data.length, vec, RTE_DIM(vec));
584 : :
585 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
586 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
587 : 0 : return;
588 : : }
589 : :
590 : 0 : sgl.vec = vec;
591 : 0 : sgl.num = n;
592 : 0 : symvec.src_sgl = &sgl;
593 : 0 : symvec.iv = &iv_ptr;
594 : 0 : symvec.digest = &digest_ptr;
595 : 0 : symvec.status = &st;
596 : 0 : symvec.num = 1;
597 : :
598 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
599 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
600 : :
601 : 0 : ofs.raw = 0;
602 : 0 : ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
603 : 0 : ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
604 : 0 : (sop->cipher.data.offset + sop->cipher.data.length);
605 : :
606 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
607 : : &symvec);
608 : :
609 [ # # ]: 0 : if (n != 1)
610 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
611 : : else
612 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
613 : : }
614 : :
615 : : static struct rte_crypto_op *
616 : 118 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
617 : : {
618 : :
619 [ - + ]: 118 : RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
620 : :
621 [ - + ]: 118 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
622 : 0 : RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
623 : 0 : return NULL;
624 : : }
625 : :
626 : 118 : op = NULL;
627 : :
628 [ - + ]: 118 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
629 : : rte_pause();
630 : :
631 [ + + ]: 118 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
632 : 11 : RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
633 : 11 : return NULL;
634 : : }
635 : :
636 : : return op;
637 : : }
638 : :
639 : : static int
640 : 1 : testsuite_setup(void)
641 : : {
642 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
643 : : struct rte_cryptodev_info info;
644 : : uint32_t i = 0, nb_devs, dev_id;
645 : : uint16_t qp_id;
646 : :
647 : : memset(ts_params, 0, sizeof(*ts_params));
648 : :
649 : 1 : ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
650 [ + - ]: 1 : if (ts_params->mbuf_pool == NULL) {
651 : : /* Not already created so create */
652 : 1 : ts_params->mbuf_pool = rte_pktmbuf_pool_create(
653 : : "CRYPTO_MBUFPOOL",
654 : : NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
655 : 1 : rte_socket_id());
656 [ - + ]: 1 : if (ts_params->mbuf_pool == NULL) {
657 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
658 : 0 : return TEST_FAILED;
659 : : }
660 : : }
661 : :
662 : 1 : ts_params->large_mbuf_pool = rte_mempool_lookup(
663 : : "CRYPTO_LARGE_MBUFPOOL");
664 [ + - ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
665 : : /* Not already created so create */
666 : 1 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
667 : : "CRYPTO_LARGE_MBUFPOOL",
668 : : 1, 0, 0, LARGE_MBUF_SIZE,
669 : 1 : rte_socket_id());
670 [ - + ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
671 : 0 : RTE_LOG(ERR, USER1,
672 : : "Can't create CRYPTO_LARGE_MBUFPOOL\n");
673 : 0 : return TEST_FAILED;
674 : : }
675 : : }
676 : :
677 : 1 : ts_params->op_mpool = rte_crypto_op_pool_create(
678 : : "MBUF_CRYPTO_SYM_OP_POOL",
679 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC,
680 : : NUM_MBUFS, MBUF_CACHE_SIZE,
681 : : DEFAULT_NUM_XFORMS *
682 : : sizeof(struct rte_crypto_sym_xform) +
683 : : MAXIMUM_IV_LENGTH,
684 : 1 : rte_socket_id());
685 [ - + ]: 1 : if (ts_params->op_mpool == NULL) {
686 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
687 : 0 : return TEST_FAILED;
688 : : }
689 : :
690 : 1 : nb_devs = rte_cryptodev_count();
691 [ - + ]: 1 : if (nb_devs < 1) {
692 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
693 : 0 : return TEST_SKIPPED;
694 : : }
695 : :
696 [ - + ]: 1 : if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
697 : 0 : RTE_LOG(WARNING, USER1, "No %s devices found?\n",
698 : : rte_cryptodev_driver_name_get(gbl_driver_id));
699 : 0 : return TEST_SKIPPED;
700 : : }
701 : :
702 : : /* Create list of valid crypto devs */
703 [ + + ]: 2 : for (i = 0; i < nb_devs; i++) {
704 : 1 : rte_cryptodev_info_get(i, &info);
705 [ + - ]: 1 : if (info.driver_id == gbl_driver_id)
706 : 1 : ts_params->valid_devs[ts_params->valid_dev_count++] = i;
707 : : }
708 : :
709 [ + - ]: 1 : if (ts_params->valid_dev_count < 1)
710 : : return TEST_FAILED;
711 : :
712 : : /* Set up all the qps on the first of the valid devices found */
713 : :
714 : 1 : dev_id = ts_params->valid_devs[0];
715 : :
716 : 1 : rte_cryptodev_info_get(dev_id, &info);
717 : :
718 : 1 : ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
719 : 1 : ts_params->conf.socket_id = SOCKET_ID_ANY;
720 : 1 : ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
721 : :
722 : : unsigned int session_size =
723 : 1 : rte_cryptodev_sym_get_private_session_size(dev_id);
724 : :
725 : : #ifdef RTE_LIB_SECURITY
726 : 1 : unsigned int security_session_size = rte_security_session_get_size(
727 : : rte_cryptodev_get_sec_ctx(dev_id));
728 : :
729 : : if (session_size < security_session_size)
730 : : session_size = security_session_size;
731 : : #endif
732 : : /*
733 : : * Create mempool with maximum number of sessions.
734 : : */
735 [ - + ]: 1 : if (info.sym.max_nb_sessions != 0 &&
736 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
737 : 0 : RTE_LOG(ERR, USER1, "Device does not support "
738 : : "at least %u sessions\n",
739 : : MAX_NB_SESSIONS);
740 : 0 : return TEST_FAILED;
741 : : }
742 : :
743 : 1 : ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
744 : : "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
745 : : SOCKET_ID_ANY);
746 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
747 : : "session mempool allocation failed");
748 : :
749 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
750 : : &ts_params->conf),
751 : : "Failed to configure cryptodev %u with %u qps",
752 : : dev_id, ts_params->conf.nb_queue_pairs);
753 : :
754 : 1 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
755 : 1 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
756 : :
757 [ + + ]: 9 : for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
758 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
759 : : dev_id, qp_id, &ts_params->qp_conf,
760 : : rte_cryptodev_socket_id(dev_id)),
761 : : "Failed to setup queue pair %u on cryptodev %u",
762 : : qp_id, dev_id);
763 : : }
764 : :
765 : : return TEST_SUCCESS;
766 : : }
767 : :
768 : : static void
769 : 1 : testsuite_teardown(void)
770 : : {
771 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
772 : : int res;
773 : :
774 [ + - ]: 1 : if (ts_params->large_mbuf_pool != NULL) {
775 : 1 : rte_mempool_free(ts_params->large_mbuf_pool);
776 : 1 : ts_params->large_mbuf_pool = NULL;
777 : : }
778 : :
779 [ + - ]: 1 : if (ts_params->mbuf_pool != NULL) {
780 : 1 : rte_mempool_free(ts_params->mbuf_pool);
781 : 1 : ts_params->mbuf_pool = NULL;
782 : : }
783 : :
784 [ + - ]: 1 : if (ts_params->op_mpool != NULL) {
785 : 1 : rte_mempool_free(ts_params->op_mpool);
786 : 1 : ts_params->op_mpool = NULL;
787 : : }
788 : :
789 [ + - ]: 1 : if (ts_params->session_mpool != NULL) {
790 : 1 : rte_mempool_free(ts_params->session_mpool);
791 : 1 : ts_params->session_mpool = NULL;
792 : : }
793 : :
794 : 1 : res = rte_cryptodev_close(ts_params->valid_devs[0]);
795 [ - + ]: 1 : if (res)
796 : 0 : RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
797 : 1 : }
798 : :
799 : : static int
800 : 40 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
801 : : const int *algs, uint16_t num_algs)
802 : : {
803 : 40 : uint8_t dev_id = testsuite_params.valid_devs[0];
804 : : bool some_alg_supported = false;
805 : : uint16_t i;
806 : :
807 [ + + ]: 110 : for (i = 0; i < num_algs && !some_alg_supported; i++) {
808 : 70 : struct rte_cryptodev_sym_capability_idx alg = {
809 : 70 : type, {algs[i]}
810 : : };
811 [ + + ]: 70 : if (rte_cryptodev_sym_capability_get(dev_id,
812 : : &alg) != NULL)
813 : : some_alg_supported = true;
814 : : }
815 [ + + ]: 40 : if (!some_alg_supported)
816 : 23 : return TEST_SKIPPED;
817 : :
818 : : return 0;
819 : : }
820 : :
821 : : int
822 : 9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
823 : : uint16_t num_ciphers)
824 : : {
825 : 20 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
826 : : (const int *) ciphers, num_ciphers);
827 : : }
828 : :
829 : : int
830 : 2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
831 : : uint16_t num_auths)
832 : : {
833 : 12 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
834 : : (const int *) auths, num_auths);
835 : : }
836 : :
837 : : int
838 : 0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
839 : : uint16_t num_aeads)
840 : : {
841 : 8 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
842 : : (const int *) aeads, num_aeads);
843 : : }
844 : :
845 : : static int
846 : 1 : null_testsuite_setup(void)
847 : : {
848 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
849 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
850 : : struct rte_cryptodev_info dev_info;
851 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
852 : : RTE_CRYPTO_CIPHER_NULL
853 : : };
854 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
855 : : RTE_CRYPTO_AUTH_NULL
856 : : };
857 : :
858 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
859 : :
860 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
861 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
862 : : "testsuite not met\n");
863 : 0 : return TEST_SKIPPED;
864 : : }
865 : :
866 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
867 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
868 : : RTE_DIM(auths)) != 0) {
869 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for NULL "
870 : : "testsuite not met\n");
871 : 1 : return TEST_SKIPPED;
872 : : }
873 : :
874 : : return 0;
875 : : }
876 : :
877 : : static int
878 : 1 : crypto_gen_testsuite_setup(void)
879 : : {
880 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
881 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
882 : : struct rte_cryptodev_info dev_info;
883 : :
884 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
885 : :
886 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
887 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
888 : : "testsuite not met\n");
889 : 0 : return TEST_SKIPPED;
890 : : }
891 : :
892 : : return 0;
893 : : }
894 : :
895 : : #ifdef RTE_LIB_SECURITY
896 : : static int
897 : 4 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
898 : : {
899 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
900 : : struct crypto_unittest_params *ut_params = &unittest_params;
901 : : struct rte_cryptodev_info dev_info;
902 : : int ret = 0;
903 : :
904 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
905 : :
906 [ + - ]: 4 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
907 : 4 : RTE_LOG(INFO, USER1,
908 : : "Feature flag requirements for security protocol testsuite not met\n");
909 : 4 : return TEST_SKIPPED;
910 : : }
911 : :
912 : : /* Reconfigure to enable security */
913 : 0 : ret = dev_configure_and_start(0);
914 [ # # ]: 0 : if (ret != TEST_SUCCESS)
915 : : return ret;
916 : :
917 : : /* Set action type */
918 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
919 : :
920 [ # # ]: 0 : if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
921 : 0 : RTE_LOG(INFO, USER1,
922 : : "Capability requirements for security protocol test not met\n");
923 : : ret = TEST_SKIPPED;
924 : : }
925 : :
926 : 0 : test_sec_alg_list_populate();
927 : 0 : test_sec_auth_only_alg_list_populate();
928 : :
929 : : /*
930 : : * Stop the device. Device would be started again by individual test
931 : : * case setup routine.
932 : : */
933 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
934 : :
935 : 0 : return ret;
936 : : }
937 : :
938 : : static int
939 : 1 : ipsec_proto_testsuite_setup(void)
940 : : {
941 : 1 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
942 : : }
943 : :
944 : : static int
945 : 3 : tls_record_proto_testsuite_setup(void)
946 : : {
947 : 3 : test_sec_proto_pattern_generate();
948 : :
949 : 3 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
950 : : }
951 : :
952 : : static int
953 : 1 : pdcp_proto_testsuite_setup(void)
954 : : {
955 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
956 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
957 : : struct rte_cryptodev_info dev_info;
958 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
959 : : RTE_CRYPTO_CIPHER_NULL,
960 : : RTE_CRYPTO_CIPHER_AES_CTR,
961 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
962 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
963 : : };
964 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
965 : : RTE_CRYPTO_AUTH_NULL,
966 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
967 : : RTE_CRYPTO_AUTH_AES_CMAC,
968 : : RTE_CRYPTO_AUTH_ZUC_EIA3
969 : : };
970 : :
971 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
972 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
973 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
974 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
975 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
976 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
977 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
978 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
979 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
980 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
981 : :
982 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
983 : :
984 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
985 : : !(dev_info.feature_flags &
986 : : RTE_CRYPTODEV_FF_SECURITY)) {
987 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
988 : : "testsuite not met\n");
989 : 1 : return TEST_SKIPPED;
990 : : }
991 : :
992 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
993 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
994 : : RTE_DIM(auths)) != 0) {
995 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
996 : : "testsuite not met\n");
997 : 0 : return TEST_SKIPPED;
998 : : }
999 : :
1000 : : return 0;
1001 : : }
1002 : :
1003 : : static int
1004 : 1 : docsis_proto_testsuite_setup(void)
1005 : : {
1006 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1007 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1008 : : struct rte_cryptodev_info dev_info;
1009 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1010 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
1011 : : };
1012 : :
1013 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1014 : :
1015 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1016 : : !(dev_info.feature_flags &
1017 : : RTE_CRYPTODEV_FF_SECURITY)) {
1018 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
1019 : : "Proto testsuite not met\n");
1020 : 1 : return TEST_SKIPPED;
1021 : : }
1022 : :
1023 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1024 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
1025 : : "testsuite not met\n");
1026 : 0 : return TEST_SKIPPED;
1027 : : }
1028 : :
1029 : : return 0;
1030 : : }
1031 : : #endif
1032 : :
1033 : : static int
1034 : 1 : aes_ccm_auth_testsuite_setup(void)
1035 : : {
1036 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1037 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1038 : : struct rte_cryptodev_info dev_info;
1039 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1040 : : RTE_CRYPTO_AEAD_AES_CCM
1041 : : };
1042 : :
1043 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1044 : :
1045 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1046 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1047 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1048 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
1049 : : "testsuite not met\n");
1050 : 0 : return TEST_SKIPPED;
1051 : : }
1052 : :
1053 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1054 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
1055 : : "testsuite not met\n");
1056 : 0 : return TEST_SKIPPED;
1057 : : }
1058 : :
1059 : : return 0;
1060 : : }
1061 : :
1062 : : static int
1063 : 1 : aes_gcm_auth_testsuite_setup(void)
1064 : : {
1065 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1066 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1067 : : struct rte_cryptodev_info dev_info;
1068 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1069 : : RTE_CRYPTO_AEAD_AES_GCM
1070 : : };
1071 : :
1072 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1073 : :
1074 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1075 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
1076 : : "testsuite not met\n");
1077 : 0 : return TEST_SKIPPED;
1078 : : }
1079 : :
1080 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1081 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
1082 : : "testsuite not met\n");
1083 : 0 : return TEST_SKIPPED;
1084 : : }
1085 : :
1086 : : return 0;
1087 : : }
1088 : :
1089 : : static int
1090 : 1 : aes_gmac_auth_testsuite_setup(void)
1091 : : {
1092 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1093 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1094 : : struct rte_cryptodev_info dev_info;
1095 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1096 : : RTE_CRYPTO_AUTH_AES_GMAC
1097 : : };
1098 : :
1099 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1100 : :
1101 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1102 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1103 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1104 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1105 : : "testsuite not met\n");
1106 : 0 : return TEST_SKIPPED;
1107 : : }
1108 : :
1109 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1110 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1111 : : "testsuite not met\n");
1112 : 0 : return TEST_SKIPPED;
1113 : : }
1114 : :
1115 : : return 0;
1116 : : }
1117 : :
1118 : : static int
1119 : 1 : chacha20_poly1305_testsuite_setup(void)
1120 : : {
1121 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1122 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1123 : : struct rte_cryptodev_info dev_info;
1124 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1125 : : RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1126 : : };
1127 : :
1128 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1129 : :
1130 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1131 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1132 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1133 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1134 : : "Chacha20-Poly1305 testsuite not met\n");
1135 : 0 : return TEST_SKIPPED;
1136 : : }
1137 : :
1138 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1139 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1140 : : "Chacha20-Poly1305 testsuite not met\n");
1141 : 1 : return TEST_SKIPPED;
1142 : : }
1143 : :
1144 : : return 0;
1145 : : }
1146 : :
1147 : : static int
1148 : 1 : sm4_gcm_testsuite_setup(void)
1149 : : {
1150 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1151 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1152 : : struct rte_cryptodev_info dev_info;
1153 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1154 : : RTE_CRYPTO_AEAD_SM4_GCM
1155 : : };
1156 : :
1157 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1158 : :
1159 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1160 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1161 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1162 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1163 : : "SM4 GCM testsuite not met\n");
1164 : 0 : return TEST_SKIPPED;
1165 : : }
1166 : :
1167 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1168 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1169 : : "SM4 GCM testsuite not met\n");
1170 : 1 : return TEST_SKIPPED;
1171 : : }
1172 : :
1173 : : return 0;
1174 : : }
1175 : :
1176 : : static int
1177 : 1 : snow3g_testsuite_setup(void)
1178 : : {
1179 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1180 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1181 : : struct rte_cryptodev_info dev_info;
1182 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1183 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1184 : :
1185 : : };
1186 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1187 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2
1188 : : };
1189 : :
1190 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1191 : :
1192 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1193 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1194 : : "testsuite not met\n");
1195 : 0 : return TEST_SKIPPED;
1196 : : }
1197 : :
1198 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1199 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1200 : : RTE_DIM(auths)) != 0) {
1201 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1202 : : "testsuite not met\n");
1203 : 1 : return TEST_SKIPPED;
1204 : : }
1205 : :
1206 : : return 0;
1207 : : }
1208 : :
1209 : : static int
1210 : 1 : zuc_testsuite_setup(void)
1211 : : {
1212 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1213 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1214 : : struct rte_cryptodev_info dev_info;
1215 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1216 : : RTE_CRYPTO_CIPHER_ZUC_EEA3
1217 : : };
1218 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1219 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1220 : : };
1221 : :
1222 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1223 : :
1224 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1225 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1226 : : "testsuite not met\n");
1227 : 0 : return TEST_SKIPPED;
1228 : : }
1229 : :
1230 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1231 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1232 : : RTE_DIM(auths)) != 0) {
1233 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1234 : : "testsuite not met\n");
1235 : 1 : return TEST_SKIPPED;
1236 : : }
1237 : :
1238 : : return 0;
1239 : : }
1240 : :
1241 : : static int
1242 : 1 : hmac_md5_auth_testsuite_setup(void)
1243 : : {
1244 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1245 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1246 : : struct rte_cryptodev_info dev_info;
1247 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1248 : : RTE_CRYPTO_AUTH_MD5_HMAC
1249 : : };
1250 : :
1251 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1252 : :
1253 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1254 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1255 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1256 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1257 : : "Auth testsuite not met\n");
1258 : 0 : return TEST_SKIPPED;
1259 : : }
1260 : :
1261 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1262 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1263 : : "testsuite not met\n");
1264 : 0 : return TEST_SKIPPED;
1265 : : }
1266 : :
1267 : : return 0;
1268 : : }
1269 : :
1270 : : static int
1271 : 1 : kasumi_testsuite_setup(void)
1272 : : {
1273 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1274 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1275 : : struct rte_cryptodev_info dev_info;
1276 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1277 : : RTE_CRYPTO_CIPHER_KASUMI_F8
1278 : : };
1279 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1280 : : RTE_CRYPTO_AUTH_KASUMI_F9
1281 : : };
1282 : :
1283 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1284 : :
1285 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1286 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1287 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1288 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1289 : : "testsuite not met\n");
1290 : 0 : return TEST_SKIPPED;
1291 : : }
1292 : :
1293 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1294 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1295 : : RTE_DIM(auths)) != 0) {
1296 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1297 : : "testsuite not met\n");
1298 : 1 : return TEST_SKIPPED;
1299 : : }
1300 : :
1301 : : return 0;
1302 : : }
1303 : :
1304 : : static int
1305 : 1 : negative_aes_gcm_testsuite_setup(void)
1306 : : {
1307 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1308 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1309 : : struct rte_cryptodev_info dev_info;
1310 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1311 : : RTE_CRYPTO_AEAD_AES_GCM
1312 : : };
1313 : :
1314 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1315 : :
1316 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1317 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1318 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1319 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1320 : : "AES GCM testsuite not met\n");
1321 : 0 : return TEST_SKIPPED;
1322 : : }
1323 : :
1324 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1325 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1326 : : "AES GCM testsuite not met\n");
1327 : 0 : return TEST_SKIPPED;
1328 : : }
1329 : :
1330 : : return 0;
1331 : : }
1332 : :
1333 : : static int
1334 : 1 : negative_aes_gmac_testsuite_setup(void)
1335 : : {
1336 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1337 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1338 : : struct rte_cryptodev_info dev_info;
1339 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1340 : : RTE_CRYPTO_AUTH_AES_GMAC
1341 : : };
1342 : :
1343 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1344 : :
1345 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1346 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1347 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1348 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1349 : : "AES GMAC testsuite not met\n");
1350 : 0 : return TEST_SKIPPED;
1351 : : }
1352 : :
1353 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1354 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1355 : : "AES GMAC testsuite not met\n");
1356 : 0 : return TEST_SKIPPED;
1357 : : }
1358 : :
1359 : : return 0;
1360 : : }
1361 : :
1362 : : static int
1363 : 1 : mixed_cipher_hash_testsuite_setup(void)
1364 : : {
1365 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1366 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1367 : : struct rte_cryptodev_info dev_info;
1368 : : uint64_t feat_flags;
1369 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1370 : : RTE_CRYPTO_CIPHER_NULL,
1371 : : RTE_CRYPTO_CIPHER_AES_CTR,
1372 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
1373 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1374 : : };
1375 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1376 : : RTE_CRYPTO_AUTH_NULL,
1377 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1378 : : RTE_CRYPTO_AUTH_AES_CMAC,
1379 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1380 : : };
1381 : :
1382 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1383 : 1 : feat_flags = dev_info.feature_flags;
1384 : :
1385 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1386 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1387 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1388 : : "Cipher Hash testsuite not met\n");
1389 : 0 : return TEST_SKIPPED;
1390 : : }
1391 : :
1392 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1393 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1394 : : RTE_DIM(auths)) != 0) {
1395 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1396 : : "Cipher Hash testsuite not met\n");
1397 : 0 : return TEST_SKIPPED;
1398 : : }
1399 : :
1400 : : return 0;
1401 : : }
1402 : :
1403 : : static int
1404 : 1 : esn_testsuite_setup(void)
1405 : : {
1406 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1407 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1408 : : struct rte_cryptodev_info dev_info;
1409 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1410 : : RTE_CRYPTO_CIPHER_AES_CBC
1411 : : };
1412 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1413 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1414 : : };
1415 : :
1416 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1417 : :
1418 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1419 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1420 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1421 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1422 : : "testsuite not met\n");
1423 : 0 : return TEST_SKIPPED;
1424 : : }
1425 : :
1426 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1427 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1428 : : RTE_DIM(auths)) != 0) {
1429 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1430 : : "testsuite not met\n");
1431 : 0 : return TEST_SKIPPED;
1432 : : }
1433 : :
1434 : : return 0;
1435 : : }
1436 : :
1437 : : static int
1438 : 1 : multi_session_testsuite_setup(void)
1439 : : {
1440 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1441 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1442 : : struct rte_cryptodev_info dev_info;
1443 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1444 : : RTE_CRYPTO_CIPHER_AES_CBC
1445 : : };
1446 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1447 : : RTE_CRYPTO_AUTH_SHA512_HMAC
1448 : : };
1449 : :
1450 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1451 : :
1452 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1453 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1454 : : "Session testsuite not met\n");
1455 : 0 : return TEST_SKIPPED;
1456 : : }
1457 : :
1458 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1459 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1460 : : RTE_DIM(auths)) != 0) {
1461 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1462 : : "Session testsuite not met\n");
1463 : 0 : return TEST_SKIPPED;
1464 : : }
1465 : :
1466 : : return 0;
1467 : : }
1468 : :
1469 : : static int
1470 : 1 : negative_hmac_sha1_testsuite_setup(void)
1471 : : {
1472 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1473 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1474 : : struct rte_cryptodev_info dev_info;
1475 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1476 : : RTE_CRYPTO_CIPHER_AES_CBC
1477 : : };
1478 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1479 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1480 : : };
1481 : :
1482 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1483 : :
1484 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1485 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1486 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1487 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1488 : : "HMAC SHA1 testsuite not met\n");
1489 : 0 : return TEST_SKIPPED;
1490 : : }
1491 : :
1492 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1493 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1494 : : RTE_DIM(auths)) != 0) {
1495 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1496 : : "HMAC SHA1 testsuite not met\n");
1497 : 0 : return TEST_SKIPPED;
1498 : : }
1499 : :
1500 : : return 0;
1501 : : }
1502 : :
1503 : : static int
1504 : 434 : dev_configure_and_start(uint64_t ff_disable)
1505 : : {
1506 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1507 : : struct crypto_unittest_params *ut_params = &unittest_params;
1508 : :
1509 : : uint16_t qp_id;
1510 : :
1511 : : /* Clear unit test parameters before running test */
1512 : : memset(ut_params, 0, sizeof(*ut_params));
1513 : :
1514 : : /* Reconfigure device to default parameters */
1515 : 434 : ts_params->conf.socket_id = SOCKET_ID_ANY;
1516 : 434 : ts_params->conf.ff_disable = ff_disable;
1517 : 434 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1518 : 434 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
1519 : :
1520 [ - + ]: 434 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1521 : : &ts_params->conf),
1522 : : "Failed to configure cryptodev %u",
1523 : : ts_params->valid_devs[0]);
1524 : :
1525 [ + + ]: 3906 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1526 [ - + ]: 3472 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1527 : : ts_params->valid_devs[0], qp_id,
1528 : : &ts_params->qp_conf,
1529 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1530 : : "Failed to setup queue pair %u on cryptodev %u",
1531 : : qp_id, ts_params->valid_devs[0]);
1532 : : }
1533 : :
1534 : :
1535 : 434 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1536 : :
1537 : : /* Start the device */
1538 [ - + ]: 434 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1539 : : "Failed to start cryptodev %u",
1540 : : ts_params->valid_devs[0]);
1541 : :
1542 : : return TEST_SUCCESS;
1543 : : }
1544 : :
1545 : : int
1546 : 434 : ut_setup(void)
1547 : : {
1548 : : /* Configure and start the device with security feature disabled */
1549 : 434 : return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1550 : : }
1551 : :
1552 : : static int
1553 : 0 : ut_setup_security(void)
1554 : : {
1555 : : /* Configure and start the device with no features disabled */
1556 : 0 : return dev_configure_and_start(0);
1557 : : }
1558 : :
1559 : : static int
1560 : 0 : ut_setup_security_rx_inject(void)
1561 : : {
1562 : 0 : struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1563 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1564 : 0 : struct rte_eth_conf port_conf = {
1565 : : .rxmode = {
1566 : : .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1567 : : RTE_ETH_RX_OFFLOAD_SECURITY |
1568 : : RTE_ETH_RX_OFFLOAD_SCATTER,
1569 : : },
1570 : : .txmode = {
1571 : : .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1572 : : },
1573 : : .lpbk_mode = 1, /* Enable loopback */
1574 : : };
1575 : : struct rte_cryptodev_info dev_info;
1576 : 0 : struct rte_eth_rxconf rx_conf = {
1577 : : .rx_thresh = {
1578 : : .pthresh = 8,
1579 : : .hthresh = 8,
1580 : : .wthresh = 8,
1581 : : },
1582 : : .rx_free_thresh = 32,
1583 : : };
1584 : : uint16_t nb_ports;
1585 : : void *sec_ctx;
1586 : : int ret;
1587 : :
1588 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1589 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1590 : : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1591 : 0 : RTE_LOG(INFO, USER1,
1592 : : "Feature requirements for IPsec Rx inject test case not met\n");
1593 : 0 : return TEST_SKIPPED;
1594 : : }
1595 : :
1596 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1597 [ # # ]: 0 : if (sec_ctx == NULL)
1598 : : return TEST_SKIPPED;
1599 : :
1600 : 0 : nb_ports = rte_eth_dev_count_avail();
1601 [ # # ]: 0 : if (nb_ports == 0)
1602 : : return TEST_SKIPPED;
1603 : :
1604 : 0 : ret = rte_eth_dev_configure(0 /* port_id */,
1605 : : 1 /* nb_rx_queue */,
1606 : : 0 /* nb_tx_queue */,
1607 : : &port_conf);
1608 [ # # ]: 0 : if (ret) {
1609 : : printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1610 : 0 : return TEST_SKIPPED;
1611 : : }
1612 : :
1613 : : /* Rx queue setup */
1614 : 0 : ret = rte_eth_rx_queue_setup(0 /* port_id */,
1615 : : 0 /* rx_queue_id */,
1616 : : 1024 /* nb_rx_desc */,
1617 : : SOCKET_ID_ANY,
1618 : : &rx_conf,
1619 : : mbuf_pool);
1620 [ # # ]: 0 : if (ret) {
1621 : : printf("Could not setup eth port 0 queue 0\n");
1622 : 0 : return TEST_SKIPPED;
1623 : : }
1624 : :
1625 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1626 [ # # ]: 0 : if (ret) {
1627 : : printf("Could not enable Rx inject offload");
1628 : 0 : return TEST_SKIPPED;
1629 : : }
1630 : :
1631 : 0 : ret = rte_eth_dev_start(0);
1632 [ # # ]: 0 : if (ret) {
1633 : : printf("Could not start ethdev");
1634 : 0 : return TEST_SKIPPED;
1635 : : }
1636 : :
1637 : 0 : ret = rte_eth_promiscuous_enable(0);
1638 [ # # ]: 0 : if (ret) {
1639 : : printf("Could not enable promiscuous mode");
1640 : 0 : return TEST_SKIPPED;
1641 : : }
1642 : :
1643 : : /* Configure and start cryptodev with no features disabled */
1644 : 0 : return dev_configure_and_start(0);
1645 : : }
1646 : :
1647 : : static inline void
1648 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1649 : : {
1650 : 0 : }
1651 : :
1652 : : static inline void
1653 : 110 : ext_mbuf_memzone_free(int nb_segs)
1654 : : {
1655 : : int i;
1656 : :
1657 [ + + ]: 330 : for (i = 0; i <= nb_segs; i++) {
1658 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1659 : : const struct rte_memzone *memzone;
1660 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1661 : 220 : memzone = rte_memzone_lookup(mz_name);
1662 [ + + ]: 220 : if (memzone != NULL) {
1663 : 2 : rte_memzone_free(memzone);
1664 : : memzone = NULL;
1665 : : }
1666 : : }
1667 : 110 : }
1668 : :
1669 : : static inline struct rte_mbuf *
1670 : 2 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1671 : : int nb_segs, const void *input_text)
1672 : : {
1673 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
1674 : : size_t data_off = 0;
1675 : : uint8_t *dst;
1676 : : int i, size;
1677 : : int t_len;
1678 : :
1679 [ - + ]: 2 : if (pkt_len < 1) {
1680 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1681 : 0 : return NULL;
1682 : : }
1683 : :
1684 [ - + ]: 2 : if (nb_segs < 1) {
1685 : : printf("Number of segments must be 1 or more (is %d)\n",
1686 : : nb_segs);
1687 : 0 : return NULL;
1688 : : }
1689 : :
1690 [ + - ]: 2 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1691 : : size = pkt_len;
1692 : :
1693 : : /* Create chained mbuf_src with external buffer */
1694 [ + + ]: 4 : for (i = 0; size > 0; i++) {
1695 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1696 : 2 : uint16_t data_len = RTE_MIN(size, t_len);
1697 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1698 : : const struct rte_memzone *memzone;
1699 : : void *ext_buf_addr = NULL;
1700 : : rte_iova_t buf_iova;
1701 : 2 : bool freed = false;
1702 : : uint16_t buf_len;
1703 : :
1704 : 2 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1705 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
1706 : :
1707 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1708 : 2 : memzone = rte_memzone_lookup(mz_name);
1709 [ - + - - ]: 2 : if (memzone != NULL && memzone->len != buf_len) {
1710 : 0 : rte_memzone_free(memzone);
1711 : : memzone = NULL;
1712 : : }
1713 [ + - ]: 2 : if (memzone == NULL) {
1714 : 2 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1715 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1716 [ - + ]: 2 : if (memzone == NULL) {
1717 : : printf("Can't allocate memory zone %s\n", mz_name);
1718 : 0 : return NULL;
1719 : : }
1720 : : }
1721 : :
1722 : 2 : ext_buf_addr = memzone->addr;
1723 [ - + ]: 2 : if (input_text)
1724 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1725 : :
1726 : : /* Create buffer to hold rte_mbuf header */
1727 : 2 : m = rte_pktmbuf_alloc(mbuf_pool);
1728 [ + - ]: 2 : if (i == 0)
1729 : : mbuf = m;
1730 : :
1731 [ - + ]: 2 : if (m == NULL) {
1732 : : printf("Cannot create segment for source mbuf");
1733 : 0 : goto fail;
1734 : : }
1735 : :
1736 : : /* Save shared data (like callback function) in external buffer's end */
1737 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1738 : : ext_mbuf_callback_fn_free, &freed);
1739 : : if (ret_shinfo == NULL) {
1740 : : printf("Shared mem initialization failed!\n");
1741 : 0 : goto fail;
1742 : : }
1743 : :
1744 : 2 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
1745 : :
1746 : : /* Attach external buffer to mbuf */
1747 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1748 : : ret_shinfo);
1749 [ - + ]: 2 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1750 : : printf("External buffer is not attached to mbuf\n");
1751 : 0 : goto fail;
1752 : : }
1753 : :
1754 [ - + ]: 2 : if (input_text) {
1755 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1756 [ # # ]: 0 : if (dst == NULL) {
1757 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
1758 : 0 : goto fail;
1759 : : }
1760 : : }
1761 : :
1762 [ - + ]: 2 : if (mbuf != m)
1763 : : rte_pktmbuf_chain(mbuf, m);
1764 : :
1765 : 2 : size -= data_len;
1766 : 2 : data_off += data_len;
1767 : : }
1768 : :
1769 : : return mbuf;
1770 : :
1771 : : fail:
1772 : 0 : rte_pktmbuf_free(mbuf);
1773 : 0 : ext_mbuf_memzone_free(nb_segs);
1774 : 0 : return NULL;
1775 : : }
1776 : :
1777 : : void
1778 : 434 : ut_teardown(void)
1779 : : {
1780 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1781 : : struct crypto_unittest_params *ut_params = &unittest_params;
1782 : :
1783 : : /* free crypto session structure */
1784 : : #ifdef RTE_LIB_SECURITY
1785 [ - + ]: 434 : if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1786 [ # # ]: 0 : if (ut_params->sec_session) {
1787 : 0 : rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1788 : 0 : (ts_params->valid_devs[0]),
1789 : : ut_params->sec_session);
1790 : 0 : ut_params->sec_session = NULL;
1791 : : }
1792 : : } else
1793 : : #endif
1794 : : {
1795 [ + + ]: 434 : if (ut_params->sess) {
1796 : 111 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1797 : : ut_params->sess);
1798 : 111 : ut_params->sess = NULL;
1799 : : }
1800 : : }
1801 : :
1802 : : /* free crypto operation structure */
1803 : 434 : rte_crypto_op_free(ut_params->op);
1804 : :
1805 : : /*
1806 : : * free mbuf - both obuf and ibuf are usually the same,
1807 : : * so check if they point at the same address is necessary,
1808 : : * to avoid freeing the mbuf twice.
1809 : : */
1810 [ + + ]: 434 : if (ut_params->obuf) {
1811 : 6 : rte_pktmbuf_free(ut_params->obuf);
1812 [ + + ]: 6 : if (ut_params->ibuf == ut_params->obuf)
1813 : 3 : ut_params->ibuf = 0;
1814 : 6 : ut_params->obuf = 0;
1815 : : }
1816 [ + + ]: 434 : if (ut_params->ibuf) {
1817 : 110 : ext_mbuf_memzone_free(1);
1818 : 110 : rte_pktmbuf_free(ut_params->ibuf);
1819 : 110 : ut_params->ibuf = 0;
1820 : : }
1821 : :
1822 [ + - ]: 434 : if (ts_params->mbuf_pool != NULL)
1823 : 434 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1824 : : rte_mempool_avail_count(ts_params->mbuf_pool));
1825 : :
1826 : : /* Stop the device */
1827 : 434 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1828 : 434 : }
1829 : :
1830 : : static void
1831 : 0 : ut_teardown_rx_inject(void)
1832 : : {
1833 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1834 : : void *sec_ctx;
1835 : : int ret;
1836 : :
1837 [ # # ]: 0 : if (rte_eth_dev_count_avail() != 0) {
1838 : 0 : ret = rte_eth_dev_reset(0);
1839 [ # # ]: 0 : if (ret)
1840 : : printf("Could not reset eth port 0");
1841 : :
1842 : : }
1843 : :
1844 : 0 : ut_teardown();
1845 : :
1846 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1847 [ # # ]: 0 : if (sec_ctx == NULL)
1848 : : return;
1849 : :
1850 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1851 [ # # ]: 0 : if (ret) {
1852 : : printf("Could not disable Rx inject offload");
1853 : 0 : return;
1854 : : }
1855 : : }
1856 : :
1857 : : static int
1858 : 1 : test_device_configure_invalid_dev_id(void)
1859 : : {
1860 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1861 : : uint16_t dev_id, num_devs = 0;
1862 : :
1863 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1864 : : "Need at least %d devices for test", 1);
1865 : :
1866 : : /* valid dev_id values */
1867 : 1 : dev_id = ts_params->valid_devs[0];
1868 : :
1869 : : /* Stop the device in case it's started so it can be configured */
1870 : 1 : rte_cryptodev_stop(dev_id);
1871 : :
1872 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1873 : : "Failed test for rte_cryptodev_configure: "
1874 : : "invalid dev_num %u", dev_id);
1875 : :
1876 : : /* invalid dev_id values */
1877 : : dev_id = num_devs;
1878 : :
1879 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1880 : : "Failed test for rte_cryptodev_configure: "
1881 : : "invalid dev_num %u", dev_id);
1882 : :
1883 : : dev_id = 0xff;
1884 : :
1885 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1886 : : "Failed test for rte_cryptodev_configure:"
1887 : : "invalid dev_num %u", dev_id);
1888 : :
1889 : : return TEST_SUCCESS;
1890 : : }
1891 : :
1892 : : static int
1893 : 1 : test_device_configure_invalid_queue_pair_ids(void)
1894 : : {
1895 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1896 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1897 : :
1898 : : /* Stop the device in case it's started so it can be configured */
1899 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1900 : :
1901 : : /* valid - max value queue pairs */
1902 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1903 : :
1904 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1905 : : &ts_params->conf),
1906 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1907 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1908 : :
1909 : : /* valid - one queue pairs */
1910 : 1 : ts_params->conf.nb_queue_pairs = 1;
1911 : :
1912 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1913 : : &ts_params->conf),
1914 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1915 : : ts_params->valid_devs[0],
1916 : : ts_params->conf.nb_queue_pairs);
1917 : :
1918 : :
1919 : : /* invalid - zero queue pairs */
1920 : 1 : ts_params->conf.nb_queue_pairs = 0;
1921 : :
1922 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1923 : : &ts_params->conf),
1924 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1925 : : " invalid qps: %u",
1926 : : ts_params->valid_devs[0],
1927 : : ts_params->conf.nb_queue_pairs);
1928 : :
1929 : :
1930 : : /* invalid - max value supported by field queue pairs */
1931 : 1 : ts_params->conf.nb_queue_pairs = UINT16_MAX;
1932 : :
1933 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1934 : : &ts_params->conf),
1935 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1936 : : " invalid qps: %u",
1937 : : ts_params->valid_devs[0],
1938 : : ts_params->conf.nb_queue_pairs);
1939 : :
1940 : :
1941 : : /* invalid - max value + 1 queue pairs */
1942 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1943 : :
1944 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1945 : : &ts_params->conf),
1946 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1947 : : " invalid qps: %u",
1948 : : ts_params->valid_devs[0],
1949 : : ts_params->conf.nb_queue_pairs);
1950 : :
1951 : : /* revert to original testsuite value */
1952 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1953 : :
1954 : 1 : return TEST_SUCCESS;
1955 : : }
1956 : :
1957 : : static int
1958 : 1 : test_queue_pair_descriptor_setup(void)
1959 : : {
1960 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1961 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
1962 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1963 : : };
1964 : : uint16_t qp_id;
1965 : :
1966 : : /* Stop the device in case it's started so it can be configured */
1967 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1968 : :
1969 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1970 : : &ts_params->conf),
1971 : : "Failed to configure cryptodev %u",
1972 : : ts_params->valid_devs[0]);
1973 : :
1974 : : /*
1975 : : * Test various ring sizes on this device. memzones can't be
1976 : : * freed so are re-used if ring is released and re-created.
1977 : : */
1978 : 1 : qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1979 : 1 : qp_conf.mp_session = ts_params->session_mpool;
1980 : :
1981 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1982 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1983 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1984 : : rte_cryptodev_socket_id(
1985 : : ts_params->valid_devs[0])),
1986 : : "Failed test for "
1987 : : "rte_cryptodev_queue_pair_setup: num_inflights "
1988 : : "%u on qp %u on cryptodev %u",
1989 : : qp_conf.nb_descriptors, qp_id,
1990 : : ts_params->valid_devs[0]);
1991 : : }
1992 : :
1993 : 1 : qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1994 : :
1995 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1996 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1997 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1998 : : rte_cryptodev_socket_id(
1999 : : ts_params->valid_devs[0])),
2000 : : "Failed test for"
2001 : : " rte_cryptodev_queue_pair_setup: num_inflights"
2002 : : " %u on qp %u on cryptodev %u",
2003 : : qp_conf.nb_descriptors, qp_id,
2004 : : ts_params->valid_devs[0]);
2005 : : }
2006 : :
2007 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
2008 : :
2009 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
2010 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
2011 : : ts_params->valid_devs[0], qp_id, &qp_conf,
2012 : : rte_cryptodev_socket_id(
2013 : : ts_params->valid_devs[0])),
2014 : : "Failed test for "
2015 : : "rte_cryptodev_queue_pair_setup: num_inflights"
2016 : : " %u on qp %u on cryptodev %u",
2017 : : qp_conf.nb_descriptors, qp_id,
2018 : : ts_params->valid_devs[0]);
2019 : : }
2020 : :
2021 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
2022 : :
2023 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
2024 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
2025 : : ts_params->valid_devs[0], qp_id, &qp_conf,
2026 : : rte_cryptodev_socket_id(
2027 : : ts_params->valid_devs[0])),
2028 : : "Failed test for"
2029 : : " rte_cryptodev_queue_pair_setup:"
2030 : : "num_inflights %u on qp %u on cryptodev %u",
2031 : : qp_conf.nb_descriptors, qp_id,
2032 : : ts_params->valid_devs[0]);
2033 : : }
2034 : :
2035 : : /* test invalid queue pair id */
2036 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
2037 : :
2038 : : qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
2039 : :
2040 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2041 : : ts_params->valid_devs[0],
2042 : : qp_id, &qp_conf,
2043 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2044 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2045 : : "invalid qp %u on cryptodev %u",
2046 : : qp_id, ts_params->valid_devs[0]);
2047 : :
2048 : : qp_id = 0xffff; /*invalid*/
2049 : :
2050 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2051 : : ts_params->valid_devs[0],
2052 : : qp_id, &qp_conf,
2053 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2054 : : "Failed test for rte_cryptodev_queue_pair_setup:"
2055 : : "invalid qp %u on cryptodev %u",
2056 : : qp_id, ts_params->valid_devs[0]);
2057 : :
2058 : : return TEST_SUCCESS;
2059 : : }
2060 : :
2061 : : /* ***** Plaintext data for tests ***** */
2062 : :
2063 : : const char catch_22_quote_1[] =
2064 : : "There was only one catch and that was Catch-22, which "
2065 : : "specified that a concern for one's safety in the face of "
2066 : : "dangers that were real and immediate was the process of a "
2067 : : "rational mind. Orr was crazy and could be grounded. All he "
2068 : : "had to do was ask; and as soon as he did, he would no longer "
2069 : : "be crazy and would have to fly more missions. Orr would be "
2070 : : "crazy to fly more missions and sane if he didn't, but if he "
2071 : : "was sane he had to fly them. If he flew them he was crazy "
2072 : : "and didn't have to; but if he didn't want to he was sane and "
2073 : : "had to. Yossarian was moved very deeply by the absolute "
2074 : : "simplicity of this clause of Catch-22 and let out a "
2075 : : "respectful whistle. \"That's some catch, that Catch-22\", he "
2076 : : "observed. \"It's the best there is,\" Doc Daneeka agreed.";
2077 : :
2078 : : const char catch_22_quote[] =
2079 : : "What a lousy earth! He wondered how many people were "
2080 : : "destitute that same night even in his own prosperous country, "
2081 : : "how many homes were shanties, how many husbands were drunk "
2082 : : "and wives socked, and how many children were bullied, abused, "
2083 : : "or abandoned. How many families hungered for food they could "
2084 : : "not afford to buy? How many hearts were broken? How many "
2085 : : "suicides would take place that same night, how many people "
2086 : : "would go insane? How many cockroaches and landlords would "
2087 : : "triumph? How many winners were losers, successes failures, "
2088 : : "and rich men poor men? How many wise guys were stupid? How "
2089 : : "many happy endings were unhappy endings? How many honest men "
2090 : : "were liars, brave men cowards, loyal men traitors, how many "
2091 : : "sainted men were corrupt, how many people in positions of "
2092 : : "trust had sold their souls to bodyguards, how many had never "
2093 : : "had souls? How many straight-and-narrow paths were crooked "
2094 : : "paths? How many best families were worst families and how "
2095 : : "many good people were bad people? When you added them all up "
2096 : : "and then subtracted, you might be left with only the children, "
2097 : : "and perhaps with Albert Einstein and an old violinist or "
2098 : : "sculptor somewhere.";
2099 : :
2100 : : #define QUOTE_480_BYTES (480)
2101 : : #define QUOTE_512_BYTES (512)
2102 : : #define QUOTE_768_BYTES (768)
2103 : : #define QUOTE_1024_BYTES (1024)
2104 : :
2105 : :
2106 : :
2107 : : /* ***** SHA1 Hash Tests ***** */
2108 : :
2109 : : #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
2110 : :
2111 : : static uint8_t hmac_sha1_key[] = {
2112 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
2113 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
2114 : : 0xDE, 0xF4, 0xDE, 0xAD };
2115 : :
2116 : : /* ***** SHA224 Hash Tests ***** */
2117 : :
2118 : : #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
2119 : :
2120 : :
2121 : : /* ***** AES-CBC Cipher Tests ***** */
2122 : :
2123 : : #define CIPHER_KEY_LENGTH_AES_CBC (16)
2124 : : #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
2125 : :
2126 : : static uint8_t aes_cbc_key[] = {
2127 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2128 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2129 : :
2130 : : static uint8_t aes_cbc_iv[] = {
2131 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2132 : : 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2133 : :
2134 : :
2135 : : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2136 : :
2137 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2138 : : 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2139 : : 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2140 : : 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2141 : : 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2142 : : 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2143 : : 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2144 : : 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2145 : : 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2146 : : 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2147 : : 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2148 : : 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2149 : : 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2150 : : 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2151 : : 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2152 : : 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2153 : : 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2154 : : 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2155 : : 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2156 : : 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2157 : : 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2158 : : 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2159 : : 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2160 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2161 : : 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2162 : : 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2163 : : 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2164 : : 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2165 : : 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2166 : : 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2167 : : 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2168 : : 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2169 : : 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2170 : : 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2171 : : 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2172 : : 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2173 : : 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2174 : : 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2175 : : 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2176 : : 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2177 : : 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2178 : : 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2179 : : 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2180 : : 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2181 : : 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2182 : : 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2183 : : 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2184 : : 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2185 : : 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2186 : : 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2187 : : 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2188 : : 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2189 : : 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2190 : : 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2191 : : 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2192 : : 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2193 : : 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2194 : : 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2195 : : 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2196 : : 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2197 : : 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2198 : : 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2199 : : 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2200 : : 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2201 : : 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2202 : : };
2203 : :
2204 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2205 : : 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2206 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2207 : : 0x18, 0x8c, 0x1d, 0x32
2208 : : };
2209 : :
2210 : :
2211 : : /* Multisession Vector context Test */
2212 : : /*Begin Session 0 */
2213 : : static uint8_t ms_aes_cbc_key0[] = {
2214 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2215 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2216 : : };
2217 : :
2218 : : static uint8_t ms_aes_cbc_iv0[] = {
2219 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2220 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2221 : : };
2222 : :
2223 : : static const uint8_t ms_aes_cbc_cipher0[] = {
2224 : : 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2225 : : 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2226 : : 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2227 : : 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2228 : : 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2229 : : 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2230 : : 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2231 : : 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2232 : : 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2233 : : 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2234 : : 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2235 : : 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2236 : : 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2237 : : 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2238 : : 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2239 : : 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2240 : : 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2241 : : 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2242 : : 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2243 : : 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2244 : : 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2245 : : 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2246 : : 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2247 : : 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2248 : : 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2249 : : 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2250 : : 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2251 : : 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2252 : : 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2253 : : 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2254 : : 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2255 : : 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2256 : : 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2257 : : 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2258 : : 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2259 : : 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2260 : : 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2261 : : 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2262 : : 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2263 : : 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2264 : : 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2265 : : 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2266 : : 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2267 : : 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2268 : : 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2269 : : 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2270 : : 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2271 : : 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2272 : : 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2273 : : 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2274 : : 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2275 : : 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2276 : : 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2277 : : 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2278 : : 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2279 : : 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2280 : : 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2281 : : 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2282 : : 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2283 : : 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2284 : : 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2285 : : 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2286 : : 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2287 : : 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2288 : : };
2289 : :
2290 : :
2291 : : static uint8_t ms_hmac_key0[] = {
2292 : : 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2293 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2294 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2295 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2296 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2297 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2298 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2299 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2300 : : };
2301 : :
2302 : : static const uint8_t ms_hmac_digest0[] = {
2303 : : 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2304 : : 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2305 : : 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2306 : : 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2307 : : 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2308 : : 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2309 : : 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2310 : : 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2311 : : };
2312 : :
2313 : : /* End Session 0 */
2314 : : /* Begin session 1 */
2315 : :
2316 : : static uint8_t ms_aes_cbc_key1[] = {
2317 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2318 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2319 : : };
2320 : :
2321 : : static uint8_t ms_aes_cbc_iv1[] = {
2322 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2323 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2324 : : };
2325 : :
2326 : : static const uint8_t ms_aes_cbc_cipher1[] = {
2327 : : 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2328 : : 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2329 : : 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2330 : : 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2331 : : 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2332 : : 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2333 : : 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2334 : : 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2335 : : 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2336 : : 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2337 : : 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2338 : : 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2339 : : 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2340 : : 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2341 : : 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2342 : : 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2343 : : 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2344 : : 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2345 : : 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2346 : : 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2347 : : 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2348 : : 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2349 : : 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2350 : : 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2351 : : 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2352 : : 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2353 : : 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2354 : : 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2355 : : 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2356 : : 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2357 : : 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2358 : : 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2359 : : 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2360 : : 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2361 : : 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2362 : : 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2363 : : 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2364 : : 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2365 : : 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2366 : : 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2367 : : 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2368 : : 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2369 : : 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2370 : : 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2371 : : 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2372 : : 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2373 : : 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2374 : : 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2375 : : 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2376 : : 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2377 : : 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2378 : : 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2379 : : 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2380 : : 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2381 : : 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2382 : : 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2383 : : 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2384 : : 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2385 : : 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2386 : : 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2387 : : 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2388 : : 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2389 : : 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2390 : : 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2391 : :
2392 : : };
2393 : :
2394 : : static uint8_t ms_hmac_key1[] = {
2395 : : 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2396 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2397 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2398 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2399 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2400 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2401 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2402 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2403 : : };
2404 : :
2405 : : static const uint8_t ms_hmac_digest1[] = {
2406 : : 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2407 : : 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2408 : : 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2409 : : 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2410 : : 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2411 : : 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2412 : : 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2413 : : 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2414 : : };
2415 : : /* End Session 1 */
2416 : : /* Begin Session 2 */
2417 : : static uint8_t ms_aes_cbc_key2[] = {
2418 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2419 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2420 : : };
2421 : :
2422 : : static uint8_t ms_aes_cbc_iv2[] = {
2423 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2424 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2425 : : };
2426 : :
2427 : : static const uint8_t ms_aes_cbc_cipher2[] = {
2428 : : 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2429 : : 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2430 : : 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2431 : : 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2432 : : 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2433 : : 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2434 : : 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2435 : : 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2436 : : 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2437 : : 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2438 : : 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2439 : : 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2440 : : 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2441 : : 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2442 : : 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2443 : : 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2444 : : 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2445 : : 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2446 : : 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2447 : : 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2448 : : 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2449 : : 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2450 : : 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2451 : : 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2452 : : 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2453 : : 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2454 : : 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2455 : : 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2456 : : 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2457 : : 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2458 : : 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2459 : : 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2460 : : 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2461 : : 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2462 : : 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2463 : : 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2464 : : 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2465 : : 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2466 : : 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2467 : : 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2468 : : 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2469 : : 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2470 : : 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2471 : : 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2472 : : 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2473 : : 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2474 : : 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2475 : : 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2476 : : 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2477 : : 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2478 : : 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2479 : : 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2480 : : 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2481 : : 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2482 : : 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2483 : : 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2484 : : 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2485 : : 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2486 : : 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2487 : : 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2488 : : 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2489 : : 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2490 : : 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2491 : : 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2492 : : };
2493 : :
2494 : : static uint8_t ms_hmac_key2[] = {
2495 : : 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2496 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2497 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2498 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2499 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2500 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2501 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2502 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2503 : : };
2504 : :
2505 : : static const uint8_t ms_hmac_digest2[] = {
2506 : : 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2507 : : 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2508 : : 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2509 : : 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2510 : : 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2511 : : 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2512 : : 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2513 : : 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2514 : : };
2515 : :
2516 : : /* End Session 2 */
2517 : :
2518 : : #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
2519 : : static int
2520 : 1 : test_queue_pair_descriptor_count(void)
2521 : : {
2522 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2523 : : struct crypto_unittest_params *ut_params = &unittest_params;
2524 : 1 : struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
2525 : 1 : struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
2526 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2527 : : int qp_depth = 0;
2528 : : int i;
2529 : :
2530 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2531 : : return TEST_SKIPPED;
2532 : :
2533 : : /* Verify if the queue pair depth API is supported by driver */
2534 [ + - ]: 1 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2535 [ # # ]: 0 : if (qp_depth == -ENOTSUP)
2536 : 1 : return TEST_SKIPPED;
2537 : :
2538 : : /* Verify the capabilities */
2539 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2540 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2541 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2542 : : return TEST_SKIPPED;
2543 : :
2544 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2545 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2546 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2547 : : return TEST_SKIPPED;
2548 : :
2549 : : /* Setup Cipher Parameters */
2550 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2551 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2552 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2553 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2554 : 0 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2555 : 0 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2556 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2557 : 0 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2558 : :
2559 : : /* Setup HMAC Parameters */
2560 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2561 : 0 : ut_params->auth_xform.next = NULL;
2562 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2563 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2564 : 0 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2565 : 0 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2566 : 0 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2567 : :
2568 : 0 : rte_errno = 0;
2569 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
2570 : : &ut_params->cipher_xform, ts_params->session_mpool);
2571 [ # # ]: 0 : if (rte_errno == ENOTSUP)
2572 : : return TEST_SKIPPED;
2573 : :
2574 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2575 : :
2576 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
2577 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
2578 : : MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
2579 : :
2580 : : /* Generate crypto op data structure */
2581 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2582 : : struct rte_mbuf *m;
2583 : : uint8_t *digest;
2584 : :
2585 : : /* Generate test mbuf data and space for digest */
2586 : 0 : m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
2587 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
2588 : :
2589 : : digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
2590 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
2591 : :
2592 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
2593 : :
2594 : : /* set crypto operation source mbuf */
2595 : 0 : ops[i]->sym->m_src = m;
2596 : :
2597 : : /* Set crypto operation authentication parameters */
2598 : 0 : ops[i]->sym->auth.digest.data = digest;
2599 : 0 : ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
2600 : :
2601 : 0 : ops[i]->sym->auth.data.offset = 0;
2602 : 0 : ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
2603 : :
2604 : : /* Copy IV at the end of the crypto operation */
2605 : 0 : memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
2606 : : CIPHER_IV_LENGTH_AES_CBC);
2607 : :
2608 : : /* Set crypto operation cipher parameters */
2609 : 0 : ops[i]->sym->cipher.data.offset = 0;
2610 : 0 : ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
2611 : :
2612 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
2613 : : &ops[i], 1), 1, "Error enqueuing");
2614 : : }
2615 : :
2616 [ # # ]: 0 : for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2617 [ # # ]: 0 : qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2618 [ # # ]: 0 : TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
2619 : : "Crypto queue pair depth used does not match with inflight ops");
2620 : :
2621 : 0 : while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
2622 [ # # ]: 0 : &ops_deq[i], 1) == 0)
2623 : : rte_pause();
2624 : :
2625 [ # # ]: 0 : TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2626 : : "crypto op processing failed");
2627 : :
2628 : 0 : rte_pktmbuf_free(ops_deq[i]->sym->m_src);
2629 : 0 : rte_crypto_op_free(ops_deq[i]);
2630 : 0 : ops_deq[i] = NULL;
2631 : : }
2632 : :
2633 : : return TEST_SUCCESS;
2634 : : }
2635 : :
2636 : : static int
2637 : 2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2638 : : {
2639 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2640 : : struct crypto_unittest_params *ut_params = &unittest_params;
2641 : : /* Verify the capabilities */
2642 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2643 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2644 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2645 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2646 : : &cap_idx) == NULL)
2647 : : return TEST_SKIPPED;
2648 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2649 : 2 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2650 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2651 : : &cap_idx) == NULL)
2652 : : return TEST_SKIPPED;
2653 : :
2654 : : /* Generate test mbuf data and space for digest */
2655 : 2 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2656 : : catch_22_quote, QUOTE_512_BYTES, 0);
2657 : :
2658 : 2 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2659 : : DIGEST_BYTE_LENGTH_SHA1);
2660 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2661 : :
2662 : : /* Setup Cipher Parameters */
2663 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2664 : 2 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2665 : :
2666 : 2 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2667 : 2 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2668 : 2 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2669 : 2 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2670 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2671 : 2 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2672 : :
2673 : : /* Setup HMAC Parameters */
2674 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2675 : :
2676 : 2 : ut_params->auth_xform.next = NULL;
2677 : :
2678 : 2 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2679 : 2 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2680 : 2 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2681 : 2 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2682 : 2 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2683 : :
2684 : 2 : rte_errno = 0;
2685 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(
2686 : 2 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2687 : : ts_params->session_mpool);
2688 [ + - ]: 2 : if (rte_errno == ENOTSUP)
2689 : : return TEST_SKIPPED;
2690 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2691 : :
2692 : : /* Generate crypto op data structure */
2693 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2694 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2695 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
2696 : : "Failed to allocate symmetric crypto operation struct");
2697 : :
2698 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2699 : :
2700 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2701 : :
2702 : : /* set crypto operation source mbuf */
2703 : 2 : sym_op->m_src = ut_params->ibuf;
2704 : :
2705 : : /* Set crypto operation authentication parameters */
2706 : 2 : sym_op->auth.digest.data = ut_params->digest;
2707 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2708 : : ut_params->ibuf, QUOTE_512_BYTES);
2709 : :
2710 : 2 : sym_op->auth.data.offset = 0;
2711 : 2 : sym_op->auth.data.length = QUOTE_512_BYTES;
2712 : :
2713 : : /* Copy IV at the end of the crypto operation */
2714 [ - + ]: 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2715 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2716 : :
2717 : : /* Set crypto operation cipher parameters */
2718 : 2 : sym_op->cipher.data.offset = 0;
2719 : 2 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2720 : :
2721 : : /* Process crypto operation */
2722 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2723 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2724 : : ut_params->op);
2725 : : else
2726 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
2727 : : process_crypto_request(ts_params->valid_devs[0],
2728 : : ut_params->op),
2729 : : "failed to process sym crypto op");
2730 : :
2731 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2732 : : "crypto op processing failed");
2733 : :
2734 : : /* Validate obuf */
2735 : 2 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2736 : : uint8_t *);
2737 : :
2738 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2739 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2740 : : QUOTE_512_BYTES,
2741 : : "ciphertext data not as expected");
2742 : :
2743 : 2 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2744 : :
2745 [ + - - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2746 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2747 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2748 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2749 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2750 : : DIGEST_BYTE_LENGTH_SHA1,
2751 : : "Generated digest data not as expected");
2752 : :
2753 : : return TEST_SUCCESS;
2754 : : }
2755 : :
2756 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2757 : :
2758 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2759 : :
2760 : : static uint8_t hmac_sha512_key[] = {
2761 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2762 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2763 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2764 : : 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2765 : : 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2766 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2767 : : 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2768 : : 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2769 : :
2770 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2771 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2772 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2773 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2774 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2775 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2776 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2777 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2778 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2779 : :
2780 : :
2781 : :
2782 : : static int
2783 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2784 : : struct crypto_unittest_params *ut_params,
2785 : : uint8_t *cipher_key,
2786 : : uint8_t *hmac_key);
2787 : :
2788 : : static int
2789 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2790 : : struct crypto_unittest_params *ut_params,
2791 : : struct crypto_testsuite_params *ts_params,
2792 : : const uint8_t *cipher,
2793 : : const uint8_t *digest,
2794 : : const uint8_t *iv);
2795 : :
2796 : :
2797 : : static int
2798 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2799 : : struct crypto_unittest_params *ut_params,
2800 : : uint8_t *cipher_key,
2801 : : uint8_t *hmac_key)
2802 : : {
2803 : :
2804 : : /* Setup Cipher Parameters */
2805 : 4 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2806 : 4 : ut_params->cipher_xform.next = NULL;
2807 : :
2808 : 4 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2809 : 4 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2810 : 4 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2811 : 4 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2812 : 4 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2813 : 4 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2814 : :
2815 : : /* Setup HMAC Parameters */
2816 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2817 : 4 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2818 : :
2819 : 4 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2820 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2821 : 4 : ut_params->auth_xform.auth.key.data = hmac_key;
2822 : 4 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2823 : 4 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2824 : :
2825 : : return TEST_SUCCESS;
2826 : : }
2827 : :
2828 : :
2829 : : static int
2830 : 5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2831 : : struct crypto_unittest_params *ut_params,
2832 : : struct crypto_testsuite_params *ts_params,
2833 : : const uint8_t *cipher,
2834 : : const uint8_t *digest,
2835 : : const uint8_t *iv)
2836 : : {
2837 : : int ret;
2838 : :
2839 : : /* Generate test mbuf data and digest */
2840 : 5 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2841 : : (const char *)
2842 : : cipher,
2843 : : QUOTE_512_BYTES, 0);
2844 : :
2845 : 5 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2846 : : DIGEST_BYTE_LENGTH_SHA512);
2847 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2848 : :
2849 : : rte_memcpy(ut_params->digest,
2850 : : digest,
2851 : : DIGEST_BYTE_LENGTH_SHA512);
2852 : :
2853 : : /* Generate Crypto op data structure */
2854 : 5 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2855 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2856 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->op,
2857 : : "Failed to allocate symmetric crypto operation struct");
2858 : :
2859 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2860 : :
2861 : 5 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2862 : :
2863 : : /* set crypto operation source mbuf */
2864 : 5 : sym_op->m_src = ut_params->ibuf;
2865 : :
2866 : 5 : sym_op->auth.digest.data = ut_params->digest;
2867 [ - + ]: 5 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2868 : : ut_params->ibuf, QUOTE_512_BYTES);
2869 : :
2870 : 5 : sym_op->auth.data.offset = 0;
2871 : 5 : sym_op->auth.data.length = QUOTE_512_BYTES;
2872 : :
2873 : : /* Copy IV at the end of the crypto operation */
2874 [ - + ]: 5 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2875 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2876 : :
2877 : 5 : sym_op->cipher.data.offset = 0;
2878 : 5 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2879 : :
2880 : : /* Process crypto operation */
2881 [ - + ]: 5 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2882 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2883 : : ut_params->op);
2884 [ - + ]: 5 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2885 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2886 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2887 : : return ret;
2888 : : } else
2889 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(
2890 : : process_crypto_request(ts_params->valid_devs[0],
2891 : : ut_params->op),
2892 : : "failed to process sym crypto op");
2893 : :
2894 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2895 : : "crypto op processing failed");
2896 : :
2897 : 5 : ut_params->obuf = ut_params->op->sym->m_src;
2898 : :
2899 : : /* Validate obuf */
2900 [ - + ]: 5 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2901 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2902 : : catch_22_quote,
2903 : : QUOTE_512_BYTES,
2904 : : "Plaintext data not as expected");
2905 : :
2906 : : /* Validate obuf */
2907 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2908 : : "Digest verification failed");
2909 : :
2910 : : return TEST_SUCCESS;
2911 : : }
2912 : :
2913 : : /* ***** SNOW 3G Tests ***** */
2914 : : static int
2915 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2916 : : const uint8_t *key, const uint8_t key_len,
2917 : : const uint8_t iv_len, const uint8_t auth_len,
2918 : : enum rte_crypto_auth_operation op,
2919 : : enum rte_crypto_auth_algorithm algo)
2920 : : {
2921 : 0 : uint8_t *hash_key = alloca(key_len);
2922 : :
2923 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2924 : : struct crypto_unittest_params *ut_params = &unittest_params;
2925 : :
2926 : : memcpy(hash_key, key, key_len);
2927 : :
2928 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2929 : :
2930 : : /* Setup Authentication Parameters */
2931 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2932 : 0 : ut_params->auth_xform.next = NULL;
2933 : :
2934 : 0 : ut_params->auth_xform.auth.op = op;
2935 : 0 : ut_params->auth_xform.auth.algo = algo;
2936 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2937 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2938 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2939 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2940 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2941 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2942 : : &ut_params->auth_xform, ts_params->session_mpool);
2943 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2944 : : return TEST_SKIPPED;
2945 : :
2946 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2947 : : return 0;
2948 : : }
2949 : :
2950 : : static int
2951 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2952 : : enum rte_crypto_cipher_operation op,
2953 : : enum rte_crypto_cipher_algorithm algo,
2954 : : const uint8_t *key, const uint8_t key_len,
2955 : : uint8_t iv_len)
2956 : : {
2957 : 0 : uint8_t *cipher_key = alloca(key_len);
2958 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2959 : : struct crypto_unittest_params *ut_params = &unittest_params;
2960 : :
2961 : : memcpy(cipher_key, key, key_len);
2962 : :
2963 : : /* Setup Cipher Parameters */
2964 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2965 : 0 : ut_params->cipher_xform.next = NULL;
2966 : :
2967 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2968 : 0 : ut_params->cipher_xform.cipher.op = op;
2969 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2970 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2971 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2972 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2973 : :
2974 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2975 : :
2976 : : /* Create Crypto session */
2977 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2978 : : &ut_params->cipher_xform, ts_params->session_mpool);
2979 : :
2980 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2981 : : return TEST_SKIPPED;
2982 : :
2983 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2984 : : return 0;
2985 : : }
2986 : :
2987 : : static int
2988 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2989 : : unsigned int cipher_len,
2990 : : unsigned int cipher_offset)
2991 : : {
2992 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2993 : : struct crypto_unittest_params *ut_params = &unittest_params;
2994 : :
2995 : : /* Generate Crypto op data structure */
2996 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2997 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2998 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2999 : : "Failed to allocate pktmbuf offload");
3000 : :
3001 : : /* Set crypto operation data parameters */
3002 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3003 : :
3004 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3005 : :
3006 : : /* set crypto operation source mbuf */
3007 : 0 : sym_op->m_src = ut_params->ibuf;
3008 : :
3009 : : /* iv */
3010 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3011 : : iv, iv_len);
3012 : 0 : sym_op->cipher.data.length = cipher_len;
3013 : 0 : sym_op->cipher.data.offset = cipher_offset;
3014 : 0 : return 0;
3015 : : }
3016 : :
3017 : : static int
3018 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
3019 : : unsigned int cipher_len,
3020 : : unsigned int cipher_offset)
3021 : : {
3022 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3023 : : struct crypto_unittest_params *ut_params = &unittest_params;
3024 : :
3025 : : /* Generate Crypto op data structure */
3026 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3027 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3028 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3029 : : "Failed to allocate pktmbuf offload");
3030 : :
3031 : : /* Set crypto operation data parameters */
3032 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3033 : :
3034 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3035 : :
3036 : : /* set crypto operation source mbuf */
3037 : 0 : sym_op->m_src = ut_params->ibuf;
3038 : 0 : sym_op->m_dst = ut_params->obuf;
3039 : :
3040 : : /* iv */
3041 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3042 : : iv, iv_len);
3043 : 0 : sym_op->cipher.data.length = cipher_len;
3044 : 0 : sym_op->cipher.data.offset = cipher_offset;
3045 : 0 : return 0;
3046 : : }
3047 : :
3048 : : static int
3049 : 1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
3050 : : enum rte_crypto_cipher_operation cipher_op,
3051 : : enum rte_crypto_auth_operation auth_op,
3052 : : enum rte_crypto_auth_algorithm auth_algo,
3053 : : enum rte_crypto_cipher_algorithm cipher_algo,
3054 : : const uint8_t *a_key, uint8_t a_key_len,
3055 : : const uint8_t *c_key, uint8_t c_key_len,
3056 : : uint8_t auth_iv_len, uint8_t auth_len,
3057 : : uint8_t cipher_iv_len)
3058 : :
3059 : : {
3060 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3061 : : struct crypto_unittest_params *ut_params = &unittest_params;
3062 : :
3063 : : /* Setup Authentication Parameters */
3064 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3065 : 1 : ut_params->auth_xform.next = NULL;
3066 : :
3067 : 1 : ut_params->auth_xform.auth.op = auth_op;
3068 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3069 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3070 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3071 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3072 : : /* Auth IV will be after cipher IV */
3073 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3074 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3075 : :
3076 : : /* Setup Cipher Parameters */
3077 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3078 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3079 : :
3080 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3081 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3082 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3083 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3084 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3085 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3086 : :
3087 : 1 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
3088 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3089 : :
3090 : : /* Create Crypto session*/
3091 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3092 : : &ut_params->cipher_xform, ts_params->session_mpool);
3093 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3094 : : return TEST_SKIPPED;
3095 : :
3096 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3097 : : return 0;
3098 : : }
3099 : :
3100 : : static int
3101 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
3102 : : enum rte_crypto_cipher_operation cipher_op,
3103 : : enum rte_crypto_auth_operation auth_op,
3104 : : enum rte_crypto_auth_algorithm auth_algo,
3105 : : enum rte_crypto_cipher_algorithm cipher_algo,
3106 : : const struct wireless_test_data *tdata)
3107 : : {
3108 : 0 : const uint8_t key_len = tdata->key.len;
3109 : 0 : uint8_t *cipher_auth_key = alloca(key_len);
3110 : :
3111 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3112 : : struct crypto_unittest_params *ut_params = &unittest_params;
3113 : 0 : const uint8_t *key = tdata->key.data;
3114 : 0 : const uint8_t auth_len = tdata->digest.len;
3115 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
3116 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
3117 : :
3118 : : memcpy(cipher_auth_key, key, key_len);
3119 : :
3120 : : /* Setup Authentication Parameters */
3121 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3122 : 0 : ut_params->auth_xform.next = NULL;
3123 : :
3124 : 0 : ut_params->auth_xform.auth.op = auth_op;
3125 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
3126 : 0 : ut_params->auth_xform.auth.key.length = key_len;
3127 : : /* Hash key = cipher key */
3128 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
3129 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
3130 : : /* Auth IV will be after cipher IV */
3131 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3132 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3133 : :
3134 : : /* Setup Cipher Parameters */
3135 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3136 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3137 : :
3138 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3139 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
3140 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
3141 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
3142 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3143 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3144 : :
3145 : :
3146 : 0 : debug_hexdump(stdout, "key:", key, key_len);
3147 : :
3148 : : /* Create Crypto session*/
3149 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3150 : : &ut_params->cipher_xform, ts_params->session_mpool);
3151 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3152 : : return TEST_SKIPPED;
3153 : :
3154 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3155 : : return 0;
3156 : : }
3157 : :
3158 : : static int
3159 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
3160 : : const struct wireless_test_data *tdata)
3161 : : {
3162 : 0 : return create_wireless_cipher_auth_session(dev_id,
3163 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3164 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
3165 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
3166 : : }
3167 : :
3168 : : static int
3169 : 1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
3170 : : enum rte_crypto_cipher_operation cipher_op,
3171 : : enum rte_crypto_auth_operation auth_op,
3172 : : enum rte_crypto_auth_algorithm auth_algo,
3173 : : enum rte_crypto_cipher_algorithm cipher_algo,
3174 : : const uint8_t *a_key, const uint8_t a_key_len,
3175 : : const uint8_t *c_key, const uint8_t c_key_len,
3176 : : uint8_t auth_iv_len, uint8_t auth_len,
3177 : : uint8_t cipher_iv_len)
3178 : : {
3179 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3180 : : struct crypto_unittest_params *ut_params = &unittest_params;
3181 : :
3182 : : /* Setup Authentication Parameters */
3183 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3184 : 1 : ut_params->auth_xform.auth.op = auth_op;
3185 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
3186 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
3187 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
3188 : 1 : ut_params->auth_xform.auth.key.data = a_key;
3189 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
3190 : : /* Auth IV will be after cipher IV */
3191 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3192 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
3193 : :
3194 : : /* Setup Cipher Parameters */
3195 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3196 : 1 : ut_params->cipher_xform.next = NULL;
3197 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
3198 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
3199 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
3200 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
3201 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3202 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3203 : :
3204 : 1 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
3205 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3206 : :
3207 : : /* Create Crypto session*/
3208 [ - + ]: 1 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3209 : 0 : ut_params->auth_xform.next = NULL;
3210 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
3211 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3212 : : &ut_params->cipher_xform, ts_params->session_mpool);
3213 : : } else
3214 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3215 : : &ut_params->auth_xform, ts_params->session_mpool);
3216 : :
3217 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3218 : : return TEST_SKIPPED;
3219 : :
3220 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3221 : :
3222 : : return 0;
3223 : : }
3224 : :
3225 : : static int
3226 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
3227 : : unsigned int auth_tag_len,
3228 : : const uint8_t *iv, unsigned int iv_len,
3229 : : unsigned int data_pad_len,
3230 : : enum rte_crypto_auth_operation op,
3231 : : unsigned int auth_len, unsigned int auth_offset)
3232 : : {
3233 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3234 : :
3235 : : struct crypto_unittest_params *ut_params = &unittest_params;
3236 : :
3237 : : /* Generate Crypto op data structure */
3238 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3239 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3240 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3241 : : "Failed to allocate pktmbuf offload");
3242 : :
3243 : : /* Set crypto operation data parameters */
3244 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3245 : :
3246 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3247 : :
3248 : : /* set crypto operation source mbuf */
3249 : 0 : sym_op->m_src = ut_params->ibuf;
3250 : :
3251 : : /* iv */
3252 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3253 : : iv, iv_len);
3254 : : /* digest */
3255 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3256 : : ut_params->ibuf, auth_tag_len);
3257 : :
3258 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3259 : : "no room to append auth tag");
3260 : 0 : ut_params->digest = sym_op->auth.digest.data;
3261 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3262 : : ut_params->ibuf, data_pad_len);
3263 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3264 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3265 : : else
3266 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3267 : :
3268 : 0 : debug_hexdump(stdout, "digest:",
3269 : 0 : sym_op->auth.digest.data,
3270 : : auth_tag_len);
3271 : :
3272 : 0 : sym_op->auth.data.length = auth_len;
3273 : 0 : sym_op->auth.data.offset = auth_offset;
3274 : :
3275 : 0 : return 0;
3276 : : }
3277 : :
3278 : : static int
3279 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3280 : : enum rte_crypto_auth_operation op)
3281 : : {
3282 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3283 : : struct crypto_unittest_params *ut_params = &unittest_params;
3284 : :
3285 : 0 : const uint8_t *auth_tag = tdata->digest.data;
3286 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
3287 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3288 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3289 : :
3290 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
3291 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3292 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
3293 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
3294 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3295 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
3296 : :
3297 : : /* Generate Crypto op data structure */
3298 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3299 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3300 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3301 : : "Failed to allocate pktmbuf offload");
3302 : : /* Set crypto operation data parameters */
3303 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3304 : :
3305 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3306 : :
3307 : : /* set crypto operation source mbuf */
3308 : 0 : sym_op->m_src = ut_params->ibuf;
3309 : :
3310 : : /* digest */
3311 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3312 : : ut_params->ibuf, auth_tag_len);
3313 : :
3314 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3315 : : "no room to append auth tag");
3316 : 0 : ut_params->digest = sym_op->auth.digest.data;
3317 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3318 : : ut_params->ibuf, data_pad_len);
3319 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3320 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3321 : : else
3322 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3323 : :
3324 : 0 : debug_hexdump(stdout, "digest:",
3325 : 0 : sym_op->auth.digest.data,
3326 : : auth_tag_len);
3327 : :
3328 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3329 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3330 : : IV_OFFSET);
3331 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3332 : 0 : iv_ptr += cipher_iv_len;
3333 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3334 : :
3335 : 0 : sym_op->cipher.data.length = cipher_len;
3336 : 0 : sym_op->cipher.data.offset = 0;
3337 : 0 : sym_op->auth.data.length = auth_len;
3338 : 0 : sym_op->auth.data.offset = 0;
3339 : :
3340 : 0 : return 0;
3341 : : }
3342 : :
3343 : : static int
3344 : : create_zuc_cipher_hash_generate_operation(
3345 : : const struct wireless_test_data *tdata)
3346 : : {
3347 : 0 : return create_wireless_cipher_hash_operation(tdata,
3348 : : RTE_CRYPTO_AUTH_OP_GENERATE);
3349 : : }
3350 : :
3351 : : static int
3352 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3353 : : const unsigned auth_tag_len,
3354 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3355 : : unsigned data_pad_len,
3356 : : enum rte_crypto_auth_operation op,
3357 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3358 : : const unsigned cipher_len, const unsigned cipher_offset,
3359 : : const unsigned auth_len, const unsigned auth_offset)
3360 : : {
3361 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3362 : : struct crypto_unittest_params *ut_params = &unittest_params;
3363 : :
3364 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
3365 : : ut_params->cipher_xform.cipher.algo;
3366 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3367 : : ut_params->auth_xform.auth.algo;
3368 : :
3369 : : /* Generate Crypto op data structure */
3370 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3371 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3372 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3373 : : "Failed to allocate pktmbuf offload");
3374 : : /* Set crypto operation data parameters */
3375 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3376 : :
3377 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3378 : :
3379 : : /* set crypto operation source mbuf */
3380 : 0 : sym_op->m_src = ut_params->ibuf;
3381 : :
3382 : : /* digest */
3383 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3384 : : ut_params->ibuf, auth_tag_len);
3385 : :
3386 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3387 : : "no room to append auth tag");
3388 : 0 : ut_params->digest = sym_op->auth.digest.data;
3389 : :
3390 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3391 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3392 : : ut_params->ibuf, data_pad_len);
3393 : : } else {
3394 : : struct rte_mbuf *m = ut_params->ibuf;
3395 : : unsigned int offset = data_pad_len;
3396 : :
3397 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3398 : 0 : offset -= m->data_len;
3399 : : m = m->next;
3400 : : }
3401 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3402 : : m, offset);
3403 : : }
3404 : :
3405 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3406 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3407 : : else
3408 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3409 : :
3410 : 0 : debug_hexdump(stdout, "digest:",
3411 : 0 : sym_op->auth.digest.data,
3412 : : auth_tag_len);
3413 : :
3414 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3415 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3416 : : IV_OFFSET);
3417 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3418 : 0 : iv_ptr += cipher_iv_len;
3419 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3420 : :
3421 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3422 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3423 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3424 : 0 : sym_op->cipher.data.length = cipher_len;
3425 : 0 : sym_op->cipher.data.offset = cipher_offset;
3426 : : } else {
3427 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3428 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3429 : : }
3430 : :
3431 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3432 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3433 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3434 : 0 : sym_op->auth.data.length = auth_len;
3435 : 0 : sym_op->auth.data.offset = auth_offset;
3436 : : } else {
3437 : 0 : sym_op->auth.data.length = auth_len >> 3;
3438 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3439 : : }
3440 : :
3441 : : return 0;
3442 : : }
3443 : :
3444 : : static int
3445 : 2 : create_wireless_algo_auth_cipher_operation(
3446 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3447 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3448 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3449 : : unsigned int data_pad_len,
3450 : : unsigned int cipher_len, unsigned int cipher_offset,
3451 : : unsigned int auth_len, unsigned int auth_offset,
3452 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3453 : : {
3454 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3455 : : struct crypto_unittest_params *ut_params = &unittest_params;
3456 : :
3457 : 2 : enum rte_crypto_cipher_algorithm cipher_algo =
3458 : : ut_params->cipher_xform.cipher.algo;
3459 : 2 : enum rte_crypto_auth_algorithm auth_algo =
3460 : : ut_params->auth_xform.auth.algo;
3461 : :
3462 : : /* Generate Crypto op data structure */
3463 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3464 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3465 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
3466 : : "Failed to allocate pktmbuf offload");
3467 : :
3468 : : /* Set crypto operation data parameters */
3469 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3470 : :
3471 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3472 : :
3473 : : /* set crypto operation mbufs */
3474 : 2 : sym_op->m_src = ut_params->ibuf;
3475 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE)
3476 : 0 : sym_op->m_dst = ut_params->obuf;
3477 : :
3478 : : /* digest */
3479 [ - + ]: 2 : if (!do_sgl) {
3480 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3481 : : (op_mode == IN_PLACE ?
3482 : : ut_params->ibuf : ut_params->obuf),
3483 : : uint8_t *, data_pad_len);
3484 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3485 : : (op_mode == IN_PLACE ?
3486 : : ut_params->ibuf : ut_params->obuf),
3487 : : data_pad_len);
3488 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3489 : : } else {
3490 : 2 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3491 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3492 [ - + ]: 2 : sym_op->m_src : sym_op->m_dst);
3493 : : struct rte_mbuf *sgl_buf_head = sgl_buf;
3494 : :
3495 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3496 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3497 : 30 : sgl_buf = sgl_buf->next;
3498 : : }
3499 : :
3500 : : /* The last segment should be large enough to hold full digest */
3501 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3502 : : uint16_t next_data_len = 0;
3503 [ # # ]: 0 : if (sgl_buf->next != NULL) {
3504 : 0 : next_data_len = sgl_buf->next->data_len;
3505 : :
3506 : 0 : rte_pktmbuf_free(sgl_buf->next);
3507 : 0 : sgl_buf->next = NULL;
3508 : 0 : sgl_buf_head->nb_segs -= 1;
3509 : 0 : sgl_buf_head->pkt_len -= next_data_len;
3510 : : }
3511 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(
3512 : : sgl_buf_head, auth_tag_len - sgl_buf->data_len),
3513 : : "No room to append auth tag");
3514 : : }
3515 : :
3516 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3517 : : uint8_t *, remaining_off);
3518 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3519 : : remaining_off);
3520 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3521 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3522 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3523 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3524 : 0 : sgl_buf = sgl_buf->next;
3525 : : }
3526 : : }
3527 : :
3528 : : /* Copy digest for the verification */
3529 [ + + ]: 2 : if (verify)
3530 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3531 : :
3532 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3533 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3534 : : ut_params->op, uint8_t *, IV_OFFSET);
3535 : :
3536 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3537 : 2 : iv_ptr += cipher_iv_len;
3538 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3539 : :
3540 : : /* Only copy over the offset data needed from src to dst in OOP,
3541 : : * if the auth and cipher offsets are not aligned
3542 : : */
3543 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3544 [ # # ]: 0 : if (cipher_offset > auth_offset)
3545 : 0 : rte_memcpy(
3546 : 0 : rte_pktmbuf_mtod_offset(
3547 : : sym_op->m_dst,
3548 : : uint8_t *, auth_offset >> 3),
3549 : 0 : rte_pktmbuf_mtod_offset(
3550 : : sym_op->m_src,
3551 : : uint8_t *, auth_offset >> 3),
3552 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3553 : : }
3554 : :
3555 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3556 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3557 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3558 : 0 : sym_op->cipher.data.length = cipher_len;
3559 : 0 : sym_op->cipher.data.offset = cipher_offset;
3560 : : } else {
3561 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3562 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3563 : : }
3564 : :
3565 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3566 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3567 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3568 : 0 : sym_op->auth.data.length = auth_len;
3569 : 0 : sym_op->auth.data.offset = auth_offset;
3570 : : } else {
3571 : 2 : sym_op->auth.data.length = auth_len >> 3;
3572 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3573 : : }
3574 : :
3575 : : return 0;
3576 : : }
3577 : :
3578 : : static int
3579 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3580 : : {
3581 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3582 : : struct crypto_unittest_params *ut_params = &unittest_params;
3583 : :
3584 : : int retval;
3585 : : unsigned plaintext_pad_len;
3586 : : unsigned plaintext_len;
3587 : : uint8_t *plaintext;
3588 : : struct rte_cryptodev_info dev_info;
3589 : :
3590 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3591 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3592 : :
3593 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3594 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3595 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3596 : 0 : return TEST_SKIPPED;
3597 : : }
3598 : :
3599 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3600 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3601 : : printf("Device doesn't support RAW data-path APIs.\n");
3602 : 0 : return TEST_SKIPPED;
3603 : : }
3604 : :
3605 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3606 : : return TEST_SKIPPED;
3607 : :
3608 : : /* Verify the capabilities */
3609 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3610 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3611 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3612 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3613 : : &cap_idx) == NULL)
3614 : : return TEST_SKIPPED;
3615 : :
3616 : : /* Create SNOW 3G session */
3617 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3618 : 0 : tdata->key.data, tdata->key.len,
3619 : 0 : tdata->auth_iv.len, tdata->digest.len,
3620 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3621 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3622 [ # # ]: 0 : if (retval < 0)
3623 : : return retval;
3624 : :
3625 : : /* alloc mbuf and set payload */
3626 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3627 : :
3628 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3629 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3630 : :
3631 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3632 : : /* Append data which is padded to a multiple of */
3633 : : /* the algorithms block size */
3634 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3635 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3636 : : plaintext_pad_len);
3637 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3638 : :
3639 : : /* Create SNOW 3G operation */
3640 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3641 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3642 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3643 : 0 : tdata->validAuthLenInBits.len,
3644 : : 0);
3645 [ # # ]: 0 : if (retval < 0)
3646 : : return retval;
3647 : :
3648 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3649 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3650 : : 0);
3651 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3652 : : return retval;
3653 : : } else
3654 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3655 : : ut_params->op);
3656 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3657 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3658 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3659 : : uint8_t *,
3660 : : plaintext_pad_len);
3661 : :
3662 : : /* Validate obuf */
3663 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3664 : : ut_params->digest,
3665 : : tdata->digest.data,
3666 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3667 : : "SNOW 3G Generated auth tag not as expected");
3668 : :
3669 : : return 0;
3670 : : }
3671 : :
3672 : : static int
3673 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3674 : : {
3675 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3676 : : struct crypto_unittest_params *ut_params = &unittest_params;
3677 : :
3678 : : int retval;
3679 : : unsigned plaintext_pad_len;
3680 : : unsigned plaintext_len;
3681 : : uint8_t *plaintext;
3682 : : struct rte_cryptodev_info dev_info;
3683 : :
3684 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3685 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3686 : :
3687 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3688 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3689 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3690 : 0 : return TEST_SKIPPED;
3691 : : }
3692 : :
3693 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3694 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3695 : : printf("Device doesn't support RAW data-path APIs.\n");
3696 : 0 : return TEST_SKIPPED;
3697 : : }
3698 : :
3699 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3700 : : return TEST_SKIPPED;
3701 : :
3702 : : /* Verify the capabilities */
3703 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3704 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3705 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3706 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3707 : : &cap_idx) == NULL)
3708 : : return TEST_SKIPPED;
3709 : :
3710 : : /* Create SNOW 3G session */
3711 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3712 : 0 : tdata->key.data, tdata->key.len,
3713 : 0 : tdata->auth_iv.len, tdata->digest.len,
3714 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3715 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3716 [ # # ]: 0 : if (retval < 0)
3717 : : return retval;
3718 : : /* alloc mbuf and set payload */
3719 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3720 : :
3721 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3722 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3723 : :
3724 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3725 : : /* Append data which is padded to a multiple of */
3726 : : /* the algorithms block size */
3727 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3728 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3729 : : plaintext_pad_len);
3730 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3731 : :
3732 : : /* Create SNOW 3G operation */
3733 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3734 : 0 : tdata->digest.len,
3735 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3736 : : plaintext_pad_len,
3737 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3738 : 0 : tdata->validAuthLenInBits.len,
3739 : : 0);
3740 [ # # ]: 0 : if (retval < 0)
3741 : : return retval;
3742 : :
3743 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3744 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3745 : : 0);
3746 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3747 : : return retval;
3748 : : } else
3749 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3750 : : ut_params->op);
3751 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3752 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3753 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3754 : : uint8_t *,
3755 : : plaintext_pad_len);
3756 : :
3757 : : /* Validate obuf */
3758 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3759 : : return 0;
3760 : : else
3761 : 0 : return -1;
3762 : :
3763 : : return 0;
3764 : : }
3765 : :
3766 : : static int
3767 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3768 : : {
3769 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3770 : : struct crypto_unittest_params *ut_params = &unittest_params;
3771 : :
3772 : : int retval;
3773 : : unsigned plaintext_pad_len;
3774 : : unsigned plaintext_len;
3775 : : uint8_t *plaintext;
3776 : : struct rte_cryptodev_info dev_info;
3777 : :
3778 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3779 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3780 : :
3781 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3782 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3783 : : printf("Device doesn't support RAW data-path APIs.\n");
3784 : 0 : return TEST_SKIPPED;
3785 : : }
3786 : :
3787 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3788 : : return TEST_SKIPPED;
3789 : :
3790 : : /* Verify the capabilities */
3791 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3792 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3793 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3794 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3795 : : &cap_idx) == NULL)
3796 : : return TEST_SKIPPED;
3797 : :
3798 : : /* Create KASUMI session */
3799 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3800 : 0 : tdata->key.data, tdata->key.len,
3801 : 0 : 0, tdata->digest.len,
3802 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3803 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3804 [ # # ]: 0 : if (retval < 0)
3805 : : return retval;
3806 : :
3807 : : /* alloc mbuf and set payload */
3808 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3809 : :
3810 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3811 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3812 : :
3813 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3814 : : /* Append data which is padded to a multiple of */
3815 : : /* the algorithms block size */
3816 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3817 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3818 : : plaintext_pad_len);
3819 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3820 : :
3821 : : /* Create KASUMI operation */
3822 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3823 : : NULL, 0,
3824 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3825 : 0 : tdata->plaintext.len,
3826 : : 0);
3827 [ # # ]: 0 : if (retval < 0)
3828 : : return retval;
3829 : :
3830 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3831 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3832 : : ut_params->op);
3833 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3834 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3835 : : 0);
3836 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3837 : : return retval;
3838 : : } else
3839 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3840 : : ut_params->op);
3841 : :
3842 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3843 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3844 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3845 : : uint8_t *,
3846 : : plaintext_pad_len);
3847 : :
3848 : : /* Validate obuf */
3849 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3850 : : ut_params->digest,
3851 : : tdata->digest.data,
3852 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3853 : : "KASUMI Generated auth tag not as expected");
3854 : :
3855 : : return 0;
3856 : : }
3857 : :
3858 : : static int
3859 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3860 : : {
3861 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3862 : : struct crypto_unittest_params *ut_params = &unittest_params;
3863 : :
3864 : : int retval;
3865 : : unsigned plaintext_pad_len;
3866 : : unsigned plaintext_len;
3867 : : uint8_t *plaintext;
3868 : : struct rte_cryptodev_info dev_info;
3869 : :
3870 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3871 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3872 : :
3873 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3874 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3875 : : printf("Device doesn't support RAW data-path APIs.\n");
3876 : 0 : return TEST_SKIPPED;
3877 : : }
3878 : :
3879 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3880 : : return TEST_SKIPPED;
3881 : :
3882 : : /* Verify the capabilities */
3883 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3884 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3885 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3886 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3887 : : &cap_idx) == NULL)
3888 : : return TEST_SKIPPED;
3889 : :
3890 : : /* Create KASUMI session */
3891 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3892 : 0 : tdata->key.data, tdata->key.len,
3893 : 0 : 0, tdata->digest.len,
3894 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3895 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3896 [ # # ]: 0 : if (retval < 0)
3897 : : return retval;
3898 : : /* alloc mbuf and set payload */
3899 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3900 : :
3901 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3902 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3903 : :
3904 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3905 : : /* Append data which is padded to a multiple */
3906 : : /* of the algorithms block size */
3907 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3908 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3909 : : plaintext_pad_len);
3910 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3911 : :
3912 : : /* Create KASUMI operation */
3913 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3914 : 0 : tdata->digest.len,
3915 : : NULL, 0,
3916 : : plaintext_pad_len,
3917 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3918 : 0 : tdata->plaintext.len,
3919 : : 0);
3920 [ # # ]: 0 : if (retval < 0)
3921 : : return retval;
3922 : :
3923 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3924 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3925 : : 0);
3926 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3927 : : return retval;
3928 : : } else
3929 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3930 : : ut_params->op);
3931 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3932 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3933 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3934 : : uint8_t *,
3935 : : plaintext_pad_len);
3936 : :
3937 : : /* Validate obuf */
3938 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3939 : : return 0;
3940 : : else
3941 : 0 : return -1;
3942 : :
3943 : : return 0;
3944 : : }
3945 : :
3946 : : static int
3947 : 0 : test_snow3g_hash_generate_test_case_1(void)
3948 : : {
3949 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3950 : : }
3951 : :
3952 : : static int
3953 : 0 : test_snow3g_hash_generate_test_case_2(void)
3954 : : {
3955 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3956 : : }
3957 : :
3958 : : static int
3959 : 0 : test_snow3g_hash_generate_test_case_3(void)
3960 : : {
3961 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3962 : : }
3963 : :
3964 : : static int
3965 : 0 : test_snow3g_hash_generate_test_case_4(void)
3966 : : {
3967 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3968 : : }
3969 : :
3970 : : static int
3971 : 0 : test_snow3g_hash_generate_test_case_5(void)
3972 : : {
3973 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3974 : : }
3975 : :
3976 : : static int
3977 : 0 : test_snow3g_hash_generate_test_case_6(void)
3978 : : {
3979 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3980 : : }
3981 : :
3982 : : static int
3983 : 0 : test_snow3g_hash_verify_test_case_1(void)
3984 : : {
3985 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3986 : :
3987 : : }
3988 : :
3989 : : static int
3990 : 0 : test_snow3g_hash_verify_test_case_2(void)
3991 : : {
3992 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3993 : : }
3994 : :
3995 : : static int
3996 : 0 : test_snow3g_hash_verify_test_case_3(void)
3997 : : {
3998 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3999 : : }
4000 : :
4001 : : static int
4002 : 0 : test_snow3g_hash_verify_test_case_4(void)
4003 : : {
4004 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
4005 : : }
4006 : :
4007 : : static int
4008 : 0 : test_snow3g_hash_verify_test_case_5(void)
4009 : : {
4010 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
4011 : : }
4012 : :
4013 : : static int
4014 : 0 : test_snow3g_hash_verify_test_case_6(void)
4015 : : {
4016 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
4017 : : }
4018 : :
4019 : : static int
4020 : 0 : test_kasumi_hash_generate_test_case_1(void)
4021 : : {
4022 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
4023 : : }
4024 : :
4025 : : static int
4026 : 0 : test_kasumi_hash_generate_test_case_2(void)
4027 : : {
4028 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
4029 : : }
4030 : :
4031 : : static int
4032 : 0 : test_kasumi_hash_generate_test_case_3(void)
4033 : : {
4034 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
4035 : : }
4036 : :
4037 : : static int
4038 : 0 : test_kasumi_hash_generate_test_case_4(void)
4039 : : {
4040 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
4041 : : }
4042 : :
4043 : : static int
4044 : 0 : test_kasumi_hash_generate_test_case_5(void)
4045 : : {
4046 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
4047 : : }
4048 : :
4049 : : static int
4050 : 0 : test_kasumi_hash_generate_test_case_6(void)
4051 : : {
4052 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
4053 : : }
4054 : :
4055 : : static int
4056 : 0 : test_kasumi_hash_verify_test_case_1(void)
4057 : : {
4058 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
4059 : : }
4060 : :
4061 : : static int
4062 : 0 : test_kasumi_hash_verify_test_case_2(void)
4063 : : {
4064 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
4065 : : }
4066 : :
4067 : : static int
4068 : 0 : test_kasumi_hash_verify_test_case_3(void)
4069 : : {
4070 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
4071 : : }
4072 : :
4073 : : static int
4074 : 0 : test_kasumi_hash_verify_test_case_4(void)
4075 : : {
4076 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
4077 : : }
4078 : :
4079 : : static int
4080 : 0 : test_kasumi_hash_verify_test_case_5(void)
4081 : : {
4082 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
4083 : : }
4084 : :
4085 : : static int
4086 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
4087 : : {
4088 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4089 : : struct crypto_unittest_params *ut_params = &unittest_params;
4090 : :
4091 : : int retval;
4092 : : uint8_t *plaintext, *ciphertext;
4093 : : unsigned plaintext_pad_len;
4094 : : unsigned plaintext_len;
4095 : : struct rte_cryptodev_info dev_info;
4096 : :
4097 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4098 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4099 : :
4100 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4101 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4102 : : printf("Device doesn't support RAW data-path APIs.\n");
4103 : 0 : return TEST_SKIPPED;
4104 : : }
4105 : :
4106 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4107 : : return TEST_SKIPPED;
4108 : :
4109 : : /* Verify the capabilities */
4110 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4111 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4112 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4113 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4114 : : &cap_idx) == NULL)
4115 : : return TEST_SKIPPED;
4116 : :
4117 : : /* Create KASUMI session */
4118 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4119 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4120 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4121 : 0 : tdata->key.data, tdata->key.len,
4122 : 0 : tdata->cipher_iv.len);
4123 [ # # ]: 0 : if (retval < 0)
4124 : : return retval;
4125 : :
4126 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4127 : :
4128 : : /* Clear mbuf payload */
4129 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4130 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4131 : :
4132 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4133 : : /* Append data which is padded to a multiple */
4134 : : /* of the algorithms block size */
4135 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4136 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4137 : : plaintext_pad_len);
4138 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4139 : :
4140 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4141 : :
4142 : : /* Create KASUMI operation */
4143 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4144 : 0 : tdata->cipher_iv.len,
4145 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4146 : 0 : tdata->validCipherOffsetInBits.len);
4147 [ # # ]: 0 : if (retval < 0)
4148 : : return retval;
4149 : :
4150 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4151 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4152 : 0 : tdata->cipher_iv.len);
4153 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4154 : : return retval;
4155 : : } else
4156 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4157 : : ut_params->op);
4158 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4159 : :
4160 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4161 [ # # ]: 0 : if (ut_params->obuf)
4162 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4163 : : else
4164 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4165 : :
4166 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4167 : :
4168 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4169 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4170 : : /* Validate obuf */
4171 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4172 : : ciphertext,
4173 : : reference_ciphertext,
4174 : : tdata->validCipherLenInBits.len,
4175 : : "KASUMI Ciphertext data not as expected");
4176 : : return 0;
4177 : : }
4178 : :
4179 : : static int
4180 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4181 : : {
4182 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4183 : : struct crypto_unittest_params *ut_params = &unittest_params;
4184 : :
4185 : : int retval;
4186 : :
4187 : : unsigned int plaintext_pad_len;
4188 : : unsigned int plaintext_len;
4189 : :
4190 : : uint8_t buffer[10000];
4191 : : const uint8_t *ciphertext;
4192 : :
4193 : : struct rte_cryptodev_info dev_info;
4194 : :
4195 : : /* Verify the capabilities */
4196 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4197 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4198 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4199 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4200 : : &cap_idx) == NULL)
4201 : : return TEST_SKIPPED;
4202 : :
4203 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4204 : :
4205 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4206 : :
4207 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4208 : : printf("Device doesn't support in-place scatter-gather. "
4209 : : "Test Skipped.\n");
4210 : 0 : return TEST_SKIPPED;
4211 : : }
4212 : :
4213 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4214 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4215 : : printf("Device doesn't support RAW data-path APIs.\n");
4216 : 0 : return TEST_SKIPPED;
4217 : : }
4218 : :
4219 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4220 : : return TEST_SKIPPED;
4221 : :
4222 : : /* Create KASUMI session */
4223 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4224 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4225 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4226 : 0 : tdata->key.data, tdata->key.len,
4227 : 0 : tdata->cipher_iv.len);
4228 [ # # ]: 0 : if (retval < 0)
4229 : : return retval;
4230 : :
4231 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4232 : :
4233 : :
4234 : : /* Append data which is padded to a multiple */
4235 : : /* of the algorithms block size */
4236 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4237 : :
4238 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4239 : : plaintext_pad_len, 10, 0);
4240 : :
4241 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4242 : :
4243 : : /* Create KASUMI operation */
4244 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4245 : 0 : tdata->cipher_iv.len,
4246 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4247 : 0 : tdata->validCipherOffsetInBits.len);
4248 [ # # ]: 0 : if (retval < 0)
4249 : : return retval;
4250 : :
4251 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4252 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4253 : 0 : tdata->cipher_iv.len);
4254 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4255 : : return retval;
4256 : : } else
4257 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4258 : : ut_params->op);
4259 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4260 : :
4261 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4262 : :
4263 [ # # ]: 0 : if (ut_params->obuf)
4264 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4265 : : plaintext_len, buffer);
4266 : : else
4267 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4268 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4269 : : plaintext_len, buffer);
4270 : :
4271 : : /* Validate obuf */
4272 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4273 : :
4274 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4275 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4276 : : /* Validate obuf */
4277 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4278 : : ciphertext,
4279 : : reference_ciphertext,
4280 : : tdata->validCipherLenInBits.len,
4281 : : "KASUMI Ciphertext data not as expected");
4282 : : return 0;
4283 : : }
4284 : :
4285 : : static int
4286 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4287 : : {
4288 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4289 : : struct crypto_unittest_params *ut_params = &unittest_params;
4290 : :
4291 : : int retval;
4292 : : uint8_t *plaintext, *ciphertext;
4293 : : unsigned plaintext_pad_len;
4294 : : unsigned plaintext_len;
4295 : :
4296 : : /* Verify the capabilities */
4297 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4298 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4299 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4300 : : /* Data-path service does not support OOP */
4301 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4302 : : &cap_idx) == NULL)
4303 : : return TEST_SKIPPED;
4304 : :
4305 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4306 : : return TEST_SKIPPED;
4307 : :
4308 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4309 : : return TEST_SKIPPED;
4310 : :
4311 : : /* Create KASUMI session */
4312 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4313 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4314 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4315 : 0 : tdata->key.data, tdata->key.len,
4316 : 0 : tdata->cipher_iv.len);
4317 [ # # ]: 0 : if (retval < 0)
4318 : : return retval;
4319 : :
4320 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4321 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4322 : :
4323 : : /* Clear mbuf payload */
4324 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4325 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4326 : :
4327 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4328 : : /* Append data which is padded to a multiple */
4329 : : /* of the algorithms block size */
4330 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4331 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4332 : : plaintext_pad_len);
4333 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4334 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4335 : :
4336 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4337 : :
4338 : : /* Create KASUMI operation */
4339 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4340 : 0 : tdata->cipher_iv.len,
4341 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4342 : 0 : tdata->validCipherOffsetInBits.len);
4343 [ # # ]: 0 : if (retval < 0)
4344 : : return retval;
4345 : :
4346 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4347 : : ut_params->op);
4348 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4349 : :
4350 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4351 [ # # ]: 0 : if (ut_params->obuf)
4352 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4353 : : else
4354 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4355 : :
4356 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4357 : :
4358 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4359 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4360 : : /* Validate obuf */
4361 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4362 : : ciphertext,
4363 : : reference_ciphertext,
4364 : : tdata->validCipherLenInBits.len,
4365 : : "KASUMI Ciphertext data not as expected");
4366 : : return 0;
4367 : : }
4368 : :
4369 : : static int
4370 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4371 : : {
4372 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4373 : : struct crypto_unittest_params *ut_params = &unittest_params;
4374 : :
4375 : : int retval;
4376 : : unsigned int plaintext_pad_len;
4377 : : unsigned int plaintext_len;
4378 : :
4379 : : const uint8_t *ciphertext;
4380 : : uint8_t buffer[2048];
4381 : :
4382 : : struct rte_cryptodev_info dev_info;
4383 : :
4384 : : /* Verify the capabilities */
4385 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4386 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4387 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4388 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4389 : : &cap_idx) == NULL)
4390 : : return TEST_SKIPPED;
4391 : :
4392 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4393 : : return TEST_SKIPPED;
4394 : :
4395 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4396 : : return TEST_SKIPPED;
4397 : :
4398 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4399 : :
4400 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4401 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4402 : : printf("Device doesn't support out-of-place scatter-gather "
4403 : : "in both input and output mbufs. "
4404 : : "Test Skipped.\n");
4405 : 0 : return TEST_SKIPPED;
4406 : : }
4407 : :
4408 : : /* Create KASUMI session */
4409 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4410 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4411 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4412 : 0 : tdata->key.data, tdata->key.len,
4413 : 0 : tdata->cipher_iv.len);
4414 [ # # ]: 0 : if (retval < 0)
4415 : : return retval;
4416 : :
4417 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4418 : : /* Append data which is padded to a multiple */
4419 : : /* of the algorithms block size */
4420 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4421 : :
4422 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4423 : : plaintext_pad_len, 10, 0);
4424 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4425 : : plaintext_pad_len, 3, 0);
4426 : :
4427 : : /* Append data which is padded to a multiple */
4428 : : /* of the algorithms block size */
4429 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4430 : :
4431 : : /* Create KASUMI operation */
4432 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4433 : 0 : tdata->cipher_iv.len,
4434 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4435 : 0 : tdata->validCipherOffsetInBits.len);
4436 [ # # ]: 0 : if (retval < 0)
4437 : : return retval;
4438 : :
4439 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4440 : : ut_params->op);
4441 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4442 : :
4443 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4444 [ # # ]: 0 : if (ut_params->obuf)
4445 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4446 : : plaintext_pad_len, buffer);
4447 : : else
4448 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4449 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4450 : : plaintext_pad_len, buffer);
4451 : :
4452 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4453 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4454 : : /* Validate obuf */
4455 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4456 : : ciphertext,
4457 : : reference_ciphertext,
4458 : : tdata->validCipherLenInBits.len,
4459 : : "KASUMI Ciphertext data not as expected");
4460 : : return 0;
4461 : : }
4462 : :
4463 : :
4464 : : static int
4465 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4466 : : {
4467 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4468 : : struct crypto_unittest_params *ut_params = &unittest_params;
4469 : :
4470 : : int retval;
4471 : : uint8_t *ciphertext, *plaintext;
4472 : : unsigned ciphertext_pad_len;
4473 : : unsigned ciphertext_len;
4474 : :
4475 : : /* Verify the capabilities */
4476 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4477 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4478 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4479 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4480 : : &cap_idx) == NULL)
4481 : : return TEST_SKIPPED;
4482 : :
4483 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4484 : : return TEST_SKIPPED;
4485 : :
4486 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4487 : : return TEST_SKIPPED;
4488 : :
4489 : : /* Create KASUMI session */
4490 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4491 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4492 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4493 : 0 : tdata->key.data, tdata->key.len,
4494 : 0 : tdata->cipher_iv.len);
4495 [ # # ]: 0 : if (retval < 0)
4496 : : return retval;
4497 : :
4498 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4499 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4500 : :
4501 : : /* Clear mbuf payload */
4502 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4503 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4504 : :
4505 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4506 : : /* Append data which is padded to a multiple */
4507 : : /* of the algorithms block size */
4508 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4509 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4510 : : ciphertext_pad_len);
4511 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4512 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4513 : :
4514 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4515 : :
4516 : : /* Create KASUMI operation */
4517 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4518 : 0 : tdata->cipher_iv.len,
4519 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4520 : 0 : tdata->validCipherOffsetInBits.len);
4521 [ # # ]: 0 : if (retval < 0)
4522 : : return retval;
4523 : :
4524 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4525 : : ut_params->op);
4526 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4527 : :
4528 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4529 [ # # ]: 0 : if (ut_params->obuf)
4530 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4531 : : else
4532 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4533 : :
4534 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4535 : :
4536 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4537 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4538 : : /* Validate obuf */
4539 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4540 : : plaintext,
4541 : : reference_plaintext,
4542 : : tdata->validCipherLenInBits.len,
4543 : : "KASUMI Plaintext data not as expected");
4544 : : return 0;
4545 : : }
4546 : :
4547 : : static int
4548 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4549 : : {
4550 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4551 : : struct crypto_unittest_params *ut_params = &unittest_params;
4552 : :
4553 : : int retval;
4554 : : uint8_t *ciphertext, *plaintext;
4555 : : unsigned ciphertext_pad_len;
4556 : : unsigned ciphertext_len;
4557 : : struct rte_cryptodev_info dev_info;
4558 : :
4559 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4560 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4561 : :
4562 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4563 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4564 : : printf("Device doesn't support RAW data-path APIs.\n");
4565 : 0 : return TEST_SKIPPED;
4566 : : }
4567 : :
4568 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4569 : : return TEST_SKIPPED;
4570 : :
4571 : : /* Verify the capabilities */
4572 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4573 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4574 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4575 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4576 : : &cap_idx) == NULL)
4577 : : return TEST_SKIPPED;
4578 : :
4579 : : /* Create KASUMI session */
4580 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4581 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4582 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4583 : 0 : tdata->key.data, tdata->key.len,
4584 : 0 : tdata->cipher_iv.len);
4585 [ # # ]: 0 : if (retval < 0)
4586 : : return retval;
4587 : :
4588 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4589 : :
4590 : : /* Clear mbuf payload */
4591 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4592 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4593 : :
4594 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4595 : : /* Append data which is padded to a multiple */
4596 : : /* of the algorithms block size */
4597 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4598 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4599 : : ciphertext_pad_len);
4600 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4601 : :
4602 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4603 : :
4604 : : /* Create KASUMI operation */
4605 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4606 : 0 : tdata->cipher_iv.len,
4607 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4608 : 0 : tdata->validCipherOffsetInBits.len);
4609 [ # # ]: 0 : if (retval < 0)
4610 : : return retval;
4611 : :
4612 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4613 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4614 : : 0);
4615 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4616 : : return retval;
4617 : : } else
4618 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4619 : : ut_params->op);
4620 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4621 : :
4622 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4623 [ # # ]: 0 : if (ut_params->obuf)
4624 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4625 : : else
4626 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4627 : :
4628 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4629 : :
4630 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4631 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4632 : : /* Validate obuf */
4633 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4634 : : plaintext,
4635 : : reference_plaintext,
4636 : : tdata->validCipherLenInBits.len,
4637 : : "KASUMI Plaintext data not as expected");
4638 : : return 0;
4639 : : }
4640 : :
4641 : : static int
4642 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4643 : : {
4644 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4645 : : struct crypto_unittest_params *ut_params = &unittest_params;
4646 : :
4647 : : int retval;
4648 : : uint8_t *plaintext, *ciphertext;
4649 : : unsigned plaintext_pad_len;
4650 : : unsigned plaintext_len;
4651 : : struct rte_cryptodev_info dev_info;
4652 : :
4653 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4654 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4655 : :
4656 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4657 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4658 : : printf("Device doesn't support RAW data-path APIs.\n");
4659 : 0 : return TEST_SKIPPED;
4660 : : }
4661 : :
4662 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4663 : : return TEST_SKIPPED;
4664 : :
4665 : : /* Verify the capabilities */
4666 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4667 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4668 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4669 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4670 : : &cap_idx) == NULL)
4671 : : return TEST_SKIPPED;
4672 : :
4673 : : /* Create SNOW 3G session */
4674 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4675 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4676 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4677 : 0 : tdata->key.data, tdata->key.len,
4678 : 0 : tdata->cipher_iv.len);
4679 [ # # ]: 0 : if (retval < 0)
4680 : : return retval;
4681 : :
4682 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4683 : :
4684 : : /* Clear mbuf payload */
4685 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4686 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4687 : :
4688 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4689 : : /* Append data which is padded to a multiple of */
4690 : : /* the algorithms block size */
4691 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4692 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4693 : : plaintext_pad_len);
4694 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4695 : :
4696 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4697 : :
4698 : : /* Create SNOW 3G operation */
4699 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4700 : 0 : tdata->cipher_iv.len,
4701 : 0 : tdata->validCipherLenInBits.len,
4702 : : 0);
4703 [ # # ]: 0 : if (retval < 0)
4704 : : return retval;
4705 : :
4706 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4707 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4708 : 0 : tdata->cipher_iv.len);
4709 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4710 : : return retval;
4711 : : } else
4712 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4713 : : ut_params->op);
4714 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4715 : :
4716 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4717 [ # # ]: 0 : if (ut_params->obuf)
4718 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4719 : : else
4720 : : ciphertext = plaintext;
4721 : :
4722 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4723 : :
4724 : : /* Validate obuf */
4725 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4726 : : ciphertext,
4727 : : tdata->ciphertext.data,
4728 : : tdata->validDataLenInBits.len,
4729 : : "SNOW 3G Ciphertext data not as expected");
4730 : : return 0;
4731 : : }
4732 : :
4733 : :
4734 : : static int
4735 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4736 : : {
4737 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4738 : : struct crypto_unittest_params *ut_params = &unittest_params;
4739 : : uint8_t *plaintext, *ciphertext;
4740 : :
4741 : : int retval;
4742 : : unsigned plaintext_pad_len;
4743 : : unsigned plaintext_len;
4744 : : struct rte_cryptodev_info dev_info;
4745 : :
4746 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4747 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4748 : :
4749 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4750 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4751 : : printf("Device does not support RAW data-path APIs.\n");
4752 : 0 : return -ENOTSUP;
4753 : : }
4754 : :
4755 : : /* Verify the capabilities */
4756 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4757 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4758 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4759 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4760 : : &cap_idx) == NULL)
4761 : : return TEST_SKIPPED;
4762 : :
4763 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4764 : : return TEST_SKIPPED;
4765 : :
4766 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4767 : : return TEST_SKIPPED;
4768 : :
4769 : : /* Create SNOW 3G session */
4770 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4771 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4772 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4773 : 0 : tdata->key.data, tdata->key.len,
4774 : 0 : tdata->cipher_iv.len);
4775 [ # # ]: 0 : if (retval < 0)
4776 : : return retval;
4777 : :
4778 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4779 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4780 : :
4781 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4782 : : "Failed to allocate input buffer in mempool");
4783 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4784 : : "Failed to allocate output buffer in mempool");
4785 : :
4786 : : /* Clear mbuf payload */
4787 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4788 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4789 : :
4790 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4791 : : /* Append data which is padded to a multiple of */
4792 : : /* the algorithms block size */
4793 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4794 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4795 : : plaintext_pad_len);
4796 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4797 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4798 : :
4799 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4800 : :
4801 : : /* Create SNOW 3G operation */
4802 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4803 : 0 : tdata->cipher_iv.len,
4804 : 0 : tdata->validCipherLenInBits.len,
4805 : : 0);
4806 [ # # ]: 0 : if (retval < 0)
4807 : : return retval;
4808 : :
4809 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4810 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4811 : 0 : tdata->cipher_iv.len);
4812 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4813 : : return retval;
4814 : : } else
4815 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4816 : : ut_params->op);
4817 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4818 : :
4819 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4820 [ # # ]: 0 : if (ut_params->obuf)
4821 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4822 : : else
4823 : : ciphertext = plaintext;
4824 : :
4825 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4826 : :
4827 : : /* Validate obuf */
4828 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4829 : : ciphertext,
4830 : : tdata->ciphertext.data,
4831 : : tdata->validDataLenInBits.len,
4832 : : "SNOW 3G Ciphertext data not as expected");
4833 : : return 0;
4834 : : }
4835 : :
4836 : : static int
4837 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4838 : : uint8_t sgl_in, uint8_t sgl_out)
4839 : : {
4840 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4841 : : struct crypto_unittest_params *ut_params = &unittest_params;
4842 : :
4843 : : int retval;
4844 : : unsigned int plaintext_pad_len;
4845 : : unsigned int plaintext_len;
4846 : : uint8_t buffer[10000];
4847 : : const uint8_t *ciphertext;
4848 : :
4849 : : struct rte_cryptodev_info dev_info;
4850 : :
4851 : : /* Verify the capabilities */
4852 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4853 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4854 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4855 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4856 : : &cap_idx) == NULL)
4857 : : return TEST_SKIPPED;
4858 : :
4859 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4860 : : return TEST_SKIPPED;
4861 : :
4862 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4863 : : return TEST_SKIPPED;
4864 : :
4865 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4866 : :
4867 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4868 : :
4869 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4870 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4871 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4872 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4873 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4874 : : printf("Device doesn't support out-of-place scatter gather type. "
4875 : : "Test Skipped.\n");
4876 : 0 : return TEST_SKIPPED;
4877 : : }
4878 : :
4879 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4880 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4881 : : printf("Device does not support RAW data-path APIs.\n");
4882 : 0 : return -ENOTSUP;
4883 : : }
4884 : :
4885 : : /* Create SNOW 3G session */
4886 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4887 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4888 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4889 : 0 : tdata->key.data, tdata->key.len,
4890 : 0 : tdata->cipher_iv.len);
4891 [ # # ]: 0 : if (retval < 0)
4892 : : return retval;
4893 : :
4894 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4895 : : /* Append data which is padded to a multiple of */
4896 : : /* the algorithms block size */
4897 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4898 : :
4899 [ # # ]: 0 : if (sgl_in)
4900 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4901 : : plaintext_pad_len, 10, 0);
4902 : : else {
4903 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4904 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4905 : : }
4906 : :
4907 [ # # ]: 0 : if (sgl_out)
4908 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4909 : : plaintext_pad_len, 3, 0);
4910 : : else {
4911 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4912 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4913 : : }
4914 : :
4915 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4916 : : "Failed to allocate input buffer in mempool");
4917 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4918 : : "Failed to allocate output buffer in mempool");
4919 : :
4920 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4921 : :
4922 : : /* Create SNOW 3G operation */
4923 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4924 : 0 : tdata->cipher_iv.len,
4925 : 0 : tdata->validCipherLenInBits.len,
4926 : : 0);
4927 [ # # ]: 0 : if (retval < 0)
4928 : : return retval;
4929 : :
4930 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4931 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4932 : 0 : tdata->cipher_iv.len);
4933 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4934 : : return retval;
4935 : : } else
4936 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4937 : : ut_params->op);
4938 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4939 : :
4940 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4941 [ # # ]: 0 : if (ut_params->obuf)
4942 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4943 : : plaintext_len, buffer);
4944 : : else
4945 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4946 : : plaintext_len, buffer);
4947 : :
4948 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4949 : :
4950 : : /* Validate obuf */
4951 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4952 : : ciphertext,
4953 : : tdata->ciphertext.data,
4954 : : tdata->validDataLenInBits.len,
4955 : : "SNOW 3G Ciphertext data not as expected");
4956 : :
4957 : : return 0;
4958 : : }
4959 : :
4960 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4961 : : static void
4962 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4963 : : {
4964 : : uint8_t curr_byte, prev_byte;
4965 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4966 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4967 : : unsigned i;
4968 : :
4969 : 0 : prev_byte = buffer[0];
4970 : 0 : buffer[0] >>= offset;
4971 : :
4972 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4973 : 0 : curr_byte = buffer[i];
4974 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4975 : 0 : (curr_byte >> offset);
4976 : : prev_byte = curr_byte;
4977 : : }
4978 : 0 : }
4979 : :
4980 : : static int
4981 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4982 : : {
4983 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4984 : : struct crypto_unittest_params *ut_params = &unittest_params;
4985 : : uint8_t *plaintext, *ciphertext;
4986 : : int retval;
4987 : : uint32_t plaintext_len;
4988 : : uint32_t plaintext_pad_len;
4989 : : uint8_t extra_offset = 4;
4990 : : uint8_t *expected_ciphertext_shifted;
4991 : : struct rte_cryptodev_info dev_info;
4992 : :
4993 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4994 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4995 : :
4996 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4997 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4998 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4999 : 0 : return TEST_SKIPPED;
5000 : : }
5001 : :
5002 : : /* Verify the capabilities */
5003 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5004 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5005 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5006 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5007 : : &cap_idx) == NULL)
5008 : : return TEST_SKIPPED;
5009 : :
5010 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5011 : : return TEST_SKIPPED;
5012 : :
5013 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5014 : : return TEST_SKIPPED;
5015 : :
5016 : : /* Create SNOW 3G session */
5017 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5018 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5019 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5020 : 0 : tdata->key.data, tdata->key.len,
5021 : 0 : tdata->cipher_iv.len);
5022 [ # # ]: 0 : if (retval < 0)
5023 : : return retval;
5024 : :
5025 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5026 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5027 : :
5028 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5029 : : "Failed to allocate input buffer in mempool");
5030 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5031 : : "Failed to allocate output buffer in mempool");
5032 : :
5033 : : /* Clear mbuf payload */
5034 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5035 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5036 : :
5037 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
5038 : : /*
5039 : : * Append data which is padded to a
5040 : : * multiple of the algorithms block size
5041 : : */
5042 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5043 : :
5044 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
5045 : : plaintext_pad_len);
5046 : :
5047 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5048 : :
5049 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
5050 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
5051 : :
5052 : : #ifdef RTE_APP_TEST_DEBUG
5053 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
5054 : : #endif
5055 : : /* Create SNOW 3G operation */
5056 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5057 : 0 : tdata->cipher_iv.len,
5058 : 0 : tdata->validCipherLenInBits.len,
5059 : : extra_offset);
5060 [ # # ]: 0 : if (retval < 0)
5061 : : return retval;
5062 : :
5063 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5064 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5065 : 0 : tdata->cipher_iv.len);
5066 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5067 : : return retval;
5068 : : } else
5069 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5070 : : ut_params->op);
5071 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5072 : :
5073 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5074 [ # # ]: 0 : if (ut_params->obuf)
5075 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5076 : : else
5077 : : ciphertext = plaintext;
5078 : :
5079 : : #ifdef RTE_APP_TEST_DEBUG
5080 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5081 : : #endif
5082 : :
5083 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
5084 : :
5085 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
5086 : : "failed to reserve memory for ciphertext shifted\n");
5087 : :
5088 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
5089 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
5090 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
5091 : : extra_offset);
5092 : : /* Validate obuf */
5093 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5094 : : ciphertext,
5095 : : expected_ciphertext_shifted,
5096 : : tdata->validDataLenInBits.len,
5097 : : extra_offset,
5098 : : "SNOW 3G Ciphertext data not as expected");
5099 : : return 0;
5100 : : }
5101 : :
5102 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
5103 : : {
5104 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5105 : : struct crypto_unittest_params *ut_params = &unittest_params;
5106 : :
5107 : : int retval;
5108 : :
5109 : : uint8_t *plaintext, *ciphertext;
5110 : : unsigned ciphertext_pad_len;
5111 : : unsigned ciphertext_len;
5112 : : struct rte_cryptodev_info dev_info;
5113 : :
5114 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5115 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5116 : :
5117 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5118 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5119 : : printf("Device doesn't support RAW data-path APIs.\n");
5120 : 0 : return TEST_SKIPPED;
5121 : : }
5122 : :
5123 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5124 : : return TEST_SKIPPED;
5125 : :
5126 : : /* Verify the capabilities */
5127 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5128 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5129 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5130 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5131 : : &cap_idx) == NULL)
5132 : : return TEST_SKIPPED;
5133 : :
5134 : : /* Create SNOW 3G session */
5135 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5136 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5137 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5138 : 0 : tdata->key.data, tdata->key.len,
5139 : 0 : tdata->cipher_iv.len);
5140 [ # # ]: 0 : if (retval < 0)
5141 : : return retval;
5142 : :
5143 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5144 : :
5145 : : /* Clear mbuf payload */
5146 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5147 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5148 : :
5149 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5150 : : /* Append data which is padded to a multiple of */
5151 : : /* the algorithms block size */
5152 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5153 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5154 : : ciphertext_pad_len);
5155 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5156 : :
5157 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5158 : :
5159 : : /* Create SNOW 3G operation */
5160 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5161 : 0 : tdata->cipher_iv.len,
5162 : 0 : tdata->validCipherLenInBits.len,
5163 : 0 : tdata->cipher.offset_bits);
5164 [ # # ]: 0 : if (retval < 0)
5165 : : return retval;
5166 : :
5167 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5168 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5169 : 0 : tdata->cipher_iv.len);
5170 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5171 : : return retval;
5172 : : } else
5173 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5174 : : ut_params->op);
5175 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5176 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5177 [ # # ]: 0 : if (ut_params->obuf)
5178 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5179 : : else
5180 : : plaintext = ciphertext;
5181 : :
5182 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5183 : :
5184 : : /* Validate obuf */
5185 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5186 : : tdata->plaintext.data,
5187 : : tdata->validDataLenInBits.len,
5188 : : "SNOW 3G Plaintext data not as expected");
5189 : : return 0;
5190 : : }
5191 : :
5192 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5193 : : {
5194 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5195 : : struct crypto_unittest_params *ut_params = &unittest_params;
5196 : :
5197 : : int retval;
5198 : :
5199 : : uint8_t *plaintext, *ciphertext;
5200 : : unsigned ciphertext_pad_len;
5201 : : unsigned ciphertext_len;
5202 : : struct rte_cryptodev_info dev_info;
5203 : :
5204 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5205 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5206 : :
5207 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5208 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5209 : : printf("Device does not support RAW data-path APIs.\n");
5210 : 0 : return -ENOTSUP;
5211 : : }
5212 : : /* Verify the capabilities */
5213 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5214 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5215 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5216 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5217 : : &cap_idx) == NULL)
5218 : : return TEST_SKIPPED;
5219 : :
5220 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5221 : : return TEST_SKIPPED;
5222 : :
5223 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5224 : : return TEST_SKIPPED;
5225 : :
5226 : : /* Create SNOW 3G session */
5227 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5228 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
5229 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5230 : 0 : tdata->key.data, tdata->key.len,
5231 : 0 : tdata->cipher_iv.len);
5232 [ # # ]: 0 : if (retval < 0)
5233 : : return retval;
5234 : :
5235 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5236 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5237 : :
5238 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5239 : : "Failed to allocate input buffer");
5240 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5241 : : "Failed to allocate output buffer");
5242 : :
5243 : : /* Clear mbuf payload */
5244 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5245 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5246 : :
5247 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5248 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5249 : :
5250 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5251 : : /* Append data which is padded to a multiple of */
5252 : : /* the algorithms block size */
5253 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5254 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5255 : : ciphertext_pad_len);
5256 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5257 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5258 : :
5259 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5260 : :
5261 : : /* Create SNOW 3G operation */
5262 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5263 : 0 : tdata->cipher_iv.len,
5264 : 0 : tdata->validCipherLenInBits.len,
5265 : : 0);
5266 [ # # ]: 0 : if (retval < 0)
5267 : : return retval;
5268 : :
5269 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5270 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5271 : 0 : tdata->cipher_iv.len);
5272 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5273 : : return retval;
5274 : : } else
5275 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5276 : : ut_params->op);
5277 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5278 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5279 [ # # ]: 0 : if (ut_params->obuf)
5280 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5281 : : else
5282 : : plaintext = ciphertext;
5283 : :
5284 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5285 : :
5286 : : /* Validate obuf */
5287 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5288 : : tdata->plaintext.data,
5289 : : tdata->validDataLenInBits.len,
5290 : : "SNOW 3G Plaintext data not as expected");
5291 : : return 0;
5292 : : }
5293 : :
5294 : : static int
5295 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5296 : : {
5297 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5298 : : struct crypto_unittest_params *ut_params = &unittest_params;
5299 : :
5300 : : int retval;
5301 : :
5302 : : uint8_t *plaintext, *ciphertext;
5303 : : unsigned int plaintext_pad_len;
5304 : : unsigned int plaintext_len;
5305 : :
5306 : : struct rte_cryptodev_info dev_info;
5307 : :
5308 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5309 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5310 : :
5311 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5312 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
5313 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
5314 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
5315 : 0 : return TEST_SKIPPED;
5316 : : }
5317 : :
5318 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5319 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5320 : : printf("Device doesn't support RAW data-path APIs.\n");
5321 : 0 : return TEST_SKIPPED;
5322 : : }
5323 : :
5324 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5325 : : return TEST_SKIPPED;
5326 : :
5327 : : /* Check if device supports ZUC EEA3 */
5328 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5329 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
5330 : : return TEST_SKIPPED;
5331 : :
5332 : : /* Check if device supports ZUC EIA3 */
5333 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5334 : 0 : tdata->key.len, tdata->auth_iv.len,
5335 : 0 : tdata->digest.len) < 0)
5336 : : return TEST_SKIPPED;
5337 : :
5338 : : /* Create ZUC session */
5339 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
5340 : 0 : ts_params->valid_devs[0],
5341 : : tdata);
5342 [ # # ]: 0 : if (retval != 0)
5343 : : return retval;
5344 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5345 : :
5346 : : /* clear mbuf payload */
5347 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5348 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5349 : :
5350 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5351 : : /* Append data which is padded to a multiple of */
5352 : : /* the algorithms block size */
5353 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5354 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5355 : : plaintext_pad_len);
5356 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5357 : :
5358 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5359 : :
5360 : : /* Create ZUC operation */
5361 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
5362 [ # # ]: 0 : if (retval < 0)
5363 : : return retval;
5364 : :
5365 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5366 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5367 : 0 : tdata->cipher_iv.len);
5368 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5369 : : return retval;
5370 : : } else
5371 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5372 : : ut_params->op);
5373 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5374 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5375 [ # # ]: 0 : if (ut_params->obuf)
5376 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5377 : : else
5378 : : ciphertext = plaintext;
5379 : :
5380 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5381 : : /* Validate obuf */
5382 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5383 : : ciphertext,
5384 : : tdata->ciphertext.data,
5385 : : tdata->validDataLenInBits.len,
5386 : : "ZUC Ciphertext data not as expected");
5387 : :
5388 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5389 : : uint8_t *,
5390 : : plaintext_pad_len);
5391 : :
5392 : : /* Validate obuf */
5393 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5394 : : ut_params->digest,
5395 : : tdata->digest.data,
5396 : : tdata->digest.len,
5397 : : "ZUC Generated auth tag not as expected");
5398 : : return 0;
5399 : : }
5400 : :
5401 : : static int
5402 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5403 : : {
5404 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5405 : : struct crypto_unittest_params *ut_params = &unittest_params;
5406 : :
5407 : : int retval;
5408 : :
5409 : : uint8_t *plaintext, *ciphertext;
5410 : : unsigned plaintext_pad_len;
5411 : : unsigned plaintext_len;
5412 : : struct rte_cryptodev_info dev_info;
5413 : :
5414 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5415 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5416 : :
5417 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5418 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5419 : : printf("Device doesn't support RAW data-path APIs.\n");
5420 : 0 : return TEST_SKIPPED;
5421 : : }
5422 : :
5423 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5424 : : return TEST_SKIPPED;
5425 : :
5426 : : /* Verify the capabilities */
5427 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5428 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5429 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5430 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5431 : : &cap_idx) == NULL)
5432 : : return TEST_SKIPPED;
5433 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5434 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5435 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5436 : : &cap_idx) == NULL)
5437 : : return TEST_SKIPPED;
5438 : :
5439 : : /* Create SNOW 3G session */
5440 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5441 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5442 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5443 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5444 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5445 : : tdata->key.data, tdata->key.len,
5446 : 0 : tdata->key.data, tdata->key.len,
5447 : 0 : tdata->auth_iv.len, tdata->digest.len,
5448 : 0 : tdata->cipher_iv.len);
5449 [ # # ]: 0 : if (retval != 0)
5450 : : return retval;
5451 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5452 : :
5453 : : /* clear mbuf payload */
5454 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5455 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5456 : :
5457 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5458 : : /* Append data which is padded to a multiple of */
5459 : : /* the algorithms block size */
5460 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5461 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5462 : : plaintext_pad_len);
5463 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5464 : :
5465 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5466 : :
5467 : : /* Create SNOW 3G operation */
5468 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5469 : 0 : tdata->digest.len, tdata->auth_iv.data,
5470 : 0 : tdata->auth_iv.len,
5471 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5472 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5473 : 0 : tdata->validCipherLenInBits.len,
5474 : : 0,
5475 : 0 : tdata->validAuthLenInBits.len,
5476 : : 0
5477 : : );
5478 [ # # ]: 0 : if (retval < 0)
5479 : : return retval;
5480 : :
5481 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5482 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5483 : 0 : tdata->cipher_iv.len);
5484 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5485 : : return retval;
5486 : : } else
5487 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5488 : : ut_params->op);
5489 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5490 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5491 [ # # ]: 0 : if (ut_params->obuf)
5492 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5493 : : else
5494 : : ciphertext = plaintext;
5495 : :
5496 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5497 : : /* Validate obuf */
5498 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5499 : : ciphertext,
5500 : : tdata->ciphertext.data,
5501 : : tdata->validDataLenInBits.len,
5502 : : "SNOW 3G Ciphertext data not as expected");
5503 : :
5504 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5505 : : uint8_t *,
5506 : : plaintext_pad_len);
5507 : :
5508 : : /* Validate obuf */
5509 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5510 : : ut_params->digest,
5511 : : tdata->digest.data,
5512 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5513 : : "SNOW 3G Generated auth tag not as expected");
5514 : : return 0;
5515 : : }
5516 : :
5517 : : static int
5518 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5519 : : uint8_t op_mode, uint8_t verify)
5520 : : {
5521 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5522 : : struct crypto_unittest_params *ut_params = &unittest_params;
5523 : :
5524 : : int retval;
5525 : :
5526 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5527 : : unsigned int plaintext_pad_len;
5528 : : unsigned int plaintext_len;
5529 : : unsigned int ciphertext_pad_len;
5530 : : unsigned int ciphertext_len;
5531 : : unsigned int digest_offset;
5532 : :
5533 : : struct rte_cryptodev_info dev_info;
5534 : :
5535 : : /* Verify the capabilities */
5536 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5537 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5538 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5539 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5540 : : &cap_idx) == NULL)
5541 : : return TEST_SKIPPED;
5542 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5543 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5544 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5545 : : &cap_idx) == NULL)
5546 : : return TEST_SKIPPED;
5547 : :
5548 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5549 : : return TEST_SKIPPED;
5550 : :
5551 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5552 : :
5553 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5554 : :
5555 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5556 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5557 : : printf("Device doesn't support digest encrypted.\n");
5558 : 0 : return TEST_SKIPPED;
5559 : : }
5560 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5561 : : return TEST_SKIPPED;
5562 : : }
5563 : :
5564 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5565 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5566 : : printf("Device doesn't support RAW data-path APIs.\n");
5567 : 0 : return TEST_SKIPPED;
5568 : : }
5569 : :
5570 : : /* Create SNOW 3G session */
5571 : 0 : retval = create_wireless_algo_auth_cipher_session(
5572 : 0 : ts_params->valid_devs[0],
5573 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5574 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5575 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5576 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5577 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5578 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5579 : : tdata->key.data, tdata->key.len,
5580 : 0 : tdata->key.data, tdata->key.len,
5581 : 0 : tdata->auth_iv.len, tdata->digest.len,
5582 : 0 : tdata->cipher_iv.len);
5583 [ # # ]: 0 : if (retval != 0)
5584 : : return retval;
5585 : :
5586 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5587 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5588 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5589 : :
5590 : : /* clear mbuf payload */
5591 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5592 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5593 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5594 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5595 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5596 : :
5597 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5598 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5599 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5600 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5601 : :
5602 [ # # ]: 0 : if (verify) {
5603 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5604 : : ciphertext_pad_len);
5605 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5606 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5607 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5608 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5609 : : ciphertext_len);
5610 : : } else {
5611 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5612 : : plaintext_pad_len);
5613 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5614 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5615 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5616 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5617 : : }
5618 : :
5619 : : /* Create SNOW 3G operation */
5620 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5621 : 0 : tdata->digest.data, tdata->digest.len,
5622 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5623 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5624 : 0 : (tdata->digest.offset_bytes == 0 ?
5625 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5626 : : : tdata->digest.offset_bytes),
5627 : 0 : tdata->validCipherLenInBits.len,
5628 : 0 : tdata->cipher.offset_bits,
5629 : 0 : tdata->validAuthLenInBits.len,
5630 [ # # ]: 0 : tdata->auth.offset_bits,
5631 : : op_mode, 0, verify);
5632 : :
5633 [ # # ]: 0 : if (retval < 0)
5634 : : return retval;
5635 : :
5636 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5637 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5638 : 0 : tdata->cipher_iv.len);
5639 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5640 : : return retval;
5641 : : } else
5642 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5643 : : ut_params->op);
5644 : :
5645 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5646 : :
5647 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5648 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5649 : :
5650 [ # # ]: 0 : if (verify) {
5651 [ # # ]: 0 : if (ut_params->obuf)
5652 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5653 : : uint8_t *);
5654 : : else
5655 : 0 : plaintext = ciphertext +
5656 : 0 : (tdata->cipher.offset_bits >> 3);
5657 : :
5658 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5659 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5660 : 0 : debug_hexdump(stdout, "plaintext expected:",
5661 : 0 : tdata->plaintext.data,
5662 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5663 : : } else {
5664 [ # # ]: 0 : if (ut_params->obuf)
5665 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5666 : : uint8_t *);
5667 : : else
5668 : : ciphertext = plaintext;
5669 : :
5670 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5671 : : ciphertext_len);
5672 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5673 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5674 : :
5675 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5676 : : digest_offset = plaintext_pad_len;
5677 : : else
5678 : : digest_offset = tdata->digest.offset_bytes;
5679 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5680 : : uint8_t *, digest_offset);
5681 : :
5682 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5683 : 0 : tdata->digest.len);
5684 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5685 : 0 : tdata->digest.len);
5686 : : }
5687 : :
5688 : : /* Validate obuf */
5689 [ # # ]: 0 : if (verify) {
5690 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5691 : : plaintext,
5692 : : tdata->plaintext.data,
5693 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5694 : : (tdata->digest.len << 3)),
5695 : : tdata->cipher.offset_bits,
5696 : : "SNOW 3G Plaintext data not as expected");
5697 : : } else {
5698 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5699 : : ciphertext,
5700 : : tdata->ciphertext.data,
5701 : : (tdata->validDataLenInBits.len -
5702 : : tdata->cipher.offset_bits),
5703 : : tdata->cipher.offset_bits,
5704 : : "SNOW 3G Ciphertext data not as expected");
5705 : :
5706 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5707 : : ut_params->digest,
5708 : : tdata->digest.data,
5709 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5710 : : "SNOW 3G Generated auth tag not as expected");
5711 : : }
5712 : : return 0;
5713 : : }
5714 : :
5715 : : static int
5716 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5717 : : uint8_t op_mode, uint8_t verify)
5718 : : {
5719 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5720 : : struct crypto_unittest_params *ut_params = &unittest_params;
5721 : :
5722 : : int retval;
5723 : :
5724 : : const uint8_t *plaintext = NULL;
5725 : : const uint8_t *ciphertext = NULL;
5726 : : const uint8_t *digest = NULL;
5727 : : unsigned int plaintext_pad_len;
5728 : : unsigned int plaintext_len;
5729 : : unsigned int ciphertext_pad_len;
5730 : : unsigned int ciphertext_len;
5731 : : uint8_t buffer[10000];
5732 : : uint8_t digest_buffer[10000];
5733 : :
5734 : : struct rte_cryptodev_info dev_info;
5735 : :
5736 : : /* Verify the capabilities */
5737 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5738 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5739 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5740 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5741 : : &cap_idx) == NULL)
5742 : : return TEST_SKIPPED;
5743 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5744 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5745 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5746 : : &cap_idx) == NULL)
5747 : : return TEST_SKIPPED;
5748 : :
5749 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5750 : : return TEST_SKIPPED;
5751 : :
5752 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5753 : :
5754 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5755 : :
5756 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5757 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5758 : : printf("Device doesn't support in-place scatter-gather "
5759 : : "in both input and output mbufs.\n");
5760 : 0 : return TEST_SKIPPED;
5761 : : }
5762 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5763 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5764 : : printf("Device doesn't support RAW data-path APIs.\n");
5765 : 0 : return TEST_SKIPPED;
5766 : : }
5767 : : } else {
5768 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5769 : : return TEST_SKIPPED;
5770 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5771 : : printf("Device doesn't support out-of-place scatter-gather "
5772 : : "in both input and output mbufs.\n");
5773 : 0 : return TEST_SKIPPED;
5774 : : }
5775 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5776 : : printf("Device doesn't support digest encrypted.\n");
5777 : 0 : return TEST_SKIPPED;
5778 : : }
5779 : : }
5780 : :
5781 : : /* Create SNOW 3G session */
5782 : 0 : retval = create_wireless_algo_auth_cipher_session(
5783 : 0 : ts_params->valid_devs[0],
5784 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5785 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5786 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5787 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5788 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5789 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5790 : : tdata->key.data, tdata->key.len,
5791 : 0 : tdata->key.data, tdata->key.len,
5792 : 0 : tdata->auth_iv.len, tdata->digest.len,
5793 : 0 : tdata->cipher_iv.len);
5794 : :
5795 [ # # ]: 0 : if (retval != 0)
5796 : : return retval;
5797 : :
5798 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5799 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5800 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5801 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5802 : :
5803 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5804 : : plaintext_pad_len, 15, 0);
5805 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5806 : : "Failed to allocate input buffer in mempool");
5807 : :
5808 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5809 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5810 : : plaintext_pad_len, 15, 0);
5811 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5812 : : "Failed to allocate output buffer in mempool");
5813 : : }
5814 : :
5815 [ # # ]: 0 : if (verify) {
5816 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5817 : 0 : tdata->ciphertext.data);
5818 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5819 : : ciphertext_len, buffer);
5820 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5821 : : ciphertext_len);
5822 : : } else {
5823 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5824 : 0 : tdata->plaintext.data);
5825 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5826 : : plaintext_len, buffer);
5827 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5828 : : plaintext_len);
5829 : : }
5830 : : memset(buffer, 0, sizeof(buffer));
5831 : :
5832 : : /* Create SNOW 3G operation */
5833 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5834 : 0 : tdata->digest.data, tdata->digest.len,
5835 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5836 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5837 : 0 : (tdata->digest.offset_bytes == 0 ?
5838 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5839 : : : tdata->digest.offset_bytes),
5840 : 0 : tdata->validCipherLenInBits.len,
5841 : 0 : tdata->cipher.offset_bits,
5842 : 0 : tdata->validAuthLenInBits.len,
5843 [ # # ]: 0 : tdata->auth.offset_bits,
5844 : : op_mode, 1, verify);
5845 : :
5846 [ # # ]: 0 : if (retval < 0)
5847 : : return retval;
5848 : :
5849 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5850 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5851 : 0 : tdata->cipher_iv.len);
5852 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5853 : : return retval;
5854 : : } else
5855 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5856 : : ut_params->op);
5857 : :
5858 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5859 : :
5860 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5861 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5862 : :
5863 [ # # ]: 0 : if (verify) {
5864 [ # # ]: 0 : if (ut_params->obuf)
5865 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5866 : : plaintext_len, buffer);
5867 : : else
5868 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5869 : : plaintext_len, buffer);
5870 : :
5871 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5872 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5873 : 0 : debug_hexdump(stdout, "plaintext expected:",
5874 : 0 : tdata->plaintext.data,
5875 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5876 : : } else {
5877 [ # # ]: 0 : if (ut_params->obuf)
5878 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5879 : : ciphertext_len, buffer);
5880 : : else
5881 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5882 : : ciphertext_len, buffer);
5883 : :
5884 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5885 : : ciphertext_len);
5886 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5887 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5888 : :
5889 [ # # ]: 0 : if (ut_params->obuf)
5890 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5891 : 0 : (tdata->digest.offset_bytes == 0 ?
5892 : : plaintext_pad_len : tdata->digest.offset_bytes),
5893 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5894 : : else
5895 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5896 : 0 : (tdata->digest.offset_bytes == 0 ?
5897 : : plaintext_pad_len : tdata->digest.offset_bytes),
5898 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5899 : :
5900 : 0 : debug_hexdump(stdout, "digest:", digest,
5901 : 0 : tdata->digest.len);
5902 : 0 : debug_hexdump(stdout, "digest expected:",
5903 : 0 : tdata->digest.data, tdata->digest.len);
5904 : : }
5905 : :
5906 : : /* Validate obuf */
5907 [ # # ]: 0 : if (verify) {
5908 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5909 : : plaintext,
5910 : : tdata->plaintext.data,
5911 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5912 : : (tdata->digest.len << 3)),
5913 : : tdata->cipher.offset_bits,
5914 : : "SNOW 3G Plaintext data not as expected");
5915 : : } else {
5916 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5917 : : ciphertext,
5918 : : tdata->ciphertext.data,
5919 : : (tdata->validDataLenInBits.len -
5920 : : tdata->cipher.offset_bits),
5921 : : tdata->cipher.offset_bits,
5922 : : "SNOW 3G Ciphertext data not as expected");
5923 : :
5924 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5925 : : digest,
5926 : : tdata->digest.data,
5927 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5928 : : "SNOW 3G Generated auth tag not as expected");
5929 : : }
5930 : : return 0;
5931 : : }
5932 : :
5933 : : static int
5934 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5935 : : uint8_t op_mode, uint8_t verify)
5936 : : {
5937 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5938 : : struct crypto_unittest_params *ut_params = &unittest_params;
5939 : :
5940 : : int retval;
5941 : :
5942 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5943 : : unsigned int plaintext_pad_len;
5944 : : unsigned int plaintext_len;
5945 : : unsigned int ciphertext_pad_len;
5946 : : unsigned int ciphertext_len;
5947 : : unsigned int digest_offset;
5948 : :
5949 : : struct rte_cryptodev_info dev_info;
5950 : :
5951 : : /* Verify the capabilities */
5952 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5953 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5954 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5955 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5956 : : &cap_idx) == NULL)
5957 : : return TEST_SKIPPED;
5958 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5959 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5960 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5961 : : &cap_idx) == NULL)
5962 : : return TEST_SKIPPED;
5963 : :
5964 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5965 : :
5966 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5967 : :
5968 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5969 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5970 : : printf("Device doesn't support RAW data-path APIs.\n");
5971 : 0 : return TEST_SKIPPED;
5972 : : }
5973 : :
5974 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5975 : : return TEST_SKIPPED;
5976 : :
5977 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5978 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5979 : : return TEST_SKIPPED;
5980 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5981 : : printf("Device doesn't support digest encrypted.\n");
5982 : 0 : return TEST_SKIPPED;
5983 : : }
5984 : : }
5985 : :
5986 : : /* Create KASUMI session */
5987 : 0 : retval = create_wireless_algo_auth_cipher_session(
5988 : 0 : ts_params->valid_devs[0],
5989 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5990 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5991 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5992 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5993 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5994 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5995 : : tdata->key.data, tdata->key.len,
5996 : 0 : tdata->key.data, tdata->key.len,
5997 : 0 : 0, tdata->digest.len,
5998 : 0 : tdata->cipher_iv.len);
5999 : :
6000 [ # # ]: 0 : if (retval != 0)
6001 : : return retval;
6002 : :
6003 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6004 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6005 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6006 : :
6007 : : /* clear mbuf payload */
6008 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6009 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6010 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6011 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6012 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6013 : :
6014 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6015 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6016 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6017 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6018 : :
6019 [ # # ]: 0 : if (verify) {
6020 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6021 : : ciphertext_pad_len);
6022 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6023 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6024 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6025 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6026 : : ciphertext_len);
6027 : : } else {
6028 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6029 : : plaintext_pad_len);
6030 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6031 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6032 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6033 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6034 : : plaintext_len);
6035 : : }
6036 : :
6037 : : /* Create KASUMI operation */
6038 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6039 : 0 : tdata->digest.data, tdata->digest.len,
6040 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6041 : : NULL, 0,
6042 : 0 : (tdata->digest.offset_bytes == 0 ?
6043 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6044 : : : tdata->digest.offset_bytes),
6045 : 0 : tdata->validCipherLenInBits.len,
6046 : 0 : tdata->validCipherOffsetInBits.len,
6047 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6048 : : 0,
6049 : : op_mode, 0, verify);
6050 : :
6051 [ # # ]: 0 : if (retval < 0)
6052 : : return retval;
6053 : :
6054 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6055 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6056 : 0 : tdata->cipher_iv.len);
6057 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6058 : : return retval;
6059 : : } else
6060 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6061 : : ut_params->op);
6062 : :
6063 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6064 : :
6065 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6066 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6067 : :
6068 : :
6069 [ # # ]: 0 : if (verify) {
6070 [ # # ]: 0 : if (ut_params->obuf)
6071 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6072 : : uint8_t *);
6073 : : else
6074 : : plaintext = ciphertext;
6075 : :
6076 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6077 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6078 : 0 : debug_hexdump(stdout, "plaintext expected:",
6079 : 0 : tdata->plaintext.data,
6080 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6081 : : } else {
6082 [ # # ]: 0 : if (ut_params->obuf)
6083 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6084 : : uint8_t *);
6085 : : else
6086 : : ciphertext = plaintext;
6087 : :
6088 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6089 : : ciphertext_len);
6090 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6091 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6092 : :
6093 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6094 : : digest_offset = plaintext_pad_len;
6095 : : else
6096 : : digest_offset = tdata->digest.offset_bytes;
6097 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6098 : : uint8_t *, digest_offset);
6099 : :
6100 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6101 : 0 : tdata->digest.len);
6102 : 0 : debug_hexdump(stdout, "digest expected:",
6103 : 0 : tdata->digest.data, tdata->digest.len);
6104 : : }
6105 : :
6106 : : /* Validate obuf */
6107 [ # # ]: 0 : if (verify) {
6108 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6109 : : plaintext,
6110 : : tdata->plaintext.data,
6111 : : tdata->plaintext.len >> 3,
6112 : : "KASUMI Plaintext data not as expected");
6113 : : } else {
6114 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6115 : : ciphertext,
6116 : : tdata->ciphertext.data,
6117 : : tdata->ciphertext.len >> 3,
6118 : : "KASUMI Ciphertext data not as expected");
6119 : :
6120 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6121 : : ut_params->digest,
6122 : : tdata->digest.data,
6123 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6124 : : "KASUMI Generated auth tag not as expected");
6125 : : }
6126 : : return 0;
6127 : : }
6128 : :
6129 : : static int
6130 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6131 : : uint8_t op_mode, uint8_t verify)
6132 : : {
6133 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6134 : : struct crypto_unittest_params *ut_params = &unittest_params;
6135 : :
6136 : : int retval;
6137 : :
6138 : : const uint8_t *plaintext = NULL;
6139 : : const uint8_t *ciphertext = NULL;
6140 : : const uint8_t *digest = NULL;
6141 : : unsigned int plaintext_pad_len;
6142 : : unsigned int plaintext_len;
6143 : : unsigned int ciphertext_pad_len;
6144 : : unsigned int ciphertext_len;
6145 : : uint8_t buffer[10000];
6146 : : uint8_t digest_buffer[10000];
6147 : :
6148 : : struct rte_cryptodev_info dev_info;
6149 : :
6150 : : /* Verify the capabilities */
6151 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6152 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6153 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6154 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6155 : : &cap_idx) == NULL)
6156 : : return TEST_SKIPPED;
6157 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6158 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6159 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6160 : : &cap_idx) == NULL)
6161 : : return TEST_SKIPPED;
6162 : :
6163 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6164 : : return TEST_SKIPPED;
6165 : :
6166 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6167 : :
6168 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6169 : :
6170 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6171 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6172 : : printf("Device doesn't support in-place scatter-gather "
6173 : : "in both input and output mbufs.\n");
6174 : 0 : return TEST_SKIPPED;
6175 : : }
6176 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6177 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6178 : : printf("Device doesn't support RAW data-path APIs.\n");
6179 : 0 : return TEST_SKIPPED;
6180 : : }
6181 : : } else {
6182 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6183 : : return TEST_SKIPPED;
6184 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6185 : : printf("Device doesn't support out-of-place scatter-gather "
6186 : : "in both input and output mbufs.\n");
6187 : 0 : return TEST_SKIPPED;
6188 : : }
6189 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6190 : : printf("Device doesn't support digest encrypted.\n");
6191 : 0 : return TEST_SKIPPED;
6192 : : }
6193 : : }
6194 : :
6195 : : /* Create KASUMI session */
6196 : 0 : retval = create_wireless_algo_auth_cipher_session(
6197 : 0 : ts_params->valid_devs[0],
6198 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6199 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6200 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6201 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6202 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6203 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6204 : : tdata->key.data, tdata->key.len,
6205 : 0 : tdata->key.data, tdata->key.len,
6206 : 0 : 0, tdata->digest.len,
6207 : 0 : tdata->cipher_iv.len);
6208 : :
6209 [ # # ]: 0 : if (retval != 0)
6210 : : return retval;
6211 : :
6212 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6213 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6214 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6215 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6216 : :
6217 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6218 : : plaintext_pad_len, 15, 0);
6219 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6220 : : "Failed to allocate input buffer in mempool");
6221 : :
6222 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6223 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6224 : : plaintext_pad_len, 15, 0);
6225 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6226 : : "Failed to allocate output buffer in mempool");
6227 : : }
6228 : :
6229 [ # # ]: 0 : if (verify) {
6230 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6231 : 0 : tdata->ciphertext.data);
6232 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6233 : : ciphertext_len, buffer);
6234 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6235 : : ciphertext_len);
6236 : : } else {
6237 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6238 : 0 : tdata->plaintext.data);
6239 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6240 : : plaintext_len, buffer);
6241 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6242 : : plaintext_len);
6243 : : }
6244 : : memset(buffer, 0, sizeof(buffer));
6245 : :
6246 : : /* Create KASUMI operation */
6247 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6248 : 0 : tdata->digest.data, tdata->digest.len,
6249 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6250 : : NULL, 0,
6251 : 0 : (tdata->digest.offset_bytes == 0 ?
6252 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6253 : : : tdata->digest.offset_bytes),
6254 : 0 : tdata->validCipherLenInBits.len,
6255 : 0 : tdata->validCipherOffsetInBits.len,
6256 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6257 : : 0,
6258 : : op_mode, 1, verify);
6259 : :
6260 [ # # ]: 0 : if (retval < 0)
6261 : : return retval;
6262 : :
6263 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6264 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6265 : 0 : tdata->cipher_iv.len);
6266 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6267 : : return retval;
6268 : : } else
6269 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6270 : : ut_params->op);
6271 : :
6272 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6273 : :
6274 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6275 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6276 : :
6277 [ # # ]: 0 : if (verify) {
6278 [ # # ]: 0 : if (ut_params->obuf)
6279 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6280 : : plaintext_len, buffer);
6281 : : else
6282 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6283 : : plaintext_len, buffer);
6284 : :
6285 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6286 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6287 : 0 : debug_hexdump(stdout, "plaintext expected:",
6288 : 0 : tdata->plaintext.data,
6289 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6290 : : } else {
6291 [ # # ]: 0 : if (ut_params->obuf)
6292 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6293 : : ciphertext_len, buffer);
6294 : : else
6295 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6296 : : ciphertext_len, buffer);
6297 : :
6298 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6299 : : ciphertext_len);
6300 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6301 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6302 : :
6303 [ # # ]: 0 : if (ut_params->obuf)
6304 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6305 : 0 : (tdata->digest.offset_bytes == 0 ?
6306 : : plaintext_pad_len : tdata->digest.offset_bytes),
6307 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6308 : : else
6309 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6310 : 0 : (tdata->digest.offset_bytes == 0 ?
6311 : : plaintext_pad_len : tdata->digest.offset_bytes),
6312 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6313 : :
6314 : 0 : debug_hexdump(stdout, "digest:", digest,
6315 : 0 : tdata->digest.len);
6316 : 0 : debug_hexdump(stdout, "digest expected:",
6317 : 0 : tdata->digest.data, tdata->digest.len);
6318 : : }
6319 : :
6320 : : /* Validate obuf */
6321 [ # # ]: 0 : if (verify) {
6322 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6323 : : plaintext,
6324 : : tdata->plaintext.data,
6325 : : tdata->plaintext.len >> 3,
6326 : : "KASUMI Plaintext data not as expected");
6327 : : } else {
6328 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6329 : : ciphertext,
6330 : : tdata->ciphertext.data,
6331 : : tdata->validDataLenInBits.len,
6332 : : "KASUMI Ciphertext data not as expected");
6333 : :
6334 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6335 : : digest,
6336 : : tdata->digest.data,
6337 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6338 : : "KASUMI Generated auth tag not as expected");
6339 : : }
6340 : : return 0;
6341 : : }
6342 : :
6343 : : static int
6344 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6345 : : {
6346 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6347 : : struct crypto_unittest_params *ut_params = &unittest_params;
6348 : :
6349 : : int retval;
6350 : :
6351 : : uint8_t *plaintext, *ciphertext;
6352 : : unsigned plaintext_pad_len;
6353 : : unsigned plaintext_len;
6354 : : struct rte_cryptodev_info dev_info;
6355 : :
6356 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6357 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6358 : :
6359 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6360 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6361 : : printf("Device doesn't support RAW data-path APIs.\n");
6362 : 0 : return TEST_SKIPPED;
6363 : : }
6364 : :
6365 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6366 : : return TEST_SKIPPED;
6367 : :
6368 : : /* Verify the capabilities */
6369 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6370 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6371 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6372 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6373 : : &cap_idx) == NULL)
6374 : : return TEST_SKIPPED;
6375 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6376 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6377 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6378 : : &cap_idx) == NULL)
6379 : : return TEST_SKIPPED;
6380 : :
6381 : : /* Create KASUMI session */
6382 : 0 : retval = create_wireless_algo_cipher_auth_session(
6383 : 0 : ts_params->valid_devs[0],
6384 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6385 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6386 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6387 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6388 : : tdata->key.data, tdata->key.len,
6389 : 0 : tdata->key.data, tdata->key.len,
6390 : 0 : 0, tdata->digest.len,
6391 : 0 : tdata->cipher_iv.len);
6392 [ # # ]: 0 : if (retval != 0)
6393 : : return retval;
6394 : :
6395 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6396 : :
6397 : : /* clear mbuf payload */
6398 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6399 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6400 : :
6401 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6402 : : /* Append data which is padded to a multiple of */
6403 : : /* the algorithms block size */
6404 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6405 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6406 : : plaintext_pad_len);
6407 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6408 : :
6409 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6410 : :
6411 : : /* Create KASUMI operation */
6412 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6413 : 0 : tdata->digest.len, NULL, 0,
6414 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6415 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6416 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6417 : 0 : tdata->validCipherOffsetInBits.len,
6418 : 0 : tdata->validAuthLenInBits.len,
6419 : : 0
6420 : : );
6421 [ # # ]: 0 : if (retval < 0)
6422 : : return retval;
6423 : :
6424 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6425 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6426 : 0 : tdata->cipher_iv.len);
6427 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6428 : : return retval;
6429 : : } else
6430 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6431 : : ut_params->op);
6432 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6433 : :
6434 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6435 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6436 : : else
6437 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6438 : :
6439 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6440 : : tdata->validCipherOffsetInBits.len >> 3);
6441 : :
6442 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6443 : : uint8_t *,
6444 : : plaintext_pad_len);
6445 : :
6446 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6447 : : (tdata->validCipherOffsetInBits.len >> 3);
6448 : : /* Validate obuf */
6449 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6450 : : ciphertext,
6451 : : reference_ciphertext,
6452 : : tdata->validCipherLenInBits.len,
6453 : : "KASUMI Ciphertext data not as expected");
6454 : :
6455 : : /* Validate obuf */
6456 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6457 : : ut_params->digest,
6458 : : tdata->digest.data,
6459 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6460 : : "KASUMI Generated auth tag not as expected");
6461 : : return 0;
6462 : : }
6463 : :
6464 : : static int
6465 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6466 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6467 : : const uint16_t key_size, const uint16_t iv_size)
6468 : : {
6469 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6470 : : const struct rte_cryptodev_symmetric_capability *cap;
6471 : :
6472 : : /* Check if device supports the algorithm */
6473 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6474 : 0 : cap_idx.algo.cipher = cipher_algo;
6475 : :
6476 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6477 : : &cap_idx);
6478 : :
6479 [ # # ]: 0 : if (cap == NULL)
6480 : : return -1;
6481 : :
6482 : : /* Check if device supports key size and IV size */
6483 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6484 : : iv_size) < 0) {
6485 : 0 : return -1;
6486 : : }
6487 : :
6488 : : return 0;
6489 : : }
6490 : :
6491 : : static int
6492 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6493 : : const enum rte_crypto_auth_algorithm auth_algo,
6494 : : const uint16_t key_size, const uint16_t iv_size,
6495 : : const uint16_t tag_size)
6496 : : {
6497 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6498 : : const struct rte_cryptodev_symmetric_capability *cap;
6499 : :
6500 : : /* Check if device supports the algorithm */
6501 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6502 : 0 : cap_idx.algo.auth = auth_algo;
6503 : :
6504 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6505 : : &cap_idx);
6506 : :
6507 [ # # ]: 0 : if (cap == NULL)
6508 : : return -1;
6509 : :
6510 : : /* Check if device supports key size and IV size */
6511 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6512 : : tag_size, iv_size) < 0) {
6513 : 0 : return -1;
6514 : : }
6515 : :
6516 : : return 0;
6517 : : }
6518 : :
6519 : : static int
6520 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6521 : : enum rte_crypto_cipher_operation direction)
6522 : : {
6523 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6524 : : struct crypto_unittest_params *ut_params = &unittest_params;
6525 : :
6526 : : int retval;
6527 : : uint8_t *plaintext = NULL;
6528 : : uint8_t *ciphertext = NULL;
6529 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6530 : : unsigned int plaintext_len = 0;
6531 : : unsigned int ciphertext_len = 0;
6532 : : struct rte_cryptodev_info dev_info;
6533 : :
6534 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6535 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6536 : :
6537 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6538 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6539 : : printf("Device doesn't support RAW data-path APIs.\n");
6540 : 0 : return TEST_SKIPPED;
6541 : : }
6542 : :
6543 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6544 : : return TEST_SKIPPED;
6545 : :
6546 : : /* Check if device supports ZUC EEA3 */
6547 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6548 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6549 : : return TEST_SKIPPED;
6550 : :
6551 : : /* Create ZUC session */
6552 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6553 : : direction,
6554 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6555 : 0 : tdata->key.data, tdata->key.len,
6556 : 0 : tdata->cipher_iv.len);
6557 [ # # ]: 0 : if (retval != 0)
6558 : : return retval;
6559 : :
6560 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6561 : :
6562 : : /* Clear mbuf payload */
6563 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6564 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6565 : :
6566 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6567 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6568 : : /* Append data which is padded to a multiple */
6569 : : /* of the algorithms block size */
6570 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6571 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6572 : : plaintext_pad_len);
6573 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6574 : :
6575 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6576 : : } else {
6577 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6578 : : /* Append data which is padded to a multiple */
6579 : : /* of the algorithms block size */
6580 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6581 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6582 : : ciphertext_pad_len);
6583 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6584 : :
6585 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6586 : : }
6587 : :
6588 : : /* Create ZUC operation */
6589 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6590 : 0 : tdata->cipher_iv.len,
6591 : 0 : tdata->plaintext.len,
6592 : 0 : tdata->validCipherOffsetInBits.len);
6593 [ # # ]: 0 : if (retval < 0)
6594 : : return retval;
6595 : :
6596 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6597 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6598 : 0 : tdata->cipher_iv.len);
6599 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6600 : : return retval;
6601 : : } else
6602 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6603 : : ut_params->op);
6604 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6605 : :
6606 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6607 : :
6608 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6609 [ # # ]: 0 : if (ut_params->obuf)
6610 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6611 : : else
6612 : : ciphertext = plaintext;
6613 : :
6614 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6615 : :
6616 : : /* Validate obuf */
6617 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6618 : : ciphertext,
6619 : : tdata->ciphertext.data,
6620 : : tdata->validCipherLenInBits.len,
6621 : : "ZUC Ciphertext data not as expected");
6622 : : } else {
6623 [ # # ]: 0 : if (ut_params->obuf)
6624 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6625 : : else
6626 : : plaintext = ciphertext;
6627 : :
6628 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6629 : :
6630 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6631 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6632 : :
6633 : : /* Validate obuf */
6634 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6635 : : plaintext,
6636 : : reference_plaintext,
6637 : : tdata->validCipherLenInBits.len,
6638 : : "ZUC Plaintext data not as expected");
6639 : : }
6640 : :
6641 : : return 0;
6642 : : }
6643 : :
6644 : : static int
6645 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6646 : : enum rte_crypto_cipher_operation direction)
6647 : : {
6648 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6649 : : struct crypto_unittest_params *ut_params = &unittest_params;
6650 : :
6651 : : int retval;
6652 : :
6653 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6654 : : unsigned int plaintext_len = 0;
6655 : : unsigned int ciphertext_len = 0;
6656 : : const uint8_t *ciphertext, *plaintext;
6657 : : uint8_t buffer[2048];
6658 : : struct rte_cryptodev_info dev_info;
6659 : :
6660 : : /* Check if device supports ZUC EEA3 */
6661 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6662 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6663 : : return TEST_SKIPPED;
6664 : :
6665 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6666 : : return TEST_SKIPPED;
6667 : :
6668 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6669 : :
6670 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6671 : :
6672 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6673 : : printf("Device doesn't support in-place scatter-gather. "
6674 : : "Test Skipped.\n");
6675 : 0 : return TEST_SKIPPED;
6676 : : }
6677 : :
6678 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6679 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6680 : : printf("Device doesn't support RAW data-path APIs.\n");
6681 : 0 : return TEST_SKIPPED;
6682 : : }
6683 : :
6684 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6685 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6686 : :
6687 : : /* Append data which is padded to a multiple */
6688 : : /* of the algorithms block size */
6689 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6690 : :
6691 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6692 : : plaintext_pad_len, 10, 0);
6693 : :
6694 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6695 : 0 : tdata->plaintext.data);
6696 : : } else {
6697 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6698 : :
6699 : : /* Append data which is padded to a multiple */
6700 : : /* of the algorithms block size */
6701 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6702 : :
6703 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6704 : : ciphertext_pad_len, 10, 0);
6705 : :
6706 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6707 : 0 : tdata->ciphertext.data);
6708 : :
6709 : : }
6710 : :
6711 : : /* Create ZUC session */
6712 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6713 : : direction,
6714 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6715 : 0 : tdata->key.data, tdata->key.len,
6716 : 0 : tdata->cipher_iv.len);
6717 [ # # ]: 0 : if (retval < 0)
6718 : : return retval;
6719 : :
6720 : : /* Clear mbuf payload */
6721 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6722 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6723 : : else
6724 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6725 : :
6726 : : /* Create ZUC operation */
6727 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6728 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6729 : 0 : tdata->validCipherOffsetInBits.len);
6730 [ # # ]: 0 : if (retval < 0)
6731 : : return retval;
6732 : :
6733 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6734 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6735 : 0 : tdata->cipher_iv.len);
6736 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6737 : : return retval;
6738 : : } else
6739 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6740 : : ut_params->op);
6741 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6742 : :
6743 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6744 : :
6745 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6746 [ # # ]: 0 : if (ut_params->obuf)
6747 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6748 : : 0, plaintext_len, buffer);
6749 : : else
6750 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6751 : : 0, plaintext_len, buffer);
6752 : :
6753 : : /* Validate obuf */
6754 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6755 : :
6756 : : /* Validate obuf */
6757 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6758 : : ciphertext,
6759 : : tdata->ciphertext.data,
6760 : : tdata->validCipherLenInBits.len,
6761 : : "ZUC Ciphertext data not as expected");
6762 : : } else {
6763 [ # # ]: 0 : if (ut_params->obuf)
6764 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6765 : : 0, ciphertext_len, buffer);
6766 : : else
6767 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6768 : : 0, ciphertext_len, buffer);
6769 : :
6770 : : /* Validate obuf */
6771 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6772 : :
6773 : : /* Validate obuf */
6774 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6775 : : plaintext,
6776 : : tdata->plaintext.data,
6777 : : tdata->validCipherLenInBits.len,
6778 : : "ZUC Plaintext data not as expected");
6779 : : }
6780 : :
6781 : : return 0;
6782 : : }
6783 : :
6784 : : static int
6785 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6786 : : enum rte_crypto_auth_operation auth_op)
6787 : : {
6788 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6789 : : struct crypto_unittest_params *ut_params = &unittest_params;
6790 : :
6791 : : int retval;
6792 : : unsigned plaintext_pad_len;
6793 : : unsigned plaintext_len;
6794 : : uint8_t *plaintext;
6795 : :
6796 : : struct rte_cryptodev_info dev_info;
6797 : :
6798 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6799 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6800 : :
6801 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6802 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6803 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6804 : 0 : return TEST_SKIPPED;
6805 : : }
6806 : :
6807 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6808 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6809 : : printf("Device doesn't support RAW data-path APIs.\n");
6810 : 0 : return TEST_SKIPPED;
6811 : : }
6812 : :
6813 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6814 : : return TEST_SKIPPED;
6815 : :
6816 : : /* Check if device supports ZUC EIA3 */
6817 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6818 : 0 : tdata->key.len, tdata->auth_iv.len,
6819 : 0 : tdata->digest.len) < 0)
6820 : : return TEST_SKIPPED;
6821 : :
6822 : : /* Create ZUC session */
6823 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6824 : 0 : tdata->key.data, tdata->key.len,
6825 : 0 : tdata->auth_iv.len, tdata->digest.len,
6826 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6827 [ # # ]: 0 : if (retval != 0)
6828 : : return retval;
6829 : :
6830 : : /* alloc mbuf and set payload */
6831 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6832 : :
6833 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6834 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6835 : :
6836 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6837 : : /* Append data which is padded to a multiple of */
6838 : : /* the algorithms block size */
6839 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6840 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6841 : : plaintext_pad_len);
6842 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6843 : :
6844 : : /* Create ZUC operation */
6845 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6846 : 0 : tdata->digest.len,
6847 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6848 : : plaintext_pad_len,
6849 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6850 [ # # ]: 0 : if (retval < 0)
6851 : : return retval;
6852 : :
6853 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6854 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6855 : : 0);
6856 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6857 : : return retval;
6858 : : } else
6859 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6860 : : ut_params->op);
6861 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6862 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6863 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6864 : : uint8_t *,
6865 : : plaintext_pad_len);
6866 : :
6867 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6868 : : /* Validate obuf */
6869 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6870 : : ut_params->digest,
6871 : : tdata->digest.data,
6872 : : tdata->digest.len,
6873 : : "ZUC Generated auth tag not as expected");
6874 : : return 0;
6875 : : }
6876 : :
6877 : : /* Validate obuf */
6878 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6879 : : return 0;
6880 : : else
6881 : 0 : return -1;
6882 : :
6883 : : return 0;
6884 : : }
6885 : :
6886 : : static int
6887 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6888 : : uint8_t op_mode, uint8_t verify)
6889 : : {
6890 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6891 : : struct crypto_unittest_params *ut_params = &unittest_params;
6892 : :
6893 : : int retval;
6894 : :
6895 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6896 : : unsigned int plaintext_pad_len;
6897 : : unsigned int plaintext_len;
6898 : : unsigned int ciphertext_pad_len;
6899 : : unsigned int ciphertext_len;
6900 : : unsigned int digest_offset;
6901 : :
6902 : : struct rte_cryptodev_info dev_info;
6903 : :
6904 : : /* Check if device supports ZUC EEA3 */
6905 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6906 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6907 : : return TEST_SKIPPED;
6908 : :
6909 : : /* Check if device supports ZUC EIA3 */
6910 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6911 : 0 : tdata->key.len, tdata->auth_iv.len,
6912 : 0 : tdata->digest.len) < 0)
6913 : : return TEST_SKIPPED;
6914 : :
6915 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6916 : : return TEST_SKIPPED;
6917 : :
6918 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6919 : :
6920 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6921 : :
6922 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6923 : : printf("Device doesn't support digest encrypted.\n");
6924 : 0 : return TEST_SKIPPED;
6925 : : }
6926 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6927 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6928 : : printf("Device doesn't support in-place scatter-gather "
6929 : : "in both input and output mbufs.\n");
6930 : 0 : return TEST_SKIPPED;
6931 : : }
6932 : :
6933 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6934 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6935 : : printf("Device doesn't support RAW data-path APIs.\n");
6936 : 0 : return TEST_SKIPPED;
6937 : : }
6938 : : } else {
6939 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6940 : : return TEST_SKIPPED;
6941 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6942 : : printf("Device doesn't support out-of-place scatter-gather "
6943 : : "in both input and output mbufs.\n");
6944 : 0 : return TEST_SKIPPED;
6945 : : }
6946 : : }
6947 : :
6948 : : /* Create ZUC session */
6949 : 0 : retval = create_wireless_algo_auth_cipher_session(
6950 : 0 : ts_params->valid_devs[0],
6951 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6952 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6953 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6954 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6955 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6956 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6957 : : tdata->key.data, tdata->key.len,
6958 : 0 : tdata->key.data, tdata->key.len,
6959 : 0 : tdata->auth_iv.len, tdata->digest.len,
6960 : 0 : tdata->cipher_iv.len);
6961 : :
6962 [ # # ]: 0 : if (retval != 0)
6963 : : return retval;
6964 : :
6965 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6966 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6967 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6968 : :
6969 : : /* clear mbuf payload */
6970 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6971 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6972 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6973 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6974 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6975 : :
6976 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6977 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6978 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6979 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6980 : :
6981 [ # # ]: 0 : if (verify) {
6982 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6983 : : ciphertext_pad_len);
6984 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6985 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6986 : : ciphertext_len);
6987 : : } else {
6988 : : /* make sure enough space to cover partial digest verify case */
6989 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6990 : : ciphertext_pad_len);
6991 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6992 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6993 : : plaintext_len);
6994 : : }
6995 : :
6996 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6997 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6998 : :
6999 : : /* Create ZUC operation */
7000 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7001 : 0 : tdata->digest.data, tdata->digest.len,
7002 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7003 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7004 : 0 : (tdata->digest.offset_bytes == 0 ?
7005 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7006 : : : tdata->digest.offset_bytes),
7007 : 0 : tdata->validCipherLenInBits.len,
7008 : 0 : tdata->validCipherOffsetInBits.len,
7009 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7010 : : 0,
7011 : : op_mode, 0, verify);
7012 : :
7013 [ # # ]: 0 : if (retval < 0)
7014 : : return retval;
7015 : :
7016 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7017 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7018 : 0 : tdata->cipher_iv.len);
7019 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7020 : : return retval;
7021 : : } else
7022 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7023 : : ut_params->op);
7024 : :
7025 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7026 : :
7027 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7028 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7029 : :
7030 : :
7031 [ # # ]: 0 : if (verify) {
7032 [ # # ]: 0 : if (ut_params->obuf)
7033 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7034 : : uint8_t *);
7035 : : else
7036 : : plaintext = ciphertext;
7037 : :
7038 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7039 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7040 : 0 : debug_hexdump(stdout, "plaintext expected:",
7041 : 0 : tdata->plaintext.data,
7042 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7043 : : } else {
7044 [ # # ]: 0 : if (ut_params->obuf)
7045 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7046 : : uint8_t *);
7047 : : else
7048 : : ciphertext = plaintext;
7049 : :
7050 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7051 : : ciphertext_len);
7052 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7053 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7054 : :
7055 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
7056 : : digest_offset = plaintext_pad_len;
7057 : : else
7058 : : digest_offset = tdata->digest.offset_bytes;
7059 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
7060 : : uint8_t *, digest_offset);
7061 : :
7062 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
7063 : 0 : tdata->digest.len);
7064 : 0 : debug_hexdump(stdout, "digest expected:",
7065 : 0 : tdata->digest.data, tdata->digest.len);
7066 : : }
7067 : :
7068 : : /* Validate obuf */
7069 [ # # ]: 0 : if (verify) {
7070 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7071 : : plaintext,
7072 : : tdata->plaintext.data,
7073 : : tdata->plaintext.len >> 3,
7074 : : "ZUC Plaintext data not as expected");
7075 : : } else {
7076 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7077 : : ciphertext,
7078 : : tdata->ciphertext.data,
7079 : : tdata->ciphertext.len >> 3,
7080 : : "ZUC Ciphertext data not as expected");
7081 : :
7082 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7083 : : ut_params->digest,
7084 : : tdata->digest.data,
7085 : : tdata->digest.len,
7086 : : "ZUC Generated auth tag not as expected");
7087 : : }
7088 : : return 0;
7089 : : }
7090 : :
7091 : : static int
7092 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
7093 : : uint8_t op_mode, uint8_t verify)
7094 : : {
7095 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7096 : : struct crypto_unittest_params *ut_params = &unittest_params;
7097 : :
7098 : : int retval;
7099 : :
7100 : : const uint8_t *plaintext = NULL;
7101 : : const uint8_t *ciphertext = NULL;
7102 : : const uint8_t *digest = NULL;
7103 : : unsigned int plaintext_pad_len;
7104 : : unsigned int plaintext_len;
7105 : : unsigned int ciphertext_pad_len;
7106 : : unsigned int ciphertext_len;
7107 : : uint8_t buffer[10000];
7108 : : uint8_t digest_buffer[10000];
7109 : :
7110 : : struct rte_cryptodev_info dev_info;
7111 : :
7112 : : /* Check if device supports ZUC EEA3 */
7113 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
7114 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
7115 : : return TEST_SKIPPED;
7116 : :
7117 : : /* Check if device supports ZUC EIA3 */
7118 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
7119 : 0 : tdata->key.len, tdata->auth_iv.len,
7120 : 0 : tdata->digest.len) < 0)
7121 : : return TEST_SKIPPED;
7122 : :
7123 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7124 : : return TEST_SKIPPED;
7125 : :
7126 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7127 : :
7128 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7129 : :
7130 [ # # ]: 0 : if (op_mode == IN_PLACE) {
7131 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7132 : : printf("Device doesn't support in-place scatter-gather "
7133 : : "in both input and output mbufs.\n");
7134 : 0 : return TEST_SKIPPED;
7135 : : }
7136 : :
7137 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7138 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7139 : : printf("Device doesn't support RAW data-path APIs.\n");
7140 : 0 : return TEST_SKIPPED;
7141 : : }
7142 : : } else {
7143 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7144 : : return TEST_SKIPPED;
7145 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7146 : : printf("Device doesn't support out-of-place scatter-gather "
7147 : : "in both input and output mbufs.\n");
7148 : 0 : return TEST_SKIPPED;
7149 : : }
7150 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7151 : : printf("Device doesn't support digest encrypted.\n");
7152 : 0 : return TEST_SKIPPED;
7153 : : }
7154 : : }
7155 : :
7156 : : /* Create ZUC session */
7157 : 0 : retval = create_wireless_algo_auth_cipher_session(
7158 : 0 : ts_params->valid_devs[0],
7159 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7160 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7161 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7162 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
7163 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
7164 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
7165 : : tdata->key.data, tdata->key.len,
7166 : 0 : tdata->key.data, tdata->key.len,
7167 : 0 : tdata->auth_iv.len, tdata->digest.len,
7168 : 0 : tdata->cipher_iv.len);
7169 : :
7170 [ # # ]: 0 : if (retval != 0)
7171 : : return retval;
7172 : :
7173 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7174 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
7175 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7176 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7177 : :
7178 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7179 : : plaintext_pad_len, 15, 0);
7180 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7181 : : "Failed to allocate input buffer in mempool");
7182 : :
7183 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
7184 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7185 : : plaintext_pad_len, 15, 0);
7186 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
7187 : : "Failed to allocate output buffer in mempool");
7188 : : }
7189 : :
7190 [ # # ]: 0 : if (verify) {
7191 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7192 : 0 : tdata->ciphertext.data);
7193 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7194 : : ciphertext_len, buffer);
7195 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7196 : : ciphertext_len);
7197 : : } else {
7198 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7199 : 0 : tdata->plaintext.data);
7200 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7201 : : plaintext_len, buffer);
7202 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7203 : : plaintext_len);
7204 : : }
7205 : : memset(buffer, 0, sizeof(buffer));
7206 : :
7207 : : /* Create ZUC operation */
7208 : 0 : retval = create_wireless_algo_auth_cipher_operation(
7209 : 0 : tdata->digest.data, tdata->digest.len,
7210 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
7211 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
7212 : 0 : (tdata->digest.offset_bytes == 0 ?
7213 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
7214 : : : tdata->digest.offset_bytes),
7215 : 0 : tdata->validCipherLenInBits.len,
7216 : 0 : tdata->validCipherOffsetInBits.len,
7217 [ # # ]: 0 : tdata->validAuthLenInBits.len,
7218 : : 0,
7219 : : op_mode, 1, verify);
7220 : :
7221 [ # # ]: 0 : if (retval < 0)
7222 : : return retval;
7223 : :
7224 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7225 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7226 : 0 : tdata->cipher_iv.len);
7227 [ # # ]: 0 : if (retval != TEST_SUCCESS)
7228 : : return retval;
7229 : : } else
7230 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7231 : : ut_params->op);
7232 : :
7233 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7234 : :
7235 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
7236 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7237 : :
7238 [ # # ]: 0 : if (verify) {
7239 [ # # ]: 0 : if (ut_params->obuf)
7240 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7241 : : plaintext_len, buffer);
7242 : : else
7243 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7244 : : plaintext_len, buffer);
7245 : :
7246 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7247 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7248 : 0 : debug_hexdump(stdout, "plaintext expected:",
7249 : 0 : tdata->plaintext.data,
7250 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7251 : : } else {
7252 [ # # ]: 0 : if (ut_params->obuf)
7253 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7254 : : ciphertext_len, buffer);
7255 : : else
7256 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7257 : : ciphertext_len, buffer);
7258 : :
7259 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7260 : : ciphertext_len);
7261 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7262 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7263 : :
7264 [ # # ]: 0 : if (ut_params->obuf)
7265 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
7266 : 0 : (tdata->digest.offset_bytes == 0 ?
7267 : : plaintext_pad_len : tdata->digest.offset_bytes),
7268 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7269 : : else
7270 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
7271 : 0 : (tdata->digest.offset_bytes == 0 ?
7272 : : plaintext_pad_len : tdata->digest.offset_bytes),
7273 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7274 : :
7275 : 0 : debug_hexdump(stdout, "digest:", digest,
7276 : 0 : tdata->digest.len);
7277 : 0 : debug_hexdump(stdout, "digest expected:",
7278 : 0 : tdata->digest.data, tdata->digest.len);
7279 : : }
7280 : :
7281 : : /* Validate obuf */
7282 [ # # ]: 0 : if (verify) {
7283 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7284 : : plaintext,
7285 : : tdata->plaintext.data,
7286 : : tdata->plaintext.len >> 3,
7287 : : "ZUC Plaintext data not as expected");
7288 : : } else {
7289 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7290 : : ciphertext,
7291 : : tdata->ciphertext.data,
7292 : : tdata->validDataLenInBits.len,
7293 : : "ZUC Ciphertext data not as expected");
7294 : :
7295 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7296 : : digest,
7297 : : tdata->digest.data,
7298 : : tdata->digest.len,
7299 : : "ZUC Generated auth tag not as expected");
7300 : : }
7301 : : return 0;
7302 : : }
7303 : :
7304 : : static int
7305 : 0 : test_kasumi_encryption_test_case_1(void)
7306 : : {
7307 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
7308 : : }
7309 : :
7310 : : static int
7311 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
7312 : : {
7313 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7314 : : }
7315 : :
7316 : : static int
7317 : 0 : test_kasumi_encryption_test_case_1_oop(void)
7318 : : {
7319 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
7320 : : }
7321 : :
7322 : : static int
7323 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
7324 : : {
7325 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7326 : : }
7327 : :
7328 : : static int
7329 : 0 : test_kasumi_encryption_test_case_2(void)
7330 : : {
7331 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
7332 : : }
7333 : :
7334 : : static int
7335 : 0 : test_kasumi_encryption_test_case_3(void)
7336 : : {
7337 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
7338 : : }
7339 : :
7340 : : static int
7341 : 0 : test_kasumi_encryption_test_case_4(void)
7342 : : {
7343 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
7344 : : }
7345 : :
7346 : : static int
7347 : 0 : test_kasumi_encryption_test_case_5(void)
7348 : : {
7349 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
7350 : : }
7351 : :
7352 : : static int
7353 : 0 : test_kasumi_decryption_test_case_1(void)
7354 : : {
7355 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
7356 : : }
7357 : :
7358 : : static int
7359 : 0 : test_kasumi_decryption_test_case_1_oop(void)
7360 : : {
7361 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
7362 : : }
7363 : :
7364 : : static int
7365 : 0 : test_kasumi_decryption_test_case_2(void)
7366 : : {
7367 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
7368 : : }
7369 : :
7370 : : static int
7371 : 0 : test_kasumi_decryption_test_case_3(void)
7372 : : {
7373 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7374 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7375 : : return TEST_SKIPPED;
7376 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7377 : : }
7378 : :
7379 : : static int
7380 : 0 : test_kasumi_decryption_test_case_4(void)
7381 : : {
7382 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7383 : : }
7384 : :
7385 : : static int
7386 : 0 : test_kasumi_decryption_test_case_5(void)
7387 : : {
7388 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7389 : : }
7390 : : static int
7391 : 0 : test_snow3g_encryption_test_case_1(void)
7392 : : {
7393 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7394 : : }
7395 : :
7396 : : static int
7397 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7398 : : {
7399 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7400 : : }
7401 : :
7402 : : static int
7403 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7404 : : {
7405 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7406 : : }
7407 : :
7408 : : static int
7409 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7410 : : {
7411 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7412 : : }
7413 : :
7414 : : static int
7415 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7416 : : {
7417 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7418 : : }
7419 : :
7420 : : static int
7421 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7422 : : {
7423 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7424 : : }
7425 : :
7426 : : static int
7427 : 0 : test_snow3g_encryption_test_case_2(void)
7428 : : {
7429 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7430 : : }
7431 : :
7432 : : static int
7433 : 0 : test_snow3g_encryption_test_case_3(void)
7434 : : {
7435 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7436 : : }
7437 : :
7438 : : static int
7439 : 0 : test_snow3g_encryption_test_case_4(void)
7440 : : {
7441 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7442 : : }
7443 : :
7444 : : static int
7445 : 0 : test_snow3g_encryption_test_case_5(void)
7446 : : {
7447 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7448 : : }
7449 : :
7450 : : static int
7451 : 0 : test_snow3g_decryption_test_case_1(void)
7452 : : {
7453 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7454 : : }
7455 : :
7456 : : static int
7457 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7458 : : {
7459 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7460 : : }
7461 : :
7462 : : static int
7463 : 0 : test_snow3g_decryption_test_case_2(void)
7464 : : {
7465 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7466 : : }
7467 : :
7468 : : static int
7469 : 0 : test_snow3g_decryption_test_case_3(void)
7470 : : {
7471 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7472 : : }
7473 : :
7474 : : static int
7475 : 0 : test_snow3g_decryption_test_case_4(void)
7476 : : {
7477 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7478 : : }
7479 : :
7480 : : static int
7481 : 0 : test_snow3g_decryption_test_case_5(void)
7482 : : {
7483 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7484 : : }
7485 : :
7486 : : /*
7487 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7488 : : * Pattern digest from snow3g_test_data must be allocated as
7489 : : * 4 last bytes in plaintext.
7490 : : */
7491 : : static void
7492 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7493 : : struct snow3g_hash_test_data *output)
7494 : : {
7495 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7496 : 0 : output->key.len = pattern->key.len;
7497 : :
7498 : 0 : memcpy(output->key.data,
7499 : 0 : pattern->key.data, pattern->key.len);
7500 : :
7501 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7502 : :
7503 : 0 : memcpy(output->auth_iv.data,
7504 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7505 : :
7506 : 0 : output->plaintext.len = pattern->plaintext.len;
7507 : :
7508 : 0 : memcpy(output->plaintext.data,
7509 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7510 : :
7511 : 0 : output->digest.len = pattern->digest.len;
7512 : :
7513 : 0 : memcpy(output->digest.data,
7514 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7515 : : pattern->digest.len);
7516 : :
7517 : 0 : output->validAuthLenInBits.len =
7518 : 0 : pattern->validAuthLenInBits.len;
7519 : : }
7520 : 0 : }
7521 : :
7522 : : /*
7523 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7524 : : */
7525 : : static int
7526 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7527 : : {
7528 : : int ret;
7529 : : struct snow3g_hash_test_data snow3g_hash_data;
7530 : : struct rte_cryptodev_info dev_info;
7531 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7532 : :
7533 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7534 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7535 : :
7536 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7537 : : printf("Device doesn't support encrypted digest operations.\n");
7538 : 0 : return TEST_SKIPPED;
7539 : : }
7540 : :
7541 : : /*
7542 : : * Function prepare data for hash verification test case.
7543 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7544 : : */
7545 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7546 : :
7547 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7548 [ # # ]: 0 : if (ret != 0)
7549 : : return ret;
7550 : :
7551 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7552 : : }
7553 : :
7554 : : static int
7555 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7556 : : {
7557 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7558 : : }
7559 : :
7560 : : static int
7561 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7562 : : {
7563 : 0 : return test_snow3g_auth_cipher(
7564 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7565 : : }
7566 : :
7567 : : static int
7568 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7569 : : {
7570 : 0 : return test_snow3g_auth_cipher(
7571 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7572 : : }
7573 : :
7574 : : static int
7575 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7576 : : {
7577 : 0 : return test_snow3g_auth_cipher(
7578 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7579 : : }
7580 : :
7581 : : static int
7582 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7583 : : {
7584 : 0 : return test_snow3g_auth_cipher(
7585 : : &snow3g_auth_cipher_partial_digest_encryption,
7586 : : IN_PLACE, 0);
7587 : : }
7588 : :
7589 : : static int
7590 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7591 : : {
7592 : 0 : return test_snow3g_auth_cipher(
7593 : : &snow3g_auth_cipher_partial_digest_encryption,
7594 : : OUT_OF_PLACE, 0);
7595 : : }
7596 : :
7597 : : static int
7598 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7599 : : {
7600 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7601 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7602 : : return TEST_SKIPPED;
7603 : 0 : return test_snow3g_auth_cipher_sgl(
7604 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7605 : : }
7606 : :
7607 : : static int
7608 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7609 : : {
7610 : 0 : return test_snow3g_auth_cipher_sgl(
7611 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7612 : : }
7613 : :
7614 : : static int
7615 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7616 : : {
7617 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7618 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7619 : : return TEST_SKIPPED;
7620 : 0 : return test_snow3g_auth_cipher_sgl(
7621 : : &snow3g_auth_cipher_partial_digest_encryption,
7622 : : IN_PLACE, 0);
7623 : : }
7624 : :
7625 : : static int
7626 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7627 : : {
7628 : 0 : return test_snow3g_auth_cipher_sgl(
7629 : : &snow3g_auth_cipher_partial_digest_encryption,
7630 : : OUT_OF_PLACE, 0);
7631 : : }
7632 : :
7633 : : static int
7634 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7635 : : {
7636 : 0 : return test_snow3g_auth_cipher(
7637 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7638 : : }
7639 : :
7640 : : static int
7641 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7642 : : {
7643 : 0 : return test_snow3g_auth_cipher(
7644 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7645 : : }
7646 : :
7647 : : static int
7648 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7649 : : {
7650 : 0 : return test_snow3g_auth_cipher_sgl(
7651 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7652 : : }
7653 : :
7654 : : static int
7655 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7656 : : {
7657 : 0 : return test_snow3g_auth_cipher_sgl(
7658 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7659 : : }
7660 : :
7661 : : static int
7662 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7663 : : {
7664 : 0 : return test_snow3g_auth_cipher(
7665 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7666 : : }
7667 : :
7668 : : static int
7669 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7670 : : {
7671 : 0 : return test_snow3g_auth_cipher(
7672 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7673 : : }
7674 : :
7675 : : static int
7676 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7677 : : {
7678 : 0 : return test_snow3g_auth_cipher(
7679 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7680 : : }
7681 : :
7682 : : static int
7683 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7684 : : {
7685 : 0 : return test_snow3g_auth_cipher(
7686 : : &snow3g_auth_cipher_partial_digest_encryption,
7687 : : IN_PLACE, 1);
7688 : : }
7689 : :
7690 : : static int
7691 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7692 : : {
7693 : 0 : return test_snow3g_auth_cipher(
7694 : : &snow3g_auth_cipher_partial_digest_encryption,
7695 : : OUT_OF_PLACE, 1);
7696 : : }
7697 : :
7698 : : static int
7699 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7700 : : {
7701 : 0 : return test_snow3g_auth_cipher_sgl(
7702 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7703 : : }
7704 : :
7705 : : static int
7706 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7707 : : {
7708 : 0 : return test_snow3g_auth_cipher_sgl(
7709 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7710 : : }
7711 : :
7712 : : static int
7713 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7714 : : {
7715 : 0 : return test_snow3g_auth_cipher_sgl(
7716 : : &snow3g_auth_cipher_partial_digest_encryption,
7717 : : IN_PLACE, 1);
7718 : : }
7719 : :
7720 : : static int
7721 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7722 : : {
7723 : 0 : return test_snow3g_auth_cipher_sgl(
7724 : : &snow3g_auth_cipher_partial_digest_encryption,
7725 : : OUT_OF_PLACE, 1);
7726 : : }
7727 : :
7728 : : static int
7729 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7730 : : {
7731 : 0 : return test_snow3g_auth_cipher(
7732 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7733 : : }
7734 : :
7735 : : static int
7736 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7737 : : {
7738 : 0 : return test_snow3g_auth_cipher(
7739 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7740 : : }
7741 : :
7742 : : static int
7743 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7744 : : {
7745 : 0 : return test_snow3g_auth_cipher_sgl(
7746 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7747 : : }
7748 : :
7749 : : static int
7750 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7751 : : {
7752 : 0 : return test_snow3g_auth_cipher_sgl(
7753 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7754 : : }
7755 : :
7756 : : static int
7757 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7758 : : {
7759 : 0 : return test_snow3g_auth_cipher(
7760 : : &snow3g_test_case_7, IN_PLACE, 0);
7761 : : }
7762 : :
7763 : : static int
7764 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7765 : : {
7766 : 0 : return test_kasumi_auth_cipher(
7767 : : &kasumi_test_case_3, IN_PLACE, 0);
7768 : : }
7769 : :
7770 : : static int
7771 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7772 : : {
7773 : 0 : return test_kasumi_auth_cipher(
7774 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7775 : : }
7776 : :
7777 : : static int
7778 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7779 : : {
7780 : 0 : return test_kasumi_auth_cipher(
7781 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7782 : : }
7783 : :
7784 : : static int
7785 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7786 : : {
7787 : 0 : return test_kasumi_auth_cipher_sgl(
7788 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7789 : : }
7790 : :
7791 : : static int
7792 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7793 : : {
7794 : 0 : return test_kasumi_auth_cipher_sgl(
7795 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7796 : : }
7797 : :
7798 : : static int
7799 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7800 : : {
7801 : 0 : return test_kasumi_auth_cipher(
7802 : : &kasumi_test_case_3, IN_PLACE, 1);
7803 : : }
7804 : :
7805 : : static int
7806 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7807 : : {
7808 : 0 : return test_kasumi_auth_cipher(
7809 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7810 : : }
7811 : :
7812 : : static int
7813 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7814 : : {
7815 : 0 : return test_kasumi_auth_cipher(
7816 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7817 : : }
7818 : :
7819 : : static int
7820 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7821 : : {
7822 : 0 : return test_kasumi_auth_cipher_sgl(
7823 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7824 : : }
7825 : :
7826 : : static int
7827 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7828 : : {
7829 : 0 : return test_kasumi_auth_cipher_sgl(
7830 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7831 : : }
7832 : :
7833 : : static int
7834 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7835 : : {
7836 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7837 : : }
7838 : :
7839 : : static int
7840 : 0 : test_zuc_encryption_test_case_1(void)
7841 : : {
7842 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7843 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7844 : : }
7845 : :
7846 : : static int
7847 : 0 : test_zuc_encryption_test_case_2(void)
7848 : : {
7849 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7850 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7851 : : }
7852 : :
7853 : : static int
7854 : 0 : test_zuc_encryption_test_case_3(void)
7855 : : {
7856 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7857 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7858 : : }
7859 : :
7860 : : static int
7861 : 0 : test_zuc_encryption_test_case_4(void)
7862 : : {
7863 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7864 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7865 : : }
7866 : :
7867 : : static int
7868 : 0 : test_zuc_encryption_test_case_5(void)
7869 : : {
7870 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7871 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7872 : : }
7873 : :
7874 : : static int
7875 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7876 : : {
7877 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7878 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7879 : : }
7880 : :
7881 : : static int
7882 : 0 : test_zuc_decryption_test_case_1(void)
7883 : : {
7884 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7885 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7886 : : }
7887 : :
7888 : : static int
7889 : 0 : test_zuc_decryption_test_case_2(void)
7890 : : {
7891 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7892 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7893 : : }
7894 : :
7895 : : static int
7896 : 0 : test_zuc_decryption_test_case_3(void)
7897 : : {
7898 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7899 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7900 : : }
7901 : :
7902 : : static int
7903 : 0 : test_zuc_decryption_test_case_4(void)
7904 : : {
7905 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7906 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7907 : : }
7908 : :
7909 : : static int
7910 : 0 : test_zuc_decryption_test_case_5(void)
7911 : : {
7912 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7913 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7914 : : }
7915 : :
7916 : : static int
7917 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7918 : : {
7919 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7920 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7921 : : }
7922 : :
7923 : : static int
7924 : 0 : test_zuc_hash_generate_test_case_1(void)
7925 : : {
7926 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7927 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7928 : : }
7929 : :
7930 : : static int
7931 : 0 : test_zuc_hash_generate_test_case_2(void)
7932 : : {
7933 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7934 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7935 : : }
7936 : :
7937 : : static int
7938 : 0 : test_zuc_hash_generate_test_case_3(void)
7939 : : {
7940 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7941 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7942 : : }
7943 : :
7944 : : static int
7945 : 0 : test_zuc_hash_generate_test_case_4(void)
7946 : : {
7947 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7948 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7949 : : }
7950 : :
7951 : : static int
7952 : 0 : test_zuc_hash_generate_test_case_5(void)
7953 : : {
7954 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7955 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7956 : : }
7957 : :
7958 : : static int
7959 : 0 : test_zuc_hash_generate_test_case_6(void)
7960 : : {
7961 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7962 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7963 : : }
7964 : :
7965 : : static int
7966 : 0 : test_zuc_hash_generate_test_case_7(void)
7967 : : {
7968 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7969 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7970 : : }
7971 : :
7972 : : static int
7973 : 0 : test_zuc_hash_generate_test_case_8(void)
7974 : : {
7975 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7976 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7977 : : }
7978 : :
7979 : : static int
7980 : 0 : test_zuc_hash_verify_test_case_1(void)
7981 : : {
7982 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7983 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7984 : : }
7985 : :
7986 : : static int
7987 : 0 : test_zuc_hash_verify_test_case_2(void)
7988 : : {
7989 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7990 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7991 : : }
7992 : :
7993 : : static int
7994 : 0 : test_zuc_hash_verify_test_case_3(void)
7995 : : {
7996 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7997 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7998 : : }
7999 : :
8000 : : static int
8001 : 0 : test_zuc_hash_verify_test_case_4(void)
8002 : : {
8003 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
8004 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8005 : : }
8006 : :
8007 : : static int
8008 : 0 : test_zuc_hash_verify_test_case_5(void)
8009 : : {
8010 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
8011 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8012 : : }
8013 : :
8014 : : static int
8015 : 0 : test_zuc_hash_verify_test_case_6(void)
8016 : : {
8017 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
8018 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8019 : : }
8020 : :
8021 : : static int
8022 : 0 : test_zuc_hash_verify_test_case_7(void)
8023 : : {
8024 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
8025 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8026 : : }
8027 : :
8028 : : static int
8029 : 0 : test_zuc_hash_verify_test_case_8(void)
8030 : : {
8031 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
8032 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8033 : : }
8034 : :
8035 : : static int
8036 : 0 : test_zuc_cipher_auth_test_case_1(void)
8037 : : {
8038 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
8039 : : }
8040 : :
8041 : : static int
8042 : 0 : test_zuc_cipher_auth_test_case_2(void)
8043 : : {
8044 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
8045 : : }
8046 : :
8047 : : static int
8048 : 0 : test_zuc_auth_cipher_test_case_1(void)
8049 : : {
8050 : 0 : return test_zuc_auth_cipher(
8051 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8052 : : }
8053 : :
8054 : : static int
8055 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
8056 : : {
8057 : 0 : return test_zuc_auth_cipher(
8058 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8059 : : }
8060 : :
8061 : : static int
8062 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
8063 : : {
8064 : 0 : return test_zuc_auth_cipher_sgl(
8065 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8066 : : }
8067 : :
8068 : : static int
8069 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
8070 : : {
8071 : 0 : return test_zuc_auth_cipher_sgl(
8072 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8073 : : }
8074 : :
8075 : : static int
8076 : 0 : test_zuc_auth_cipher_test_case_2(void)
8077 : : {
8078 : 0 : return test_zuc_auth_cipher(
8079 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
8080 : : }
8081 : :
8082 : : static int
8083 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
8084 : : {
8085 : 0 : return test_zuc_auth_cipher(
8086 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
8087 : : }
8088 : :
8089 : : static int
8090 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
8091 : : {
8092 : 0 : return test_zuc_auth_cipher(
8093 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8094 : : }
8095 : :
8096 : : static int
8097 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
8098 : : {
8099 : 0 : return test_zuc_auth_cipher(
8100 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8101 : : }
8102 : :
8103 : : static int
8104 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
8105 : : {
8106 : 0 : return test_zuc_auth_cipher_sgl(
8107 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8108 : : }
8109 : :
8110 : : static int
8111 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
8112 : : {
8113 : 0 : return test_zuc_auth_cipher_sgl(
8114 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8115 : : }
8116 : :
8117 : : static int
8118 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
8119 : : {
8120 : 0 : return test_zuc_auth_cipher(
8121 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
8122 : : }
8123 : :
8124 : : static int
8125 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
8126 : : {
8127 : 0 : return test_zuc_auth_cipher(
8128 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8129 : : }
8130 : :
8131 : : static int
8132 : 0 : test_zuc256_encryption_test_case_1(void)
8133 : : {
8134 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8135 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8136 : : }
8137 : :
8138 : : static int
8139 : 0 : test_zuc256_encryption_test_case_2(void)
8140 : : {
8141 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8142 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8143 : : }
8144 : :
8145 : : static int
8146 : 0 : test_zuc256_decryption_test_case_1(void)
8147 : : {
8148 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
8149 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8150 : : }
8151 : :
8152 : : static int
8153 : 0 : test_zuc256_decryption_test_case_2(void)
8154 : : {
8155 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
8156 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
8157 : : }
8158 : :
8159 : : static int
8160 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
8161 : : {
8162 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8163 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8164 : : }
8165 : :
8166 : : static int
8167 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
8168 : : {
8169 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8170 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8171 : : }
8172 : :
8173 : : static int
8174 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
8175 : : {
8176 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8177 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8178 : : }
8179 : :
8180 : : static int
8181 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
8182 : : {
8183 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8184 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8185 : : }
8186 : :
8187 : : static int
8188 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
8189 : : {
8190 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8191 : : RTE_CRYPTO_AUTH_OP_GENERATE);
8192 : : }
8193 : :
8194 : : static int
8195 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
8196 : : {
8197 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
8198 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8199 : : }
8200 : :
8201 : : static int
8202 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
8203 : : {
8204 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
8205 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8206 : : }
8207 : :
8208 : : static int
8209 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
8210 : : {
8211 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8212 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8213 : : }
8214 : :
8215 : : static int
8216 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
8217 : : {
8218 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8219 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8220 : : }
8221 : :
8222 : : static int
8223 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
8224 : : {
8225 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8226 : : RTE_CRYPTO_AUTH_OP_VERIFY);
8227 : : }
8228 : :
8229 : : static int
8230 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8231 : : {
8232 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8233 : : }
8234 : :
8235 : : static int
8236 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8237 : : {
8238 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8239 : : }
8240 : :
8241 : : static int
8242 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8243 : : {
8244 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8245 : : }
8246 : :
8247 : : static int
8248 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8249 : : {
8250 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8251 : : }
8252 : :
8253 : : static int
8254 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8255 : : {
8256 : 0 : return test_zuc_auth_cipher(
8257 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8258 : : }
8259 : :
8260 : : static int
8261 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8262 : : {
8263 : 0 : return test_zuc_auth_cipher(
8264 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8265 : : }
8266 : :
8267 : : static int
8268 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8269 : : {
8270 : 0 : return test_zuc_auth_cipher(
8271 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8272 : : }
8273 : :
8274 : : static int
8275 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8276 : : {
8277 : 0 : return test_zuc_auth_cipher(
8278 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8279 : : }
8280 : :
8281 : : static int
8282 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8283 : : {
8284 : 0 : return test_zuc_auth_cipher(
8285 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8286 : : }
8287 : :
8288 : : static int
8289 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8290 : : {
8291 : 0 : return test_zuc_auth_cipher(
8292 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8293 : : }
8294 : :
8295 : : static int
8296 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8297 : : {
8298 : 0 : return test_zuc_auth_cipher(
8299 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8300 : : }
8301 : :
8302 : : static int
8303 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8304 : : {
8305 : 0 : return test_zuc_auth_cipher(
8306 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8307 : : }
8308 : :
8309 : : static int
8310 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8311 : : {
8312 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
8313 : :
8314 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8315 : :
8316 : : /* Check if device supports particular cipher algorithm */
8317 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8318 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
8319 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8320 : : return TEST_SKIPPED;
8321 : :
8322 : : /* Check if device supports particular hash algorithm */
8323 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8324 : 24 : cap_idx.algo.auth = tdata->auth_algo;
8325 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8326 : 12 : return TEST_SKIPPED;
8327 : :
8328 : : return 0;
8329 : : }
8330 : :
8331 : : static int
8332 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8333 : : uint8_t op_mode, uint8_t verify)
8334 : : {
8335 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8336 : : struct crypto_unittest_params *ut_params = &unittest_params;
8337 : :
8338 : : int retval;
8339 : :
8340 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
8341 : : unsigned int plaintext_pad_len;
8342 : : unsigned int plaintext_len;
8343 : : unsigned int ciphertext_pad_len;
8344 : : unsigned int ciphertext_len;
8345 : : unsigned int digest_offset;
8346 : :
8347 : : struct rte_cryptodev_info dev_info;
8348 : : struct rte_crypto_op *op;
8349 : :
8350 : : /* Check if device supports particular algorithms separately */
8351 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
8352 : : return TEST_SKIPPED;
8353 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8354 : : return TEST_SKIPPED;
8355 : :
8356 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8357 : : return TEST_SKIPPED;
8358 : :
8359 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8360 : :
8361 : 8 : uint64_t feat_flags = dev_info.feature_flags;
8362 : :
8363 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8364 : : printf("Device doesn't support digest encrypted.\n");
8365 : 8 : return TEST_SKIPPED;
8366 : : }
8367 : :
8368 : : /* Create the session */
8369 [ # # ]: 0 : if (verify)
8370 : 0 : retval = create_wireless_algo_cipher_auth_session(
8371 : 0 : ts_params->valid_devs[0],
8372 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8373 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8374 : 0 : tdata->auth_algo,
8375 : 0 : tdata->cipher_algo,
8376 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8377 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8378 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8379 : 0 : tdata->cipher_iv.len);
8380 : : else
8381 : 0 : retval = create_wireless_algo_auth_cipher_session(
8382 : 0 : ts_params->valid_devs[0],
8383 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8384 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8385 : 0 : tdata->auth_algo,
8386 : 0 : tdata->cipher_algo,
8387 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8388 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8389 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8390 : 0 : tdata->cipher_iv.len);
8391 [ # # ]: 0 : if (retval != 0)
8392 : : return retval;
8393 : :
8394 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8395 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8396 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8397 : :
8398 : : /* clear mbuf payload */
8399 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8400 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8401 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8402 : :
8403 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8404 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8405 : : }
8406 : :
8407 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8408 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8409 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8410 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8411 : :
8412 [ # # ]: 0 : if (verify) {
8413 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8414 : : ciphertext_pad_len);
8415 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8416 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8417 : : ciphertext_len);
8418 : : } else {
8419 : : /* make sure enough space to cover partial digest verify case */
8420 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8421 : : ciphertext_pad_len);
8422 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8423 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8424 : : }
8425 : :
8426 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8427 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8428 : :
8429 : : /* Create the operation */
8430 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8431 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8432 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8433 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8434 : 0 : (tdata->digest_enc.offset == 0 ?
8435 : : plaintext_pad_len
8436 : : : tdata->digest_enc.offset),
8437 : 0 : tdata->validCipherLen.len_bits,
8438 : 0 : tdata->cipher.offset_bits,
8439 : 0 : tdata->validAuthLen.len_bits,
8440 [ # # ]: 0 : tdata->auth.offset_bits,
8441 : : op_mode, 0, verify);
8442 : :
8443 [ # # ]: 0 : if (retval < 0)
8444 : : return retval;
8445 : :
8446 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8447 : :
8448 : : /* Check if the op failed because the device doesn't */
8449 : : /* support this particular combination of algorithms */
8450 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8451 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8452 : : printf("Device doesn't support this mixed combination. "
8453 : : "Test Skipped.\n");
8454 : 0 : return TEST_SKIPPED;
8455 : : }
8456 : 0 : ut_params->op = op;
8457 : :
8458 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8459 : :
8460 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8461 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8462 : :
8463 [ # # ]: 0 : if (verify) {
8464 [ # # ]: 0 : if (ut_params->obuf)
8465 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8466 : : uint8_t *);
8467 : : else
8468 : 0 : plaintext = ciphertext +
8469 : 0 : (tdata->cipher.offset_bits >> 3);
8470 : :
8471 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8472 : 0 : tdata->plaintext.len_bits >> 3);
8473 : 0 : debug_hexdump(stdout, "plaintext expected:",
8474 : 0 : tdata->plaintext.data,
8475 : 0 : tdata->plaintext.len_bits >> 3);
8476 : : } else {
8477 [ # # ]: 0 : if (ut_params->obuf)
8478 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8479 : : uint8_t *);
8480 : : else
8481 : : ciphertext = plaintext;
8482 : :
8483 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8484 : : ciphertext_len);
8485 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8486 : 0 : tdata->ciphertext.data,
8487 : 0 : tdata->ciphertext.len_bits >> 3);
8488 : :
8489 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8490 : : digest_offset = plaintext_pad_len;
8491 : : else
8492 : : digest_offset = tdata->digest_enc.offset;
8493 : :
8494 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8495 : : uint8_t *, digest_offset);
8496 : :
8497 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8498 : 0 : tdata->digest_enc.len);
8499 : 0 : debug_hexdump(stdout, "digest expected:",
8500 : : tdata->digest_enc.data,
8501 : 0 : tdata->digest_enc.len);
8502 : : }
8503 : :
8504 [ # # ]: 0 : if (!verify) {
8505 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8506 : : ut_params->digest,
8507 : : tdata->digest_enc.data,
8508 : : tdata->digest_enc.len,
8509 : : "Generated auth tag not as expected");
8510 : : }
8511 : :
8512 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8513 [ # # ]: 0 : if (verify) {
8514 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8515 : : plaintext,
8516 : : tdata->plaintext.data,
8517 : : tdata->plaintext.len_bits >> 3,
8518 : : "Plaintext data not as expected");
8519 : : } else {
8520 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8521 : : ciphertext,
8522 : : tdata->ciphertext.data,
8523 : : tdata->validDataLen.len_bits,
8524 : : "Ciphertext data not as expected");
8525 : : }
8526 : : }
8527 : :
8528 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8529 : : "crypto op processing failed");
8530 : :
8531 : : return 0;
8532 : : }
8533 : :
8534 : : static int
8535 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8536 : : uint8_t op_mode, uint8_t verify)
8537 : : {
8538 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8539 : : struct crypto_unittest_params *ut_params = &unittest_params;
8540 : :
8541 : : int retval;
8542 : :
8543 : : const uint8_t *plaintext = NULL;
8544 : : const uint8_t *ciphertext = NULL;
8545 : : const uint8_t *digest = NULL;
8546 : : unsigned int plaintext_pad_len;
8547 : : unsigned int plaintext_len;
8548 : : unsigned int ciphertext_pad_len;
8549 : : unsigned int ciphertext_len;
8550 : : uint8_t buffer[10000];
8551 : : uint8_t digest_buffer[10000];
8552 : :
8553 : : struct rte_cryptodev_info dev_info;
8554 : : struct rte_crypto_op *op;
8555 : :
8556 : : /* Check if device supports particular algorithms */
8557 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8558 : : return TEST_SKIPPED;
8559 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8560 : : return TEST_SKIPPED;
8561 : :
8562 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8563 : :
8564 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8565 : :
8566 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8567 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8568 : : printf("Device doesn't support in-place scatter-gather "
8569 : : "in both input and output mbufs.\n");
8570 : 0 : return TEST_SKIPPED;
8571 : : }
8572 : : } else {
8573 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8574 : : printf("Device doesn't support out-of-place scatter-gather "
8575 : : "in both input and output mbufs.\n");
8576 : 2 : return TEST_SKIPPED;
8577 : : }
8578 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8579 : : printf("Device doesn't support digest encrypted.\n");
8580 : 0 : return TEST_SKIPPED;
8581 : : }
8582 : : }
8583 : :
8584 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8585 : : return TEST_SKIPPED;
8586 : :
8587 : : /* Create the session */
8588 [ + + ]: 2 : if (verify)
8589 : 1 : retval = create_wireless_algo_cipher_auth_session(
8590 : 1 : ts_params->valid_devs[0],
8591 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8592 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8593 : 1 : tdata->auth_algo,
8594 : 1 : tdata->cipher_algo,
8595 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8596 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8597 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8598 : 1 : tdata->cipher_iv.len);
8599 : : else
8600 : 1 : retval = create_wireless_algo_auth_cipher_session(
8601 : 1 : ts_params->valid_devs[0],
8602 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8603 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8604 : 1 : tdata->auth_algo,
8605 : 1 : tdata->cipher_algo,
8606 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8607 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8608 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8609 : 1 : tdata->cipher_iv.len);
8610 [ + - ]: 2 : if (retval != 0)
8611 : : return retval;
8612 : :
8613 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8614 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8615 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8616 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8617 : :
8618 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8619 : : ciphertext_pad_len, 15, 0);
8620 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8621 : : "Failed to allocate input buffer in mempool");
8622 : :
8623 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8624 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8625 : : plaintext_pad_len, 15, 0);
8626 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8627 : : "Failed to allocate output buffer in mempool");
8628 : : }
8629 : :
8630 [ + + ]: 2 : if (verify) {
8631 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8632 : 1 : tdata->ciphertext.data);
8633 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8634 : : ciphertext_len, buffer);
8635 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8636 : : ciphertext_len);
8637 : : } else {
8638 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8639 : 1 : tdata->plaintext.data);
8640 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8641 : : plaintext_len, buffer);
8642 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8643 : : plaintext_len);
8644 : : }
8645 : : memset(buffer, 0, sizeof(buffer));
8646 : :
8647 : : /* Create the operation */
8648 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8649 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8650 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8651 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8652 : 2 : (tdata->digest_enc.offset == 0 ?
8653 : : plaintext_pad_len
8654 : : : tdata->digest_enc.offset),
8655 : 2 : tdata->validCipherLen.len_bits,
8656 : 2 : tdata->cipher.offset_bits,
8657 : 2 : tdata->validAuthLen.len_bits,
8658 [ + - ]: 2 : tdata->auth.offset_bits,
8659 : : op_mode, 1, verify);
8660 : :
8661 [ + - ]: 2 : if (retval < 0)
8662 : : return retval;
8663 : :
8664 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8665 : :
8666 : : /* Check if the op failed because the device doesn't */
8667 : : /* support this particular combination of algorithms */
8668 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8669 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8670 : : printf("Device doesn't support this mixed combination. "
8671 : : "Test Skipped.\n");
8672 : 0 : return TEST_SKIPPED;
8673 : : }
8674 : 2 : ut_params->op = op;
8675 : :
8676 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8677 : :
8678 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8679 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8680 : :
8681 [ + + ]: 2 : if (verify) {
8682 [ + - ]: 1 : if (ut_params->obuf)
8683 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8684 : : plaintext_len, buffer);
8685 : : else
8686 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8687 : : plaintext_len, buffer);
8688 : :
8689 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8690 : 1 : (tdata->plaintext.len_bits >> 3) -
8691 : 1 : tdata->digest_enc.len);
8692 : 1 : debug_hexdump(stdout, "plaintext expected:",
8693 : 1 : tdata->plaintext.data,
8694 : 1 : (tdata->plaintext.len_bits >> 3) -
8695 : 1 : tdata->digest_enc.len);
8696 : : } else {
8697 [ + - ]: 1 : if (ut_params->obuf)
8698 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8699 : : ciphertext_len, buffer);
8700 : : else
8701 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8702 : : ciphertext_len, buffer);
8703 : :
8704 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8705 : : ciphertext_len);
8706 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8707 : 1 : tdata->ciphertext.data,
8708 : 1 : tdata->ciphertext.len_bits >> 3);
8709 : :
8710 [ + - ]: 1 : if (ut_params->obuf)
8711 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8712 : 1 : (tdata->digest_enc.offset == 0 ?
8713 : : plaintext_pad_len :
8714 : : tdata->digest_enc.offset),
8715 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8716 : : else
8717 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8718 : 0 : (tdata->digest_enc.offset == 0 ?
8719 : : plaintext_pad_len :
8720 : : tdata->digest_enc.offset),
8721 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8722 : :
8723 : 1 : debug_hexdump(stdout, "digest:", digest,
8724 : 1 : tdata->digest_enc.len);
8725 : 1 : debug_hexdump(stdout, "digest expected:",
8726 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8727 : : }
8728 : :
8729 [ + + ]: 2 : if (!verify) {
8730 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8731 : : digest,
8732 : : tdata->digest_enc.data,
8733 : : tdata->digest_enc.len,
8734 : : "Generated auth tag not as expected");
8735 : : }
8736 : :
8737 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8738 [ + + ]: 2 : if (verify) {
8739 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8740 : : plaintext,
8741 : : tdata->plaintext.data,
8742 : : tdata->plaintext.len_bits >> 3,
8743 : : "Plaintext data not as expected");
8744 : : } else {
8745 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8746 : : ciphertext,
8747 : : tdata->ciphertext.data,
8748 : : tdata->validDataLen.len_bits,
8749 : : "Ciphertext data not as expected");
8750 : : }
8751 : : }
8752 : :
8753 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8754 : : "crypto op processing failed");
8755 : :
8756 : : return 0;
8757 : : }
8758 : :
8759 : : /** AUTH AES CMAC + CIPHER AES CTR */
8760 : :
8761 : : static int
8762 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8763 : : {
8764 : 1 : return test_mixed_auth_cipher(
8765 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8766 : : }
8767 : :
8768 : : static int
8769 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8770 : : {
8771 : 1 : return test_mixed_auth_cipher(
8772 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8773 : : }
8774 : :
8775 : : static int
8776 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8777 : : {
8778 : 1 : return test_mixed_auth_cipher_sgl(
8779 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8780 : : }
8781 : :
8782 : : static int
8783 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8784 : : {
8785 : 1 : return test_mixed_auth_cipher_sgl(
8786 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8787 : : }
8788 : :
8789 : : static int
8790 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8791 : : {
8792 : 1 : return test_mixed_auth_cipher(
8793 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8794 : : }
8795 : :
8796 : : static int
8797 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8798 : : {
8799 : 1 : return test_mixed_auth_cipher(
8800 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8801 : : }
8802 : :
8803 : : static int
8804 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8805 : : {
8806 : 1 : return test_mixed_auth_cipher(
8807 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8808 : : }
8809 : :
8810 : : static int
8811 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8812 : : {
8813 : 1 : return test_mixed_auth_cipher(
8814 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8815 : : }
8816 : :
8817 : : static int
8818 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8819 : : {
8820 : 1 : return test_mixed_auth_cipher(
8821 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8822 : : }
8823 : :
8824 : : static int
8825 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8826 : : {
8827 : 1 : return test_mixed_auth_cipher_sgl(
8828 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8829 : : }
8830 : :
8831 : : static int
8832 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8833 : : {
8834 : 1 : return test_mixed_auth_cipher_sgl(
8835 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8836 : : }
8837 : :
8838 : : static int
8839 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8840 : : {
8841 : 1 : return test_mixed_auth_cipher(
8842 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8843 : : }
8844 : :
8845 : : /** MIXED AUTH + CIPHER */
8846 : :
8847 : : static int
8848 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8849 : : {
8850 : 1 : return test_mixed_auth_cipher(
8851 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8852 : : }
8853 : :
8854 : : static int
8855 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8856 : : {
8857 : 1 : return test_mixed_auth_cipher(
8858 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8859 : : }
8860 : :
8861 : : static int
8862 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8863 : : {
8864 : 1 : return test_mixed_auth_cipher(
8865 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8866 : : }
8867 : :
8868 : : static int
8869 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8870 : : {
8871 : 1 : return test_mixed_auth_cipher(
8872 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8873 : : }
8874 : :
8875 : :
8876 : : static int
8877 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8878 : : {
8879 : 1 : return test_mixed_auth_cipher(
8880 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8881 : : }
8882 : :
8883 : : static int
8884 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8885 : : {
8886 : 1 : return test_mixed_auth_cipher(
8887 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8888 : : }
8889 : :
8890 : : static int
8891 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8892 : : {
8893 : 1 : return test_mixed_auth_cipher(
8894 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8895 : : }
8896 : :
8897 : : static int
8898 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8899 : : {
8900 : 1 : return test_mixed_auth_cipher(
8901 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8902 : : }
8903 : :
8904 : : static int
8905 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8906 : : {
8907 : 1 : return test_mixed_auth_cipher(
8908 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8909 : : }
8910 : :
8911 : : static int
8912 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8913 : : {
8914 : 1 : return test_mixed_auth_cipher(
8915 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8916 : : }
8917 : :
8918 : : static int
8919 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8920 : : {
8921 : 1 : return test_mixed_auth_cipher(
8922 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8923 : : }
8924 : :
8925 : : static int
8926 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8927 : : {
8928 : 1 : return test_mixed_auth_cipher(
8929 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8930 : : }
8931 : :
8932 : : static int
8933 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8934 : : {
8935 : 1 : return test_mixed_auth_cipher(
8936 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8937 : : }
8938 : :
8939 : : static int
8940 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8941 : : {
8942 : 1 : return test_mixed_auth_cipher(
8943 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8944 : : }
8945 : :
8946 : : static int
8947 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8948 : : {
8949 : 1 : return test_mixed_auth_cipher_sgl(
8950 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8951 : : }
8952 : :
8953 : : static int
8954 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8955 : : {
8956 : 1 : return test_mixed_auth_cipher(
8957 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8958 : : }
8959 : :
8960 : : static int
8961 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8962 : : {
8963 : 1 : return test_mixed_auth_cipher_sgl(
8964 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8965 : : }
8966 : :
8967 : : static int
8968 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8969 : : {
8970 : 1 : return test_mixed_auth_cipher(
8971 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8972 : : }
8973 : :
8974 : : static int
8975 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8976 : : {
8977 : 1 : return test_mixed_auth_cipher(
8978 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8979 : : }
8980 : :
8981 : : static int
8982 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8983 : : {
8984 : 1 : return test_mixed_auth_cipher(
8985 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8986 : : }
8987 : :
8988 : : static int
8989 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8990 : : {
8991 : 1 : return test_mixed_auth_cipher(
8992 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8993 : : }
8994 : :
8995 : : static int
8996 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8997 : : {
8998 : 1 : return test_mixed_auth_cipher(
8999 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
9000 : : }
9001 : :
9002 : : static int
9003 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
9004 : : {
9005 : 1 : return test_mixed_auth_cipher(
9006 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9007 : : }
9008 : :
9009 : : static int
9010 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
9011 : : {
9012 : 1 : return test_mixed_auth_cipher(
9013 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9014 : : }
9015 : : static int
9016 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9017 : : {
9018 : 1 : return test_mixed_auth_cipher(
9019 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
9020 : : }
9021 : :
9022 : : static int
9023 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
9024 : : {
9025 : 1 : return test_mixed_auth_cipher(
9026 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
9027 : : }
9028 : :
9029 : : static int
9030 : 1 : test_auth_null_cipher_snow_test_case_1(void)
9031 : : {
9032 : 1 : return test_mixed_auth_cipher(
9033 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
9034 : : }
9035 : :
9036 : : static int
9037 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
9038 : : {
9039 : 1 : return test_mixed_auth_cipher(
9040 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
9041 : : }
9042 : :
9043 : : static int
9044 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
9045 : : {
9046 : 1 : return test_mixed_auth_cipher(
9047 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9048 : : }
9049 : :
9050 : : static int
9051 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
9052 : : {
9053 : 1 : return test_mixed_auth_cipher(
9054 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9055 : : }
9056 : :
9057 : : static int
9058 : 1 : test_auth_snow_cipher_null_test_case_1(void)
9059 : : {
9060 : 1 : return test_mixed_auth_cipher(
9061 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9062 : : }
9063 : :
9064 : : static int
9065 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
9066 : : {
9067 : 1 : return test_mixed_auth_cipher(
9068 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9069 : : }
9070 : :
9071 : : static int
9072 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
9073 : : {
9074 : 1 : return test_mixed_auth_cipher(
9075 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9076 : : }
9077 : :
9078 : : static int
9079 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
9080 : : {
9081 : 1 : return test_mixed_auth_cipher(
9082 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9083 : : }
9084 : :
9085 : : static int
9086 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
9087 : : {
9088 : 1 : return test_mixed_auth_cipher(
9089 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
9090 : : }
9091 : :
9092 : : static int
9093 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
9094 : : {
9095 : 1 : return test_mixed_auth_cipher(
9096 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
9097 : : }
9098 : :
9099 : : static int
9100 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
9101 : : {
9102 : 1 : return test_mixed_auth_cipher(
9103 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9104 : : }
9105 : :
9106 : : static int
9107 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
9108 : : {
9109 : 1 : return test_mixed_auth_cipher(
9110 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9111 : : }
9112 : :
9113 : : /* ***** AEAD algorithm Tests ***** */
9114 : :
9115 : : static int
9116 : 87 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
9117 : : enum rte_crypto_aead_operation op,
9118 : : const uint8_t *key, const uint8_t key_len,
9119 : : const uint16_t aad_len, const uint8_t auth_len,
9120 : : uint8_t iv_len)
9121 : : {
9122 : 87 : uint8_t *aead_key = alloca(key_len);
9123 : :
9124 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9125 : : struct crypto_unittest_params *ut_params = &unittest_params;
9126 : :
9127 : : memcpy(aead_key, key, key_len);
9128 : :
9129 : : /* Setup AEAD Parameters */
9130 : 87 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9131 : 87 : ut_params->aead_xform.next = NULL;
9132 : 87 : ut_params->aead_xform.aead.algo = algo;
9133 : 87 : ut_params->aead_xform.aead.op = op;
9134 : 87 : ut_params->aead_xform.aead.key.data = aead_key;
9135 : 87 : ut_params->aead_xform.aead.key.length = key_len;
9136 : 87 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9137 : 87 : ut_params->aead_xform.aead.iv.length = iv_len;
9138 : 87 : ut_params->aead_xform.aead.digest_length = auth_len;
9139 : 87 : ut_params->aead_xform.aead.aad_length = aad_len;
9140 : :
9141 : 87 : debug_hexdump(stdout, "key:", key, key_len);
9142 : :
9143 : : /* Create Crypto session*/
9144 : 87 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9145 : : &ut_params->aead_xform, ts_params->session_mpool);
9146 [ - + - - ]: 87 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9147 : : return TEST_SKIPPED;
9148 [ - + ]: 87 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9149 : : return 0;
9150 : : }
9151 : :
9152 : : static int
9153 : 2 : create_aead_xform(struct rte_crypto_op *op,
9154 : : enum rte_crypto_aead_algorithm algo,
9155 : : enum rte_crypto_aead_operation aead_op,
9156 : : uint8_t *key, const uint8_t key_len,
9157 : : const uint8_t aad_len, const uint8_t auth_len,
9158 : : uint8_t iv_len)
9159 : : {
9160 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9161 : : "failed to allocate space for crypto transform");
9162 : :
9163 : : struct rte_crypto_sym_op *sym_op = op->sym;
9164 : :
9165 : : /* Setup AEAD Parameters */
9166 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9167 : 2 : sym_op->xform->next = NULL;
9168 : 2 : sym_op->xform->aead.algo = algo;
9169 : 2 : sym_op->xform->aead.op = aead_op;
9170 : 2 : sym_op->xform->aead.key.data = key;
9171 : 2 : sym_op->xform->aead.key.length = key_len;
9172 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
9173 : 2 : sym_op->xform->aead.iv.length = iv_len;
9174 : 2 : sym_op->xform->aead.digest_length = auth_len;
9175 : 2 : sym_op->xform->aead.aad_length = aad_len;
9176 : :
9177 : 2 : debug_hexdump(stdout, "key:", key, key_len);
9178 : :
9179 : : return 0;
9180 : : }
9181 : :
9182 : : static int
9183 : 88 : create_aead_operation(enum rte_crypto_aead_operation op,
9184 : : const struct aead_test_data *tdata)
9185 : : {
9186 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9187 : : struct crypto_unittest_params *ut_params = &unittest_params;
9188 : :
9189 : : uint8_t *plaintext, *ciphertext;
9190 : : unsigned int aad_pad_len, plaintext_pad_len;
9191 : :
9192 : : /* Generate Crypto op data structure */
9193 : 88 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9194 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9195 [ - + ]: 88 : TEST_ASSERT_NOT_NULL(ut_params->op,
9196 : : "Failed to allocate symmetric crypto operation struct");
9197 : :
9198 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9199 : :
9200 : : /* Append aad data */
9201 [ + + ]: 88 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9202 : 20 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9203 : 20 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9204 : : aad_pad_len);
9205 [ - + ]: 20 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9206 : : "no room to append aad");
9207 : :
9208 : 20 : sym_op->aead.aad.phys_addr =
9209 : 20 : rte_pktmbuf_iova(ut_params->ibuf);
9210 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
9211 : 20 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9212 : 20 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9213 : 20 : tdata->aad.len);
9214 : :
9215 : : /* Append IV at the end of the crypto operation*/
9216 : 20 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9217 : : uint8_t *, IV_OFFSET);
9218 : :
9219 : : /* Copy IV 1 byte after the IV pointer, according to the API */
9220 [ + - ]: 20 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9221 : 20 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
9222 : 20 : tdata->iv.len);
9223 : : } else {
9224 : 68 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9225 : 68 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9226 : : aad_pad_len);
9227 [ - + ]: 68 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9228 : : "no room to append aad");
9229 : :
9230 : 68 : sym_op->aead.aad.phys_addr =
9231 : 68 : rte_pktmbuf_iova(ut_params->ibuf);
9232 : 68 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9233 : 68 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9234 : 68 : tdata->aad.len);
9235 : :
9236 : : /* Append IV at the end of the crypto operation*/
9237 : 68 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9238 : : uint8_t *, IV_OFFSET);
9239 : :
9240 [ - + ]: 68 : if (tdata->iv.len == 0) {
9241 : : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9242 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
9243 : : AES_GCM_J0_LENGTH);
9244 : : } else {
9245 [ + - ]: 68 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9246 : 68 : debug_hexdump(stdout, "iv:", iv_ptr,
9247 : 68 : tdata->iv.len);
9248 : : }
9249 : : }
9250 : :
9251 : : /* Append plaintext/ciphertext */
9252 [ + + ]: 88 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9253 : 44 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9254 : 44 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9255 : : plaintext_pad_len);
9256 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9257 : :
9258 : 44 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9259 : 44 : debug_hexdump(stdout, "plaintext:", plaintext,
9260 : 44 : tdata->plaintext.len);
9261 : :
9262 [ + + ]: 44 : if (ut_params->obuf) {
9263 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
9264 : : ut_params->obuf,
9265 : 1 : plaintext_pad_len + aad_pad_len);
9266 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
9267 : : "no room to append ciphertext");
9268 : :
9269 : 1 : memset(ciphertext + aad_pad_len, 0,
9270 : 1 : tdata->ciphertext.len);
9271 : : }
9272 : : } else {
9273 : 44 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9274 : 44 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9275 : : plaintext_pad_len);
9276 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(ciphertext,
9277 : : "no room to append ciphertext");
9278 : :
9279 : 44 : memcpy(ciphertext, tdata->ciphertext.data,
9280 : 44 : tdata->ciphertext.len);
9281 : 44 : debug_hexdump(stdout, "ciphertext:", ciphertext,
9282 : 44 : tdata->ciphertext.len);
9283 : :
9284 [ + + ]: 44 : if (ut_params->obuf) {
9285 : : plaintext = (uint8_t *)rte_pktmbuf_append(
9286 : : ut_params->obuf,
9287 : 1 : plaintext_pad_len + aad_pad_len);
9288 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
9289 : : "no room to append plaintext");
9290 : :
9291 : 1 : memset(plaintext + aad_pad_len, 0,
9292 : 1 : tdata->plaintext.len);
9293 : : }
9294 : : }
9295 : :
9296 : : /* Append digest data */
9297 [ + + ]: 88 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9298 : 43 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9299 : 44 : ut_params->obuf ? ut_params->obuf :
9300 : : ut_params->ibuf,
9301 [ + + ]: 44 : tdata->auth_tag.len);
9302 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9303 : : "no room to append digest");
9304 [ + + ]: 44 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9305 [ + + ]: 44 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9306 : : ut_params->obuf ? ut_params->obuf :
9307 : : ut_params->ibuf,
9308 : : plaintext_pad_len +
9309 : : aad_pad_len);
9310 : : } else {
9311 : 88 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9312 : 44 : ut_params->ibuf, tdata->auth_tag.len);
9313 [ - + ]: 44 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9314 : : "no room to append digest");
9315 [ + + ]: 44 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9316 : : ut_params->ibuf,
9317 : : plaintext_pad_len + aad_pad_len);
9318 : :
9319 : 44 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9320 [ + + ]: 44 : tdata->auth_tag.len);
9321 : 44 : debug_hexdump(stdout, "digest:",
9322 : 44 : sym_op->aead.digest.data,
9323 : 44 : tdata->auth_tag.len);
9324 : : }
9325 : :
9326 : 88 : sym_op->aead.data.length = tdata->plaintext.len;
9327 : 88 : sym_op->aead.data.offset = aad_pad_len;
9328 : :
9329 : 88 : return 0;
9330 : : }
9331 : :
9332 : : static int
9333 : 43 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9334 : : {
9335 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9336 : : struct crypto_unittest_params *ut_params = &unittest_params;
9337 : :
9338 : : int retval;
9339 : : uint8_t *ciphertext, *auth_tag;
9340 : : uint16_t plaintext_pad_len;
9341 : : uint32_t i;
9342 : : struct rte_cryptodev_info dev_info;
9343 : :
9344 : 43 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9345 : 43 : uint64_t feat_flags = dev_info.feature_flags;
9346 : :
9347 [ - + ]: 43 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9348 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9349 : : printf("Device doesn't support RAW data-path APIs.\n");
9350 : 0 : return TEST_SKIPPED;
9351 : : }
9352 : :
9353 : : /* Verify the capabilities */
9354 : : struct rte_cryptodev_sym_capability_idx cap_idx;
9355 : : const struct rte_cryptodev_symmetric_capability *capability;
9356 : 43 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9357 : 43 : cap_idx.algo.aead = tdata->algo;
9358 : 43 : capability = rte_cryptodev_sym_capability_get(
9359 : 43 : ts_params->valid_devs[0], &cap_idx);
9360 [ + - ]: 43 : if (capability == NULL)
9361 : : return TEST_SKIPPED;
9362 [ + + ]: 43 : if (rte_cryptodev_sym_capability_check_aead(
9363 : 43 : capability, tdata->key.len, tdata->auth_tag.len,
9364 : 43 : tdata->aad.len, tdata->iv.len))
9365 : : return TEST_SKIPPED;
9366 : :
9367 : : /* Create AEAD session */
9368 : 42 : retval = create_aead_session(ts_params->valid_devs[0],
9369 : 42 : tdata->algo,
9370 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
9371 : 42 : tdata->key.data, tdata->key.len,
9372 : 42 : tdata->aad.len, tdata->auth_tag.len,
9373 : 42 : tdata->iv.len);
9374 [ + - ]: 42 : if (retval != TEST_SUCCESS)
9375 : : return retval;
9376 : :
9377 [ + + ]: 42 : if (tdata->aad.len > MBUF_SIZE) {
9378 [ - + ]: 2 : if (use_ext_mbuf) {
9379 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9380 : : AEAD_TEXT_MAX_LENGTH,
9381 : : 1 /* nb_segs */,
9382 : : NULL);
9383 : : } else {
9384 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9385 : : }
9386 : : /* Populate full size of add data */
9387 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9388 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9389 : : } else {
9390 [ + + ]: 40 : if (use_ext_mbuf) {
9391 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9392 : : AEAD_TEXT_MAX_LENGTH,
9393 : : 1 /* nb_segs */,
9394 : : NULL);
9395 : : } else {
9396 : 39 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9397 : : }
9398 : : }
9399 : :
9400 : : /* clear mbuf payload */
9401 : 42 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9402 : 42 : rte_pktmbuf_tailroom(ut_params->ibuf));
9403 : :
9404 : : /* Create AEAD operation */
9405 : 42 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9406 [ + - ]: 42 : if (retval < 0)
9407 : : return retval;
9408 : :
9409 [ + - ]: 42 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9410 : :
9411 : 42 : ut_params->op->sym->m_src = ut_params->ibuf;
9412 : :
9413 : : /* Process crypto operation */
9414 [ - + ]: 42 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9415 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9416 [ - + ]: 42 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9417 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9418 : : 0);
9419 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9420 : : return retval;
9421 : : } else
9422 [ - + ]: 42 : TEST_ASSERT_NOT_NULL(
9423 : : process_crypto_request(ts_params->valid_devs[0],
9424 : : ut_params->op), "failed to process sym crypto op");
9425 : :
9426 [ - + ]: 42 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9427 : : "crypto op processing failed");
9428 : :
9429 : 42 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9430 : :
9431 [ - + ]: 42 : if (ut_params->op->sym->m_dst) {
9432 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9433 : : uint8_t *);
9434 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9435 : : uint8_t *, plaintext_pad_len);
9436 : : } else {
9437 : 42 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9438 : : uint8_t *,
9439 : : ut_params->op->sym->cipher.data.offset);
9440 : 42 : auth_tag = ciphertext + plaintext_pad_len;
9441 : : }
9442 : :
9443 : 42 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9444 : 42 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9445 : :
9446 : : /* Validate obuf */
9447 [ + + ]: 45 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9448 : : ciphertext,
9449 : : tdata->ciphertext.data,
9450 : : tdata->ciphertext.len,
9451 : : "Ciphertext data not as expected");
9452 : :
9453 [ + + ]: 42 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9454 : : auth_tag,
9455 : : tdata->auth_tag.data,
9456 : : tdata->auth_tag.len,
9457 : : "Generated auth tag not as expected");
9458 : :
9459 : : return 0;
9460 : :
9461 : : }
9462 : :
9463 : : static int
9464 : : test_authenticated_encryption(const struct aead_test_data *tdata)
9465 : : {
9466 : 42 : return test_authenticated_encryption_helper(tdata, false);
9467 : : }
9468 : :
9469 : : #ifdef RTE_LIB_SECURITY
9470 : : static int
9471 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9472 : : enum rte_security_session_protocol proto)
9473 : : {
9474 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9475 : :
9476 : : const struct rte_security_capability *capabilities;
9477 : : const struct rte_security_capability *capability;
9478 : : uint16_t i = 0;
9479 : :
9480 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9481 : :
9482 : :
9483 : 0 : capabilities = rte_security_capabilities_get(ctx);
9484 : :
9485 [ # # ]: 0 : if (capabilities == NULL)
9486 : : return -ENOTSUP;
9487 : :
9488 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9489 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9490 [ # # ]: 0 : if (capability->action == action &&
9491 [ # # ]: 0 : capability->protocol == proto)
9492 : : return 0;
9493 : : }
9494 : :
9495 : : return -ENOTSUP;
9496 : : }
9497 : :
9498 : : /* Basic algorithm run function for async inplace mode.
9499 : : * Creates a session from input parameters and runs one operation
9500 : : * on input_vec. Checks the output of the crypto operation against
9501 : : * output_vec.
9502 : : */
9503 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9504 : : enum rte_crypto_auth_operation opa,
9505 : : const uint8_t *input_vec, unsigned int input_vec_len,
9506 : : const uint8_t *output_vec,
9507 : : unsigned int output_vec_len,
9508 : : enum rte_crypto_cipher_algorithm cipher_alg,
9509 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9510 : : enum rte_crypto_auth_algorithm auth_alg,
9511 : : const uint8_t *auth_key, uint32_t auth_key_len,
9512 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9513 : : uint8_t packet_direction, uint8_t sn_size,
9514 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9515 : : {
9516 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9517 : : struct crypto_unittest_params *ut_params = &unittest_params;
9518 : : uint8_t *plaintext;
9519 : : int ret = TEST_SUCCESS;
9520 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9521 : : struct rte_cryptodev_info dev_info;
9522 : : uint64_t feat_flags;
9523 : :
9524 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9525 : 0 : feat_flags = dev_info.feature_flags;
9526 : :
9527 : : /* Verify the capabilities */
9528 : : struct rte_security_capability_idx sec_cap_idx;
9529 : :
9530 : 0 : sec_cap_idx.action = ut_params->type;
9531 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9532 : 0 : sec_cap_idx.pdcp.domain = domain;
9533 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9534 : : return TEST_SKIPPED;
9535 : :
9536 : : /* Generate test mbuf data */
9537 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9538 : :
9539 : : /* clear mbuf payload */
9540 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9541 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9542 : :
9543 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9544 : : input_vec_len);
9545 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9546 : :
9547 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9548 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9549 : : printf("Device does not support RAW data-path APIs.\n");
9550 : 0 : return TEST_SKIPPED;
9551 : : }
9552 : : /* Out of place support */
9553 [ # # ]: 0 : if (oop) {
9554 : : /*
9555 : : * For out-of-place we need to alloc another mbuf
9556 : : */
9557 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9558 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9559 : : }
9560 : :
9561 : : /* Setup Cipher Parameters */
9562 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9563 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9564 : 0 : ut_params->cipher_xform.cipher.op = opc;
9565 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9566 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9567 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9568 : : packet_direction ? 4 : 0;
9569 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9570 : :
9571 : : /* Setup HMAC Parameters if ICV header is required */
9572 [ # # ]: 0 : if (auth_alg != 0) {
9573 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9574 : 0 : ut_params->auth_xform.next = NULL;
9575 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9576 : 0 : ut_params->auth_xform.auth.op = opa;
9577 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9578 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9579 : :
9580 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9581 : : } else {
9582 : 0 : ut_params->cipher_xform.next = NULL;
9583 : : }
9584 : :
9585 : 0 : struct rte_security_session_conf sess_conf = {
9586 : 0 : .action_type = ut_params->type,
9587 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9588 : : {.pdcp = {
9589 : : .bearer = bearer,
9590 : : .domain = domain,
9591 : : .pkt_dir = packet_direction,
9592 : : .sn_size = sn_size,
9593 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9594 : : /**
9595 : : * hfn can be set as pdcp_test_hfn[i]
9596 : : * if hfn_ovrd is not set. Here, PDCP
9597 : : * packet direction is just used to
9598 : : * run half of the cases with session
9599 : : * HFN and other half with per packet
9600 : : * HFN.
9601 : : */
9602 : : .hfn_threshold = hfn_threshold,
9603 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9604 : : .sdap_enabled = sdap,
9605 : : } },
9606 : : .crypto_xform = &ut_params->cipher_xform
9607 : : };
9608 : :
9609 : : /* Create security session */
9610 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9611 : : &sess_conf, ts_params->session_mpool);
9612 : :
9613 [ # # ]: 0 : if (!ut_params->sec_session) {
9614 : : printf("TestCase %s()-%d line %d failed %s: ",
9615 : : __func__, i, __LINE__, "Failed to allocate session");
9616 : : ret = TEST_FAILED;
9617 : 0 : goto on_err;
9618 : : }
9619 : :
9620 : : /* Generate crypto op data structure */
9621 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9622 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9623 [ # # ]: 0 : if (!ut_params->op) {
9624 : : printf("TestCase %s()-%d line %d failed %s: ",
9625 : : __func__, i, __LINE__,
9626 : : "Failed to allocate symmetric crypto operation struct");
9627 : : ret = TEST_FAILED;
9628 : 0 : goto on_err;
9629 : : }
9630 : :
9631 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9632 : : uint32_t *, IV_OFFSET);
9633 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9634 : :
9635 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9636 : :
9637 : : /* set crypto operation source mbuf */
9638 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9639 [ # # ]: 0 : if (oop)
9640 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9641 : :
9642 : : /* Process crypto operation */
9643 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9644 : : /* filling lengths */
9645 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9646 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9647 : :
9648 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9649 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9650 : : return ret;
9651 : : } else {
9652 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9653 : : }
9654 [ # # ]: 0 : if (ut_params->op == NULL) {
9655 : : printf("TestCase %s()-%d line %d failed %s: ",
9656 : : __func__, i, __LINE__,
9657 : : "failed to process sym crypto op");
9658 : : ret = TEST_FAILED;
9659 : 0 : goto on_err;
9660 : : }
9661 : :
9662 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9663 : : printf("TestCase %s()-%d line %d failed %s: ",
9664 : : __func__, i, __LINE__, "crypto op processing failed");
9665 : : ret = TEST_FAILED;
9666 : 0 : goto on_err;
9667 : : }
9668 : :
9669 : : /* Validate obuf */
9670 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9671 : : uint8_t *);
9672 [ # # ]: 0 : if (oop) {
9673 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9674 : : uint8_t *);
9675 : : }
9676 : :
9677 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9678 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9679 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9680 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9681 : : ret = TEST_FAILED;
9682 : 0 : goto on_err;
9683 : : }
9684 : :
9685 : 0 : on_err:
9686 : 0 : rte_crypto_op_free(ut_params->op);
9687 : 0 : ut_params->op = NULL;
9688 : :
9689 [ # # ]: 0 : if (ut_params->sec_session)
9690 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9691 : 0 : ut_params->sec_session = NULL;
9692 : :
9693 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9694 : 0 : ut_params->ibuf = NULL;
9695 [ # # ]: 0 : if (oop) {
9696 : 0 : rte_pktmbuf_free(ut_params->obuf);
9697 : 0 : ut_params->obuf = NULL;
9698 : : }
9699 : :
9700 : : return ret;
9701 : : }
9702 : :
9703 : : static int
9704 : 0 : test_pdcp_proto_SGL(int i, int oop,
9705 : : enum rte_crypto_cipher_operation opc,
9706 : : enum rte_crypto_auth_operation opa,
9707 : : uint8_t *input_vec,
9708 : : unsigned int input_vec_len,
9709 : : uint8_t *output_vec,
9710 : : unsigned int output_vec_len,
9711 : : uint32_t fragsz,
9712 : : uint32_t fragsz_oop)
9713 : : {
9714 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9715 : : struct crypto_unittest_params *ut_params = &unittest_params;
9716 : : uint8_t *plaintext;
9717 : : struct rte_mbuf *buf, *buf_oop = NULL;
9718 : : int ret = TEST_SUCCESS;
9719 : : int to_trn = 0;
9720 : : int to_trn_tbl[16];
9721 : : unsigned int trn_data = 0;
9722 : : struct rte_cryptodev_info dev_info;
9723 : : uint64_t feat_flags;
9724 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9725 : : struct rte_mbuf *temp_mbuf;
9726 : :
9727 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9728 : 0 : feat_flags = dev_info.feature_flags;
9729 : :
9730 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9731 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9732 : : printf("Device does not support RAW data-path APIs.\n");
9733 : 0 : return -ENOTSUP;
9734 : : }
9735 : : /* Verify the capabilities */
9736 : : struct rte_security_capability_idx sec_cap_idx;
9737 : :
9738 : 0 : sec_cap_idx.action = ut_params->type;
9739 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9740 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9741 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9742 : : return TEST_SKIPPED;
9743 : :
9744 : : if (fragsz > input_vec_len)
9745 : : fragsz = input_vec_len;
9746 : :
9747 : 0 : uint16_t plaintext_len = fragsz;
9748 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9749 : :
9750 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9751 : 0 : frag_size_oop = output_vec_len;
9752 : :
9753 : : int ecx = 0;
9754 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9755 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9756 : : return 1;
9757 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9758 : : return 1;
9759 : :
9760 : : /* Out of place support */
9761 [ # # ]: 0 : if (oop) {
9762 : : /*
9763 : : * For out-of-place we need to alloc another mbuf
9764 : : */
9765 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9766 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9767 : 0 : buf_oop = ut_params->obuf;
9768 : : }
9769 : :
9770 : : /* Generate test mbuf data */
9771 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9772 : :
9773 : : /* clear mbuf payload */
9774 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9775 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9776 : :
9777 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9778 : : plaintext_len);
9779 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9780 : : trn_data += plaintext_len;
9781 : :
9782 : 0 : buf = ut_params->ibuf;
9783 : :
9784 : : /*
9785 : : * Loop until no more fragments
9786 : : */
9787 : :
9788 [ # # ]: 0 : while (trn_data < input_vec_len) {
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 [ # # ]: 0 : ut_params->ibuf->nb_segs++;
9797 : :
9798 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9799 : : rte_pktmbuf_tailroom(buf));
9800 : :
9801 : : /* OOP */
9802 [ # # ]: 0 : if (oop && !fragsz_oop) {
9803 : 0 : buf_oop->next =
9804 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9805 : : buf_oop = buf_oop->next;
9806 [ # # ]: 0 : ut_params->obuf->nb_segs++;
9807 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9808 : : 0, rte_pktmbuf_tailroom(buf_oop));
9809 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "Output buffer not initialized");
9810 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
9811 : : }
9812 : :
9813 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9814 : : to_trn);
9815 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
9816 : :
9817 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9818 : 0 : trn_data += to_trn;
9819 : : }
9820 : :
9821 [ # # ]: 0 : if (fragsz_oop && oop) {
9822 : : to_trn = 0;
9823 : : ecx = 0;
9824 : :
9825 : 0 : trn_data = frag_size_oop;
9826 [ # # ]: 0 : while (trn_data < output_vec_len) {
9827 : 0 : to_trn =
9828 : 0 : (output_vec_len - trn_data <
9829 : : frag_size_oop) ?
9830 : 0 : (output_vec_len - trn_data) :
9831 : : frag_size_oop;
9832 : :
9833 : 0 : to_trn_tbl[ecx++] = to_trn;
9834 : :
9835 : 0 : buf_oop->next =
9836 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9837 : : buf_oop = buf_oop->next;
9838 : 0 : ut_params->obuf->nb_segs++;
9839 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9840 : : 0, rte_pktmbuf_tailroom(buf_oop));
9841 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
9842 : :
9843 : 0 : trn_data += to_trn;
9844 : : }
9845 : : }
9846 : :
9847 : : /* Setup Cipher Parameters */
9848 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9849 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9850 : 0 : ut_params->cipher_xform.cipher.op = opc;
9851 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9852 : 0 : ut_params->cipher_xform.cipher.key.length =
9853 : 0 : pdcp_test_params[i].cipher_key_len;
9854 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9855 : :
9856 : : /* Setup HMAC Parameters if ICV header is required */
9857 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9858 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9859 : 0 : ut_params->auth_xform.next = NULL;
9860 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9861 : 0 : ut_params->auth_xform.auth.op = opa;
9862 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9863 : 0 : ut_params->auth_xform.auth.key.length =
9864 : 0 : pdcp_test_params[i].auth_key_len;
9865 : :
9866 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9867 : : } else {
9868 : 0 : ut_params->cipher_xform.next = NULL;
9869 : : }
9870 : :
9871 : 0 : struct rte_security_session_conf sess_conf = {
9872 : 0 : .action_type = ut_params->type,
9873 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9874 : : {.pdcp = {
9875 : 0 : .bearer = pdcp_test_bearer[i],
9876 : 0 : .domain = pdcp_test_params[i].domain,
9877 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9878 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9879 : 0 : .hfn = pdcp_test_hfn[i],
9880 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9881 : : .hfn_ovrd = 0,
9882 : : } },
9883 : : .crypto_xform = &ut_params->cipher_xform
9884 : : };
9885 : :
9886 : : /* Create security session */
9887 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9888 : : &sess_conf, ts_params->session_mpool);
9889 : :
9890 [ # # ]: 0 : if (!ut_params->sec_session) {
9891 : : printf("TestCase %s()-%d line %d failed %s: ",
9892 : : __func__, i, __LINE__, "Failed to allocate session");
9893 : : ret = TEST_FAILED;
9894 : 0 : goto on_err;
9895 : : }
9896 : :
9897 : : /* Generate crypto op data structure */
9898 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9899 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9900 [ # # ]: 0 : if (!ut_params->op) {
9901 : : printf("TestCase %s()-%d line %d failed %s: ",
9902 : : __func__, i, __LINE__,
9903 : : "Failed to allocate symmetric crypto operation struct");
9904 : : ret = TEST_FAILED;
9905 : 0 : goto on_err;
9906 : : }
9907 : :
9908 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9909 : :
9910 : : /* set crypto operation source mbuf */
9911 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9912 [ # # ]: 0 : if (oop)
9913 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9914 : :
9915 : : /* Process crypto operation */
9916 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9917 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9918 : : /* filling lengths */
9919 [ # # ]: 0 : while (temp_mbuf) {
9920 : 0 : ut_params->op->sym->cipher.data.length
9921 : 0 : += temp_mbuf->pkt_len;
9922 : 0 : ut_params->op->sym->auth.data.length
9923 : 0 : += temp_mbuf->pkt_len;
9924 : 0 : temp_mbuf = temp_mbuf->next;
9925 : : }
9926 : :
9927 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9928 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9929 : : return ret;
9930 : : } else {
9931 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9932 : : ut_params->op);
9933 : : }
9934 [ # # ]: 0 : if (ut_params->op == NULL) {
9935 : : printf("TestCase %s()-%d line %d failed %s: ",
9936 : : __func__, i, __LINE__,
9937 : : "failed to process sym crypto op");
9938 : : ret = TEST_FAILED;
9939 : 0 : goto on_err;
9940 : : }
9941 : :
9942 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9943 : : printf("TestCase %s()-%d line %d failed %s: ",
9944 : : __func__, i, __LINE__, "crypto op processing failed");
9945 : : ret = TEST_FAILED;
9946 : 0 : goto on_err;
9947 : : }
9948 : :
9949 : : /* Validate obuf */
9950 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9951 : : uint8_t *);
9952 [ # # ]: 0 : if (oop) {
9953 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9954 : : uint8_t *);
9955 : : }
9956 [ # # ]: 0 : if (fragsz_oop)
9957 : 0 : fragsz = frag_size_oop;
9958 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9959 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9960 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9961 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9962 : : ret = TEST_FAILED;
9963 : 0 : goto on_err;
9964 : : }
9965 : :
9966 : 0 : buf = ut_params->op->sym->m_src->next;
9967 [ # # ]: 0 : if (oop)
9968 : 0 : buf = ut_params->op->sym->m_dst->next;
9969 : :
9970 : : unsigned int off = fragsz;
9971 : :
9972 : : ecx = 0;
9973 [ # # ]: 0 : while (buf) {
9974 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9975 : : uint8_t *);
9976 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9977 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9978 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9979 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9980 : : to_trn_tbl[ecx]);
9981 : : ret = TEST_FAILED;
9982 : 0 : goto on_err;
9983 : : }
9984 : 0 : off += to_trn_tbl[ecx++];
9985 : 0 : buf = buf->next;
9986 : : }
9987 : 0 : on_err:
9988 : 0 : rte_crypto_op_free(ut_params->op);
9989 : 0 : ut_params->op = NULL;
9990 : :
9991 [ # # ]: 0 : if (ut_params->sec_session)
9992 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9993 : 0 : ut_params->sec_session = NULL;
9994 : :
9995 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9996 : 0 : ut_params->ibuf = NULL;
9997 [ # # ]: 0 : if (oop) {
9998 : 0 : rte_pktmbuf_free(ut_params->obuf);
9999 : 0 : ut_params->obuf = NULL;
10000 : : }
10001 : :
10002 : : return ret;
10003 : : }
10004 : :
10005 : : int
10006 : 0 : test_pdcp_proto_cplane_encap(int i)
10007 : : {
10008 : 0 : return test_pdcp_proto(
10009 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10010 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10011 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10012 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10013 : 0 : pdcp_test_params[i].cipher_key_len,
10014 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10015 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10016 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10017 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10018 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10019 : : }
10020 : :
10021 : : int
10022 : 0 : test_pdcp_proto_uplane_encap(int i)
10023 : : {
10024 : 0 : return test_pdcp_proto(
10025 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10026 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10027 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10028 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10029 : 0 : pdcp_test_params[i].cipher_key_len,
10030 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10031 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10032 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10033 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10034 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10035 : : }
10036 : :
10037 : : int
10038 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
10039 : : {
10040 : 0 : return test_pdcp_proto(
10041 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10042 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10043 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10044 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10045 : 0 : pdcp_test_params[i].cipher_key_len,
10046 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10047 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10048 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10049 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10050 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10051 : : }
10052 : :
10053 : : int
10054 : 0 : test_pdcp_proto_cplane_decap(int i)
10055 : : {
10056 : 0 : return test_pdcp_proto(
10057 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10058 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10059 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10060 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10061 : 0 : pdcp_test_params[i].cipher_key_len,
10062 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10063 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10064 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10065 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10066 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10067 : : }
10068 : :
10069 : : int
10070 : 0 : test_pdcp_proto_uplane_decap(int i)
10071 : : {
10072 : 0 : return test_pdcp_proto(
10073 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10074 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10075 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10076 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10077 : 0 : pdcp_test_params[i].cipher_key_len,
10078 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10079 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10080 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10081 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10082 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10083 : : }
10084 : :
10085 : : int
10086 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
10087 : : {
10088 : 0 : return test_pdcp_proto(
10089 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10090 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10091 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10092 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10093 : 0 : pdcp_test_params[i].cipher_key_len,
10094 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10095 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10096 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10097 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10098 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10099 : : }
10100 : :
10101 : : static int
10102 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
10103 : : {
10104 : : /* i can be used for running any PDCP case
10105 : : * In this case it is uplane 12-bit AES-SNOW DL encap
10106 : : */
10107 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
10108 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
10109 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10110 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10111 : : pdcp_test_data_in[i],
10112 : : pdcp_test_data_in_len[i],
10113 : : pdcp_test_data_out[i],
10114 : 0 : pdcp_test_data_in_len[i]+4,
10115 : : 32, 0);
10116 : : }
10117 : : static int
10118 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
10119 : : {
10120 : : /* i can be used for running any PDCP case
10121 : : * In this case it is uplane 18-bit NULL-NULL DL encap
10122 : : */
10123 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10124 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10125 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10126 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10127 : : pdcp_test_data_in[i],
10128 : : pdcp_test_data_in_len[i],
10129 : : pdcp_test_data_out[i],
10130 : 0 : pdcp_test_data_in_len[i]+4,
10131 : : 32, 128);
10132 : : }
10133 : : static int
10134 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
10135 : : {
10136 : : /* i can be used for running any PDCP case
10137 : : * In this case it is uplane 18-bit AES DL encap
10138 : : */
10139 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10140 : : + DOWNLINK;
10141 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10142 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10143 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10144 : : pdcp_test_data_in[i],
10145 : : pdcp_test_data_in_len[i],
10146 : : pdcp_test_data_out[i],
10147 : : pdcp_test_data_in_len[i],
10148 : : 32, 40);
10149 : : }
10150 : : static int
10151 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
10152 : : {
10153 : : /* i can be used for running any PDCP case
10154 : : * In this case it is cplane 12-bit AES-ZUC DL encap
10155 : : */
10156 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10157 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10158 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10159 : : RTE_CRYPTO_AUTH_OP_GENERATE,
10160 : : pdcp_test_data_in[i],
10161 : : pdcp_test_data_in_len[i],
10162 : : pdcp_test_data_out[i],
10163 : 0 : pdcp_test_data_in_len[i]+4,
10164 : : 128, 32);
10165 : : }
10166 : :
10167 : : static int
10168 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
10169 : : {
10170 : : int i = 0, size = 0;
10171 : : int err, all_err = TEST_SUCCESS;
10172 : : const struct pdcp_sdap_test *cur_test;
10173 : :
10174 : : size = RTE_DIM(list_pdcp_sdap_tests);
10175 : :
10176 [ # # ]: 0 : for (i = 0; i < size; i++) {
10177 : : cur_test = &list_pdcp_sdap_tests[i];
10178 : 0 : err = test_pdcp_proto(
10179 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10180 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10181 : 0 : cur_test->in_len, cur_test->data_out,
10182 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10183 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
10184 : 0 : cur_test->param.cipher_key_len,
10185 : 0 : cur_test->param.auth_alg,
10186 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10187 : 0 : cur_test->bearer, cur_test->param.domain,
10188 : 0 : cur_test->packet_direction, cur_test->sn_size,
10189 : 0 : cur_test->hfn,
10190 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10191 [ # # ]: 0 : if (err) {
10192 : : printf("\t%d) %s: Encapsulation failed\n",
10193 : 0 : cur_test->test_idx,
10194 : 0 : cur_test->param.name);
10195 : : err = TEST_FAILED;
10196 : : } else {
10197 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10198 : 0 : cur_test->param.name);
10199 : : err = TEST_SUCCESS;
10200 : : }
10201 : 0 : all_err += err;
10202 : : }
10203 : :
10204 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10205 : :
10206 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10207 : : }
10208 : :
10209 : : static int
10210 : 0 : test_PDCP_PROTO_short_mac(void)
10211 : : {
10212 : : int i = 0, size = 0;
10213 : : int err, all_err = TEST_SUCCESS;
10214 : : const struct pdcp_short_mac_test *cur_test;
10215 : :
10216 : : size = RTE_DIM(list_pdcp_smac_tests);
10217 : :
10218 [ # # ]: 0 : for (i = 0; i < size; i++) {
10219 : : cur_test = &list_pdcp_smac_tests[i];
10220 : 0 : err = test_pdcp_proto(
10221 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10222 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10223 : 0 : cur_test->in_len, cur_test->data_out,
10224 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10225 : : RTE_CRYPTO_CIPHER_NULL, NULL,
10226 : 0 : 0, cur_test->param.auth_alg,
10227 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
10228 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
10229 : : 0, 0, 0);
10230 [ # # ]: 0 : if (err) {
10231 : : printf("\t%d) %s: Short MAC test failed\n",
10232 : 0 : cur_test->test_idx,
10233 : 0 : cur_test->param.name);
10234 : : err = TEST_FAILED;
10235 : : } else {
10236 : : printf("\t%d) %s: Short MAC test PASS\n",
10237 : 0 : cur_test->test_idx,
10238 : 0 : cur_test->param.name);
10239 : 0 : rte_hexdump(stdout, "MAC I",
10240 : 0 : cur_test->data_out + cur_test->in_len + 2,
10241 : : 2);
10242 : : err = TEST_SUCCESS;
10243 : : }
10244 : 0 : all_err += err;
10245 : : }
10246 : :
10247 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10248 : :
10249 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10250 : :
10251 : : }
10252 : :
10253 : : static int
10254 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
10255 : : {
10256 : : int i = 0, size = 0;
10257 : : int err, all_err = TEST_SUCCESS;
10258 : : const struct pdcp_sdap_test *cur_test;
10259 : :
10260 : : size = RTE_DIM(list_pdcp_sdap_tests);
10261 : :
10262 [ # # ]: 0 : for (i = 0; i < size; i++) {
10263 : : cur_test = &list_pdcp_sdap_tests[i];
10264 : 0 : err = test_pdcp_proto(
10265 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10266 : : RTE_CRYPTO_AUTH_OP_VERIFY,
10267 : 0 : cur_test->data_out,
10268 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10269 : 0 : cur_test->data_in, cur_test->in_len,
10270 : 0 : cur_test->param.cipher_alg,
10271 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
10272 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
10273 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
10274 : 0 : cur_test->param.domain, cur_test->packet_direction,
10275 : 0 : cur_test->sn_size, cur_test->hfn,
10276 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10277 [ # # ]: 0 : if (err) {
10278 : : printf("\t%d) %s: Decapsulation failed\n",
10279 : 0 : cur_test->test_idx,
10280 : 0 : cur_test->param.name);
10281 : : err = TEST_FAILED;
10282 : : } else {
10283 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10284 : 0 : cur_test->param.name);
10285 : : err = TEST_SUCCESS;
10286 : : }
10287 : 0 : all_err += err;
10288 : : }
10289 : :
10290 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10291 : :
10292 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10293 : : }
10294 : :
10295 : : static int
10296 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10297 : : struct crypto_unittest_params *ut_params,
10298 : : struct rte_security_ipsec_xform *ipsec_xform,
10299 : : const struct ipsec_test_data *td,
10300 : : const struct ipsec_test_flags *flags,
10301 : : int pkt_num)
10302 : : {
10303 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10304 : : enum rte_security_ipsec_sa_direction dir;
10305 : : int ret;
10306 : :
10307 : 0 : dir = ipsec_xform->direction;
10308 : :
10309 : : /* Generate crypto op data structure */
10310 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10311 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10312 [ # # ]: 0 : if (!ut_params->op) {
10313 : : printf("Could not allocate crypto op");
10314 : 0 : return TEST_FAILED;
10315 : : }
10316 : :
10317 : : /* Attach session to operation */
10318 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10319 : :
10320 : : /* Set crypto operation mbufs */
10321 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10322 : 0 : ut_params->op->sym->m_dst = NULL;
10323 : :
10324 : : /* Copy IV in crypto operation when IV generation is disabled */
10325 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10326 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10327 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10328 : : uint8_t *,
10329 : : IV_OFFSET);
10330 : : int len;
10331 : :
10332 [ # # ]: 0 : if (td->aead)
10333 : 0 : len = td->xform.aead.aead.iv.length;
10334 [ # # ]: 0 : else if (td->aes_gmac)
10335 : 0 : len = td->xform.chain.auth.auth.iv.length;
10336 : : else
10337 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10338 : :
10339 : 0 : memcpy(iv, td->iv.data, len);
10340 : : }
10341 : :
10342 : : /* Process crypto operation */
10343 : 0 : process_crypto_request(dev_id, ut_params->op);
10344 : :
10345 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10346 : :
10347 : 0 : rte_crypto_op_free(ut_params->op);
10348 : 0 : ut_params->op = NULL;
10349 : :
10350 : 0 : return ret;
10351 : : }
10352 : :
10353 : : static int
10354 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10355 : : struct crypto_unittest_params *ut_params,
10356 : : void *ctx)
10357 : : {
10358 : : uint64_t timeout, userdata;
10359 : : struct rte_ether_hdr *hdr;
10360 : : struct rte_mbuf *m;
10361 : : void **sec_sess;
10362 : : int ret;
10363 : :
10364 : : RTE_SET_USED(ts_params);
10365 : :
10366 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10367 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10368 : :
10369 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10370 : 0 : ut_params->ibuf->port = 0;
10371 : :
10372 : 0 : sec_sess = &ut_params->sec_session;
10373 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10374 : :
10375 [ # # ]: 0 : if (ret != 1)
10376 : : return TEST_FAILED;
10377 : :
10378 : 0 : ut_params->ibuf = NULL;
10379 : :
10380 : : /* Add a timeout for 1 s */
10381 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10382 : :
10383 : : do {
10384 : : /* Get packet from port 0, queue 0 */
10385 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10386 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10387 : :
10388 [ # # ]: 0 : if (ret == 0) {
10389 : : printf("Could not receive packets from ethdev\n");
10390 : 0 : return TEST_FAILED;
10391 : : }
10392 : :
10393 [ # # ]: 0 : if (m == NULL) {
10394 : : printf("Received mbuf is NULL\n");
10395 : 0 : return TEST_FAILED;
10396 : : }
10397 : :
10398 : 0 : ut_params->ibuf = m;
10399 : :
10400 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10401 : : printf("Received packet is not Rx security processed\n");
10402 : 0 : return TEST_FAILED;
10403 : : }
10404 : :
10405 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10406 : : printf("Received packet has failed Rx security processing\n");
10407 : 0 : return TEST_FAILED;
10408 : : }
10409 : :
10410 : : /*
10411 : : * 'ut_params' is set as userdata. Verify that the field is returned
10412 : : * correctly.
10413 : : */
10414 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10415 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10416 : : printf("Userdata retrieved not matching expected\n");
10417 : 0 : return TEST_FAILED;
10418 : : }
10419 : :
10420 : : /* Trim L2 header */
10421 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10422 : :
10423 : : return TEST_SUCCESS;
10424 : : }
10425 : :
10426 : : static int
10427 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10428 : : struct ipsec_test_data res_d[],
10429 : : int nb_td,
10430 : : bool silent,
10431 : : const struct ipsec_test_flags *flags)
10432 : : {
10433 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10434 : : 0x0000, 0x001a};
10435 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10436 : : 0xe82c, 0x4887};
10437 : : const struct rte_ipv4_hdr *ipv4 =
10438 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10439 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10440 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10441 : : struct crypto_unittest_params *ut_params = &unittest_params;
10442 : : struct rte_security_capability_idx sec_cap_idx;
10443 : : const struct rte_security_capability *sec_cap;
10444 : : struct rte_security_ipsec_xform ipsec_xform;
10445 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10446 : : enum rte_security_ipsec_sa_direction dir;
10447 : : struct ipsec_test_data *res_d_tmp = NULL;
10448 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10449 : : int salt_len, i, ret = TEST_SUCCESS;
10450 : : void *ctx;
10451 : : uint32_t src, dst;
10452 : : uint32_t verify;
10453 : :
10454 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10455 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10456 : :
10457 : : /* Use first test data to create session */
10458 : :
10459 : : /* Copy IPsec xform */
10460 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10461 : :
10462 : 0 : dir = ipsec_xform.direction;
10463 : 0 : verify = flags->tunnel_hdr_verify;
10464 : :
10465 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10466 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10467 : :
10468 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10469 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10470 : 0 : src += 1;
10471 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10472 : 0 : dst += 1;
10473 : : }
10474 : :
10475 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10476 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10477 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10478 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10479 : : sizeof(src));
10480 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10481 : : sizeof(dst));
10482 : :
10483 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10484 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10485 : :
10486 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10487 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10488 : :
10489 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10490 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10491 : :
10492 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10493 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10494 : : TEST_IPSEC_DSCP_VAL;
10495 : :
10496 : : } else {
10497 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10498 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10499 : :
10500 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10501 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10502 : : TEST_IPSEC_DSCP_VAL;
10503 : :
10504 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10505 : : sizeof(v6_src));
10506 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10507 : : sizeof(v6_dst));
10508 : : }
10509 : : }
10510 : :
10511 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10512 : :
10513 : 0 : sec_cap_idx.action = ut_params->type;
10514 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10515 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10516 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10517 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10518 : :
10519 [ # # ]: 0 : if (flags->udp_encap)
10520 : 0 : ipsec_xform.options.udp_encap = 1;
10521 : :
10522 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10523 [ # # ]: 0 : if (sec_cap == NULL)
10524 : : return TEST_SKIPPED;
10525 : :
10526 : : /* Copy cipher session parameters */
10527 [ # # ]: 0 : if (td[0].aead) {
10528 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10529 : : sizeof(ut_params->aead_xform));
10530 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10531 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10532 : :
10533 : : /* Verify crypto capabilities */
10534 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10535 [ # # ]: 0 : if (!silent)
10536 : 0 : RTE_LOG(INFO, USER1,
10537 : : "Crypto capabilities not supported\n");
10538 : 0 : return TEST_SKIPPED;
10539 : : }
10540 [ # # ]: 0 : } else if (td[0].auth_only) {
10541 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10542 : : sizeof(ut_params->auth_xform));
10543 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10544 : :
10545 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10546 [ # # ]: 0 : if (!silent)
10547 : 0 : RTE_LOG(INFO, USER1,
10548 : : "Auth crypto capabilities not supported\n");
10549 : 0 : return TEST_SKIPPED;
10550 : : }
10551 : : } else {
10552 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10553 : : sizeof(ut_params->cipher_xform));
10554 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10555 : : sizeof(ut_params->auth_xform));
10556 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10557 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10558 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10559 : :
10560 : : /* Verify crypto capabilities */
10561 : :
10562 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10563 [ # # ]: 0 : if (!silent)
10564 : 0 : RTE_LOG(INFO, USER1,
10565 : : "Cipher crypto capabilities not supported\n");
10566 : 0 : return TEST_SKIPPED;
10567 : : }
10568 : :
10569 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10570 [ # # ]: 0 : if (!silent)
10571 : 0 : RTE_LOG(INFO, USER1,
10572 : : "Auth crypto capabilities not supported\n");
10573 : 0 : return TEST_SKIPPED;
10574 : : }
10575 : : }
10576 : :
10577 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10578 : : return TEST_SKIPPED;
10579 : :
10580 : 0 : struct rte_security_session_conf sess_conf = {
10581 : 0 : .action_type = ut_params->type,
10582 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10583 : : };
10584 : :
10585 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac ||
10586 [ # # ]: 0 : (td[0].xform.chain.cipher.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR)) {
10587 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10588 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10589 : : }
10590 : :
10591 [ # # ]: 0 : if (td[0].aead) {
10592 : 0 : sess_conf.ipsec = ipsec_xform;
10593 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10594 [ # # ]: 0 : } else if (td[0].auth_only) {
10595 : 0 : sess_conf.ipsec = ipsec_xform;
10596 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10597 : : } else {
10598 : 0 : sess_conf.ipsec = ipsec_xform;
10599 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10600 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10601 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10602 : : } else {
10603 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10604 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10605 : : }
10606 : : }
10607 : :
10608 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10609 : 0 : sess_conf.userdata = ut_params;
10610 : :
10611 : : /* Create security session */
10612 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10613 : : ts_params->session_mpool);
10614 : :
10615 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10616 : : return TEST_SKIPPED;
10617 : :
10618 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10619 [ # # # # ]: 0 : if (flags->antireplay &&
10620 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10621 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10622 : 0 : ret = rte_security_session_update(ctx,
10623 : : ut_params->sec_session, &sess_conf);
10624 [ # # ]: 0 : if (ret) {
10625 : : printf("Could not update sequence number in "
10626 : : "session\n");
10627 : 0 : return TEST_SKIPPED;
10628 : : }
10629 : : }
10630 : :
10631 : : /* Copy test data before modification */
10632 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10633 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10634 : : ret = TEST_FAILED;
10635 : 0 : goto mbuf_free;
10636 : : }
10637 : :
10638 : : /* Setup source mbuf payload */
10639 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10640 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10641 : 0 : td[i].input_text.len, nb_segs, input_text);
10642 : : } else {
10643 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10644 : 0 : td[i].input_text.len, nb_segs, 0);
10645 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10646 : : }
10647 : :
10648 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10649 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10650 : : ctx);
10651 : : else
10652 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10653 : : ut_params,
10654 : : &ipsec_xform,
10655 : : &td[i], flags,
10656 : : i + 1);
10657 : :
10658 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10659 : 0 : goto mbuf_free;
10660 : :
10661 [ # # ]: 0 : if (res_d != NULL)
10662 : 0 : res_d_tmp = &res_d[i];
10663 : :
10664 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10665 : : res_d_tmp, silent, flags);
10666 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10667 : 0 : goto mbuf_free;
10668 : :
10669 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10670 : : flags, dir);
10671 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10672 : 0 : goto mbuf_free;
10673 : :
10674 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10675 : 0 : ut_params->ibuf = NULL;
10676 : : }
10677 : :
10678 : 0 : mbuf_free:
10679 [ # # ]: 0 : if (flags->use_ext_mbuf)
10680 : 0 : ext_mbuf_memzone_free(nb_segs);
10681 : :
10682 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10683 : 0 : ut_params->ibuf = NULL;
10684 : :
10685 [ # # ]: 0 : if (ut_params->sec_session)
10686 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10687 : 0 : ut_params->sec_session = NULL;
10688 : :
10689 : 0 : return ret;
10690 : : }
10691 : :
10692 : : static int
10693 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10694 : : {
10695 : : struct ipsec_test_data td_outb;
10696 : : struct ipsec_test_flags flags;
10697 : :
10698 : : memset(&flags, 0, sizeof(flags));
10699 : :
10700 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10701 : :
10702 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10703 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10704 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10705 : : /* Disable IV gen to be able to test with known vectors */
10706 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10707 : : }
10708 : :
10709 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10710 : : }
10711 : :
10712 : : static int
10713 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10714 : : {
10715 : : struct ipsec_test_data td_outb;
10716 : : struct ipsec_test_flags flags;
10717 : :
10718 : : memset(&flags, 0, sizeof(flags));
10719 [ # # ]: 0 : flags.use_ext_mbuf = true;
10720 : :
10721 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10722 : :
10723 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10724 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10725 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10726 : : /* Disable IV gen to be able to test with known vectors */
10727 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10728 : : }
10729 : :
10730 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10731 : : }
10732 : :
10733 : : static int
10734 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10735 : : {
10736 : : const struct ipsec_test_data *td = test_data;
10737 : : struct ipsec_test_flags flags;
10738 : : struct ipsec_test_data td_inb;
10739 : :
10740 : : memset(&flags, 0, sizeof(flags));
10741 : :
10742 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10743 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10744 : : else
10745 : : memcpy(&td_inb, td, sizeof(td_inb));
10746 : :
10747 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10748 : : }
10749 : :
10750 : : static int
10751 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10752 : : {
10753 : : struct ipsec_test_data td_outb;
10754 : : struct ipsec_test_flags flags;
10755 : :
10756 : : memset(&flags, 0, sizeof(flags));
10757 : 0 : flags.fragment = true;
10758 : :
10759 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10760 : :
10761 : : /* Disable IV gen to be able to test with known vectors */
10762 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10763 : :
10764 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10765 : : }
10766 : :
10767 : : static int
10768 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10769 : : {
10770 : : const struct ipsec_test_data *td = test_data;
10771 : : struct ipsec_test_flags flags;
10772 : : struct ipsec_test_data td_inb;
10773 : :
10774 : : memset(&flags, 0, sizeof(flags));
10775 : 0 : flags.rx_inject = true;
10776 : :
10777 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10778 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10779 : : else
10780 : : memcpy(&td_inb, td, sizeof(td_inb));
10781 : :
10782 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10783 : : }
10784 : :
10785 : : static int
10786 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject_multi_seg(const void *test_data)
10787 : : {
10788 : : const struct ipsec_test_data *td = test_data;
10789 : : struct ipsec_test_flags flags;
10790 : : struct ipsec_test_data td_inb;
10791 : :
10792 : : memset(&flags, 0, sizeof(flags));
10793 : 0 : flags.rx_inject = true;
10794 : 0 : flags.nb_segs_in_mbuf = 4;
10795 : :
10796 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10797 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10798 : : else
10799 : : memcpy(&td_inb, td, sizeof(td_inb));
10800 : :
10801 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10802 : : }
10803 : :
10804 : : static int
10805 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10806 : : {
10807 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10808 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10809 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10810 : : int ret;
10811 : :
10812 [ # # ]: 0 : if (flags->iv_gen ||
10813 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10814 : : flags->sa_expiry_pkts_hard)
10815 : : nb_pkts = TEST_SEC_PKTS_MAX;
10816 : :
10817 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10818 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10819 : : sec_alg_list[i].param2,
10820 : : flags,
10821 : : td_outb,
10822 : : nb_pkts);
10823 : :
10824 [ # # ]: 0 : if (!td_outb->aead) {
10825 : : enum rte_crypto_cipher_algorithm cipher_alg;
10826 : : enum rte_crypto_auth_algorithm auth_alg;
10827 : :
10828 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10829 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10830 : :
10831 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10832 : 0 : continue;
10833 : :
10834 : : /* ICV is not applicable for NULL auth */
10835 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10836 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10837 : 0 : continue;
10838 : :
10839 : : /* IV is not applicable for NULL cipher */
10840 [ # # # # ]: 0 : if (flags->iv_gen &&
10841 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10842 : 0 : continue;
10843 : : }
10844 : :
10845 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10846 : : flags);
10847 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10848 : 0 : continue;
10849 : :
10850 [ # # ]: 0 : if (ret == TEST_FAILED)
10851 : : return TEST_FAILED;
10852 : :
10853 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10854 : :
10855 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10856 : : flags);
10857 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10858 : 0 : continue;
10859 : :
10860 [ # # ]: 0 : if (ret == TEST_FAILED)
10861 : : return TEST_FAILED;
10862 : :
10863 [ # # ]: 0 : if (flags->display_alg)
10864 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10865 : :
10866 : 0 : pass_cnt++;
10867 : : }
10868 : :
10869 [ # # ]: 0 : if (pass_cnt > 0)
10870 : : return TEST_SUCCESS;
10871 : : else
10872 : 0 : return TEST_SKIPPED;
10873 : : }
10874 : :
10875 : : static int
10876 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10877 : : {
10878 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10879 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10880 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10881 : : int ret;
10882 : :
10883 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10884 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10885 : : sec_auth_only_alg_list[i].param2,
10886 : : flags,
10887 : : td_outb,
10888 : : nb_pkts);
10889 : :
10890 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10891 : : flags);
10892 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10893 : 0 : continue;
10894 : :
10895 [ # # ]: 0 : if (ret == TEST_FAILED)
10896 : : return TEST_FAILED;
10897 : :
10898 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10899 : :
10900 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10901 : : flags);
10902 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10903 : 0 : continue;
10904 : :
10905 [ # # ]: 0 : if (ret == TEST_FAILED)
10906 : : return TEST_FAILED;
10907 : :
10908 [ # # ]: 0 : if (flags->display_alg)
10909 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10910 : : sec_auth_only_alg_list[i].param2);
10911 : :
10912 : 0 : pass_cnt++;
10913 : : }
10914 : :
10915 [ # # ]: 0 : if (pass_cnt > 0)
10916 : : return TEST_SUCCESS;
10917 : : else
10918 : 0 : return TEST_SKIPPED;
10919 : : }
10920 : :
10921 : : static int
10922 : 0 : test_ipsec_proto_display_list(void)
10923 : : {
10924 : : struct ipsec_test_flags flags;
10925 : :
10926 : : memset(&flags, 0, sizeof(flags));
10927 : :
10928 : 0 : flags.display_alg = true;
10929 : :
10930 : 0 : return test_ipsec_proto_all(&flags);
10931 : : }
10932 : :
10933 : : static int
10934 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10935 : : {
10936 : : struct ipsec_test_flags flags;
10937 : :
10938 : : memset(&flags, 0, sizeof(flags));
10939 : :
10940 : 0 : flags.ah = true;
10941 : 0 : flags.display_alg = true;
10942 : :
10943 : 0 : return test_ipsec_ah_proto_all(&flags);
10944 : : }
10945 : :
10946 : : static int
10947 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10948 : : {
10949 : : struct ipsec_test_flags flags;
10950 : :
10951 : : memset(&flags, 0, sizeof(flags));
10952 : :
10953 : 0 : flags.ah = true;
10954 : 0 : flags.transport = true;
10955 : :
10956 : 0 : return test_ipsec_ah_proto_all(&flags);
10957 : : }
10958 : :
10959 : : static int
10960 : 0 : test_ipsec_proto_iv_gen(void)
10961 : : {
10962 : : struct ipsec_test_flags flags;
10963 : :
10964 : : memset(&flags, 0, sizeof(flags));
10965 : :
10966 : 0 : flags.iv_gen = true;
10967 : :
10968 : 0 : return test_ipsec_proto_all(&flags);
10969 : : }
10970 : :
10971 : : static int
10972 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10973 : : {
10974 : : struct ipsec_test_flags flags;
10975 : :
10976 : : memset(&flags, 0, sizeof(flags));
10977 : :
10978 : 0 : flags.sa_expiry_pkts_soft = true;
10979 : :
10980 : 0 : return test_ipsec_proto_all(&flags);
10981 : : }
10982 : :
10983 : : static int
10984 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10985 : : {
10986 : : struct ipsec_test_flags flags;
10987 : :
10988 : : memset(&flags, 0, sizeof(flags));
10989 : :
10990 : 0 : flags.sa_expiry_pkts_hard = true;
10991 : :
10992 : 0 : return test_ipsec_proto_all(&flags);
10993 : : }
10994 : :
10995 : : static int
10996 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10997 : : {
10998 : : struct ipsec_test_flags flags;
10999 : :
11000 : : memset(&flags, 0, sizeof(flags));
11001 : :
11002 : 0 : flags.icv_corrupt = true;
11003 : :
11004 : 0 : return test_ipsec_proto_all(&flags);
11005 : : }
11006 : :
11007 : : static int
11008 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
11009 : : {
11010 : : struct ipsec_test_flags flags;
11011 : :
11012 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11013 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
11014 : : return TEST_SKIPPED;
11015 : :
11016 : : memset(&flags, 0, sizeof(flags));
11017 : :
11018 : 0 : flags.udp_encap = true;
11019 : 0 : flags.udp_encap_custom_ports = true;
11020 : :
11021 : 0 : return test_ipsec_proto_all(&flags);
11022 : : }
11023 : :
11024 : : static int
11025 : 0 : test_ipsec_proto_udp_encap(void)
11026 : : {
11027 : : struct ipsec_test_flags flags;
11028 : :
11029 : : memset(&flags, 0, sizeof(flags));
11030 : :
11031 : 0 : flags.udp_encap = true;
11032 : :
11033 : 0 : return test_ipsec_proto_all(&flags);
11034 : : }
11035 : :
11036 : : static int
11037 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
11038 : : {
11039 : : struct ipsec_test_flags flags;
11040 : :
11041 : : memset(&flags, 0, sizeof(flags));
11042 : :
11043 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
11044 : :
11045 : 0 : return test_ipsec_proto_all(&flags);
11046 : : }
11047 : :
11048 : : static int
11049 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
11050 : : {
11051 : : struct ipsec_test_flags flags;
11052 : :
11053 : : memset(&flags, 0, sizeof(flags));
11054 : :
11055 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
11056 : :
11057 : 0 : return test_ipsec_proto_all(&flags);
11058 : : }
11059 : :
11060 : : static int
11061 : 0 : test_ipsec_proto_udp_ports_verify(void)
11062 : : {
11063 : : struct ipsec_test_flags flags;
11064 : :
11065 : : memset(&flags, 0, sizeof(flags));
11066 : :
11067 : 0 : flags.udp_encap = true;
11068 : 0 : flags.udp_ports_verify = true;
11069 : :
11070 : 0 : return test_ipsec_proto_all(&flags);
11071 : : }
11072 : :
11073 : : static int
11074 : 0 : test_ipsec_proto_inner_ip_csum(void)
11075 : : {
11076 : : struct ipsec_test_flags flags;
11077 : :
11078 : : memset(&flags, 0, sizeof(flags));
11079 : :
11080 : 0 : flags.ip_csum = true;
11081 : :
11082 : 0 : return test_ipsec_proto_all(&flags);
11083 : : }
11084 : :
11085 : : static int
11086 : 0 : test_ipsec_proto_inner_l4_csum(void)
11087 : : {
11088 : : struct ipsec_test_flags flags;
11089 : :
11090 : : memset(&flags, 0, sizeof(flags));
11091 : :
11092 : 0 : flags.l4_csum = true;
11093 : :
11094 : 0 : return test_ipsec_proto_all(&flags);
11095 : : }
11096 : :
11097 : : static int
11098 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
11099 : : {
11100 : : struct ipsec_test_flags flags;
11101 : :
11102 : : memset(&flags, 0, sizeof(flags));
11103 : :
11104 : : flags.ipv6 = false;
11105 : : flags.tunnel_ipv6 = false;
11106 : :
11107 : 0 : return test_ipsec_proto_all(&flags);
11108 : : }
11109 : :
11110 : : static int
11111 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
11112 : : {
11113 : : struct ipsec_test_flags flags;
11114 : :
11115 : : memset(&flags, 0, sizeof(flags));
11116 : :
11117 : 0 : flags.ipv6 = true;
11118 : 0 : flags.tunnel_ipv6 = true;
11119 : :
11120 : 0 : return test_ipsec_proto_all(&flags);
11121 : : }
11122 : :
11123 : : static int
11124 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
11125 : : {
11126 : : struct ipsec_test_flags flags;
11127 : :
11128 : : memset(&flags, 0, sizeof(flags));
11129 : :
11130 : : flags.ipv6 = false;
11131 : 0 : flags.tunnel_ipv6 = true;
11132 : :
11133 : 0 : return test_ipsec_proto_all(&flags);
11134 : : }
11135 : :
11136 : : static int
11137 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
11138 : : {
11139 : : struct ipsec_test_flags flags;
11140 : :
11141 : : memset(&flags, 0, sizeof(flags));
11142 : :
11143 : 0 : flags.ipv6 = true;
11144 : : flags.tunnel_ipv6 = false;
11145 : :
11146 : 0 : return test_ipsec_proto_all(&flags);
11147 : : }
11148 : :
11149 : : static int
11150 : 0 : test_ipsec_proto_transport_v4(void)
11151 : : {
11152 : : struct ipsec_test_flags flags;
11153 : :
11154 : : memset(&flags, 0, sizeof(flags));
11155 : :
11156 : : flags.ipv6 = false;
11157 : 0 : flags.transport = true;
11158 : :
11159 : 0 : return test_ipsec_proto_all(&flags);
11160 : : }
11161 : :
11162 : : static int
11163 : 0 : test_ipsec_proto_transport_l4_csum(void)
11164 : : {
11165 : 0 : struct ipsec_test_flags flags = {
11166 : : .l4_csum = true,
11167 : : .transport = true,
11168 : : };
11169 : :
11170 : 0 : return test_ipsec_proto_all(&flags);
11171 : : }
11172 : :
11173 : : static int
11174 : 0 : test_ipsec_proto_stats(void)
11175 : : {
11176 : : struct ipsec_test_flags flags;
11177 : :
11178 : : memset(&flags, 0, sizeof(flags));
11179 : :
11180 : 0 : flags.stats_success = true;
11181 : :
11182 : 0 : return test_ipsec_proto_all(&flags);
11183 : : }
11184 : :
11185 : : static int
11186 : 0 : test_ipsec_proto_pkt_fragment(void)
11187 : : {
11188 : : struct ipsec_test_flags flags;
11189 : :
11190 : : memset(&flags, 0, sizeof(flags));
11191 : :
11192 : 0 : flags.fragment = true;
11193 : :
11194 : 0 : return test_ipsec_proto_all(&flags);
11195 : :
11196 : : }
11197 : :
11198 : : static int
11199 : 0 : test_ipsec_proto_copy_df_inner_0(void)
11200 : : {
11201 : : struct ipsec_test_flags flags;
11202 : :
11203 : : memset(&flags, 0, sizeof(flags));
11204 : :
11205 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11206 : :
11207 : 0 : return test_ipsec_proto_all(&flags);
11208 : : }
11209 : :
11210 : : static int
11211 : 0 : test_ipsec_proto_copy_df_inner_1(void)
11212 : : {
11213 : : struct ipsec_test_flags flags;
11214 : :
11215 : : memset(&flags, 0, sizeof(flags));
11216 : :
11217 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11218 : :
11219 : 0 : return test_ipsec_proto_all(&flags);
11220 : : }
11221 : :
11222 : : static int
11223 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
11224 : : {
11225 : : struct ipsec_test_flags flags;
11226 : :
11227 : : memset(&flags, 0, sizeof(flags));
11228 : :
11229 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11230 : :
11231 : 0 : return test_ipsec_proto_all(&flags);
11232 : : }
11233 : :
11234 : : static int
11235 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
11236 : : {
11237 : : struct ipsec_test_flags flags;
11238 : :
11239 : : memset(&flags, 0, sizeof(flags));
11240 : :
11241 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11242 : :
11243 : 0 : return test_ipsec_proto_all(&flags);
11244 : : }
11245 : :
11246 : : static int
11247 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11248 : : {
11249 : : struct ipsec_test_flags flags;
11250 : :
11251 : : memset(&flags, 0, sizeof(flags));
11252 : :
11253 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11254 : :
11255 : 0 : return test_ipsec_proto_all(&flags);
11256 : : }
11257 : :
11258 : : static int
11259 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11260 : : {
11261 : : struct ipsec_test_flags flags;
11262 : :
11263 : : memset(&flags, 0, sizeof(flags));
11264 : :
11265 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11266 : :
11267 : 0 : return test_ipsec_proto_all(&flags);
11268 : : }
11269 : :
11270 : : static int
11271 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11272 : : {
11273 : : struct ipsec_test_flags flags;
11274 : :
11275 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11276 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11277 : : return TEST_SKIPPED;
11278 : :
11279 : : memset(&flags, 0, sizeof(flags));
11280 : :
11281 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11282 : :
11283 : 0 : return test_ipsec_proto_all(&flags);
11284 : : }
11285 : :
11286 : : static int
11287 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11288 : : {
11289 : : struct ipsec_test_flags flags;
11290 : :
11291 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11292 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11293 : : return TEST_SKIPPED;
11294 : :
11295 : : memset(&flags, 0, sizeof(flags));
11296 : :
11297 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11298 : :
11299 : 0 : return test_ipsec_proto_all(&flags);
11300 : : }
11301 : :
11302 : : static int
11303 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11304 : : {
11305 : : struct ipsec_test_flags flags;
11306 : :
11307 : : memset(&flags, 0, sizeof(flags));
11308 : :
11309 : 0 : flags.ipv6 = true;
11310 : 0 : flags.tunnel_ipv6 = true;
11311 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11312 : :
11313 : 0 : return test_ipsec_proto_all(&flags);
11314 : : }
11315 : :
11316 : : static int
11317 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11318 : : {
11319 : : struct ipsec_test_flags flags;
11320 : :
11321 : : memset(&flags, 0, sizeof(flags));
11322 : :
11323 : 0 : flags.ipv6 = true;
11324 : 0 : flags.tunnel_ipv6 = true;
11325 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11326 : :
11327 : 0 : return test_ipsec_proto_all(&flags);
11328 : : }
11329 : :
11330 : : static int
11331 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11332 : : {
11333 : : struct ipsec_test_flags flags;
11334 : :
11335 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11336 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11337 : : return TEST_SKIPPED;
11338 : :
11339 : : memset(&flags, 0, sizeof(flags));
11340 : :
11341 : 0 : flags.ipv6 = true;
11342 : 0 : flags.tunnel_ipv6 = true;
11343 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11344 : :
11345 : 0 : return test_ipsec_proto_all(&flags);
11346 : : }
11347 : :
11348 : : static int
11349 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11350 : : {
11351 : : struct ipsec_test_flags flags;
11352 : :
11353 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11354 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11355 : : return TEST_SKIPPED;
11356 : :
11357 : : memset(&flags, 0, sizeof(flags));
11358 : :
11359 : 0 : flags.ipv6 = true;
11360 : 0 : flags.tunnel_ipv6 = true;
11361 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11362 : :
11363 : 0 : return test_ipsec_proto_all(&flags);
11364 : : }
11365 : :
11366 : : static int
11367 : 0 : test_ipsec_proto_sgl(void)
11368 : : {
11369 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11370 : : struct rte_cryptodev_info dev_info;
11371 : :
11372 : 0 : struct ipsec_test_flags flags = {
11373 : : .nb_segs_in_mbuf = 5
11374 : : };
11375 : :
11376 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11377 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11378 : : printf("Device doesn't support in-place scatter-gather. "
11379 : : "Test Skipped.\n");
11380 : 0 : return TEST_SKIPPED;
11381 : : }
11382 : :
11383 : 0 : return test_ipsec_proto_all(&flags);
11384 : : }
11385 : :
11386 : : static int
11387 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11388 : : {
11389 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11390 : : struct rte_cryptodev_info dev_info;
11391 : :
11392 : 0 : struct ipsec_test_flags flags = {
11393 : : .nb_segs_in_mbuf = 5,
11394 : : .use_ext_mbuf = 1
11395 : : };
11396 : :
11397 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11398 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11399 : : printf("Device doesn't support in-place scatter-gather. "
11400 : : "Test Skipped.\n");
11401 : 0 : return TEST_SKIPPED;
11402 : : }
11403 : :
11404 : 0 : return test_ipsec_proto_all(&flags);
11405 : : }
11406 : :
11407 : : static int
11408 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11409 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11410 : : uint64_t winsz)
11411 : : {
11412 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11413 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11414 : : struct ipsec_test_flags flags;
11415 : : uint32_t i = 0, ret = 0;
11416 : :
11417 [ # # ]: 0 : if (nb_pkts == 0)
11418 : : return TEST_FAILED;
11419 : :
11420 : : memset(&flags, 0, sizeof(flags));
11421 : 0 : flags.antireplay = true;
11422 : :
11423 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11424 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11425 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11426 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11427 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11428 : : }
11429 : :
11430 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11431 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11432 : :
11433 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11434 : : &flags);
11435 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11436 : : return ret;
11437 : :
11438 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11439 : :
11440 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11441 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11442 : : /* Set antireplay flag for packets to be dropped */
11443 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11444 : : }
11445 : :
11446 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11447 : : &flags);
11448 : :
11449 : 0 : return ret;
11450 : : }
11451 : :
11452 : : static int
11453 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11454 : : {
11455 : :
11456 : : uint32_t nb_pkts = 5;
11457 : : bool replayed_pkt[5];
11458 : : uint64_t esn[5];
11459 : :
11460 : : /* 1. Advance the TOP of the window to WS * 2 */
11461 : 0 : esn[0] = winsz * 2;
11462 : : /* 2. Test sequence number within the new window(WS + 1) */
11463 : 0 : esn[1] = winsz + 1;
11464 : : /* 3. Test sequence number less than the window BOTTOM */
11465 : 0 : esn[2] = winsz;
11466 : : /* 4. Test sequence number in the middle of the window */
11467 : 0 : esn[3] = winsz + (winsz / 2);
11468 : : /* 5. Test replay of the packet in the middle of the window */
11469 : 0 : esn[4] = winsz + (winsz / 2);
11470 : :
11471 : 0 : replayed_pkt[0] = false;
11472 : 0 : replayed_pkt[1] = false;
11473 : 0 : replayed_pkt[2] = true;
11474 : 0 : replayed_pkt[3] = false;
11475 : 0 : replayed_pkt[4] = true;
11476 : :
11477 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11478 : : false, winsz);
11479 : : }
11480 : :
11481 : : static int
11482 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11483 : : {
11484 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11485 : : }
11486 : :
11487 : : static int
11488 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11489 : : {
11490 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11491 : : }
11492 : :
11493 : : static int
11494 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11495 : : {
11496 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11497 : : }
11498 : :
11499 : : static int
11500 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11501 : : {
11502 : :
11503 : : uint32_t nb_pkts = 7;
11504 : : bool replayed_pkt[7];
11505 : : uint64_t esn[7];
11506 : :
11507 : : /* Set the initial sequence number */
11508 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11509 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11510 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11511 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11512 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11513 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11514 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11515 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11516 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11517 : : /* 5. Test with duplicate sequence number within
11518 : : * new window (1<<32 - 1)
11519 : : */
11520 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11521 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11522 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11523 : :
11524 : 0 : replayed_pkt[0] = false;
11525 : 0 : replayed_pkt[1] = false;
11526 : 0 : replayed_pkt[2] = false;
11527 : 0 : replayed_pkt[3] = false;
11528 : 0 : replayed_pkt[4] = false;
11529 : 0 : replayed_pkt[5] = true;
11530 : 0 : replayed_pkt[6] = true;
11531 : :
11532 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11533 : : true, winsz);
11534 : : }
11535 : :
11536 : : static int
11537 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11538 : : {
11539 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11540 : : }
11541 : :
11542 : : static int
11543 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11544 : : {
11545 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11546 : : }
11547 : :
11548 : : static int
11549 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11550 : : {
11551 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11552 : : }
11553 : :
11554 : : static int
11555 : 0 : test_PDCP_PROTO_all(void)
11556 : : {
11557 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11558 : : struct crypto_unittest_params *ut_params = &unittest_params;
11559 : : struct rte_cryptodev_info dev_info;
11560 : : int status;
11561 : :
11562 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11563 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11564 : :
11565 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11566 : : return TEST_SKIPPED;
11567 : :
11568 : : /* Set action type */
11569 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11570 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11571 : : gbl_action_type;
11572 : :
11573 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11574 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11575 : : return TEST_SKIPPED;
11576 : :
11577 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11578 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11579 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11580 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11581 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11582 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11583 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11584 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11585 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11586 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11587 : 0 : status += test_PDCP_PROTO_short_mac();
11588 : :
11589 [ # # ]: 0 : if (status)
11590 : : return TEST_FAILED;
11591 : : else
11592 : 0 : return TEST_SUCCESS;
11593 : : }
11594 : :
11595 : : static int
11596 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11597 : : {
11598 : 0 : struct ipsec_test_flags flags = {
11599 : : .dec_ttl_or_hop_limit = true
11600 : : };
11601 : :
11602 : 0 : return test_ipsec_proto_all(&flags);
11603 : : }
11604 : :
11605 : : static int
11606 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11607 : : {
11608 : 0 : struct ipsec_test_flags flags = {
11609 : : .ipv6 = true,
11610 : : .dec_ttl_or_hop_limit = true
11611 : : };
11612 : :
11613 : 0 : return test_ipsec_proto_all(&flags);
11614 : : }
11615 : :
11616 : : static int
11617 : 0 : test_docsis_proto_uplink(const void *data)
11618 : : {
11619 : : const struct docsis_test_data *d_td = data;
11620 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11621 : : struct crypto_unittest_params *ut_params = &unittest_params;
11622 : : uint8_t *plaintext = NULL;
11623 : : uint8_t *ciphertext = NULL;
11624 : : uint8_t *iv_ptr;
11625 : : int32_t cipher_len, crc_len;
11626 : : uint32_t crc_data_len;
11627 : : int ret = TEST_SUCCESS;
11628 : :
11629 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11630 : :
11631 : : /* Verify the capabilities */
11632 : : struct rte_security_capability_idx sec_cap_idx;
11633 : : const struct rte_security_capability *sec_cap;
11634 : : const struct rte_cryptodev_capabilities *crypto_cap;
11635 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11636 : : int j = 0;
11637 : :
11638 : : /* Set action type */
11639 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11640 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11641 : : gbl_action_type;
11642 : :
11643 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11644 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11645 : : return TEST_SKIPPED;
11646 : :
11647 : 0 : sec_cap_idx.action = ut_params->type;
11648 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11649 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11650 : :
11651 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11652 [ # # ]: 0 : if (sec_cap == NULL)
11653 : : return TEST_SKIPPED;
11654 : :
11655 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11656 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11657 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11658 : : crypto_cap->sym.xform_type ==
11659 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11660 : : crypto_cap->sym.cipher.algo ==
11661 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11662 : 0 : sym_cap = &crypto_cap->sym;
11663 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11664 : 0 : d_td->key.len,
11665 : 0 : d_td->iv.len) == 0)
11666 : : break;
11667 : : }
11668 : : }
11669 : :
11670 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11671 : : return TEST_SKIPPED;
11672 : :
11673 : : /* Setup source mbuf payload */
11674 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11675 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11676 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11677 : :
11678 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11679 : 0 : d_td->ciphertext.len);
11680 : :
11681 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11682 : :
11683 : : /* Setup cipher session parameters */
11684 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11685 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11686 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11687 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11688 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11689 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11690 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11691 : 0 : ut_params->cipher_xform.next = NULL;
11692 : :
11693 : : /* Setup DOCSIS session parameters */
11694 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11695 : :
11696 : 0 : struct rte_security_session_conf sess_conf = {
11697 : 0 : .action_type = ut_params->type,
11698 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11699 : : .docsis = ut_params->docsis_xform,
11700 : : .crypto_xform = &ut_params->cipher_xform,
11701 : : };
11702 : :
11703 : : /* Create security session */
11704 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11705 : : ts_params->session_mpool);
11706 : :
11707 [ # # ]: 0 : if (!ut_params->sec_session) {
11708 : : printf("Test function %s line %u: failed to allocate session\n",
11709 : : __func__, __LINE__);
11710 : : ret = TEST_FAILED;
11711 : 0 : goto on_err;
11712 : : }
11713 : :
11714 : : /* Generate crypto op data structure */
11715 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11716 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11717 [ # # ]: 0 : if (!ut_params->op) {
11718 : : printf("Test function %s line %u: failed to allocate symmetric "
11719 : : "crypto operation\n", __func__, __LINE__);
11720 : : ret = TEST_FAILED;
11721 : 0 : goto on_err;
11722 : : }
11723 : :
11724 : : /* Setup CRC operation parameters */
11725 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11726 : 0 : (d_td->ciphertext.len -
11727 : 0 : d_td->ciphertext.crc_offset -
11728 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11729 : : 0;
11730 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11731 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11732 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11733 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11734 : :
11735 : : /* Setup cipher operation parameters */
11736 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11737 : 0 : (d_td->ciphertext.len -
11738 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11739 : : 0;
11740 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11741 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11742 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11743 : :
11744 : : /* Setup cipher IV */
11745 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11746 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11747 : :
11748 : : /* Attach session to operation */
11749 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11750 : :
11751 : : /* Set crypto operation mbufs */
11752 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11753 : 0 : ut_params->op->sym->m_dst = NULL;
11754 : :
11755 : : /* Process crypto operation */
11756 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11757 : : NULL) {
11758 : : printf("Test function %s line %u: failed to process security "
11759 : : "crypto op\n", __func__, __LINE__);
11760 : : ret = TEST_FAILED;
11761 : 0 : goto on_err;
11762 : : }
11763 : :
11764 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11765 : : printf("Test function %s line %u: failed to process crypto op\n",
11766 : : __func__, __LINE__);
11767 : : ret = TEST_FAILED;
11768 : 0 : goto on_err;
11769 : : }
11770 : :
11771 : : /* Validate plaintext */
11772 : : plaintext = ciphertext;
11773 : :
11774 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11775 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11776 : : printf("Test function %s line %u: plaintext not as expected\n",
11777 : : __func__, __LINE__);
11778 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11779 : 0 : d_td->plaintext.len);
11780 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11781 : : ret = TEST_FAILED;
11782 : 0 : goto on_err;
11783 : : }
11784 : :
11785 : 0 : on_err:
11786 : 0 : rte_crypto_op_free(ut_params->op);
11787 : 0 : ut_params->op = NULL;
11788 : :
11789 [ # # ]: 0 : if (ut_params->sec_session)
11790 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11791 : 0 : ut_params->sec_session = NULL;
11792 : :
11793 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11794 : 0 : ut_params->ibuf = NULL;
11795 : :
11796 : 0 : return ret;
11797 : : }
11798 : :
11799 : : static int
11800 : 0 : test_docsis_proto_downlink(const void *data)
11801 : : {
11802 : : const struct docsis_test_data *d_td = data;
11803 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11804 : : struct crypto_unittest_params *ut_params = &unittest_params;
11805 : : uint8_t *plaintext = NULL;
11806 : : uint8_t *ciphertext = NULL;
11807 : : uint8_t *iv_ptr;
11808 : : int32_t cipher_len, crc_len;
11809 : : int ret = TEST_SUCCESS;
11810 : :
11811 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11812 : :
11813 : : /* Verify the capabilities */
11814 : : struct rte_security_capability_idx sec_cap_idx;
11815 : : const struct rte_security_capability *sec_cap;
11816 : : const struct rte_cryptodev_capabilities *crypto_cap;
11817 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11818 : : int j = 0;
11819 : :
11820 : : /* Set action type */
11821 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11822 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11823 : : gbl_action_type;
11824 : :
11825 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11826 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11827 : : return TEST_SKIPPED;
11828 : :
11829 : 0 : sec_cap_idx.action = ut_params->type;
11830 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11831 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11832 : :
11833 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11834 [ # # ]: 0 : if (sec_cap == NULL)
11835 : : return TEST_SKIPPED;
11836 : :
11837 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11838 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11839 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11840 : : crypto_cap->sym.xform_type ==
11841 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11842 : : crypto_cap->sym.cipher.algo ==
11843 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11844 : 0 : sym_cap = &crypto_cap->sym;
11845 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11846 : 0 : d_td->key.len,
11847 : 0 : d_td->iv.len) == 0)
11848 : : break;
11849 : : }
11850 : : }
11851 : :
11852 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11853 : : return TEST_SKIPPED;
11854 : :
11855 : : /* Setup source mbuf payload */
11856 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11857 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11858 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11859 : :
11860 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11861 : 0 : d_td->plaintext.len);
11862 : :
11863 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11864 : :
11865 : : /* Setup cipher session parameters */
11866 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11867 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11868 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11869 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11870 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11871 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11872 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11873 : 0 : ut_params->cipher_xform.next = NULL;
11874 : :
11875 : : /* Setup DOCSIS session parameters */
11876 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11877 : :
11878 : 0 : struct rte_security_session_conf sess_conf = {
11879 : 0 : .action_type = ut_params->type,
11880 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11881 : : .docsis = ut_params->docsis_xform,
11882 : : .crypto_xform = &ut_params->cipher_xform,
11883 : : };
11884 : :
11885 : : /* Create security session */
11886 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11887 : : ts_params->session_mpool);
11888 : :
11889 [ # # ]: 0 : if (!ut_params->sec_session) {
11890 : : printf("Test function %s line %u: failed to allocate session\n",
11891 : : __func__, __LINE__);
11892 : : ret = TEST_FAILED;
11893 : 0 : goto on_err;
11894 : : }
11895 : :
11896 : : /* Generate crypto op data structure */
11897 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11898 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11899 [ # # ]: 0 : if (!ut_params->op) {
11900 : : printf("Test function %s line %u: failed to allocate symmetric "
11901 : : "crypto operation\n", __func__, __LINE__);
11902 : : ret = TEST_FAILED;
11903 : 0 : goto on_err;
11904 : : }
11905 : :
11906 : : /* Setup CRC operation parameters */
11907 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11908 : 0 : (d_td->plaintext.len -
11909 : 0 : d_td->plaintext.crc_offset -
11910 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11911 : : 0;
11912 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11913 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11914 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11915 : :
11916 : : /* Setup cipher operation parameters */
11917 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11918 : 0 : (d_td->plaintext.len -
11919 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11920 : : 0;
11921 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11922 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11923 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11924 : :
11925 : : /* Setup cipher IV */
11926 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11927 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11928 : :
11929 : : /* Attach session to operation */
11930 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11931 : :
11932 : : /* Set crypto operation mbufs */
11933 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11934 : 0 : ut_params->op->sym->m_dst = NULL;
11935 : :
11936 : : /* Process crypto operation */
11937 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11938 : : NULL) {
11939 : : printf("Test function %s line %u: failed to process crypto op\n",
11940 : : __func__, __LINE__);
11941 : : ret = TEST_FAILED;
11942 : 0 : goto on_err;
11943 : : }
11944 : :
11945 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11946 : : printf("Test function %s line %u: crypto op processing failed\n",
11947 : : __func__, __LINE__);
11948 : : ret = TEST_FAILED;
11949 : 0 : goto on_err;
11950 : : }
11951 : :
11952 : : /* Validate ciphertext */
11953 : : ciphertext = plaintext;
11954 : :
11955 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11956 : : printf("Test function %s line %u: plaintext not as expected\n",
11957 : : __func__, __LINE__);
11958 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11959 : 0 : d_td->ciphertext.len);
11960 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11961 : : ret = TEST_FAILED;
11962 : 0 : goto on_err;
11963 : : }
11964 : :
11965 : 0 : on_err:
11966 : 0 : rte_crypto_op_free(ut_params->op);
11967 : 0 : ut_params->op = NULL;
11968 : :
11969 [ # # ]: 0 : if (ut_params->sec_session)
11970 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11971 : 0 : ut_params->sec_session = NULL;
11972 : :
11973 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11974 : 0 : ut_params->ibuf = NULL;
11975 : :
11976 : 0 : return ret;
11977 : : }
11978 : :
11979 : : static void
11980 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11981 : : struct rte_security_tls_record_xform *tls_record_xform)
11982 : : {
11983 : : unsigned int imp_nonce_len;
11984 : : uint8_t *imp_nonce;
11985 : :
11986 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11987 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11988 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11989 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11990 : 0 : break;
11991 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11992 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11993 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11994 : 0 : break;
11995 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
11996 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11997 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11998 : 0 : break;
11999 : : default:
12000 : : return;
12001 : : }
12002 : :
12003 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
12004 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
12005 : : }
12006 : :
12007 : : static int
12008 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
12009 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
12010 : : const struct tls_record_test_flags *flags)
12011 : : {
12012 : 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
12013 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12014 : : struct crypto_unittest_params *ut_params = &unittest_params;
12015 : : struct rte_security_tls_record_xform tls_record_xform;
12016 : : struct rte_security_capability_idx sec_cap_idx;
12017 : : const struct rte_security_capability *sec_cap;
12018 : : struct tls_record_test_data *res_d_tmp = NULL;
12019 : : enum rte_security_tls_sess_type sess_type;
12020 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
12021 : : struct rte_security_ctx *ctx;
12022 : : int i, ret = TEST_SUCCESS;
12023 : :
12024 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
12025 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
12026 : :
12027 : : /* Use first test data to create session */
12028 : :
12029 : : /* Copy TLS record xform */
12030 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
12031 : :
12032 : 0 : sess_type = tls_record_xform.type;
12033 : :
12034 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12035 : :
12036 : 0 : sec_cap_idx.action = ut_params->type;
12037 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
12038 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
12039 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
12040 : :
12041 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
12042 [ # # ]: 0 : if (sec_cap == NULL)
12043 : : return TEST_SKIPPED;
12044 : :
12045 : : /* Copy cipher session parameters */
12046 [ # # ]: 0 : if (td[0].aead) {
12047 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
12048 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
12049 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
12050 : :
12051 : : /* Verify crypto capabilities */
12052 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
12053 [ # # ]: 0 : if (!silent)
12054 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
12055 : 0 : return TEST_SKIPPED;
12056 : : }
12057 : : } else {
12058 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
12059 : : sizeof(ut_params->cipher_xform));
12060 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
12061 : : sizeof(ut_params->auth_xform));
12062 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
12063 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12064 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
12065 : :
12066 : : /* Verify crypto capabilities */
12067 : :
12068 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
12069 [ # # ]: 0 : if (!silent)
12070 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
12071 : 0 : return TEST_SKIPPED;
12072 : : }
12073 : :
12074 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
12075 [ # # ]: 0 : if (!silent)
12076 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
12077 : 0 : return TEST_SKIPPED;
12078 : : }
12079 : : }
12080 : :
12081 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
12082 : : return TEST_SKIPPED;
12083 : :
12084 : 0 : struct rte_security_session_conf sess_conf = {
12085 : 0 : .action_type = ut_params->type,
12086 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
12087 : : };
12088 : :
12089 : : if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
12090 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
12091 : : sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
12092 : :
12093 [ # # ]: 0 : if (td[0].aead)
12094 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
12095 : :
12096 [ # # ]: 0 : if (flags->opt_padding)
12097 : 0 : tls_record_xform.options.extra_padding_enable = 1;
12098 : :
12099 : 0 : sess_conf.tls_record = tls_record_xform;
12100 : :
12101 [ # # ]: 0 : if (td[0].aead) {
12102 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
12103 : : } else {
12104 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
12105 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
12106 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
12107 : : } else {
12108 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
12109 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
12110 : : }
12111 : : }
12112 : :
12113 [ # # ]: 0 : if (ut_params->sec_session == NULL) {
12114 : : /* Create security session */
12115 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
12116 : : ts_params->session_mpool);
12117 : : }
12118 : :
12119 [ # # ]: 0 : if (ut_params->sec_session == NULL)
12120 : : return TEST_SKIPPED;
12121 : :
12122 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
12123 [ # # # # ]: 0 : if (flags->ar_win_size &&
12124 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
12125 : 0 : sess_conf.tls_record.dtls_1_2.seq_no =
12126 : 0 : td[i].tls_record_xform.dtls_1_2.seq_no;
12127 : 0 : ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
12128 [ # # ]: 0 : if (ret) {
12129 : : printf("Could not update sequence number in session\n");
12130 : 0 : return TEST_SKIPPED;
12131 : : }
12132 : : }
12133 : :
12134 : : /* Setup source mbuf payload */
12135 : 0 : ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12136 : 0 : ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
12137 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
12138 [ # # ]: 0 : if (flags->out_of_place)
12139 : 0 : ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12140 : 0 : ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
12141 : : 0);
12142 : : else
12143 : 0 : ut_params->obuf = NULL;
12144 : :
12145 : : /* Generate crypto op data structure */
12146 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12147 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12148 [ # # ]: 0 : if (ut_params->op == NULL) {
12149 : : printf("Could not allocate crypto op");
12150 : : ret = TEST_FAILED;
12151 : 0 : goto crypto_op_free;
12152 : : }
12153 : :
12154 : : /* Attach session to operation */
12155 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
12156 : :
12157 : : /* Set crypto operation mbufs */
12158 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12159 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12160 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
12161 : :
12162 [ # # ]: 0 : if (flags->opt_padding)
12163 : 0 : ut_params->op->aux_flags = flags->opt_padding;
12164 : :
12165 : : /* Copy IV in crypto operation when IV generation is disabled */
12166 [ # # ]: 0 : if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12167 [ # # ]: 0 : (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12168 [ # # ]: 0 : (tls_record_xform.options.iv_gen_disable == 1)) {
12169 : : uint8_t *iv;
12170 : : int len;
12171 : :
12172 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12173 [ # # ]: 0 : if (td[i].aead)
12174 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
12175 : : else
12176 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
12177 : 0 : memcpy(iv, td[i].iv.data, len);
12178 : : }
12179 : :
12180 : : /* Process crypto operation */
12181 : 0 : process_crypto_request(dev_id, ut_params->op);
12182 : :
12183 : 0 : ret = test_tls_record_status_check(ut_params->op, &td[i]);
12184 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12185 : 0 : goto crypto_op_free;
12186 : :
12187 [ # # ]: 0 : if (res_d != NULL)
12188 : 0 : res_d_tmp = &res_d[i];
12189 : :
12190 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12191 [ # # ]: 0 : struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12192 : : ut_params->ibuf;
12193 : :
12194 : 0 : ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12195 : : silent, flags);
12196 [ # # ]: 0 : if (ret != TEST_SUCCESS)
12197 : 0 : goto crypto_op_free;
12198 : : }
12199 : :
12200 : 0 : rte_crypto_op_free(ut_params->op);
12201 : 0 : ut_params->op = NULL;
12202 : :
12203 [ # # ]: 0 : if (flags->out_of_place) {
12204 : 0 : rte_pktmbuf_free(ut_params->obuf);
12205 : 0 : ut_params->obuf = NULL;
12206 : : }
12207 : :
12208 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12209 : 0 : ut_params->ibuf = NULL;
12210 : : }
12211 : :
12212 : 0 : crypto_op_free:
12213 : 0 : rte_crypto_op_free(ut_params->op);
12214 : 0 : ut_params->op = NULL;
12215 : :
12216 [ # # ]: 0 : if (flags->out_of_place) {
12217 : 0 : rte_pktmbuf_free(ut_params->obuf);
12218 : 0 : ut_params->obuf = NULL;
12219 : : }
12220 : :
12221 : 0 : rte_pktmbuf_free(ut_params->ibuf);
12222 : 0 : ut_params->ibuf = NULL;
12223 : :
12224 [ # # # # ]: 0 : if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12225 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
12226 : 0 : ut_params->sec_session = NULL;
12227 : : }
12228 : :
12229 : : RTE_SET_USED(flags);
12230 : :
12231 : : return ret;
12232 : : }
12233 : :
12234 : : static int
12235 : 0 : test_tls_record_proto_known_vec(const void *test_data)
12236 : : {
12237 : : struct tls_record_test_data td_write;
12238 : : struct tls_record_test_flags flags;
12239 : :
12240 : : memset(&flags, 0, sizeof(flags));
12241 : :
12242 : : memcpy(&td_write, test_data, sizeof(td_write));
12243 : :
12244 : : /* Disable IV gen to be able to test with known vectors */
12245 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
12246 : :
12247 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12248 : : }
12249 : :
12250 : : static int
12251 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
12252 : : {
12253 : : const struct tls_record_test_data *td = test_data;
12254 : : struct tls_record_test_flags flags;
12255 : : struct tls_record_test_data td_inb;
12256 : :
12257 : : memset(&flags, 0, sizeof(flags));
12258 : :
12259 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12260 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
12261 : : else
12262 : : memcpy(&td_inb, td, sizeof(td_inb));
12263 : :
12264 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12265 : : }
12266 : :
12267 : : static int
12268 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12269 : : {
12270 : : unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12271 : : struct crypto_unittest_params *ut_params = &unittest_params;
12272 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12273 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12274 : : void *sec_session_outb = NULL;
12275 : : void *sec_session_inb = NULL;
12276 : : int ret;
12277 : :
12278 [ # # # ]: 0 : switch (flags->tls_version) {
12279 : : case RTE_SECURITY_VERSION_TLS_1_2:
12280 : : max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12281 : : break;
12282 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
12283 : : max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12284 : 0 : break;
12285 : : case RTE_SECURITY_VERSION_DTLS_1_2:
12286 : : max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12287 : : break;
12288 : 0 : default:
12289 : : max_payload_len = 0;
12290 : : }
12291 : :
12292 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12293 : : payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12294 [ # # ]: 0 : if (flags->nb_segs_in_mbuf)
12295 : 0 : payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12296 : :
12297 [ # # ]: 0 : if (flags->zero_len)
12298 : : payload_len = 0;
12299 : 0 : again:
12300 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12301 : : flags, td_outb, nb_pkts, payload_len);
12302 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12303 : 0 : continue;
12304 : :
12305 [ # # ]: 0 : if (flags->skip_sess_destroy)
12306 : 0 : ut_params->sec_session = sec_session_outb;
12307 : :
12308 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12309 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12310 : 0 : continue;
12311 : :
12312 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_outb == NULL)
12313 : 0 : sec_session_outb = ut_params->sec_session;
12314 : :
12315 [ # # # # ]: 0 : if (flags->zero_len && flags->content_type != TLS_RECORD_TEST_CONTENT_TYPE_APP) {
12316 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12317 : : return TEST_FAILED;
12318 : 0 : goto skip_decrypt;
12319 [ # # ]: 0 : } else if (ret == TEST_FAILED) {
12320 : : return TEST_FAILED;
12321 : : }
12322 : :
12323 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12324 : :
12325 [ # # ]: 0 : if (flags->skip_sess_destroy)
12326 : 0 : ut_params->sec_session = sec_session_inb;
12327 : :
12328 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12329 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12330 : 0 : continue;
12331 : :
12332 [ # # # # ]: 0 : if (flags->skip_sess_destroy && sec_session_inb == NULL)
12333 : 0 : sec_session_inb = ut_params->sec_session;
12334 : :
12335 [ # # # # ]: 0 : if (flags->pkt_corruption || flags->padding_corruption) {
12336 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12337 : : return TEST_FAILED;
12338 : : } else {
12339 [ # # ]: 0 : if (ret == TEST_FAILED)
12340 : : return TEST_FAILED;
12341 : : }
12342 : :
12343 : 0 : skip_decrypt:
12344 [ # # # # ]: 0 : if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12345 : 0 : goto again;
12346 : :
12347 [ # # ]: 0 : if (flags->display_alg)
12348 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12349 : :
12350 [ # # ]: 0 : if (flags->skip_sess_destroy) {
12351 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
12352 : : struct rte_security_ctx *ctx;
12353 : :
12354 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
12355 [ # # ]: 0 : if (sec_session_inb != NULL) {
12356 : 0 : rte_security_session_destroy(ctx, sec_session_inb);
12357 : : sec_session_inb = NULL;
12358 : : }
12359 [ # # ]: 0 : if (sec_session_outb != NULL) {
12360 : 0 : rte_security_session_destroy(ctx, sec_session_outb);
12361 : : sec_session_outb = NULL;
12362 : : }
12363 : 0 : ut_params->sec_session = NULL;
12364 : : }
12365 : :
12366 : 0 : pass_cnt++;
12367 : : }
12368 : :
12369 [ # # ]: 0 : if (flags->data_walkthrough)
12370 : : printf("\t Min payload size: %d, Max payload size: %d\n",
12371 : : TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
12372 : :
12373 [ # # ]: 0 : if (pass_cnt > 0)
12374 : : return TEST_SUCCESS;
12375 : : else
12376 : 0 : return TEST_SKIPPED;
12377 : : }
12378 : :
12379 : : static int
12380 : 0 : test_tls_1_2_record_proto_data_walkthrough(void)
12381 : : {
12382 : : struct tls_record_test_flags flags;
12383 : :
12384 : : memset(&flags, 0, sizeof(flags));
12385 : :
12386 : 0 : flags.data_walkthrough = true;
12387 : 0 : flags.skip_sess_destroy = true;
12388 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12389 : :
12390 : 0 : return test_tls_record_proto_all(&flags);
12391 : : }
12392 : :
12393 : : static int
12394 : 0 : test_tls_1_2_record_proto_display_list(void)
12395 : : {
12396 : : struct tls_record_test_flags flags;
12397 : :
12398 : : memset(&flags, 0, sizeof(flags));
12399 : :
12400 : 0 : flags.display_alg = true;
12401 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12402 : :
12403 : 0 : return test_tls_record_proto_all(&flags);
12404 : : }
12405 : :
12406 : : static int
12407 : 0 : test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12408 : : {
12409 : 0 : struct tls_record_test_flags flags = {
12410 : : .nb_segs_in_mbuf = 5,
12411 : : .tls_version = tls_version
12412 : : };
12413 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12414 : : struct rte_cryptodev_info dev_info;
12415 : :
12416 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12417 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12418 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12419 : 0 : return TEST_SKIPPED;
12420 : : }
12421 : :
12422 : 0 : return test_tls_record_proto_all(&flags);
12423 : : }
12424 : :
12425 : : static int
12426 : 0 : test_tls_1_2_record_proto_sgl(void)
12427 : : {
12428 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12429 : : }
12430 : :
12431 : : static int
12432 : 0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12433 : : {
12434 : 0 : struct tls_record_test_flags flags = {
12435 : : .nb_segs_in_mbuf = 5,
12436 : : .tls_version = tls_version,
12437 : : .skip_sess_destroy = true,
12438 : : .data_walkthrough = true
12439 : : };
12440 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12441 : : struct rte_cryptodev_info dev_info;
12442 : :
12443 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12444 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12445 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12446 : 0 : return TEST_SKIPPED;
12447 : : }
12448 : :
12449 : 0 : return test_tls_record_proto_all(&flags);
12450 : : }
12451 : :
12452 : : static int
12453 : 0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12454 : : {
12455 : 0 : struct tls_record_test_flags flags = {
12456 : : .nb_segs_in_mbuf = 5,
12457 : : .out_of_place = true,
12458 : : .tls_version = tls_version
12459 : : };
12460 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12461 : : struct rte_cryptodev_info dev_info;
12462 : :
12463 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12464 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12465 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12466 : 0 : return TEST_SKIPPED;
12467 : : }
12468 : :
12469 : 0 : return test_tls_record_proto_all(&flags);
12470 : : }
12471 : :
12472 : : static int
12473 : 0 : test_tls_1_2_record_proto_sgl_oop(void)
12474 : : {
12475 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12476 : : }
12477 : :
12478 : : static int
12479 : 0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12480 : : {
12481 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12482 : : }
12483 : :
12484 : : static int
12485 : 0 : test_tls_record_proto_corrupt_pkt(void)
12486 : : {
12487 : 0 : struct tls_record_test_flags flags = {
12488 : : .pkt_corruption = 1
12489 : : };
12490 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12491 : : struct rte_cryptodev_info dev_info;
12492 : :
12493 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12494 : :
12495 : 0 : return test_tls_record_proto_all(&flags);
12496 : : }
12497 : :
12498 : : static int
12499 : 0 : test_tls_record_proto_custom_content_type(void)
12500 : : {
12501 : 0 : struct tls_record_test_flags flags = {
12502 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12503 : : };
12504 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12505 : : struct rte_cryptodev_info dev_info;
12506 : :
12507 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12508 : :
12509 : 0 : return test_tls_record_proto_all(&flags);
12510 : : }
12511 : :
12512 : : static int
12513 : 0 : test_tls_record_proto_zero_len(void)
12514 : : {
12515 : 0 : struct tls_record_test_flags flags = {
12516 : : .zero_len = 1
12517 : : };
12518 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12519 : : struct rte_cryptodev_info dev_info;
12520 : :
12521 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12522 : :
12523 : 0 : return test_tls_record_proto_all(&flags);
12524 : : }
12525 : :
12526 : : static int
12527 : 0 : test_tls_record_proto_zero_len_non_app(void)
12528 : : {
12529 : 0 : struct tls_record_test_flags flags = {
12530 : : .zero_len = 1,
12531 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12532 : : };
12533 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12534 : : struct rte_cryptodev_info dev_info;
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_opt_padding(uint8_t padding, uint8_t num_segs,
12543 : : enum rte_security_tls_version tls_version)
12544 : : {
12545 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12546 : : struct rte_cryptodev_info dev_info;
12547 : 0 : struct tls_record_test_flags flags = {
12548 : : .nb_segs_in_mbuf = num_segs,
12549 : : .tls_version = tls_version,
12550 : : .opt_padding = padding
12551 : : };
12552 : :
12553 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12554 : :
12555 : 0 : return test_tls_record_proto_all(&flags);
12556 : : }
12557 : :
12558 : : static int
12559 : 0 : test_tls_record_proto_dm_opt_padding(void)
12560 : : {
12561 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12562 : : }
12563 : :
12564 : : static int
12565 : 0 : test_tls_record_proto_dm_opt_padding_1(void)
12566 : : {
12567 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12568 : : }
12569 : :
12570 : : static int
12571 : 0 : test_tls_record_proto_sg_opt_padding(void)
12572 : : {
12573 : 0 : return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12574 : : }
12575 : :
12576 : : static int
12577 : 0 : test_tls_record_proto_sg_opt_padding_1(void)
12578 : : {
12579 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12580 : : }
12581 : :
12582 : : static int
12583 : 0 : test_tls_record_proto_sg_opt_padding_2(void)
12584 : : {
12585 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12586 : : }
12587 : :
12588 : : static int
12589 : 0 : test_tls_record_proto_sg_opt_padding_max(void)
12590 : : {
12591 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12592 : : }
12593 : :
12594 : : static int
12595 : 0 : test_tls_record_proto_sg_opt_padding_corrupt(void)
12596 : : {
12597 : 0 : struct tls_record_test_flags flags = {
12598 : : .opt_padding = 8,
12599 : : .padding_corruption = true,
12600 : : .nb_segs_in_mbuf = 4,
12601 : : };
12602 : :
12603 : 0 : return test_tls_record_proto_all(&flags);
12604 : : }
12605 : :
12606 : : static int
12607 : 0 : test_dtls_1_2_record_proto_data_walkthrough(void)
12608 : : {
12609 : : struct tls_record_test_flags flags;
12610 : :
12611 : : memset(&flags, 0, sizeof(flags));
12612 : :
12613 : 0 : flags.data_walkthrough = true;
12614 : 0 : flags.skip_sess_destroy = true;
12615 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12616 : :
12617 : 0 : return test_tls_record_proto_all(&flags);
12618 : : }
12619 : :
12620 : : static int
12621 : 0 : test_dtls_1_2_record_proto_display_list(void)
12622 : : {
12623 : : struct tls_record_test_flags flags;
12624 : :
12625 : : memset(&flags, 0, sizeof(flags));
12626 : :
12627 : 0 : flags.display_alg = true;
12628 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12629 : :
12630 : 0 : return test_tls_record_proto_all(&flags);
12631 : : }
12632 : :
12633 : : static int
12634 : 0 : test_dtls_pkt_replay(const uint64_t seq_no[],
12635 : : bool replayed_pkt[], uint32_t nb_pkts,
12636 : : struct tls_record_test_flags *flags)
12637 : : {
12638 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12639 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12640 : : unsigned int i, idx, pass_cnt = 0;
12641 : : int ret;
12642 : :
12643 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12644 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12645 : : flags, td_outb, nb_pkts, 0);
12646 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12647 : 0 : continue;
12648 : :
12649 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++)
12650 : 0 : td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12651 : :
12652 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12653 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12654 : 0 : continue;
12655 : :
12656 [ # # ]: 0 : if (ret == TEST_FAILED)
12657 : : return TEST_FAILED;
12658 : :
12659 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12660 : :
12661 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
12662 : 0 : td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12663 : : /* Set antireplay flag for packets to be dropped */
12664 : 0 : td_inb[idx].ar_packet = replayed_pkt[idx];
12665 : : }
12666 : :
12667 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12668 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12669 : 0 : continue;
12670 : :
12671 [ # # ]: 0 : if (ret == TEST_FAILED)
12672 : : return TEST_FAILED;
12673 : :
12674 [ # # ]: 0 : if (flags->display_alg)
12675 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12676 : :
12677 : 0 : pass_cnt++;
12678 : : }
12679 : :
12680 [ # # ]: 0 : if (pass_cnt > 0)
12681 : : return TEST_SUCCESS;
12682 : : else
12683 : 0 : return TEST_SKIPPED;
12684 : : }
12685 : :
12686 : : static int
12687 : 0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12688 : : {
12689 : : struct tls_record_test_flags flags;
12690 : : uint32_t nb_pkts = 5;
12691 : : bool replayed_pkt[5];
12692 : : uint64_t seq_no[5];
12693 : :
12694 : : memset(&flags, 0, sizeof(flags));
12695 : :
12696 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12697 : 0 : flags.ar_win_size = winsz;
12698 : :
12699 : : /* 1. Advance the TOP of the window to WS * 2 */
12700 : 0 : seq_no[0] = winsz * 2;
12701 : : /* 2. Test sequence number within the new window(WS + 1) */
12702 : 0 : seq_no[1] = winsz + 1;
12703 : : /* 3. Test sequence number less than the window BOTTOM */
12704 : 0 : seq_no[2] = winsz;
12705 : : /* 4. Test sequence number in the middle of the window */
12706 : 0 : seq_no[3] = winsz + (winsz / 2);
12707 : : /* 5. Test replay of the packet in the middle of the window */
12708 : 0 : seq_no[4] = winsz + (winsz / 2);
12709 : :
12710 : 0 : replayed_pkt[0] = false;
12711 : 0 : replayed_pkt[1] = false;
12712 : 0 : replayed_pkt[2] = true;
12713 : 0 : replayed_pkt[3] = false;
12714 : 0 : replayed_pkt[4] = true;
12715 : :
12716 : 0 : return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12717 : : }
12718 : :
12719 : : static int
12720 : 0 : test_dtls_1_2_record_proto_antireplay64(void)
12721 : : {
12722 : 0 : return test_dtls_1_2_record_proto_antireplay(64);
12723 : : }
12724 : :
12725 : : static int
12726 : 0 : test_dtls_1_2_record_proto_antireplay128(void)
12727 : : {
12728 : 0 : return test_dtls_1_2_record_proto_antireplay(128);
12729 : : }
12730 : :
12731 : : static int
12732 : 0 : test_dtls_1_2_record_proto_antireplay256(void)
12733 : : {
12734 : 0 : return test_dtls_1_2_record_proto_antireplay(256);
12735 : : }
12736 : :
12737 : : static int
12738 : 0 : test_dtls_1_2_record_proto_antireplay512(void)
12739 : : {
12740 : 0 : return test_dtls_1_2_record_proto_antireplay(512);
12741 : : }
12742 : :
12743 : : static int
12744 : 0 : test_dtls_1_2_record_proto_antireplay1024(void)
12745 : : {
12746 : 0 : return test_dtls_1_2_record_proto_antireplay(1024);
12747 : : }
12748 : :
12749 : : static int
12750 : 0 : test_dtls_1_2_record_proto_antireplay2048(void)
12751 : : {
12752 : 0 : return test_dtls_1_2_record_proto_antireplay(2048);
12753 : : }
12754 : :
12755 : : static int
12756 : 0 : test_dtls_1_2_record_proto_antireplay4096(void)
12757 : : {
12758 : 0 : return test_dtls_1_2_record_proto_antireplay(4096);
12759 : : }
12760 : :
12761 : : static int
12762 : 0 : test_dtls_1_2_record_proto_sgl(void)
12763 : : {
12764 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12765 : : }
12766 : :
12767 : : static int
12768 : 0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12769 : : {
12770 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12771 : : }
12772 : :
12773 : : static int
12774 : 0 : test_dtls_1_2_record_proto_sgl_oop(void)
12775 : : {
12776 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12777 : : }
12778 : :
12779 : : static int
12780 : 0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
12781 : : {
12782 : 0 : struct tls_record_test_flags flags = {
12783 : : .pkt_corruption = 1,
12784 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12785 : : };
12786 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12787 : : struct rte_cryptodev_info dev_info;
12788 : :
12789 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12790 : :
12791 : 0 : return test_tls_record_proto_all(&flags);
12792 : : }
12793 : :
12794 : : static int
12795 : 0 : test_dtls_1_2_record_proto_custom_content_type(void)
12796 : : {
12797 : 0 : struct tls_record_test_flags flags = {
12798 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12799 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12800 : : };
12801 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12802 : : struct rte_cryptodev_info dev_info;
12803 : :
12804 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12805 : :
12806 : 0 : return test_tls_record_proto_all(&flags);
12807 : : }
12808 : :
12809 : : static int
12810 : 0 : test_dtls_1_2_record_proto_zero_len(void)
12811 : : {
12812 : 0 : struct tls_record_test_flags flags = {
12813 : : .zero_len = 1,
12814 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12815 : : };
12816 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12817 : : struct rte_cryptodev_info dev_info;
12818 : :
12819 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12820 : :
12821 : 0 : return test_tls_record_proto_all(&flags);
12822 : : }
12823 : :
12824 : : static int
12825 : 0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
12826 : : {
12827 : 0 : struct tls_record_test_flags flags = {
12828 : : .zero_len = 1,
12829 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12830 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12831 : : };
12832 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12833 : : struct rte_cryptodev_info dev_info;
12834 : :
12835 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12836 : :
12837 : 0 : return test_tls_record_proto_all(&flags);
12838 : : }
12839 : :
12840 : : static int
12841 : 0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
12842 : : {
12843 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12844 : : }
12845 : :
12846 : : static int
12847 : 0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12848 : : {
12849 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12850 : : }
12851 : :
12852 : : static int
12853 : 0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
12854 : : {
12855 : 0 : return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12856 : : }
12857 : :
12858 : : static int
12859 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12860 : : {
12861 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12862 : : }
12863 : :
12864 : : static int
12865 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12866 : : {
12867 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12868 : : }
12869 : :
12870 : : static int
12871 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12872 : : {
12873 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12874 : : }
12875 : :
12876 : : static int
12877 : 0 : test_tls_1_3_record_proto_display_list(void)
12878 : : {
12879 : : struct tls_record_test_flags flags;
12880 : :
12881 : : memset(&flags, 0, sizeof(flags));
12882 : :
12883 : 0 : flags.display_alg = true;
12884 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12885 : :
12886 : 0 : return test_tls_record_proto_all(&flags);
12887 : : }
12888 : :
12889 : : static int
12890 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12891 : : {
12892 : 0 : struct tls_record_test_flags flags = {
12893 : : .opt_padding = 8,
12894 : : .padding_corruption = true,
12895 : : .nb_segs_in_mbuf = 4,
12896 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12897 : : };
12898 : :
12899 : 0 : return test_tls_record_proto_all(&flags);
12900 : : }
12901 : :
12902 : : static int
12903 : 0 : test_tls_1_3_record_proto_corrupt_pkt(void)
12904 : : {
12905 : 0 : struct tls_record_test_flags flags = {
12906 : : .pkt_corruption = 1,
12907 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12908 : : };
12909 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12910 : : struct rte_cryptodev_info dev_info;
12911 : :
12912 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12913 : :
12914 : 0 : return test_tls_record_proto_all(&flags);
12915 : : }
12916 : :
12917 : : static int
12918 : 0 : test_tls_1_3_record_proto_custom_content_type(void)
12919 : : {
12920 : 0 : struct tls_record_test_flags flags = {
12921 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12922 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12923 : : };
12924 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12925 : : struct rte_cryptodev_info dev_info;
12926 : :
12927 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12928 : :
12929 : 0 : return test_tls_record_proto_all(&flags);
12930 : : }
12931 : :
12932 : : static int
12933 : 0 : test_tls_1_3_record_proto_zero_len(void)
12934 : : {
12935 : 0 : struct tls_record_test_flags flags = {
12936 : : .zero_len = 1,
12937 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12938 : : };
12939 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12940 : : struct rte_cryptodev_info dev_info;
12941 : :
12942 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12943 : :
12944 : 0 : return test_tls_record_proto_all(&flags);
12945 : : }
12946 : :
12947 : : static int
12948 : 0 : test_tls_1_3_record_proto_zero_len_non_app(void)
12949 : : {
12950 : 0 : struct tls_record_test_flags flags = {
12951 : : .zero_len = 1,
12952 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12953 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12954 : : };
12955 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12956 : : struct rte_cryptodev_info dev_info;
12957 : :
12958 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12959 : :
12960 : 0 : return test_tls_record_proto_all(&flags);
12961 : : }
12962 : :
12963 : : static int
12964 : 0 : test_tls_1_3_record_proto_dm_opt_padding(void)
12965 : : {
12966 : 0 : return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12967 : : }
12968 : :
12969 : : static int
12970 : 0 : test_tls_1_3_record_proto_sg_opt_padding(void)
12971 : : {
12972 : 0 : return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12973 : : }
12974 : :
12975 : : static int
12976 : 0 : test_tls_1_3_record_proto_sg_opt_padding_1(void)
12977 : : {
12978 : 0 : return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12979 : : }
12980 : :
12981 : : static int
12982 : 0 : test_tls_1_3_record_proto_data_walkthrough(void)
12983 : : {
12984 : : struct tls_record_test_flags flags;
12985 : :
12986 : : memset(&flags, 0, sizeof(flags));
12987 : :
12988 : 0 : flags.data_walkthrough = true;
12989 : 0 : flags.skip_sess_destroy = true;
12990 : 0 : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12991 : :
12992 : 0 : return test_tls_record_proto_all(&flags);
12993 : : }
12994 : :
12995 : : static int
12996 : 0 : test_tls_1_3_record_proto_sgl(void)
12997 : : {
12998 : 0 : return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
12999 : : }
13000 : :
13001 : : static int
13002 : 0 : test_tls_1_3_record_proto_sgl_data_walkthrough(void)
13003 : : {
13004 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
13005 : : }
13006 : :
13007 : : static int
13008 : 0 : test_tls_1_3_record_proto_sgl_oop(void)
13009 : : {
13010 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
13011 : : }
13012 : :
13013 : : #endif
13014 : :
13015 : : static int
13016 : 1 : test_cryptodev_error_recover_helper_check(void)
13017 : : {
13018 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13019 : : struct rte_cryptodev_info dev_info;
13020 : : uint64_t feat_flags;
13021 : : int ret;
13022 : :
13023 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13024 : 1 : feat_flags = dev_info.feature_flags;
13025 : :
13026 : : /* Skip the test if queue pair reset is not supported */
13027 : 1 : ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
13028 [ - + ]: 1 : if (ret == -ENOTSUP)
13029 : : return TEST_SKIPPED;
13030 : :
13031 [ # # ]: 0 : ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
13032 [ # # ]: 0 : if (ret == -ENOTSUP)
13033 : 0 : return TEST_SKIPPED;
13034 : :
13035 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
13036 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13037 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13038 : 0 : RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
13039 : 0 : return TEST_SKIPPED;
13040 : : }
13041 : :
13042 : : return 0;
13043 : : }
13044 : :
13045 : : static int
13046 : 0 : test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
13047 : : {
13048 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13049 : : struct crypto_unittest_params *ut_params = &unittest_params;
13050 : : const struct blockcipher_test_data *tdata = test_data;
13051 : 0 : uint8_t *cipher_key = alloca(tdata->cipher_key.len);
13052 : : struct rte_crypto_sym_op *sym_op = NULL;
13053 : : struct rte_crypto_op *op = NULL;
13054 : : char *dst;
13055 : :
13056 : 0 : memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
13057 : 0 : ut_params->cipher_xform.next = NULL;
13058 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13059 : 0 : ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
13060 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13061 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
13062 : 0 : ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
13063 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13064 : 0 : ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
13065 : :
13066 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
13067 : : ts_params->session_mpool);
13068 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13069 : : return TEST_SKIPPED;
13070 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13071 : :
13072 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13073 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
13074 : :
13075 : 0 : memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
13076 [ # # ]: 0 : tdata->iv.len);
13077 : : sym_op = ut_params->op->sym;
13078 : 0 : sym_op->cipher.data.offset = tdata->cipher_offset;
13079 : 0 : sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
13080 : :
13081 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13082 : :
13083 [ # # ]: 0 : if (generate_err) {
13084 : 0 : ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
13085 [ # # ]: 0 : if (ut_params->ibuf == NULL)
13086 : : return TEST_FAILED;
13087 : 0 : crypto_err = CRYPTODEV_ERR_TRIGGERED;
13088 : : } else {
13089 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13090 : : }
13091 : :
13092 : : /* clear mbuf payload */
13093 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13094 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
13095 : :
13096 : 0 : dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
13097 : 0 : memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
13098 : :
13099 : 0 : sym_op->m_src = ut_params->ibuf;
13100 : 0 : sym_op->m_dst = NULL;
13101 : :
13102 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
13103 : :
13104 [ # # ]: 0 : if (generate_err) {
13105 : 0 : free(ut_params->ibuf);
13106 : 0 : ut_params->ibuf = NULL;
13107 [ # # ]: 0 : if (op == NULL) {
13108 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13109 : 0 : ut_params->sess = NULL;
13110 : 0 : return TEST_SUCCESS;
13111 : : } else {
13112 : : return TEST_FAILED;
13113 : : }
13114 : : }
13115 : :
13116 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13117 : : "crypto op processing failed");
13118 : :
13119 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
13120 : : tdata->ciphertext.len - tdata->cipher_offset,
13121 : : "Data not as expected");
13122 : :
13123 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13124 : 0 : ut_params->sess = NULL;
13125 : :
13126 : 0 : return TEST_SUCCESS;
13127 : : }
13128 : :
13129 : : /*
13130 : : * This unit test verifies the recovery of the cryptodev from any fatal error.
13131 : : * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
13132 : : * for every call to helper function.
13133 : : *
13134 : : * When the flag is set to 0, the helper function verifies the test data without generating any
13135 : : * errors, i.e: verifies the default behaviour of the cryptodev.
13136 : : *
13137 : : * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
13138 : : * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
13139 : : * is generated, it waits till the cryptodev is recoverd from the error.
13140 : : *
13141 : : * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
13142 : : * of cryptodev after the recovery.
13143 : : */
13144 : : static int
13145 : 1 : test_cryptodev_verify_error_recover(const void *test_data)
13146 : : {
13147 : : int ret = TEST_FAILED;
13148 : : int i, num_itr = 5;
13149 : :
13150 : 1 : ret = test_cryptodev_error_recover_helper_check();
13151 [ - + ]: 1 : if (ret)
13152 : : return ret;
13153 : :
13154 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
13155 : : RTE_CRYPTODEV_EVENT_ERROR,
13156 : : test_cryptodev_error_cb, NULL),
13157 : : "Failed to register Cryptodev callback");
13158 : :
13159 [ # # ]: 0 : for (i = 0; i < num_itr; i++) {
13160 : : int ticks = 0;
13161 : :
13162 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13163 : : test_data, false);
13164 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13165 : :
13166 : : /* Generate Error */
13167 : 0 : ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13168 : : test_data, true);
13169 [ # # ]: 0 : TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13170 : :
13171 : : /* Wait till cryptodev recovered from error */
13172 [ # # ]: 0 : while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
13173 : : rte_delay_ms(10);
13174 [ # # ]: 0 : if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
13175 : : return TEST_FAILED;
13176 : : }
13177 : : }
13178 [ # # ]: 0 : TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
13179 : :
13180 : : return ret;
13181 : : }
13182 : :
13183 : : static int
13184 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
13185 : : {
13186 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
13187 : : }
13188 : :
13189 : : static int
13190 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
13191 : : {
13192 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
13193 : : }
13194 : :
13195 : : static int
13196 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
13197 : : {
13198 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
13199 : : }
13200 : :
13201 : : static int
13202 : 1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
13203 : : {
13204 : 1 : return test_authenticated_encryption_helper(&gcm_test_case_3, true);
13205 : : }
13206 : :
13207 : : static int
13208 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
13209 : : {
13210 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
13211 : : }
13212 : :
13213 : : static int
13214 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
13215 : : {
13216 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
13217 : : }
13218 : :
13219 : : static int
13220 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
13221 : : {
13222 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
13223 : : }
13224 : :
13225 : : static int
13226 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
13227 : : {
13228 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
13229 : : }
13230 : :
13231 : : static int
13232 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
13233 : : {
13234 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
13235 : : }
13236 : :
13237 : : static int
13238 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
13239 : : {
13240 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
13241 : : }
13242 : :
13243 : : static int
13244 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
13245 : : {
13246 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
13247 : : }
13248 : :
13249 : : static int
13250 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
13251 : : {
13252 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
13253 : : }
13254 : :
13255 : : static int
13256 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
13257 : : {
13258 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
13259 : : }
13260 : :
13261 : : static int
13262 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
13263 : : {
13264 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
13265 : : }
13266 : :
13267 : : static int
13268 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
13269 : : {
13270 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
13271 : : }
13272 : :
13273 : : static int
13274 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
13275 : : {
13276 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
13277 : : }
13278 : :
13279 : : static int
13280 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
13281 : : {
13282 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
13283 : : }
13284 : :
13285 : : static int
13286 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
13287 : : {
13288 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
13289 : : }
13290 : :
13291 : : static int
13292 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
13293 : : {
13294 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
13295 : : }
13296 : :
13297 : : static int
13298 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
13299 : : {
13300 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
13301 : : }
13302 : :
13303 : : static int
13304 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
13305 : : {
13306 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
13307 : : }
13308 : :
13309 : : static int
13310 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
13311 : : {
13312 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
13313 : : }
13314 : :
13315 : : static int
13316 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
13317 : : {
13318 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
13319 : : }
13320 : :
13321 : : static int
13322 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
13323 : : {
13324 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
13325 : : }
13326 : :
13327 : : static int
13328 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
13329 : : {
13330 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
13331 : : }
13332 : :
13333 : : static int
13334 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
13335 : : {
13336 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
13337 : : }
13338 : :
13339 : : static int
13340 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13341 : : {
13342 : : struct aead_test_data tdata;
13343 : : int res;
13344 : :
13345 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13346 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13347 : 1 : tdata.iv.data[0] += 1;
13348 : : res = test_authenticated_encryption(&tdata);
13349 [ + - ]: 1 : if (res == TEST_SKIPPED)
13350 : : return res;
13351 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13352 : : return TEST_SUCCESS;
13353 : : }
13354 : :
13355 : : static int
13356 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13357 : : {
13358 : : struct aead_test_data tdata;
13359 : : int res;
13360 : :
13361 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13362 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13363 : 1 : tdata.plaintext.data[0] += 1;
13364 : : res = test_authenticated_encryption(&tdata);
13365 [ + - ]: 1 : if (res == TEST_SKIPPED)
13366 : : return res;
13367 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13368 : : return TEST_SUCCESS;
13369 : : }
13370 : :
13371 : : static int
13372 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13373 : : {
13374 : : struct aead_test_data tdata;
13375 : : int res;
13376 : :
13377 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13378 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13379 : 1 : tdata.ciphertext.data[0] += 1;
13380 : : res = test_authenticated_encryption(&tdata);
13381 [ + - ]: 1 : if (res == TEST_SKIPPED)
13382 : : return res;
13383 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13384 : : return TEST_SUCCESS;
13385 : : }
13386 : :
13387 : : static int
13388 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13389 : : {
13390 : : struct aead_test_data tdata;
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 : 1 : tdata.aad.len += 1;
13396 : : res = test_authenticated_encryption(&tdata);
13397 [ + - ]: 1 : if (res == TEST_SKIPPED)
13398 : : return res;
13399 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13400 : : return TEST_SUCCESS;
13401 : : }
13402 : :
13403 : : static int
13404 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13405 : : {
13406 : : struct aead_test_data tdata;
13407 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13408 : : int res;
13409 : :
13410 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13411 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13412 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13413 : 1 : aad[0] += 1;
13414 : 1 : tdata.aad.data = aad;
13415 : : res = test_authenticated_encryption(&tdata);
13416 [ + - ]: 1 : if (res == TEST_SKIPPED)
13417 : : return res;
13418 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13419 : : return TEST_SUCCESS;
13420 : : }
13421 : :
13422 : : static int
13423 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13424 : : {
13425 : : struct aead_test_data tdata;
13426 : : int res;
13427 : :
13428 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13429 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13430 : 1 : tdata.auth_tag.data[0] += 1;
13431 : : res = test_authenticated_encryption(&tdata);
13432 [ + - ]: 1 : if (res == TEST_SKIPPED)
13433 : : return res;
13434 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13435 : : return TEST_SUCCESS;
13436 : : }
13437 : :
13438 : : static int
13439 : 43 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13440 : : {
13441 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13442 : : struct crypto_unittest_params *ut_params = &unittest_params;
13443 : :
13444 : : int retval;
13445 : : uint8_t *plaintext;
13446 : : uint32_t i;
13447 : : struct rte_cryptodev_info dev_info;
13448 : :
13449 : 43 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13450 : 43 : uint64_t feat_flags = dev_info.feature_flags;
13451 : :
13452 [ - + ]: 43 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13453 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13454 : : printf("Device doesn't support RAW data-path APIs.\n");
13455 : 0 : return TEST_SKIPPED;
13456 : : }
13457 : :
13458 : : /* Verify the capabilities */
13459 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13460 : : const struct rte_cryptodev_symmetric_capability *capability;
13461 : 43 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13462 : 43 : cap_idx.algo.aead = tdata->algo;
13463 : 43 : capability = rte_cryptodev_sym_capability_get(
13464 : 43 : ts_params->valid_devs[0], &cap_idx);
13465 [ + - ]: 43 : if (capability == NULL)
13466 : : return TEST_SKIPPED;
13467 [ + + ]: 43 : if (rte_cryptodev_sym_capability_check_aead(
13468 : 43 : capability, tdata->key.len, tdata->auth_tag.len,
13469 : 43 : tdata->aad.len, tdata->iv.len))
13470 : : return TEST_SKIPPED;
13471 : :
13472 : : /* Create AEAD session */
13473 : 42 : retval = create_aead_session(ts_params->valid_devs[0],
13474 : 42 : tdata->algo,
13475 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13476 : 42 : tdata->key.data, tdata->key.len,
13477 : 42 : tdata->aad.len, tdata->auth_tag.len,
13478 : 42 : tdata->iv.len);
13479 [ + - ]: 42 : if (retval != TEST_SUCCESS)
13480 : : return retval;
13481 : :
13482 : : /* alloc mbuf and set payload */
13483 [ + + ]: 42 : if (tdata->aad.len > MBUF_SIZE) {
13484 [ - + ]: 2 : if (use_ext_mbuf) {
13485 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13486 : : AEAD_TEXT_MAX_LENGTH,
13487 : : 1 /* nb_segs */,
13488 : : NULL);
13489 : : } else {
13490 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13491 : : }
13492 : : /* Populate full size of add data */
13493 [ + + ]: 4088 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13494 : 4086 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13495 : : } else {
13496 [ + + ]: 40 : if (use_ext_mbuf) {
13497 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13498 : : AEAD_TEXT_MAX_LENGTH,
13499 : : 1 /* nb_segs */,
13500 : : NULL);
13501 : : } else {
13502 : 39 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13503 : : }
13504 : : }
13505 : 42 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13506 : 42 : rte_pktmbuf_tailroom(ut_params->ibuf));
13507 : :
13508 : : /* Create AEAD operation */
13509 : 42 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13510 [ + - ]: 42 : if (retval < 0)
13511 : : return retval;
13512 : :
13513 [ + - ]: 42 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13514 : :
13515 : 42 : ut_params->op->sym->m_src = ut_params->ibuf;
13516 : :
13517 : : /* Process crypto operation */
13518 [ - + ]: 42 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13519 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13520 [ - + ]: 42 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13521 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13522 : : 0);
13523 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13524 : : return retval;
13525 : : } else
13526 [ + + ]: 42 : TEST_ASSERT_NOT_NULL(
13527 : : process_crypto_request(ts_params->valid_devs[0],
13528 : : ut_params->op), "failed to process sym crypto op");
13529 : :
13530 [ - + ]: 37 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13531 : : "crypto op processing failed");
13532 : :
13533 [ - + ]: 37 : if (ut_params->op->sym->m_dst)
13534 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13535 : : uint8_t *);
13536 : : else
13537 : 37 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13538 : : uint8_t *,
13539 : : ut_params->op->sym->cipher.data.offset);
13540 : :
13541 : 37 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13542 : :
13543 : : /* Validate obuf */
13544 [ + + ]: 38 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13545 : : plaintext,
13546 : : tdata->plaintext.data,
13547 : : tdata->plaintext.len,
13548 : : "Plaintext data not as expected");
13549 : :
13550 [ - + ]: 36 : TEST_ASSERT_EQUAL(ut_params->op->status,
13551 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13552 : : "Authentication failed");
13553 : :
13554 : : return 0;
13555 : : }
13556 : :
13557 : : static int
13558 : : test_authenticated_decryption(const struct aead_test_data *tdata)
13559 : : {
13560 : 42 : return test_authenticated_decryption_helper(tdata, false);
13561 : : }
13562 : :
13563 : : static int
13564 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
13565 : : {
13566 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
13567 : : }
13568 : :
13569 : : static int
13570 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
13571 : : {
13572 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
13573 : : }
13574 : :
13575 : : static int
13576 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
13577 : : {
13578 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
13579 : : }
13580 : :
13581 : : static int
13582 : 1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13583 : : {
13584 : 1 : return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13585 : : }
13586 : :
13587 : : static int
13588 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
13589 : : {
13590 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
13591 : : }
13592 : :
13593 : : static int
13594 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
13595 : : {
13596 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
13597 : : }
13598 : :
13599 : : static int
13600 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
13601 : : {
13602 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
13603 : : }
13604 : :
13605 : : static int
13606 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
13607 : : {
13608 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
13609 : : }
13610 : :
13611 : : static int
13612 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
13613 : : {
13614 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
13615 : : }
13616 : :
13617 : : static int
13618 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13619 : : {
13620 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
13621 : : }
13622 : :
13623 : : static int
13624 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
13625 : : {
13626 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
13627 : : }
13628 : :
13629 : : static int
13630 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
13631 : : {
13632 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
13633 : : }
13634 : :
13635 : : static int
13636 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
13637 : : {
13638 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
13639 : : }
13640 : :
13641 : : static int
13642 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
13643 : : {
13644 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
13645 : : }
13646 : :
13647 : : static int
13648 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
13649 : : {
13650 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
13651 : : }
13652 : :
13653 : : static int
13654 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
13655 : : {
13656 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
13657 : : }
13658 : :
13659 : : static int
13660 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
13661 : : {
13662 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
13663 : : }
13664 : :
13665 : : static int
13666 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
13667 : : {
13668 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
13669 : : }
13670 : :
13671 : : static int
13672 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
13673 : : {
13674 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
13675 : : }
13676 : :
13677 : : static int
13678 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
13679 : : {
13680 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
13681 : : }
13682 : :
13683 : : static int
13684 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
13685 : : {
13686 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
13687 : : }
13688 : :
13689 : : static int
13690 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
13691 : : {
13692 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
13693 : : }
13694 : :
13695 : : static int
13696 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
13697 : : {
13698 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
13699 : : }
13700 : :
13701 : : static int
13702 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
13703 : : {
13704 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
13705 : : }
13706 : :
13707 : : static int
13708 : 1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
13709 : : {
13710 : 1 : return test_authenticated_decryption(&gcm_test_case_256_8);
13711 : : }
13712 : :
13713 : : static int
13714 : 1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
13715 : : {
13716 : 1 : return test_authenticated_encryption(&gcm_test_case_256_8);
13717 : : }
13718 : :
13719 : : static int
13720 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
13721 : : {
13722 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
13723 : : }
13724 : :
13725 : : static int
13726 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
13727 : : {
13728 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
13729 : : }
13730 : :
13731 : : static int
13732 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13733 : : {
13734 : : struct aead_test_data tdata;
13735 : : int res;
13736 : :
13737 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13738 : 1 : tdata.iv.data[0] += 1;
13739 : : res = test_authenticated_decryption(&tdata);
13740 [ + - ]: 1 : if (res == TEST_SKIPPED)
13741 : : return res;
13742 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13743 : : return TEST_SUCCESS;
13744 : : }
13745 : :
13746 : : static int
13747 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13748 : : {
13749 : : struct aead_test_data tdata;
13750 : : int res;
13751 : :
13752 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13753 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13754 : 1 : tdata.plaintext.data[0] += 1;
13755 : : res = test_authenticated_decryption(&tdata);
13756 [ + - ]: 1 : if (res == TEST_SKIPPED)
13757 : : return res;
13758 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13759 : : return TEST_SUCCESS;
13760 : : }
13761 : :
13762 : : static int
13763 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13764 : : {
13765 : : struct aead_test_data tdata;
13766 : : int res;
13767 : :
13768 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13769 : 1 : tdata.ciphertext.data[0] += 1;
13770 : : res = test_authenticated_decryption(&tdata);
13771 [ + - ]: 1 : if (res == TEST_SKIPPED)
13772 : : return res;
13773 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13774 : : return TEST_SUCCESS;
13775 : : }
13776 : :
13777 : : static int
13778 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13779 : : {
13780 : : struct aead_test_data tdata;
13781 : : int res;
13782 : :
13783 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13784 : 1 : tdata.aad.len += 1;
13785 : : res = test_authenticated_decryption(&tdata);
13786 [ + - ]: 1 : if (res == TEST_SKIPPED)
13787 : : return res;
13788 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13789 : : return TEST_SUCCESS;
13790 : : }
13791 : :
13792 : : static int
13793 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13794 : : {
13795 : : struct aead_test_data tdata;
13796 : 1 : uint8_t *aad = alloca(gcm_test_case_7.aad.len);
13797 : : int res;
13798 : :
13799 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13800 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13801 : 1 : aad[0] += 1;
13802 : 1 : tdata.aad.data = aad;
13803 : : res = test_authenticated_decryption(&tdata);
13804 [ + - ]: 1 : if (res == TEST_SKIPPED)
13805 : : return res;
13806 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13807 : : return TEST_SUCCESS;
13808 : : }
13809 : :
13810 : : static int
13811 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13812 : : {
13813 : : struct aead_test_data tdata;
13814 : : int res;
13815 : :
13816 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13817 : 1 : tdata.auth_tag.data[0] += 1;
13818 : : res = test_authenticated_decryption(&tdata);
13819 [ + - ]: 1 : if (res == TEST_SKIPPED)
13820 : : return res;
13821 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13822 : : return TEST_SUCCESS;
13823 : : }
13824 : :
13825 : : static int
13826 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13827 : : {
13828 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13829 : : struct crypto_unittest_params *ut_params = &unittest_params;
13830 : :
13831 : : uint32_t i;
13832 : : int retval;
13833 : : uint8_t *ciphertext, *auth_tag, *buffer_oop;
13834 : : uint16_t plaintext_pad_len;
13835 : : struct rte_cryptodev_info dev_info;
13836 : :
13837 : : /* Verify the capabilities */
13838 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13839 : : const struct rte_cryptodev_symmetric_capability *capability;
13840 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13841 : 1 : cap_idx.algo.aead = tdata->algo;
13842 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13843 [ + - ]: 1 : if (capability == NULL)
13844 : : return TEST_SKIPPED;
13845 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(
13846 : 1 : capability, tdata->key.len, tdata->auth_tag.len,
13847 : 1 : tdata->aad.len, tdata->iv.len))
13848 : : return TEST_SKIPPED;
13849 : :
13850 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13851 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13852 : :
13853 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13854 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13855 : : return TEST_SKIPPED;
13856 : :
13857 : : /* not supported with CPU crypto */
13858 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13859 : : return TEST_SKIPPED;
13860 : :
13861 : : /* Create AEAD session */
13862 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13863 : 1 : tdata->algo,
13864 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13865 : 1 : tdata->key.data, tdata->key.len,
13866 : 1 : tdata->aad.len, tdata->auth_tag.len,
13867 : 1 : tdata->iv.len);
13868 [ + - ]: 1 : if (retval < 0)
13869 : : return retval;
13870 : :
13871 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13872 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13873 : :
13874 : : /* clear mbuf payload */
13875 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13876 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13877 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13878 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13879 : :
13880 : : /* Create AEAD operation */
13881 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13882 [ + - ]: 1 : if (retval < 0)
13883 : : return retval;
13884 : :
13885 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13886 : :
13887 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13888 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13889 : :
13890 : : /* Process crypto operation */
13891 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13892 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13893 : : 0);
13894 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13895 : : return retval;
13896 : : } else
13897 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13898 : : ut_params->op), "failed to process sym crypto op");
13899 : :
13900 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13901 : : "crypto op processing failed");
13902 : :
13903 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13904 : :
13905 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13906 : : ut_params->op->sym->cipher.data.offset);
13907 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13908 : :
13909 : : /* Check if the data within the offset range is not overwritten in the OOP */
13910 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
13911 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
13912 [ - + ]: 16 : if (buffer_oop[i]) {
13913 : 0 : RTE_LOG(ERR, USER1,
13914 : : "Incorrect value of the output buffer header\n");
13915 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
13916 : 0 : ut_params->op->sym->cipher.data.offset);
13917 : 0 : return TEST_FAILED;
13918 : : }
13919 : : }
13920 : :
13921 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13922 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13923 : :
13924 : : /* Validate obuf */
13925 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13926 : : ciphertext,
13927 : : tdata->ciphertext.data,
13928 : : tdata->ciphertext.len,
13929 : : "Ciphertext data not as expected");
13930 : :
13931 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13932 : : auth_tag,
13933 : : tdata->auth_tag.data,
13934 : : tdata->auth_tag.len,
13935 : : "Generated auth tag not as expected");
13936 : :
13937 : : return 0;
13938 : :
13939 : : }
13940 : :
13941 : : static int
13942 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13943 : : {
13944 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
13945 : : }
13946 : :
13947 : : static int
13948 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13949 : : {
13950 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13951 : : struct crypto_unittest_params *ut_params = &unittest_params;
13952 : :
13953 : : uint32_t i;
13954 : : int retval;
13955 : : uint8_t *plaintext, *buffer_oop;
13956 : : struct rte_cryptodev_info dev_info;
13957 : :
13958 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13959 : : uint64_t feat_flags = dev_info.feature_flags;
13960 : :
13961 : : /* Verify the capabilities */
13962 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13963 : : const struct rte_cryptodev_symmetric_capability *capability;
13964 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13965 : 1 : cap_idx.algo.aead = tdata->algo;
13966 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13967 : :
13968 [ + - ]: 1 : if (capability == NULL)
13969 : : return TEST_SKIPPED;
13970 : :
13971 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13972 : 1 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13973 : : return TEST_SKIPPED;
13974 : :
13975 : : /* not supported with CPU crypto and raw data-path APIs*/
13976 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13977 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
13978 : : return TEST_SKIPPED;
13979 : :
13980 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13981 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13982 : : printf("Device does not support RAW data-path APIs.\n");
13983 : : return TEST_SKIPPED;
13984 : : }
13985 : :
13986 : : /* Create AEAD session */
13987 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13988 : 1 : tdata->algo,
13989 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13990 : 1 : tdata->key.data, tdata->key.len,
13991 : 1 : tdata->aad.len, tdata->auth_tag.len,
13992 : 1 : tdata->iv.len);
13993 [ + - ]: 1 : if (retval < 0)
13994 : : return retval;
13995 : :
13996 : : /* alloc mbuf and set payload */
13997 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13998 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13999 : :
14000 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14001 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
14002 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
14003 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
14004 : :
14005 : : /* Create AEAD operation */
14006 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14007 [ + - ]: 1 : if (retval < 0)
14008 : : return retval;
14009 : :
14010 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14011 : :
14012 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14013 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
14014 : :
14015 : : /* Process crypto operation */
14016 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14017 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14018 : : 0);
14019 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14020 : : return retval;
14021 : : } else
14022 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14023 : : ut_params->op), "failed to process sym crypto op");
14024 : :
14025 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14026 : : "crypto op processing failed");
14027 : :
14028 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
14029 : : ut_params->op->sym->cipher.data.offset);
14030 : :
14031 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14032 : :
14033 : : /* Check if the data within the offset range is not overwritten in the OOP */
14034 : 1 : buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
14035 [ + + ]: 17 : for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
14036 [ - + ]: 16 : if (buffer_oop[i]) {
14037 : 0 : RTE_LOG(ERR, USER1,
14038 : : "Incorrect value of the output buffer header\n");
14039 : 0 : debug_hexdump(stdout, "Incorrect value:", buffer_oop,
14040 : 0 : ut_params->op->sym->cipher.data.offset);
14041 : 0 : return TEST_FAILED;
14042 : : }
14043 : : }
14044 : : /* Validate obuf */
14045 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14046 : : plaintext,
14047 : : tdata->plaintext.data,
14048 : : tdata->plaintext.len,
14049 : : "Plaintext data not as expected");
14050 : :
14051 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14052 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14053 : : "Authentication failed");
14054 : : return 0;
14055 : : }
14056 : :
14057 : : static int
14058 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
14059 : : {
14060 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
14061 : : }
14062 : :
14063 : : static int
14064 : 1 : test_authenticated_encryption_sessionless(
14065 : : const struct aead_test_data *tdata)
14066 : : {
14067 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14068 : : struct crypto_unittest_params *ut_params = &unittest_params;
14069 : :
14070 : : int retval;
14071 : : uint8_t *ciphertext, *auth_tag;
14072 : : uint16_t plaintext_pad_len;
14073 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14074 : : struct rte_cryptodev_info dev_info;
14075 : :
14076 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14077 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14078 : :
14079 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14080 : : printf("Device doesn't support Sessionless ops.\n");
14081 : 0 : return TEST_SKIPPED;
14082 : : }
14083 : :
14084 : : /* not supported with CPU crypto */
14085 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14086 : : return TEST_SKIPPED;
14087 : :
14088 : : /* Verify the capabilities */
14089 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14090 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14091 : 1 : cap_idx.algo.aead = tdata->algo;
14092 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14093 : : &cap_idx) == NULL)
14094 : : return TEST_SKIPPED;
14095 : :
14096 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14097 : :
14098 : : /* clear mbuf payload */
14099 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14100 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14101 : :
14102 : : /* Create AEAD operation */
14103 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
14104 [ + - ]: 1 : if (retval < 0)
14105 : : return retval;
14106 : :
14107 : : /* Create GCM xform */
14108 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14109 : 1 : retval = create_aead_xform(ut_params->op,
14110 : 1 : tdata->algo,
14111 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
14112 : : key, tdata->key.len,
14113 : 1 : tdata->aad.len, tdata->auth_tag.len,
14114 : 1 : tdata->iv.len);
14115 [ + - ]: 1 : if (retval < 0)
14116 : : return retval;
14117 : :
14118 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14119 : :
14120 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14121 : : RTE_CRYPTO_OP_SESSIONLESS,
14122 : : "crypto op session type not sessionless");
14123 : :
14124 : : /* Process crypto operation */
14125 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14126 : : ut_params->op), "failed to process sym crypto op");
14127 : :
14128 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14129 : :
14130 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14131 : : "crypto op status not success");
14132 : :
14133 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14134 : :
14135 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14136 : : ut_params->op->sym->cipher.data.offset);
14137 : 1 : auth_tag = ciphertext + plaintext_pad_len;
14138 : :
14139 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
14140 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
14141 : :
14142 : : /* Validate obuf */
14143 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14144 : : ciphertext,
14145 : : tdata->ciphertext.data,
14146 : : tdata->ciphertext.len,
14147 : : "Ciphertext data not as expected");
14148 : :
14149 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14150 : : auth_tag,
14151 : : tdata->auth_tag.data,
14152 : : tdata->auth_tag.len,
14153 : : "Generated auth tag not as expected");
14154 : :
14155 : : return 0;
14156 : :
14157 : : }
14158 : :
14159 : : static int
14160 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
14161 : : {
14162 : 1 : return test_authenticated_encryption_sessionless(
14163 : : &gcm_test_case_5);
14164 : : }
14165 : :
14166 : : static int
14167 : 1 : test_authenticated_decryption_sessionless(
14168 : : const struct aead_test_data *tdata)
14169 : : {
14170 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14171 : : struct crypto_unittest_params *ut_params = &unittest_params;
14172 : :
14173 : : int retval;
14174 : : uint8_t *plaintext;
14175 : 1 : uint8_t *key = alloca(tdata->key.len + 1);
14176 : : struct rte_cryptodev_info dev_info;
14177 : :
14178 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14179 : 1 : uint64_t feat_flags = dev_info.feature_flags;
14180 : :
14181 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14182 : : printf("Device doesn't support Sessionless ops.\n");
14183 : 0 : return TEST_SKIPPED;
14184 : : }
14185 : :
14186 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14187 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14188 : : printf("Device doesn't support RAW data-path APIs.\n");
14189 : 0 : return TEST_SKIPPED;
14190 : : }
14191 : :
14192 : : /* not supported with CPU crypto */
14193 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14194 : : return TEST_SKIPPED;
14195 : :
14196 : : /* Verify the capabilities */
14197 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14198 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14199 : 1 : cap_idx.algo.aead = tdata->algo;
14200 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14201 : : &cap_idx) == NULL)
14202 : : return TEST_SKIPPED;
14203 : :
14204 : : /* alloc mbuf and set payload */
14205 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14206 : :
14207 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14208 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14209 : :
14210 : : /* Create AEAD operation */
14211 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14212 [ + - ]: 1 : if (retval < 0)
14213 : : return retval;
14214 : :
14215 : : /* Create AEAD xform */
14216 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
14217 : 1 : retval = create_aead_xform(ut_params->op,
14218 : 1 : tdata->algo,
14219 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
14220 : : key, tdata->key.len,
14221 : 1 : tdata->aad.len, tdata->auth_tag.len,
14222 : 1 : tdata->iv.len);
14223 [ + - ]: 1 : if (retval < 0)
14224 : : return retval;
14225 : :
14226 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
14227 : :
14228 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14229 : : RTE_CRYPTO_OP_SESSIONLESS,
14230 : : "crypto op session type not sessionless");
14231 : :
14232 : : /* Process crypto operation */
14233 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14234 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14235 : : 0);
14236 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14237 : : return retval;
14238 : : } else
14239 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
14240 : : ts_params->valid_devs[0], ut_params->op),
14241 : : "failed to process sym crypto op");
14242 : :
14243 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14244 : :
14245 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14246 : : "crypto op status not success");
14247 : :
14248 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14249 : : ut_params->op->sym->cipher.data.offset);
14250 : :
14251 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14252 : :
14253 : : /* Validate obuf */
14254 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14255 : : plaintext,
14256 : : tdata->plaintext.data,
14257 : : tdata->plaintext.len,
14258 : : "Plaintext data not as expected");
14259 : :
14260 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
14261 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14262 : : "Authentication failed");
14263 : : return 0;
14264 : : }
14265 : :
14266 : : static int
14267 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
14268 : : {
14269 : 1 : return test_authenticated_decryption_sessionless(
14270 : : &gcm_test_case_5);
14271 : : }
14272 : :
14273 : : static int
14274 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
14275 : : {
14276 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
14277 : : }
14278 : :
14279 : : static int
14280 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
14281 : : {
14282 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
14283 : : }
14284 : :
14285 : : static int
14286 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
14287 : : {
14288 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
14289 : : }
14290 : :
14291 : : static int
14292 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_4(void)
14293 : : {
14294 : 1 : return test_authenticated_encryption(&ccm_test_case_128_4);
14295 : : }
14296 : :
14297 : : static int
14298 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
14299 : : {
14300 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
14301 : : }
14302 : :
14303 : : static int
14304 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
14305 : : {
14306 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
14307 : : }
14308 : :
14309 : : static int
14310 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
14311 : : {
14312 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
14313 : : }
14314 : :
14315 : : static int
14316 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_4(void)
14317 : : {
14318 : 1 : return test_authenticated_decryption(&ccm_test_case_128_4);
14319 : : }
14320 : :
14321 : : static int
14322 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
14323 : : {
14324 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
14325 : : }
14326 : :
14327 : : static int
14328 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
14329 : : {
14330 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
14331 : : }
14332 : :
14333 : : static int
14334 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
14335 : : {
14336 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
14337 : : }
14338 : :
14339 : : static int
14340 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
14341 : : {
14342 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
14343 : : }
14344 : :
14345 : : static int
14346 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
14347 : : {
14348 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
14349 : : }
14350 : :
14351 : : static int
14352 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14353 : : {
14354 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
14355 : : }
14356 : :
14357 : : static int
14358 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14359 : : {
14360 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
14361 : : }
14362 : :
14363 : : static int
14364 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14365 : : {
14366 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
14367 : : }
14368 : :
14369 : : static int
14370 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14371 : : {
14372 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
14373 : : }
14374 : :
14375 : : static int
14376 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14377 : : {
14378 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
14379 : : }
14380 : :
14381 : : static int
14382 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14383 : : {
14384 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
14385 : : }
14386 : :
14387 : : static int
14388 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14389 : : {
14390 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
14391 : : }
14392 : :
14393 : : static int
14394 : 1 : test_stats(void)
14395 : : {
14396 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14397 : : struct rte_cryptodev_stats stats;
14398 : :
14399 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14400 : : return TEST_SKIPPED;
14401 : :
14402 : : /* Verify the capabilities */
14403 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14404 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14405 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14406 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14407 : : &cap_idx) == NULL)
14408 : : return TEST_SKIPPED;
14409 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14410 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14411 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14412 : : &cap_idx) == NULL)
14413 : : return TEST_SKIPPED;
14414 : :
14415 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14416 : : == -ENOTSUP)
14417 : : return TEST_SKIPPED;
14418 : :
14419 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14420 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14421 : : &stats) == -ENODEV),
14422 : : "rte_cryptodev_stats_get invalid dev failed");
14423 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14424 : : "rte_cryptodev_stats_get invalid Param failed");
14425 : :
14426 : : /* Test expected values */
14427 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
14428 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14429 : : &stats),
14430 : : "rte_cryptodev_stats_get failed");
14431 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14432 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
14433 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
14434 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
14435 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
14436 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14437 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
14438 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14439 : :
14440 : : /* invalid device but should ignore and not reset device stats*/
14441 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14442 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14443 : : &stats),
14444 : : "rte_cryptodev_stats_get failed");
14445 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
14446 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14447 : :
14448 : : /* check that a valid reset clears stats */
14449 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14450 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14451 : : &stats),
14452 : : "rte_cryptodev_stats_get failed");
14453 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
14454 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14455 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
14456 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14457 : :
14458 : : return TEST_SUCCESS;
14459 : : }
14460 : :
14461 : : static int
14462 : 1 : test_device_reconfigure(void)
14463 : : {
14464 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14465 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14466 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14467 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14468 : 1 : .mp_session = ts_params->session_mpool
14469 : : };
14470 : : uint16_t qp_id, dev_id, num_devs = 0;
14471 : :
14472 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14473 : : "Need at least %d devices for test", 1);
14474 : :
14475 : 1 : dev_id = ts_params->valid_devs[0];
14476 : :
14477 : : /* Stop the device in case it's started so it can be configured */
14478 : 1 : rte_cryptodev_stop(dev_id);
14479 : :
14480 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14481 : : "Failed test for rte_cryptodev_configure: "
14482 : : "dev_num %u", dev_id);
14483 : :
14484 : : /* Reconfigure with same configure params */
14485 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14486 : : "Failed test for rte_cryptodev_configure: "
14487 : : "dev_num %u", dev_id);
14488 : :
14489 : : /* Reconfigure with just one queue pair */
14490 : 1 : ts_params->conf.nb_queue_pairs = 1;
14491 : :
14492 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14493 : : &ts_params->conf),
14494 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14495 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14496 : :
14497 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14498 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14499 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14500 : : rte_cryptodev_socket_id(
14501 : : ts_params->valid_devs[0])),
14502 : : "Failed test for "
14503 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14504 : : "%u on qp %u on cryptodev %u",
14505 : : qp_conf.nb_descriptors, qp_id,
14506 : : ts_params->valid_devs[0]);
14507 : : }
14508 : :
14509 : : /* Reconfigure with max number of queue pairs */
14510 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
14511 : :
14512 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14513 : : &ts_params->conf),
14514 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
14515 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14516 : :
14517 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14518 : :
14519 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14520 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14521 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14522 : : rte_cryptodev_socket_id(
14523 : : ts_params->valid_devs[0])),
14524 : : "Failed test for "
14525 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14526 : : "%u on qp %u on cryptodev %u",
14527 : : qp_conf.nb_descriptors, qp_id,
14528 : : ts_params->valid_devs[0]);
14529 : : }
14530 : :
14531 : : /* Start the device */
14532 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14533 : : "Failed to start cryptodev %u",
14534 : : ts_params->valid_devs[0]);
14535 : :
14536 : : /* Test expected values */
14537 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14538 : : }
14539 : :
14540 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14541 : : struct crypto_unittest_params *ut_params,
14542 : : enum rte_crypto_auth_operation op,
14543 : : const struct HMAC_MD5_vector *test_case)
14544 : : {
14545 : : uint8_t key[64];
14546 : :
14547 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
14548 : :
14549 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14550 : 4 : ut_params->auth_xform.next = NULL;
14551 : 4 : ut_params->auth_xform.auth.op = op;
14552 : :
14553 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14554 : :
14555 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14556 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
14557 : 4 : ut_params->auth_xform.auth.key.data = key;
14558 : :
14559 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
14560 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14561 : : ts_params->session_mpool);
14562 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14563 : : return TEST_SKIPPED;
14564 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14565 : :
14566 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14567 : :
14568 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14569 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14570 : :
14571 : 4 : return 0;
14572 : : }
14573 : :
14574 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14575 : : const struct HMAC_MD5_vector *test_case,
14576 : : uint8_t **plaintext)
14577 : : {
14578 : : uint16_t plaintext_pad_len;
14579 : :
14580 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14581 : :
14582 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14583 : : 16);
14584 : :
14585 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14586 : : plaintext_pad_len);
14587 : 4 : memcpy(*plaintext, test_case->plaintext.data,
14588 : 4 : test_case->plaintext.len);
14589 : :
14590 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14591 : : ut_params->ibuf, MD5_DIGEST_LEN);
14592 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14593 : : "no room to append digest");
14594 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14595 : : ut_params->ibuf, plaintext_pad_len);
14596 : :
14597 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14598 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14599 [ - + ]: 2 : test_case->auth_tag.len);
14600 : : }
14601 : :
14602 : 4 : sym_op->auth.data.offset = 0;
14603 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
14604 : :
14605 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14606 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14607 : :
14608 : 4 : return 0;
14609 : : }
14610 : :
14611 : : static int
14612 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14613 : : {
14614 : : uint16_t plaintext_pad_len;
14615 : : uint8_t *plaintext, *auth_tag;
14616 : : int ret;
14617 : :
14618 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14619 : : struct crypto_unittest_params *ut_params = &unittest_params;
14620 : : struct rte_cryptodev_info dev_info;
14621 : :
14622 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14623 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14624 : :
14625 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14626 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14627 : : printf("Device doesn't support RAW data-path APIs.\n");
14628 : 0 : return TEST_SKIPPED;
14629 : : }
14630 : :
14631 : : /* Verify the capabilities */
14632 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14633 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14634 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14635 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14636 : : &cap_idx) == NULL)
14637 : : return TEST_SKIPPED;
14638 : :
14639 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14640 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14641 : : return TEST_FAILED;
14642 : :
14643 : : /* Generate Crypto op data structure */
14644 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14645 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14646 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14647 : : "Failed to allocate symmetric crypto operation struct");
14648 : :
14649 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14650 : : 16);
14651 : :
14652 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14653 : : return TEST_FAILED;
14654 : :
14655 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14656 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14657 : : ut_params->op);
14658 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14659 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14660 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14661 : : return ret;
14662 : : } else
14663 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14664 : : process_crypto_request(ts_params->valid_devs[0],
14665 : : ut_params->op),
14666 : : "failed to process sym crypto op");
14667 : :
14668 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14669 : : "crypto op processing failed");
14670 : :
14671 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
14672 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14673 : : uint8_t *, plaintext_pad_len);
14674 : : } else {
14675 : 2 : auth_tag = plaintext + plaintext_pad_len;
14676 : : }
14677 : :
14678 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14679 : : auth_tag,
14680 : : test_case->auth_tag.data,
14681 : : test_case->auth_tag.len,
14682 : : "HMAC_MD5 generated tag not as expected");
14683 : :
14684 : : return TEST_SUCCESS;
14685 : : }
14686 : :
14687 : : static int
14688 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14689 : : {
14690 : : uint8_t *plaintext;
14691 : : int ret;
14692 : :
14693 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14694 : : struct crypto_unittest_params *ut_params = &unittest_params;
14695 : : struct rte_cryptodev_info dev_info;
14696 : :
14697 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14698 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14699 : :
14700 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14701 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14702 : : printf("Device doesn't support RAW data-path APIs.\n");
14703 : 0 : return TEST_SKIPPED;
14704 : : }
14705 : :
14706 : : /* Verify the capabilities */
14707 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14708 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14709 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14710 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14711 : : &cap_idx) == NULL)
14712 : : return TEST_SKIPPED;
14713 : :
14714 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14715 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14716 : : return TEST_FAILED;
14717 : : }
14718 : :
14719 : : /* Generate Crypto op data structure */
14720 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14721 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14722 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14723 : : "Failed to allocate symmetric crypto operation struct");
14724 : :
14725 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14726 : : return TEST_FAILED;
14727 : :
14728 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14729 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14730 : : ut_params->op);
14731 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14732 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14733 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14734 : : return ret;
14735 : : } else
14736 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14737 : : process_crypto_request(ts_params->valid_devs[0],
14738 : : ut_params->op),
14739 : : "failed to process sym crypto op");
14740 : :
14741 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14742 : : "HMAC_MD5 crypto op processing failed");
14743 : :
14744 : : return TEST_SUCCESS;
14745 : : }
14746 : :
14747 : : static int
14748 : 1 : test_MD5_HMAC_generate_case_1(void)
14749 : : {
14750 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14751 : : }
14752 : :
14753 : : static int
14754 : 1 : test_MD5_HMAC_verify_case_1(void)
14755 : : {
14756 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14757 : : }
14758 : :
14759 : : static int
14760 : 1 : test_MD5_HMAC_generate_case_2(void)
14761 : : {
14762 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14763 : : }
14764 : :
14765 : : static int
14766 : 1 : test_MD5_HMAC_verify_case_2(void)
14767 : : {
14768 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14769 : : }
14770 : :
14771 : : static int
14772 : 1 : test_multi_session(void)
14773 : : {
14774 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14775 : : struct crypto_unittest_params *ut_params = &unittest_params;
14776 : : struct rte_cryptodev_info dev_info;
14777 : : int i, nb_sess, ret = TEST_SUCCESS;
14778 : : void **sessions;
14779 : :
14780 : : /* Verify the capabilities */
14781 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14782 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14783 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14784 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14785 : : &cap_idx) == NULL)
14786 : : return TEST_SKIPPED;
14787 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14788 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14789 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14790 : : &cap_idx) == NULL)
14791 : : return TEST_SKIPPED;
14792 : :
14793 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14794 : : aes_cbc_key, hmac_sha512_key);
14795 : :
14796 : :
14797 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14798 : :
14799 : 1 : sessions = rte_malloc(NULL,
14800 : : sizeof(void *) *
14801 : : (MAX_NB_SESSIONS + 1), 0);
14802 : :
14803 : : /* Create multiple crypto sessions*/
14804 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
14805 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
14806 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14807 : : ts_params->session_mpool);
14808 [ - + ]: 4 : if (sessions[i] == NULL) {
14809 : : nb_sess = i;
14810 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14811 : : ret = TEST_SKIPPED;
14812 : : else {
14813 : : ret = TEST_FAILED;
14814 : : printf("TestCase %s() line %d failed : "
14815 : : "Session creation failed at session number %u",
14816 : : __func__, __LINE__, i);
14817 : : }
14818 : : break;
14819 : : }
14820 : :
14821 : :
14822 : : /* Attempt to send a request on each session */
14823 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14824 : : sessions[i],
14825 : : ut_params,
14826 : : ts_params,
14827 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14828 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14829 : : aes_cbc_iv);
14830 : :
14831 : : /* free crypto operation structure */
14832 : 4 : rte_crypto_op_free(ut_params->op);
14833 : 4 : ut_params->op = NULL;
14834 : :
14835 : : /*
14836 : : * free mbuf - both obuf and ibuf are usually the same,
14837 : : * so check if they point at the same address is necessary,
14838 : : * to avoid freeing the mbuf twice.
14839 : : */
14840 [ + - ]: 4 : if (ut_params->obuf) {
14841 : 4 : rte_pktmbuf_free(ut_params->obuf);
14842 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
14843 : 4 : ut_params->ibuf = 0;
14844 : 4 : ut_params->obuf = 0;
14845 : : }
14846 [ - + ]: 4 : if (ut_params->ibuf) {
14847 : 0 : rte_pktmbuf_free(ut_params->ibuf);
14848 : 0 : ut_params->ibuf = 0;
14849 : : }
14850 : :
14851 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
14852 : 0 : i++;
14853 : 0 : break;
14854 : : }
14855 : : }
14856 : :
14857 : : nb_sess = i;
14858 : :
14859 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
14860 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14861 : 4 : sessions[i]);
14862 : : }
14863 : :
14864 : 1 : rte_free(sessions);
14865 : :
14866 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14867 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14868 : :
14869 : : return ret;
14870 : : }
14871 : :
14872 : : struct multi_session_params {
14873 : : struct crypto_unittest_params ut_params;
14874 : : uint8_t *cipher_key;
14875 : : uint8_t *hmac_key;
14876 : : const uint8_t *cipher;
14877 : : const uint8_t *digest;
14878 : : uint8_t *iv;
14879 : : };
14880 : :
14881 : : #define MB_SESSION_NUMBER 3
14882 : :
14883 : : static int
14884 : 1 : test_multi_session_random_usage(void)
14885 : : {
14886 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14887 : : struct rte_cryptodev_info dev_info;
14888 : : int index = 0, ret = TEST_SUCCESS;
14889 : : uint32_t nb_sess, i, j;
14890 : : void **sessions;
14891 : 1 : struct multi_session_params ut_paramz[] = {
14892 : :
14893 : : {
14894 : : .cipher_key = ms_aes_cbc_key0,
14895 : : .hmac_key = ms_hmac_key0,
14896 : : .cipher = ms_aes_cbc_cipher0,
14897 : : .digest = ms_hmac_digest0,
14898 : : .iv = ms_aes_cbc_iv0
14899 : : },
14900 : : {
14901 : : .cipher_key = ms_aes_cbc_key1,
14902 : : .hmac_key = ms_hmac_key1,
14903 : : .cipher = ms_aes_cbc_cipher1,
14904 : : .digest = ms_hmac_digest1,
14905 : : .iv = ms_aes_cbc_iv1
14906 : : },
14907 : : {
14908 : : .cipher_key = ms_aes_cbc_key2,
14909 : : .hmac_key = ms_hmac_key2,
14910 : : .cipher = ms_aes_cbc_cipher2,
14911 : : .digest = ms_hmac_digest2,
14912 : : .iv = ms_aes_cbc_iv2
14913 : : },
14914 : :
14915 : : };
14916 : :
14917 : : /* Verify the capabilities */
14918 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14919 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14920 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14921 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14922 : : &cap_idx) == NULL)
14923 : : return TEST_SKIPPED;
14924 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14925 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14926 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14927 : : &cap_idx) == NULL)
14928 : : return TEST_SKIPPED;
14929 : :
14930 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14931 : :
14932 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
14933 : : * MAX_NB_SESSIONS) + 1, 0);
14934 : :
14935 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
14936 : :
14937 : 3 : ut_paramz[i].ut_params = unittest_params;
14938 : :
14939 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14940 : : &ut_paramz[i].ut_params,
14941 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14942 : :
14943 : : /* Create multiple crypto sessions*/
14944 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
14945 : 3 : ts_params->valid_devs[0],
14946 : : &ut_paramz[i].ut_params.auth_xform,
14947 : : ts_params->session_mpool);
14948 [ - + ]: 3 : if (sessions[i] == NULL) {
14949 : : nb_sess = i;
14950 [ # # ]: 0 : if (rte_errno == ENOTSUP)
14951 : : ret = TEST_SKIPPED;
14952 : : else {
14953 : : ret = TEST_FAILED;
14954 : : printf("TestCase %s() line %d failed : "
14955 : : "Session creation failed at session number %u",
14956 : : __func__, __LINE__, i);
14957 : : }
14958 : 0 : goto session_clear;
14959 : : }
14960 : :
14961 : : }
14962 : :
14963 : : nb_sess = i;
14964 : :
14965 : 1 : srand(time(NULL));
14966 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
14967 : :
14968 : 1 : j = rand() % MB_SESSION_NUMBER;
14969 : :
14970 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14971 : 1 : sessions[j],
14972 : : &ut_paramz[j].ut_params,
14973 : : ts_params, ut_paramz[j].cipher,
14974 : : ut_paramz[j].digest,
14975 : 1 : ut_paramz[j].iv);
14976 : :
14977 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
14978 : 1 : ut_paramz[j].ut_params.op = NULL;
14979 : :
14980 : : /*
14981 : : * free mbuf - both obuf and ibuf are usually the same,
14982 : : * so check if they point at the same address is necessary,
14983 : : * to avoid freeing the mbuf twice.
14984 : : */
14985 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
14986 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14987 : 1 : if (ut_paramz[j].ut_params.ibuf
14988 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
14989 : 1 : ut_paramz[j].ut_params.ibuf = 0;
14990 : 1 : ut_paramz[j].ut_params.obuf = 0;
14991 : : }
14992 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
14993 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14994 : 0 : ut_paramz[j].ut_params.ibuf = 0;
14995 : : }
14996 : :
14997 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
14998 : 1 : index = i;
14999 : 1 : break;
15000 : : }
15001 : : }
15002 : :
15003 : 0 : session_clear:
15004 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
15005 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
15006 : 3 : sessions[i]);
15007 : : }
15008 : :
15009 : 1 : rte_free(sessions);
15010 : :
15011 [ + - ]: 1 : if (ret != TEST_SKIPPED)
15012 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
15013 : :
15014 : : return TEST_SUCCESS;
15015 : : }
15016 : :
15017 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
15018 : : 0xab, 0xab, 0xab, 0xab,
15019 : : 0xab, 0xab, 0xab, 0xab,
15020 : : 0xab, 0xab, 0xab, 0xab};
15021 : :
15022 : : static int
15023 : 0 : test_null_invalid_operation(void)
15024 : : {
15025 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15026 : : struct crypto_unittest_params *ut_params = &unittest_params;
15027 : :
15028 : : /* This test is for NULL PMD only */
15029 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15030 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15031 : : return TEST_SKIPPED;
15032 : :
15033 : : /* Setup Cipher Parameters */
15034 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15035 : 0 : ut_params->cipher_xform.next = NULL;
15036 : :
15037 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
15038 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15039 : :
15040 : : /* Create Crypto session*/
15041 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15042 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15043 : : ts_params->session_mpool);
15044 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15045 : : return TEST_SKIPPED;
15046 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15047 : : "Session creation succeeded unexpectedly");
15048 : :
15049 : : /* Setup HMAC Parameters */
15050 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15051 : 0 : ut_params->auth_xform.next = NULL;
15052 : :
15053 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
15054 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15055 : :
15056 : : /* Create Crypto session*/
15057 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15058 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
15059 : : ts_params->session_mpool);
15060 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15061 : : return TEST_SKIPPED;
15062 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
15063 : : "Session creation succeeded unexpectedly");
15064 : :
15065 : : return TEST_SUCCESS;
15066 : : }
15067 : :
15068 : :
15069 : : #define NULL_BURST_LENGTH (32)
15070 : :
15071 : : static int
15072 : 0 : test_null_burst_operation(void)
15073 : : {
15074 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15075 : : struct crypto_unittest_params *ut_params = &unittest_params;
15076 : :
15077 : : unsigned i, burst_len = NULL_BURST_LENGTH;
15078 : :
15079 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
15080 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
15081 : :
15082 : : /* This test is for NULL PMD only */
15083 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
15084 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
15085 : : return TEST_SKIPPED;
15086 : :
15087 : : /* Setup Cipher Parameters */
15088 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15089 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15090 : :
15091 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15092 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15093 : :
15094 : : /* Setup HMAC Parameters */
15095 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15096 : 0 : ut_params->auth_xform.next = NULL;
15097 : :
15098 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15099 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15100 : :
15101 : : /* Create Crypto session*/
15102 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15103 : 0 : ts_params->valid_devs[0],
15104 : : &ut_params->auth_xform,
15105 : : ts_params->session_mpool);
15106 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15107 : : return TEST_SKIPPED;
15108 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15109 : :
15110 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
15111 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
15112 : : burst_len, "failed to generate burst of crypto ops");
15113 : :
15114 : : /* Generate an operation for each mbuf in burst */
15115 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15116 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15117 : :
15118 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
15119 : :
15120 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
15121 : : sizeof(unsigned));
15122 : 0 : *data = i;
15123 : :
15124 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
15125 : :
15126 : 0 : burst[i]->sym->m_src = m;
15127 : : }
15128 : :
15129 : : /* Process crypto operation */
15130 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
15131 : : 0, burst, burst_len),
15132 : : burst_len,
15133 : : "Error enqueuing burst");
15134 : :
15135 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
15136 : : 0, burst_dequeued, burst_len),
15137 : : burst_len,
15138 : : "Error dequeuing burst");
15139 : :
15140 : :
15141 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
15142 [ # # ]: 0 : TEST_ASSERT_EQUAL(
15143 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
15144 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
15145 : : uint32_t *),
15146 : : "data not as expected");
15147 : :
15148 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
15149 : 0 : rte_crypto_op_free(burst[i]);
15150 : : }
15151 : :
15152 : : return TEST_SUCCESS;
15153 : : }
15154 : :
15155 : : static uint16_t
15156 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15157 : : uint16_t nb_ops, void *user_param)
15158 : : {
15159 : : RTE_SET_USED(dev_id);
15160 : : RTE_SET_USED(qp_id);
15161 : : RTE_SET_USED(ops);
15162 : : RTE_SET_USED(user_param);
15163 : :
15164 : 0 : enq_cb_called = true;
15165 : : printf("crypto enqueue callback called\n");
15166 : 0 : return nb_ops;
15167 : : }
15168 : :
15169 : : static uint16_t
15170 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15171 : : uint16_t nb_ops, void *user_param)
15172 : : {
15173 : : RTE_SET_USED(dev_id);
15174 : : RTE_SET_USED(qp_id);
15175 : : RTE_SET_USED(ops);
15176 : : RTE_SET_USED(user_param);
15177 : :
15178 : 0 : deq_cb_called = true;
15179 : : printf("crypto dequeue callback called\n");
15180 : 0 : return nb_ops;
15181 : : }
15182 : :
15183 : : /*
15184 : : * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
15185 : : */
15186 : : static int
15187 : 0 : test_enqdeq_callback_null_cipher(void)
15188 : : {
15189 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15190 : : struct crypto_unittest_params *ut_params = &unittest_params;
15191 : :
15192 : : /* Setup Cipher Parameters */
15193 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15194 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15195 : :
15196 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15197 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15198 : :
15199 : : /* Setup Auth Parameters */
15200 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15201 : 0 : ut_params->auth_xform.next = NULL;
15202 : :
15203 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15204 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15205 : :
15206 : : /* Create Crypto session */
15207 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
15208 : : &ut_params->auth_xform, ts_params->session_mpool);
15209 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15210 : : return TEST_SKIPPED;
15211 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15212 : :
15213 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15214 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
15215 : :
15216 : : /* Allocate mbuf */
15217 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15218 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
15219 : :
15220 : : /* Append some random data */
15221 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
15222 : : "no room to append data");
15223 : :
15224 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15225 : :
15226 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15227 : :
15228 : : /* Process crypto operation */
15229 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
15230 : : "failed to process sym crypto op");
15231 : :
15232 : : return 0;
15233 : : }
15234 : :
15235 : : static int
15236 : 1 : test_enq_callback_setup(void)
15237 : : {
15238 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15239 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15240 : : struct rte_cryptodev_info dev_info;
15241 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15242 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15243 : : };
15244 : :
15245 : : struct rte_cryptodev_cb *cb;
15246 : : uint16_t qp_id = 0;
15247 : : int j = 0;
15248 : :
15249 : : /* Skip test if synchronous API is used */
15250 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15251 : : return TEST_SKIPPED;
15252 : :
15253 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15254 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15255 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15256 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15257 : : &cap_idx) == NULL)
15258 : : return TEST_SKIPPED;
15259 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15260 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15261 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15262 : : &cap_idx) == NULL)
15263 : : return TEST_SKIPPED;
15264 : :
15265 : : /* Stop the device in case it's started so it can be configured */
15266 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15267 : :
15268 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15269 : :
15270 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15271 : : &ts_params->conf),
15272 : : "Failed to configure cryptodev %u",
15273 : : ts_params->valid_devs[0]);
15274 : :
15275 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15276 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15277 : :
15278 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15279 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15280 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15281 : : "Failed test for "
15282 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15283 : : "%u on qp %u on cryptodev %u",
15284 : : qp_conf.nb_descriptors, qp_id,
15285 : : ts_params->valid_devs[0]);
15286 : :
15287 : 0 : enq_cb_called = false;
15288 : : /* Test with invalid crypto device */
15289 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
15290 : : qp_id, test_enq_callback, NULL);
15291 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15292 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15293 : : "rte_cryptodev_add_enq_callback() "
15294 : : "Not supported, skipped\n", __func__, __LINE__);
15295 : 0 : return TEST_SKIPPED;
15296 : : }
15297 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15298 : : "cryptodev %u did not fail",
15299 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15300 : :
15301 : : /* Test with invalid queue pair */
15302 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15303 : 0 : dev_info.max_nb_queue_pairs + 1,
15304 : : test_enq_callback, NULL);
15305 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15306 : : "cryptodev %u did not fail",
15307 : : dev_info.max_nb_queue_pairs + 1,
15308 : : ts_params->valid_devs[0]);
15309 : :
15310 : : /* Test with NULL callback */
15311 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15312 : : qp_id, NULL, NULL);
15313 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15314 : : "cryptodev %u did not fail",
15315 : : qp_id, ts_params->valid_devs[0]);
15316 : :
15317 : : /* Test with valid configuration */
15318 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15319 : : qp_id, test_enq_callback, NULL);
15320 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15321 : : "qp %u on cryptodev %u",
15322 : : qp_id, ts_params->valid_devs[0]);
15323 : :
15324 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15325 : :
15326 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
15327 : :
15328 : : /* Wait until callback not called. */
15329 [ # # # # ]: 0 : while (!enq_cb_called && (j++ < 10))
15330 : : rte_delay_ms(10);
15331 : :
15332 : : /* Test with invalid crypto device */
15333 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15334 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15335 : : "Expected call to fail as crypto device is invalid");
15336 : :
15337 : : /* Test with invalid queue pair */
15338 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15339 : : ts_params->valid_devs[0],
15340 : : dev_info.max_nb_queue_pairs + 1, cb),
15341 : : "Expected call to fail as queue pair is invalid");
15342 : :
15343 : : /* Test with NULL callback */
15344 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15345 : : ts_params->valid_devs[0], qp_id, NULL),
15346 : : "Expected call to fail as callback is NULL");
15347 : :
15348 : : /* Test with valid configuration */
15349 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
15350 : : ts_params->valid_devs[0], qp_id, cb),
15351 : : "Failed test to remove callback on "
15352 : : "qp %u on cryptodev %u",
15353 : : qp_id, ts_params->valid_devs[0]);
15354 : :
15355 [ # # ]: 0 : TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
15356 : :
15357 : : return TEST_SUCCESS;
15358 : : }
15359 : :
15360 : : static int
15361 : 1 : test_deq_callback_setup(void)
15362 : : {
15363 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15364 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15365 : : struct rte_cryptodev_info dev_info;
15366 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
15367 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
15368 : : };
15369 : :
15370 : : struct rte_cryptodev_cb *cb;
15371 : : uint16_t qp_id = 0;
15372 : : int j = 0;
15373 : :
15374 : : /* Skip test if synchronous API is used */
15375 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15376 : : return TEST_SKIPPED;
15377 : :
15378 : : /* Verify the crypto capabilities for which enqueue/dequeue is done. */
15379 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15380 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15381 [ - + ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15382 : : &cap_idx) == NULL)
15383 : : return TEST_SKIPPED;
15384 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15385 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15386 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15387 : : &cap_idx) == NULL)
15388 : : return TEST_SKIPPED;
15389 : :
15390 : : /* Stop the device in case it's started so it can be configured */
15391 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
15392 : :
15393 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15394 : :
15395 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15396 : : &ts_params->conf),
15397 : : "Failed to configure cryptodev %u",
15398 : : ts_params->valid_devs[0]);
15399 : :
15400 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15401 : 0 : qp_conf.mp_session = ts_params->session_mpool;
15402 : :
15403 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15404 : : ts_params->valid_devs[0], qp_id, &qp_conf,
15405 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15406 : : "Failed test for "
15407 : : "rte_cryptodev_queue_pair_setup: num_inflights "
15408 : : "%u on qp %u on cryptodev %u",
15409 : : qp_conf.nb_descriptors, qp_id,
15410 : : ts_params->valid_devs[0]);
15411 : :
15412 : 0 : deq_cb_called = false;
15413 : : /* Test with invalid crypto device */
15414 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15415 : : qp_id, test_deq_callback, NULL);
15416 [ # # ]: 0 : if (rte_errno == ENOTSUP) {
15417 : 0 : RTE_LOG(ERR, USER1, "%s line %d: "
15418 : : "rte_cryptodev_add_deq_callback() "
15419 : : "Not supported, skipped\n", __func__, __LINE__);
15420 : 0 : return TEST_SKIPPED;
15421 : : }
15422 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15423 : : "cryptodev %u did not fail",
15424 : : qp_id, RTE_CRYPTO_MAX_DEVS);
15425 : :
15426 : : /* Test with invalid queue pair */
15427 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15428 : 0 : dev_info.max_nb_queue_pairs + 1,
15429 : : test_deq_callback, NULL);
15430 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15431 : : "cryptodev %u did not fail",
15432 : : dev_info.max_nb_queue_pairs + 1,
15433 : : ts_params->valid_devs[0]);
15434 : :
15435 : : /* Test with NULL callback */
15436 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15437 : : qp_id, NULL, NULL);
15438 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15439 : : "cryptodev %u did not fail",
15440 : : qp_id, ts_params->valid_devs[0]);
15441 : :
15442 : : /* Test with valid configuration */
15443 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15444 : : qp_id, test_deq_callback, NULL);
15445 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15446 : : "qp %u on cryptodev %u",
15447 : : qp_id, ts_params->valid_devs[0]);
15448 : :
15449 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
15450 : :
15451 [ # # ]: 0 : TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15452 : :
15453 : : /* Wait until callback not called. */
15454 [ # # # # ]: 0 : while (!deq_cb_called && (j++ < 10))
15455 : : rte_delay_ms(10);
15456 : :
15457 : : /* Test with invalid crypto device */
15458 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15459 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15460 : : "Expected call to fail as crypto device is invalid");
15461 : :
15462 : : /* Test with invalid queue pair */
15463 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15464 : : ts_params->valid_devs[0],
15465 : : dev_info.max_nb_queue_pairs + 1, cb),
15466 : : "Expected call to fail as queue pair is invalid");
15467 : :
15468 : : /* Test with NULL callback */
15469 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15470 : : ts_params->valid_devs[0], qp_id, NULL),
15471 : : "Expected call to fail as callback is NULL");
15472 : :
15473 : : /* Test with valid configuration */
15474 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15475 : : ts_params->valid_devs[0], qp_id, cb),
15476 : : "Failed test to remove callback on "
15477 : : "qp %u on cryptodev %u",
15478 : : qp_id, ts_params->valid_devs[0]);
15479 : :
15480 [ # # ]: 0 : TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15481 : :
15482 : : return TEST_SUCCESS;
15483 : : }
15484 : :
15485 : : static void
15486 : : generate_gmac_large_plaintext(uint8_t *data)
15487 : : {
15488 : : uint16_t i;
15489 : :
15490 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15491 : 4082 : memcpy(&data[i], &data[0], 32);
15492 : : }
15493 : :
15494 : : static int
15495 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
15496 : : const struct gmac_test_data *tdata)
15497 : : {
15498 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15499 : : struct crypto_unittest_params *ut_params = &unittest_params;
15500 : : struct rte_crypto_sym_op *sym_op;
15501 : :
15502 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15503 : :
15504 : : /* Generate Crypto op data structure */
15505 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15506 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15507 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
15508 : : "Failed to allocate symmetric crypto operation struct");
15509 : :
15510 : : sym_op = ut_params->op->sym;
15511 : :
15512 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15513 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
15514 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15515 : : "no room to append digest");
15516 : :
15517 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15518 : : ut_params->ibuf, plaintext_pad_len);
15519 : :
15520 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15521 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15522 [ - + ]: 4 : tdata->gmac_tag.len);
15523 : 4 : debug_hexdump(stdout, "digest:",
15524 : 4 : sym_op->auth.digest.data,
15525 : 4 : tdata->gmac_tag.len);
15526 : : }
15527 : :
15528 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15529 : : uint8_t *, IV_OFFSET);
15530 : :
15531 [ + - ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15532 : :
15533 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15534 : :
15535 : 8 : sym_op->cipher.data.length = 0;
15536 : 8 : sym_op->cipher.data.offset = 0;
15537 : :
15538 : 8 : sym_op->auth.data.offset = 0;
15539 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
15540 : :
15541 : 8 : return 0;
15542 : : }
15543 : :
15544 : : static int
15545 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15546 : : const struct gmac_test_data *tdata,
15547 : : void *digest_mem, uint64_t digest_phys)
15548 : : {
15549 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15550 : : struct crypto_unittest_params *ut_params = &unittest_params;
15551 : : struct rte_crypto_sym_op *sym_op;
15552 : :
15553 : : /* Generate Crypto op data structure */
15554 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15555 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15556 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15557 : : "Failed to allocate symmetric crypto operation struct");
15558 : :
15559 : : sym_op = ut_params->op->sym;
15560 : :
15561 : 0 : sym_op->auth.digest.data = digest_mem;
15562 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15563 : : "no room to append digest");
15564 : :
15565 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
15566 : :
15567 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15568 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15569 [ # # ]: 0 : tdata->gmac_tag.len);
15570 : 0 : debug_hexdump(stdout, "digest:",
15571 : 0 : sym_op->auth.digest.data,
15572 : 0 : tdata->gmac_tag.len);
15573 : : }
15574 : :
15575 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15576 : : uint8_t *, IV_OFFSET);
15577 : :
15578 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15579 : :
15580 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15581 : :
15582 : 0 : sym_op->cipher.data.length = 0;
15583 : 0 : sym_op->cipher.data.offset = 0;
15584 : :
15585 : 0 : sym_op->auth.data.offset = 0;
15586 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
15587 : :
15588 : 0 : return 0;
15589 : : }
15590 : :
15591 : 8 : static int create_gmac_session(uint8_t dev_id,
15592 : : const struct gmac_test_data *tdata,
15593 : : enum rte_crypto_auth_operation auth_op)
15594 : : {
15595 : 8 : uint8_t *auth_key = alloca(tdata->key.len);
15596 : :
15597 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15598 : : struct crypto_unittest_params *ut_params = &unittest_params;
15599 : :
15600 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
15601 : :
15602 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15603 : 8 : ut_params->auth_xform.next = NULL;
15604 : :
15605 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15606 : 8 : ut_params->auth_xform.auth.op = auth_op;
15607 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15608 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
15609 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
15610 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15611 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15612 : :
15613 : :
15614 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15615 : : &ut_params->auth_xform, ts_params->session_mpool);
15616 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15617 : : return TEST_SKIPPED;
15618 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15619 : :
15620 : : return 0;
15621 : : }
15622 : :
15623 : : static int
15624 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15625 : : {
15626 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15627 : : struct crypto_unittest_params *ut_params = &unittest_params;
15628 : : struct rte_cryptodev_info dev_info;
15629 : :
15630 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15631 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15632 : :
15633 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15634 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15635 : : printf("Device doesn't support RAW data-path APIs.\n");
15636 : 0 : return TEST_SKIPPED;
15637 : : }
15638 : :
15639 : : int retval;
15640 : :
15641 : : uint8_t *auth_tag, *plaintext;
15642 : : uint16_t plaintext_pad_len;
15643 : :
15644 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15645 : : "No GMAC length in the source data");
15646 : :
15647 : : /* Verify the capabilities */
15648 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15649 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15650 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15651 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15652 : : &cap_idx) == NULL)
15653 : : return TEST_SKIPPED;
15654 : :
15655 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15656 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15657 : :
15658 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15659 : : return TEST_SKIPPED;
15660 [ + - ]: 4 : if (retval < 0)
15661 : : return retval;
15662 : :
15663 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15664 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15665 : : else
15666 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15667 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15668 : : "Failed to allocate input buffer in mempool");
15669 : :
15670 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15671 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15672 : :
15673 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15674 : : /*
15675 : : * Runtime generate the large plain text instead of use hard code
15676 : : * plain text vector. It is done to avoid create huge source file
15677 : : * with the test vector.
15678 : : */
15679 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15680 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15681 : :
15682 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15683 : : plaintext_pad_len);
15684 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15685 : :
15686 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15687 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15688 : 4 : tdata->plaintext.len);
15689 : :
15690 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15691 : : tdata);
15692 : :
15693 [ + - ]: 4 : if (retval < 0)
15694 : : return retval;
15695 : :
15696 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15697 : :
15698 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15699 : :
15700 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15701 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15702 : : ut_params->op);
15703 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15704 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15705 : : 0);
15706 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15707 : : return retval;
15708 : : } else
15709 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15710 : : process_crypto_request(ts_params->valid_devs[0],
15711 : : ut_params->op), "failed to process sym crypto op");
15712 : :
15713 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15714 : : "crypto op processing failed");
15715 : :
15716 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
15717 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15718 : : uint8_t *, plaintext_pad_len);
15719 : : } else {
15720 : 4 : auth_tag = plaintext + plaintext_pad_len;
15721 : : }
15722 : :
15723 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15724 : :
15725 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15726 : : auth_tag,
15727 : : tdata->gmac_tag.data,
15728 : : tdata->gmac_tag.len,
15729 : : "GMAC Generated auth tag not as expected");
15730 : :
15731 : : return 0;
15732 : : }
15733 : :
15734 : : static int
15735 : 1 : test_AES_GMAC_authentication_test_case_1(void)
15736 : : {
15737 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
15738 : : }
15739 : :
15740 : : static int
15741 : 1 : test_AES_GMAC_authentication_test_case_2(void)
15742 : : {
15743 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
15744 : : }
15745 : :
15746 : : static int
15747 : 1 : test_AES_GMAC_authentication_test_case_3(void)
15748 : : {
15749 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
15750 : : }
15751 : :
15752 : : static int
15753 : 1 : test_AES_GMAC_authentication_test_case_4(void)
15754 : : {
15755 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
15756 : : }
15757 : :
15758 : : static int
15759 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15760 : : {
15761 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15762 : : struct crypto_unittest_params *ut_params = &unittest_params;
15763 : : int retval;
15764 : : uint32_t plaintext_pad_len;
15765 : : uint8_t *plaintext;
15766 : : struct rte_cryptodev_info dev_info;
15767 : :
15768 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15769 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15770 : :
15771 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15772 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15773 : : printf("Device doesn't support RAW data-path APIs.\n");
15774 : 0 : return TEST_SKIPPED;
15775 : : }
15776 : :
15777 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15778 : : "No GMAC length in the source data");
15779 : :
15780 : : /* Verify the capabilities */
15781 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15782 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15783 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15784 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15785 : : &cap_idx) == NULL)
15786 : : return TEST_SKIPPED;
15787 : :
15788 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15789 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15790 : :
15791 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15792 : : return TEST_SKIPPED;
15793 [ + - ]: 4 : if (retval < 0)
15794 : : return retval;
15795 : :
15796 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15797 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15798 : : else
15799 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15800 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15801 : : "Failed to allocate input buffer in mempool");
15802 : :
15803 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15804 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15805 : :
15806 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15807 : :
15808 : : /*
15809 : : * Runtime generate the large plain text instead of use hard code
15810 : : * plain text vector. It is done to avoid create huge source file
15811 : : * with the test vector.
15812 : : */
15813 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15814 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15815 : :
15816 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15817 : : plaintext_pad_len);
15818 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15819 : :
15820 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15821 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15822 : 4 : tdata->plaintext.len);
15823 : :
15824 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15825 : : tdata);
15826 : :
15827 [ + - ]: 4 : if (retval < 0)
15828 : : return retval;
15829 : :
15830 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15831 : :
15832 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15833 : :
15834 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15835 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15836 : : ut_params->op);
15837 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15838 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15839 : : 0);
15840 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15841 : : return retval;
15842 : : } else
15843 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15844 : : process_crypto_request(ts_params->valid_devs[0],
15845 : : ut_params->op), "failed to process sym crypto op");
15846 : :
15847 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15848 : : "crypto op processing failed");
15849 : :
15850 : : return 0;
15851 : :
15852 : : }
15853 : :
15854 : : static int
15855 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
15856 : : {
15857 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15858 : : }
15859 : :
15860 : : static int
15861 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
15862 : : {
15863 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15864 : : }
15865 : :
15866 : : static int
15867 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
15868 : : {
15869 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15870 : : }
15871 : :
15872 : : static int
15873 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
15874 : : {
15875 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15876 : : }
15877 : :
15878 : : static int
15879 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15880 : : uint32_t fragsz)
15881 : : {
15882 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15883 : : struct crypto_unittest_params *ut_params = &unittest_params;
15884 : : struct rte_cryptodev_info dev_info;
15885 : : uint64_t feature_flags;
15886 : : unsigned int trn_data = 0;
15887 : : void *digest_mem = NULL;
15888 : : unsigned int to_trn = 0;
15889 : : struct rte_mbuf *buf = NULL;
15890 : : uint8_t *auth_tag, *plaintext;
15891 : : int retval;
15892 : :
15893 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15894 : : "No GMAC length in the source data");
15895 : :
15896 : : /* Verify the capabilities */
15897 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15898 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15899 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15900 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15901 : : &cap_idx) == NULL)
15902 : : return TEST_SKIPPED;
15903 : :
15904 : : /* Check for any input SGL support */
15905 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15906 : 4 : feature_flags = dev_info.feature_flags;
15907 : :
15908 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15909 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15910 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15911 : : return TEST_SKIPPED;
15912 : :
15913 : 0 : if (fragsz > tdata->plaintext.len)
15914 : : fragsz = tdata->plaintext.len;
15915 : :
15916 : 0 : uint16_t plaintext_len = fragsz;
15917 : :
15918 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
15919 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15920 : :
15921 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15922 : : return TEST_SKIPPED;
15923 [ # # ]: 0 : if (retval < 0)
15924 : : return retval;
15925 : :
15926 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15927 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15928 : : "Failed to allocate input buffer in mempool");
15929 : :
15930 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15931 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15932 : :
15933 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15934 : : plaintext_len);
15935 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15936 : :
15937 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15938 : :
15939 : : trn_data += plaintext_len;
15940 : :
15941 : 0 : buf = ut_params->ibuf;
15942 : :
15943 : : /*
15944 : : * Loop until no more fragments
15945 : : */
15946 : :
15947 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15948 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15949 : : (tdata->plaintext.len - trn_data) : fragsz;
15950 : :
15951 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15952 : : buf = buf->next;
15953 : 0 : ut_params->ibuf->nb_segs++;
15954 : :
15955 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15956 : : rte_pktmbuf_tailroom(buf));
15957 : :
15958 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15959 : : to_trn);
15960 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
15961 : :
15962 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15963 : : to_trn);
15964 : 0 : trn_data += to_trn;
15965 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15966 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15967 : 0 : tdata->gmac_tag.len);
15968 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append digest data");
15969 : : }
15970 : : }
15971 : :
15972 : : /*
15973 : : * Place digest at the end of the last buffer
15974 : : */
15975 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15976 : :
15977 [ # # ]: 0 : if (!digest_mem) {
15978 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15979 : 0 : + tdata->gmac_tag.len);
15980 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15981 : : tdata->plaintext.len);
15982 : : }
15983 : :
15984 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15985 : : tdata, digest_mem, digest_phys);
15986 : :
15987 [ # # ]: 0 : if (retval < 0)
15988 : : return retval;
15989 : :
15990 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15991 : :
15992 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15993 : :
15994 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15995 : : return TEST_SKIPPED;
15996 : :
15997 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15998 : : process_crypto_request(ts_params->valid_devs[0],
15999 : : ut_params->op), "failed to process sym crypto op");
16000 : :
16001 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16002 : : "crypto op processing failed");
16003 : :
16004 : : auth_tag = digest_mem;
16005 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
16006 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16007 : : auth_tag,
16008 : : tdata->gmac_tag.data,
16009 : : tdata->gmac_tag.len,
16010 : : "GMAC Generated auth tag not as expected");
16011 : :
16012 : : return 0;
16013 : : }
16014 : :
16015 : : /* Segment size not multiple of block size (16B) */
16016 : : static int
16017 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
16018 : : {
16019 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
16020 : : }
16021 : :
16022 : : static int
16023 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
16024 : : {
16025 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
16026 : : }
16027 : :
16028 : : static int
16029 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
16030 : : {
16031 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
16032 : : }
16033 : :
16034 : : /* Segment size not multiple of block size (16B) */
16035 : : static int
16036 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
16037 : : {
16038 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
16039 : : }
16040 : :
16041 : : struct test_crypto_vector {
16042 : : enum rte_crypto_cipher_algorithm crypto_algo;
16043 : : unsigned int cipher_offset;
16044 : : unsigned int cipher_len;
16045 : :
16046 : : struct {
16047 : : uint8_t data[64];
16048 : : unsigned int len;
16049 : : } cipher_key;
16050 : :
16051 : : struct {
16052 : : uint8_t data[64];
16053 : : unsigned int len;
16054 : : } iv;
16055 : :
16056 : : struct {
16057 : : const uint8_t *data;
16058 : : unsigned int len;
16059 : : } plaintext;
16060 : :
16061 : : struct {
16062 : : const uint8_t *data;
16063 : : unsigned int len;
16064 : : } ciphertext;
16065 : :
16066 : : enum rte_crypto_auth_algorithm auth_algo;
16067 : : unsigned int auth_offset;
16068 : :
16069 : : struct {
16070 : : uint8_t data[128];
16071 : : unsigned int len;
16072 : : } auth_key;
16073 : :
16074 : : struct {
16075 : : const uint8_t *data;
16076 : : unsigned int len;
16077 : : } aad;
16078 : :
16079 : : struct {
16080 : : uint8_t data[128];
16081 : : unsigned int len;
16082 : : } digest;
16083 : : };
16084 : :
16085 : : static const struct test_crypto_vector
16086 : : hmac_sha1_test_crypto_vector = {
16087 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16088 : : .plaintext = {
16089 : : .data = plaintext_hash,
16090 : : .len = 512
16091 : : },
16092 : : .auth_key = {
16093 : : .data = {
16094 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16095 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16096 : : 0xDE, 0xF4, 0xDE, 0xAD
16097 : : },
16098 : : .len = 20
16099 : : },
16100 : : .digest = {
16101 : : .data = {
16102 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
16103 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
16104 : : 0x3F, 0x91, 0x64, 0x59
16105 : : },
16106 : : .len = 20
16107 : : }
16108 : : };
16109 : :
16110 : : static const struct test_crypto_vector
16111 : : aes128_gmac_test_vector = {
16112 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
16113 : : .plaintext = {
16114 : : .data = plaintext_hash,
16115 : : .len = 512
16116 : : },
16117 : : .iv = {
16118 : : .data = {
16119 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16120 : : 0x08, 0x09, 0x0A, 0x0B
16121 : : },
16122 : : .len = 12
16123 : : },
16124 : : .auth_key = {
16125 : : .data = {
16126 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16127 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
16128 : : },
16129 : : .len = 16
16130 : : },
16131 : : .digest = {
16132 : : .data = {
16133 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
16134 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
16135 : : },
16136 : : .len = 16
16137 : : }
16138 : : };
16139 : :
16140 : : static const struct test_crypto_vector
16141 : : aes128cbc_hmac_sha1_test_vector = {
16142 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16143 : : .cipher_offset = 0,
16144 : : .cipher_len = 512,
16145 : : .cipher_key = {
16146 : : .data = {
16147 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16148 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16149 : : },
16150 : : .len = 16
16151 : : },
16152 : : .iv = {
16153 : : .data = {
16154 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16155 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16156 : : },
16157 : : .len = 16
16158 : : },
16159 : : .plaintext = {
16160 : : .data = plaintext_hash,
16161 : : .len = 512
16162 : : },
16163 : : .ciphertext = {
16164 : : .data = ciphertext512_aes128cbc,
16165 : : .len = 512
16166 : : },
16167 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16168 : : .auth_offset = 0,
16169 : : .auth_key = {
16170 : : .data = {
16171 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16172 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16173 : : 0xDE, 0xF4, 0xDE, 0xAD
16174 : : },
16175 : : .len = 20
16176 : : },
16177 : : .digest = {
16178 : : .data = {
16179 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
16180 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16181 : : 0x18, 0x8C, 0x1D, 0x32
16182 : : },
16183 : : .len = 20
16184 : : }
16185 : : };
16186 : :
16187 : : static const struct test_crypto_vector
16188 : : aes128cbc_hmac_sha1_aad_test_vector = {
16189 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16190 : : .cipher_offset = 8,
16191 : : .cipher_len = 496,
16192 : : .cipher_key = {
16193 : : .data = {
16194 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16195 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16196 : : },
16197 : : .len = 16
16198 : : },
16199 : : .iv = {
16200 : : .data = {
16201 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16202 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16203 : : },
16204 : : .len = 16
16205 : : },
16206 : : .plaintext = {
16207 : : .data = plaintext_hash,
16208 : : .len = 512
16209 : : },
16210 : : .ciphertext = {
16211 : : .data = ciphertext512_aes128cbc_aad,
16212 : : .len = 512
16213 : : },
16214 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16215 : : .auth_offset = 0,
16216 : : .auth_key = {
16217 : : .data = {
16218 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16219 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16220 : : 0xDE, 0xF4, 0xDE, 0xAD
16221 : : },
16222 : : .len = 20
16223 : : },
16224 : : .digest = {
16225 : : .data = {
16226 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
16227 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
16228 : : 0x62, 0x0F, 0xFB, 0x10
16229 : : },
16230 : : .len = 20
16231 : : }
16232 : : };
16233 : :
16234 : : static void
16235 : : data_corruption(uint8_t *data)
16236 : : {
16237 : 3 : data[0] += 1;
16238 : 3 : }
16239 : :
16240 : : static void
16241 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
16242 : : {
16243 : 3 : data[tag_offset] += 1;
16244 : 3 : }
16245 : :
16246 : : static int
16247 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
16248 : : uint8_t dev_id,
16249 : : const struct test_crypto_vector *reference,
16250 : : enum rte_crypto_auth_operation auth_op)
16251 : : {
16252 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16253 : 2 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16254 : :
16255 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16256 : :
16257 : : /* Setup Authentication Parameters */
16258 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16259 : 2 : ut_params->auth_xform.auth.op = auth_op;
16260 : 2 : ut_params->auth_xform.next = NULL;
16261 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16262 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16263 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
16264 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16265 : :
16266 : : /* Create Crypto session*/
16267 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16268 : : &ut_params->auth_xform,
16269 : : ts_params->session_mpool);
16270 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16271 : : return TEST_SKIPPED;
16272 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16273 : :
16274 : : return 0;
16275 : : }
16276 : :
16277 : : static int
16278 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
16279 : : uint8_t dev_id,
16280 : : const struct test_crypto_vector *reference,
16281 : : enum rte_crypto_auth_operation auth_op,
16282 : : enum rte_crypto_cipher_operation cipher_op)
16283 : : {
16284 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16285 : 4 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16286 : 4 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16287 : :
16288 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
16289 : : reference->cipher_key.len);
16290 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16291 : :
16292 : : /* Setup Authentication Parameters */
16293 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16294 : 4 : ut_params->auth_xform.auth.op = auth_op;
16295 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16296 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16297 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
16298 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16299 : :
16300 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
16301 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
16302 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
16303 : : } else {
16304 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16305 : :
16306 : : /* Setup Cipher Parameters */
16307 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16308 : 2 : ut_params->cipher_xform.next = NULL;
16309 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16310 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
16311 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16312 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16313 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16314 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16315 : : }
16316 : :
16317 : : /* Create Crypto session*/
16318 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16319 : : &ut_params->auth_xform,
16320 : : ts_params->session_mpool);
16321 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16322 : : return TEST_SKIPPED;
16323 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16324 : :
16325 : : return 0;
16326 : : }
16327 : :
16328 : : static int
16329 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
16330 : : struct crypto_unittest_params *ut_params,
16331 : : const struct test_crypto_vector *reference,
16332 : : unsigned int auth_generate)
16333 : : {
16334 : : /* Generate Crypto op data structure */
16335 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16336 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16337 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16338 : : "Failed to allocate pktmbuf offload");
16339 : :
16340 : : /* Set crypto operation data parameters */
16341 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16342 : :
16343 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16344 : :
16345 : : /* set crypto operation source mbuf */
16346 : 2 : sym_op->m_src = ut_params->ibuf;
16347 : :
16348 : : /* digest */
16349 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16350 : 2 : ut_params->ibuf, reference->digest.len);
16351 : :
16352 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16353 : : "no room to append auth tag");
16354 : :
16355 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16356 : : ut_params->ibuf, reference->plaintext.len);
16357 : :
16358 [ - + ]: 2 : if (auth_generate)
16359 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16360 : : else
16361 : 2 : memcpy(sym_op->auth.digest.data,
16362 : 2 : reference->digest.data,
16363 : 2 : reference->digest.len);
16364 : :
16365 : 2 : debug_hexdump(stdout, "digest:",
16366 : 2 : sym_op->auth.digest.data,
16367 : 2 : reference->digest.len);
16368 : :
16369 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16370 : 2 : sym_op->auth.data.offset = 0;
16371 : :
16372 : 2 : return 0;
16373 : : }
16374 : :
16375 : : static int
16376 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16377 : : struct crypto_unittest_params *ut_params,
16378 : : const struct test_crypto_vector *reference,
16379 : : unsigned int auth_generate)
16380 : : {
16381 : : /* Generate Crypto op data structure */
16382 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16383 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16384 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
16385 : : "Failed to allocate pktmbuf offload");
16386 : :
16387 : : /* Set crypto operation data parameters */
16388 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16389 : :
16390 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16391 : :
16392 : : /* set crypto operation source mbuf */
16393 : 2 : sym_op->m_src = ut_params->ibuf;
16394 : :
16395 : : /* digest */
16396 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16397 : 2 : ut_params->ibuf, reference->digest.len);
16398 : :
16399 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16400 : : "no room to append auth tag");
16401 : :
16402 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16403 : : ut_params->ibuf, reference->ciphertext.len);
16404 : :
16405 [ - + ]: 2 : if (auth_generate)
16406 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16407 : : else
16408 : 2 : memcpy(sym_op->auth.digest.data,
16409 : 2 : reference->digest.data,
16410 : 2 : reference->digest.len);
16411 : :
16412 : 2 : debug_hexdump(stdout, "digest:",
16413 : 2 : sym_op->auth.digest.data,
16414 : 2 : reference->digest.len);
16415 : :
16416 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16417 [ + - ]: 2 : reference->iv.data, reference->iv.len);
16418 : :
16419 : 2 : sym_op->cipher.data.length = 0;
16420 : 2 : sym_op->cipher.data.offset = 0;
16421 : :
16422 : 2 : sym_op->auth.data.length = reference->plaintext.len;
16423 : 2 : sym_op->auth.data.offset = 0;
16424 : :
16425 : 2 : return 0;
16426 : : }
16427 : :
16428 : : static int
16429 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16430 : : struct crypto_unittest_params *ut_params,
16431 : : const struct test_crypto_vector *reference,
16432 : : unsigned int auth_generate)
16433 : : {
16434 : : /* Generate Crypto op data structure */
16435 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16436 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16437 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
16438 : : "Failed to allocate pktmbuf offload");
16439 : :
16440 : : /* Set crypto operation data parameters */
16441 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16442 : :
16443 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16444 : :
16445 : : /* set crypto operation source mbuf */
16446 : 4 : sym_op->m_src = ut_params->ibuf;
16447 : :
16448 : : /* digest */
16449 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16450 : 4 : ut_params->ibuf, reference->digest.len);
16451 : :
16452 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16453 : : "no room to append auth tag");
16454 : :
16455 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16456 : : ut_params->ibuf, reference->ciphertext.len);
16457 : :
16458 [ - + ]: 4 : if (auth_generate)
16459 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
16460 : : else
16461 : 4 : memcpy(sym_op->auth.digest.data,
16462 : 4 : reference->digest.data,
16463 : 4 : reference->digest.len);
16464 : :
16465 : 4 : debug_hexdump(stdout, "digest:",
16466 : 4 : sym_op->auth.digest.data,
16467 : 4 : reference->digest.len);
16468 : :
16469 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16470 [ - + ]: 4 : reference->iv.data, reference->iv.len);
16471 : :
16472 : 4 : sym_op->cipher.data.length = reference->cipher_len;
16473 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
16474 : :
16475 : 4 : sym_op->auth.data.length = reference->plaintext.len;
16476 : 4 : sym_op->auth.data.offset = reference->auth_offset;
16477 : :
16478 : 4 : return 0;
16479 : : }
16480 : :
16481 : : static int
16482 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16483 : : struct crypto_unittest_params *ut_params,
16484 : : const struct test_crypto_vector *reference)
16485 : : {
16486 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
16487 : : }
16488 : :
16489 : : static int
16490 : : create_auth_verify_GMAC_operation(
16491 : : struct crypto_testsuite_params *ts_params,
16492 : : struct crypto_unittest_params *ut_params,
16493 : : const struct test_crypto_vector *reference)
16494 : : {
16495 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16496 : : }
16497 : :
16498 : : static int
16499 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16500 : : struct crypto_unittest_params *ut_params,
16501 : : const struct test_crypto_vector *reference)
16502 : : {
16503 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16504 : : }
16505 : :
16506 : : static int
16507 : 2 : test_authentication_verify_fail_when_data_corruption(
16508 : : struct crypto_testsuite_params *ts_params,
16509 : : struct crypto_unittest_params *ut_params,
16510 : : const struct test_crypto_vector *reference,
16511 : : unsigned int data_corrupted)
16512 : : {
16513 : : int retval;
16514 : :
16515 : : uint8_t *plaintext;
16516 : : struct rte_cryptodev_info dev_info;
16517 : :
16518 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16519 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16520 : :
16521 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16522 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16523 : : printf("Device doesn't support RAW data-path APIs.\n");
16524 : 0 : return TEST_SKIPPED;
16525 : : }
16526 : :
16527 : : /* Verify the capabilities */
16528 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16529 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16530 : 2 : cap_idx.algo.auth = reference->auth_algo;
16531 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16532 : : &cap_idx) == NULL)
16533 : : return TEST_SKIPPED;
16534 : :
16535 : :
16536 : : /* Create session */
16537 : 2 : retval = create_auth_session(ut_params,
16538 : 2 : ts_params->valid_devs[0],
16539 : : reference,
16540 : : RTE_CRYPTO_AUTH_OP_VERIFY);
16541 : :
16542 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16543 : : return TEST_SKIPPED;
16544 [ + - ]: 2 : if (retval < 0)
16545 : : return retval;
16546 : :
16547 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16548 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16549 : : "Failed to allocate input buffer in mempool");
16550 : :
16551 : : /* clear mbuf payload */
16552 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16553 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16554 : :
16555 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16556 : 2 : reference->plaintext.len);
16557 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16558 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16559 : :
16560 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16561 : 2 : reference->plaintext.len);
16562 : :
16563 : : /* Create operation */
16564 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
16565 : :
16566 [ + - ]: 2 : if (retval < 0)
16567 : : return retval;
16568 : :
16569 [ + + ]: 2 : if (data_corrupted)
16570 : : data_corruption(plaintext);
16571 : : else
16572 : 1 : tag_corruption(plaintext, reference->plaintext.len);
16573 : :
16574 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16575 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16576 : : ut_params->op);
16577 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16578 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16579 : : "authentication not failed");
16580 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16581 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16582 : : 0);
16583 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16584 : : return retval;
16585 : : } else {
16586 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16587 : : ut_params->op);
16588 : : }
16589 [ - + ]: 2 : if (ut_params->op == NULL)
16590 : : return 0;
16591 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16592 : 0 : return 0;
16593 : :
16594 : : return -1;
16595 : : }
16596 : :
16597 : : static int
16598 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
16599 : : struct crypto_testsuite_params *ts_params,
16600 : : struct crypto_unittest_params *ut_params,
16601 : : const struct test_crypto_vector *reference,
16602 : : unsigned int data_corrupted)
16603 : : {
16604 : : int retval;
16605 : : uint8_t *plaintext;
16606 : : struct rte_cryptodev_info dev_info;
16607 : :
16608 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16609 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16610 : :
16611 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16612 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16613 : : printf("Device doesn't support RAW data-path APIs.\n");
16614 : 0 : return TEST_SKIPPED;
16615 : : }
16616 : :
16617 : : /* Verify the capabilities */
16618 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16619 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16620 : 2 : cap_idx.algo.auth = reference->auth_algo;
16621 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16622 : : &cap_idx) == NULL)
16623 : : return TEST_SKIPPED;
16624 : :
16625 : : /* Create session */
16626 : 2 : retval = create_auth_cipher_session(ut_params,
16627 : 2 : ts_params->valid_devs[0],
16628 : : reference,
16629 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16630 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16631 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16632 : : return TEST_SKIPPED;
16633 [ + - ]: 2 : if (retval < 0)
16634 : : return retval;
16635 : :
16636 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16637 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16638 : : "Failed to allocate input buffer in mempool");
16639 : :
16640 : : /* clear mbuf payload */
16641 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16642 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16643 : :
16644 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16645 : 2 : reference->plaintext.len);
16646 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16647 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16648 : :
16649 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
16650 : 2 : reference->plaintext.len);
16651 : :
16652 : : /* Create operation */
16653 : : retval = create_auth_verify_GMAC_operation(ts_params,
16654 : : ut_params,
16655 : : reference);
16656 : :
16657 [ + - ]: 2 : if (retval < 0)
16658 : : return retval;
16659 : :
16660 [ + + ]: 2 : if (data_corrupted)
16661 : : data_corruption(plaintext);
16662 : : else
16663 : 1 : tag_corruption(plaintext, reference->aad.len);
16664 : :
16665 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16666 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16667 : : ut_params->op);
16668 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16669 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16670 : : "authentication not failed");
16671 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16672 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16673 : : 0);
16674 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16675 : 0 : return retval;
16676 : : } else {
16677 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16678 : : ut_params->op);
16679 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16680 : : }
16681 : :
16682 : : return 0;
16683 : : }
16684 : :
16685 : : static int
16686 : 2 : test_authenticated_decryption_fail_when_corruption(
16687 : : struct crypto_testsuite_params *ts_params,
16688 : : struct crypto_unittest_params *ut_params,
16689 : : const struct test_crypto_vector *reference,
16690 : : unsigned int data_corrupted)
16691 : : {
16692 : : int retval;
16693 : :
16694 : : uint8_t *ciphertext;
16695 : : struct rte_cryptodev_info dev_info;
16696 : :
16697 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16698 : 2 : uint64_t feat_flags = dev_info.feature_flags;
16699 : :
16700 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16701 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16702 : : printf("Device doesn't support RAW data-path APIs.\n");
16703 : 0 : return TEST_SKIPPED;
16704 : : }
16705 : :
16706 : : /* Verify the capabilities */
16707 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16708 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16709 : 2 : cap_idx.algo.auth = reference->auth_algo;
16710 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16711 : : &cap_idx) == NULL)
16712 : : return TEST_SKIPPED;
16713 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16714 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
16715 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16716 : : &cap_idx) == NULL)
16717 : : return TEST_SKIPPED;
16718 : :
16719 : : /* Create session */
16720 : 2 : retval = create_auth_cipher_session(ut_params,
16721 : 2 : ts_params->valid_devs[0],
16722 : : reference,
16723 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16724 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16725 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16726 : : return TEST_SKIPPED;
16727 [ + - ]: 2 : if (retval < 0)
16728 : : return retval;
16729 : :
16730 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16731 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16732 : : "Failed to allocate input buffer in mempool");
16733 : :
16734 : : /* clear mbuf payload */
16735 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16736 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16737 : :
16738 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16739 : 2 : reference->ciphertext.len);
16740 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16741 : 2 : memcpy(ciphertext, reference->ciphertext.data,
16742 : 2 : reference->ciphertext.len);
16743 : :
16744 : : /* Create operation */
16745 : : retval = create_cipher_auth_verify_operation(ts_params,
16746 : : ut_params,
16747 : : reference);
16748 : :
16749 [ + - ]: 2 : if (retval < 0)
16750 : : return retval;
16751 : :
16752 [ + + ]: 2 : if (data_corrupted)
16753 : : data_corruption(ciphertext);
16754 : : else
16755 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
16756 : :
16757 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16758 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16759 : : ut_params->op);
16760 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16761 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16762 : : "authentication not failed");
16763 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16764 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16765 : : 0);
16766 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16767 : 0 : return retval;
16768 : : } else {
16769 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16770 : : ut_params->op);
16771 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16772 : : }
16773 : :
16774 : : return 0;
16775 : : }
16776 : :
16777 : : static int
16778 : 1 : test_authenticated_encrypt_with_esn(
16779 : : struct crypto_testsuite_params *ts_params,
16780 : : struct crypto_unittest_params *ut_params,
16781 : : const struct test_crypto_vector *reference)
16782 : : {
16783 : : int retval;
16784 : :
16785 : : uint8_t *authciphertext, *plaintext, *auth_tag;
16786 : : uint16_t plaintext_pad_len;
16787 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16788 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16789 : : struct rte_cryptodev_info dev_info;
16790 : :
16791 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16792 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16793 : :
16794 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16795 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16796 : : printf("Device doesn't support RAW data-path APIs.\n");
16797 : 0 : return TEST_SKIPPED;
16798 : : }
16799 : :
16800 : : /* Verify the capabilities */
16801 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16802 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16803 : 1 : cap_idx.algo.auth = reference->auth_algo;
16804 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16805 : : &cap_idx) == NULL)
16806 : : return TEST_SKIPPED;
16807 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16808 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16809 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16810 : : &cap_idx) == NULL)
16811 : : return TEST_SKIPPED;
16812 : :
16813 : : /* Create session */
16814 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16815 : 1 : reference->cipher_key.len);
16816 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16817 : :
16818 : : /* Setup Cipher Parameters */
16819 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16820 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16821 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16822 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16823 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16824 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16825 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16826 : :
16827 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
16828 : :
16829 : : /* Setup Authentication Parameters */
16830 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16831 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16832 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16833 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16834 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16835 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16836 : 1 : ut_params->auth_xform.next = NULL;
16837 : :
16838 : : /* Create Crypto session*/
16839 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16840 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
16841 : : ts_params->session_mpool);
16842 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16843 : : return TEST_SKIPPED;
16844 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16845 : :
16846 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16847 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16848 : : "Failed to allocate input buffer in mempool");
16849 : :
16850 : : /* clear mbuf payload */
16851 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16852 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16853 : :
16854 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16855 : 1 : reference->plaintext.len);
16856 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16857 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16858 : :
16859 : : /* Create operation */
16860 : 1 : retval = create_cipher_auth_operation(ts_params,
16861 : : ut_params,
16862 : : reference, 0);
16863 : :
16864 [ + - ]: 1 : if (retval < 0)
16865 : : return retval;
16866 : :
16867 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16868 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16869 : : ut_params->op);
16870 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16871 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16872 : : 0);
16873 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16874 : : return retval;
16875 : : } else
16876 : 1 : ut_params->op = process_crypto_request(
16877 : 1 : ts_params->valid_devs[0], ut_params->op);
16878 : :
16879 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16880 : :
16881 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16882 : : "crypto op processing failed");
16883 : :
16884 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16885 : :
16886 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16887 : : ut_params->op->sym->auth.data.offset);
16888 : 1 : auth_tag = authciphertext + plaintext_pad_len;
16889 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
16890 : 1 : reference->ciphertext.len);
16891 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16892 : :
16893 : : /* Validate obuf */
16894 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16895 : : authciphertext,
16896 : : reference->ciphertext.data,
16897 : : reference->ciphertext.len,
16898 : : "Ciphertext data not as expected");
16899 : :
16900 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16901 : : auth_tag,
16902 : : reference->digest.data,
16903 : : reference->digest.len,
16904 : : "Generated digest not as expected");
16905 : :
16906 : : return TEST_SUCCESS;
16907 : :
16908 : : }
16909 : :
16910 : : static int
16911 : 1 : test_authenticated_decrypt_with_esn(
16912 : : struct crypto_testsuite_params *ts_params,
16913 : : struct crypto_unittest_params *ut_params,
16914 : : const struct test_crypto_vector *reference)
16915 : : {
16916 : : int retval;
16917 : :
16918 : : uint8_t *ciphertext;
16919 : 1 : uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
16920 : 1 : uint8_t *auth_key = alloca(reference->auth_key.len + 1);
16921 : : struct rte_cryptodev_info dev_info;
16922 : :
16923 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16924 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16925 : :
16926 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16927 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16928 : : printf("Device doesn't support RAW data-path APIs.\n");
16929 : 0 : return TEST_SKIPPED;
16930 : : }
16931 : :
16932 : : /* Verify the capabilities */
16933 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16934 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16935 : 1 : cap_idx.algo.auth = reference->auth_algo;
16936 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16937 : : &cap_idx) == NULL)
16938 : : return TEST_SKIPPED;
16939 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16940 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16941 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16942 : : &cap_idx) == NULL)
16943 : : return TEST_SKIPPED;
16944 : :
16945 : : /* Create session */
16946 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16947 : 1 : reference->cipher_key.len);
16948 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16949 : :
16950 : : /* Setup Authentication Parameters */
16951 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16952 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16953 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16954 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16955 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16956 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16957 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16958 : :
16959 : : /* Setup Cipher Parameters */
16960 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16961 : 1 : ut_params->cipher_xform.next = NULL;
16962 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16963 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16964 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16965 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16966 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16967 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16968 : :
16969 : : /* Create Crypto session*/
16970 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16971 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
16972 : : ts_params->session_mpool);
16973 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16974 : : return TEST_SKIPPED;
16975 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16976 : :
16977 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16978 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16979 : : "Failed to allocate input buffer in mempool");
16980 : :
16981 : : /* clear mbuf payload */
16982 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16983 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16984 : :
16985 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16986 : 1 : reference->ciphertext.len);
16987 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16988 : 1 : memcpy(ciphertext, reference->ciphertext.data,
16989 : 1 : reference->ciphertext.len);
16990 : :
16991 : : /* Create operation */
16992 : : retval = create_cipher_auth_verify_operation(ts_params,
16993 : : ut_params,
16994 : : reference);
16995 : :
16996 [ + - ]: 1 : if (retval < 0)
16997 : : return retval;
16998 : :
16999 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17000 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
17001 : : ut_params->op);
17002 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17003 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
17004 : : 0);
17005 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17006 : : return retval;
17007 : : } else
17008 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
17009 : : ut_params->op);
17010 : :
17011 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
17012 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
17013 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
17014 : : "crypto op processing passed");
17015 : :
17016 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
17017 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
17018 : :
17019 : : return 0;
17020 : : }
17021 : :
17022 : : static int
17023 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
17024 : : const struct aead_test_data *tdata,
17025 : : void *digest_mem, uint64_t digest_phys)
17026 : : {
17027 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17028 : : struct crypto_unittest_params *ut_params = &unittest_params;
17029 : :
17030 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
17031 : 1 : const unsigned int iv_len = tdata->iv.len;
17032 : 1 : unsigned int aad_len = tdata->aad.len;
17033 : : unsigned int aad_len_pad = 0;
17034 : :
17035 : : /* Generate Crypto op data structure */
17036 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
17037 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
17038 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
17039 : : "Failed to allocate symmetric crypto operation struct");
17040 : :
17041 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
17042 : :
17043 : 1 : sym_op->aead.digest.data = digest_mem;
17044 : :
17045 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
17046 : : "no room to append digest");
17047 : :
17048 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
17049 : :
17050 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
17051 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
17052 : : auth_tag_len);
17053 : 0 : debug_hexdump(stdout, "digest:",
17054 : 0 : sym_op->aead.digest.data,
17055 : : auth_tag_len);
17056 : : }
17057 : :
17058 : : /* Append aad data */
17059 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
17060 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17061 : : uint8_t *, IV_OFFSET);
17062 : :
17063 : : /* Copy IV 1 byte after the IV pointer, according to the API */
17064 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
17065 : :
17066 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
17067 : :
17068 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17069 : : ut_params->ibuf, aad_len);
17070 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17071 : : "no room to prepend aad");
17072 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17073 : : ut_params->ibuf);
17074 : :
17075 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
17076 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
17077 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17078 : :
17079 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17080 : 0 : debug_hexdump(stdout, "aad:",
17081 : 0 : sym_op->aead.aad.data, aad_len);
17082 : : } else {
17083 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
17084 : : uint8_t *, IV_OFFSET);
17085 : :
17086 [ + - ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
17087 : :
17088 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
17089 : :
17090 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
17091 : : ut_params->ibuf, aad_len_pad);
17092 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
17093 : : "no room to prepend aad");
17094 [ + - ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
17095 : : ut_params->ibuf);
17096 : :
17097 [ + - ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
17098 [ + - ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
17099 : :
17100 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
17101 : 1 : debug_hexdump(stdout, "aad:",
17102 : 1 : sym_op->aead.aad.data, aad_len);
17103 : : }
17104 : :
17105 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
17106 : 1 : sym_op->aead.data.offset = aad_len_pad;
17107 : :
17108 : 1 : return 0;
17109 : : }
17110 : :
17111 : : #define SGL_MAX_NO 16
17112 : :
17113 : : static int
17114 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
17115 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
17116 : : {
17117 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17118 : : struct crypto_unittest_params *ut_params = &unittest_params;
17119 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
17120 : : int retval;
17121 : : int to_trn = 0;
17122 : : int to_trn_tbl[SGL_MAX_NO];
17123 : : unsigned int trn_data = 0;
17124 : : uint8_t *plaintext, *ciphertext, *auth_tag;
17125 : : struct rte_cryptodev_info dev_info;
17126 : :
17127 : : /* Verify the capabilities */
17128 : : struct rte_cryptodev_sym_capability_idx cap_idx;
17129 : : const struct rte_cryptodev_symmetric_capability *capability;
17130 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
17131 : 3 : cap_idx.algo.aead = tdata->algo;
17132 : 3 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
17133 [ + - ]: 3 : if (capability == NULL)
17134 : : return TEST_SKIPPED;
17135 [ + - ]: 3 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
17136 : 3 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
17137 : : return TEST_SKIPPED;
17138 : :
17139 : : /*
17140 : : * SGL not supported on AESNI_MB PMD CPU crypto,
17141 : : * OOP not supported on AESNI_GCM CPU crypto
17142 : : */
17143 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
17144 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
17145 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
17146 : : return TEST_SKIPPED;
17147 : :
17148 : : /* Detailed check for the particular SGL support flag */
17149 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
17150 [ - + ]: 3 : if (!oop) {
17151 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17152 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
17153 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
17154 : : return TEST_SKIPPED;
17155 : :
17156 : 0 : uint64_t feat_flags = dev_info.feature_flags;
17157 : :
17158 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
17159 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
17160 : : printf("Device doesn't support RAW data-path APIs.\n");
17161 : 0 : return TEST_SKIPPED;
17162 : : }
17163 : : } else {
17164 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
17165 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
17166 : : tdata->plaintext.len;
17167 : : /* Raw data path API does not support OOP */
17168 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
17169 : : return TEST_SKIPPED;
17170 [ + + ]: 3 : if (sgl_in && !sgl_out) {
17171 [ + - ]: 1 : if (!(dev_info.feature_flags &
17172 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
17173 : : return TEST_SKIPPED;
17174 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
17175 [ # # ]: 0 : if (!(dev_info.feature_flags &
17176 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
17177 : : return TEST_SKIPPED;
17178 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
17179 [ - + ]: 2 : if (!(dev_info.feature_flags &
17180 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
17181 : : return TEST_SKIPPED;
17182 : : }
17183 : : }
17184 : :
17185 : 1 : if (fragsz > tdata->plaintext.len)
17186 : : fragsz = tdata->plaintext.len;
17187 : :
17188 : 1 : uint16_t plaintext_len = fragsz;
17189 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
17190 : :
17191 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
17192 : 0 : frag_size_oop = tdata->plaintext.len;
17193 : :
17194 : : int ecx = 0;
17195 : : void *digest_mem = NULL;
17196 : :
17197 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
17198 : :
17199 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
17200 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
17201 : : return 1;
17202 : : } else {
17203 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
17204 : : return 1;
17205 : : }
17206 : :
17207 : : /*
17208 : : * For out-of-place we need to alloc another mbuf
17209 : : */
17210 [ + - ]: 1 : if (oop) {
17211 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17212 : : rte_pktmbuf_append(ut_params->obuf,
17213 : 1 : frag_size_oop + prepend_len);
17214 : 1 : buf_oop = ut_params->obuf;
17215 : : }
17216 : :
17217 : : /* Create AEAD session */
17218 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
17219 : 1 : tdata->algo,
17220 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
17221 : 1 : tdata->key.data, tdata->key.len,
17222 : 1 : tdata->aad.len, tdata->auth_tag.len,
17223 : 1 : tdata->iv.len);
17224 [ + - ]: 1 : if (retval < 0)
17225 : : return retval;
17226 : :
17227 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17228 : :
17229 : : /* clear mbuf payload */
17230 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
17231 : : rte_pktmbuf_tailroom(ut_params->ibuf));
17232 : :
17233 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17234 : : plaintext_len);
17235 : :
17236 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
17237 : :
17238 : : trn_data += plaintext_len;
17239 : :
17240 : 1 : buf = ut_params->ibuf;
17241 : :
17242 : : /*
17243 : : * Loop until no more fragments
17244 : : */
17245 : :
17246 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
17247 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
17248 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
17249 : :
17250 : 5 : to_trn_tbl[ecx++] = to_trn;
17251 : :
17252 : 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17253 : : buf = buf->next;
17254 [ - + ]: 5 : ut_params->ibuf->nb_segs++;
17255 : :
17256 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
17257 : : rte_pktmbuf_tailroom(buf));
17258 : :
17259 : : /* OOP */
17260 [ - + ]: 5 : if (oop && !fragsz_oop) {
17261 : 0 : buf_last_oop = buf_oop->next =
17262 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17263 : : buf_oop = buf_oop->next;
17264 : 0 : ut_params->obuf->nb_segs++;
17265 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17266 : : 0, rte_pktmbuf_tailroom(buf_oop));
17267 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
17268 : : }
17269 : :
17270 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17271 : : to_trn);
17272 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(plaintext, "Failed to append plaintext");
17273 : :
17274 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
17275 : : to_trn);
17276 : 5 : trn_data += to_trn;
17277 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
17278 [ + - ]: 1 : if (oop) {
17279 [ - + ]: 1 : if (!fragsz_oop) {
17280 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17281 : 0 : tdata->auth_tag.len);
17282 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17283 : : }
17284 : : } else {
17285 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17286 : 0 : tdata->auth_tag.len);
17287 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17288 : : }
17289 : : }
17290 : : }
17291 : :
17292 : : uint64_t digest_phys = 0;
17293 : :
17294 [ + - ]: 1 : if (fragsz_oop && oop) {
17295 : : to_trn = 0;
17296 : : ecx = 0;
17297 : :
17298 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
17299 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17300 : 1 : tdata->auth_tag.len);
17301 : :
17302 : 1 : digest_phys = rte_pktmbuf_iova_offset(
17303 : : ut_params->obuf,
17304 : : tdata->plaintext.len + prepend_len);
17305 : : }
17306 : :
17307 : : trn_data = frag_size_oop;
17308 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
17309 : 0 : to_trn =
17310 : 0 : (tdata->plaintext.len - trn_data <
17311 : : frag_size_oop) ?
17312 : 0 : (tdata->plaintext.len - trn_data) :
17313 : : frag_size_oop;
17314 : :
17315 : 0 : to_trn_tbl[ecx++] = to_trn;
17316 : :
17317 : 0 : buf_last_oop = buf_oop->next =
17318 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
17319 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(buf_oop->next, "Unexpected end of chain");
17320 : 0 : ut_params->obuf->nb_segs++;
17321 : 0 : buf_oop = buf_oop->next;
17322 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17323 : : 0, rte_pktmbuf_tailroom(buf_oop));
17324 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->obuf, to_trn), "Failed to append to mbuf");
17325 : :
17326 : 0 : trn_data += to_trn;
17327 : :
17328 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
17329 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
17330 : 0 : tdata->auth_tag.len);
17331 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(digest_mem, "Failed to append auth tag");
17332 : : }
17333 : : }
17334 : : }
17335 : :
17336 : : /*
17337 : : * Place digest at the end of the last buffer
17338 : : */
17339 [ - + ]: 1 : if (!digest_phys)
17340 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
17341 [ - + ]: 1 : if (oop && buf_last_oop)
17342 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
17343 : :
17344 [ - + ]: 1 : if (!digest_mem && !oop) {
17345 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17346 : 0 : + tdata->auth_tag.len);
17347 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
17348 : : tdata->plaintext.len);
17349 : : }
17350 : :
17351 : : /* Create AEAD operation */
17352 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
17353 : : tdata, digest_mem, digest_phys);
17354 : :
17355 [ + - ]: 1 : if (retval < 0)
17356 : : return retval;
17357 : :
17358 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
17359 : :
17360 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
17361 [ + - ]: 1 : if (oop)
17362 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
17363 : :
17364 : : /* Process crypto operation */
17365 [ - + ]: 1 : if (oop == IN_PLACE &&
17366 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17367 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
17368 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17369 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
17370 : : 0);
17371 [ # # ]: 0 : if (retval != TEST_SUCCESS)
17372 : : return retval;
17373 : : } else
17374 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
17375 : : process_crypto_request(ts_params->valid_devs[0],
17376 : : ut_params->op), "failed to process sym crypto op");
17377 : :
17378 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17379 : : "crypto op processing failed");
17380 : :
17381 : :
17382 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17383 : : uint8_t *, prepend_len);
17384 [ + - ]: 1 : if (oop) {
17385 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17386 : : uint8_t *, prepend_len);
17387 : : }
17388 : :
17389 [ + - ]: 1 : if (fragsz_oop)
17390 : : fragsz = fragsz_oop;
17391 : :
17392 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17393 : : ciphertext,
17394 : : tdata->ciphertext.data,
17395 : : fragsz,
17396 : : "Ciphertext data not as expected");
17397 : :
17398 : 1 : buf = ut_params->op->sym->m_src->next;
17399 [ + - ]: 1 : if (oop)
17400 : 1 : buf = ut_params->op->sym->m_dst->next;
17401 : :
17402 : : unsigned int off = fragsz;
17403 : :
17404 : : ecx = 0;
17405 [ - + ]: 1 : while (buf) {
17406 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
17407 : : uint8_t *);
17408 : :
17409 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17410 : : ciphertext,
17411 : : tdata->ciphertext.data + off,
17412 : : to_trn_tbl[ecx],
17413 : : "Ciphertext data not as expected");
17414 : :
17415 : 0 : off += to_trn_tbl[ecx++];
17416 : 0 : buf = buf->next;
17417 : : }
17418 : :
17419 : : auth_tag = digest_mem;
17420 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
17421 : : auth_tag,
17422 : : tdata->auth_tag.data,
17423 : : tdata->auth_tag.len,
17424 : : "Generated auth tag not as expected");
17425 : :
17426 : : return 0;
17427 : : }
17428 : :
17429 : : static int
17430 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17431 : : {
17432 : 1 : return test_authenticated_encryption_SGL(
17433 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17434 : : }
17435 : :
17436 : : static int
17437 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17438 : : {
17439 : 1 : return test_authenticated_encryption_SGL(
17440 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17441 : : }
17442 : :
17443 : : static int
17444 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17445 : : {
17446 : 1 : return test_authenticated_encryption_SGL(
17447 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
17448 : : gcm_test_case_8.plaintext.len);
17449 : : }
17450 : :
17451 : : static int
17452 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17453 : : {
17454 : : /* This test is not for OPENSSL PMD */
17455 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17456 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17457 : : return TEST_SKIPPED;
17458 : :
17459 : 0 : return test_authenticated_encryption_SGL(
17460 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17461 : : }
17462 : :
17463 : : static int
17464 : : test_authentication_verify_fail_when_data_corrupted(
17465 : : struct crypto_testsuite_params *ts_params,
17466 : : struct crypto_unittest_params *ut_params,
17467 : : const struct test_crypto_vector *reference)
17468 : : {
17469 : 1 : return test_authentication_verify_fail_when_data_corruption(
17470 : : ts_params, ut_params, reference, 1);
17471 : : }
17472 : :
17473 : : static int
17474 : : test_authentication_verify_fail_when_tag_corrupted(
17475 : : struct crypto_testsuite_params *ts_params,
17476 : : struct crypto_unittest_params *ut_params,
17477 : : const struct test_crypto_vector *reference)
17478 : : {
17479 : 1 : return test_authentication_verify_fail_when_data_corruption(
17480 : : ts_params, ut_params, reference, 0);
17481 : : }
17482 : :
17483 : : static int
17484 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
17485 : : struct crypto_testsuite_params *ts_params,
17486 : : struct crypto_unittest_params *ut_params,
17487 : : const struct test_crypto_vector *reference)
17488 : : {
17489 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17490 : : ts_params, ut_params, reference, 1);
17491 : : }
17492 : :
17493 : : static int
17494 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
17495 : : struct crypto_testsuite_params *ts_params,
17496 : : struct crypto_unittest_params *ut_params,
17497 : : const struct test_crypto_vector *reference)
17498 : : {
17499 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
17500 : : ts_params, ut_params, reference, 0);
17501 : : }
17502 : :
17503 : : static int
17504 : : test_authenticated_decryption_fail_when_data_corrupted(
17505 : : struct crypto_testsuite_params *ts_params,
17506 : : struct crypto_unittest_params *ut_params,
17507 : : const struct test_crypto_vector *reference)
17508 : : {
17509 : 1 : return test_authenticated_decryption_fail_when_corruption(
17510 : : ts_params, ut_params, reference, 1);
17511 : : }
17512 : :
17513 : : static int
17514 : : test_authenticated_decryption_fail_when_tag_corrupted(
17515 : : struct crypto_testsuite_params *ts_params,
17516 : : struct crypto_unittest_params *ut_params,
17517 : : const struct test_crypto_vector *reference)
17518 : : {
17519 : 1 : return test_authenticated_decryption_fail_when_corruption(
17520 : : ts_params, ut_params, reference, 0);
17521 : : }
17522 : :
17523 : : static int
17524 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17525 : : {
17526 : 1 : return test_authentication_verify_fail_when_data_corrupted(
17527 : : &testsuite_params, &unittest_params,
17528 : : &hmac_sha1_test_crypto_vector);
17529 : : }
17530 : :
17531 : : static int
17532 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17533 : : {
17534 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
17535 : : &testsuite_params, &unittest_params,
17536 : : &hmac_sha1_test_crypto_vector);
17537 : : }
17538 : :
17539 : : static int
17540 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17541 : : {
17542 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
17543 : : &testsuite_params, &unittest_params,
17544 : : &aes128_gmac_test_vector);
17545 : : }
17546 : :
17547 : : static int
17548 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17549 : : {
17550 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17551 : : &testsuite_params, &unittest_params,
17552 : : &aes128_gmac_test_vector);
17553 : : }
17554 : :
17555 : : static int
17556 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17557 : : {
17558 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
17559 : : &testsuite_params,
17560 : : &unittest_params,
17561 : : &aes128cbc_hmac_sha1_test_vector);
17562 : : }
17563 : :
17564 : : static int
17565 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17566 : : {
17567 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
17568 : : &testsuite_params,
17569 : : &unittest_params,
17570 : : &aes128cbc_hmac_sha1_test_vector);
17571 : : }
17572 : :
17573 : : static int
17574 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17575 : : {
17576 : 1 : return test_authenticated_encrypt_with_esn(
17577 : : &testsuite_params,
17578 : : &unittest_params,
17579 : : &aes128cbc_hmac_sha1_aad_test_vector);
17580 : : }
17581 : :
17582 : : static int
17583 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17584 : : {
17585 : 1 : return test_authenticated_decrypt_with_esn(
17586 : : &testsuite_params,
17587 : : &unittest_params,
17588 : : &aes128cbc_hmac_sha1_aad_test_vector);
17589 : : }
17590 : :
17591 : : static int
17592 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17593 : : {
17594 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17595 : : }
17596 : :
17597 : : static int
17598 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17599 : : {
17600 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17601 : : }
17602 : :
17603 : : static int
17604 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17605 : : {
17606 : 0 : return test_authenticated_encryption_SGL(
17607 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17608 : : chacha20_poly1305_case_2.plaintext.len);
17609 : : }
17610 : :
17611 : : static int
17612 : 0 : test_SM4_GCM_case_1(void)
17613 : : {
17614 : 0 : return test_authenticated_encryption(&sm4_gcm_case_1);
17615 : : }
17616 : :
17617 : : static int
17618 : 0 : test_SM4_GCM_case_2(void)
17619 : : {
17620 : 0 : return test_authenticated_encryption(&sm4_gcm_case_2);
17621 : : }
17622 : :
17623 : : static int
17624 : 0 : test_SM4_GCM_case_3(void)
17625 : : {
17626 : 0 : return test_authenticated_encryption(&sm4_gcm_case_3);
17627 : : }
17628 : :
17629 : : static int
17630 : 0 : test_SM4_GCM_case_4(void)
17631 : : {
17632 : 0 : return test_authenticated_encryption(&sm4_gcm_case_4);
17633 : : }
17634 : :
17635 : : static int
17636 : 0 : test_SM4_GCM_case_5(void)
17637 : : {
17638 : 0 : return test_authenticated_encryption(&sm4_gcm_case_5);
17639 : : }
17640 : :
17641 : : static int
17642 : 0 : test_SM4_GCM_case_6(void)
17643 : : {
17644 : 0 : return test_authenticated_encryption(&sm4_gcm_case_6);
17645 : : }
17646 : :
17647 : : static int
17648 : 0 : test_SM4_GCM_case_7(void)
17649 : : {
17650 : 0 : return test_authenticated_encryption(&sm4_gcm_case_7);
17651 : : }
17652 : :
17653 : : static int
17654 : 0 : test_SM4_GCM_case_8(void)
17655 : : {
17656 : 0 : return test_authenticated_encryption(&sm4_gcm_case_8);
17657 : : }
17658 : :
17659 : : static int
17660 : 0 : test_SM4_GCM_case_9(void)
17661 : : {
17662 : 0 : return test_authenticated_encryption(&sm4_gcm_case_9);
17663 : : }
17664 : :
17665 : : static int
17666 : 0 : test_SM4_GCM_case_10(void)
17667 : : {
17668 : 0 : return test_authenticated_encryption(&sm4_gcm_case_10);
17669 : : }
17670 : :
17671 : : static int
17672 : 0 : test_SM4_GCM_case_11(void)
17673 : : {
17674 : 0 : return test_authenticated_encryption(&sm4_gcm_case_11);
17675 : : }
17676 : :
17677 : : static int
17678 : 0 : test_SM4_GCM_case_12(void)
17679 : : {
17680 : 0 : return test_authenticated_encryption(&sm4_gcm_case_12);
17681 : : }
17682 : :
17683 : : static int
17684 : 0 : test_SM4_GCM_case_13(void)
17685 : : {
17686 : 0 : return test_authenticated_encryption(&sm4_gcm_case_13);
17687 : : }
17688 : :
17689 : : static int
17690 : 0 : test_SM4_GCM_case_14(void)
17691 : : {
17692 : 0 : return test_authenticated_encryption(&sm4_gcm_case_14);
17693 : : }
17694 : :
17695 : : static int
17696 : 0 : test_SM4_GCM_case_15(void)
17697 : : {
17698 : 0 : return test_authenticated_encryption(&sm4_gcm_case_15);
17699 : : }
17700 : :
17701 : : #ifdef RTE_CRYPTO_SCHEDULER
17702 : :
17703 : : /* global AESNI worker IDs for the scheduler test */
17704 : : uint8_t aesni_ids[2];
17705 : :
17706 : : static int
17707 : 0 : scheduler_testsuite_setup(void)
17708 : : {
17709 : : uint32_t i = 0;
17710 : : int32_t nb_devs, ret;
17711 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
17712 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17713 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
17714 : : uint16_t worker_core_count = 0;
17715 : : uint16_t socket_id = 0;
17716 : :
17717 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
17718 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17719 : :
17720 : : /* Identify the Worker Cores
17721 : : * Use 2 worker cores for the device args
17722 : : */
17723 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
17724 [ # # ]: 0 : if (worker_core_count > 1)
17725 : : break;
17726 : : ret = snprintf(vdev_args, sizeof(vdev_args), "%s%d", temp_str, i);
17727 : :
17728 : : /* If too many args the result will have been truncated */
17729 [ # # ]: 0 : if (ret >= VDEV_ARGS_SIZE) {
17730 : 0 : RTE_LOG(ERR, USER1,
17731 : : "Cryptodev scheduler test vdev arg size exceeded\n");
17732 : 0 : return TEST_FAILED;
17733 : : }
17734 : :
17735 : : strcpy(temp_str, vdev_args);
17736 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
17737 : 0 : worker_core_count++;
17738 : 0 : socket_id = rte_lcore_to_socket_id(i);
17739 : : }
17740 [ # # ]: 0 : if (worker_core_count != 2) {
17741 : 0 : RTE_LOG(ERR, USER1,
17742 : : "Cryptodev scheduler test require at least "
17743 : : "two worker cores to run. "
17744 : : "Please use the correct coremask.\n");
17745 : 0 : return TEST_FAILED;
17746 : : }
17747 : : strcpy(temp_str, vdev_args);
17748 [ # # ]: 0 : ret = snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d", temp_str,
17749 : : socket_id);
17750 [ # # ]: 0 : if (ret >= VDEV_ARGS_SIZE) {
17751 : 0 : RTE_LOG(ERR, USER1,
17752 : : "Cryptodev scheduler test vdev arg size exceeded\n");
17753 : 0 : return TEST_FAILED;
17754 : : }
17755 : :
17756 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17757 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
17758 : 0 : rte_cryptodev_driver_id_get(
17759 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17760 [ # # ]: 0 : if (nb_devs < 1) {
17761 : 0 : ret = rte_vdev_init(
17762 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17763 : : vdev_args);
17764 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17765 : : "Failed to create instance %u of pmd : %s",
17766 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17767 : : }
17768 : : }
17769 : 0 : return testsuite_setup();
17770 : : }
17771 : :
17772 : : static int
17773 : 0 : test_scheduler_attach_worker_op(void)
17774 : : {
17775 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17776 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17777 : : uint32_t i, nb_devs_attached = 0;
17778 : : int ret;
17779 : : char vdev_name[32];
17780 : 0 : unsigned int count = rte_cryptodev_count();
17781 : :
17782 : : /* create 2 AESNI_MB vdevs on top of existing devices */
17783 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17784 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17785 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17786 : : i);
17787 : 0 : ret = rte_vdev_init(vdev_name, NULL);
17788 : :
17789 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17790 : : "Failed to create instance %u of"
17791 : : " pmd : %s",
17792 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17793 : :
17794 : : if (ret < 0) {
17795 : : RTE_LOG(ERR, USER1,
17796 : : "Failed to create 2 AESNI MB PMDs.\n");
17797 : : return TEST_SKIPPED;
17798 : : }
17799 : : }
17800 : :
17801 : : /* attach 2 AESNI_MB cdevs */
17802 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
17803 : : struct rte_cryptodev_info info;
17804 : : unsigned int session_size;
17805 : :
17806 : 0 : rte_cryptodev_info_get(i, &info);
17807 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
17808 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17809 : 0 : continue;
17810 : :
17811 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
17812 : : /*
17813 : : * Create the session mempool again, since now there are new devices
17814 : : * to use the mempool.
17815 : : */
17816 [ # # ]: 0 : if (ts_params->session_mpool) {
17817 : 0 : rte_mempool_free(ts_params->session_mpool);
17818 : 0 : ts_params->session_mpool = NULL;
17819 : : }
17820 : :
17821 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
17822 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17823 : 0 : RTE_LOG(ERR, USER1,
17824 : : "Device does not support "
17825 : : "at least %u sessions\n",
17826 : : MAX_NB_SESSIONS);
17827 : 0 : return TEST_FAILED;
17828 : : }
17829 : : /*
17830 : : * Create mempool with maximum number of sessions,
17831 : : * to include the session headers
17832 : : */
17833 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
17834 : 0 : ts_params->session_mpool =
17835 : 0 : rte_cryptodev_sym_session_pool_create(
17836 : : "test_sess_mp",
17837 : : MAX_NB_SESSIONS, session_size,
17838 : : 0, 0, SOCKET_ID_ANY);
17839 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17840 : : "session mempool allocation failed");
17841 : : }
17842 : :
17843 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
17844 : :
17845 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17846 : : (uint8_t)i);
17847 : :
17848 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17849 : : "Failed to attach device %u of pmd : %s", i,
17850 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17851 : :
17852 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
17853 : :
17854 : 0 : nb_devs_attached++;
17855 : : }
17856 : :
17857 : : return 0;
17858 : : }
17859 : :
17860 : : static int
17861 : 0 : test_scheduler_detach_worker_op(void)
17862 : : {
17863 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17864 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17865 : : uint32_t i;
17866 : : int ret;
17867 : :
17868 [ # # ]: 0 : for (i = 0; i < 2; i++) {
17869 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17870 : 0 : aesni_ids[i]);
17871 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17872 : : "Failed to detach device %u", aesni_ids[i]);
17873 : : }
17874 : :
17875 : : return 0;
17876 : : }
17877 : :
17878 : : static int
17879 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17880 : : {
17881 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17882 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17883 : : /* set mode */
17884 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
17885 : : scheduler_mode);
17886 : : }
17887 : :
17888 : : static int
17889 : 0 : test_scheduler_mode_roundrobin_op(void)
17890 : : {
17891 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17892 : : 0, "Failed to set roundrobin mode");
17893 : : return 0;
17894 : :
17895 : : }
17896 : :
17897 : : static int
17898 : 0 : test_scheduler_mode_multicore_op(void)
17899 : : {
17900 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17901 : : 0, "Failed to set multicore mode");
17902 : :
17903 : : return 0;
17904 : : }
17905 : :
17906 : : static int
17907 : 0 : test_scheduler_mode_failover_op(void)
17908 : : {
17909 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17910 : : 0, "Failed to set failover mode");
17911 : :
17912 : : return 0;
17913 : : }
17914 : :
17915 : : static int
17916 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
17917 : : {
17918 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17919 : : 0, "Failed to set pktsize mode");
17920 : :
17921 : : return 0;
17922 : : }
17923 : :
17924 : : static int
17925 : 0 : scheduler_multicore_testsuite_setup(void)
17926 : : {
17927 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17928 : : return TEST_SKIPPED;
17929 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17930 : 0 : return TEST_SKIPPED;
17931 : : return 0;
17932 : : }
17933 : :
17934 : : static int
17935 : 0 : scheduler_roundrobin_testsuite_setup(void)
17936 : : {
17937 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17938 : : return TEST_SKIPPED;
17939 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17940 : 0 : return TEST_SKIPPED;
17941 : : return 0;
17942 : : }
17943 : :
17944 : : static int
17945 : 0 : scheduler_failover_testsuite_setup(void)
17946 : : {
17947 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17948 : : return TEST_SKIPPED;
17949 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17950 : 0 : return TEST_SKIPPED;
17951 : : return 0;
17952 : : }
17953 : :
17954 : : static int
17955 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
17956 : : {
17957 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17958 : : return TEST_SKIPPED;
17959 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17960 : 0 : return TEST_SKIPPED;
17961 : : return 0;
17962 : : }
17963 : :
17964 : : static void
17965 : 0 : scheduler_mode_testsuite_teardown(void)
17966 : : {
17967 : 0 : test_scheduler_detach_worker_op();
17968 : 0 : }
17969 : :
17970 : : #endif /* RTE_CRYPTO_SCHEDULER */
17971 : :
17972 : : static struct unit_test_suite end_testsuite = {
17973 : : .suite_name = NULL,
17974 : : .setup = NULL,
17975 : : .teardown = NULL,
17976 : : .unit_test_suites = NULL
17977 : : };
17978 : :
17979 : : #ifdef RTE_LIB_SECURITY
17980 : : static struct unit_test_suite ipsec_proto_testsuite = {
17981 : : .suite_name = "IPsec Proto Unit Test Suite",
17982 : : .setup = ipsec_proto_testsuite_setup,
17983 : : .unit_test_cases = {
17984 : : TEST_CASE_NAMED_WITH_DATA(
17985 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17986 : : ut_setup_security, ut_teardown,
17987 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17988 : : TEST_CASE_NAMED_WITH_DATA(
17989 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17990 : : ut_setup_security, ut_teardown,
17991 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17992 : : TEST_CASE_NAMED_WITH_DATA(
17993 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17994 : : ut_setup_security, ut_teardown,
17995 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17996 : : TEST_CASE_NAMED_WITH_DATA(
17997 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17998 : : ut_setup_security, ut_teardown,
17999 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
18000 : : TEST_CASE_NAMED_WITH_DATA(
18001 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
18002 : : ut_setup_security, ut_teardown,
18003 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
18004 : : TEST_CASE_NAMED_WITH_DATA(
18005 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
18006 : : ut_setup_security, ut_teardown,
18007 : : test_ipsec_proto_known_vec,
18008 : : &pkt_aes_128_cbc_md5),
18009 : : TEST_CASE_NAMED_WITH_DATA(
18010 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
18011 : : ut_setup_security, ut_teardown,
18012 : : test_ipsec_proto_known_vec,
18013 : : &pkt_aes_128_ctr_hmac_sha256),
18014 : : TEST_CASE_NAMED_WITH_DATA(
18015 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
18016 : : ut_setup_security, ut_teardown,
18017 : : test_ipsec_proto_known_vec,
18018 : : &pkt_aes_128_ctr_hmac_sha384),
18019 : : TEST_CASE_NAMED_WITH_DATA(
18020 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
18021 : : ut_setup_security, ut_teardown,
18022 : : test_ipsec_proto_known_vec,
18023 : : &pkt_aes_128_ctr_hmac_sha512),
18024 : : TEST_CASE_NAMED_WITH_DATA(
18025 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA256 [16B ICV])",
18026 : : ut_setup_security, ut_teardown,
18027 : : test_ipsec_proto_known_vec_inb,
18028 : : &pkt_aes_128_ctr_hmac_sha256),
18029 : : TEST_CASE_NAMED_WITH_DATA(
18030 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA384 [16B ICV])",
18031 : : ut_setup_security, ut_teardown,
18032 : : test_ipsec_proto_known_vec_inb,
18033 : : &pkt_aes_128_ctr_hmac_sha384),
18034 : : TEST_CASE_NAMED_WITH_DATA(
18035 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CTR 128 HMAC-SHA512 [16B ICV])",
18036 : : ut_setup_security, ut_teardown,
18037 : : test_ipsec_proto_known_vec_inb,
18038 : : &pkt_aes_128_ctr_hmac_sha512),
18039 : : TEST_CASE_NAMED_WITH_DATA(
18040 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18041 : : ut_setup_security, ut_teardown,
18042 : : test_ipsec_proto_known_vec,
18043 : : &pkt_aes_128_cbc_hmac_sha256),
18044 : : TEST_CASE_NAMED_WITH_DATA(
18045 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18046 : : ut_setup_security, ut_teardown,
18047 : : test_ipsec_proto_known_vec,
18048 : : &pkt_aes_128_cbc_hmac_sha384),
18049 : : TEST_CASE_NAMED_WITH_DATA(
18050 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18051 : : ut_setup_security, ut_teardown,
18052 : : test_ipsec_proto_known_vec,
18053 : : &pkt_aes_128_cbc_hmac_sha512),
18054 : : TEST_CASE_NAMED_WITH_DATA(
18055 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18056 : : ut_setup_security, ut_teardown,
18057 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
18058 : : TEST_CASE_NAMED_WITH_DATA(
18059 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18060 : : ut_setup_security, ut_teardown,
18061 : : test_ipsec_proto_known_vec,
18062 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18063 : : TEST_CASE_NAMED_WITH_DATA(
18064 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18065 : : ut_setup_security, ut_teardown,
18066 : : test_ipsec_proto_known_vec,
18067 : : &pkt_null_aes_xcbc),
18068 : : TEST_CASE_NAMED_WITH_DATA(
18069 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18070 : : ut_setup_security, ut_teardown,
18071 : : test_ipsec_proto_known_vec,
18072 : : &pkt_des_cbc_hmac_sha256),
18073 : : TEST_CASE_NAMED_WITH_DATA(
18074 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18075 : : ut_setup_security, ut_teardown,
18076 : : test_ipsec_proto_known_vec,
18077 : : &pkt_des_cbc_hmac_sha384),
18078 : : TEST_CASE_NAMED_WITH_DATA(
18079 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18080 : : ut_setup_security, ut_teardown,
18081 : : test_ipsec_proto_known_vec,
18082 : : &pkt_des_cbc_hmac_sha512),
18083 : : TEST_CASE_NAMED_WITH_DATA(
18084 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18085 : : ut_setup_security, ut_teardown,
18086 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
18087 : : TEST_CASE_NAMED_WITH_DATA(
18088 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18089 : : ut_setup_security, ut_teardown,
18090 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
18091 : : TEST_CASE_NAMED_WITH_DATA(
18092 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18093 : : ut_setup_security, ut_teardown,
18094 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
18095 : : TEST_CASE_NAMED_WITH_DATA(
18096 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18097 : : ut_setup_security, ut_teardown,
18098 : : test_ipsec_proto_known_vec,
18099 : : &pkt_des_cbc_hmac_sha256_v6),
18100 : : TEST_CASE_NAMED_WITH_DATA(
18101 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18102 : : ut_setup_security, ut_teardown,
18103 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
18104 : : TEST_CASE_NAMED_WITH_DATA(
18105 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18106 : : ut_setup_security, ut_teardown,
18107 : : test_ipsec_proto_known_vec,
18108 : : &pkt_ah_tunnel_sha256),
18109 : : TEST_CASE_NAMED_WITH_DATA(
18110 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18111 : : ut_setup_security, ut_teardown,
18112 : : test_ipsec_proto_known_vec,
18113 : : &pkt_ah_transport_sha256),
18114 : : TEST_CASE_NAMED_WITH_DATA(
18115 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18116 : : ut_setup_security, ut_teardown,
18117 : : test_ipsec_proto_known_vec,
18118 : : &pkt_ah_ipv4_aes_gmac_128),
18119 : : TEST_CASE_NAMED_WITH_DATA(
18120 : : "Outbound fragmented packet",
18121 : : ut_setup_security, ut_teardown,
18122 : : test_ipsec_proto_known_vec_fragmented,
18123 : : &pkt_aes_128_gcm_frag),
18124 : : TEST_CASE_NAMED_WITH_DATA(
18125 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
18126 : : ut_setup_security, ut_teardown,
18127 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
18128 : : TEST_CASE_NAMED_WITH_DATA(
18129 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
18130 : : ut_setup_security, ut_teardown,
18131 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
18132 : : TEST_CASE_NAMED_WITH_DATA(
18133 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
18134 : : ut_setup_security, ut_teardown,
18135 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
18136 : : TEST_CASE_NAMED_WITH_DATA(
18137 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
18138 : : ut_setup_security, ut_teardown,
18139 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
18140 : : TEST_CASE_NAMED_WITH_DATA(
18141 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
18142 : : ut_setup_security, ut_teardown,
18143 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
18144 : : TEST_CASE_NAMED_WITH_DATA(
18145 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
18146 : : ut_setup_security, ut_teardown,
18147 : : test_ipsec_proto_known_vec_inb,
18148 : : &pkt_aes_128_cbc_md5),
18149 : : TEST_CASE_NAMED_WITH_DATA(
18150 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18151 : : ut_setup_security, ut_teardown,
18152 : : test_ipsec_proto_known_vec_inb,
18153 : : &pkt_aes_128_cbc_hmac_sha256),
18154 : : TEST_CASE_NAMED_WITH_DATA(
18155 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
18156 : : ut_setup_security, ut_teardown,
18157 : : test_ipsec_proto_known_vec_inb,
18158 : : &pkt_aes_128_cbc_hmac_sha384),
18159 : : TEST_CASE_NAMED_WITH_DATA(
18160 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
18161 : : ut_setup_security, ut_teardown,
18162 : : test_ipsec_proto_known_vec_inb,
18163 : : &pkt_aes_128_cbc_hmac_sha512),
18164 : : TEST_CASE_NAMED_WITH_DATA(
18165 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
18166 : : ut_setup_security, ut_teardown,
18167 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
18168 : : TEST_CASE_NAMED_WITH_DATA(
18169 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
18170 : : ut_setup_security, ut_teardown,
18171 : : test_ipsec_proto_known_vec_inb,
18172 : : &pkt_aes_128_cbc_hmac_sha256_v6),
18173 : : TEST_CASE_NAMED_WITH_DATA(
18174 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
18175 : : ut_setup_security, ut_teardown,
18176 : : test_ipsec_proto_known_vec_inb,
18177 : : &pkt_null_aes_xcbc),
18178 : : TEST_CASE_NAMED_WITH_DATA(
18179 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
18180 : : ut_setup_security, ut_teardown,
18181 : : test_ipsec_proto_known_vec_inb,
18182 : : &pkt_des_cbc_hmac_sha256),
18183 : : TEST_CASE_NAMED_WITH_DATA(
18184 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
18185 : : ut_setup_security, ut_teardown,
18186 : : test_ipsec_proto_known_vec_inb,
18187 : : &pkt_des_cbc_hmac_sha384),
18188 : : TEST_CASE_NAMED_WITH_DATA(
18189 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
18190 : : ut_setup_security, ut_teardown,
18191 : : test_ipsec_proto_known_vec_inb,
18192 : : &pkt_des_cbc_hmac_sha512),
18193 : : TEST_CASE_NAMED_WITH_DATA(
18194 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
18195 : : ut_setup_security, ut_teardown,
18196 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
18197 : : TEST_CASE_NAMED_WITH_DATA(
18198 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
18199 : : ut_setup_security, ut_teardown,
18200 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
18201 : : TEST_CASE_NAMED_WITH_DATA(
18202 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
18203 : : ut_setup_security, ut_teardown,
18204 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
18205 : : TEST_CASE_NAMED_WITH_DATA(
18206 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
18207 : : ut_setup_security, ut_teardown,
18208 : : test_ipsec_proto_known_vec_inb,
18209 : : &pkt_des_cbc_hmac_sha256_v6),
18210 : : TEST_CASE_NAMED_WITH_DATA(
18211 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
18212 : : ut_setup_security, ut_teardown,
18213 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
18214 : : TEST_CASE_NAMED_WITH_DATA(
18215 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
18216 : : ut_setup_security, ut_teardown,
18217 : : test_ipsec_proto_known_vec_inb,
18218 : : &pkt_ah_tunnel_sha256),
18219 : : TEST_CASE_NAMED_WITH_DATA(
18220 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
18221 : : ut_setup_security, ut_teardown,
18222 : : test_ipsec_proto_known_vec_inb,
18223 : : &pkt_ah_transport_sha256),
18224 : : TEST_CASE_NAMED_WITH_DATA(
18225 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
18226 : : ut_setup_security, ut_teardown,
18227 : : test_ipsec_proto_known_vec_inb,
18228 : : &pkt_ah_ipv4_aes_gmac_128),
18229 : : TEST_CASE_NAMED_ST(
18230 : : "Combined test alg list",
18231 : : ut_setup_security, ut_teardown,
18232 : : test_ipsec_proto_display_list),
18233 : : TEST_CASE_NAMED_ST(
18234 : : "Combined test alg list (AH)",
18235 : : ut_setup_security, ut_teardown,
18236 : : test_ipsec_proto_ah_tunnel_ipv4),
18237 : : TEST_CASE_NAMED_ST(
18238 : : "IV generation",
18239 : : ut_setup_security, ut_teardown,
18240 : : test_ipsec_proto_iv_gen),
18241 : : TEST_CASE_NAMED_ST(
18242 : : "UDP encapsulation",
18243 : : ut_setup_security, ut_teardown,
18244 : : test_ipsec_proto_udp_encap),
18245 : : TEST_CASE_NAMED_ST(
18246 : : "UDP encapsulation with custom ports",
18247 : : ut_setup_security, ut_teardown,
18248 : : test_ipsec_proto_udp_encap_custom_ports),
18249 : : TEST_CASE_NAMED_ST(
18250 : : "UDP encapsulation ports verification test",
18251 : : ut_setup_security, ut_teardown,
18252 : : test_ipsec_proto_udp_ports_verify),
18253 : : TEST_CASE_NAMED_ST(
18254 : : "SA expiry packets soft",
18255 : : ut_setup_security, ut_teardown,
18256 : : test_ipsec_proto_sa_exp_pkts_soft),
18257 : : TEST_CASE_NAMED_ST(
18258 : : "SA expiry packets hard",
18259 : : ut_setup_security, ut_teardown,
18260 : : test_ipsec_proto_sa_exp_pkts_hard),
18261 : : TEST_CASE_NAMED_ST(
18262 : : "Negative test: ICV corruption",
18263 : : ut_setup_security, ut_teardown,
18264 : : test_ipsec_proto_err_icv_corrupt),
18265 : : TEST_CASE_NAMED_ST(
18266 : : "Tunnel dst addr verification",
18267 : : ut_setup_security, ut_teardown,
18268 : : test_ipsec_proto_tunnel_dst_addr_verify),
18269 : : TEST_CASE_NAMED_ST(
18270 : : "Tunnel src and dst addr verification",
18271 : : ut_setup_security, ut_teardown,
18272 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
18273 : : TEST_CASE_NAMED_ST(
18274 : : "Inner IP checksum",
18275 : : ut_setup_security, ut_teardown,
18276 : : test_ipsec_proto_inner_ip_csum),
18277 : : TEST_CASE_NAMED_ST(
18278 : : "Inner L4 checksum",
18279 : : ut_setup_security, ut_teardown,
18280 : : test_ipsec_proto_inner_l4_csum),
18281 : : TEST_CASE_NAMED_ST(
18282 : : "Tunnel IPv4 in IPv4",
18283 : : ut_setup_security, ut_teardown,
18284 : : test_ipsec_proto_tunnel_v4_in_v4),
18285 : : TEST_CASE_NAMED_ST(
18286 : : "Tunnel IPv6 in IPv6",
18287 : : ut_setup_security, ut_teardown,
18288 : : test_ipsec_proto_tunnel_v6_in_v6),
18289 : : TEST_CASE_NAMED_ST(
18290 : : "Tunnel IPv4 in IPv6",
18291 : : ut_setup_security, ut_teardown,
18292 : : test_ipsec_proto_tunnel_v4_in_v6),
18293 : : TEST_CASE_NAMED_ST(
18294 : : "Tunnel IPv6 in IPv4",
18295 : : ut_setup_security, ut_teardown,
18296 : : test_ipsec_proto_tunnel_v6_in_v4),
18297 : : TEST_CASE_NAMED_ST(
18298 : : "Transport IPv4",
18299 : : ut_setup_security, ut_teardown,
18300 : : test_ipsec_proto_transport_v4),
18301 : : TEST_CASE_NAMED_ST(
18302 : : "AH transport IPv4",
18303 : : ut_setup_security, ut_teardown,
18304 : : test_ipsec_proto_ah_transport_ipv4),
18305 : : TEST_CASE_NAMED_ST(
18306 : : "Transport l4 checksum",
18307 : : ut_setup_security, ut_teardown,
18308 : : test_ipsec_proto_transport_l4_csum),
18309 : : TEST_CASE_NAMED_ST(
18310 : : "Statistics: success",
18311 : : ut_setup_security, ut_teardown,
18312 : : test_ipsec_proto_stats),
18313 : : TEST_CASE_NAMED_ST(
18314 : : "Fragmented packet",
18315 : : ut_setup_security, ut_teardown,
18316 : : test_ipsec_proto_pkt_fragment),
18317 : : TEST_CASE_NAMED_ST(
18318 : : "Tunnel header copy DF (inner 0)",
18319 : : ut_setup_security, ut_teardown,
18320 : : test_ipsec_proto_copy_df_inner_0),
18321 : : TEST_CASE_NAMED_ST(
18322 : : "Tunnel header copy DF (inner 1)",
18323 : : ut_setup_security, ut_teardown,
18324 : : test_ipsec_proto_copy_df_inner_1),
18325 : : TEST_CASE_NAMED_ST(
18326 : : "Tunnel header set DF 0 (inner 1)",
18327 : : ut_setup_security, ut_teardown,
18328 : : test_ipsec_proto_set_df_0_inner_1),
18329 : : TEST_CASE_NAMED_ST(
18330 : : "Tunnel header set DF 1 (inner 0)",
18331 : : ut_setup_security, ut_teardown,
18332 : : test_ipsec_proto_set_df_1_inner_0),
18333 : : TEST_CASE_NAMED_ST(
18334 : : "Tunnel header IPv4 copy DSCP (inner 0)",
18335 : : ut_setup_security, ut_teardown,
18336 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
18337 : : TEST_CASE_NAMED_ST(
18338 : : "Tunnel header IPv4 copy DSCP (inner 1)",
18339 : : ut_setup_security, ut_teardown,
18340 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
18341 : : TEST_CASE_NAMED_ST(
18342 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
18343 : : ut_setup_security, ut_teardown,
18344 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
18345 : : TEST_CASE_NAMED_ST(
18346 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
18347 : : ut_setup_security, ut_teardown,
18348 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
18349 : : TEST_CASE_NAMED_ST(
18350 : : "Tunnel header IPv6 copy DSCP (inner 0)",
18351 : : ut_setup_security, ut_teardown,
18352 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
18353 : : TEST_CASE_NAMED_ST(
18354 : : "Tunnel header IPv6 copy DSCP (inner 1)",
18355 : : ut_setup_security, ut_teardown,
18356 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
18357 : : TEST_CASE_NAMED_ST(
18358 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
18359 : : ut_setup_security, ut_teardown,
18360 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
18361 : : TEST_CASE_NAMED_ST(
18362 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
18363 : : ut_setup_security, ut_teardown,
18364 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
18365 : : TEST_CASE_NAMED_WITH_DATA(
18366 : : "Antireplay with window size 1024",
18367 : : ut_setup_security, ut_teardown,
18368 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
18369 : : TEST_CASE_NAMED_WITH_DATA(
18370 : : "Antireplay with window size 2048",
18371 : : ut_setup_security, ut_teardown,
18372 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
18373 : : TEST_CASE_NAMED_WITH_DATA(
18374 : : "Antireplay with window size 4096",
18375 : : ut_setup_security, ut_teardown,
18376 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
18377 : : TEST_CASE_NAMED_WITH_DATA(
18378 : : "ESN and Antireplay with window size 1024",
18379 : : ut_setup_security, ut_teardown,
18380 : : test_ipsec_proto_pkt_esn_antireplay1024,
18381 : : &pkt_aes_128_gcm),
18382 : : TEST_CASE_NAMED_WITH_DATA(
18383 : : "ESN and Antireplay with window size 2048",
18384 : : ut_setup_security, ut_teardown,
18385 : : test_ipsec_proto_pkt_esn_antireplay2048,
18386 : : &pkt_aes_128_gcm),
18387 : : TEST_CASE_NAMED_WITH_DATA(
18388 : : "ESN and Antireplay with window size 4096",
18389 : : ut_setup_security, ut_teardown,
18390 : : test_ipsec_proto_pkt_esn_antireplay4096,
18391 : : &pkt_aes_128_gcm),
18392 : : TEST_CASE_NAMED_ST(
18393 : : "Tunnel header IPv4 decrement inner TTL",
18394 : : ut_setup_security, ut_teardown,
18395 : : test_ipsec_proto_ipv4_ttl_decrement),
18396 : : TEST_CASE_NAMED_ST(
18397 : : "Tunnel header IPv6 decrement inner hop limit",
18398 : : ut_setup_security, ut_teardown,
18399 : : test_ipsec_proto_ipv6_hop_limit_decrement),
18400 : : TEST_CASE_NAMED_ST(
18401 : : "Multi-segmented mode",
18402 : : ut_setup_security, ut_teardown,
18403 : : test_ipsec_proto_sgl),
18404 : : TEST_CASE_NAMED_ST(
18405 : : "Multi-segmented external mbuf mode",
18406 : : ut_setup_security, ut_teardown,
18407 : : test_ipsec_proto_sgl_ext_mbuf),
18408 : : TEST_CASE_NAMED_WITH_DATA(
18409 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
18410 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18411 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
18412 : : TEST_CASE_NAMED_WITH_DATA(
18413 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject multi seg",
18414 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
18415 : : test_ipsec_proto_known_vec_inb_rx_inject_multi_seg, &pkt_aes_128_gcm),
18416 : :
18417 : : TEST_CASES_END() /**< NULL terminate unit test array */
18418 : : }
18419 : : };
18420 : :
18421 : : static struct unit_test_suite pdcp_proto_testsuite = {
18422 : : .suite_name = "PDCP Proto Unit Test Suite",
18423 : : .setup = pdcp_proto_testsuite_setup,
18424 : : .unit_test_cases = {
18425 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
18426 : : test_PDCP_PROTO_all),
18427 : : TEST_CASES_END() /**< NULL terminate unit test array */
18428 : : }
18429 : : };
18430 : :
18431 : : static struct unit_test_suite tls12_record_proto_testsuite = {
18432 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
18433 : : .setup = tls_record_proto_testsuite_setup,
18434 : : .unit_test_cases = {
18435 : : TEST_CASE_NAMED_WITH_DATA(
18436 : : "Write record known vector AES-GCM-128 (vector 1)",
18437 : : ut_setup_security, ut_teardown,
18438 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
18439 : : TEST_CASE_NAMED_WITH_DATA(
18440 : : "Write record known vector AES-GCM-128 (vector 2)",
18441 : : ut_setup_security, ut_teardown,
18442 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
18443 : : TEST_CASE_NAMED_WITH_DATA(
18444 : : "Write record known vector AES-GCM-256",
18445 : : ut_setup_security, ut_teardown,
18446 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
18447 : : TEST_CASE_NAMED_WITH_DATA(
18448 : : "Write record known vector AES-CBC-128-SHA1",
18449 : : ut_setup_security, ut_teardown,
18450 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
18451 : : TEST_CASE_NAMED_WITH_DATA(
18452 : : "Write record known vector AES-128-CBC-SHA256",
18453 : : ut_setup_security, ut_teardown,
18454 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
18455 : : TEST_CASE_NAMED_WITH_DATA(
18456 : : "Write record known vector AES-256-CBC-SHA1",
18457 : : ut_setup_security, ut_teardown,
18458 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
18459 : : TEST_CASE_NAMED_WITH_DATA(
18460 : : "Write record known vector AES-256-CBC-SHA256",
18461 : : ut_setup_security, ut_teardown,
18462 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
18463 : : TEST_CASE_NAMED_WITH_DATA(
18464 : : "Write record known vector AES-256-CBC-SHA384",
18465 : : ut_setup_security, ut_teardown,
18466 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
18467 : : TEST_CASE_NAMED_WITH_DATA(
18468 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18469 : : ut_setup_security, ut_teardown,
18470 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
18471 : : TEST_CASE_NAMED_WITH_DATA(
18472 : : "Write record known vector NULL-SHA1-HMAC",
18473 : : ut_setup_security, ut_teardown,
18474 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
18475 : : TEST_CASE_NAMED_WITH_DATA(
18476 : : "Write record known vector CHACHA20-POLY1305",
18477 : : ut_setup_security, ut_teardown,
18478 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
18479 : :
18480 : : TEST_CASE_NAMED_WITH_DATA(
18481 : : "Read record known vector AES-GCM-128 (vector 1)",
18482 : : ut_setup_security, ut_teardown,
18483 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
18484 : : TEST_CASE_NAMED_WITH_DATA(
18485 : : "Read record known vector AES-GCM-128 (vector 2)",
18486 : : ut_setup_security, ut_teardown,
18487 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
18488 : : TEST_CASE_NAMED_WITH_DATA(
18489 : : "Read record known vector AES-GCM-256",
18490 : : ut_setup_security, ut_teardown,
18491 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
18492 : : TEST_CASE_NAMED_WITH_DATA(
18493 : : "Read record known vector AES-128-CBC-SHA1",
18494 : : ut_setup_security, ut_teardown,
18495 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
18496 : : TEST_CASE_NAMED_WITH_DATA(
18497 : : "Read record known vector AES-128-CBC-SHA256",
18498 : : ut_setup_security, ut_teardown,
18499 : : test_tls_record_proto_known_vec_read,
18500 : : &tls_test_data_aes_128_cbc_sha256_hmac),
18501 : : TEST_CASE_NAMED_WITH_DATA(
18502 : : "Read record known vector AES-256-CBC-SHA1",
18503 : : ut_setup_security, ut_teardown,
18504 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
18505 : : TEST_CASE_NAMED_WITH_DATA(
18506 : : "Read record known vector AES-256-CBC-SHA256",
18507 : : ut_setup_security, ut_teardown,
18508 : : test_tls_record_proto_known_vec_read,
18509 : : &tls_test_data_aes_256_cbc_sha256_hmac),
18510 : : TEST_CASE_NAMED_WITH_DATA(
18511 : : "Read record known vector AES-256-CBC-SHA384",
18512 : : ut_setup_security, ut_teardown,
18513 : : test_tls_record_proto_known_vec_read,
18514 : : &tls_test_data_aes_256_cbc_sha384_hmac),
18515 : : TEST_CASE_NAMED_WITH_DATA(
18516 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18517 : : ut_setup_security, ut_teardown,
18518 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18519 : : TEST_CASE_NAMED_WITH_DATA(
18520 : : "Read record known vector NULL-SHA1-HMAC",
18521 : : ut_setup_security, ut_teardown,
18522 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18523 : : TEST_CASE_NAMED_WITH_DATA(
18524 : : "Read record known vector CHACHA20-POLY1305",
18525 : : ut_setup_security, ut_teardown,
18526 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18527 : :
18528 : : TEST_CASE_NAMED_ST(
18529 : : "Combined test alg list",
18530 : : ut_setup_security, ut_teardown,
18531 : : test_tls_1_2_record_proto_display_list),
18532 : : TEST_CASE_NAMED_ST(
18533 : : "Data walkthrough combined test alg list",
18534 : : ut_setup_security, ut_teardown,
18535 : : test_tls_1_2_record_proto_data_walkthrough),
18536 : : TEST_CASE_NAMED_ST(
18537 : : "Multi-segmented mode",
18538 : : ut_setup_security, ut_teardown,
18539 : : test_tls_1_2_record_proto_sgl),
18540 : : TEST_CASE_NAMED_ST(
18541 : : "Multi-segmented mode data walkthrough",
18542 : : ut_setup_security, ut_teardown,
18543 : : test_tls_1_2_record_proto_sgl_data_walkthrough),
18544 : : TEST_CASE_NAMED_ST(
18545 : : "Multi-segmented mode out of place",
18546 : : ut_setup_security, ut_teardown,
18547 : : test_tls_1_2_record_proto_sgl_oop),
18548 : : TEST_CASE_NAMED_ST(
18549 : : "TLS packet header corruption",
18550 : : ut_setup_security, ut_teardown,
18551 : : test_tls_record_proto_corrupt_pkt),
18552 : : TEST_CASE_NAMED_ST(
18553 : : "Custom content type",
18554 : : ut_setup_security, ut_teardown,
18555 : : test_tls_record_proto_custom_content_type),
18556 : : TEST_CASE_NAMED_ST(
18557 : : "Zero len TLS record with content type as app",
18558 : : ut_setup_security, ut_teardown,
18559 : : test_tls_record_proto_zero_len),
18560 : : TEST_CASE_NAMED_ST(
18561 : : "Zero len TLS record with content type as ctrl",
18562 : : ut_setup_security, ut_teardown,
18563 : : test_tls_record_proto_zero_len_non_app),
18564 : : TEST_CASE_NAMED_ST(
18565 : : "TLS record DM mode with optional padding < 2 blocks",
18566 : : ut_setup_security, ut_teardown,
18567 : : test_tls_record_proto_dm_opt_padding),
18568 : : TEST_CASE_NAMED_ST(
18569 : : "TLS record DM mode with optional padding > 2 blocks",
18570 : : ut_setup_security, ut_teardown,
18571 : : test_tls_record_proto_dm_opt_padding_1),
18572 : : TEST_CASE_NAMED_ST(
18573 : : "TLS record SG mode with optional padding < 2 blocks",
18574 : : ut_setup_security, ut_teardown,
18575 : : test_tls_record_proto_sg_opt_padding),
18576 : : TEST_CASE_NAMED_ST(
18577 : : "TLS record SG mode with optional padding > 2 blocks",
18578 : : ut_setup_security, ut_teardown,
18579 : : test_tls_record_proto_sg_opt_padding_1),
18580 : : TEST_CASE_NAMED_ST(
18581 : : "TLS record SG mode with optional padding > 2 blocks",
18582 : : ut_setup_security, ut_teardown,
18583 : : test_tls_record_proto_sg_opt_padding_2),
18584 : : TEST_CASE_NAMED_ST(
18585 : : "TLS record SG mode with optional padding > max range",
18586 : : ut_setup_security, ut_teardown,
18587 : : test_tls_record_proto_sg_opt_padding_max),
18588 : : TEST_CASE_NAMED_ST(
18589 : : "TLS record SG mode with padding corruption",
18590 : : ut_setup_security, ut_teardown,
18591 : : test_tls_record_proto_sg_opt_padding_corrupt),
18592 : : TEST_CASES_END() /**< NULL terminate unit test array */
18593 : : }
18594 : : };
18595 : :
18596 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
18597 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18598 : : .setup = tls_record_proto_testsuite_setup,
18599 : : .unit_test_cases = {
18600 : : TEST_CASE_NAMED_WITH_DATA(
18601 : : "Write record known vector AES-GCM-128",
18602 : : ut_setup_security, ut_teardown,
18603 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18604 : : TEST_CASE_NAMED_WITH_DATA(
18605 : : "Write record known vector AES-GCM-256",
18606 : : ut_setup_security, ut_teardown,
18607 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18608 : : TEST_CASE_NAMED_WITH_DATA(
18609 : : "Write record known vector AES-128-CBC-SHA1",
18610 : : ut_setup_security, ut_teardown,
18611 : : test_tls_record_proto_known_vec,
18612 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18613 : : TEST_CASE_NAMED_WITH_DATA(
18614 : : "Write record known vector AES-128-CBC-SHA256",
18615 : : ut_setup_security, ut_teardown,
18616 : : test_tls_record_proto_known_vec,
18617 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18618 : : TEST_CASE_NAMED_WITH_DATA(
18619 : : "Write record known vector AES-256-CBC-SHA1",
18620 : : ut_setup_security, ut_teardown,
18621 : : test_tls_record_proto_known_vec,
18622 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18623 : : TEST_CASE_NAMED_WITH_DATA(
18624 : : "Write record known vector AES-256-CBC-SHA256",
18625 : : ut_setup_security, ut_teardown,
18626 : : test_tls_record_proto_known_vec,
18627 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18628 : : TEST_CASE_NAMED_WITH_DATA(
18629 : : "Write record known vector AES-256-CBC-SHA384",
18630 : : ut_setup_security, ut_teardown,
18631 : : test_tls_record_proto_known_vec,
18632 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18633 : : TEST_CASE_NAMED_WITH_DATA(
18634 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
18635 : : ut_setup_security, ut_teardown,
18636 : : test_tls_record_proto_known_vec,
18637 : : &dtls_test_data_3des_cbc_sha1_hmac),
18638 : : TEST_CASE_NAMED_WITH_DATA(
18639 : : "Write record known vector NULL-SHA1-HMAC",
18640 : : ut_setup_security, ut_teardown,
18641 : : test_tls_record_proto_known_vec,
18642 : : &dtls_test_data_null_cipher_sha1_hmac),
18643 : : TEST_CASE_NAMED_WITH_DATA(
18644 : : "Write record known vector CHACHA20-POLY1305",
18645 : : ut_setup_security, ut_teardown,
18646 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18647 : : TEST_CASE_NAMED_WITH_DATA(
18648 : : "Read record known vector AES-GCM-128",
18649 : : ut_setup_security, ut_teardown,
18650 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18651 : : TEST_CASE_NAMED_WITH_DATA(
18652 : : "Read record known vector AES-GCM-256",
18653 : : ut_setup_security, ut_teardown,
18654 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18655 : : TEST_CASE_NAMED_WITH_DATA(
18656 : : "Read record known vector AES-128-CBC-SHA1",
18657 : : ut_setup_security, ut_teardown,
18658 : : test_tls_record_proto_known_vec_read,
18659 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
18660 : : TEST_CASE_NAMED_WITH_DATA(
18661 : : "Read record known vector AES-128-CBC-SHA256",
18662 : : ut_setup_security, ut_teardown,
18663 : : test_tls_record_proto_known_vec_read,
18664 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
18665 : : TEST_CASE_NAMED_WITH_DATA(
18666 : : "Read record known vector AES-256-CBC-SHA1",
18667 : : ut_setup_security, ut_teardown,
18668 : : test_tls_record_proto_known_vec_read,
18669 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
18670 : : TEST_CASE_NAMED_WITH_DATA(
18671 : : "Read record known vector AES-256-CBC-SHA256",
18672 : : ut_setup_security, ut_teardown,
18673 : : test_tls_record_proto_known_vec_read,
18674 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
18675 : : TEST_CASE_NAMED_WITH_DATA(
18676 : : "Read record known vector AES-256-CBC-SHA384",
18677 : : ut_setup_security, ut_teardown,
18678 : : test_tls_record_proto_known_vec_read,
18679 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
18680 : : TEST_CASE_NAMED_WITH_DATA(
18681 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
18682 : : ut_setup_security, ut_teardown,
18683 : : test_tls_record_proto_known_vec_read,
18684 : : &dtls_test_data_3des_cbc_sha1_hmac),
18685 : : TEST_CASE_NAMED_WITH_DATA(
18686 : : "Read record known vector NULL-SHA1-HMAC",
18687 : : ut_setup_security, ut_teardown,
18688 : : test_tls_record_proto_known_vec_read,
18689 : : &dtls_test_data_null_cipher_sha1_hmac),
18690 : : TEST_CASE_NAMED_WITH_DATA(
18691 : : "Read record known vector CHACHA20-POLY1305",
18692 : : ut_setup_security, ut_teardown,
18693 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18694 : :
18695 : : TEST_CASE_NAMED_ST(
18696 : : "Combined test alg list",
18697 : : ut_setup_security, ut_teardown,
18698 : : test_dtls_1_2_record_proto_display_list),
18699 : : TEST_CASE_NAMED_ST(
18700 : : "Data walkthrough combined test alg list",
18701 : : ut_setup_security, ut_teardown,
18702 : : test_dtls_1_2_record_proto_data_walkthrough),
18703 : : TEST_CASE_NAMED_ST(
18704 : : "Multi-segmented mode",
18705 : : ut_setup_security, ut_teardown,
18706 : : test_dtls_1_2_record_proto_sgl),
18707 : : TEST_CASE_NAMED_ST(
18708 : : "Multi-segmented mode data walkthrough",
18709 : : ut_setup_security, ut_teardown,
18710 : : test_dtls_1_2_record_proto_sgl_data_walkthrough),
18711 : : TEST_CASE_NAMED_ST(
18712 : : "Multi-segmented mode out of place",
18713 : : ut_setup_security, ut_teardown,
18714 : : test_dtls_1_2_record_proto_sgl_oop),
18715 : : TEST_CASE_NAMED_ST(
18716 : : "Packet corruption",
18717 : : ut_setup_security, ut_teardown,
18718 : : test_dtls_1_2_record_proto_corrupt_pkt),
18719 : : TEST_CASE_NAMED_ST(
18720 : : "Custom content type",
18721 : : ut_setup_security, ut_teardown,
18722 : : test_dtls_1_2_record_proto_custom_content_type),
18723 : : TEST_CASE_NAMED_ST(
18724 : : "Zero len DTLS record with content type as app",
18725 : : ut_setup_security, ut_teardown,
18726 : : test_dtls_1_2_record_proto_zero_len),
18727 : : TEST_CASE_NAMED_ST(
18728 : : "Zero len DTLS record with content type as ctrl",
18729 : : ut_setup_security, ut_teardown,
18730 : : test_dtls_1_2_record_proto_zero_len_non_app),
18731 : : TEST_CASE_NAMED_ST(
18732 : : "Antireplay with window size 64",
18733 : : ut_setup_security, ut_teardown,
18734 : : test_dtls_1_2_record_proto_antireplay64),
18735 : : TEST_CASE_NAMED_ST(
18736 : : "Antireplay with window size 128",
18737 : : ut_setup_security, ut_teardown,
18738 : : test_dtls_1_2_record_proto_antireplay128),
18739 : : TEST_CASE_NAMED_ST(
18740 : : "Antireplay with window size 256",
18741 : : ut_setup_security, ut_teardown,
18742 : : test_dtls_1_2_record_proto_antireplay256),
18743 : : TEST_CASE_NAMED_ST(
18744 : : "Antireplay with window size 512",
18745 : : ut_setup_security, ut_teardown,
18746 : : test_dtls_1_2_record_proto_antireplay512),
18747 : : TEST_CASE_NAMED_ST(
18748 : : "Antireplay with window size 1024",
18749 : : ut_setup_security, ut_teardown,
18750 : : test_dtls_1_2_record_proto_antireplay1024),
18751 : : TEST_CASE_NAMED_ST(
18752 : : "Antireplay with window size 2048",
18753 : : ut_setup_security, ut_teardown,
18754 : : test_dtls_1_2_record_proto_antireplay2048),
18755 : : TEST_CASE_NAMED_ST(
18756 : : "Antireplay with window size 4096",
18757 : : ut_setup_security, ut_teardown,
18758 : : test_dtls_1_2_record_proto_antireplay4096),
18759 : : TEST_CASE_NAMED_ST(
18760 : : "DTLS record DM mode with optional padding < 2 blocks",
18761 : : ut_setup_security, ut_teardown,
18762 : : test_dtls_1_2_record_proto_dm_opt_padding),
18763 : : TEST_CASE_NAMED_ST(
18764 : : "DTLS record DM mode with optional padding > 2 blocks",
18765 : : ut_setup_security, ut_teardown,
18766 : : test_dtls_1_2_record_proto_dm_opt_padding_1),
18767 : : TEST_CASE_NAMED_ST(
18768 : : "DTLS record SG mode with optional padding < 2 blocks",
18769 : : ut_setup_security, ut_teardown,
18770 : : test_dtls_1_2_record_proto_sg_opt_padding),
18771 : : TEST_CASE_NAMED_ST(
18772 : : "DTLS record SG mode with optional padding > 2 blocks",
18773 : : ut_setup_security, ut_teardown,
18774 : : test_dtls_1_2_record_proto_sg_opt_padding_1),
18775 : : TEST_CASE_NAMED_ST(
18776 : : "DTLS record SG mode with optional padding > 2 blocks",
18777 : : ut_setup_security, ut_teardown,
18778 : : test_dtls_1_2_record_proto_sg_opt_padding_2),
18779 : : TEST_CASE_NAMED_ST(
18780 : : "DTLS record SG mode with optional padding > max range",
18781 : : ut_setup_security, ut_teardown,
18782 : : test_dtls_1_2_record_proto_sg_opt_padding_max),
18783 : : TEST_CASE_NAMED_ST(
18784 : : "DTLS record SG mode with padding corruption",
18785 : : ut_setup_security, ut_teardown,
18786 : : test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18787 : : TEST_CASES_END() /**< NULL terminate unit test array */
18788 : : }
18789 : : };
18790 : :
18791 : : static struct unit_test_suite tls13_record_proto_testsuite = {
18792 : : .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18793 : : .setup = tls_record_proto_testsuite_setup,
18794 : : .unit_test_cases = {
18795 : : TEST_CASE_NAMED_WITH_DATA(
18796 : : "Write record known vector AES-GCM-128",
18797 : : ut_setup_security, ut_teardown,
18798 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18799 : : TEST_CASE_NAMED_WITH_DATA(
18800 : : "Write record known vector AES-GCM-256",
18801 : : ut_setup_security, ut_teardown,
18802 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18803 : : TEST_CASE_NAMED_WITH_DATA(
18804 : : "Write record known vector CHACHA20-POLY1305",
18805 : : ut_setup_security, ut_teardown,
18806 : : test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18807 : :
18808 : : TEST_CASE_NAMED_WITH_DATA(
18809 : : "Read record known vector AES-GCM-128",
18810 : : ut_setup_security, ut_teardown,
18811 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18812 : : TEST_CASE_NAMED_WITH_DATA(
18813 : : "Read record known vector AES-GCM-256",
18814 : : ut_setup_security, ut_teardown,
18815 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18816 : : TEST_CASE_NAMED_WITH_DATA(
18817 : : "Read record known vector CHACHA20-POLY1305",
18818 : : ut_setup_security, ut_teardown,
18819 : : test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18820 : : TEST_CASE_NAMED_ST(
18821 : : "TLS-1.3 record header corruption",
18822 : : ut_setup_security, ut_teardown,
18823 : : test_tls_1_3_record_proto_corrupt_pkt),
18824 : : TEST_CASE_NAMED_ST(
18825 : : "TLS-1.3 record header with custom content type",
18826 : : ut_setup_security, ut_teardown,
18827 : : test_tls_1_3_record_proto_custom_content_type),
18828 : : TEST_CASE_NAMED_ST(
18829 : : "TLS-1.3 record with zero len and content type as app",
18830 : : ut_setup_security, ut_teardown,
18831 : : test_tls_1_3_record_proto_zero_len),
18832 : : TEST_CASE_NAMED_ST(
18833 : : "TLS-1.3 record with zero len and content type as ctrl",
18834 : : ut_setup_security, ut_teardown,
18835 : : test_tls_1_3_record_proto_zero_len_non_app),
18836 : : TEST_CASE_NAMED_ST(
18837 : : "TLS-1.3 record DM mode with optional padding",
18838 : : ut_setup_security, ut_teardown,
18839 : : test_tls_1_3_record_proto_dm_opt_padding),
18840 : : TEST_CASE_NAMED_ST(
18841 : : "TLS-1.3 record SG mode with optional padding - 1",
18842 : : ut_setup_security, ut_teardown,
18843 : : test_tls_1_3_record_proto_sg_opt_padding),
18844 : : TEST_CASE_NAMED_ST(
18845 : : "TLS-1.3 record SG mode with optional padding",
18846 : : ut_setup_security, ut_teardown,
18847 : : test_tls_1_3_record_proto_sg_opt_padding_1),
18848 : : TEST_CASE_NAMED_ST(
18849 : : "Combined test alg list",
18850 : : ut_setup_security, ut_teardown,
18851 : : test_tls_1_3_record_proto_display_list),
18852 : : TEST_CASE_NAMED_ST(
18853 : : "Data walkthrough combined test alg list",
18854 : : ut_setup_security, ut_teardown,
18855 : : test_tls_1_3_record_proto_data_walkthrough),
18856 : : TEST_CASE_NAMED_ST(
18857 : : "Multi-segmented mode",
18858 : : ut_setup_security, ut_teardown,
18859 : : test_tls_1_3_record_proto_sgl),
18860 : : TEST_CASE_NAMED_ST(
18861 : : "Multi-segmented mode data walkthrough",
18862 : : ut_setup_security, ut_teardown,
18863 : : test_tls_1_3_record_proto_sgl_data_walkthrough),
18864 : : TEST_CASE_NAMED_ST(
18865 : : "Multi-segmented mode out of place",
18866 : : ut_setup_security, ut_teardown,
18867 : : test_tls_1_3_record_proto_sgl_oop),
18868 : : TEST_CASES_END() /**< NULL terminate unit test array */
18869 : : }
18870 : : };
18871 : :
18872 : : #define ADD_UPLINK_TESTCASE(data) \
18873 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
18874 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
18875 : :
18876 : : #define ADD_DOWNLINK_TESTCASE(data) \
18877 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
18878 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
18879 : :
18880 : : static struct unit_test_suite docsis_proto_testsuite = {
18881 : : .suite_name = "DOCSIS Proto Unit Test Suite",
18882 : : .setup = docsis_proto_testsuite_setup,
18883 : : .unit_test_cases = {
18884 : : /* Uplink */
18885 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
18886 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
18887 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
18888 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
18889 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
18890 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
18891 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
18892 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
18893 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
18894 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
18895 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
18896 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
18897 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
18898 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
18899 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
18900 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
18901 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
18902 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
18903 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
18904 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
18905 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
18906 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
18907 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
18908 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
18909 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
18910 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
18911 : : /* Downlink */
18912 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18913 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18914 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18915 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18916 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18917 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18918 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18919 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18920 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18921 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18922 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18923 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18924 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18925 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18926 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18927 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18928 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18929 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18930 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18931 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18932 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18933 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18934 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18935 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18936 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18937 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18938 : : TEST_CASES_END() /**< NULL terminate unit test array */
18939 : : }
18940 : : };
18941 : : #endif
18942 : :
18943 : : static struct unit_test_suite cryptodev_gen_testsuite = {
18944 : : .suite_name = "Crypto General Unit Test Suite",
18945 : : .setup = crypto_gen_testsuite_setup,
18946 : : .unit_test_cases = {
18947 : : TEST_CASE_ST(ut_setup, ut_teardown,
18948 : : test_device_reconfigure),
18949 : : TEST_CASE_ST(ut_setup, ut_teardown,
18950 : : test_device_configure_invalid_dev_id),
18951 : : TEST_CASE_ST(ut_setup, ut_teardown,
18952 : : test_queue_pair_descriptor_setup),
18953 : : TEST_CASE_ST(ut_setup, ut_teardown,
18954 : : test_device_configure_invalid_queue_pair_ids),
18955 : : TEST_CASE_ST(ut_setup, ut_teardown,
18956 : : test_queue_pair_descriptor_count),
18957 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18958 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18959 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18960 : : TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
18961 : : test_cryptodev_verify_error_recover, &aes_test_data_4),
18962 : : TEST_CASES_END() /**< NULL terminate unit test array */
18963 : : }
18964 : : };
18965 : :
18966 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18967 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
18968 : : .setup = negative_hmac_sha1_testsuite_setup,
18969 : : .unit_test_cases = {
18970 : : /** Negative tests */
18971 : : TEST_CASE_ST(ut_setup, ut_teardown,
18972 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
18973 : : TEST_CASE_ST(ut_setup, ut_teardown,
18974 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18975 : : TEST_CASE_ST(ut_setup, ut_teardown,
18976 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18977 : : TEST_CASE_ST(ut_setup, ut_teardown,
18978 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18979 : :
18980 : : TEST_CASES_END() /**< NULL terminate unit test array */
18981 : : }
18982 : : };
18983 : :
18984 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
18985 : : .suite_name = "Multi Session Unit Test Suite",
18986 : : .setup = multi_session_testsuite_setup,
18987 : : .unit_test_cases = {
18988 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18989 : : TEST_CASE_ST(ut_setup, ut_teardown,
18990 : : test_multi_session_random_usage),
18991 : :
18992 : : TEST_CASES_END() /**< NULL terminate unit test array */
18993 : : }
18994 : : };
18995 : :
18996 : : static struct unit_test_suite cryptodev_null_testsuite = {
18997 : : .suite_name = "NULL Test Suite",
18998 : : .setup = null_testsuite_setup,
18999 : : .unit_test_cases = {
19000 : : TEST_CASE_ST(ut_setup, ut_teardown,
19001 : : test_null_invalid_operation),
19002 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
19003 : : TEST_CASES_END()
19004 : : }
19005 : : };
19006 : :
19007 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
19008 : : .suite_name = "AES CCM Authenticated Test Suite",
19009 : : .setup = aes_ccm_auth_testsuite_setup,
19010 : : .unit_test_cases = {
19011 : : /** AES CCM Authenticated Encryption 128 bits key*/
19012 : : TEST_CASE_ST(ut_setup, ut_teardown,
19013 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
19014 : : TEST_CASE_ST(ut_setup, ut_teardown,
19015 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
19016 : : TEST_CASE_ST(ut_setup, ut_teardown,
19017 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
19018 : : TEST_CASE_ST(ut_setup, ut_teardown,
19019 : : test_AES_CCM_authenticated_encryption_test_case_128_4),
19020 : :
19021 : : /** AES CCM Authenticated Decryption 128 bits key*/
19022 : : TEST_CASE_ST(ut_setup, ut_teardown,
19023 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
19024 : : TEST_CASE_ST(ut_setup, ut_teardown,
19025 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
19026 : : TEST_CASE_ST(ut_setup, ut_teardown,
19027 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
19028 : : TEST_CASE_ST(ut_setup, ut_teardown,
19029 : : test_AES_CCM_authenticated_decryption_test_case_128_4),
19030 : :
19031 : : /** AES CCM Authenticated Encryption 192 bits key */
19032 : : TEST_CASE_ST(ut_setup, ut_teardown,
19033 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
19034 : : TEST_CASE_ST(ut_setup, ut_teardown,
19035 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
19036 : : TEST_CASE_ST(ut_setup, ut_teardown,
19037 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
19038 : :
19039 : : /** AES CCM Authenticated Decryption 192 bits key*/
19040 : : TEST_CASE_ST(ut_setup, ut_teardown,
19041 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
19042 : : TEST_CASE_ST(ut_setup, ut_teardown,
19043 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
19044 : : TEST_CASE_ST(ut_setup, ut_teardown,
19045 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
19046 : :
19047 : : /** AES CCM Authenticated Encryption 256 bits key */
19048 : : TEST_CASE_ST(ut_setup, ut_teardown,
19049 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
19050 : : TEST_CASE_ST(ut_setup, ut_teardown,
19051 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
19052 : : TEST_CASE_ST(ut_setup, ut_teardown,
19053 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
19054 : :
19055 : : /** AES CCM Authenticated Decryption 256 bits key*/
19056 : : TEST_CASE_ST(ut_setup, ut_teardown,
19057 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
19058 : : TEST_CASE_ST(ut_setup, ut_teardown,
19059 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
19060 : : TEST_CASE_ST(ut_setup, ut_teardown,
19061 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
19062 : : TEST_CASES_END()
19063 : : }
19064 : : };
19065 : :
19066 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
19067 : : .suite_name = "AES GCM Authenticated Test Suite",
19068 : : .setup = aes_gcm_auth_testsuite_setup,
19069 : : .unit_test_cases = {
19070 : : /** AES GCM Authenticated Encryption */
19071 : : TEST_CASE_ST(ut_setup, ut_teardown,
19072 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
19073 : : TEST_CASE_ST(ut_setup, ut_teardown,
19074 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
19075 : : TEST_CASE_ST(ut_setup, ut_teardown,
19076 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
19077 : : TEST_CASE_ST(ut_setup, ut_teardown,
19078 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
19079 : : TEST_CASE_ST(ut_setup, ut_teardown,
19080 : : test_AES_GCM_authenticated_encryption_test_case_1),
19081 : : TEST_CASE_ST(ut_setup, ut_teardown,
19082 : : test_AES_GCM_authenticated_encryption_test_case_2),
19083 : : TEST_CASE_ST(ut_setup, ut_teardown,
19084 : : test_AES_GCM_authenticated_encryption_test_case_3),
19085 : : TEST_CASE_ST(ut_setup, ut_teardown,
19086 : : test_AES_GCM_authenticated_encryption_test_case_4),
19087 : : TEST_CASE_ST(ut_setup, ut_teardown,
19088 : : test_AES_GCM_authenticated_encryption_test_case_5),
19089 : : TEST_CASE_ST(ut_setup, ut_teardown,
19090 : : test_AES_GCM_authenticated_encryption_test_case_6),
19091 : : TEST_CASE_ST(ut_setup, ut_teardown,
19092 : : test_AES_GCM_authenticated_encryption_test_case_7),
19093 : : TEST_CASE_ST(ut_setup, ut_teardown,
19094 : : test_AES_GCM_authenticated_encryption_test_case_8),
19095 : : TEST_CASE_ST(ut_setup, ut_teardown,
19096 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
19097 : :
19098 : : /** AES GCM Authenticated Decryption */
19099 : : TEST_CASE_ST(ut_setup, ut_teardown,
19100 : : test_AES_GCM_authenticated_decryption_test_case_1),
19101 : : TEST_CASE_ST(ut_setup, ut_teardown,
19102 : : test_AES_GCM_authenticated_decryption_test_case_2),
19103 : : TEST_CASE_ST(ut_setup, ut_teardown,
19104 : : test_AES_GCM_authenticated_decryption_test_case_3),
19105 : : TEST_CASE_ST(ut_setup, ut_teardown,
19106 : : test_AES_GCM_authenticated_decryption_test_case_4),
19107 : : TEST_CASE_ST(ut_setup, ut_teardown,
19108 : : test_AES_GCM_authenticated_decryption_test_case_5),
19109 : : TEST_CASE_ST(ut_setup, ut_teardown,
19110 : : test_AES_GCM_authenticated_decryption_test_case_6),
19111 : : TEST_CASE_ST(ut_setup, ut_teardown,
19112 : : test_AES_GCM_authenticated_decryption_test_case_7),
19113 : : TEST_CASE_ST(ut_setup, ut_teardown,
19114 : : test_AES_GCM_authenticated_decryption_test_case_8),
19115 : : TEST_CASE_ST(ut_setup, ut_teardown,
19116 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
19117 : :
19118 : : /** AES GCM Authenticated Encryption 192 bits key */
19119 : : TEST_CASE_ST(ut_setup, ut_teardown,
19120 : : test_AES_GCM_auth_encryption_test_case_192_1),
19121 : : TEST_CASE_ST(ut_setup, ut_teardown,
19122 : : test_AES_GCM_auth_encryption_test_case_192_2),
19123 : : TEST_CASE_ST(ut_setup, ut_teardown,
19124 : : test_AES_GCM_auth_encryption_test_case_192_3),
19125 : : TEST_CASE_ST(ut_setup, ut_teardown,
19126 : : test_AES_GCM_auth_encryption_test_case_192_4),
19127 : : TEST_CASE_ST(ut_setup, ut_teardown,
19128 : : test_AES_GCM_auth_encryption_test_case_192_5),
19129 : : TEST_CASE_ST(ut_setup, ut_teardown,
19130 : : test_AES_GCM_auth_encryption_test_case_192_6),
19131 : : TEST_CASE_ST(ut_setup, ut_teardown,
19132 : : test_AES_GCM_auth_encryption_test_case_192_7),
19133 : :
19134 : : /** AES GCM Authenticated Decryption 192 bits key */
19135 : : TEST_CASE_ST(ut_setup, ut_teardown,
19136 : : test_AES_GCM_auth_decryption_test_case_192_1),
19137 : : TEST_CASE_ST(ut_setup, ut_teardown,
19138 : : test_AES_GCM_auth_decryption_test_case_192_2),
19139 : : TEST_CASE_ST(ut_setup, ut_teardown,
19140 : : test_AES_GCM_auth_decryption_test_case_192_3),
19141 : : TEST_CASE_ST(ut_setup, ut_teardown,
19142 : : test_AES_GCM_auth_decryption_test_case_192_4),
19143 : : TEST_CASE_ST(ut_setup, ut_teardown,
19144 : : test_AES_GCM_auth_decryption_test_case_192_5),
19145 : : TEST_CASE_ST(ut_setup, ut_teardown,
19146 : : test_AES_GCM_auth_decryption_test_case_192_6),
19147 : : TEST_CASE_ST(ut_setup, ut_teardown,
19148 : : test_AES_GCM_auth_decryption_test_case_192_7),
19149 : :
19150 : : /** AES GCM Authenticated Encryption 256 bits key */
19151 : : TEST_CASE_ST(ut_setup, ut_teardown,
19152 : : test_AES_GCM_auth_encryption_test_case_256_1),
19153 : : TEST_CASE_ST(ut_setup, ut_teardown,
19154 : : test_AES_GCM_auth_encryption_test_case_256_2),
19155 : : TEST_CASE_ST(ut_setup, ut_teardown,
19156 : : test_AES_GCM_auth_encryption_test_case_256_3),
19157 : : TEST_CASE_ST(ut_setup, ut_teardown,
19158 : : test_AES_GCM_auth_encryption_test_case_256_4),
19159 : : TEST_CASE_ST(ut_setup, ut_teardown,
19160 : : test_AES_GCM_auth_encryption_test_case_256_5),
19161 : : TEST_CASE_ST(ut_setup, ut_teardown,
19162 : : test_AES_GCM_auth_encryption_test_case_256_6),
19163 : : TEST_CASE_ST(ut_setup, ut_teardown,
19164 : : test_AES_GCM_auth_encryption_test_case_256_7),
19165 : : TEST_CASE_ST(ut_setup, ut_teardown,
19166 : : test_AES_GCM_auth_encryption_test_case_256_8),
19167 : :
19168 : : /** AES GCM Authenticated Decryption 256 bits key */
19169 : : TEST_CASE_ST(ut_setup, ut_teardown,
19170 : : test_AES_GCM_auth_decryption_test_case_256_1),
19171 : : TEST_CASE_ST(ut_setup, ut_teardown,
19172 : : test_AES_GCM_auth_decryption_test_case_256_2),
19173 : : TEST_CASE_ST(ut_setup, ut_teardown,
19174 : : test_AES_GCM_auth_decryption_test_case_256_3),
19175 : : TEST_CASE_ST(ut_setup, ut_teardown,
19176 : : test_AES_GCM_auth_decryption_test_case_256_4),
19177 : : TEST_CASE_ST(ut_setup, ut_teardown,
19178 : : test_AES_GCM_auth_decryption_test_case_256_5),
19179 : : TEST_CASE_ST(ut_setup, ut_teardown,
19180 : : test_AES_GCM_auth_decryption_test_case_256_6),
19181 : : TEST_CASE_ST(ut_setup, ut_teardown,
19182 : : test_AES_GCM_auth_decryption_test_case_256_7),
19183 : : TEST_CASE_ST(ut_setup, ut_teardown,
19184 : : test_AES_GCM_auth_decryption_test_case_256_8),
19185 : :
19186 : : /** AES GCM Authenticated Encryption big aad size */
19187 : : TEST_CASE_ST(ut_setup, ut_teardown,
19188 : : test_AES_GCM_auth_encryption_test_case_aad_1),
19189 : : TEST_CASE_ST(ut_setup, ut_teardown,
19190 : : test_AES_GCM_auth_encryption_test_case_aad_2),
19191 : :
19192 : : /** AES GCM Authenticated Decryption big aad size */
19193 : : TEST_CASE_ST(ut_setup, ut_teardown,
19194 : : test_AES_GCM_auth_decryption_test_case_aad_1),
19195 : : TEST_CASE_ST(ut_setup, ut_teardown,
19196 : : test_AES_GCM_auth_decryption_test_case_aad_2),
19197 : :
19198 : : /** Out of place tests */
19199 : : TEST_CASE_ST(ut_setup, ut_teardown,
19200 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
19201 : : TEST_CASE_ST(ut_setup, ut_teardown,
19202 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
19203 : :
19204 : : /** Session-less tests */
19205 : : TEST_CASE_ST(ut_setup, ut_teardown,
19206 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
19207 : : TEST_CASE_ST(ut_setup, ut_teardown,
19208 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
19209 : :
19210 : : /** AES GCM external mbuf tests */
19211 : : TEST_CASE_ST(ut_setup, ut_teardown,
19212 : : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
19213 : : TEST_CASE_ST(ut_setup, ut_teardown,
19214 : : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
19215 : :
19216 : : TEST_CASES_END()
19217 : : }
19218 : : };
19219 : :
19220 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
19221 : : .suite_name = "AES GMAC Authentication Test Suite",
19222 : : .setup = aes_gmac_auth_testsuite_setup,
19223 : : .unit_test_cases = {
19224 : : TEST_CASE_ST(ut_setup, ut_teardown,
19225 : : test_AES_GMAC_authentication_test_case_1),
19226 : : TEST_CASE_ST(ut_setup, ut_teardown,
19227 : : test_AES_GMAC_authentication_verify_test_case_1),
19228 : : TEST_CASE_ST(ut_setup, ut_teardown,
19229 : : test_AES_GMAC_authentication_test_case_2),
19230 : : TEST_CASE_ST(ut_setup, ut_teardown,
19231 : : test_AES_GMAC_authentication_verify_test_case_2),
19232 : : TEST_CASE_ST(ut_setup, ut_teardown,
19233 : : test_AES_GMAC_authentication_test_case_3),
19234 : : TEST_CASE_ST(ut_setup, ut_teardown,
19235 : : test_AES_GMAC_authentication_verify_test_case_3),
19236 : : TEST_CASE_ST(ut_setup, ut_teardown,
19237 : : test_AES_GMAC_authentication_test_case_4),
19238 : : TEST_CASE_ST(ut_setup, ut_teardown,
19239 : : test_AES_GMAC_authentication_verify_test_case_4),
19240 : : TEST_CASE_ST(ut_setup, ut_teardown,
19241 : : test_AES_GMAC_authentication_SGL_40B),
19242 : : TEST_CASE_ST(ut_setup, ut_teardown,
19243 : : test_AES_GMAC_authentication_SGL_80B),
19244 : : TEST_CASE_ST(ut_setup, ut_teardown,
19245 : : test_AES_GMAC_authentication_SGL_2048B),
19246 : : TEST_CASE_ST(ut_setup, ut_teardown,
19247 : : test_AES_GMAC_authentication_SGL_2047B),
19248 : :
19249 : : TEST_CASES_END()
19250 : : }
19251 : : };
19252 : :
19253 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
19254 : : .suite_name = "Chacha20-Poly1305 Test Suite",
19255 : : .setup = chacha20_poly1305_testsuite_setup,
19256 : : .unit_test_cases = {
19257 : : TEST_CASE_ST(ut_setup, ut_teardown,
19258 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
19259 : : TEST_CASE_ST(ut_setup, ut_teardown,
19260 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
19261 : : TEST_CASE_ST(ut_setup, ut_teardown,
19262 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
19263 : : TEST_CASES_END()
19264 : : }
19265 : : };
19266 : :
19267 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
19268 : : .suite_name = "SNOW 3G Test Suite",
19269 : : .setup = snow3g_testsuite_setup,
19270 : : .unit_test_cases = {
19271 : : /** SNOW 3G encrypt only (UEA2) */
19272 : : TEST_CASE_ST(ut_setup, ut_teardown,
19273 : : test_snow3g_encryption_test_case_1),
19274 : : TEST_CASE_ST(ut_setup, ut_teardown,
19275 : : test_snow3g_encryption_test_case_2),
19276 : : TEST_CASE_ST(ut_setup, ut_teardown,
19277 : : test_snow3g_encryption_test_case_3),
19278 : : TEST_CASE_ST(ut_setup, ut_teardown,
19279 : : test_snow3g_encryption_test_case_4),
19280 : : TEST_CASE_ST(ut_setup, ut_teardown,
19281 : : test_snow3g_encryption_test_case_5),
19282 : :
19283 : : TEST_CASE_ST(ut_setup, ut_teardown,
19284 : : test_snow3g_encryption_test_case_1_oop),
19285 : : TEST_CASE_ST(ut_setup, ut_teardown,
19286 : : test_snow3g_encryption_test_case_1_oop_sgl),
19287 : : TEST_CASE_ST(ut_setup, ut_teardown,
19288 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
19289 : : TEST_CASE_ST(ut_setup, ut_teardown,
19290 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
19291 : : TEST_CASE_ST(ut_setup, ut_teardown,
19292 : : test_snow3g_encryption_test_case_1_offset_oop),
19293 : : TEST_CASE_ST(ut_setup, ut_teardown,
19294 : : test_snow3g_decryption_test_case_1_oop),
19295 : :
19296 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
19297 : : TEST_CASE_ST(ut_setup, ut_teardown,
19298 : : test_snow3g_auth_cipher_test_case_1),
19299 : : TEST_CASE_ST(ut_setup, ut_teardown,
19300 : : test_snow3g_auth_cipher_test_case_2),
19301 : : TEST_CASE_ST(ut_setup, ut_teardown,
19302 : : test_snow3g_auth_cipher_test_case_2_oop),
19303 : : TEST_CASE_ST(ut_setup, ut_teardown,
19304 : : test_snow3g_auth_cipher_part_digest_enc),
19305 : : TEST_CASE_ST(ut_setup, ut_teardown,
19306 : : test_snow3g_auth_cipher_part_digest_enc_oop),
19307 : : TEST_CASE_ST(ut_setup, ut_teardown,
19308 : : test_snow3g_auth_cipher_test_case_3_sgl),
19309 : : TEST_CASE_ST(ut_setup, ut_teardown,
19310 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
19311 : : TEST_CASE_ST(ut_setup, ut_teardown,
19312 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
19313 : : TEST_CASE_ST(ut_setup, ut_teardown,
19314 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
19315 : : TEST_CASE_ST(ut_setup, ut_teardown,
19316 : : test_snow3g_auth_cipher_total_digest_enc_1),
19317 : : TEST_CASE_ST(ut_setup, ut_teardown,
19318 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
19319 : : TEST_CASE_ST(ut_setup, ut_teardown,
19320 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
19321 : : TEST_CASE_ST(ut_setup, ut_teardown,
19322 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
19323 : :
19324 : : /** SNOW 3G decrypt (UEA2), then verify auth */
19325 : : TEST_CASE_ST(ut_setup, ut_teardown,
19326 : : test_snow3g_auth_cipher_verify_test_case_1),
19327 : : TEST_CASE_ST(ut_setup, ut_teardown,
19328 : : test_snow3g_auth_cipher_verify_test_case_2),
19329 : : TEST_CASE_ST(ut_setup, ut_teardown,
19330 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
19331 : : TEST_CASE_ST(ut_setup, ut_teardown,
19332 : : test_snow3g_auth_cipher_verify_part_digest_enc),
19333 : : TEST_CASE_ST(ut_setup, ut_teardown,
19334 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
19335 : : TEST_CASE_ST(ut_setup, ut_teardown,
19336 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
19337 : : TEST_CASE_ST(ut_setup, ut_teardown,
19338 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
19339 : : TEST_CASE_ST(ut_setup, ut_teardown,
19340 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
19341 : : TEST_CASE_ST(ut_setup, ut_teardown,
19342 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
19343 : : TEST_CASE_ST(ut_setup, ut_teardown,
19344 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
19345 : : TEST_CASE_ST(ut_setup, ut_teardown,
19346 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
19347 : : TEST_CASE_ST(ut_setup, ut_teardown,
19348 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
19349 : : TEST_CASE_ST(ut_setup, ut_teardown,
19350 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
19351 : :
19352 : : /** SNOW 3G decrypt only (UEA2) */
19353 : : TEST_CASE_ST(ut_setup, ut_teardown,
19354 : : test_snow3g_decryption_test_case_1),
19355 : : TEST_CASE_ST(ut_setup, ut_teardown,
19356 : : test_snow3g_decryption_test_case_2),
19357 : : TEST_CASE_ST(ut_setup, ut_teardown,
19358 : : test_snow3g_decryption_test_case_3),
19359 : : TEST_CASE_ST(ut_setup, ut_teardown,
19360 : : test_snow3g_decryption_test_case_4),
19361 : : TEST_CASE_ST(ut_setup, ut_teardown,
19362 : : test_snow3g_decryption_test_case_5),
19363 : : TEST_CASE_ST(ut_setup, ut_teardown,
19364 : : test_snow3g_decryption_with_digest_test_case_1),
19365 : : TEST_CASE_ST(ut_setup, ut_teardown,
19366 : : test_snow3g_hash_generate_test_case_1),
19367 : : TEST_CASE_ST(ut_setup, ut_teardown,
19368 : : test_snow3g_hash_generate_test_case_2),
19369 : : TEST_CASE_ST(ut_setup, ut_teardown,
19370 : : test_snow3g_hash_generate_test_case_3),
19371 : :
19372 : : /* Tests with buffers which length is not byte-aligned */
19373 : : TEST_CASE_ST(ut_setup, ut_teardown,
19374 : : test_snow3g_hash_generate_test_case_4),
19375 : : TEST_CASE_ST(ut_setup, ut_teardown,
19376 : : test_snow3g_hash_generate_test_case_5),
19377 : : TEST_CASE_ST(ut_setup, ut_teardown,
19378 : : test_snow3g_hash_generate_test_case_6),
19379 : : TEST_CASE_ST(ut_setup, ut_teardown,
19380 : : test_snow3g_hash_verify_test_case_1),
19381 : : TEST_CASE_ST(ut_setup, ut_teardown,
19382 : : test_snow3g_hash_verify_test_case_2),
19383 : : TEST_CASE_ST(ut_setup, ut_teardown,
19384 : : test_snow3g_hash_verify_test_case_3),
19385 : :
19386 : : /* Tests with buffers which length is not byte-aligned */
19387 : : TEST_CASE_ST(ut_setup, ut_teardown,
19388 : : test_snow3g_hash_verify_test_case_4),
19389 : : TEST_CASE_ST(ut_setup, ut_teardown,
19390 : : test_snow3g_hash_verify_test_case_5),
19391 : : TEST_CASE_ST(ut_setup, ut_teardown,
19392 : : test_snow3g_hash_verify_test_case_6),
19393 : : TEST_CASE_ST(ut_setup, ut_teardown,
19394 : : test_snow3g_cipher_auth_test_case_1),
19395 : : TEST_CASE_ST(ut_setup, ut_teardown,
19396 : : test_snow3g_auth_cipher_with_digest_test_case_1),
19397 : : TEST_CASES_END()
19398 : : }
19399 : : };
19400 : :
19401 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
19402 : : .suite_name = "ZUC Test Suite",
19403 : : .setup = zuc_testsuite_setup,
19404 : : .unit_test_cases = {
19405 : : /** ZUC encrypt only (EEA3) */
19406 : : TEST_CASE_ST(ut_setup, ut_teardown,
19407 : : test_zuc_encryption_test_case_1),
19408 : : TEST_CASE_ST(ut_setup, ut_teardown,
19409 : : test_zuc_encryption_test_case_2),
19410 : : TEST_CASE_ST(ut_setup, ut_teardown,
19411 : : test_zuc_encryption_test_case_3),
19412 : : TEST_CASE_ST(ut_setup, ut_teardown,
19413 : : test_zuc_encryption_test_case_4),
19414 : : TEST_CASE_ST(ut_setup, ut_teardown,
19415 : : test_zuc_encryption_test_case_5),
19416 : : TEST_CASE_ST(ut_setup, ut_teardown,
19417 : : test_zuc_encryption_test_case_6_sgl),
19418 : :
19419 : : /** ZUC decrypt only (EEA3) */
19420 : : TEST_CASE_ST(ut_setup, ut_teardown,
19421 : : test_zuc_decryption_test_case_1),
19422 : : TEST_CASE_ST(ut_setup, ut_teardown,
19423 : : test_zuc_decryption_test_case_2),
19424 : : TEST_CASE_ST(ut_setup, ut_teardown,
19425 : : test_zuc_decryption_test_case_3),
19426 : : TEST_CASE_ST(ut_setup, ut_teardown,
19427 : : test_zuc_decryption_test_case_4),
19428 : : TEST_CASE_ST(ut_setup, ut_teardown,
19429 : : test_zuc_decryption_test_case_5),
19430 : : TEST_CASE_ST(ut_setup, ut_teardown,
19431 : : test_zuc_decryption_test_case_6_sgl),
19432 : :
19433 : : /** ZUC authenticate (EIA3) */
19434 : : TEST_CASE_ST(ut_setup, ut_teardown,
19435 : : test_zuc_hash_generate_test_case_1),
19436 : : TEST_CASE_ST(ut_setup, ut_teardown,
19437 : : test_zuc_hash_generate_test_case_2),
19438 : : TEST_CASE_ST(ut_setup, ut_teardown,
19439 : : test_zuc_hash_generate_test_case_3),
19440 : : TEST_CASE_ST(ut_setup, ut_teardown,
19441 : : test_zuc_hash_generate_test_case_4),
19442 : : TEST_CASE_ST(ut_setup, ut_teardown,
19443 : : test_zuc_hash_generate_test_case_5),
19444 : : TEST_CASE_ST(ut_setup, ut_teardown,
19445 : : test_zuc_hash_generate_test_case_6),
19446 : : TEST_CASE_ST(ut_setup, ut_teardown,
19447 : : test_zuc_hash_generate_test_case_7),
19448 : : TEST_CASE_ST(ut_setup, ut_teardown,
19449 : : test_zuc_hash_generate_test_case_8),
19450 : :
19451 : : /** ZUC verify (EIA3) */
19452 : : TEST_CASE_ST(ut_setup, ut_teardown,
19453 : : test_zuc_hash_verify_test_case_1),
19454 : : TEST_CASE_ST(ut_setup, ut_teardown,
19455 : : test_zuc_hash_verify_test_case_2),
19456 : : TEST_CASE_ST(ut_setup, ut_teardown,
19457 : : test_zuc_hash_verify_test_case_3),
19458 : : TEST_CASE_ST(ut_setup, ut_teardown,
19459 : : test_zuc_hash_verify_test_case_4),
19460 : : TEST_CASE_ST(ut_setup, ut_teardown,
19461 : : test_zuc_hash_verify_test_case_5),
19462 : : TEST_CASE_ST(ut_setup, ut_teardown,
19463 : : test_zuc_hash_verify_test_case_6),
19464 : : TEST_CASE_ST(ut_setup, ut_teardown,
19465 : : test_zuc_hash_verify_test_case_7),
19466 : : TEST_CASE_ST(ut_setup, ut_teardown,
19467 : : test_zuc_hash_verify_test_case_8),
19468 : :
19469 : : /** ZUC alg-chain (EEA3/EIA3) */
19470 : : TEST_CASE_ST(ut_setup, ut_teardown,
19471 : : test_zuc_cipher_auth_test_case_1),
19472 : : TEST_CASE_ST(ut_setup, ut_teardown,
19473 : : test_zuc_cipher_auth_test_case_2),
19474 : :
19475 : : /** ZUC generate auth, then encrypt (EEA3) */
19476 : : TEST_CASE_ST(ut_setup, ut_teardown,
19477 : : test_zuc_auth_cipher_test_case_1),
19478 : : TEST_CASE_ST(ut_setup, ut_teardown,
19479 : : test_zuc_auth_cipher_test_case_1_oop),
19480 : : TEST_CASE_ST(ut_setup, ut_teardown,
19481 : : test_zuc_auth_cipher_test_case_1_sgl),
19482 : : TEST_CASE_ST(ut_setup, ut_teardown,
19483 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
19484 : : TEST_CASE_ST(ut_setup, ut_teardown,
19485 : : test_zuc_auth_cipher_test_case_2),
19486 : : TEST_CASE_ST(ut_setup, ut_teardown,
19487 : : test_zuc_auth_cipher_test_case_2_oop),
19488 : :
19489 : : /** ZUC decrypt (EEA3), then verify auth */
19490 : : TEST_CASE_ST(ut_setup, ut_teardown,
19491 : : test_zuc_auth_cipher_verify_test_case_1),
19492 : : TEST_CASE_ST(ut_setup, ut_teardown,
19493 : : test_zuc_auth_cipher_verify_test_case_1_oop),
19494 : : TEST_CASE_ST(ut_setup, ut_teardown,
19495 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
19496 : : TEST_CASE_ST(ut_setup, ut_teardown,
19497 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
19498 : : TEST_CASE_ST(ut_setup, ut_teardown,
19499 : : test_zuc_auth_cipher_verify_test_case_2),
19500 : : TEST_CASE_ST(ut_setup, ut_teardown,
19501 : : test_zuc_auth_cipher_verify_test_case_2_oop),
19502 : :
19503 : : /** ZUC-256 encrypt only **/
19504 : : TEST_CASE_ST(ut_setup, ut_teardown,
19505 : : test_zuc256_encryption_test_case_1),
19506 : : TEST_CASE_ST(ut_setup, ut_teardown,
19507 : : test_zuc256_encryption_test_case_2),
19508 : :
19509 : : /** ZUC-256 decrypt only **/
19510 : : TEST_CASE_ST(ut_setup, ut_teardown,
19511 : : test_zuc256_decryption_test_case_1),
19512 : : TEST_CASE_ST(ut_setup, ut_teardown,
19513 : : test_zuc256_decryption_test_case_2),
19514 : :
19515 : : /** ZUC-256 authentication only **/
19516 : : TEST_CASE_ST(ut_setup, ut_teardown,
19517 : : test_zuc256_hash_generate_4b_tag_test_case_1),
19518 : : TEST_CASE_ST(ut_setup, ut_teardown,
19519 : : test_zuc256_hash_generate_4b_tag_test_case_2),
19520 : : TEST_CASE_ST(ut_setup, ut_teardown,
19521 : : test_zuc256_hash_generate_4b_tag_test_case_3),
19522 : : TEST_CASE_ST(ut_setup, ut_teardown,
19523 : : test_zuc256_hash_generate_8b_tag_test_case_1),
19524 : : TEST_CASE_ST(ut_setup, ut_teardown,
19525 : : test_zuc256_hash_generate_16b_tag_test_case_1),
19526 : :
19527 : : /** ZUC-256 authentication verify only **/
19528 : : TEST_CASE_ST(ut_setup, ut_teardown,
19529 : : test_zuc256_hash_verify_4b_tag_test_case_1),
19530 : : TEST_CASE_ST(ut_setup, ut_teardown,
19531 : : test_zuc256_hash_verify_4b_tag_test_case_2),
19532 : : TEST_CASE_ST(ut_setup, ut_teardown,
19533 : : test_zuc256_hash_verify_4b_tag_test_case_3),
19534 : : TEST_CASE_ST(ut_setup, ut_teardown,
19535 : : test_zuc256_hash_verify_8b_tag_test_case_1),
19536 : : TEST_CASE_ST(ut_setup, ut_teardown,
19537 : : test_zuc256_hash_verify_16b_tag_test_case_1),
19538 : :
19539 : : /** ZUC-256 encrypt and authenticate **/
19540 : : TEST_CASE_ST(ut_setup, ut_teardown,
19541 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
19542 : : TEST_CASE_ST(ut_setup, ut_teardown,
19543 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
19544 : : TEST_CASE_ST(ut_setup, ut_teardown,
19545 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
19546 : : TEST_CASE_ST(ut_setup, ut_teardown,
19547 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
19548 : :
19549 : : /** ZUC-256 generate auth, then encrypt */
19550 : : TEST_CASE_ST(ut_setup, ut_teardown,
19551 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
19552 : : TEST_CASE_ST(ut_setup, ut_teardown,
19553 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
19554 : : TEST_CASE_ST(ut_setup, ut_teardown,
19555 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
19556 : : TEST_CASE_ST(ut_setup, ut_teardown,
19557 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
19558 : :
19559 : : /** ZUC-256 decrypt, then verify auth */
19560 : : TEST_CASE_ST(ut_setup, ut_teardown,
19561 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19562 : : TEST_CASE_ST(ut_setup, ut_teardown,
19563 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19564 : : TEST_CASE_ST(ut_setup, ut_teardown,
19565 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19566 : : TEST_CASE_ST(ut_setup, ut_teardown,
19567 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19568 : :
19569 : : TEST_CASES_END()
19570 : : }
19571 : : };
19572 : :
19573 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
19574 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
19575 : : .setup = hmac_md5_auth_testsuite_setup,
19576 : : .unit_test_cases = {
19577 : : TEST_CASE_ST(ut_setup, ut_teardown,
19578 : : test_MD5_HMAC_generate_case_1),
19579 : : TEST_CASE_ST(ut_setup, ut_teardown,
19580 : : test_MD5_HMAC_verify_case_1),
19581 : : TEST_CASE_ST(ut_setup, ut_teardown,
19582 : : test_MD5_HMAC_generate_case_2),
19583 : : TEST_CASE_ST(ut_setup, ut_teardown,
19584 : : test_MD5_HMAC_verify_case_2),
19585 : : TEST_CASES_END()
19586 : : }
19587 : : };
19588 : :
19589 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
19590 : : .suite_name = "Kasumi Test Suite",
19591 : : .setup = kasumi_testsuite_setup,
19592 : : .unit_test_cases = {
19593 : : /** KASUMI hash only (UIA1) */
19594 : : TEST_CASE_ST(ut_setup, ut_teardown,
19595 : : test_kasumi_hash_generate_test_case_1),
19596 : : TEST_CASE_ST(ut_setup, ut_teardown,
19597 : : test_kasumi_hash_generate_test_case_2),
19598 : : TEST_CASE_ST(ut_setup, ut_teardown,
19599 : : test_kasumi_hash_generate_test_case_3),
19600 : : TEST_CASE_ST(ut_setup, ut_teardown,
19601 : : test_kasumi_hash_generate_test_case_4),
19602 : : TEST_CASE_ST(ut_setup, ut_teardown,
19603 : : test_kasumi_hash_generate_test_case_5),
19604 : : TEST_CASE_ST(ut_setup, ut_teardown,
19605 : : test_kasumi_hash_generate_test_case_6),
19606 : :
19607 : : TEST_CASE_ST(ut_setup, ut_teardown,
19608 : : test_kasumi_hash_verify_test_case_1),
19609 : : TEST_CASE_ST(ut_setup, ut_teardown,
19610 : : test_kasumi_hash_verify_test_case_2),
19611 : : TEST_CASE_ST(ut_setup, ut_teardown,
19612 : : test_kasumi_hash_verify_test_case_3),
19613 : : TEST_CASE_ST(ut_setup, ut_teardown,
19614 : : test_kasumi_hash_verify_test_case_4),
19615 : : TEST_CASE_ST(ut_setup, ut_teardown,
19616 : : test_kasumi_hash_verify_test_case_5),
19617 : :
19618 : : /** KASUMI encrypt only (UEA1) */
19619 : : TEST_CASE_ST(ut_setup, ut_teardown,
19620 : : test_kasumi_encryption_test_case_1),
19621 : : TEST_CASE_ST(ut_setup, ut_teardown,
19622 : : test_kasumi_encryption_test_case_1_sgl),
19623 : : TEST_CASE_ST(ut_setup, ut_teardown,
19624 : : test_kasumi_encryption_test_case_1_oop),
19625 : : TEST_CASE_ST(ut_setup, ut_teardown,
19626 : : test_kasumi_encryption_test_case_1_oop_sgl),
19627 : : TEST_CASE_ST(ut_setup, ut_teardown,
19628 : : test_kasumi_encryption_test_case_2),
19629 : : TEST_CASE_ST(ut_setup, ut_teardown,
19630 : : test_kasumi_encryption_test_case_3),
19631 : : TEST_CASE_ST(ut_setup, ut_teardown,
19632 : : test_kasumi_encryption_test_case_4),
19633 : : TEST_CASE_ST(ut_setup, ut_teardown,
19634 : : test_kasumi_encryption_test_case_5),
19635 : :
19636 : : /** KASUMI decrypt only (UEA1) */
19637 : : TEST_CASE_ST(ut_setup, ut_teardown,
19638 : : test_kasumi_decryption_test_case_1),
19639 : : TEST_CASE_ST(ut_setup, ut_teardown,
19640 : : test_kasumi_decryption_test_case_2),
19641 : : TEST_CASE_ST(ut_setup, ut_teardown,
19642 : : test_kasumi_decryption_test_case_3),
19643 : : TEST_CASE_ST(ut_setup, ut_teardown,
19644 : : test_kasumi_decryption_test_case_4),
19645 : : TEST_CASE_ST(ut_setup, ut_teardown,
19646 : : test_kasumi_decryption_test_case_5),
19647 : : TEST_CASE_ST(ut_setup, ut_teardown,
19648 : : test_kasumi_decryption_test_case_1_oop),
19649 : : TEST_CASE_ST(ut_setup, ut_teardown,
19650 : : test_kasumi_cipher_auth_test_case_1),
19651 : :
19652 : : /** KASUMI generate auth, then encrypt (F8) */
19653 : : TEST_CASE_ST(ut_setup, ut_teardown,
19654 : : test_kasumi_auth_cipher_test_case_1),
19655 : : TEST_CASE_ST(ut_setup, ut_teardown,
19656 : : test_kasumi_auth_cipher_test_case_2),
19657 : : TEST_CASE_ST(ut_setup, ut_teardown,
19658 : : test_kasumi_auth_cipher_test_case_2_oop),
19659 : : TEST_CASE_ST(ut_setup, ut_teardown,
19660 : : test_kasumi_auth_cipher_test_case_2_sgl),
19661 : : TEST_CASE_ST(ut_setup, ut_teardown,
19662 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
19663 : :
19664 : : /** KASUMI decrypt (F8), then verify auth */
19665 : : TEST_CASE_ST(ut_setup, ut_teardown,
19666 : : test_kasumi_auth_cipher_verify_test_case_1),
19667 : : TEST_CASE_ST(ut_setup, ut_teardown,
19668 : : test_kasumi_auth_cipher_verify_test_case_2),
19669 : : TEST_CASE_ST(ut_setup, ut_teardown,
19670 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
19671 : : TEST_CASE_ST(ut_setup, ut_teardown,
19672 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
19673 : : TEST_CASE_ST(ut_setup, ut_teardown,
19674 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19675 : :
19676 : : TEST_CASES_END()
19677 : : }
19678 : : };
19679 : :
19680 : : static struct unit_test_suite cryptodev_esn_testsuite = {
19681 : : .suite_name = "ESN Test Suite",
19682 : : .setup = esn_testsuite_setup,
19683 : : .unit_test_cases = {
19684 : : TEST_CASE_ST(ut_setup, ut_teardown,
19685 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19686 : : TEST_CASE_ST(ut_setup, ut_teardown,
19687 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19688 : : TEST_CASES_END()
19689 : : }
19690 : : };
19691 : :
19692 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
19693 : : .suite_name = "Negative AES GCM Test Suite",
19694 : : .setup = negative_aes_gcm_testsuite_setup,
19695 : : .unit_test_cases = {
19696 : : TEST_CASE_ST(ut_setup, ut_teardown,
19697 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
19698 : : TEST_CASE_ST(ut_setup, ut_teardown,
19699 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19700 : : TEST_CASE_ST(ut_setup, ut_teardown,
19701 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19702 : : TEST_CASE_ST(ut_setup, ut_teardown,
19703 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19704 : : TEST_CASE_ST(ut_setup, ut_teardown,
19705 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
19706 : : TEST_CASE_ST(ut_setup, ut_teardown,
19707 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
19708 : : TEST_CASE_ST(ut_setup, ut_teardown,
19709 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
19710 : : TEST_CASE_ST(ut_setup, ut_teardown,
19711 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19712 : : TEST_CASE_ST(ut_setup, ut_teardown,
19713 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19714 : : TEST_CASE_ST(ut_setup, ut_teardown,
19715 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19716 : : TEST_CASE_ST(ut_setup, ut_teardown,
19717 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
19718 : : TEST_CASE_ST(ut_setup, ut_teardown,
19719 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
19720 : :
19721 : : TEST_CASES_END()
19722 : : }
19723 : : };
19724 : :
19725 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
19726 : : .suite_name = "Negative AES GMAC Test Suite",
19727 : : .setup = negative_aes_gmac_testsuite_setup,
19728 : : .unit_test_cases = {
19729 : : TEST_CASE_ST(ut_setup, ut_teardown,
19730 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
19731 : : TEST_CASE_ST(ut_setup, ut_teardown,
19732 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
19733 : :
19734 : : TEST_CASES_END()
19735 : : }
19736 : : };
19737 : :
19738 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
19739 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19740 : : .setup = mixed_cipher_hash_testsuite_setup,
19741 : : .unit_test_cases = {
19742 : : /** AUTH AES CMAC + CIPHER AES CTR */
19743 : : TEST_CASE_ST(ut_setup, ut_teardown,
19744 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19745 : : TEST_CASE_ST(ut_setup, ut_teardown,
19746 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19747 : : TEST_CASE_ST(ut_setup, ut_teardown,
19748 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19749 : : TEST_CASE_ST(ut_setup, ut_teardown,
19750 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19751 : : TEST_CASE_ST(ut_setup, ut_teardown,
19752 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19753 : : TEST_CASE_ST(ut_setup, ut_teardown,
19754 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19755 : : TEST_CASE_ST(ut_setup, ut_teardown,
19756 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19757 : : TEST_CASE_ST(ut_setup, ut_teardown,
19758 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19759 : : TEST_CASE_ST(ut_setup, ut_teardown,
19760 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19761 : : TEST_CASE_ST(ut_setup, ut_teardown,
19762 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19763 : : TEST_CASE_ST(ut_setup, ut_teardown,
19764 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19765 : : TEST_CASE_ST(ut_setup, ut_teardown,
19766 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19767 : :
19768 : : /** AUTH ZUC + CIPHER SNOW3G */
19769 : : TEST_CASE_ST(ut_setup, ut_teardown,
19770 : : test_auth_zuc_cipher_snow_test_case_1),
19771 : : TEST_CASE_ST(ut_setup, ut_teardown,
19772 : : test_verify_auth_zuc_cipher_snow_test_case_1),
19773 : : TEST_CASE_ST(ut_setup, ut_teardown,
19774 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
19775 : : TEST_CASE_ST(ut_setup, ut_teardown,
19776 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19777 : : /** AUTH AES CMAC + CIPHER SNOW3G */
19778 : : TEST_CASE_ST(ut_setup, ut_teardown,
19779 : : test_auth_aes_cmac_cipher_snow_test_case_1),
19780 : : TEST_CASE_ST(ut_setup, ut_teardown,
19781 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19782 : : TEST_CASE_ST(ut_setup, ut_teardown,
19783 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19784 : : TEST_CASE_ST(ut_setup, ut_teardown,
19785 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19786 : : /** AUTH ZUC + CIPHER AES CTR */
19787 : : TEST_CASE_ST(ut_setup, ut_teardown,
19788 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
19789 : : TEST_CASE_ST(ut_setup, ut_teardown,
19790 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19791 : : TEST_CASE_ST(ut_setup, ut_teardown,
19792 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19793 : : TEST_CASE_ST(ut_setup, ut_teardown,
19794 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19795 : : /** AUTH SNOW3G + CIPHER AES CTR */
19796 : : TEST_CASE_ST(ut_setup, ut_teardown,
19797 : : test_auth_snow_cipher_aes_ctr_test_case_1),
19798 : : TEST_CASE_ST(ut_setup, ut_teardown,
19799 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19800 : : TEST_CASE_ST(ut_setup, ut_teardown,
19801 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19802 : : TEST_CASE_ST(ut_setup, ut_teardown,
19803 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19804 : : TEST_CASE_ST(ut_setup, ut_teardown,
19805 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19806 : : TEST_CASE_ST(ut_setup, ut_teardown,
19807 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19808 : : /** AUTH SNOW3G + CIPHER ZUC */
19809 : : TEST_CASE_ST(ut_setup, ut_teardown,
19810 : : test_auth_snow_cipher_zuc_test_case_1),
19811 : : TEST_CASE_ST(ut_setup, ut_teardown,
19812 : : test_verify_auth_snow_cipher_zuc_test_case_1),
19813 : : TEST_CASE_ST(ut_setup, ut_teardown,
19814 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
19815 : : TEST_CASE_ST(ut_setup, ut_teardown,
19816 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19817 : : /** AUTH AES CMAC + CIPHER ZUC */
19818 : : TEST_CASE_ST(ut_setup, ut_teardown,
19819 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
19820 : : TEST_CASE_ST(ut_setup, ut_teardown,
19821 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19822 : : TEST_CASE_ST(ut_setup, ut_teardown,
19823 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19824 : : TEST_CASE_ST(ut_setup, ut_teardown,
19825 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19826 : :
19827 : : /** AUTH NULL + CIPHER SNOW3G */
19828 : : TEST_CASE_ST(ut_setup, ut_teardown,
19829 : : test_auth_null_cipher_snow_test_case_1),
19830 : : TEST_CASE_ST(ut_setup, ut_teardown,
19831 : : test_verify_auth_null_cipher_snow_test_case_1),
19832 : : /** AUTH NULL + CIPHER ZUC */
19833 : : TEST_CASE_ST(ut_setup, ut_teardown,
19834 : : test_auth_null_cipher_zuc_test_case_1),
19835 : : TEST_CASE_ST(ut_setup, ut_teardown,
19836 : : test_verify_auth_null_cipher_zuc_test_case_1),
19837 : : /** AUTH SNOW3G + CIPHER NULL */
19838 : : TEST_CASE_ST(ut_setup, ut_teardown,
19839 : : test_auth_snow_cipher_null_test_case_1),
19840 : : TEST_CASE_ST(ut_setup, ut_teardown,
19841 : : test_verify_auth_snow_cipher_null_test_case_1),
19842 : : /** AUTH ZUC + CIPHER NULL */
19843 : : TEST_CASE_ST(ut_setup, ut_teardown,
19844 : : test_auth_zuc_cipher_null_test_case_1),
19845 : : TEST_CASE_ST(ut_setup, ut_teardown,
19846 : : test_verify_auth_zuc_cipher_null_test_case_1),
19847 : : /** AUTH NULL + CIPHER AES CTR */
19848 : : TEST_CASE_ST(ut_setup, ut_teardown,
19849 : : test_auth_null_cipher_aes_ctr_test_case_1),
19850 : : TEST_CASE_ST(ut_setup, ut_teardown,
19851 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
19852 : : /** AUTH AES CMAC + CIPHER NULL */
19853 : : TEST_CASE_ST(ut_setup, ut_teardown,
19854 : : test_auth_aes_cmac_cipher_null_test_case_1),
19855 : : TEST_CASE_ST(ut_setup, ut_teardown,
19856 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
19857 : : TEST_CASES_END()
19858 : : }
19859 : : };
19860 : :
19861 : : static struct unit_test_suite cryptodev_sm4_gcm_testsuite = {
19862 : : .suite_name = "SM4 GCM Test Suite",
19863 : : .setup = sm4_gcm_testsuite_setup,
19864 : : .unit_test_cases = {
19865 : : TEST_CASE_ST(ut_setup, ut_teardown,
19866 : : test_SM4_GCM_case_1),
19867 : : TEST_CASE_ST(ut_setup, ut_teardown,
19868 : : test_SM4_GCM_case_2),
19869 : : TEST_CASE_ST(ut_setup, ut_teardown,
19870 : : test_SM4_GCM_case_3),
19871 : : TEST_CASE_ST(ut_setup, ut_teardown,
19872 : : test_SM4_GCM_case_4),
19873 : : TEST_CASE_ST(ut_setup, ut_teardown,
19874 : : test_SM4_GCM_case_5),
19875 : : TEST_CASE_ST(ut_setup, ut_teardown,
19876 : : test_SM4_GCM_case_6),
19877 : : TEST_CASE_ST(ut_setup, ut_teardown,
19878 : : test_SM4_GCM_case_7),
19879 : : TEST_CASE_ST(ut_setup, ut_teardown,
19880 : : test_SM4_GCM_case_8),
19881 : : TEST_CASE_ST(ut_setup, ut_teardown,
19882 : : test_SM4_GCM_case_9),
19883 : : TEST_CASE_ST(ut_setup, ut_teardown,
19884 : : test_SM4_GCM_case_10),
19885 : : TEST_CASE_ST(ut_setup, ut_teardown,
19886 : : test_SM4_GCM_case_11),
19887 : : TEST_CASE_ST(ut_setup, ut_teardown,
19888 : : test_SM4_GCM_case_12),
19889 : : TEST_CASE_ST(ut_setup, ut_teardown,
19890 : : test_SM4_GCM_case_13),
19891 : : TEST_CASE_ST(ut_setup, ut_teardown,
19892 : : test_SM4_GCM_case_14),
19893 : : TEST_CASE_ST(ut_setup, ut_teardown,
19894 : : test_SM4_GCM_case_15),
19895 : : TEST_CASES_END()
19896 : : }
19897 : : };
19898 : :
19899 : : static int
19900 : 9 : nxan_testsuite_setup(enum rte_crypto_sym_xform_type xform_type)
19901 : : {
19902 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
19903 : 9 : uint8_t dev_id = ts_params->valid_devs[0];
19904 : : struct rte_cryptodev_info dev_info;
19905 : 9 : const enum rte_crypto_cipher_algorithm ciphers[] = {
19906 : : RTE_CRYPTO_CIPHER_SNOW5G_NEA4,
19907 : : RTE_CRYPTO_CIPHER_AES_NEA5,
19908 : : RTE_CRYPTO_CIPHER_ZUC_NEA6
19909 : : };
19910 : 9 : const enum rte_crypto_auth_algorithm auths[] = {
19911 : : RTE_CRYPTO_AUTH_SNOW5G_NIA4,
19912 : : RTE_CRYPTO_AUTH_AES_NIA5,
19913 : : RTE_CRYPTO_AUTH_ZUC_NIA6
19914 : : };
19915 : 9 : const enum rte_crypto_aead_algorithm aeads[] = {
19916 : : RTE_CRYPTO_AEAD_SNOW5G_NCA4,
19917 : : RTE_CRYPTO_AEAD_AES_NCA5,
19918 : : RTE_CRYPTO_AEAD_ZUC_NCA6
19919 : : };
19920 : :
19921 : 9 : rte_cryptodev_info_get(dev_id, &dev_info);
19922 : :
19923 [ + - ]: 9 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
19924 [ - + ]: 9 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
19925 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
19926 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NxA4/5/6 "
19927 : : "testsuite not met\n");
19928 : 0 : return TEST_SKIPPED;
19929 : : }
19930 : :
19931 [ + + - + ]: 12 : if ((xform_type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
19932 [ + + ]: 6 : check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) ||
19933 [ - + ]: 3 : (xform_type == RTE_CRYPTO_SYM_XFORM_AUTH &&
19934 [ + - ]: 3 : check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) ||
19935 [ + - ]: 3 : (xform_type == RTE_CRYPTO_SYM_XFORM_AEAD &&
19936 : : check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0)) {
19937 : 9 : RTE_LOG(INFO, USER1, "Capability requirements for NxA4/5/6 "
19938 : : "testsuite not met\n");
19939 : 9 : return TEST_SKIPPED;
19940 : : }
19941 : :
19942 : : return 0;
19943 : : }
19944 : :
19945 : : static int
19946 : 3 : nea_testsuite_setup(void)
19947 : : {
19948 : 3 : return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_CIPHER);
19949 : : }
19950 : :
19951 : : static int
19952 : 3 : nia_testsuite_setup(void)
19953 : : {
19954 : 3 : return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_AUTH);
19955 : : }
19956 : :
19957 : : static int
19958 : 3 : nca_testsuite_setup(void)
19959 : : {
19960 : 3 : return nxan_testsuite_setup(RTE_CRYPTO_SYM_XFORM_AEAD);
19961 : : }
19962 : :
19963 : : static int
19964 : 0 : test_NEA_helper(
19965 : : const struct nxa_256_test_data *tdata,
19966 : : enum rte_crypto_cipher_operation op)
19967 : : {
19968 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
19969 : : struct crypto_unittest_params *ut_params = &unittest_params;
19970 : :
19971 : : int retval;
19972 : : uint8_t *input, *output;
19973 : : uint32_t pad_len;
19974 : : uint32_t len;
19975 : : bool is_enc = (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT);
19976 : :
19977 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
19978 : : return TEST_SKIPPED;
19979 : :
19980 : : /* Create session */
19981 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
19982 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
19983 : 0 : tdata->cipher_algo, tdata->key, 32, 16);
19984 [ # # ]: 0 : if (retval != 0)
19985 : : return retval;
19986 : :
19987 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
19988 : :
19989 : : /* Clear mbuf payload */
19990 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
19991 : : rte_pktmbuf_tailroom(ut_params->ibuf));
19992 : :
19993 [ # # ]: 0 : len = ceil_byte_length(tdata->msg_size);
19994 : : /* Append data which is padded to a multiple */
19995 : : /* of the algorithms block size */
19996 : 0 : pad_len = RTE_ALIGN_CEIL(len, 8);
19997 : 0 : input = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
19998 : : pad_len);
19999 [ # # ]: 0 : memcpy(input, is_enc ? tdata->plaintext : tdata->ciphertext, len);
20000 : 0 : debug_hexdump(stdout, "input:", input, len);
20001 : :
20002 : : /* Create operation */
20003 : 0 : retval = create_wireless_algo_cipher_operation(tdata->iv,
20004 : 0 : 16, RTE_ALIGN_CEIL(tdata->msg_size, 8), 0);
20005 [ # # ]: 0 : if (retval != 0)
20006 : : return retval;
20007 : :
20008 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
20009 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
20010 : : 16);
20011 [ # # ]: 0 : if (retval != TEST_SUCCESS)
20012 : : return retval;
20013 : : } else
20014 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
20015 : : ut_params->op);
20016 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
20017 : :
20018 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
20019 [ # # ]: 0 : if (ut_params->obuf)
20020 : 0 : output = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
20021 : : else
20022 : : output = input;
20023 : :
20024 : 0 : debug_hexdump(stdout, "output:", output, len);
20025 : : const uint8_t *reference_output =
20026 [ # # ]: 0 : is_enc ? tdata->ciphertext : tdata->plaintext;
20027 : : /* Validate obuf */
20028 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
20029 : : output,
20030 : : reference_output,
20031 : : tdata->msg_size,
20032 : : "Output data not as expected");
20033 : : return 0;
20034 : : }
20035 : :
20036 : : static int
20037 : 0 : test_NIA_helper(const void *td)
20038 : : {
20039 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
20040 : : struct crypto_unittest_params *ut_params = &unittest_params;
20041 : : const struct nxa_256_test_data *tdata = td;
20042 : :
20043 : : int retval;
20044 : : uint32_t plaintext_pad_len;
20045 : : uint32_t plaintext_len;
20046 : : uint8_t *plaintext;
20047 : :
20048 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
20049 : : return TEST_SKIPPED;
20050 : :
20051 : : /* Create auth session */
20052 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
20053 : 0 : tdata->key, 32,
20054 : 0 : 16, tdata->tag_size >> 3,
20055 : : RTE_CRYPTO_AUTH_OP_VERIFY,
20056 : 0 : tdata->auth_algo);
20057 [ # # ]: 0 : if (retval != 0)
20058 : : return retval;
20059 : : /* alloc mbuf and set payload */
20060 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
20061 : :
20062 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
20063 : : rte_pktmbuf_tailroom(ut_params->ibuf));
20064 : :
20065 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->msg_size);
20066 : : /* Append data which is padded to a multiple */
20067 : : /* of the algorithms block size */
20068 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
20069 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
20070 : : plaintext_pad_len);
20071 : 0 : memcpy(plaintext, tdata->plaintext, plaintext_len);
20072 : :
20073 : : /* Create auth operation */
20074 : 0 : retval = create_wireless_algo_hash_operation(tdata->tag,
20075 : 0 : tdata->tag_size >> 3,
20076 : 0 : tdata->iv, 16,
20077 : : plaintext_pad_len,
20078 : : RTE_CRYPTO_AUTH_OP_VERIFY,
20079 : 0 : tdata->msg_size,
20080 : : 0);
20081 [ # # ]: 0 : if (retval != 0)
20082 : : return retval;
20083 : :
20084 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
20085 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
20086 : : 0);
20087 [ # # ]: 0 : if (retval != TEST_SUCCESS)
20088 : : return retval;
20089 : : } else
20090 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
20091 : : ut_params->op);
20092 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "Crypto request failed");
20093 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
20094 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
20095 : : uint8_t *,
20096 : : plaintext_pad_len);
20097 : :
20098 : : /* Validate obuf */
20099 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
20100 : : return 0;
20101 : : else
20102 : 0 : return -1;
20103 : :
20104 : : return 0;
20105 : : }
20106 : :
20107 : : static int
20108 : 0 : test_NCA_helper(
20109 : : const struct nxa_256_test_data *tdata,
20110 : : enum rte_crypto_cipher_operation op)
20111 : : {
20112 : 0 : struct aead_test_data aead_tdata = {
20113 : 0 : .algo = tdata->aead_algo,
20114 : : .key = {
20115 : : .len = 32,
20116 : : },
20117 : : .iv = {
20118 : : .len = 16,
20119 : : },
20120 : : .aad = {
20121 : 0 : .data = (uint8_t *)(uintptr_t)tdata->aad,
20122 : 0 : .len = tdata->aad_size >> 3,
20123 : : },
20124 : : .plaintext = {
20125 : 0 : .len = tdata->msg_size >> 3,
20126 : : },
20127 : : .ciphertext = {
20128 : : .len = tdata->msg_size >> 3,
20129 : : },
20130 : : .auth_tag = {
20131 : 0 : .len = tdata->tag_size >> 3,
20132 : : },
20133 : : };
20134 : :
20135 [ # # ]: 0 : memcpy(aead_tdata.key.data, tdata->key, 32);
20136 : : memcpy(aead_tdata.iv.data, tdata->iv, 16);
20137 : 0 : memcpy(aead_tdata.plaintext.data, tdata->plaintext,
20138 : : tdata->msg_size >> 3);
20139 : 0 : memcpy(aead_tdata.ciphertext.data, tdata->ciphertext,
20140 : : tdata->msg_size >> 3);
20141 : 0 : memcpy(aead_tdata.auth_tag.data, tdata->tag,
20142 : : tdata->tag_size >> 3);
20143 : :
20144 [ # # ]: 0 : if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
20145 : 0 : return test_authenticated_encryption_helper(&aead_tdata, false);
20146 : : else
20147 : 0 : return test_authenticated_decryption_helper(&aead_tdata, false);
20148 : : }
20149 : :
20150 : :
20151 : 0 : static int test_case_NEA_encrypt(const void *tdata)
20152 : : {
20153 : 0 : return test_NEA_helper(tdata, RTE_CRYPTO_CIPHER_OP_ENCRYPT);
20154 : : }
20155 : :
20156 : 0 : static int test_case_NEA_decrypt(const void *tdata)
20157 : : {
20158 : 0 : return test_NEA_helper(tdata, RTE_CRYPTO_CIPHER_OP_DECRYPT);
20159 : : }
20160 : :
20161 : : static struct unit_test_suite cryptodev_256_NEA4_testsuite = {
20162 : : .suite_name = "256 NEA4 (SNOW 5G) Test Suite",
20163 : : .setup = nea_testsuite_setup,
20164 : : .unit_test_cases = {
20165 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20166 : : test_case_NEA_encrypt, &nea4_test_1),
20167 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20168 : : test_case_NEA_decrypt, &nea4_test_1),
20169 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20170 : : test_case_NEA_encrypt, &nea4_test_2),
20171 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20172 : : test_case_NEA_decrypt, &nea4_test_2),
20173 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20174 : : test_case_NEA_encrypt, &nea4_test_3),
20175 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20176 : : test_case_NEA_decrypt, &nea4_test_3),
20177 : :
20178 : : TEST_CASES_END()
20179 : : }
20180 : : };
20181 : :
20182 : : static struct unit_test_suite cryptodev_256_NEA5_testsuite = {
20183 : : .suite_name = "256 NEA5 (AES 256) Test Suite",
20184 : : .setup = nea_testsuite_setup,
20185 : : .unit_test_cases = {
20186 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20187 : : test_case_NEA_encrypt, &nea5_test_1),
20188 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20189 : : test_case_NEA_decrypt, &nea5_test_1),
20190 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20191 : : test_case_NEA_encrypt, &nea5_test_2),
20192 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20193 : : test_case_NEA_decrypt, &nea5_test_2),
20194 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20195 : : test_case_NEA_encrypt, &nea5_test_3),
20196 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20197 : : test_case_NEA_decrypt, &nea5_test_3),
20198 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20199 : : test_case_NEA_encrypt, &nea5_test_4),
20200 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20201 : : test_case_NEA_decrypt, &nea5_test_4),
20202 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20203 : : test_case_NEA_encrypt, &nea5_test_5),
20204 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20205 : : test_case_NEA_decrypt, &nea5_test_5),
20206 : :
20207 : : TEST_CASES_END()
20208 : : }
20209 : : };
20210 : :
20211 : : static struct unit_test_suite cryptodev_256_NEA6_testsuite = {
20212 : : .suite_name = "256 NEA6 (ZUC 256) Test Suite",
20213 : : .setup = nea_testsuite_setup,
20214 : : .unit_test_cases = {
20215 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20216 : : test_case_NEA_encrypt, &nea6_test_1),
20217 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20218 : : test_case_NEA_decrypt, &nea6_test_1),
20219 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20220 : : test_case_NEA_encrypt, &nea6_test_2),
20221 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20222 : : test_case_NEA_decrypt, &nea6_test_2),
20223 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20224 : : test_case_NEA_encrypt, &nea6_test_3),
20225 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20226 : : test_case_NEA_decrypt, &nea6_test_3),
20227 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20228 : : test_case_NEA_encrypt, &nea6_test_4),
20229 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20230 : : test_case_NEA_decrypt, &nea6_test_4),
20231 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20232 : : test_case_NEA_encrypt, &nea6_test_5),
20233 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20234 : : test_case_NEA_decrypt, &nea6_test_5),
20235 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20236 : : test_case_NEA_encrypt, &nea6_test_6),
20237 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20238 : : test_case_NEA_decrypt, &nea6_test_6),
20239 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20240 : : test_case_NEA_encrypt, &nea6_test_7),
20241 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20242 : : test_case_NEA_decrypt, &nea6_test_7),
20243 : :
20244 : : TEST_CASES_END()
20245 : : }
20246 : : };
20247 : :
20248 : :
20249 : : static struct unit_test_suite cryptodev_256_NIA4_testsuite = {
20250 : : .suite_name = "256 NIA4 (SNOW 5G) Test Suite",
20251 : : .setup = nia_testsuite_setup,
20252 : : .unit_test_cases = {
20253 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20254 : : test_NIA_helper, &nia4_test_1),
20255 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20256 : : test_NIA_helper, &nia4_test_2),
20257 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20258 : : test_NIA_helper, &nia4_test_3),
20259 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20260 : : test_NIA_helper, &nia4_test_4),
20261 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20262 : : test_NIA_helper, &nia4_test_5),
20263 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20264 : : test_NIA_helper, &nia4_test_6),
20265 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20266 : : test_NIA_helper, &nia4_test_7),
20267 : :
20268 : : TEST_CASES_END()
20269 : : }
20270 : : };
20271 : :
20272 : : static struct unit_test_suite cryptodev_256_NIA5_testsuite = {
20273 : : .suite_name = "256 NIA5 (AES 256) Test Suite",
20274 : : .setup = nia_testsuite_setup,
20275 : : .unit_test_cases = {
20276 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20277 : : test_NIA_helper, &nia5_test_1),
20278 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20279 : : test_NIA_helper, &nia5_test_2),
20280 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20281 : : test_NIA_helper, &nia5_test_3),
20282 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20283 : : test_NIA_helper, &nia5_test_4),
20284 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20285 : : test_NIA_helper, &nia5_test_5),
20286 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20287 : : test_NIA_helper, &nia5_test_6),
20288 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20289 : : test_NIA_helper, &nia5_test_7),
20290 : :
20291 : : TEST_CASES_END()
20292 : : }
20293 : : };
20294 : :
20295 : : static struct unit_test_suite cryptodev_256_NIA6_testsuite = {
20296 : : .suite_name = "256 NIA6 (ZUC 256) Test Suite",
20297 : : .setup = nia_testsuite_setup,
20298 : : .unit_test_cases = {
20299 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20300 : : test_NIA_helper, &nia6_test_1),
20301 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20302 : : test_NIA_helper, &nia6_test_2),
20303 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20304 : : test_NIA_helper, &nia6_test_3),
20305 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20306 : : test_NIA_helper, &nia6_test_4),
20307 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20308 : : test_NIA_helper, &nia6_test_5),
20309 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20310 : : test_NIA_helper, &nia6_test_6),
20311 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20312 : : test_NIA_helper, &nia6_test_7),
20313 : :
20314 : : TEST_CASES_END()
20315 : : }
20316 : : };
20317 : :
20318 : :
20319 : 0 : static int test_case_NCA_encrypt(const void *tdata)
20320 : : {
20321 : 0 : return test_NCA_helper(tdata, RTE_CRYPTO_CIPHER_OP_ENCRYPT);
20322 : : }
20323 : :
20324 : 0 : static int test_case_NCA_decrypt(const void *tdata)
20325 : : {
20326 : 0 : return test_NCA_helper(tdata, RTE_CRYPTO_CIPHER_OP_DECRYPT);
20327 : : }
20328 : :
20329 : : static struct unit_test_suite cryptodev_256_NCA4_testsuite = {
20330 : : .suite_name = "256 NCA4 (SNOW 5G) Test Suite",
20331 : : .setup = nca_testsuite_setup,
20332 : : .unit_test_cases = {
20333 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20334 : : test_case_NCA_encrypt, &nca4_test_1),
20335 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20336 : : test_case_NCA_decrypt, &nca4_test_1),
20337 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20338 : : test_case_NCA_encrypt, &nca4_test_2),
20339 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20340 : : test_case_NCA_decrypt, &nca4_test_2),
20341 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20342 : : test_case_NCA_encrypt, &nca4_test_3),
20343 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20344 : : test_case_NCA_decrypt, &nca4_test_3),
20345 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20346 : : test_case_NCA_encrypt, &nca4_test_4),
20347 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20348 : : test_case_NCA_decrypt, &nca4_test_4),
20349 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20350 : : test_case_NCA_encrypt, &nca4_test_5),
20351 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20352 : : test_case_NCA_decrypt, &nca4_test_5),
20353 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20354 : : test_case_NCA_encrypt, &nca4_test_6),
20355 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20356 : : test_case_NCA_decrypt, &nca4_test_6),
20357 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20358 : : test_case_NCA_encrypt, &nca4_test_7),
20359 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20360 : : test_case_NCA_decrypt, &nca4_test_7),
20361 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20362 : : test_case_NCA_encrypt, &nca4_test_8),
20363 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20364 : : test_case_NCA_decrypt, &nca4_test_8),
20365 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20366 : : test_case_NCA_encrypt, &nca4_test_9),
20367 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20368 : : test_case_NCA_decrypt, &nca4_test_9),
20369 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20370 : : test_case_NCA_encrypt, &nca4_test_10),
20371 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20372 : : test_case_NCA_decrypt, &nca4_test_10),
20373 : :
20374 : : TEST_CASES_END()
20375 : : }
20376 : : };
20377 : :
20378 : : static struct unit_test_suite cryptodev_256_NCA5_testsuite = {
20379 : : .suite_name = "256 NCA5 (AES 256) Test Suite",
20380 : : .setup = nca_testsuite_setup,
20381 : : .unit_test_cases = {
20382 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20383 : : test_case_NCA_encrypt, &nca5_test_1),
20384 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20385 : : test_case_NCA_decrypt, &nca5_test_1),
20386 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20387 : : test_case_NCA_encrypt, &nca5_test_2),
20388 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20389 : : test_case_NCA_decrypt, &nca5_test_2),
20390 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20391 : : test_case_NCA_encrypt, &nca5_test_3),
20392 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20393 : : test_case_NCA_decrypt, &nca5_test_3),
20394 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20395 : : test_case_NCA_encrypt, &nca5_test_4),
20396 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20397 : : test_case_NCA_decrypt, &nca5_test_4),
20398 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20399 : : test_case_NCA_encrypt, &nca5_test_5),
20400 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20401 : : test_case_NCA_decrypt, &nca5_test_5),
20402 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20403 : : test_case_NCA_encrypt, &nca5_test_6),
20404 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20405 : : test_case_NCA_decrypt, &nca5_test_6),
20406 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20407 : : test_case_NCA_encrypt, &nca5_test_7),
20408 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20409 : : test_case_NCA_decrypt, &nca5_test_7),
20410 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20411 : : test_case_NCA_encrypt, &nca5_test_8),
20412 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20413 : : test_case_NCA_decrypt, &nca5_test_8),
20414 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20415 : : test_case_NCA_encrypt, &nca5_test_9),
20416 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20417 : : test_case_NCA_decrypt, &nca5_test_9),
20418 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20419 : : test_case_NCA_encrypt, &nca5_test_10),
20420 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20421 : : test_case_NCA_decrypt, &nca5_test_10),
20422 : :
20423 : : TEST_CASES_END()
20424 : : }
20425 : : };
20426 : :
20427 : : static struct unit_test_suite cryptodev_256_NCA6_testsuite = {
20428 : : .suite_name = "256 NCA6 (ZUC 256) Test Suite",
20429 : : .setup = nca_testsuite_setup,
20430 : : .unit_test_cases = {
20431 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20432 : : test_case_NCA_encrypt, &nca6_test_1),
20433 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20434 : : test_case_NCA_decrypt, &nca6_test_1),
20435 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20436 : : test_case_NCA_encrypt, &nca6_test_2),
20437 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20438 : : test_case_NCA_decrypt, &nca6_test_2),
20439 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20440 : : test_case_NCA_encrypt, &nca6_test_3),
20441 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20442 : : test_case_NCA_decrypt, &nca6_test_3),
20443 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20444 : : test_case_NCA_encrypt, &nca6_test_4),
20445 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20446 : : test_case_NCA_decrypt, &nca6_test_4),
20447 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20448 : : test_case_NCA_encrypt, &nca6_test_5),
20449 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20450 : : test_case_NCA_decrypt, &nca6_test_5),
20451 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20452 : : test_case_NCA_encrypt, &nca6_test_6),
20453 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20454 : : test_case_NCA_decrypt, &nca6_test_6),
20455 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20456 : : test_case_NCA_encrypt, &nca6_test_7),
20457 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20458 : : test_case_NCA_decrypt, &nca6_test_7),
20459 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20460 : : test_case_NCA_encrypt, &nca6_test_8),
20461 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20462 : : test_case_NCA_decrypt, &nca6_test_8),
20463 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20464 : : test_case_NCA_encrypt, &nca6_test_9),
20465 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20466 : : test_case_NCA_decrypt, &nca6_test_9),
20467 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20468 : : test_case_NCA_encrypt, &nca6_test_10),
20469 : : TEST_CASE_WITH_DATA(ut_setup, ut_teardown,
20470 : : test_case_NCA_decrypt, &nca6_test_10),
20471 : :
20472 : : TEST_CASES_END()
20473 : : }
20474 : : };
20475 : :
20476 : : static int
20477 : 1 : run_cryptodev_testsuite(const char *pmd_name)
20478 : : {
20479 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
20480 : 1 : const enum blockcipher_test_type blk_suites[] = {
20481 : : BLKCIPHER_AES_CHAIN_TYPE,
20482 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
20483 : : BLKCIPHER_AES_DOCSIS_TYPE,
20484 : : BLKCIPHER_3DES_CHAIN_TYPE,
20485 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
20486 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
20487 : : BLKCIPHER_DES_DOCSIS_TYPE,
20488 : : BLKCIPHER_SM4_CHAIN_TYPE,
20489 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
20490 : : BLKCIPHER_AUTHONLY_TYPE};
20491 : 1 : struct unit_test_suite *static_suites[] = {
20492 : : &cryptodev_multi_session_testsuite,
20493 : : &cryptodev_null_testsuite,
20494 : : &cryptodev_aes_ccm_auth_testsuite,
20495 : : &cryptodev_aes_gcm_auth_testsuite,
20496 : : &cryptodev_aes_gmac_auth_testsuite,
20497 : : &cryptodev_snow3g_testsuite,
20498 : : &cryptodev_chacha20_poly1305_testsuite,
20499 : : &cryptodev_zuc_testsuite,
20500 : : &cryptodev_hmac_md5_auth_testsuite,
20501 : : &cryptodev_kasumi_testsuite,
20502 : : &cryptodev_esn_testsuite,
20503 : : &cryptodev_negative_aes_gcm_testsuite,
20504 : : &cryptodev_negative_aes_gmac_testsuite,
20505 : : &cryptodev_mixed_cipher_hash_testsuite,
20506 : : &cryptodev_negative_hmac_sha1_testsuite,
20507 : : &cryptodev_gen_testsuite,
20508 : : &cryptodev_sm4_gcm_testsuite,
20509 : : &cryptodev_256_NEA4_testsuite,
20510 : : &cryptodev_256_NEA5_testsuite,
20511 : : &cryptodev_256_NEA6_testsuite,
20512 : : &cryptodev_256_NIA4_testsuite,
20513 : : &cryptodev_256_NIA5_testsuite,
20514 : : &cryptodev_256_NIA6_testsuite,
20515 : : &cryptodev_256_NCA4_testsuite,
20516 : : &cryptodev_256_NCA5_testsuite,
20517 : : &cryptodev_256_NCA6_testsuite,
20518 : : #ifdef RTE_LIB_SECURITY
20519 : : &ipsec_proto_testsuite,
20520 : : &pdcp_proto_testsuite,
20521 : : &docsis_proto_testsuite,
20522 : : &tls12_record_proto_testsuite,
20523 : : &dtls12_record_proto_testsuite,
20524 : : &tls13_record_proto_testsuite,
20525 : : #endif
20526 : : &end_testsuite
20527 : : };
20528 : : static struct unit_test_suite ts = {
20529 : : .suite_name = "Cryptodev Unit Test Suite",
20530 : : .setup = testsuite_setup,
20531 : : .teardown = testsuite_teardown,
20532 : : .unit_test_cases = {TEST_CASES_END()}
20533 : : };
20534 : :
20535 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
20536 : :
20537 [ - + ]: 1 : if (gbl_driver_id == -1) {
20538 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
20539 : 0 : return TEST_SKIPPED;
20540 : : }
20541 : :
20542 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
20543 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
20544 : :
20545 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
20546 [ + + ]: 34 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
20547 : 1 : ret = unit_test_suite_runner(&ts);
20548 : :
20549 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
20550 : 1 : free(ts.unit_test_suites);
20551 : 1 : return ret;
20552 : : }
20553 : :
20554 : : static int
20555 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
20556 : : {
20557 : : struct rte_cryptodev_info dev_info;
20558 : : uint8_t i, nb_devs;
20559 : : int driver_id;
20560 : :
20561 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
20562 [ # # ]: 0 : if (driver_id == -1) {
20563 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
20564 : 0 : return TEST_SKIPPED;
20565 : : }
20566 : :
20567 : 0 : nb_devs = rte_cryptodev_count();
20568 [ # # ]: 0 : if (nb_devs < 1) {
20569 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
20570 : 0 : return TEST_SKIPPED;
20571 : : }
20572 : :
20573 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
20574 : 0 : rte_cryptodev_info_get(i, &dev_info);
20575 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
20576 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
20577 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
20578 : : flag_name);
20579 : 0 : return TEST_SKIPPED;
20580 : : }
20581 : : return 0; /* found */
20582 : : }
20583 : : }
20584 : :
20585 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
20586 : 0 : return TEST_SKIPPED;
20587 : : }
20588 : :
20589 : : static int
20590 : 0 : test_cryptodev_qat(void)
20591 : : {
20592 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20593 : : }
20594 : :
20595 : : static int
20596 : 0 : test_cryptodev_uadk(void)
20597 : : {
20598 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
20599 : : }
20600 : :
20601 : : static int
20602 : 0 : test_cryptodev_virtio(void)
20603 : : {
20604 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
20605 : : }
20606 : :
20607 : : static int
20608 : 0 : test_cryptodev_virtio_user(void)
20609 : : {
20610 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_USER_PMD));
20611 : : }
20612 : :
20613 : : static int
20614 : 0 : test_cryptodev_aesni_mb(void)
20615 : : {
20616 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
20617 : : }
20618 : :
20619 : : static int
20620 : 0 : test_cryptodev_cpu_aesni_mb(void)
20621 : : {
20622 : : int32_t rc;
20623 : 0 : enum rte_security_session_action_type at = gbl_action_type;
20624 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
20625 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
20626 : 0 : gbl_action_type = at;
20627 : 0 : return rc;
20628 : : }
20629 : :
20630 : : static int
20631 : 1 : test_cryptodev_openssl(void)
20632 : : {
20633 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
20634 : : }
20635 : :
20636 : : static int
20637 : 0 : test_cryptodev_aesni_gcm(void)
20638 : : {
20639 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20640 : : }
20641 : :
20642 : : static int
20643 : 0 : test_cryptodev_cpu_aesni_gcm(void)
20644 : : {
20645 : : int32_t rc;
20646 : 0 : enum rte_security_session_action_type at = gbl_action_type;
20647 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
20648 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
20649 : 0 : gbl_action_type = at;
20650 : 0 : return rc;
20651 : : }
20652 : :
20653 : : static int
20654 : 0 : test_cryptodev_mlx5(void)
20655 : : {
20656 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
20657 : : }
20658 : :
20659 : : static int
20660 : 0 : test_cryptodev_null(void)
20661 : : {
20662 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
20663 : : }
20664 : :
20665 : : static int
20666 : 0 : test_cryptodev_sw_snow3g(void)
20667 : : {
20668 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
20669 : : }
20670 : :
20671 : : static int
20672 : 0 : test_cryptodev_sw_zuc(void)
20673 : : {
20674 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
20675 : : }
20676 : :
20677 : : static int
20678 : 0 : test_cryptodev_armv8(void)
20679 : : {
20680 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
20681 : : }
20682 : :
20683 : : static int
20684 : 0 : test_cryptodev_mrvl(void)
20685 : : {
20686 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
20687 : : }
20688 : :
20689 : : #ifdef RTE_CRYPTO_SCHEDULER
20690 : :
20691 : : static int
20692 : 0 : test_cryptodev_scheduler(void)
20693 : : {
20694 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
20695 : 0 : const enum blockcipher_test_type blk_suites[] = {
20696 : : BLKCIPHER_AES_CHAIN_TYPE,
20697 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
20698 : : BLKCIPHER_AUTHONLY_TYPE
20699 : : };
20700 : : static struct unit_test_suite scheduler_multicore = {
20701 : : .suite_name = "Scheduler Multicore Unit Test Suite",
20702 : : .setup = scheduler_multicore_testsuite_setup,
20703 : : .teardown = scheduler_mode_testsuite_teardown,
20704 : : .unit_test_cases = {TEST_CASES_END()}
20705 : : };
20706 : : static struct unit_test_suite scheduler_round_robin = {
20707 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
20708 : : .setup = scheduler_roundrobin_testsuite_setup,
20709 : : .teardown = scheduler_mode_testsuite_teardown,
20710 : : .unit_test_cases = {TEST_CASES_END()}
20711 : : };
20712 : : static struct unit_test_suite scheduler_failover = {
20713 : : .suite_name = "Scheduler Failover Unit Test Suite",
20714 : : .setup = scheduler_failover_testsuite_setup,
20715 : : .teardown = scheduler_mode_testsuite_teardown,
20716 : : .unit_test_cases = {TEST_CASES_END()}
20717 : : };
20718 : : static struct unit_test_suite scheduler_pkt_size_distr = {
20719 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
20720 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
20721 : : .teardown = scheduler_mode_testsuite_teardown,
20722 : : .unit_test_cases = {TEST_CASES_END()}
20723 : : };
20724 : 0 : struct unit_test_suite *sched_mode_suites[] = {
20725 : : &scheduler_multicore,
20726 : : &scheduler_round_robin,
20727 : : &scheduler_failover,
20728 : : &scheduler_pkt_size_distr
20729 : : };
20730 : : static struct unit_test_suite scheduler_config = {
20731 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
20732 : : .unit_test_cases = {
20733 : : TEST_CASE(test_scheduler_attach_worker_op),
20734 : : TEST_CASE(test_scheduler_mode_multicore_op),
20735 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
20736 : : TEST_CASE(test_scheduler_mode_failover_op),
20737 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
20738 : : TEST_CASE(test_scheduler_detach_worker_op),
20739 : :
20740 : : TEST_CASES_END() /**< NULL terminate array */
20741 : : }
20742 : : };
20743 : 0 : struct unit_test_suite *static_suites[] = {
20744 : : &scheduler_config,
20745 : : &end_testsuite
20746 : : };
20747 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
20748 : : #ifdef RTE_LIB_SECURITY
20749 : : &docsis_proto_testsuite,
20750 : : #endif
20751 : : &end_testsuite
20752 : : };
20753 : : static struct unit_test_suite ts = {
20754 : : .suite_name = "Scheduler Unit Test Suite",
20755 : : .setup = scheduler_testsuite_setup,
20756 : : .teardown = testsuite_teardown,
20757 : : .unit_test_cases = {TEST_CASES_END()}
20758 : : };
20759 : :
20760 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
20761 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
20762 : :
20763 [ # # ]: 0 : if (gbl_driver_id == -1) {
20764 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
20765 : 0 : return TEST_SKIPPED;
20766 : : }
20767 : :
20768 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
20769 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
20770 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
20771 : 0 : return TEST_SKIPPED;
20772 : : }
20773 : :
20774 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20775 : : uint8_t blk_i = 0;
20776 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
20777 : : (struct unit_test_suite *) *
20778 : : (RTE_DIM(blk_suites) +
20779 : : RTE_DIM(sched_mode_static_suites) + 1));
20780 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20781 : : blk_suites, RTE_DIM(blk_suites));
20782 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
20783 : : sched_mode_static_suites,
20784 : : RTE_DIM(sched_mode_static_suites));
20785 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
20786 : : }
20787 : :
20788 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
20789 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
20790 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
20791 : : RTE_DIM(sched_mode_suites));
20792 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
20793 : 0 : ret = unit_test_suite_runner(&ts);
20794 : :
20795 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
20796 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
20797 : : (*sched_mode_suites[sched_i]),
20798 : : RTE_DIM(blk_suites));
20799 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
20800 : : }
20801 : 0 : free(ts.unit_test_suites);
20802 : 0 : return ret;
20803 : : }
20804 : :
20805 : 301 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
20806 : :
20807 : : #endif
20808 : :
20809 : : static int
20810 : 0 : test_cryptodev_dpaa2_sec(void)
20811 : : {
20812 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20813 : : }
20814 : :
20815 : : static int
20816 : 0 : test_cryptodev_dpaa_sec(void)
20817 : : {
20818 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20819 : : }
20820 : :
20821 : : static int
20822 : 0 : test_cryptodev_ccp(void)
20823 : : {
20824 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
20825 : : }
20826 : :
20827 : : static int
20828 : 0 : test_cryptodev_octeontx(void)
20829 : : {
20830 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
20831 : : }
20832 : :
20833 : : static int
20834 : 0 : test_cryptodev_caam_jr(void)
20835 : : {
20836 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
20837 : : }
20838 : :
20839 : : static int
20840 : 0 : test_cryptodev_nitrox(void)
20841 : : {
20842 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
20843 : : }
20844 : :
20845 : : static int
20846 : 0 : test_cryptodev_bcmfs(void)
20847 : : {
20848 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
20849 : : }
20850 : :
20851 : : static int
20852 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
20853 : : {
20854 : : int ret;
20855 : :
20856 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
20857 [ # # ]: 0 : if (ret)
20858 : : return ret;
20859 : :
20860 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
20861 : 0 : ret = run_cryptodev_testsuite(pmd_name);
20862 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
20863 : :
20864 : 0 : return ret;
20865 : : }
20866 : :
20867 : : static int
20868 : 0 : test_cryptodev_qat_raw_api(void)
20869 : : {
20870 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20871 : : }
20872 : :
20873 : : static int
20874 : 0 : test_cryptodev_cn9k(void)
20875 : : {
20876 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
20877 : : }
20878 : :
20879 : : static int
20880 : 0 : test_cryptodev_cn10k(void)
20881 : : {
20882 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20883 : : }
20884 : :
20885 : : static int
20886 : 0 : test_cryptodev_cn10k_raw_api(void)
20887 : : {
20888 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20889 : : }
20890 : :
20891 : : static int
20892 : 0 : test_cryptodev_cn20k(void)
20893 : : {
20894 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN20K_PMD));
20895 : : }
20896 : :
20897 : : static int
20898 : 0 : test_cryptodev_cn20k_raw_api(void)
20899 : : {
20900 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN20K_PMD));
20901 : : }
20902 : :
20903 : : static int
20904 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
20905 : : {
20906 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20907 : : }
20908 : :
20909 : : static int
20910 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
20911 : : {
20912 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20913 : : }
20914 : :
20915 : : static int
20916 : 0 : test_cryptodev_zsda(void)
20917 : : {
20918 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZSDA_SYM_PMD));
20919 : : }
20920 : :
20921 : 301 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
20922 : : test_cryptodev_cn10k_raw_api);
20923 : 301 : REGISTER_DRIVER_TEST(cryptodev_cn20k_raw_api_autotest,
20924 : : test_cryptodev_cn20k_raw_api);
20925 : 301 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
20926 : : test_cryptodev_dpaa2_sec_raw_api);
20927 : 301 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
20928 : : test_cryptodev_dpaa_sec_raw_api);
20929 : 301 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
20930 : : test_cryptodev_qat_raw_api);
20931 : 301 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
20932 : 301 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
20933 : 301 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
20934 : : test_cryptodev_cpu_aesni_mb);
20935 : 301 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
20936 : 301 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
20937 : 301 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
20938 : : test_cryptodev_cpu_aesni_gcm);
20939 : 301 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
20940 : 301 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
20941 : 301 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
20942 : 301 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
20943 : 301 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
20944 : 301 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
20945 : 301 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
20946 : 301 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
20947 : 301 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
20948 : 301 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
20949 : 301 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
20950 : 301 : REGISTER_DRIVER_TEST(cryptodev_virtio_user_autotest, test_cryptodev_virtio_user);
20951 : 301 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
20952 : 301 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
20953 : 301 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
20954 : 301 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
20955 : 301 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
20956 : 301 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
20957 : 301 : REGISTER_DRIVER_TEST(cryptodev_cn20k_autotest, test_cryptodev_cn20k);
20958 : 301 : REGISTER_DRIVER_TEST(cryptodev_zsda_autotest, test_cryptodev_zsda);
|