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 <time.h>
7 : :
8 : : #include <rte_common.h>
9 : : #include <rte_hexdump.h>
10 : : #include <rte_mbuf.h>
11 : : #include <rte_malloc.h>
12 : : #include <rte_memcpy.h>
13 : : #include <rte_pause.h>
14 : : #include <rte_bus_vdev.h>
15 : : #include <rte_ether.h>
16 : : #include <rte_errno.h>
17 : :
18 : : #include <rte_crypto.h>
19 : : #include <rte_cryptodev.h>
20 : : #include <rte_ethdev.h>
21 : : #include <rte_ip.h>
22 : : #include <rte_string_fns.h>
23 : : #include <rte_tcp.h>
24 : : #include <rte_udp.h>
25 : :
26 : : #ifdef RTE_CRYPTO_SCHEDULER
27 : : #include <rte_cryptodev_scheduler.h>
28 : : #include <rte_cryptodev_scheduler_operations.h>
29 : : #endif
30 : :
31 : : #include <rte_lcore.h>
32 : :
33 : : #include "test.h"
34 : : #include "test_cryptodev.h"
35 : :
36 : : #include "test_cryptodev_blockcipher.h"
37 : : #include "test_cryptodev_aes_test_vectors.h"
38 : : #include "test_cryptodev_des_test_vectors.h"
39 : : #include "test_cryptodev_hash_test_vectors.h"
40 : : #include "test_cryptodev_kasumi_test_vectors.h"
41 : : #include "test_cryptodev_kasumi_hash_test_vectors.h"
42 : : #include "test_cryptodev_snow3g_test_vectors.h"
43 : : #include "test_cryptodev_snow3g_hash_test_vectors.h"
44 : : #include "test_cryptodev_zuc_test_vectors.h"
45 : : #include "test_cryptodev_aead_test_vectors.h"
46 : : #include "test_cryptodev_hmac_test_vectors.h"
47 : : #include "test_cryptodev_mixed_test_vectors.h"
48 : : #include "test_cryptodev_sm4_test_vectors.h"
49 : : #ifdef RTE_LIB_SECURITY
50 : : #include "test_cryptodev_security_ipsec.h"
51 : : #include "test_cryptodev_security_ipsec_test_vectors.h"
52 : : #include "test_cryptodev_security_pdcp_test_vectors.h"
53 : : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
54 : : #include "test_cryptodev_security_pdcp_test_func.h"
55 : : #include "test_cryptodev_security_docsis_test_vectors.h"
56 : : #include "test_cryptodev_security_tls_record.h"
57 : : #include "test_security_proto.h"
58 : :
59 : : #define SDAP_DISABLED 0
60 : : #define SDAP_ENABLED 1
61 : : #endif
62 : :
63 : : #define VDEV_ARGS_SIZE 100
64 : : #define MAX_NB_SESSIONS 4
65 : :
66 : : #define MAX_DRV_SERVICE_CTX_SIZE 256
67 : :
68 : : #define MAX_RAW_DEQUEUE_COUNT 65535
69 : :
70 : : #define IN_PLACE 0
71 : : #define OUT_OF_PLACE 1
72 : :
73 : : static int gbl_driver_id;
74 : :
75 : : static enum rte_security_session_action_type gbl_action_type =
76 : : RTE_SECURITY_ACTION_TYPE_NONE;
77 : :
78 : : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
79 : :
80 : : struct crypto_unittest_params {
81 : : struct rte_crypto_sym_xform cipher_xform;
82 : : struct rte_crypto_sym_xform auth_xform;
83 : : struct rte_crypto_sym_xform aead_xform;
84 : : #ifdef RTE_LIB_SECURITY
85 : : struct rte_security_docsis_xform docsis_xform;
86 : : #endif
87 : :
88 : : union {
89 : : void *sess;
90 : : #ifdef RTE_LIB_SECURITY
91 : : void *sec_session;
92 : : #endif
93 : : };
94 : : #ifdef RTE_LIB_SECURITY
95 : : enum rte_security_session_action_type type;
96 : : #endif
97 : : struct rte_crypto_op *op;
98 : :
99 : : struct rte_mbuf *obuf, *ibuf;
100 : :
101 : : uint8_t *digest;
102 : : };
103 : :
104 : : #define ALIGN_POW2_ROUNDUP(num, align) \
105 : : (((num) + (align) - 1) & ~((align) - 1))
106 : :
107 : : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
108 : : for (j = 0; j < num_child_ts; index++, j++) \
109 : : parent_ts.unit_test_suites[index] = child_ts[j]
110 : :
111 : : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
112 : : for (j = 0; j < num_blk_types; index++, j++) \
113 : : parent_ts.unit_test_suites[index] = \
114 : : build_blockcipher_test_suite(blk_types[j])
115 : :
116 : : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
117 : : for (j = index; j < index + num_blk_types; j++) \
118 : : free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
119 : :
120 : : /*
121 : : * Forward declarations.
122 : : */
123 : : static int
124 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
125 : : struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
126 : : uint8_t *hmac_key);
127 : :
128 : : static int
129 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
130 : : struct crypto_unittest_params *ut_params,
131 : : struct crypto_testsuite_params *ts_param,
132 : : const uint8_t *cipher,
133 : : const uint8_t *digest,
134 : : const uint8_t *iv);
135 : :
136 : : static int
137 : : security_proto_supported(enum rte_security_session_action_type action,
138 : : enum rte_security_session_protocol proto);
139 : :
140 : : static int
141 : : dev_configure_and_start(uint64_t ff_disable);
142 : :
143 : : static int
144 : : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
145 : : const enum rte_crypto_cipher_algorithm cipher_algo,
146 : : const uint16_t key_size, const uint16_t iv_size);
147 : :
148 : : static int
149 : : check_auth_capability(const struct crypto_testsuite_params *ts_params,
150 : : const enum rte_crypto_auth_algorithm auth_algo,
151 : : const uint16_t key_size, const uint16_t iv_size,
152 : : const uint16_t tag_size);
153 : :
154 : : static struct rte_mbuf *
155 : 7 : setup_test_string(struct rte_mempool *mpool,
156 : : const char *string, size_t len, uint8_t blocksize)
157 : : {
158 : 7 : struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
159 [ - + ]: 7 : size_t t_len = len - (blocksize ? (len % blocksize) : 0);
160 : :
161 [ + - ]: 7 : if (m) {
162 : : char *dst;
163 : :
164 : 7 : memset(m->buf_addr, 0, m->buf_len);
165 : 7 : dst = rte_pktmbuf_append(m, t_len);
166 [ - + ]: 7 : if (!dst) {
167 : 0 : rte_pktmbuf_free(m);
168 : 0 : return NULL;
169 : : }
170 [ + - ]: 7 : if (string != NULL)
171 : : rte_memcpy(dst, string, t_len);
172 : : else
173 : : memset(dst, 0, t_len);
174 : : }
175 : :
176 : : return m;
177 : : }
178 : :
179 : : /* Get number of bytes in X bits (rounding up) */
180 : : static uint32_t
181 : : ceil_byte_length(uint32_t num_bits)
182 : : {
183 : 4 : if (num_bits % 8)
184 : 0 : return ((num_bits >> 3) + 1);
185 : : else
186 : 4 : return (num_bits >> 3);
187 : : }
188 : :
189 : : static void
190 : 0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
191 : : uint8_t is_op_success)
192 : : {
193 : : struct rte_crypto_op *op = user_data;
194 [ # # ]: 0 : op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
195 : : RTE_CRYPTO_OP_STATUS_ERROR;
196 : 0 : }
197 : :
198 : : static struct crypto_testsuite_params testsuite_params = { NULL };
199 : : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
200 : : static struct crypto_unittest_params unittest_params;
201 : :
202 : : int
203 : 0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
204 : : struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
205 : : uint8_t len_in_bits, uint8_t cipher_iv_len)
206 : : {
207 : 0 : struct rte_crypto_sym_op *sop = op->sym;
208 : 0 : struct rte_crypto_op *ret_op = NULL;
209 : : struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
210 : : struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
211 : : union rte_crypto_sym_ofs ofs;
212 : : struct rte_crypto_sym_vec vec;
213 : : struct rte_crypto_sgl sgl, dest_sgl;
214 : : uint32_t max_len;
215 : : union rte_cryptodev_session_ctx sess;
216 : : uint64_t auth_end_iova;
217 : : uint32_t count = 0;
218 : : struct rte_crypto_raw_dp_ctx *ctx;
219 : : uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
220 : : auth_len = 0;
221 : : int32_t n;
222 : : uint32_t n_success;
223 : : int ctx_service_size;
224 : 0 : int32_t status = 0;
225 : : int enqueue_status, dequeue_status;
226 : : struct crypto_unittest_params *ut_params = &unittest_params;
227 : 0 : int is_sgl = sop->m_src->nb_segs > 1;
228 : : int ret = TEST_SUCCESS, is_oop = 0;
229 : :
230 : 0 : ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
231 [ # # ]: 0 : if (ctx_service_size < 0)
232 : : return TEST_SKIPPED;
233 : :
234 : 0 : ctx = malloc(ctx_service_size);
235 [ # # ]: 0 : if (ctx == NULL)
236 : : return TEST_FAILED;
237 : :
238 : : /* Both are enums, setting crypto_sess will suit any session type */
239 : 0 : sess.crypto_sess = op->sym->session;
240 : :
241 : 0 : ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
242 [ # # ]: 0 : if (ret == -ENOTSUP) {
243 : : ret = TEST_SKIPPED;
244 : 0 : goto exit;
245 [ # # ]: 0 : } else if (ret) {
246 : : ret = TEST_FAILED;
247 : 0 : goto exit;
248 : : }
249 : :
250 : 0 : cipher_iv.iova = 0;
251 : 0 : cipher_iv.va = NULL;
252 : 0 : aad_auth_iv.iova = 0;
253 : 0 : aad_auth_iv.va = NULL;
254 : 0 : digest.iova = 0;
255 : 0 : digest.va = NULL;
256 : 0 : sgl.vec = data_vec;
257 : 0 : vec.num = 1;
258 : 0 : vec.src_sgl = &sgl;
259 : 0 : vec.iv = &cipher_iv;
260 : 0 : vec.digest = &digest;
261 : 0 : vec.aad = &aad_auth_iv;
262 : 0 : vec.status = &status;
263 : :
264 : 0 : ofs.raw = 0;
265 : :
266 [ # # # # ]: 0 : if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
267 : : is_oop = 1;
268 : :
269 [ # # ]: 0 : if (is_cipher && is_auth) {
270 : 0 : cipher_offset = sop->cipher.data.offset;
271 : 0 : cipher_len = sop->cipher.data.length;
272 : 0 : auth_offset = sop->auth.data.offset;
273 : 0 : auth_len = sop->auth.data.length;
274 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len,
275 : : auth_offset + auth_len);
276 [ # # ]: 0 : if (len_in_bits) {
277 : 0 : max_len = max_len >> 3;
278 : 0 : cipher_offset = cipher_offset >> 3;
279 : 0 : auth_offset = auth_offset >> 3;
280 : 0 : cipher_len = cipher_len >> 3;
281 : 0 : auth_len = auth_len >> 3;
282 : : }
283 : 0 : ofs.ofs.cipher.head = cipher_offset;
284 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
285 : 0 : ofs.ofs.auth.head = auth_offset;
286 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
287 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
288 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
289 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
290 : : op, void *, IV_OFFSET + cipher_iv_len);
291 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
292 : : cipher_iv_len);
293 : 0 : digest.va = (void *)sop->auth.digest.data;
294 : 0 : digest.iova = sop->auth.digest.phys_addr;
295 : :
296 [ # # ]: 0 : if (is_sgl) {
297 : 0 : uint32_t remaining_off = auth_offset + auth_len;
298 : 0 : struct rte_mbuf *sgl_buf = sop->m_src;
299 [ # # ]: 0 : if (is_oop)
300 : : sgl_buf = sop->m_dst;
301 : :
302 : 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
303 [ # # # # ]: 0 : && sgl_buf->next != NULL) {
304 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
305 : : sgl_buf = sgl_buf->next;
306 : : }
307 : :
308 : 0 : auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
309 : : sgl_buf, remaining_off);
310 : : } else {
311 : 0 : auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
312 : 0 : auth_offset + auth_len;
313 : : }
314 : : /* Then check if digest-encrypted conditions are met */
315 [ # # # # ]: 0 : if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
316 [ # # ]: 0 : (digest.iova == auth_end_iova) && is_sgl)
317 : 0 : max_len = RTE_MAX(max_len,
318 : : auth_offset + auth_len +
319 : : ut_params->auth_xform.auth.digest_length);
320 : :
321 [ # # ]: 0 : } else if (is_cipher) {
322 : 0 : cipher_offset = sop->cipher.data.offset;
323 : 0 : cipher_len = sop->cipher.data.length;
324 : 0 : max_len = cipher_len + cipher_offset;
325 [ # # ]: 0 : if (len_in_bits) {
326 : 0 : max_len = max_len >> 3;
327 : 0 : cipher_offset = cipher_offset >> 3;
328 : 0 : cipher_len = cipher_len >> 3;
329 : : }
330 : 0 : ofs.ofs.cipher.head = cipher_offset;
331 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
332 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
333 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
334 : :
335 [ # # ]: 0 : } else if (is_auth) {
336 : 0 : auth_offset = sop->auth.data.offset;
337 : 0 : auth_len = sop->auth.data.length;
338 : 0 : max_len = auth_len + auth_offset;
339 [ # # ]: 0 : if (len_in_bits) {
340 : 0 : max_len = max_len >> 3;
341 : 0 : auth_offset = auth_offset >> 3;
342 : 0 : auth_len = auth_len >> 3;
343 : : }
344 : 0 : ofs.ofs.auth.head = auth_offset;
345 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
346 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
347 : : op, void *, IV_OFFSET + cipher_iv_len);
348 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
349 : : cipher_iv_len);
350 : 0 : digest.va = (void *)sop->auth.digest.data;
351 : 0 : digest.iova = sop->auth.digest.phys_addr;
352 : :
353 : : } else { /* aead */
354 : 0 : cipher_offset = sop->aead.data.offset;
355 : 0 : cipher_len = sop->aead.data.length;
356 : 0 : max_len = cipher_len + cipher_offset;
357 [ # # ]: 0 : if (len_in_bits) {
358 : 0 : max_len = max_len >> 3;
359 : 0 : cipher_offset = cipher_offset >> 3;
360 : 0 : cipher_len = cipher_len >> 3;
361 : : }
362 : 0 : ofs.ofs.cipher.head = cipher_offset;
363 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
364 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
365 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
366 : 0 : aad_auth_iv.va = (void *)sop->aead.aad.data;
367 : 0 : aad_auth_iv.iova = sop->aead.aad.phys_addr;
368 : 0 : digest.va = (void *)sop->aead.digest.data;
369 : 0 : digest.iova = sop->aead.digest.phys_addr;
370 : : }
371 : :
372 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
373 : : data_vec, RTE_DIM(data_vec));
374 [ # # # # ]: 0 : if (n < 0 || n > sop->m_src->nb_segs) {
375 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
376 : 0 : goto exit;
377 : : }
378 : :
379 : 0 : sgl.num = n;
380 : : /* Out of place */
381 [ # # ]: 0 : if (is_oop) {
382 : 0 : dest_sgl.vec = dest_data_vec;
383 : 0 : vec.dest_sgl = &dest_sgl;
384 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
385 : : dest_data_vec, RTE_DIM(dest_data_vec));
386 [ # # # # ]: 0 : if (n < 0 || n > sop->m_dst->nb_segs) {
387 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
388 : 0 : goto exit;
389 : : }
390 : 0 : dest_sgl.num = n;
391 : : } else
392 : 0 : vec.dest_sgl = NULL;
393 : :
394 [ # # ]: 0 : if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
395 : : &enqueue_status) < 1) {
396 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
397 : 0 : goto exit;
398 : : }
399 : :
400 [ # # ]: 0 : if (enqueue_status == 0) {
401 : 0 : status = rte_cryptodev_raw_enqueue_done(ctx, 1);
402 [ # # ]: 0 : if (status < 0) {
403 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
404 : 0 : goto exit;
405 : : }
406 [ # # ]: 0 : } else if (enqueue_status < 0) {
407 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
408 : 0 : goto exit;
409 : : }
410 : :
411 : 0 : n = n_success = 0;
412 [ # # # # ]: 0 : while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
413 : 0 : n = rte_cryptodev_raw_dequeue_burst(ctx,
414 : : NULL, 1, post_process_raw_dp_op,
415 : : (void **)&ret_op, 0, &n_success,
416 : : &dequeue_status);
417 [ # # ]: 0 : if (dequeue_status < 0) {
418 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
419 : 0 : goto exit;
420 : : }
421 [ # # ]: 0 : if (n == 0)
422 : : rte_pause();
423 : : }
424 : :
425 [ # # # # ]: 0 : if (n == 1 && dequeue_status == 0) {
426 [ # # ]: 0 : if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
427 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
428 : 0 : goto exit;
429 : : }
430 : : }
431 : :
432 [ # # # # ]: 0 : op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
433 [ # # ]: 0 : ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
434 [ # # ]: 0 : n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
435 : : RTE_CRYPTO_OP_STATUS_SUCCESS;
436 : :
437 : 0 : exit:
438 : 0 : free(ctx);
439 : 0 : return ret;
440 : : }
441 : :
442 : : static void
443 : 0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
444 : : {
445 : : int32_t n, st;
446 : : struct rte_crypto_sym_op *sop;
447 : : union rte_crypto_sym_ofs ofs;
448 : : struct rte_crypto_sgl sgl;
449 : : struct rte_crypto_sym_vec symvec;
450 : : struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
451 : : struct rte_crypto_vec vec[UINT8_MAX];
452 : :
453 : : sop = op->sym;
454 : :
455 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
456 : : sop->aead.data.length, vec, RTE_DIM(vec));
457 : :
458 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
459 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
460 : 0 : return;
461 : : }
462 : :
463 : 0 : sgl.vec = vec;
464 : 0 : sgl.num = n;
465 : 0 : symvec.src_sgl = &sgl;
466 : 0 : symvec.iv = &iv_ptr;
467 : 0 : symvec.digest = &digest_ptr;
468 : 0 : symvec.aad = &aad_ptr;
469 : 0 : symvec.status = &st;
470 : 0 : symvec.num = 1;
471 : :
472 : : /* for CPU crypto the IOVA address is not required */
473 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
474 : 0 : digest_ptr.va = (void *)sop->aead.digest.data;
475 : 0 : aad_ptr.va = (void *)sop->aead.aad.data;
476 : :
477 : 0 : ofs.raw = 0;
478 : :
479 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
480 : : &symvec);
481 : :
482 [ # # ]: 0 : if (n != 1)
483 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
484 : : else
485 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
486 : : }
487 : :
488 : : static void
489 : 0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
490 : : {
491 : : int32_t n, st;
492 : : struct rte_crypto_sym_op *sop;
493 : : union rte_crypto_sym_ofs ofs;
494 : : struct rte_crypto_sgl sgl;
495 : : struct rte_crypto_sym_vec symvec;
496 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
497 : : struct rte_crypto_vec vec[UINT8_MAX];
498 : :
499 : : sop = op->sym;
500 : :
501 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
502 : : sop->auth.data.length, vec, RTE_DIM(vec));
503 : :
504 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
505 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
506 : 0 : return;
507 : : }
508 : :
509 : 0 : sgl.vec = vec;
510 : 0 : sgl.num = n;
511 : 0 : symvec.src_sgl = &sgl;
512 : 0 : symvec.iv = &iv_ptr;
513 : 0 : symvec.digest = &digest_ptr;
514 : 0 : symvec.status = &st;
515 : 0 : symvec.num = 1;
516 : :
517 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
518 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
519 : :
520 : 0 : ofs.raw = 0;
521 : 0 : ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
522 : 0 : ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
523 : 0 : (sop->cipher.data.offset + sop->cipher.data.length);
524 : :
525 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
526 : : &symvec);
527 : :
528 [ # # ]: 0 : if (n != 1)
529 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
530 : : else
531 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
532 : : }
533 : :
534 : : static struct rte_crypto_op *
535 : 112 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
536 : : {
537 : :
538 [ - + ]: 112 : RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
539 : :
540 [ - + ]: 112 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
541 : 0 : RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
542 : 0 : return NULL;
543 : : }
544 : :
545 : 112 : op = NULL;
546 : :
547 [ - + ]: 112 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
548 : : rte_pause();
549 : :
550 [ + + ]: 112 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
551 : 11 : RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
552 : 11 : return NULL;
553 : : }
554 : :
555 : : return op;
556 : : }
557 : :
558 : : static int
559 : 1 : testsuite_setup(void)
560 : : {
561 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
562 : : struct rte_cryptodev_info info;
563 : : uint32_t i = 0, nb_devs, dev_id;
564 : : uint16_t qp_id;
565 : :
566 : : memset(ts_params, 0, sizeof(*ts_params));
567 : :
568 : 1 : ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
569 [ + - ]: 1 : if (ts_params->mbuf_pool == NULL) {
570 : : /* Not already created so create */
571 : 1 : ts_params->mbuf_pool = rte_pktmbuf_pool_create(
572 : : "CRYPTO_MBUFPOOL",
573 : : NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
574 : 1 : rte_socket_id());
575 [ - + ]: 1 : if (ts_params->mbuf_pool == NULL) {
576 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
577 : 0 : return TEST_FAILED;
578 : : }
579 : : }
580 : :
581 : 1 : ts_params->large_mbuf_pool = rte_mempool_lookup(
582 : : "CRYPTO_LARGE_MBUFPOOL");
583 [ + - ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
584 : : /* Not already created so create */
585 : 1 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
586 : : "CRYPTO_LARGE_MBUFPOOL",
587 : : 1, 0, 0, UINT16_MAX,
588 : 1 : rte_socket_id());
589 [ - + ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
590 : 0 : RTE_LOG(ERR, USER1,
591 : : "Can't create CRYPTO_LARGE_MBUFPOOL\n");
592 : 0 : return TEST_FAILED;
593 : : }
594 : : }
595 : :
596 : 1 : ts_params->op_mpool = rte_crypto_op_pool_create(
597 : : "MBUF_CRYPTO_SYM_OP_POOL",
598 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC,
599 : : NUM_MBUFS, MBUF_CACHE_SIZE,
600 : : DEFAULT_NUM_XFORMS *
601 : : sizeof(struct rte_crypto_sym_xform) +
602 : : MAXIMUM_IV_LENGTH,
603 : 1 : rte_socket_id());
604 [ - + ]: 1 : if (ts_params->op_mpool == NULL) {
605 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
606 : 0 : return TEST_FAILED;
607 : : }
608 : :
609 : 1 : nb_devs = rte_cryptodev_count();
610 [ - + ]: 1 : if (nb_devs < 1) {
611 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
612 : 0 : return TEST_SKIPPED;
613 : : }
614 : :
615 [ - + ]: 1 : if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
616 : 0 : RTE_LOG(WARNING, USER1, "No %s devices found?\n",
617 : : rte_cryptodev_driver_name_get(gbl_driver_id));
618 : 0 : return TEST_SKIPPED;
619 : : }
620 : :
621 : : /* Create list of valid crypto devs */
622 [ + + ]: 2 : for (i = 0; i < nb_devs; i++) {
623 : 1 : rte_cryptodev_info_get(i, &info);
624 [ + - ]: 1 : if (info.driver_id == gbl_driver_id)
625 : 1 : ts_params->valid_devs[ts_params->valid_dev_count++] = i;
626 : : }
627 : :
628 [ + - ]: 1 : if (ts_params->valid_dev_count < 1)
629 : : return TEST_FAILED;
630 : :
631 : : /* Set up all the qps on the first of the valid devices found */
632 : :
633 : 1 : dev_id = ts_params->valid_devs[0];
634 : :
635 : 1 : rte_cryptodev_info_get(dev_id, &info);
636 : :
637 : 1 : ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
638 : 1 : ts_params->conf.socket_id = SOCKET_ID_ANY;
639 : 1 : ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
640 : :
641 : : unsigned int session_size =
642 : 1 : rte_cryptodev_sym_get_private_session_size(dev_id);
643 : :
644 : : #ifdef RTE_LIB_SECURITY
645 : 1 : unsigned int security_session_size = rte_security_session_get_size(
646 : : rte_cryptodev_get_sec_ctx(dev_id));
647 : :
648 : : if (session_size < security_session_size)
649 : : session_size = security_session_size;
650 : : #endif
651 : : /*
652 : : * Create mempool with maximum number of sessions.
653 : : */
654 [ - + ]: 1 : if (info.sym.max_nb_sessions != 0 &&
655 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
656 : 0 : RTE_LOG(ERR, USER1, "Device does not support "
657 : : "at least %u sessions\n",
658 : : MAX_NB_SESSIONS);
659 : 0 : return TEST_FAILED;
660 : : }
661 : :
662 : 1 : ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
663 : : "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
664 : : SOCKET_ID_ANY);
665 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
666 : : "session mempool allocation failed");
667 : :
668 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
669 : : &ts_params->conf),
670 : : "Failed to configure cryptodev %u with %u qps",
671 : : dev_id, ts_params->conf.nb_queue_pairs);
672 : :
673 : 1 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
674 : 1 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
675 : :
676 [ + + ]: 9 : for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
677 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
678 : : dev_id, qp_id, &ts_params->qp_conf,
679 : : rte_cryptodev_socket_id(dev_id)),
680 : : "Failed to setup queue pair %u on cryptodev %u",
681 : : qp_id, dev_id);
682 : : }
683 : :
684 : : return TEST_SUCCESS;
685 : : }
686 : :
687 : : static void
688 : 1 : testsuite_teardown(void)
689 : : {
690 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
691 : : int res;
692 : :
693 [ + - ]: 1 : if (ts_params->mbuf_pool != NULL) {
694 : 1 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
695 : : rte_mempool_avail_count(ts_params->mbuf_pool));
696 : : }
697 : :
698 [ + - ]: 1 : if (ts_params->op_mpool != NULL) {
699 : 1 : RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
700 : : rte_mempool_avail_count(ts_params->op_mpool));
701 : : }
702 : :
703 [ + - ]: 1 : if (ts_params->session_mpool != NULL) {
704 : 1 : rte_mempool_free(ts_params->session_mpool);
705 : 1 : ts_params->session_mpool = NULL;
706 : : }
707 : :
708 : 1 : res = rte_cryptodev_close(ts_params->valid_devs[0]);
709 [ - + ]: 1 : if (res)
710 : 0 : RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
711 : 1 : }
712 : :
713 : : static int
714 : 30 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
715 : : const int *algs, uint16_t num_algs)
716 : : {
717 : 30 : uint8_t dev_id = testsuite_params.valid_devs[0];
718 : : bool some_alg_supported = FALSE;
719 : : uint16_t i;
720 : :
721 [ + + ]: 71 : for (i = 0; i < num_algs && !some_alg_supported; i++) {
722 : 41 : struct rte_cryptodev_sym_capability_idx alg = {
723 : 41 : type, {algs[i]}
724 : : };
725 [ + + ]: 41 : if (rte_cryptodev_sym_capability_get(dev_id,
726 : : &alg) != NULL)
727 : : some_alg_supported = TRUE;
728 : : }
729 [ + + ]: 30 : if (!some_alg_supported)
730 : 13 : return TEST_SKIPPED;
731 : :
732 : : return 0;
733 : : }
734 : :
735 : : int
736 : 9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
737 : : uint16_t num_ciphers)
738 : : {
739 : 17 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
740 : : (const int *) ciphers, num_ciphers);
741 : : }
742 : :
743 : : int
744 : 2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
745 : : uint16_t num_auths)
746 : : {
747 : 9 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
748 : : (const int *) auths, num_auths);
749 : : }
750 : :
751 : : int
752 : 0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
753 : : uint16_t num_aeads)
754 : : {
755 : 4 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
756 : : (const int *) aeads, num_aeads);
757 : : }
758 : :
759 : : static int
760 : 1 : null_testsuite_setup(void)
761 : : {
762 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
763 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
764 : : struct rte_cryptodev_info dev_info;
765 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
766 : : RTE_CRYPTO_CIPHER_NULL
767 : : };
768 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
769 : : RTE_CRYPTO_AUTH_NULL
770 : : };
771 : :
772 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
773 : :
774 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
775 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
776 : : "testsuite not met\n");
777 : 0 : return TEST_SKIPPED;
778 : : }
779 : :
780 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
781 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
782 : : RTE_DIM(auths)) != 0) {
783 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for NULL "
784 : : "testsuite not met\n");
785 : 1 : return TEST_SKIPPED;
786 : : }
787 : :
788 : : return 0;
789 : : }
790 : :
791 : : static int
792 : 1 : crypto_gen_testsuite_setup(void)
793 : : {
794 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
795 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
796 : : struct rte_cryptodev_info dev_info;
797 : :
798 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
799 : :
800 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
801 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
802 : : "testsuite not met\n");
803 : 0 : return TEST_SKIPPED;
804 : : }
805 : :
806 : : return 0;
807 : : }
808 : :
809 : : #ifdef RTE_LIB_SECURITY
810 : : static int
811 : 3 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
812 : : {
813 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
814 : : struct crypto_unittest_params *ut_params = &unittest_params;
815 : : struct rte_cryptodev_info dev_info;
816 : : int ret = 0;
817 : :
818 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
819 : :
820 [ + - ]: 3 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
821 : 3 : RTE_LOG(INFO, USER1,
822 : : "Feature flag requirements for security protocol testsuite not met\n");
823 : 3 : return TEST_SKIPPED;
824 : : }
825 : :
826 : : /* Reconfigure to enable security */
827 : 0 : ret = dev_configure_and_start(0);
828 [ # # ]: 0 : if (ret != TEST_SUCCESS)
829 : : return ret;
830 : :
831 : : /* Set action type */
832 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
833 : :
834 [ # # ]: 0 : if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
835 : 0 : RTE_LOG(INFO, USER1,
836 : : "Capability requirements for security protocol test not met\n");
837 : : ret = TEST_SKIPPED;
838 : : }
839 : :
840 : 0 : test_sec_alg_list_populate();
841 : 0 : test_sec_auth_only_alg_list_populate();
842 : :
843 : : /*
844 : : * Stop the device. Device would be started again by individual test
845 : : * case setup routine.
846 : : */
847 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
848 : :
849 : 0 : return ret;
850 : : }
851 : :
852 : : static int
853 : 1 : ipsec_proto_testsuite_setup(void)
854 : : {
855 : 1 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
856 : : }
857 : :
858 : : static int
859 : 2 : tls_record_proto_testsuite_setup(void)
860 : : {
861 : 2 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
862 : : }
863 : :
864 : : static int
865 : 1 : pdcp_proto_testsuite_setup(void)
866 : : {
867 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
868 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
869 : : struct rte_cryptodev_info dev_info;
870 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
871 : : RTE_CRYPTO_CIPHER_NULL,
872 : : RTE_CRYPTO_CIPHER_AES_CTR,
873 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
874 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
875 : : };
876 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
877 : : RTE_CRYPTO_AUTH_NULL,
878 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
879 : : RTE_CRYPTO_AUTH_AES_CMAC,
880 : : RTE_CRYPTO_AUTH_ZUC_EIA3
881 : : };
882 : :
883 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
884 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
885 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
886 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
887 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
888 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
889 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
890 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
891 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
892 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
893 : :
894 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
895 : :
896 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
897 : : !(dev_info.feature_flags &
898 : : RTE_CRYPTODEV_FF_SECURITY)) {
899 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
900 : : "testsuite not met\n");
901 : 1 : return TEST_SKIPPED;
902 : : }
903 : :
904 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
905 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
906 : : RTE_DIM(auths)) != 0) {
907 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
908 : : "testsuite not met\n");
909 : 0 : return TEST_SKIPPED;
910 : : }
911 : :
912 : : return 0;
913 : : }
914 : :
915 : : static int
916 : 1 : docsis_proto_testsuite_setup(void)
917 : : {
918 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
919 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
920 : : struct rte_cryptodev_info dev_info;
921 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
922 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
923 : : };
924 : :
925 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
926 : :
927 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
928 : : !(dev_info.feature_flags &
929 : : RTE_CRYPTODEV_FF_SECURITY)) {
930 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
931 : : "Proto testsuite not met\n");
932 : 1 : return TEST_SKIPPED;
933 : : }
934 : :
935 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
936 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
937 : : "testsuite not met\n");
938 : 0 : return TEST_SKIPPED;
939 : : }
940 : :
941 : : return 0;
942 : : }
943 : : #endif
944 : :
945 : : static int
946 : 1 : aes_ccm_auth_testsuite_setup(void)
947 : : {
948 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
949 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
950 : : struct rte_cryptodev_info dev_info;
951 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
952 : : RTE_CRYPTO_AEAD_AES_CCM
953 : : };
954 : :
955 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
956 : :
957 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
958 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
959 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
960 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
961 : : "testsuite not met\n");
962 : 0 : return TEST_SKIPPED;
963 : : }
964 : :
965 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
966 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
967 : : "testsuite not met\n");
968 : 0 : return TEST_SKIPPED;
969 : : }
970 : :
971 : : return 0;
972 : : }
973 : :
974 : : static int
975 : 1 : aes_gcm_auth_testsuite_setup(void)
976 : : {
977 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
978 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
979 : : struct rte_cryptodev_info dev_info;
980 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
981 : : RTE_CRYPTO_AEAD_AES_GCM
982 : : };
983 : :
984 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
985 : :
986 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
987 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
988 : : "testsuite not met\n");
989 : 0 : return TEST_SKIPPED;
990 : : }
991 : :
992 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
993 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
994 : : "testsuite not met\n");
995 : 0 : return TEST_SKIPPED;
996 : : }
997 : :
998 : : return 0;
999 : : }
1000 : :
1001 : : static int
1002 : 1 : aes_gmac_auth_testsuite_setup(void)
1003 : : {
1004 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1005 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1006 : : struct rte_cryptodev_info dev_info;
1007 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1008 : : RTE_CRYPTO_AUTH_AES_GMAC
1009 : : };
1010 : :
1011 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1012 : :
1013 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1014 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1015 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1016 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1017 : : "testsuite not met\n");
1018 : 0 : return TEST_SKIPPED;
1019 : : }
1020 : :
1021 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1022 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1023 : : "testsuite not met\n");
1024 : 0 : return TEST_SKIPPED;
1025 : : }
1026 : :
1027 : : return 0;
1028 : : }
1029 : :
1030 : : static int
1031 : 1 : chacha20_poly1305_testsuite_setup(void)
1032 : : {
1033 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1034 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1035 : : struct rte_cryptodev_info dev_info;
1036 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1037 : : RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1038 : : };
1039 : :
1040 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1041 : :
1042 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1043 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1044 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1045 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1046 : : "Chacha20-Poly1305 testsuite not met\n");
1047 : 0 : return TEST_SKIPPED;
1048 : : }
1049 : :
1050 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1051 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1052 : : "Chacha20-Poly1305 testsuite not met\n");
1053 : 1 : return TEST_SKIPPED;
1054 : : }
1055 : :
1056 : : return 0;
1057 : : }
1058 : :
1059 : : static int
1060 : 1 : snow3g_testsuite_setup(void)
1061 : : {
1062 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1063 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1064 : : struct rte_cryptodev_info dev_info;
1065 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1066 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1067 : :
1068 : : };
1069 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1070 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2
1071 : : };
1072 : :
1073 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1074 : :
1075 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1076 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1077 : : "testsuite not met\n");
1078 : 0 : return TEST_SKIPPED;
1079 : : }
1080 : :
1081 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1082 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1083 : : RTE_DIM(auths)) != 0) {
1084 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1085 : : "testsuite not met\n");
1086 : 1 : return TEST_SKIPPED;
1087 : : }
1088 : :
1089 : : return 0;
1090 : : }
1091 : :
1092 : : static int
1093 : 1 : zuc_testsuite_setup(void)
1094 : : {
1095 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1096 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1097 : : struct rte_cryptodev_info dev_info;
1098 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1099 : : RTE_CRYPTO_CIPHER_ZUC_EEA3
1100 : : };
1101 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1102 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1103 : : };
1104 : :
1105 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1106 : :
1107 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1108 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1109 : : "testsuite not met\n");
1110 : 0 : return TEST_SKIPPED;
1111 : : }
1112 : :
1113 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1114 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1115 : : RTE_DIM(auths)) != 0) {
1116 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1117 : : "testsuite not met\n");
1118 : 1 : return TEST_SKIPPED;
1119 : : }
1120 : :
1121 : : return 0;
1122 : : }
1123 : :
1124 : : static int
1125 : 1 : hmac_md5_auth_testsuite_setup(void)
1126 : : {
1127 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1128 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1129 : : struct rte_cryptodev_info dev_info;
1130 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1131 : : RTE_CRYPTO_AUTH_MD5_HMAC
1132 : : };
1133 : :
1134 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1135 : :
1136 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1137 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1138 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1139 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1140 : : "Auth testsuite not met\n");
1141 : 0 : return TEST_SKIPPED;
1142 : : }
1143 : :
1144 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1145 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1146 : : "testsuite not met\n");
1147 : 0 : return TEST_SKIPPED;
1148 : : }
1149 : :
1150 : : return 0;
1151 : : }
1152 : :
1153 : : static int
1154 : 1 : kasumi_testsuite_setup(void)
1155 : : {
1156 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1157 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1158 : : struct rte_cryptodev_info dev_info;
1159 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1160 : : RTE_CRYPTO_CIPHER_KASUMI_F8
1161 : : };
1162 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1163 : : RTE_CRYPTO_AUTH_KASUMI_F9
1164 : : };
1165 : :
1166 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1167 : :
1168 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1169 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1170 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1171 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1172 : : "testsuite not met\n");
1173 : 0 : return TEST_SKIPPED;
1174 : : }
1175 : :
1176 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1177 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1178 : : RTE_DIM(auths)) != 0) {
1179 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1180 : : "testsuite not met\n");
1181 : 1 : return TEST_SKIPPED;
1182 : : }
1183 : :
1184 : : return 0;
1185 : : }
1186 : :
1187 : : static int
1188 : 1 : negative_aes_gcm_testsuite_setup(void)
1189 : : {
1190 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1191 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1192 : : struct rte_cryptodev_info dev_info;
1193 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1194 : : RTE_CRYPTO_AEAD_AES_GCM
1195 : : };
1196 : :
1197 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1198 : :
1199 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1200 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1201 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1202 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1203 : : "AES GCM testsuite not met\n");
1204 : 0 : return TEST_SKIPPED;
1205 : : }
1206 : :
1207 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1208 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1209 : : "AES GCM testsuite not met\n");
1210 : 0 : return TEST_SKIPPED;
1211 : : }
1212 : :
1213 : : return 0;
1214 : : }
1215 : :
1216 : : static int
1217 : 1 : negative_aes_gmac_testsuite_setup(void)
1218 : : {
1219 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1220 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1221 : : struct rte_cryptodev_info dev_info;
1222 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1223 : : RTE_CRYPTO_AUTH_AES_GMAC
1224 : : };
1225 : :
1226 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1227 : :
1228 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1229 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1230 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1231 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1232 : : "AES GMAC testsuite not met\n");
1233 : 0 : return TEST_SKIPPED;
1234 : : }
1235 : :
1236 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1237 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1238 : : "AES GMAC testsuite not met\n");
1239 : 0 : return TEST_SKIPPED;
1240 : : }
1241 : :
1242 : : return 0;
1243 : : }
1244 : :
1245 : : static int
1246 : 1 : mixed_cipher_hash_testsuite_setup(void)
1247 : : {
1248 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1249 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1250 : : struct rte_cryptodev_info dev_info;
1251 : : uint64_t feat_flags;
1252 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1253 : : RTE_CRYPTO_CIPHER_NULL,
1254 : : RTE_CRYPTO_CIPHER_AES_CTR,
1255 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
1256 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1257 : : };
1258 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1259 : : RTE_CRYPTO_AUTH_NULL,
1260 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1261 : : RTE_CRYPTO_AUTH_AES_CMAC,
1262 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1263 : : };
1264 : :
1265 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1266 : 1 : feat_flags = dev_info.feature_flags;
1267 : :
1268 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1269 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1270 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1271 : : "Cipher Hash testsuite not met\n");
1272 : 0 : return TEST_SKIPPED;
1273 : : }
1274 : :
1275 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1276 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1277 : : RTE_DIM(auths)) != 0) {
1278 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1279 : : "Cipher Hash testsuite not met\n");
1280 : 0 : return TEST_SKIPPED;
1281 : : }
1282 : :
1283 : : return 0;
1284 : : }
1285 : :
1286 : : static int
1287 : 1 : esn_testsuite_setup(void)
1288 : : {
1289 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1290 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1291 : : struct rte_cryptodev_info dev_info;
1292 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1293 : : RTE_CRYPTO_CIPHER_AES_CBC
1294 : : };
1295 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1296 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1297 : : };
1298 : :
1299 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1300 : :
1301 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1302 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1303 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1304 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1305 : : "testsuite not met\n");
1306 : 0 : return TEST_SKIPPED;
1307 : : }
1308 : :
1309 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1310 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1311 : : RTE_DIM(auths)) != 0) {
1312 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1313 : : "testsuite not met\n");
1314 : 0 : return TEST_SKIPPED;
1315 : : }
1316 : :
1317 : : return 0;
1318 : : }
1319 : :
1320 : : static int
1321 : 1 : multi_session_testsuite_setup(void)
1322 : : {
1323 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1324 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1325 : : struct rte_cryptodev_info dev_info;
1326 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1327 : : RTE_CRYPTO_CIPHER_AES_CBC
1328 : : };
1329 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1330 : : RTE_CRYPTO_AUTH_SHA512_HMAC
1331 : : };
1332 : :
1333 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1334 : :
1335 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1336 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1337 : : "Session testsuite not met\n");
1338 : 0 : return TEST_SKIPPED;
1339 : : }
1340 : :
1341 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1342 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1343 : : RTE_DIM(auths)) != 0) {
1344 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1345 : : "Session testsuite not met\n");
1346 : 0 : return TEST_SKIPPED;
1347 : : }
1348 : :
1349 : : return 0;
1350 : : }
1351 : :
1352 : : static int
1353 : 1 : negative_hmac_sha1_testsuite_setup(void)
1354 : : {
1355 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1356 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1357 : : struct rte_cryptodev_info dev_info;
1358 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1359 : : RTE_CRYPTO_CIPHER_AES_CBC
1360 : : };
1361 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1362 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1363 : : };
1364 : :
1365 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1366 : :
1367 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1368 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1369 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1370 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1371 : : "HMAC SHA1 testsuite not met\n");
1372 : 0 : return TEST_SKIPPED;
1373 : : }
1374 : :
1375 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1376 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1377 : : RTE_DIM(auths)) != 0) {
1378 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1379 : : "HMAC SHA1 testsuite not met\n");
1380 : 0 : return TEST_SKIPPED;
1381 : : }
1382 : :
1383 : : return 0;
1384 : : }
1385 : :
1386 : : static int
1387 : 426 : dev_configure_and_start(uint64_t ff_disable)
1388 : : {
1389 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1390 : : struct crypto_unittest_params *ut_params = &unittest_params;
1391 : :
1392 : : uint16_t qp_id;
1393 : :
1394 : : /* Clear unit test parameters before running test */
1395 : : memset(ut_params, 0, sizeof(*ut_params));
1396 : :
1397 : : /* Reconfigure device to default parameters */
1398 : 426 : ts_params->conf.socket_id = SOCKET_ID_ANY;
1399 : 426 : ts_params->conf.ff_disable = ff_disable;
1400 : 426 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1401 : 426 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
1402 : :
1403 [ - + ]: 426 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1404 : : &ts_params->conf),
1405 : : "Failed to configure cryptodev %u",
1406 : : ts_params->valid_devs[0]);
1407 : :
1408 [ + + ]: 3834 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1409 [ - + ]: 3408 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1410 : : ts_params->valid_devs[0], qp_id,
1411 : : &ts_params->qp_conf,
1412 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1413 : : "Failed to setup queue pair %u on cryptodev %u",
1414 : : qp_id, ts_params->valid_devs[0]);
1415 : : }
1416 : :
1417 : :
1418 : 426 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1419 : :
1420 : : /* Start the device */
1421 [ - + ]: 426 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1422 : : "Failed to start cryptodev %u",
1423 : : ts_params->valid_devs[0]);
1424 : :
1425 : : return TEST_SUCCESS;
1426 : : }
1427 : :
1428 : : int
1429 : 426 : ut_setup(void)
1430 : : {
1431 : : /* Configure and start the device with security feature disabled */
1432 : 426 : return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1433 : : }
1434 : :
1435 : : static int
1436 : 0 : ut_setup_security(void)
1437 : : {
1438 : : /* Configure and start the device with no features disabled */
1439 : 0 : return dev_configure_and_start(0);
1440 : : }
1441 : :
1442 : : static int
1443 : 0 : ut_setup_security_rx_inject(void)
1444 : : {
1445 : 0 : struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1446 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1447 : 0 : struct rte_eth_conf port_conf = {
1448 : : .rxmode = {
1449 : : .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1450 : : RTE_ETH_RX_OFFLOAD_SECURITY,
1451 : : },
1452 : : .txmode = {
1453 : : .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1454 : : },
1455 : : .lpbk_mode = 1, /* Enable loopback */
1456 : : };
1457 : : struct rte_cryptodev_info dev_info;
1458 : 0 : struct rte_eth_rxconf rx_conf = {
1459 : : .rx_thresh = {
1460 : : .pthresh = 8,
1461 : : .hthresh = 8,
1462 : : .wthresh = 8,
1463 : : },
1464 : : .rx_free_thresh = 32,
1465 : : };
1466 : : uint16_t nb_ports;
1467 : : void *sec_ctx;
1468 : : int ret;
1469 : :
1470 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1471 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1472 : : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1473 : 0 : RTE_LOG(INFO, USER1,
1474 : : "Feature requirements for IPsec Rx inject test case not met\n");
1475 : 0 : return TEST_SKIPPED;
1476 : : }
1477 : :
1478 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1479 [ # # ]: 0 : if (sec_ctx == NULL)
1480 : : return TEST_SKIPPED;
1481 : :
1482 : 0 : nb_ports = rte_eth_dev_count_avail();
1483 [ # # ]: 0 : if (nb_ports == 0)
1484 : : return TEST_SKIPPED;
1485 : :
1486 : 0 : ret = rte_eth_dev_configure(0 /* port_id */,
1487 : : 1 /* nb_rx_queue */,
1488 : : 0 /* nb_tx_queue */,
1489 : : &port_conf);
1490 [ # # ]: 0 : if (ret) {
1491 : : printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1492 : 0 : return TEST_SKIPPED;
1493 : : }
1494 : :
1495 : : /* Rx queue setup */
1496 : 0 : ret = rte_eth_rx_queue_setup(0 /* port_id */,
1497 : : 0 /* rx_queue_id */,
1498 : : 1024 /* nb_rx_desc */,
1499 : : SOCKET_ID_ANY,
1500 : : &rx_conf,
1501 : : mbuf_pool);
1502 [ # # ]: 0 : if (ret) {
1503 : : printf("Could not setup eth port 0 queue 0\n");
1504 : 0 : return TEST_SKIPPED;
1505 : : }
1506 : :
1507 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1508 [ # # ]: 0 : if (ret) {
1509 : : printf("Could not enable Rx inject offload");
1510 : 0 : return TEST_SKIPPED;
1511 : : }
1512 : :
1513 : 0 : ret = rte_eth_dev_start(0);
1514 [ # # ]: 0 : if (ret) {
1515 : : printf("Could not start ethdev");
1516 : 0 : return TEST_SKIPPED;
1517 : : }
1518 : :
1519 : 0 : ret = rte_eth_promiscuous_enable(0);
1520 [ # # ]: 0 : if (ret) {
1521 : : printf("Could not enable promiscuous mode");
1522 : 0 : return TEST_SKIPPED;
1523 : : }
1524 : :
1525 : : /* Configure and start cryptodev with no features disabled */
1526 : 0 : return dev_configure_and_start(0);
1527 : : }
1528 : :
1529 : : void
1530 : 426 : ut_teardown(void)
1531 : : {
1532 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1533 : : struct crypto_unittest_params *ut_params = &unittest_params;
1534 : :
1535 : : /* free crypto session structure */
1536 : : #ifdef RTE_LIB_SECURITY
1537 [ - + ]: 426 : if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1538 [ # # ]: 0 : if (ut_params->sec_session) {
1539 : 0 : rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1540 : 0 : (ts_params->valid_devs[0]),
1541 : : ut_params->sec_session);
1542 : 0 : ut_params->sec_session = NULL;
1543 : : }
1544 : : } else
1545 : : #endif
1546 : : {
1547 [ + + ]: 426 : if (ut_params->sess) {
1548 : 105 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1549 : : ut_params->sess);
1550 : 105 : ut_params->sess = NULL;
1551 : : }
1552 : : }
1553 : :
1554 : : /* free crypto operation structure */
1555 : 426 : rte_crypto_op_free(ut_params->op);
1556 : :
1557 : : /*
1558 : : * free mbuf - both obuf and ibuf are usually the same,
1559 : : * so check if they point at the same address is necessary,
1560 : : * to avoid freeing the mbuf twice.
1561 : : */
1562 [ + + ]: 426 : if (ut_params->obuf) {
1563 : 6 : rte_pktmbuf_free(ut_params->obuf);
1564 [ + + ]: 6 : if (ut_params->ibuf == ut_params->obuf)
1565 : 3 : ut_params->ibuf = 0;
1566 : 6 : ut_params->obuf = 0;
1567 : : }
1568 [ + + ]: 426 : if (ut_params->ibuf) {
1569 : 104 : rte_pktmbuf_free(ut_params->ibuf);
1570 : 104 : ut_params->ibuf = 0;
1571 : : }
1572 : :
1573 [ + - ]: 426 : if (ts_params->mbuf_pool != NULL)
1574 : 426 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1575 : : rte_mempool_avail_count(ts_params->mbuf_pool));
1576 : :
1577 : : /* Stop the device */
1578 : 426 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1579 : 426 : }
1580 : :
1581 : : static void
1582 : 0 : ut_teardown_rx_inject(void)
1583 : : {
1584 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1585 : : void *sec_ctx;
1586 : : int ret;
1587 : :
1588 [ # # ]: 0 : if (rte_eth_dev_count_avail() != 0) {
1589 : 0 : ret = rte_eth_dev_reset(0);
1590 [ # # ]: 0 : if (ret)
1591 : : printf("Could not reset eth port 0");
1592 : :
1593 : : }
1594 : :
1595 : 0 : ut_teardown();
1596 : :
1597 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1598 [ # # ]: 0 : if (sec_ctx == NULL)
1599 : : return;
1600 : :
1601 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1602 [ # # ]: 0 : if (ret) {
1603 : : printf("Could not disable Rx inject offload");
1604 : 0 : return;
1605 : : }
1606 : : }
1607 : :
1608 : : static int
1609 : 1 : test_device_configure_invalid_dev_id(void)
1610 : : {
1611 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1612 : : uint16_t dev_id, num_devs = 0;
1613 : :
1614 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1615 : : "Need at least %d devices for test", 1);
1616 : :
1617 : : /* valid dev_id values */
1618 : 1 : dev_id = ts_params->valid_devs[0];
1619 : :
1620 : : /* Stop the device in case it's started so it can be configured */
1621 : 1 : rte_cryptodev_stop(dev_id);
1622 : :
1623 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1624 : : "Failed test for rte_cryptodev_configure: "
1625 : : "invalid dev_num %u", dev_id);
1626 : :
1627 : : /* invalid dev_id values */
1628 : : dev_id = num_devs;
1629 : :
1630 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1631 : : "Failed test for rte_cryptodev_configure: "
1632 : : "invalid dev_num %u", dev_id);
1633 : :
1634 : : dev_id = 0xff;
1635 : :
1636 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1637 : : "Failed test for rte_cryptodev_configure:"
1638 : : "invalid dev_num %u", dev_id);
1639 : :
1640 : : return TEST_SUCCESS;
1641 : : }
1642 : :
1643 : : static int
1644 : 1 : test_device_configure_invalid_queue_pair_ids(void)
1645 : : {
1646 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1647 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1648 : :
1649 : : /* Stop the device in case it's started so it can be configured */
1650 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1651 : :
1652 : : /* valid - max value queue pairs */
1653 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1654 : :
1655 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1656 : : &ts_params->conf),
1657 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1658 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1659 : :
1660 : : /* valid - one queue pairs */
1661 : 1 : ts_params->conf.nb_queue_pairs = 1;
1662 : :
1663 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1664 : : &ts_params->conf),
1665 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1666 : : ts_params->valid_devs[0],
1667 : : ts_params->conf.nb_queue_pairs);
1668 : :
1669 : :
1670 : : /* invalid - zero queue pairs */
1671 : 1 : ts_params->conf.nb_queue_pairs = 0;
1672 : :
1673 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1674 : : &ts_params->conf),
1675 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1676 : : " invalid qps: %u",
1677 : : ts_params->valid_devs[0],
1678 : : ts_params->conf.nb_queue_pairs);
1679 : :
1680 : :
1681 : : /* invalid - max value supported by field queue pairs */
1682 : 1 : ts_params->conf.nb_queue_pairs = UINT16_MAX;
1683 : :
1684 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1685 : : &ts_params->conf),
1686 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1687 : : " invalid qps: %u",
1688 : : ts_params->valid_devs[0],
1689 : : ts_params->conf.nb_queue_pairs);
1690 : :
1691 : :
1692 : : /* invalid - max value + 1 queue pairs */
1693 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1694 : :
1695 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1696 : : &ts_params->conf),
1697 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1698 : : " invalid qps: %u",
1699 : : ts_params->valid_devs[0],
1700 : : ts_params->conf.nb_queue_pairs);
1701 : :
1702 : : /* revert to original testsuite value */
1703 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1704 : :
1705 : 1 : return TEST_SUCCESS;
1706 : : }
1707 : :
1708 : : static int
1709 : 1 : test_queue_pair_descriptor_setup(void)
1710 : : {
1711 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1712 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
1713 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1714 : : };
1715 : : uint16_t qp_id;
1716 : :
1717 : : /* Stop the device in case it's started so it can be configured */
1718 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1719 : :
1720 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1721 : : &ts_params->conf),
1722 : : "Failed to configure cryptodev %u",
1723 : : ts_params->valid_devs[0]);
1724 : :
1725 : : /*
1726 : : * Test various ring sizes on this device. memzones can't be
1727 : : * freed so are re-used if ring is released and re-created.
1728 : : */
1729 : 1 : qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1730 : 1 : qp_conf.mp_session = ts_params->session_mpool;
1731 : :
1732 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1733 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1734 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1735 : : rte_cryptodev_socket_id(
1736 : : ts_params->valid_devs[0])),
1737 : : "Failed test for "
1738 : : "rte_cryptodev_queue_pair_setup: num_inflights "
1739 : : "%u on qp %u on cryptodev %u",
1740 : : qp_conf.nb_descriptors, qp_id,
1741 : : ts_params->valid_devs[0]);
1742 : : }
1743 : :
1744 : 1 : qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1745 : :
1746 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1747 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1748 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1749 : : rte_cryptodev_socket_id(
1750 : : ts_params->valid_devs[0])),
1751 : : "Failed test for"
1752 : : " rte_cryptodev_queue_pair_setup: num_inflights"
1753 : : " %u on qp %u on cryptodev %u",
1754 : : qp_conf.nb_descriptors, qp_id,
1755 : : ts_params->valid_devs[0]);
1756 : : }
1757 : :
1758 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1759 : :
1760 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1761 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1762 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1763 : : rte_cryptodev_socket_id(
1764 : : ts_params->valid_devs[0])),
1765 : : "Failed test for "
1766 : : "rte_cryptodev_queue_pair_setup: num_inflights"
1767 : : " %u on qp %u on cryptodev %u",
1768 : : qp_conf.nb_descriptors, qp_id,
1769 : : ts_params->valid_devs[0]);
1770 : : }
1771 : :
1772 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1773 : :
1774 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1775 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1776 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1777 : : rte_cryptodev_socket_id(
1778 : : ts_params->valid_devs[0])),
1779 : : "Failed test for"
1780 : : " rte_cryptodev_queue_pair_setup:"
1781 : : "num_inflights %u on qp %u on cryptodev %u",
1782 : : qp_conf.nb_descriptors, qp_id,
1783 : : ts_params->valid_devs[0]);
1784 : : }
1785 : :
1786 : : /* test invalid queue pair id */
1787 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1788 : :
1789 : : qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1790 : :
1791 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1792 : : ts_params->valid_devs[0],
1793 : : qp_id, &qp_conf,
1794 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1795 : : "Failed test for rte_cryptodev_queue_pair_setup:"
1796 : : "invalid qp %u on cryptodev %u",
1797 : : qp_id, ts_params->valid_devs[0]);
1798 : :
1799 : : qp_id = 0xffff; /*invalid*/
1800 : :
1801 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1802 : : ts_params->valid_devs[0],
1803 : : qp_id, &qp_conf,
1804 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1805 : : "Failed test for rte_cryptodev_queue_pair_setup:"
1806 : : "invalid qp %u on cryptodev %u",
1807 : : qp_id, ts_params->valid_devs[0]);
1808 : :
1809 : : return TEST_SUCCESS;
1810 : : }
1811 : :
1812 : : /* ***** Plaintext data for tests ***** */
1813 : :
1814 : : const char catch_22_quote_1[] =
1815 : : "There was only one catch and that was Catch-22, which "
1816 : : "specified that a concern for one's safety in the face of "
1817 : : "dangers that were real and immediate was the process of a "
1818 : : "rational mind. Orr was crazy and could be grounded. All he "
1819 : : "had to do was ask; and as soon as he did, he would no longer "
1820 : : "be crazy and would have to fly more missions. Orr would be "
1821 : : "crazy to fly more missions and sane if he didn't, but if he "
1822 : : "was sane he had to fly them. If he flew them he was crazy "
1823 : : "and didn't have to; but if he didn't want to he was sane and "
1824 : : "had to. Yossarian was moved very deeply by the absolute "
1825 : : "simplicity of this clause of Catch-22 and let out a "
1826 : : "respectful whistle. \"That's some catch, that Catch-22\", he "
1827 : : "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1828 : :
1829 : : const char catch_22_quote[] =
1830 : : "What a lousy earth! He wondered how many people were "
1831 : : "destitute that same night even in his own prosperous country, "
1832 : : "how many homes were shanties, how many husbands were drunk "
1833 : : "and wives socked, and how many children were bullied, abused, "
1834 : : "or abandoned. How many families hungered for food they could "
1835 : : "not afford to buy? How many hearts were broken? How many "
1836 : : "suicides would take place that same night, how many people "
1837 : : "would go insane? How many cockroaches and landlords would "
1838 : : "triumph? How many winners were losers, successes failures, "
1839 : : "and rich men poor men? How many wise guys were stupid? How "
1840 : : "many happy endings were unhappy endings? How many honest men "
1841 : : "were liars, brave men cowards, loyal men traitors, how many "
1842 : : "sainted men were corrupt, how many people in positions of "
1843 : : "trust had sold their souls to bodyguards, how many had never "
1844 : : "had souls? How many straight-and-narrow paths were crooked "
1845 : : "paths? How many best families were worst families and how "
1846 : : "many good people were bad people? When you added them all up "
1847 : : "and then subtracted, you might be left with only the children, "
1848 : : "and perhaps with Albert Einstein and an old violinist or "
1849 : : "sculptor somewhere.";
1850 : :
1851 : : #define QUOTE_480_BYTES (480)
1852 : : #define QUOTE_512_BYTES (512)
1853 : : #define QUOTE_768_BYTES (768)
1854 : : #define QUOTE_1024_BYTES (1024)
1855 : :
1856 : :
1857 : :
1858 : : /* ***** SHA1 Hash Tests ***** */
1859 : :
1860 : : #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1861 : :
1862 : : static uint8_t hmac_sha1_key[] = {
1863 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1864 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1865 : : 0xDE, 0xF4, 0xDE, 0xAD };
1866 : :
1867 : : /* ***** SHA224 Hash Tests ***** */
1868 : :
1869 : : #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1870 : :
1871 : :
1872 : : /* ***** AES-CBC Cipher Tests ***** */
1873 : :
1874 : : #define CIPHER_KEY_LENGTH_AES_CBC (16)
1875 : : #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1876 : :
1877 : : static uint8_t aes_cbc_key[] = {
1878 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1879 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1880 : :
1881 : : static uint8_t aes_cbc_iv[] = {
1882 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1883 : : 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1884 : :
1885 : :
1886 : : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1887 : :
1888 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1889 : : 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1890 : : 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1891 : : 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1892 : : 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1893 : : 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1894 : : 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1895 : : 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1896 : : 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1897 : : 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1898 : : 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1899 : : 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1900 : : 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1901 : : 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1902 : : 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1903 : : 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1904 : : 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1905 : : 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1906 : : 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1907 : : 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1908 : : 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1909 : : 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1910 : : 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1911 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1912 : : 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1913 : : 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1914 : : 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1915 : : 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1916 : : 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1917 : : 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1918 : : 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1919 : : 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1920 : : 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1921 : : 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1922 : : 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1923 : : 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1924 : : 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1925 : : 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1926 : : 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1927 : : 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1928 : : 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1929 : : 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1930 : : 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1931 : : 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1932 : : 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1933 : : 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1934 : : 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1935 : : 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1936 : : 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1937 : : 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1938 : : 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1939 : : 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1940 : : 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1941 : : 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1942 : : 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1943 : : 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1944 : : 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1945 : : 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1946 : : 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1947 : : 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1948 : : 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1949 : : 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1950 : : 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1951 : : 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1952 : : 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1953 : : };
1954 : :
1955 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1956 : : 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1957 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1958 : : 0x18, 0x8c, 0x1d, 0x32
1959 : : };
1960 : :
1961 : :
1962 : : /* Multisession Vector context Test */
1963 : : /*Begin Session 0 */
1964 : : static uint8_t ms_aes_cbc_key0[] = {
1965 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1966 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1967 : : };
1968 : :
1969 : : static uint8_t ms_aes_cbc_iv0[] = {
1970 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1971 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1972 : : };
1973 : :
1974 : : static const uint8_t ms_aes_cbc_cipher0[] = {
1975 : : 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1976 : : 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1977 : : 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1978 : : 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1979 : : 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1980 : : 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1981 : : 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1982 : : 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1983 : : 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1984 : : 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1985 : : 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1986 : : 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1987 : : 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1988 : : 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1989 : : 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1990 : : 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1991 : : 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1992 : : 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1993 : : 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1994 : : 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1995 : : 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1996 : : 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1997 : : 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1998 : : 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1999 : : 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2000 : : 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2001 : : 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2002 : : 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2003 : : 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2004 : : 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2005 : : 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2006 : : 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2007 : : 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2008 : : 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2009 : : 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2010 : : 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2011 : : 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2012 : : 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2013 : : 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2014 : : 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2015 : : 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2016 : : 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2017 : : 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2018 : : 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2019 : : 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2020 : : 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2021 : : 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2022 : : 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2023 : : 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2024 : : 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2025 : : 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2026 : : 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2027 : : 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2028 : : 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2029 : : 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2030 : : 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2031 : : 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2032 : : 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2033 : : 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2034 : : 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2035 : : 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2036 : : 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2037 : : 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2038 : : 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2039 : : };
2040 : :
2041 : :
2042 : : static uint8_t ms_hmac_key0[] = {
2043 : : 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2044 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2045 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2046 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2047 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2048 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2049 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2050 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2051 : : };
2052 : :
2053 : : static const uint8_t ms_hmac_digest0[] = {
2054 : : 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2055 : : 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2056 : : 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2057 : : 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2058 : : 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2059 : : 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2060 : : 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2061 : : 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2062 : : };
2063 : :
2064 : : /* End Session 0 */
2065 : : /* Begin session 1 */
2066 : :
2067 : : static uint8_t ms_aes_cbc_key1[] = {
2068 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2069 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2070 : : };
2071 : :
2072 : : static uint8_t ms_aes_cbc_iv1[] = {
2073 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2074 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2075 : : };
2076 : :
2077 : : static const uint8_t ms_aes_cbc_cipher1[] = {
2078 : : 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2079 : : 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2080 : : 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2081 : : 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2082 : : 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2083 : : 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2084 : : 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2085 : : 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2086 : : 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2087 : : 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2088 : : 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2089 : : 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2090 : : 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2091 : : 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2092 : : 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2093 : : 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2094 : : 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2095 : : 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2096 : : 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2097 : : 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2098 : : 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2099 : : 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2100 : : 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2101 : : 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2102 : : 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2103 : : 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2104 : : 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2105 : : 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2106 : : 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2107 : : 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2108 : : 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2109 : : 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2110 : : 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2111 : : 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2112 : : 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2113 : : 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2114 : : 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2115 : : 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2116 : : 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2117 : : 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2118 : : 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2119 : : 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2120 : : 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2121 : : 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2122 : : 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2123 : : 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2124 : : 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2125 : : 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2126 : : 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2127 : : 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2128 : : 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2129 : : 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2130 : : 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2131 : : 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2132 : : 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2133 : : 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2134 : : 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2135 : : 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2136 : : 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2137 : : 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2138 : : 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2139 : : 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2140 : : 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2141 : : 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2142 : :
2143 : : };
2144 : :
2145 : : static uint8_t ms_hmac_key1[] = {
2146 : : 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2147 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2148 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2149 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2150 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2151 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2152 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2153 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2154 : : };
2155 : :
2156 : : static const uint8_t ms_hmac_digest1[] = {
2157 : : 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2158 : : 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2159 : : 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2160 : : 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2161 : : 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2162 : : 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2163 : : 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2164 : : 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2165 : : };
2166 : : /* End Session 1 */
2167 : : /* Begin Session 2 */
2168 : : static uint8_t ms_aes_cbc_key2[] = {
2169 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2170 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2171 : : };
2172 : :
2173 : : static uint8_t ms_aes_cbc_iv2[] = {
2174 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2175 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2176 : : };
2177 : :
2178 : : static const uint8_t ms_aes_cbc_cipher2[] = {
2179 : : 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2180 : : 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2181 : : 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2182 : : 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2183 : : 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2184 : : 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2185 : : 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2186 : : 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2187 : : 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2188 : : 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2189 : : 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2190 : : 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2191 : : 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2192 : : 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2193 : : 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2194 : : 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2195 : : 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2196 : : 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2197 : : 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2198 : : 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2199 : : 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2200 : : 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2201 : : 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2202 : : 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2203 : : 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2204 : : 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2205 : : 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2206 : : 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2207 : : 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2208 : : 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2209 : : 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2210 : : 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2211 : : 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2212 : : 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2213 : : 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2214 : : 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2215 : : 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2216 : : 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2217 : : 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2218 : : 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2219 : : 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2220 : : 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2221 : : 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2222 : : 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2223 : : 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2224 : : 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2225 : : 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2226 : : 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2227 : : 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2228 : : 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2229 : : 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2230 : : 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2231 : : 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2232 : : 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2233 : : 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2234 : : 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2235 : : 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2236 : : 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2237 : : 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2238 : : 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2239 : : 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2240 : : 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2241 : : 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2242 : : 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2243 : : };
2244 : :
2245 : : static uint8_t ms_hmac_key2[] = {
2246 : : 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2247 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2248 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2249 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2250 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2251 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2252 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2253 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2254 : : };
2255 : :
2256 : : static const uint8_t ms_hmac_digest2[] = {
2257 : : 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2258 : : 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2259 : : 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2260 : : 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2261 : : 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2262 : : 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2263 : : 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2264 : : 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2265 : : };
2266 : :
2267 : : /* End Session 2 */
2268 : :
2269 : :
2270 : : static int
2271 : 2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2272 : : {
2273 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2274 : : struct crypto_unittest_params *ut_params = &unittest_params;
2275 : : /* Verify the capabilities */
2276 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2277 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2278 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2279 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2280 : : &cap_idx) == NULL)
2281 : : return TEST_SKIPPED;
2282 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2283 : 2 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2284 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2285 : : &cap_idx) == NULL)
2286 : : return TEST_SKIPPED;
2287 : :
2288 : : /* Generate test mbuf data and space for digest */
2289 : 2 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2290 : : catch_22_quote, QUOTE_512_BYTES, 0);
2291 : :
2292 : 2 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2293 : : DIGEST_BYTE_LENGTH_SHA1);
2294 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2295 : :
2296 : : /* Setup Cipher Parameters */
2297 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2298 : 2 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2299 : :
2300 : 2 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2301 : 2 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2302 : 2 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2303 : 2 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2304 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2305 : 2 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2306 : :
2307 : : /* Setup HMAC Parameters */
2308 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2309 : :
2310 : 2 : ut_params->auth_xform.next = NULL;
2311 : :
2312 : 2 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2313 : 2 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2314 : 2 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2315 : 2 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2316 : 2 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2317 : :
2318 : 2 : rte_errno = 0;
2319 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(
2320 : 2 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2321 : : ts_params->session_mpool);
2322 [ + - ]: 2 : if (rte_errno == ENOTSUP)
2323 : : return TEST_SKIPPED;
2324 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2325 : :
2326 : : /* Generate crypto op data structure */
2327 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2328 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2329 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
2330 : : "Failed to allocate symmetric crypto operation struct");
2331 : :
2332 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2333 : :
2334 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2335 : :
2336 : : /* set crypto operation source mbuf */
2337 : 2 : sym_op->m_src = ut_params->ibuf;
2338 : :
2339 : : /* Set crypto operation authentication parameters */
2340 : 2 : sym_op->auth.digest.data = ut_params->digest;
2341 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2342 : : ut_params->ibuf, QUOTE_512_BYTES);
2343 : :
2344 : 2 : sym_op->auth.data.offset = 0;
2345 : 2 : sym_op->auth.data.length = QUOTE_512_BYTES;
2346 : :
2347 : : /* Copy IV at the end of the crypto operation */
2348 [ - + ]: 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2349 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2350 : :
2351 : : /* Set crypto operation cipher parameters */
2352 : 2 : sym_op->cipher.data.offset = 0;
2353 : 2 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2354 : :
2355 : : /* Process crypto operation */
2356 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2357 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2358 : : ut_params->op);
2359 : : else
2360 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
2361 : : process_crypto_request(ts_params->valid_devs[0],
2362 : : ut_params->op),
2363 : : "failed to process sym crypto op");
2364 : :
2365 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2366 : : "crypto op processing failed");
2367 : :
2368 : : /* Validate obuf */
2369 : 2 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2370 : : uint8_t *);
2371 : :
2372 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2373 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2374 : : QUOTE_512_BYTES,
2375 : : "ciphertext data not as expected");
2376 : :
2377 : 2 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2378 : :
2379 [ + - - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2380 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2381 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2382 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2383 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2384 : : DIGEST_BYTE_LENGTH_SHA1,
2385 : : "Generated digest data not as expected");
2386 : :
2387 : : return TEST_SUCCESS;
2388 : : }
2389 : :
2390 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2391 : :
2392 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2393 : :
2394 : : static uint8_t hmac_sha512_key[] = {
2395 : : 0x42, 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 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2405 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2406 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2407 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2408 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2409 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2410 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2411 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2412 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2413 : :
2414 : :
2415 : :
2416 : : static int
2417 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2418 : : struct crypto_unittest_params *ut_params,
2419 : : uint8_t *cipher_key,
2420 : : uint8_t *hmac_key);
2421 : :
2422 : : static int
2423 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2424 : : struct crypto_unittest_params *ut_params,
2425 : : struct crypto_testsuite_params *ts_params,
2426 : : const uint8_t *cipher,
2427 : : const uint8_t *digest,
2428 : : const uint8_t *iv);
2429 : :
2430 : :
2431 : : static int
2432 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2433 : : struct crypto_unittest_params *ut_params,
2434 : : uint8_t *cipher_key,
2435 : : uint8_t *hmac_key)
2436 : : {
2437 : :
2438 : : /* Setup Cipher Parameters */
2439 : 4 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2440 : 4 : ut_params->cipher_xform.next = NULL;
2441 : :
2442 : 4 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2443 : 4 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2444 : 4 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2445 : 4 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2446 : 4 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2447 : 4 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2448 : :
2449 : : /* Setup HMAC Parameters */
2450 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2451 : 4 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2452 : :
2453 : 4 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2454 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2455 : 4 : ut_params->auth_xform.auth.key.data = hmac_key;
2456 : 4 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2457 : 4 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2458 : :
2459 : : return TEST_SUCCESS;
2460 : : }
2461 : :
2462 : :
2463 : : static int
2464 : 5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2465 : : struct crypto_unittest_params *ut_params,
2466 : : struct crypto_testsuite_params *ts_params,
2467 : : const uint8_t *cipher,
2468 : : const uint8_t *digest,
2469 : : const uint8_t *iv)
2470 : : {
2471 : : int ret;
2472 : :
2473 : : /* Generate test mbuf data and digest */
2474 : 5 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2475 : : (const char *)
2476 : : cipher,
2477 : : QUOTE_512_BYTES, 0);
2478 : :
2479 : 5 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2480 : : DIGEST_BYTE_LENGTH_SHA512);
2481 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2482 : :
2483 : : rte_memcpy(ut_params->digest,
2484 : : digest,
2485 : : DIGEST_BYTE_LENGTH_SHA512);
2486 : :
2487 : : /* Generate Crypto op data structure */
2488 : 5 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2489 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2490 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->op,
2491 : : "Failed to allocate symmetric crypto operation struct");
2492 : :
2493 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2494 : :
2495 : 5 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2496 : :
2497 : : /* set crypto operation source mbuf */
2498 : 5 : sym_op->m_src = ut_params->ibuf;
2499 : :
2500 : 5 : sym_op->auth.digest.data = ut_params->digest;
2501 [ - + ]: 5 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2502 : : ut_params->ibuf, QUOTE_512_BYTES);
2503 : :
2504 : 5 : sym_op->auth.data.offset = 0;
2505 : 5 : sym_op->auth.data.length = QUOTE_512_BYTES;
2506 : :
2507 : : /* Copy IV at the end of the crypto operation */
2508 [ - + ]: 5 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2509 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2510 : :
2511 : 5 : sym_op->cipher.data.offset = 0;
2512 : 5 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2513 : :
2514 : : /* Process crypto operation */
2515 [ - + ]: 5 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2516 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2517 : : ut_params->op);
2518 [ - + ]: 5 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2519 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2520 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2521 : : return ret;
2522 : : } else
2523 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(
2524 : : process_crypto_request(ts_params->valid_devs[0],
2525 : : ut_params->op),
2526 : : "failed to process sym crypto op");
2527 : :
2528 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2529 : : "crypto op processing failed");
2530 : :
2531 : 5 : ut_params->obuf = ut_params->op->sym->m_src;
2532 : :
2533 : : /* Validate obuf */
2534 [ - + ]: 5 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2535 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2536 : : catch_22_quote,
2537 : : QUOTE_512_BYTES,
2538 : : "Plaintext data not as expected");
2539 : :
2540 : : /* Validate obuf */
2541 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2542 : : "Digest verification failed");
2543 : :
2544 : : return TEST_SUCCESS;
2545 : : }
2546 : :
2547 : : /* ***** SNOW 3G Tests ***** */
2548 : : static int
2549 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2550 : : const uint8_t *key, const uint8_t key_len,
2551 : : const uint8_t iv_len, const uint8_t auth_len,
2552 : : enum rte_crypto_auth_operation op,
2553 : : enum rte_crypto_auth_algorithm algo)
2554 : 0 : {
2555 : 0 : uint8_t hash_key[key_len];
2556 : :
2557 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2558 : : struct crypto_unittest_params *ut_params = &unittest_params;
2559 : :
2560 : : memcpy(hash_key, key, key_len);
2561 : :
2562 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2563 : :
2564 : : /* Setup Authentication Parameters */
2565 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2566 : 0 : ut_params->auth_xform.next = NULL;
2567 : :
2568 : 0 : ut_params->auth_xform.auth.op = op;
2569 : 0 : ut_params->auth_xform.auth.algo = algo;
2570 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2571 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2572 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2573 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2574 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2575 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2576 : : &ut_params->auth_xform, ts_params->session_mpool);
2577 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2578 : : return TEST_SKIPPED;
2579 : :
2580 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2581 : : return 0;
2582 : : }
2583 : :
2584 : : static int
2585 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2586 : : enum rte_crypto_cipher_operation op,
2587 : : enum rte_crypto_cipher_algorithm algo,
2588 : : const uint8_t *key, const uint8_t key_len,
2589 : : uint8_t iv_len)
2590 : 0 : {
2591 : 0 : uint8_t cipher_key[key_len];
2592 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2593 : : struct crypto_unittest_params *ut_params = &unittest_params;
2594 : :
2595 : : memcpy(cipher_key, key, key_len);
2596 : :
2597 : : /* Setup Cipher Parameters */
2598 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2599 : 0 : ut_params->cipher_xform.next = NULL;
2600 : :
2601 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2602 : 0 : ut_params->cipher_xform.cipher.op = op;
2603 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2604 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2605 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2606 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2607 : :
2608 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2609 : :
2610 : : /* Create Crypto session */
2611 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2612 : : &ut_params->cipher_xform, ts_params->session_mpool);
2613 : :
2614 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2615 : : return TEST_SKIPPED;
2616 : :
2617 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2618 : : return 0;
2619 : : }
2620 : :
2621 : : static int
2622 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2623 : : unsigned int cipher_len,
2624 : : unsigned int cipher_offset)
2625 : : {
2626 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2627 : : struct crypto_unittest_params *ut_params = &unittest_params;
2628 : :
2629 : : /* Generate Crypto op data structure */
2630 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2631 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2632 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2633 : : "Failed to allocate pktmbuf offload");
2634 : :
2635 : : /* Set crypto operation data parameters */
2636 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2637 : :
2638 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2639 : :
2640 : : /* set crypto operation source mbuf */
2641 : 0 : sym_op->m_src = ut_params->ibuf;
2642 : :
2643 : : /* iv */
2644 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2645 : : iv, iv_len);
2646 : 0 : sym_op->cipher.data.length = cipher_len;
2647 : 0 : sym_op->cipher.data.offset = cipher_offset;
2648 : 0 : return 0;
2649 : : }
2650 : :
2651 : : static int
2652 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2653 : : unsigned int cipher_len,
2654 : : unsigned int cipher_offset)
2655 : : {
2656 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2657 : : struct crypto_unittest_params *ut_params = &unittest_params;
2658 : :
2659 : : /* Generate Crypto op data structure */
2660 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2661 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2662 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2663 : : "Failed to allocate pktmbuf offload");
2664 : :
2665 : : /* Set crypto operation data parameters */
2666 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2667 : :
2668 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2669 : :
2670 : : /* set crypto operation source mbuf */
2671 : 0 : sym_op->m_src = ut_params->ibuf;
2672 : 0 : sym_op->m_dst = ut_params->obuf;
2673 : :
2674 : : /* iv */
2675 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2676 : : iv, iv_len);
2677 : 0 : sym_op->cipher.data.length = cipher_len;
2678 : 0 : sym_op->cipher.data.offset = cipher_offset;
2679 : 0 : return 0;
2680 : : }
2681 : :
2682 : : static int
2683 : 1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2684 : : enum rte_crypto_cipher_operation cipher_op,
2685 : : enum rte_crypto_auth_operation auth_op,
2686 : : enum rte_crypto_auth_algorithm auth_algo,
2687 : : enum rte_crypto_cipher_algorithm cipher_algo,
2688 : : const uint8_t *a_key, uint8_t a_key_len,
2689 : : const uint8_t *c_key, uint8_t c_key_len,
2690 : : uint8_t auth_iv_len, uint8_t auth_len,
2691 : : uint8_t cipher_iv_len)
2692 : :
2693 : : {
2694 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2695 : : struct crypto_unittest_params *ut_params = &unittest_params;
2696 : :
2697 : : /* Setup Authentication Parameters */
2698 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2699 : 1 : ut_params->auth_xform.next = NULL;
2700 : :
2701 : 1 : ut_params->auth_xform.auth.op = auth_op;
2702 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
2703 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
2704 : 1 : ut_params->auth_xform.auth.key.data = a_key;
2705 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
2706 : : /* Auth IV will be after cipher IV */
2707 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2708 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2709 : :
2710 : : /* Setup Cipher Parameters */
2711 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2712 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2713 : :
2714 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2715 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
2716 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
2717 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
2718 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2719 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2720 : :
2721 : 1 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
2722 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2723 : :
2724 : : /* Create Crypto session*/
2725 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2726 : : &ut_params->cipher_xform, ts_params->session_mpool);
2727 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2728 : : return TEST_SKIPPED;
2729 : :
2730 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2731 : : return 0;
2732 : : }
2733 : :
2734 : : static int
2735 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
2736 : : enum rte_crypto_cipher_operation cipher_op,
2737 : : enum rte_crypto_auth_operation auth_op,
2738 : : enum rte_crypto_auth_algorithm auth_algo,
2739 : : enum rte_crypto_cipher_algorithm cipher_algo,
2740 : : const struct wireless_test_data *tdata)
2741 : 0 : {
2742 : 0 : const uint8_t key_len = tdata->key.len;
2743 : 0 : uint8_t cipher_auth_key[key_len];
2744 : :
2745 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2746 : : struct crypto_unittest_params *ut_params = &unittest_params;
2747 : 0 : const uint8_t *key = tdata->key.data;
2748 : 0 : const uint8_t auth_len = tdata->digest.len;
2749 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
2750 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
2751 : :
2752 : : memcpy(cipher_auth_key, key, key_len);
2753 : :
2754 : : /* Setup Authentication Parameters */
2755 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2756 : 0 : ut_params->auth_xform.next = NULL;
2757 : :
2758 : 0 : ut_params->auth_xform.auth.op = auth_op;
2759 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
2760 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2761 : : /* Hash key = cipher key */
2762 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
2763 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2764 : : /* Auth IV will be after cipher IV */
2765 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2766 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2767 : :
2768 : : /* Setup Cipher Parameters */
2769 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2770 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2771 : :
2772 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2773 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
2774 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2775 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2776 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2777 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2778 : :
2779 : :
2780 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2781 : :
2782 : : /* Create Crypto session*/
2783 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2784 : : &ut_params->cipher_xform, ts_params->session_mpool);
2785 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2786 : : return TEST_SKIPPED;
2787 : :
2788 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2789 : : return 0;
2790 : : }
2791 : :
2792 : : static int
2793 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2794 : : const struct wireless_test_data *tdata)
2795 : : {
2796 : 0 : return create_wireless_cipher_auth_session(dev_id,
2797 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2798 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2799 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2800 : : }
2801 : :
2802 : : static int
2803 : 1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2804 : : enum rte_crypto_cipher_operation cipher_op,
2805 : : enum rte_crypto_auth_operation auth_op,
2806 : : enum rte_crypto_auth_algorithm auth_algo,
2807 : : enum rte_crypto_cipher_algorithm cipher_algo,
2808 : : const uint8_t *a_key, const uint8_t a_key_len,
2809 : : const uint8_t *c_key, const uint8_t c_key_len,
2810 : : uint8_t auth_iv_len, uint8_t auth_len,
2811 : : uint8_t cipher_iv_len)
2812 : : {
2813 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2814 : : struct crypto_unittest_params *ut_params = &unittest_params;
2815 : :
2816 : : /* Setup Authentication Parameters */
2817 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2818 : 1 : ut_params->auth_xform.auth.op = auth_op;
2819 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2820 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
2821 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
2822 : 1 : ut_params->auth_xform.auth.key.data = a_key;
2823 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
2824 : : /* Auth IV will be after cipher IV */
2825 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2826 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2827 : :
2828 : : /* Setup Cipher Parameters */
2829 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2830 : 1 : ut_params->cipher_xform.next = NULL;
2831 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2832 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
2833 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
2834 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
2835 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2836 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2837 : :
2838 : 1 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
2839 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2840 : :
2841 : : /* Create Crypto session*/
2842 [ - + ]: 1 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2843 : 0 : ut_params->auth_xform.next = NULL;
2844 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2845 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2846 : : &ut_params->cipher_xform, ts_params->session_mpool);
2847 : : } else
2848 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2849 : : &ut_params->auth_xform, ts_params->session_mpool);
2850 : :
2851 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2852 : : return TEST_SKIPPED;
2853 : :
2854 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2855 : :
2856 : : return 0;
2857 : : }
2858 : :
2859 : : static int
2860 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2861 : : unsigned int auth_tag_len,
2862 : : const uint8_t *iv, unsigned int iv_len,
2863 : : unsigned int data_pad_len,
2864 : : enum rte_crypto_auth_operation op,
2865 : : unsigned int auth_len, unsigned int auth_offset)
2866 : : {
2867 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2868 : :
2869 : : struct crypto_unittest_params *ut_params = &unittest_params;
2870 : :
2871 : : /* Generate Crypto op data structure */
2872 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2873 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2874 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2875 : : "Failed to allocate pktmbuf offload");
2876 : :
2877 : : /* Set crypto operation data parameters */
2878 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2879 : :
2880 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2881 : :
2882 : : /* set crypto operation source mbuf */
2883 : 0 : sym_op->m_src = ut_params->ibuf;
2884 : :
2885 : : /* iv */
2886 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2887 : : iv, iv_len);
2888 : : /* digest */
2889 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2890 : : ut_params->ibuf, auth_tag_len);
2891 : :
2892 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2893 : : "no room to append auth tag");
2894 : 0 : ut_params->digest = sym_op->auth.digest.data;
2895 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2896 : : ut_params->ibuf, data_pad_len);
2897 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2898 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
2899 : : else
2900 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2901 : :
2902 : 0 : debug_hexdump(stdout, "digest:",
2903 : 0 : sym_op->auth.digest.data,
2904 : : auth_tag_len);
2905 : :
2906 : 0 : sym_op->auth.data.length = auth_len;
2907 : 0 : sym_op->auth.data.offset = auth_offset;
2908 : :
2909 : 0 : return 0;
2910 : : }
2911 : :
2912 : : static int
2913 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2914 : : enum rte_crypto_auth_operation op)
2915 : : {
2916 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2917 : : struct crypto_unittest_params *ut_params = &unittest_params;
2918 : :
2919 : 0 : const uint8_t *auth_tag = tdata->digest.data;
2920 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
2921 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2922 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2923 : :
2924 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
2925 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2926 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
2927 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
2928 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2929 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
2930 : :
2931 : : /* Generate Crypto op data structure */
2932 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2933 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2934 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2935 : : "Failed to allocate pktmbuf offload");
2936 : : /* Set crypto operation data parameters */
2937 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2938 : :
2939 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2940 : :
2941 : : /* set crypto operation source mbuf */
2942 : 0 : sym_op->m_src = ut_params->ibuf;
2943 : :
2944 : : /* digest */
2945 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2946 : : ut_params->ibuf, auth_tag_len);
2947 : :
2948 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2949 : : "no room to append auth tag");
2950 : 0 : ut_params->digest = sym_op->auth.digest.data;
2951 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2952 : : ut_params->ibuf, data_pad_len);
2953 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2954 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
2955 : : else
2956 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2957 : :
2958 : 0 : debug_hexdump(stdout, "digest:",
2959 : 0 : sym_op->auth.digest.data,
2960 : : auth_tag_len);
2961 : :
2962 : : /* Copy cipher and auth IVs at the end of the crypto operation */
2963 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2964 : : IV_OFFSET);
2965 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2966 : 0 : iv_ptr += cipher_iv_len;
2967 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2968 : :
2969 : 0 : sym_op->cipher.data.length = cipher_len;
2970 : 0 : sym_op->cipher.data.offset = 0;
2971 : 0 : sym_op->auth.data.length = auth_len;
2972 : 0 : sym_op->auth.data.offset = 0;
2973 : :
2974 : 0 : return 0;
2975 : : }
2976 : :
2977 : : static int
2978 : : create_zuc_cipher_hash_generate_operation(
2979 : : const struct wireless_test_data *tdata)
2980 : : {
2981 : 0 : return create_wireless_cipher_hash_operation(tdata,
2982 : : RTE_CRYPTO_AUTH_OP_GENERATE);
2983 : : }
2984 : :
2985 : : static int
2986 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2987 : : const unsigned auth_tag_len,
2988 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
2989 : : unsigned data_pad_len,
2990 : : enum rte_crypto_auth_operation op,
2991 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2992 : : const unsigned cipher_len, const unsigned cipher_offset,
2993 : : const unsigned auth_len, const unsigned auth_offset)
2994 : : {
2995 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2996 : : struct crypto_unittest_params *ut_params = &unittest_params;
2997 : :
2998 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
2999 : : ut_params->cipher_xform.cipher.algo;
3000 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3001 : : ut_params->auth_xform.auth.algo;
3002 : :
3003 : : /* Generate Crypto op data structure */
3004 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3005 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3006 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3007 : : "Failed to allocate pktmbuf offload");
3008 : : /* Set crypto operation data parameters */
3009 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3010 : :
3011 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3012 : :
3013 : : /* set crypto operation source mbuf */
3014 : 0 : sym_op->m_src = ut_params->ibuf;
3015 : :
3016 : : /* digest */
3017 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3018 : : ut_params->ibuf, auth_tag_len);
3019 : :
3020 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3021 : : "no room to append auth tag");
3022 : 0 : ut_params->digest = sym_op->auth.digest.data;
3023 : :
3024 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3025 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3026 : : ut_params->ibuf, data_pad_len);
3027 : : } else {
3028 : : struct rte_mbuf *m = ut_params->ibuf;
3029 : : unsigned int offset = data_pad_len;
3030 : :
3031 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3032 : 0 : offset -= m->data_len;
3033 : : m = m->next;
3034 : : }
3035 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3036 : : m, offset);
3037 : : }
3038 : :
3039 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3040 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3041 : : else
3042 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3043 : :
3044 : 0 : debug_hexdump(stdout, "digest:",
3045 : 0 : sym_op->auth.digest.data,
3046 : : auth_tag_len);
3047 : :
3048 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3049 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3050 : : IV_OFFSET);
3051 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3052 : 0 : iv_ptr += cipher_iv_len;
3053 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3054 : :
3055 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3056 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3057 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3058 : 0 : sym_op->cipher.data.length = cipher_len;
3059 : 0 : sym_op->cipher.data.offset = cipher_offset;
3060 : : } else {
3061 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3062 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3063 : : }
3064 : :
3065 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3066 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3067 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3068 : 0 : sym_op->auth.data.length = auth_len;
3069 : 0 : sym_op->auth.data.offset = auth_offset;
3070 : : } else {
3071 : 0 : sym_op->auth.data.length = auth_len >> 3;
3072 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3073 : : }
3074 : :
3075 : : return 0;
3076 : : }
3077 : :
3078 : : static int
3079 : 2 : create_wireless_algo_auth_cipher_operation(
3080 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3081 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3082 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3083 : : unsigned int data_pad_len,
3084 : : unsigned int cipher_len, unsigned int cipher_offset,
3085 : : unsigned int auth_len, unsigned int auth_offset,
3086 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3087 : : {
3088 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3089 : : struct crypto_unittest_params *ut_params = &unittest_params;
3090 : :
3091 : 2 : enum rte_crypto_cipher_algorithm cipher_algo =
3092 : : ut_params->cipher_xform.cipher.algo;
3093 : 2 : enum rte_crypto_auth_algorithm auth_algo =
3094 : : ut_params->auth_xform.auth.algo;
3095 : :
3096 : : /* Generate Crypto op data structure */
3097 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3098 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3099 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
3100 : : "Failed to allocate pktmbuf offload");
3101 : :
3102 : : /* Set crypto operation data parameters */
3103 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3104 : :
3105 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3106 : :
3107 : : /* set crypto operation mbufs */
3108 : 2 : sym_op->m_src = ut_params->ibuf;
3109 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE)
3110 : 0 : sym_op->m_dst = ut_params->obuf;
3111 : :
3112 : : /* digest */
3113 [ - + ]: 2 : if (!do_sgl) {
3114 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3115 : : (op_mode == IN_PLACE ?
3116 : : ut_params->ibuf : ut_params->obuf),
3117 : : uint8_t *, data_pad_len);
3118 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3119 : : (op_mode == IN_PLACE ?
3120 : : ut_params->ibuf : ut_params->obuf),
3121 : : data_pad_len);
3122 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3123 : : } else {
3124 : 2 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3125 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3126 [ - + ]: 2 : sym_op->m_src : sym_op->m_dst);
3127 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3128 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3129 : 30 : sgl_buf = sgl_buf->next;
3130 : : }
3131 : :
3132 : : /* The last segment should be large enough to hold full digest */
3133 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3134 : 0 : rte_pktmbuf_free(sgl_buf->next);
3135 : 0 : sgl_buf->next = NULL;
3136 [ # # # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3137 : : auth_tag_len - sgl_buf->data_len),
3138 : : "No room to append auth tag");
3139 : : }
3140 : :
3141 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3142 : : uint8_t *, remaining_off);
3143 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3144 : : remaining_off);
3145 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3146 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3147 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3148 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3149 : 0 : sgl_buf = sgl_buf->next;
3150 : : }
3151 : : }
3152 : :
3153 : : /* Copy digest for the verification */
3154 [ + + ]: 2 : if (verify)
3155 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3156 : :
3157 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3158 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3159 : : ut_params->op, uint8_t *, IV_OFFSET);
3160 : :
3161 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3162 : 2 : iv_ptr += cipher_iv_len;
3163 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3164 : :
3165 : : /* Only copy over the offset data needed from src to dst in OOP,
3166 : : * if the auth and cipher offsets are not aligned
3167 : : */
3168 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3169 [ # # ]: 0 : if (cipher_offset > auth_offset)
3170 : 0 : rte_memcpy(
3171 : 0 : rte_pktmbuf_mtod_offset(
3172 : : sym_op->m_dst,
3173 : : uint8_t *, auth_offset >> 3),
3174 : 0 : rte_pktmbuf_mtod_offset(
3175 : : sym_op->m_src,
3176 : : uint8_t *, auth_offset >> 3),
3177 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3178 : : }
3179 : :
3180 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3181 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3182 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3183 : 0 : sym_op->cipher.data.length = cipher_len;
3184 : 0 : sym_op->cipher.data.offset = cipher_offset;
3185 : : } else {
3186 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3187 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3188 : : }
3189 : :
3190 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3191 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3192 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3193 : 0 : sym_op->auth.data.length = auth_len;
3194 : 0 : sym_op->auth.data.offset = auth_offset;
3195 : : } else {
3196 : 2 : sym_op->auth.data.length = auth_len >> 3;
3197 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3198 : : }
3199 : :
3200 : : return 0;
3201 : : }
3202 : :
3203 : : static int
3204 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3205 : : {
3206 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3207 : : struct crypto_unittest_params *ut_params = &unittest_params;
3208 : :
3209 : : int retval;
3210 : : unsigned plaintext_pad_len;
3211 : : unsigned plaintext_len;
3212 : : uint8_t *plaintext;
3213 : : struct rte_cryptodev_info dev_info;
3214 : :
3215 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3216 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3217 : :
3218 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3219 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3220 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3221 : 0 : return TEST_SKIPPED;
3222 : : }
3223 : :
3224 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3225 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3226 : : printf("Device doesn't support RAW data-path APIs.\n");
3227 : 0 : return TEST_SKIPPED;
3228 : : }
3229 : :
3230 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3231 : : return TEST_SKIPPED;
3232 : :
3233 : : /* Verify the capabilities */
3234 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3235 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3236 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3237 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3238 : : &cap_idx) == NULL)
3239 : : return TEST_SKIPPED;
3240 : :
3241 : : /* Create SNOW 3G session */
3242 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3243 : 0 : tdata->key.data, tdata->key.len,
3244 : 0 : tdata->auth_iv.len, tdata->digest.len,
3245 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3246 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3247 [ # # ]: 0 : if (retval < 0)
3248 : : return retval;
3249 : :
3250 : : /* alloc mbuf and set payload */
3251 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3252 : :
3253 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3254 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3255 : :
3256 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3257 : : /* Append data which is padded to a multiple of */
3258 : : /* the algorithms block size */
3259 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3260 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3261 : : plaintext_pad_len);
3262 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3263 : :
3264 : : /* Create SNOW 3G operation */
3265 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3266 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3267 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3268 : 0 : tdata->validAuthLenInBits.len,
3269 : : 0);
3270 [ # # ]: 0 : if (retval < 0)
3271 : : return retval;
3272 : :
3273 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3274 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3275 : : 0);
3276 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3277 : : return retval;
3278 : : } else
3279 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3280 : : ut_params->op);
3281 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3282 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3283 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3284 : : uint8_t *,
3285 : : plaintext_pad_len);
3286 : :
3287 : : /* Validate obuf */
3288 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3289 : : ut_params->digest,
3290 : : tdata->digest.data,
3291 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3292 : : "SNOW 3G Generated auth tag not as expected");
3293 : :
3294 : : return 0;
3295 : : }
3296 : :
3297 : : static int
3298 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3299 : : {
3300 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3301 : : struct crypto_unittest_params *ut_params = &unittest_params;
3302 : :
3303 : : int retval;
3304 : : unsigned plaintext_pad_len;
3305 : : unsigned plaintext_len;
3306 : : uint8_t *plaintext;
3307 : : struct rte_cryptodev_info dev_info;
3308 : :
3309 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3310 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3311 : :
3312 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3313 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3314 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3315 : 0 : return TEST_SKIPPED;
3316 : : }
3317 : :
3318 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3319 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3320 : : printf("Device doesn't support RAW data-path APIs.\n");
3321 : 0 : return TEST_SKIPPED;
3322 : : }
3323 : :
3324 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3325 : : return TEST_SKIPPED;
3326 : :
3327 : : /* Verify the capabilities */
3328 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3329 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3330 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3331 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3332 : : &cap_idx) == NULL)
3333 : : return TEST_SKIPPED;
3334 : :
3335 : : /* Create SNOW 3G session */
3336 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3337 : 0 : tdata->key.data, tdata->key.len,
3338 : 0 : tdata->auth_iv.len, tdata->digest.len,
3339 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3340 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3341 [ # # ]: 0 : if (retval < 0)
3342 : : return retval;
3343 : : /* alloc mbuf and set payload */
3344 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3345 : :
3346 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3347 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3348 : :
3349 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3350 : : /* Append data which is padded to a multiple of */
3351 : : /* the algorithms block size */
3352 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3353 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3354 : : plaintext_pad_len);
3355 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3356 : :
3357 : : /* Create SNOW 3G operation */
3358 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3359 : 0 : tdata->digest.len,
3360 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3361 : : plaintext_pad_len,
3362 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3363 : 0 : tdata->validAuthLenInBits.len,
3364 : : 0);
3365 [ # # ]: 0 : if (retval < 0)
3366 : : return retval;
3367 : :
3368 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3369 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3370 : : 0);
3371 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3372 : : return retval;
3373 : : } else
3374 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3375 : : ut_params->op);
3376 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3377 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3378 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3379 : : uint8_t *,
3380 : : plaintext_pad_len);
3381 : :
3382 : : /* Validate obuf */
3383 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3384 : : return 0;
3385 : : else
3386 : 0 : return -1;
3387 : :
3388 : : return 0;
3389 : : }
3390 : :
3391 : : static int
3392 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3393 : : {
3394 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3395 : : struct crypto_unittest_params *ut_params = &unittest_params;
3396 : :
3397 : : int retval;
3398 : : unsigned plaintext_pad_len;
3399 : : unsigned plaintext_len;
3400 : : uint8_t *plaintext;
3401 : : struct rte_cryptodev_info dev_info;
3402 : :
3403 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3404 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3405 : :
3406 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3407 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3408 : : printf("Device doesn't support RAW data-path APIs.\n");
3409 : 0 : return TEST_SKIPPED;
3410 : : }
3411 : :
3412 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3413 : : return TEST_SKIPPED;
3414 : :
3415 : : /* Verify the capabilities */
3416 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3417 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3418 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3419 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3420 : : &cap_idx) == NULL)
3421 : : return TEST_SKIPPED;
3422 : :
3423 : : /* Create KASUMI session */
3424 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3425 : 0 : tdata->key.data, tdata->key.len,
3426 : 0 : 0, tdata->digest.len,
3427 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3428 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3429 [ # # ]: 0 : if (retval < 0)
3430 : : return retval;
3431 : :
3432 : : /* alloc mbuf and set payload */
3433 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3434 : :
3435 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3436 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3437 : :
3438 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3439 : : /* Append data which is padded to a multiple of */
3440 : : /* the algorithms block size */
3441 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3442 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3443 : : plaintext_pad_len);
3444 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3445 : :
3446 : : /* Create KASUMI operation */
3447 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3448 : : NULL, 0,
3449 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3450 : 0 : tdata->plaintext.len,
3451 : : 0);
3452 [ # # ]: 0 : if (retval < 0)
3453 : : return retval;
3454 : :
3455 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3456 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3457 : : ut_params->op);
3458 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3459 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3460 : : 0);
3461 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3462 : : return retval;
3463 : : } else
3464 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3465 : : ut_params->op);
3466 : :
3467 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3468 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3469 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3470 : : uint8_t *,
3471 : : plaintext_pad_len);
3472 : :
3473 : : /* Validate obuf */
3474 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3475 : : ut_params->digest,
3476 : : tdata->digest.data,
3477 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3478 : : "KASUMI Generated auth tag not as expected");
3479 : :
3480 : : return 0;
3481 : : }
3482 : :
3483 : : static int
3484 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3485 : : {
3486 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3487 : : struct crypto_unittest_params *ut_params = &unittest_params;
3488 : :
3489 : : int retval;
3490 : : unsigned plaintext_pad_len;
3491 : : unsigned plaintext_len;
3492 : : uint8_t *plaintext;
3493 : : struct rte_cryptodev_info dev_info;
3494 : :
3495 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3496 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3497 : :
3498 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3499 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3500 : : printf("Device doesn't support RAW data-path APIs.\n");
3501 : 0 : return TEST_SKIPPED;
3502 : : }
3503 : :
3504 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3505 : : return TEST_SKIPPED;
3506 : :
3507 : : /* Verify the capabilities */
3508 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3509 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3510 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3511 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3512 : : &cap_idx) == NULL)
3513 : : return TEST_SKIPPED;
3514 : :
3515 : : /* Create KASUMI session */
3516 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3517 : 0 : tdata->key.data, tdata->key.len,
3518 : 0 : 0, tdata->digest.len,
3519 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3520 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3521 [ # # ]: 0 : if (retval < 0)
3522 : : return retval;
3523 : : /* alloc mbuf and set payload */
3524 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3525 : :
3526 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3527 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3528 : :
3529 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3530 : : /* Append data which is padded to a multiple */
3531 : : /* of the algorithms block size */
3532 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3533 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3534 : : plaintext_pad_len);
3535 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3536 : :
3537 : : /* Create KASUMI operation */
3538 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3539 : 0 : tdata->digest.len,
3540 : : NULL, 0,
3541 : : plaintext_pad_len,
3542 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3543 : 0 : tdata->plaintext.len,
3544 : : 0);
3545 [ # # ]: 0 : if (retval < 0)
3546 : : return retval;
3547 : :
3548 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3549 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3550 : : 0);
3551 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3552 : : return retval;
3553 : : } else
3554 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3555 : : ut_params->op);
3556 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3557 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3558 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3559 : : uint8_t *,
3560 : : plaintext_pad_len);
3561 : :
3562 : : /* Validate obuf */
3563 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3564 : : return 0;
3565 : : else
3566 : 0 : return -1;
3567 : :
3568 : : return 0;
3569 : : }
3570 : :
3571 : : static int
3572 : 0 : test_snow3g_hash_generate_test_case_1(void)
3573 : : {
3574 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3575 : : }
3576 : :
3577 : : static int
3578 : 0 : test_snow3g_hash_generate_test_case_2(void)
3579 : : {
3580 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3581 : : }
3582 : :
3583 : : static int
3584 : 0 : test_snow3g_hash_generate_test_case_3(void)
3585 : : {
3586 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3587 : : }
3588 : :
3589 : : static int
3590 : 0 : test_snow3g_hash_generate_test_case_4(void)
3591 : : {
3592 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3593 : : }
3594 : :
3595 : : static int
3596 : 0 : test_snow3g_hash_generate_test_case_5(void)
3597 : : {
3598 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3599 : : }
3600 : :
3601 : : static int
3602 : 0 : test_snow3g_hash_generate_test_case_6(void)
3603 : : {
3604 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3605 : : }
3606 : :
3607 : : static int
3608 : 0 : test_snow3g_hash_verify_test_case_1(void)
3609 : : {
3610 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3611 : :
3612 : : }
3613 : :
3614 : : static int
3615 : 0 : test_snow3g_hash_verify_test_case_2(void)
3616 : : {
3617 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3618 : : }
3619 : :
3620 : : static int
3621 : 0 : test_snow3g_hash_verify_test_case_3(void)
3622 : : {
3623 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3624 : : }
3625 : :
3626 : : static int
3627 : 0 : test_snow3g_hash_verify_test_case_4(void)
3628 : : {
3629 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3630 : : }
3631 : :
3632 : : static int
3633 : 0 : test_snow3g_hash_verify_test_case_5(void)
3634 : : {
3635 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3636 : : }
3637 : :
3638 : : static int
3639 : 0 : test_snow3g_hash_verify_test_case_6(void)
3640 : : {
3641 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3642 : : }
3643 : :
3644 : : static int
3645 : 0 : test_kasumi_hash_generate_test_case_1(void)
3646 : : {
3647 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
3648 : : }
3649 : :
3650 : : static int
3651 : 0 : test_kasumi_hash_generate_test_case_2(void)
3652 : : {
3653 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
3654 : : }
3655 : :
3656 : : static int
3657 : 0 : test_kasumi_hash_generate_test_case_3(void)
3658 : : {
3659 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
3660 : : }
3661 : :
3662 : : static int
3663 : 0 : test_kasumi_hash_generate_test_case_4(void)
3664 : : {
3665 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
3666 : : }
3667 : :
3668 : : static int
3669 : 0 : test_kasumi_hash_generate_test_case_5(void)
3670 : : {
3671 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
3672 : : }
3673 : :
3674 : : static int
3675 : 0 : test_kasumi_hash_generate_test_case_6(void)
3676 : : {
3677 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
3678 : : }
3679 : :
3680 : : static int
3681 : 0 : test_kasumi_hash_verify_test_case_1(void)
3682 : : {
3683 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3684 : : }
3685 : :
3686 : : static int
3687 : 0 : test_kasumi_hash_verify_test_case_2(void)
3688 : : {
3689 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3690 : : }
3691 : :
3692 : : static int
3693 : 0 : test_kasumi_hash_verify_test_case_3(void)
3694 : : {
3695 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3696 : : }
3697 : :
3698 : : static int
3699 : 0 : test_kasumi_hash_verify_test_case_4(void)
3700 : : {
3701 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3702 : : }
3703 : :
3704 : : static int
3705 : 0 : test_kasumi_hash_verify_test_case_5(void)
3706 : : {
3707 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3708 : : }
3709 : :
3710 : : static int
3711 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
3712 : : {
3713 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3714 : : struct crypto_unittest_params *ut_params = &unittest_params;
3715 : :
3716 : : int retval;
3717 : : uint8_t *plaintext, *ciphertext;
3718 : : unsigned plaintext_pad_len;
3719 : : unsigned plaintext_len;
3720 : : struct rte_cryptodev_info dev_info;
3721 : :
3722 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3723 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3724 : :
3725 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3726 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3727 : : printf("Device doesn't support RAW data-path APIs.\n");
3728 : 0 : return TEST_SKIPPED;
3729 : : }
3730 : :
3731 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3732 : : return TEST_SKIPPED;
3733 : :
3734 : : /* Verify the capabilities */
3735 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3736 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3737 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3738 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3739 : : &cap_idx) == NULL)
3740 : : return TEST_SKIPPED;
3741 : :
3742 : : /* Create KASUMI session */
3743 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3744 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3745 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3746 : 0 : tdata->key.data, tdata->key.len,
3747 : 0 : tdata->cipher_iv.len);
3748 [ # # ]: 0 : if (retval < 0)
3749 : : return retval;
3750 : :
3751 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3752 : :
3753 : : /* Clear mbuf payload */
3754 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3755 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3756 : :
3757 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3758 : : /* Append data which is padded to a multiple */
3759 : : /* of the algorithms block size */
3760 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3761 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3762 : : plaintext_pad_len);
3763 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3764 : :
3765 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3766 : :
3767 : : /* Create KASUMI operation */
3768 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3769 : 0 : tdata->cipher_iv.len,
3770 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3771 : 0 : tdata->validCipherOffsetInBits.len);
3772 [ # # ]: 0 : if (retval < 0)
3773 : : return retval;
3774 : :
3775 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3776 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3777 : 0 : tdata->cipher_iv.len);
3778 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3779 : : return retval;
3780 : : } else
3781 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3782 : : ut_params->op);
3783 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3784 : :
3785 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3786 [ # # ]: 0 : if (ut_params->obuf)
3787 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3788 : : else
3789 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3790 : :
3791 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3792 : :
3793 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3794 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3795 : : /* Validate obuf */
3796 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3797 : : ciphertext,
3798 : : reference_ciphertext,
3799 : : tdata->validCipherLenInBits.len,
3800 : : "KASUMI Ciphertext data not as expected");
3801 : : return 0;
3802 : : }
3803 : :
3804 : : static int
3805 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3806 : : {
3807 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3808 : : struct crypto_unittest_params *ut_params = &unittest_params;
3809 : :
3810 : : int retval;
3811 : :
3812 : : unsigned int plaintext_pad_len;
3813 : : unsigned int plaintext_len;
3814 : :
3815 : : uint8_t buffer[10000];
3816 : : const uint8_t *ciphertext;
3817 : :
3818 : : struct rte_cryptodev_info dev_info;
3819 : :
3820 : : /* Verify the capabilities */
3821 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3822 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3823 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3824 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3825 : : &cap_idx) == NULL)
3826 : : return TEST_SKIPPED;
3827 : :
3828 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3829 : :
3830 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3831 : :
3832 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3833 : : printf("Device doesn't support in-place scatter-gather. "
3834 : : "Test Skipped.\n");
3835 : 0 : return TEST_SKIPPED;
3836 : : }
3837 : :
3838 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3839 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3840 : : printf("Device doesn't support RAW data-path APIs.\n");
3841 : 0 : return TEST_SKIPPED;
3842 : : }
3843 : :
3844 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3845 : : return TEST_SKIPPED;
3846 : :
3847 : : /* Create KASUMI session */
3848 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3849 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3850 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3851 : 0 : tdata->key.data, tdata->key.len,
3852 : 0 : tdata->cipher_iv.len);
3853 [ # # ]: 0 : if (retval < 0)
3854 : : return retval;
3855 : :
3856 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3857 : :
3858 : :
3859 : : /* Append data which is padded to a multiple */
3860 : : /* of the algorithms block size */
3861 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3862 : :
3863 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3864 : : plaintext_pad_len, 10, 0);
3865 : :
3866 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3867 : :
3868 : : /* Create KASUMI operation */
3869 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3870 : 0 : tdata->cipher_iv.len,
3871 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3872 : 0 : tdata->validCipherOffsetInBits.len);
3873 [ # # ]: 0 : if (retval < 0)
3874 : : return retval;
3875 : :
3876 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3877 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3878 : 0 : tdata->cipher_iv.len);
3879 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3880 : : return retval;
3881 : : } else
3882 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3883 : : ut_params->op);
3884 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3885 : :
3886 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3887 : :
3888 [ # # ]: 0 : if (ut_params->obuf)
3889 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3890 : : plaintext_len, buffer);
3891 : : else
3892 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3893 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
3894 : : plaintext_len, buffer);
3895 : :
3896 : : /* Validate obuf */
3897 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3898 : :
3899 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3900 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3901 : : /* Validate obuf */
3902 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3903 : : ciphertext,
3904 : : reference_ciphertext,
3905 : : tdata->validCipherLenInBits.len,
3906 : : "KASUMI Ciphertext data not as expected");
3907 : : return 0;
3908 : : }
3909 : :
3910 : : static int
3911 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3912 : : {
3913 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3914 : : struct crypto_unittest_params *ut_params = &unittest_params;
3915 : :
3916 : : int retval;
3917 : : uint8_t *plaintext, *ciphertext;
3918 : : unsigned plaintext_pad_len;
3919 : : unsigned plaintext_len;
3920 : :
3921 : : /* Verify the capabilities */
3922 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3923 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3924 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3925 : : /* Data-path service does not support OOP */
3926 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3927 : : &cap_idx) == NULL)
3928 : : return TEST_SKIPPED;
3929 : :
3930 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3931 : : return TEST_SKIPPED;
3932 : :
3933 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3934 : : return TEST_SKIPPED;
3935 : :
3936 : : /* Create KASUMI session */
3937 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3938 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3939 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3940 : 0 : tdata->key.data, tdata->key.len,
3941 : 0 : tdata->cipher_iv.len);
3942 [ # # ]: 0 : if (retval < 0)
3943 : : return retval;
3944 : :
3945 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3946 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3947 : :
3948 : : /* Clear mbuf payload */
3949 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3950 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
3951 : :
3952 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3953 : : /* Append data which is padded to a multiple */
3954 : : /* of the algorithms block size */
3955 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3956 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3957 : : plaintext_pad_len);
3958 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3959 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3960 : :
3961 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3962 : :
3963 : : /* Create KASUMI operation */
3964 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3965 : 0 : tdata->cipher_iv.len,
3966 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3967 : 0 : tdata->validCipherOffsetInBits.len);
3968 [ # # ]: 0 : if (retval < 0)
3969 : : return retval;
3970 : :
3971 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3972 : : ut_params->op);
3973 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3974 : :
3975 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3976 [ # # ]: 0 : if (ut_params->obuf)
3977 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3978 : : else
3979 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3980 : :
3981 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3982 : :
3983 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3984 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3985 : : /* Validate obuf */
3986 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3987 : : ciphertext,
3988 : : reference_ciphertext,
3989 : : tdata->validCipherLenInBits.len,
3990 : : "KASUMI Ciphertext data not as expected");
3991 : : return 0;
3992 : : }
3993 : :
3994 : : static int
3995 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3996 : : {
3997 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3998 : : struct crypto_unittest_params *ut_params = &unittest_params;
3999 : :
4000 : : int retval;
4001 : : unsigned int plaintext_pad_len;
4002 : : unsigned int plaintext_len;
4003 : :
4004 : : const uint8_t *ciphertext;
4005 : : uint8_t buffer[2048];
4006 : :
4007 : : struct rte_cryptodev_info dev_info;
4008 : :
4009 : : /* Verify the capabilities */
4010 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4011 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4012 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4013 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4014 : : &cap_idx) == NULL)
4015 : : return TEST_SKIPPED;
4016 : :
4017 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4018 : : return TEST_SKIPPED;
4019 : :
4020 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4021 : : return TEST_SKIPPED;
4022 : :
4023 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4024 : :
4025 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4026 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4027 : : printf("Device doesn't support out-of-place scatter-gather "
4028 : : "in both input and output mbufs. "
4029 : : "Test Skipped.\n");
4030 : 0 : return TEST_SKIPPED;
4031 : : }
4032 : :
4033 : : /* Create KASUMI session */
4034 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4035 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4036 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4037 : 0 : tdata->key.data, tdata->key.len,
4038 : 0 : tdata->cipher_iv.len);
4039 [ # # ]: 0 : if (retval < 0)
4040 : : return retval;
4041 : :
4042 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4043 : : /* Append data which is padded to a multiple */
4044 : : /* of the algorithms block size */
4045 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4046 : :
4047 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4048 : : plaintext_pad_len, 10, 0);
4049 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4050 : : plaintext_pad_len, 3, 0);
4051 : :
4052 : : /* Append data which is padded to a multiple */
4053 : : /* of the algorithms block size */
4054 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4055 : :
4056 : : /* Create KASUMI operation */
4057 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4058 : 0 : tdata->cipher_iv.len,
4059 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4060 : 0 : tdata->validCipherOffsetInBits.len);
4061 [ # # ]: 0 : if (retval < 0)
4062 : : return retval;
4063 : :
4064 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4065 : : ut_params->op);
4066 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4067 : :
4068 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4069 [ # # ]: 0 : if (ut_params->obuf)
4070 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4071 : : plaintext_pad_len, buffer);
4072 : : else
4073 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4074 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4075 : : plaintext_pad_len, buffer);
4076 : :
4077 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4078 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4079 : : /* Validate obuf */
4080 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4081 : : ciphertext,
4082 : : reference_ciphertext,
4083 : : tdata->validCipherLenInBits.len,
4084 : : "KASUMI Ciphertext data not as expected");
4085 : : return 0;
4086 : : }
4087 : :
4088 : :
4089 : : static int
4090 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4091 : : {
4092 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4093 : : struct crypto_unittest_params *ut_params = &unittest_params;
4094 : :
4095 : : int retval;
4096 : : uint8_t *ciphertext, *plaintext;
4097 : : unsigned ciphertext_pad_len;
4098 : : unsigned ciphertext_len;
4099 : :
4100 : : /* Verify the capabilities */
4101 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4102 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4103 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4104 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4105 : : &cap_idx) == NULL)
4106 : : return TEST_SKIPPED;
4107 : :
4108 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4109 : : return TEST_SKIPPED;
4110 : :
4111 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4112 : : return TEST_SKIPPED;
4113 : :
4114 : : /* Create KASUMI session */
4115 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4116 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4117 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4118 : 0 : tdata->key.data, tdata->key.len,
4119 : 0 : tdata->cipher_iv.len);
4120 [ # # ]: 0 : if (retval < 0)
4121 : : return retval;
4122 : :
4123 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4124 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4125 : :
4126 : : /* Clear mbuf payload */
4127 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4128 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4129 : :
4130 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4131 : : /* Append data which is padded to a multiple */
4132 : : /* of the algorithms block size */
4133 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4134 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4135 : : ciphertext_pad_len);
4136 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4137 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4138 : :
4139 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4140 : :
4141 : : /* Create KASUMI operation */
4142 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4143 : 0 : tdata->cipher_iv.len,
4144 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4145 : 0 : tdata->validCipherOffsetInBits.len);
4146 [ # # ]: 0 : if (retval < 0)
4147 : : return retval;
4148 : :
4149 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4150 : : ut_params->op);
4151 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4152 : :
4153 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4154 [ # # ]: 0 : if (ut_params->obuf)
4155 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4156 : : else
4157 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4158 : :
4159 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4160 : :
4161 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4162 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4163 : : /* Validate obuf */
4164 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4165 : : plaintext,
4166 : : reference_plaintext,
4167 : : tdata->validCipherLenInBits.len,
4168 : : "KASUMI Plaintext data not as expected");
4169 : : return 0;
4170 : : }
4171 : :
4172 : : static int
4173 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4174 : : {
4175 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4176 : : struct crypto_unittest_params *ut_params = &unittest_params;
4177 : :
4178 : : int retval;
4179 : : uint8_t *ciphertext, *plaintext;
4180 : : unsigned ciphertext_pad_len;
4181 : : unsigned ciphertext_len;
4182 : : struct rte_cryptodev_info dev_info;
4183 : :
4184 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4185 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4186 : :
4187 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4188 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4189 : : printf("Device doesn't support RAW data-path APIs.\n");
4190 : 0 : return TEST_SKIPPED;
4191 : : }
4192 : :
4193 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4194 : : return TEST_SKIPPED;
4195 : :
4196 : : /* Verify the capabilities */
4197 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4198 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4199 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4200 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4201 : : &cap_idx) == NULL)
4202 : : return TEST_SKIPPED;
4203 : :
4204 : : /* Create KASUMI session */
4205 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4206 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4207 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4208 : 0 : tdata->key.data, tdata->key.len,
4209 : 0 : tdata->cipher_iv.len);
4210 [ # # ]: 0 : if (retval < 0)
4211 : : return retval;
4212 : :
4213 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4214 : :
4215 : : /* Clear mbuf payload */
4216 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4217 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4218 : :
4219 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4220 : : /* Append data which is padded to a multiple */
4221 : : /* of the algorithms block size */
4222 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4223 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4224 : : ciphertext_pad_len);
4225 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4226 : :
4227 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4228 : :
4229 : : /* Create KASUMI operation */
4230 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4231 : 0 : tdata->cipher_iv.len,
4232 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4233 : 0 : tdata->validCipherOffsetInBits.len);
4234 [ # # ]: 0 : if (retval < 0)
4235 : : return retval;
4236 : :
4237 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4238 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4239 : : 0);
4240 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4241 : : return retval;
4242 : : } else
4243 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4244 : : ut_params->op);
4245 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4246 : :
4247 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4248 [ # # ]: 0 : if (ut_params->obuf)
4249 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4250 : : else
4251 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4252 : :
4253 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4254 : :
4255 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4256 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4257 : : /* Validate obuf */
4258 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4259 : : plaintext,
4260 : : reference_plaintext,
4261 : : tdata->validCipherLenInBits.len,
4262 : : "KASUMI Plaintext data not as expected");
4263 : : return 0;
4264 : : }
4265 : :
4266 : : static int
4267 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4268 : : {
4269 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4270 : : struct crypto_unittest_params *ut_params = &unittest_params;
4271 : :
4272 : : int retval;
4273 : : uint8_t *plaintext, *ciphertext;
4274 : : unsigned plaintext_pad_len;
4275 : : unsigned plaintext_len;
4276 : : struct rte_cryptodev_info dev_info;
4277 : :
4278 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4279 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4280 : :
4281 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4282 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4283 : : printf("Device doesn't support RAW data-path APIs.\n");
4284 : 0 : return TEST_SKIPPED;
4285 : : }
4286 : :
4287 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4288 : : return TEST_SKIPPED;
4289 : :
4290 : : /* Verify the capabilities */
4291 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4292 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4293 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4294 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4295 : : &cap_idx) == NULL)
4296 : : return TEST_SKIPPED;
4297 : :
4298 : : /* Create SNOW 3G session */
4299 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4300 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4301 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4302 : 0 : tdata->key.data, tdata->key.len,
4303 : 0 : tdata->cipher_iv.len);
4304 [ # # ]: 0 : if (retval < 0)
4305 : : return retval;
4306 : :
4307 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4308 : :
4309 : : /* Clear mbuf payload */
4310 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4311 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4312 : :
4313 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4314 : : /* Append data which is padded to a multiple of */
4315 : : /* the algorithms block size */
4316 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4317 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4318 : : plaintext_pad_len);
4319 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4320 : :
4321 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4322 : :
4323 : : /* Create SNOW 3G operation */
4324 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4325 : 0 : tdata->cipher_iv.len,
4326 : 0 : tdata->validCipherLenInBits.len,
4327 : : 0);
4328 [ # # ]: 0 : if (retval < 0)
4329 : : return retval;
4330 : :
4331 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4332 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4333 : 0 : tdata->cipher_iv.len);
4334 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4335 : : return retval;
4336 : : } else
4337 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4338 : : ut_params->op);
4339 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4340 : :
4341 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4342 [ # # ]: 0 : if (ut_params->obuf)
4343 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4344 : : else
4345 : : ciphertext = plaintext;
4346 : :
4347 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4348 : :
4349 : : /* Validate obuf */
4350 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4351 : : ciphertext,
4352 : : tdata->ciphertext.data,
4353 : : tdata->validDataLenInBits.len,
4354 : : "SNOW 3G Ciphertext data not as expected");
4355 : : return 0;
4356 : : }
4357 : :
4358 : :
4359 : : static int
4360 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4361 : : {
4362 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4363 : : struct crypto_unittest_params *ut_params = &unittest_params;
4364 : : uint8_t *plaintext, *ciphertext;
4365 : :
4366 : : int retval;
4367 : : unsigned plaintext_pad_len;
4368 : : unsigned plaintext_len;
4369 : : struct rte_cryptodev_info dev_info;
4370 : :
4371 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4372 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4373 : :
4374 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4375 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4376 : : printf("Device does not support RAW data-path APIs.\n");
4377 : 0 : return -ENOTSUP;
4378 : : }
4379 : :
4380 : : /* Verify the capabilities */
4381 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4382 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4383 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4384 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4385 : : &cap_idx) == NULL)
4386 : : return TEST_SKIPPED;
4387 : :
4388 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4389 : : return TEST_SKIPPED;
4390 : :
4391 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4392 : : return TEST_SKIPPED;
4393 : :
4394 : : /* Create SNOW 3G session */
4395 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4396 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4397 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4398 : 0 : tdata->key.data, tdata->key.len,
4399 : 0 : tdata->cipher_iv.len);
4400 [ # # ]: 0 : if (retval < 0)
4401 : : return retval;
4402 : :
4403 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4404 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4405 : :
4406 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4407 : : "Failed to allocate input buffer in mempool");
4408 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4409 : : "Failed to allocate output buffer in mempool");
4410 : :
4411 : : /* Clear mbuf payload */
4412 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4413 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4414 : :
4415 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4416 : : /* Append data which is padded to a multiple of */
4417 : : /* the algorithms block size */
4418 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4419 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4420 : : plaintext_pad_len);
4421 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4422 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4423 : :
4424 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4425 : :
4426 : : /* Create SNOW 3G operation */
4427 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4428 : 0 : tdata->cipher_iv.len,
4429 : 0 : tdata->validCipherLenInBits.len,
4430 : : 0);
4431 [ # # ]: 0 : if (retval < 0)
4432 : : return retval;
4433 : :
4434 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4435 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4436 : 0 : tdata->cipher_iv.len);
4437 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4438 : : return retval;
4439 : : } else
4440 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4441 : : ut_params->op);
4442 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4443 : :
4444 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4445 [ # # ]: 0 : if (ut_params->obuf)
4446 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4447 : : else
4448 : : ciphertext = plaintext;
4449 : :
4450 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4451 : :
4452 : : /* Validate obuf */
4453 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4454 : : ciphertext,
4455 : : tdata->ciphertext.data,
4456 : : tdata->validDataLenInBits.len,
4457 : : "SNOW 3G Ciphertext data not as expected");
4458 : : return 0;
4459 : : }
4460 : :
4461 : : static int
4462 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4463 : : uint8_t sgl_in, uint8_t sgl_out)
4464 : : {
4465 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4466 : : struct crypto_unittest_params *ut_params = &unittest_params;
4467 : :
4468 : : int retval;
4469 : : unsigned int plaintext_pad_len;
4470 : : unsigned int plaintext_len;
4471 : : uint8_t buffer[10000];
4472 : : const uint8_t *ciphertext;
4473 : :
4474 : : struct rte_cryptodev_info dev_info;
4475 : :
4476 : : /* Verify the capabilities */
4477 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4478 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4479 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4480 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4481 : : &cap_idx) == NULL)
4482 : : return TEST_SKIPPED;
4483 : :
4484 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4485 : : return TEST_SKIPPED;
4486 : :
4487 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4488 : : return TEST_SKIPPED;
4489 : :
4490 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4491 : :
4492 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4493 : :
4494 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4495 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4496 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4497 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4498 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4499 : : printf("Device doesn't support out-of-place scatter gather type. "
4500 : : "Test Skipped.\n");
4501 : 0 : return TEST_SKIPPED;
4502 : : }
4503 : :
4504 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4505 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4506 : : printf("Device does not support RAW data-path APIs.\n");
4507 : 0 : return -ENOTSUP;
4508 : : }
4509 : :
4510 : : /* Create SNOW 3G session */
4511 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4512 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4513 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4514 : 0 : tdata->key.data, tdata->key.len,
4515 : 0 : tdata->cipher_iv.len);
4516 [ # # ]: 0 : if (retval < 0)
4517 : : return retval;
4518 : :
4519 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4520 : : /* Append data which is padded to a multiple of */
4521 : : /* the algorithms block size */
4522 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4523 : :
4524 [ # # ]: 0 : if (sgl_in)
4525 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4526 : : plaintext_pad_len, 10, 0);
4527 : : else {
4528 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4529 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4530 : : }
4531 : :
4532 [ # # ]: 0 : if (sgl_out)
4533 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4534 : : plaintext_pad_len, 3, 0);
4535 : : else {
4536 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4537 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4538 : : }
4539 : :
4540 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4541 : : "Failed to allocate input buffer in mempool");
4542 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4543 : : "Failed to allocate output buffer in mempool");
4544 : :
4545 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4546 : :
4547 : : /* Create SNOW 3G operation */
4548 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4549 : 0 : tdata->cipher_iv.len,
4550 : 0 : tdata->validCipherLenInBits.len,
4551 : : 0);
4552 [ # # ]: 0 : if (retval < 0)
4553 : : return retval;
4554 : :
4555 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4556 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4557 : 0 : tdata->cipher_iv.len);
4558 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4559 : : return retval;
4560 : : } else
4561 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4562 : : ut_params->op);
4563 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4564 : :
4565 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4566 [ # # ]: 0 : if (ut_params->obuf)
4567 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4568 : : plaintext_len, buffer);
4569 : : else
4570 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4571 : : plaintext_len, buffer);
4572 : :
4573 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4574 : :
4575 : : /* Validate obuf */
4576 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4577 : : ciphertext,
4578 : : tdata->ciphertext.data,
4579 : : tdata->validDataLenInBits.len,
4580 : : "SNOW 3G Ciphertext data not as expected");
4581 : :
4582 : : return 0;
4583 : : }
4584 : :
4585 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4586 : : static void
4587 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4588 : : {
4589 : : uint8_t curr_byte, prev_byte;
4590 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4591 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4592 : : unsigned i;
4593 : :
4594 : 0 : prev_byte = buffer[0];
4595 : 0 : buffer[0] >>= offset;
4596 : :
4597 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4598 : 0 : curr_byte = buffer[i];
4599 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4600 : 0 : (curr_byte >> offset);
4601 : : prev_byte = curr_byte;
4602 : : }
4603 : 0 : }
4604 : :
4605 : : static int
4606 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4607 : : {
4608 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4609 : : struct crypto_unittest_params *ut_params = &unittest_params;
4610 : : uint8_t *plaintext, *ciphertext;
4611 : : int retval;
4612 : : uint32_t plaintext_len;
4613 : : uint32_t plaintext_pad_len;
4614 : : uint8_t extra_offset = 4;
4615 : : uint8_t *expected_ciphertext_shifted;
4616 : : struct rte_cryptodev_info dev_info;
4617 : :
4618 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4619 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4620 : :
4621 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4622 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4623 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4624 : 0 : return TEST_SKIPPED;
4625 : : }
4626 : :
4627 : : /* Verify the capabilities */
4628 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4629 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4630 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4631 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4632 : : &cap_idx) == NULL)
4633 : : return TEST_SKIPPED;
4634 : :
4635 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4636 : : return TEST_SKIPPED;
4637 : :
4638 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4639 : : return TEST_SKIPPED;
4640 : :
4641 : : /* Create SNOW 3G session */
4642 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4643 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4644 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4645 : 0 : tdata->key.data, tdata->key.len,
4646 : 0 : tdata->cipher_iv.len);
4647 [ # # ]: 0 : if (retval < 0)
4648 : : return retval;
4649 : :
4650 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4651 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4652 : :
4653 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4654 : : "Failed to allocate input buffer in mempool");
4655 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4656 : : "Failed to allocate output buffer in mempool");
4657 : :
4658 : : /* Clear mbuf payload */
4659 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4660 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4661 : :
4662 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4663 : : /*
4664 : : * Append data which is padded to a
4665 : : * multiple of the algorithms block size
4666 : : */
4667 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4668 : :
4669 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4670 : : plaintext_pad_len);
4671 : :
4672 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4673 : :
4674 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4675 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4676 : :
4677 : : #ifdef RTE_APP_TEST_DEBUG
4678 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4679 : : #endif
4680 : : /* Create SNOW 3G operation */
4681 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4682 : 0 : tdata->cipher_iv.len,
4683 : 0 : tdata->validCipherLenInBits.len,
4684 : : extra_offset);
4685 [ # # ]: 0 : if (retval < 0)
4686 : : return retval;
4687 : :
4688 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4689 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4690 : 0 : tdata->cipher_iv.len);
4691 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4692 : : return retval;
4693 : : } else
4694 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4695 : : ut_params->op);
4696 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4697 : :
4698 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4699 [ # # ]: 0 : if (ut_params->obuf)
4700 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4701 : : else
4702 : : ciphertext = plaintext;
4703 : :
4704 : : #ifdef RTE_APP_TEST_DEBUG
4705 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4706 : : #endif
4707 : :
4708 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4709 : :
4710 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4711 : : "failed to reserve memory for ciphertext shifted\n");
4712 : :
4713 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4714 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
4715 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4716 : : extra_offset);
4717 : : /* Validate obuf */
4718 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
4719 : : ciphertext,
4720 : : expected_ciphertext_shifted,
4721 : : tdata->validDataLenInBits.len,
4722 : : extra_offset,
4723 : : "SNOW 3G Ciphertext data not as expected");
4724 : : return 0;
4725 : : }
4726 : :
4727 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4728 : : {
4729 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4730 : : struct crypto_unittest_params *ut_params = &unittest_params;
4731 : :
4732 : : int retval;
4733 : :
4734 : : uint8_t *plaintext, *ciphertext;
4735 : : unsigned ciphertext_pad_len;
4736 : : unsigned ciphertext_len;
4737 : : struct rte_cryptodev_info dev_info;
4738 : :
4739 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4740 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4741 : :
4742 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4743 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4744 : : printf("Device doesn't support RAW data-path APIs.\n");
4745 : 0 : return TEST_SKIPPED;
4746 : : }
4747 : :
4748 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4749 : : return TEST_SKIPPED;
4750 : :
4751 : : /* Verify the capabilities */
4752 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4753 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4754 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4755 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4756 : : &cap_idx) == NULL)
4757 : : return TEST_SKIPPED;
4758 : :
4759 : : /* Create SNOW 3G session */
4760 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4761 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4762 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4763 : 0 : tdata->key.data, tdata->key.len,
4764 : 0 : tdata->cipher_iv.len);
4765 [ # # ]: 0 : if (retval < 0)
4766 : : return retval;
4767 : :
4768 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4769 : :
4770 : : /* Clear mbuf payload */
4771 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4772 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4773 : :
4774 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4775 : : /* Append data which is padded to a multiple of */
4776 : : /* the algorithms block size */
4777 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4778 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4779 : : ciphertext_pad_len);
4780 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4781 : :
4782 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4783 : :
4784 : : /* Create SNOW 3G operation */
4785 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4786 : 0 : tdata->cipher_iv.len,
4787 : 0 : tdata->validCipherLenInBits.len,
4788 : 0 : tdata->cipher.offset_bits);
4789 [ # # ]: 0 : if (retval < 0)
4790 : : return retval;
4791 : :
4792 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4793 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4794 : 0 : tdata->cipher_iv.len);
4795 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4796 : : return retval;
4797 : : } else
4798 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4799 : : ut_params->op);
4800 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4801 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4802 [ # # ]: 0 : if (ut_params->obuf)
4803 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4804 : : else
4805 : : plaintext = ciphertext;
4806 : :
4807 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4808 : :
4809 : : /* Validate obuf */
4810 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
4811 : : tdata->plaintext.data,
4812 : : tdata->validDataLenInBits.len,
4813 : : "SNOW 3G Plaintext data not as expected");
4814 : : return 0;
4815 : : }
4816 : :
4817 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4818 : : {
4819 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4820 : : struct crypto_unittest_params *ut_params = &unittest_params;
4821 : :
4822 : : int retval;
4823 : :
4824 : : uint8_t *plaintext, *ciphertext;
4825 : : unsigned ciphertext_pad_len;
4826 : : unsigned ciphertext_len;
4827 : : struct rte_cryptodev_info dev_info;
4828 : :
4829 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4830 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4831 : :
4832 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4833 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4834 : : printf("Device does not support RAW data-path APIs.\n");
4835 : 0 : return -ENOTSUP;
4836 : : }
4837 : : /* Verify the capabilities */
4838 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4839 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4840 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4841 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4842 : : &cap_idx) == NULL)
4843 : : return TEST_SKIPPED;
4844 : :
4845 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4846 : : return TEST_SKIPPED;
4847 : :
4848 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4849 : : return TEST_SKIPPED;
4850 : :
4851 : : /* Create SNOW 3G session */
4852 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4853 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4854 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4855 : 0 : tdata->key.data, tdata->key.len,
4856 : 0 : tdata->cipher_iv.len);
4857 [ # # ]: 0 : if (retval < 0)
4858 : : return retval;
4859 : :
4860 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4861 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4862 : :
4863 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4864 : : "Failed to allocate input buffer");
4865 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4866 : : "Failed to allocate output buffer");
4867 : :
4868 : : /* Clear mbuf payload */
4869 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4870 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4871 : :
4872 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4873 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
4874 : :
4875 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4876 : : /* Append data which is padded to a multiple of */
4877 : : /* the algorithms block size */
4878 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4879 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4880 : : ciphertext_pad_len);
4881 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4882 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4883 : :
4884 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4885 : :
4886 : : /* Create SNOW 3G operation */
4887 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4888 : 0 : tdata->cipher_iv.len,
4889 : 0 : tdata->validCipherLenInBits.len,
4890 : : 0);
4891 [ # # ]: 0 : if (retval < 0)
4892 : : return retval;
4893 : :
4894 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4895 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4896 : 0 : tdata->cipher_iv.len);
4897 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4898 : : return retval;
4899 : : } else
4900 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4901 : : ut_params->op);
4902 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4903 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4904 [ # # ]: 0 : if (ut_params->obuf)
4905 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4906 : : else
4907 : : plaintext = ciphertext;
4908 : :
4909 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4910 : :
4911 : : /* Validate obuf */
4912 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
4913 : : tdata->plaintext.data,
4914 : : tdata->validDataLenInBits.len,
4915 : : "SNOW 3G Plaintext data not as expected");
4916 : : return 0;
4917 : : }
4918 : :
4919 : : static int
4920 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4921 : : {
4922 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4923 : : struct crypto_unittest_params *ut_params = &unittest_params;
4924 : :
4925 : : int retval;
4926 : :
4927 : : uint8_t *plaintext, *ciphertext;
4928 : : unsigned int plaintext_pad_len;
4929 : : unsigned int plaintext_len;
4930 : :
4931 : : struct rte_cryptodev_info dev_info;
4932 : :
4933 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4934 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4935 : :
4936 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4937 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
4938 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
4939 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4940 : 0 : return TEST_SKIPPED;
4941 : : }
4942 : :
4943 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4944 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4945 : : printf("Device doesn't support RAW data-path APIs.\n");
4946 : 0 : return TEST_SKIPPED;
4947 : : }
4948 : :
4949 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4950 : : return TEST_SKIPPED;
4951 : :
4952 : : /* Check if device supports ZUC EEA3 */
4953 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
4954 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
4955 : : return TEST_SKIPPED;
4956 : :
4957 : : /* Check if device supports ZUC EIA3 */
4958 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
4959 : 0 : tdata->key.len, tdata->auth_iv.len,
4960 : 0 : tdata->digest.len) < 0)
4961 : : return TEST_SKIPPED;
4962 : :
4963 : : /* Create ZUC session */
4964 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
4965 : 0 : ts_params->valid_devs[0],
4966 : : tdata);
4967 [ # # ]: 0 : if (retval != 0)
4968 : : return retval;
4969 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4970 : :
4971 : : /* clear mbuf payload */
4972 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4973 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4974 : :
4975 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4976 : : /* Append data which is padded to a multiple of */
4977 : : /* the algorithms block size */
4978 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4979 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4980 : : plaintext_pad_len);
4981 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4982 : :
4983 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4984 : :
4985 : : /* Create ZUC operation */
4986 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
4987 [ # # ]: 0 : if (retval < 0)
4988 : : return retval;
4989 : :
4990 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4991 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
4992 : 0 : tdata->cipher_iv.len);
4993 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4994 : : return retval;
4995 : : } else
4996 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4997 : : ut_params->op);
4998 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4999 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5000 [ # # ]: 0 : if (ut_params->obuf)
5001 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5002 : : else
5003 : : ciphertext = plaintext;
5004 : :
5005 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5006 : : /* Validate obuf */
5007 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5008 : : ciphertext,
5009 : : tdata->ciphertext.data,
5010 : : tdata->validDataLenInBits.len,
5011 : : "ZUC Ciphertext data not as expected");
5012 : :
5013 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5014 : : uint8_t *,
5015 : : plaintext_pad_len);
5016 : :
5017 : : /* Validate obuf */
5018 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5019 : : ut_params->digest,
5020 : : tdata->digest.data,
5021 : : tdata->digest.len,
5022 : : "ZUC Generated auth tag not as expected");
5023 : : return 0;
5024 : : }
5025 : :
5026 : : static int
5027 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5028 : : {
5029 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5030 : : struct crypto_unittest_params *ut_params = &unittest_params;
5031 : :
5032 : : int retval;
5033 : :
5034 : : uint8_t *plaintext, *ciphertext;
5035 : : unsigned plaintext_pad_len;
5036 : : unsigned plaintext_len;
5037 : : struct rte_cryptodev_info dev_info;
5038 : :
5039 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5040 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5041 : :
5042 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5043 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5044 : : printf("Device doesn't support RAW data-path APIs.\n");
5045 : 0 : return TEST_SKIPPED;
5046 : : }
5047 : :
5048 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5049 : : return TEST_SKIPPED;
5050 : :
5051 : : /* Verify the capabilities */
5052 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5053 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5054 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5055 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5056 : : &cap_idx) == NULL)
5057 : : return TEST_SKIPPED;
5058 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5059 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5060 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5061 : : &cap_idx) == NULL)
5062 : : return TEST_SKIPPED;
5063 : :
5064 : : /* Create SNOW 3G session */
5065 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5066 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5067 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5068 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5069 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5070 : : tdata->key.data, tdata->key.len,
5071 : 0 : tdata->key.data, tdata->key.len,
5072 : 0 : tdata->auth_iv.len, tdata->digest.len,
5073 : 0 : tdata->cipher_iv.len);
5074 [ # # ]: 0 : if (retval != 0)
5075 : : return retval;
5076 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5077 : :
5078 : : /* clear mbuf payload */
5079 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5080 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5081 : :
5082 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5083 : : /* Append data which is padded to a multiple of */
5084 : : /* the algorithms block size */
5085 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5086 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5087 : : plaintext_pad_len);
5088 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5089 : :
5090 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5091 : :
5092 : : /* Create SNOW 3G operation */
5093 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5094 : 0 : tdata->digest.len, tdata->auth_iv.data,
5095 : 0 : tdata->auth_iv.len,
5096 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5097 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5098 : 0 : tdata->validCipherLenInBits.len,
5099 : : 0,
5100 : 0 : tdata->validAuthLenInBits.len,
5101 : : 0
5102 : : );
5103 [ # # ]: 0 : if (retval < 0)
5104 : : return retval;
5105 : :
5106 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5107 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5108 : 0 : tdata->cipher_iv.len);
5109 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5110 : : return retval;
5111 : : } else
5112 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5113 : : ut_params->op);
5114 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5115 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5116 [ # # ]: 0 : if (ut_params->obuf)
5117 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5118 : : else
5119 : : ciphertext = plaintext;
5120 : :
5121 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5122 : : /* Validate obuf */
5123 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5124 : : ciphertext,
5125 : : tdata->ciphertext.data,
5126 : : tdata->validDataLenInBits.len,
5127 : : "SNOW 3G Ciphertext data not as expected");
5128 : :
5129 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5130 : : uint8_t *,
5131 : : plaintext_pad_len);
5132 : :
5133 : : /* Validate obuf */
5134 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5135 : : ut_params->digest,
5136 : : tdata->digest.data,
5137 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5138 : : "SNOW 3G Generated auth tag not as expected");
5139 : : return 0;
5140 : : }
5141 : :
5142 : : static int
5143 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5144 : : uint8_t op_mode, uint8_t verify)
5145 : : {
5146 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5147 : : struct crypto_unittest_params *ut_params = &unittest_params;
5148 : :
5149 : : int retval;
5150 : :
5151 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5152 : : unsigned int plaintext_pad_len;
5153 : : unsigned int plaintext_len;
5154 : : unsigned int ciphertext_pad_len;
5155 : : unsigned int ciphertext_len;
5156 : : unsigned int digest_offset;
5157 : :
5158 : : struct rte_cryptodev_info dev_info;
5159 : :
5160 : : /* Verify the capabilities */
5161 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5162 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5163 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5164 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5165 : : &cap_idx) == NULL)
5166 : : return TEST_SKIPPED;
5167 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5168 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5169 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5170 : : &cap_idx) == NULL)
5171 : : return TEST_SKIPPED;
5172 : :
5173 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5174 : : return TEST_SKIPPED;
5175 : :
5176 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5177 : :
5178 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5179 : :
5180 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5181 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5182 : : printf("Device doesn't support digest encrypted.\n");
5183 : 0 : return TEST_SKIPPED;
5184 : : }
5185 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5186 : : return TEST_SKIPPED;
5187 : : }
5188 : :
5189 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5190 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5191 : : printf("Device doesn't support RAW data-path APIs.\n");
5192 : 0 : return TEST_SKIPPED;
5193 : : }
5194 : :
5195 : : /* Create SNOW 3G session */
5196 : 0 : retval = create_wireless_algo_auth_cipher_session(
5197 : 0 : ts_params->valid_devs[0],
5198 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5199 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5200 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5201 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5202 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5203 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5204 : : tdata->key.data, tdata->key.len,
5205 : 0 : tdata->key.data, tdata->key.len,
5206 : 0 : tdata->auth_iv.len, tdata->digest.len,
5207 : 0 : tdata->cipher_iv.len);
5208 [ # # ]: 0 : if (retval != 0)
5209 : : return retval;
5210 : :
5211 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5212 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5213 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5214 : :
5215 : : /* clear mbuf payload */
5216 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5217 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5218 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5219 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5220 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5221 : :
5222 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5223 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5224 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5225 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5226 : :
5227 [ # # ]: 0 : if (verify) {
5228 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5229 : : ciphertext_pad_len);
5230 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5231 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5232 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5233 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5234 : : ciphertext_len);
5235 : : } else {
5236 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5237 : : plaintext_pad_len);
5238 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5239 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5240 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5241 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5242 : : }
5243 : :
5244 : : /* Create SNOW 3G operation */
5245 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5246 : 0 : tdata->digest.data, tdata->digest.len,
5247 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5248 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5249 : 0 : (tdata->digest.offset_bytes == 0 ?
5250 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5251 : : : tdata->digest.offset_bytes),
5252 : 0 : tdata->validCipherLenInBits.len,
5253 : 0 : tdata->cipher.offset_bits,
5254 : 0 : tdata->validAuthLenInBits.len,
5255 [ # # ]: 0 : tdata->auth.offset_bits,
5256 : : op_mode, 0, verify);
5257 : :
5258 [ # # ]: 0 : if (retval < 0)
5259 : : return retval;
5260 : :
5261 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5262 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5263 : 0 : tdata->cipher_iv.len);
5264 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5265 : : return retval;
5266 : : } else
5267 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5268 : : ut_params->op);
5269 : :
5270 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5271 : :
5272 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5273 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5274 : :
5275 [ # # ]: 0 : if (verify) {
5276 [ # # ]: 0 : if (ut_params->obuf)
5277 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5278 : : uint8_t *);
5279 : : else
5280 : 0 : plaintext = ciphertext +
5281 : 0 : (tdata->cipher.offset_bits >> 3);
5282 : :
5283 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5284 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5285 : 0 : debug_hexdump(stdout, "plaintext expected:",
5286 : 0 : tdata->plaintext.data,
5287 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5288 : : } else {
5289 [ # # ]: 0 : if (ut_params->obuf)
5290 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5291 : : uint8_t *);
5292 : : else
5293 : : ciphertext = plaintext;
5294 : :
5295 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5296 : : ciphertext_len);
5297 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5298 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5299 : :
5300 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5301 : : digest_offset = plaintext_pad_len;
5302 : : else
5303 : : digest_offset = tdata->digest.offset_bytes;
5304 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5305 : : uint8_t *, digest_offset);
5306 : :
5307 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5308 : 0 : tdata->digest.len);
5309 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5310 : 0 : tdata->digest.len);
5311 : : }
5312 : :
5313 : : /* Validate obuf */
5314 [ # # ]: 0 : if (verify) {
5315 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5316 : : plaintext,
5317 : : tdata->plaintext.data,
5318 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5319 : : (tdata->digest.len << 3)),
5320 : : tdata->cipher.offset_bits,
5321 : : "SNOW 3G Plaintext data not as expected");
5322 : : } else {
5323 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5324 : : ciphertext,
5325 : : tdata->ciphertext.data,
5326 : : (tdata->validDataLenInBits.len -
5327 : : tdata->cipher.offset_bits),
5328 : : tdata->cipher.offset_bits,
5329 : : "SNOW 3G Ciphertext data not as expected");
5330 : :
5331 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5332 : : ut_params->digest,
5333 : : tdata->digest.data,
5334 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5335 : : "SNOW 3G Generated auth tag not as expected");
5336 : : }
5337 : : return 0;
5338 : : }
5339 : :
5340 : : static int
5341 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5342 : : uint8_t op_mode, uint8_t verify)
5343 : : {
5344 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5345 : : struct crypto_unittest_params *ut_params = &unittest_params;
5346 : :
5347 : : int retval;
5348 : :
5349 : : const uint8_t *plaintext = NULL;
5350 : : const uint8_t *ciphertext = NULL;
5351 : : const uint8_t *digest = NULL;
5352 : : unsigned int plaintext_pad_len;
5353 : : unsigned int plaintext_len;
5354 : : unsigned int ciphertext_pad_len;
5355 : : unsigned int ciphertext_len;
5356 : : uint8_t buffer[10000];
5357 : : uint8_t digest_buffer[10000];
5358 : :
5359 : : struct rte_cryptodev_info dev_info;
5360 : :
5361 : : /* Verify the capabilities */
5362 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5363 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5364 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5365 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5366 : : &cap_idx) == NULL)
5367 : : return TEST_SKIPPED;
5368 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5369 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5370 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5371 : : &cap_idx) == NULL)
5372 : : return TEST_SKIPPED;
5373 : :
5374 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5375 : : return TEST_SKIPPED;
5376 : :
5377 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5378 : :
5379 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5380 : :
5381 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5382 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5383 : : printf("Device doesn't support in-place scatter-gather "
5384 : : "in both input and output mbufs.\n");
5385 : 0 : return TEST_SKIPPED;
5386 : : }
5387 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5388 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5389 : : printf("Device doesn't support RAW data-path APIs.\n");
5390 : 0 : return TEST_SKIPPED;
5391 : : }
5392 : : } else {
5393 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5394 : : return TEST_SKIPPED;
5395 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5396 : : printf("Device doesn't support out-of-place scatter-gather "
5397 : : "in both input and output mbufs.\n");
5398 : 0 : return TEST_SKIPPED;
5399 : : }
5400 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5401 : : printf("Device doesn't support digest encrypted.\n");
5402 : 0 : return TEST_SKIPPED;
5403 : : }
5404 : : }
5405 : :
5406 : : /* Create SNOW 3G session */
5407 : 0 : retval = create_wireless_algo_auth_cipher_session(
5408 : 0 : ts_params->valid_devs[0],
5409 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5410 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5411 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5412 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5413 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5414 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5415 : : tdata->key.data, tdata->key.len,
5416 : 0 : tdata->key.data, tdata->key.len,
5417 : 0 : tdata->auth_iv.len, tdata->digest.len,
5418 : 0 : tdata->cipher_iv.len);
5419 : :
5420 [ # # ]: 0 : if (retval != 0)
5421 : : return retval;
5422 : :
5423 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5424 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5425 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5426 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5427 : :
5428 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5429 : : plaintext_pad_len, 15, 0);
5430 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5431 : : "Failed to allocate input buffer in mempool");
5432 : :
5433 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5434 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5435 : : plaintext_pad_len, 15, 0);
5436 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5437 : : "Failed to allocate output buffer in mempool");
5438 : : }
5439 : :
5440 [ # # ]: 0 : if (verify) {
5441 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5442 : 0 : tdata->ciphertext.data);
5443 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5444 : : ciphertext_len, buffer);
5445 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5446 : : ciphertext_len);
5447 : : } else {
5448 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5449 : 0 : tdata->plaintext.data);
5450 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5451 : : plaintext_len, buffer);
5452 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5453 : : plaintext_len);
5454 : : }
5455 : : memset(buffer, 0, sizeof(buffer));
5456 : :
5457 : : /* Create SNOW 3G operation */
5458 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5459 : 0 : tdata->digest.data, tdata->digest.len,
5460 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5461 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5462 : 0 : (tdata->digest.offset_bytes == 0 ?
5463 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5464 : : : tdata->digest.offset_bytes),
5465 : 0 : tdata->validCipherLenInBits.len,
5466 : 0 : tdata->cipher.offset_bits,
5467 : 0 : tdata->validAuthLenInBits.len,
5468 [ # # ]: 0 : tdata->auth.offset_bits,
5469 : : op_mode, 1, verify);
5470 : :
5471 [ # # ]: 0 : if (retval < 0)
5472 : : return retval;
5473 : :
5474 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5475 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5476 : 0 : tdata->cipher_iv.len);
5477 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5478 : : return retval;
5479 : : } else
5480 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5481 : : ut_params->op);
5482 : :
5483 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5484 : :
5485 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5486 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5487 : :
5488 [ # # ]: 0 : if (verify) {
5489 [ # # ]: 0 : if (ut_params->obuf)
5490 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5491 : : plaintext_len, buffer);
5492 : : else
5493 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5494 : : plaintext_len, buffer);
5495 : :
5496 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5497 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5498 : 0 : debug_hexdump(stdout, "plaintext expected:",
5499 : 0 : tdata->plaintext.data,
5500 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5501 : : } else {
5502 [ # # ]: 0 : if (ut_params->obuf)
5503 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5504 : : ciphertext_len, buffer);
5505 : : else
5506 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5507 : : ciphertext_len, buffer);
5508 : :
5509 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5510 : : ciphertext_len);
5511 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5512 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5513 : :
5514 [ # # ]: 0 : if (ut_params->obuf)
5515 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5516 : 0 : (tdata->digest.offset_bytes == 0 ?
5517 : : plaintext_pad_len : tdata->digest.offset_bytes),
5518 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5519 : : else
5520 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5521 : 0 : (tdata->digest.offset_bytes == 0 ?
5522 : : plaintext_pad_len : tdata->digest.offset_bytes),
5523 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5524 : :
5525 : 0 : debug_hexdump(stdout, "digest:", digest,
5526 : 0 : tdata->digest.len);
5527 : 0 : debug_hexdump(stdout, "digest expected:",
5528 : 0 : tdata->digest.data, tdata->digest.len);
5529 : : }
5530 : :
5531 : : /* Validate obuf */
5532 [ # # ]: 0 : if (verify) {
5533 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5534 : : plaintext,
5535 : : tdata->plaintext.data,
5536 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5537 : : (tdata->digest.len << 3)),
5538 : : tdata->cipher.offset_bits,
5539 : : "SNOW 3G Plaintext data not as expected");
5540 : : } else {
5541 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5542 : : ciphertext,
5543 : : tdata->ciphertext.data,
5544 : : (tdata->validDataLenInBits.len -
5545 : : tdata->cipher.offset_bits),
5546 : : tdata->cipher.offset_bits,
5547 : : "SNOW 3G Ciphertext data not as expected");
5548 : :
5549 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5550 : : digest,
5551 : : tdata->digest.data,
5552 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5553 : : "SNOW 3G Generated auth tag not as expected");
5554 : : }
5555 : : return 0;
5556 : : }
5557 : :
5558 : : static int
5559 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5560 : : uint8_t op_mode, uint8_t verify)
5561 : : {
5562 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5563 : : struct crypto_unittest_params *ut_params = &unittest_params;
5564 : :
5565 : : int retval;
5566 : :
5567 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5568 : : unsigned int plaintext_pad_len;
5569 : : unsigned int plaintext_len;
5570 : : unsigned int ciphertext_pad_len;
5571 : : unsigned int ciphertext_len;
5572 : : unsigned int digest_offset;
5573 : :
5574 : : struct rte_cryptodev_info dev_info;
5575 : :
5576 : : /* Verify the capabilities */
5577 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5578 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5579 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5580 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5581 : : &cap_idx) == NULL)
5582 : : return TEST_SKIPPED;
5583 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5584 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5585 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5586 : : &cap_idx) == NULL)
5587 : : return TEST_SKIPPED;
5588 : :
5589 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5590 : :
5591 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5592 : :
5593 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5594 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5595 : : printf("Device doesn't support RAW data-path APIs.\n");
5596 : 0 : return TEST_SKIPPED;
5597 : : }
5598 : :
5599 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5600 : : return TEST_SKIPPED;
5601 : :
5602 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5603 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5604 : : return TEST_SKIPPED;
5605 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5606 : : printf("Device doesn't support digest encrypted.\n");
5607 : 0 : return TEST_SKIPPED;
5608 : : }
5609 : : }
5610 : :
5611 : : /* Create KASUMI session */
5612 : 0 : retval = create_wireless_algo_auth_cipher_session(
5613 : 0 : ts_params->valid_devs[0],
5614 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5615 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5616 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5617 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5618 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5619 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5620 : : tdata->key.data, tdata->key.len,
5621 : 0 : tdata->key.data, tdata->key.len,
5622 : 0 : 0, tdata->digest.len,
5623 : 0 : tdata->cipher_iv.len);
5624 : :
5625 [ # # ]: 0 : if (retval != 0)
5626 : : return retval;
5627 : :
5628 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5629 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5630 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5631 : :
5632 : : /* clear mbuf payload */
5633 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5634 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5635 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5636 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5637 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5638 : :
5639 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5640 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5641 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5642 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5643 : :
5644 [ # # ]: 0 : if (verify) {
5645 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5646 : : ciphertext_pad_len);
5647 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5648 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5649 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5650 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5651 : : ciphertext_len);
5652 : : } else {
5653 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5654 : : plaintext_pad_len);
5655 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5656 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5657 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5658 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5659 : : plaintext_len);
5660 : : }
5661 : :
5662 : : /* Create KASUMI operation */
5663 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5664 : 0 : tdata->digest.data, tdata->digest.len,
5665 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5666 : : NULL, 0,
5667 : 0 : (tdata->digest.offset_bytes == 0 ?
5668 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5669 : : : tdata->digest.offset_bytes),
5670 : 0 : tdata->validCipherLenInBits.len,
5671 : 0 : tdata->validCipherOffsetInBits.len,
5672 [ # # ]: 0 : tdata->validAuthLenInBits.len,
5673 : : 0,
5674 : : op_mode, 0, verify);
5675 : :
5676 [ # # ]: 0 : if (retval < 0)
5677 : : return retval;
5678 : :
5679 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5680 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5681 : 0 : tdata->cipher_iv.len);
5682 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5683 : : return retval;
5684 : : } else
5685 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5686 : : ut_params->op);
5687 : :
5688 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5689 : :
5690 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5691 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5692 : :
5693 : :
5694 [ # # ]: 0 : if (verify) {
5695 [ # # ]: 0 : if (ut_params->obuf)
5696 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5697 : : uint8_t *);
5698 : : else
5699 : : plaintext = ciphertext;
5700 : :
5701 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5702 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5703 : 0 : debug_hexdump(stdout, "plaintext expected:",
5704 : 0 : tdata->plaintext.data,
5705 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5706 : : } else {
5707 [ # # ]: 0 : if (ut_params->obuf)
5708 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5709 : : uint8_t *);
5710 : : else
5711 : : ciphertext = plaintext;
5712 : :
5713 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5714 : : ciphertext_len);
5715 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5716 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5717 : :
5718 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5719 : : digest_offset = plaintext_pad_len;
5720 : : else
5721 : : digest_offset = tdata->digest.offset_bytes;
5722 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5723 : : uint8_t *, digest_offset);
5724 : :
5725 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5726 : 0 : tdata->digest.len);
5727 : 0 : debug_hexdump(stdout, "digest expected:",
5728 : 0 : tdata->digest.data, tdata->digest.len);
5729 : : }
5730 : :
5731 : : /* Validate obuf */
5732 [ # # ]: 0 : if (verify) {
5733 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5734 : : plaintext,
5735 : : tdata->plaintext.data,
5736 : : tdata->plaintext.len >> 3,
5737 : : "KASUMI Plaintext data not as expected");
5738 : : } else {
5739 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5740 : : ciphertext,
5741 : : tdata->ciphertext.data,
5742 : : tdata->ciphertext.len >> 3,
5743 : : "KASUMI Ciphertext data not as expected");
5744 : :
5745 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5746 : : ut_params->digest,
5747 : : tdata->digest.data,
5748 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
5749 : : "KASUMI Generated auth tag not as expected");
5750 : : }
5751 : : return 0;
5752 : : }
5753 : :
5754 : : static int
5755 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5756 : : uint8_t op_mode, uint8_t verify)
5757 : : {
5758 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5759 : : struct crypto_unittest_params *ut_params = &unittest_params;
5760 : :
5761 : : int retval;
5762 : :
5763 : : const uint8_t *plaintext = NULL;
5764 : : const uint8_t *ciphertext = NULL;
5765 : : const uint8_t *digest = NULL;
5766 : : unsigned int plaintext_pad_len;
5767 : : unsigned int plaintext_len;
5768 : : unsigned int ciphertext_pad_len;
5769 : : unsigned int ciphertext_len;
5770 : : uint8_t buffer[10000];
5771 : : uint8_t digest_buffer[10000];
5772 : :
5773 : : struct rte_cryptodev_info dev_info;
5774 : :
5775 : : /* Verify the capabilities */
5776 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5777 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5778 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5779 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5780 : : &cap_idx) == NULL)
5781 : : return TEST_SKIPPED;
5782 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5783 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5784 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5785 : : &cap_idx) == NULL)
5786 : : return TEST_SKIPPED;
5787 : :
5788 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5789 : : return TEST_SKIPPED;
5790 : :
5791 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5792 : :
5793 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5794 : :
5795 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5796 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5797 : : printf("Device doesn't support in-place scatter-gather "
5798 : : "in both input and output mbufs.\n");
5799 : 0 : return TEST_SKIPPED;
5800 : : }
5801 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5802 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5803 : : printf("Device doesn't support RAW data-path APIs.\n");
5804 : 0 : return TEST_SKIPPED;
5805 : : }
5806 : : } else {
5807 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5808 : : return TEST_SKIPPED;
5809 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5810 : : printf("Device doesn't support out-of-place scatter-gather "
5811 : : "in both input and output mbufs.\n");
5812 : 0 : return TEST_SKIPPED;
5813 : : }
5814 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5815 : : printf("Device doesn't support digest encrypted.\n");
5816 : 0 : return TEST_SKIPPED;
5817 : : }
5818 : : }
5819 : :
5820 : : /* Create KASUMI session */
5821 : 0 : retval = create_wireless_algo_auth_cipher_session(
5822 : 0 : ts_params->valid_devs[0],
5823 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5824 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5825 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5826 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5827 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5828 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5829 : : tdata->key.data, tdata->key.len,
5830 : 0 : tdata->key.data, tdata->key.len,
5831 : 0 : 0, tdata->digest.len,
5832 : 0 : tdata->cipher_iv.len);
5833 : :
5834 [ # # ]: 0 : if (retval != 0)
5835 : : return retval;
5836 : :
5837 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5838 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5839 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5840 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5841 : :
5842 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5843 : : plaintext_pad_len, 15, 0);
5844 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5845 : : "Failed to allocate input buffer in mempool");
5846 : :
5847 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5848 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5849 : : plaintext_pad_len, 15, 0);
5850 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5851 : : "Failed to allocate output buffer in mempool");
5852 : : }
5853 : :
5854 [ # # ]: 0 : if (verify) {
5855 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5856 : 0 : tdata->ciphertext.data);
5857 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5858 : : ciphertext_len, buffer);
5859 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5860 : : ciphertext_len);
5861 : : } else {
5862 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5863 : 0 : tdata->plaintext.data);
5864 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5865 : : plaintext_len, buffer);
5866 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5867 : : plaintext_len);
5868 : : }
5869 : : memset(buffer, 0, sizeof(buffer));
5870 : :
5871 : : /* Create KASUMI operation */
5872 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5873 : 0 : tdata->digest.data, tdata->digest.len,
5874 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5875 : : NULL, 0,
5876 : 0 : (tdata->digest.offset_bytes == 0 ?
5877 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5878 : : : tdata->digest.offset_bytes),
5879 : 0 : tdata->validCipherLenInBits.len,
5880 : 0 : tdata->validCipherOffsetInBits.len,
5881 [ # # ]: 0 : tdata->validAuthLenInBits.len,
5882 : : 0,
5883 : : op_mode, 1, verify);
5884 : :
5885 [ # # ]: 0 : if (retval < 0)
5886 : : return retval;
5887 : :
5888 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5889 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5890 : 0 : tdata->cipher_iv.len);
5891 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5892 : : return retval;
5893 : : } else
5894 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5895 : : ut_params->op);
5896 : :
5897 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5898 : :
5899 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5900 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5901 : :
5902 [ # # ]: 0 : if (verify) {
5903 [ # # ]: 0 : if (ut_params->obuf)
5904 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5905 : : plaintext_len, buffer);
5906 : : else
5907 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5908 : : plaintext_len, buffer);
5909 : :
5910 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5911 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5912 : 0 : debug_hexdump(stdout, "plaintext expected:",
5913 : 0 : tdata->plaintext.data,
5914 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5915 : : } else {
5916 [ # # ]: 0 : if (ut_params->obuf)
5917 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5918 : : ciphertext_len, buffer);
5919 : : else
5920 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5921 : : ciphertext_len, buffer);
5922 : :
5923 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5924 : : ciphertext_len);
5925 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5926 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5927 : :
5928 [ # # ]: 0 : if (ut_params->obuf)
5929 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5930 : 0 : (tdata->digest.offset_bytes == 0 ?
5931 : : plaintext_pad_len : tdata->digest.offset_bytes),
5932 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5933 : : else
5934 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5935 : 0 : (tdata->digest.offset_bytes == 0 ?
5936 : : plaintext_pad_len : tdata->digest.offset_bytes),
5937 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5938 : :
5939 : 0 : debug_hexdump(stdout, "digest:", digest,
5940 : 0 : tdata->digest.len);
5941 : 0 : debug_hexdump(stdout, "digest expected:",
5942 : 0 : tdata->digest.data, tdata->digest.len);
5943 : : }
5944 : :
5945 : : /* Validate obuf */
5946 [ # # ]: 0 : if (verify) {
5947 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5948 : : plaintext,
5949 : : tdata->plaintext.data,
5950 : : tdata->plaintext.len >> 3,
5951 : : "KASUMI Plaintext data not as expected");
5952 : : } else {
5953 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5954 : : ciphertext,
5955 : : tdata->ciphertext.data,
5956 : : tdata->validDataLenInBits.len,
5957 : : "KASUMI Ciphertext data not as expected");
5958 : :
5959 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5960 : : digest,
5961 : : tdata->digest.data,
5962 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
5963 : : "KASUMI Generated auth tag not as expected");
5964 : : }
5965 : : return 0;
5966 : : }
5967 : :
5968 : : static int
5969 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5970 : : {
5971 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5972 : : struct crypto_unittest_params *ut_params = &unittest_params;
5973 : :
5974 : : int retval;
5975 : :
5976 : : uint8_t *plaintext, *ciphertext;
5977 : : unsigned plaintext_pad_len;
5978 : : unsigned plaintext_len;
5979 : : struct rte_cryptodev_info dev_info;
5980 : :
5981 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5982 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5983 : :
5984 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5985 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5986 : : printf("Device doesn't support RAW data-path APIs.\n");
5987 : 0 : return TEST_SKIPPED;
5988 : : }
5989 : :
5990 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5991 : : return TEST_SKIPPED;
5992 : :
5993 : : /* Verify the capabilities */
5994 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5995 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5996 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5997 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5998 : : &cap_idx) == NULL)
5999 : : return TEST_SKIPPED;
6000 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6001 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6002 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6003 : : &cap_idx) == NULL)
6004 : : return TEST_SKIPPED;
6005 : :
6006 : : /* Create KASUMI session */
6007 : 0 : retval = create_wireless_algo_cipher_auth_session(
6008 : 0 : ts_params->valid_devs[0],
6009 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6010 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6011 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6012 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6013 : : tdata->key.data, tdata->key.len,
6014 : 0 : tdata->key.data, tdata->key.len,
6015 : 0 : 0, tdata->digest.len,
6016 : 0 : tdata->cipher_iv.len);
6017 [ # # ]: 0 : if (retval != 0)
6018 : : return retval;
6019 : :
6020 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6021 : :
6022 : : /* clear mbuf payload */
6023 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6024 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6025 : :
6026 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6027 : : /* Append data which is padded to a multiple of */
6028 : : /* the algorithms block size */
6029 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6030 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6031 : : plaintext_pad_len);
6032 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6033 : :
6034 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6035 : :
6036 : : /* Create KASUMI operation */
6037 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6038 : 0 : tdata->digest.len, NULL, 0,
6039 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6040 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6041 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6042 : 0 : tdata->validCipherOffsetInBits.len,
6043 : 0 : tdata->validAuthLenInBits.len,
6044 : : 0
6045 : : );
6046 [ # # ]: 0 : if (retval < 0)
6047 : : return retval;
6048 : :
6049 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6050 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6051 : 0 : tdata->cipher_iv.len);
6052 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6053 : : return retval;
6054 : : } else
6055 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6056 : : ut_params->op);
6057 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6058 : :
6059 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6060 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6061 : : else
6062 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6063 : :
6064 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6065 : : tdata->validCipherOffsetInBits.len >> 3);
6066 : :
6067 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6068 : : uint8_t *,
6069 : : plaintext_pad_len);
6070 : :
6071 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6072 : : (tdata->validCipherOffsetInBits.len >> 3);
6073 : : /* Validate obuf */
6074 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6075 : : ciphertext,
6076 : : reference_ciphertext,
6077 : : tdata->validCipherLenInBits.len,
6078 : : "KASUMI Ciphertext data not as expected");
6079 : :
6080 : : /* Validate obuf */
6081 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6082 : : ut_params->digest,
6083 : : tdata->digest.data,
6084 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6085 : : "KASUMI Generated auth tag not as expected");
6086 : : return 0;
6087 : : }
6088 : :
6089 : : static int
6090 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6091 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6092 : : const uint16_t key_size, const uint16_t iv_size)
6093 : : {
6094 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6095 : : const struct rte_cryptodev_symmetric_capability *cap;
6096 : :
6097 : : /* Check if device supports the algorithm */
6098 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6099 : 0 : cap_idx.algo.cipher = cipher_algo;
6100 : :
6101 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6102 : : &cap_idx);
6103 : :
6104 [ # # ]: 0 : if (cap == NULL)
6105 : : return -1;
6106 : :
6107 : : /* Check if device supports key size and IV size */
6108 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6109 : : iv_size) < 0) {
6110 : 0 : return -1;
6111 : : }
6112 : :
6113 : : return 0;
6114 : : }
6115 : :
6116 : : static int
6117 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6118 : : const enum rte_crypto_auth_algorithm auth_algo,
6119 : : const uint16_t key_size, const uint16_t iv_size,
6120 : : const uint16_t tag_size)
6121 : : {
6122 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6123 : : const struct rte_cryptodev_symmetric_capability *cap;
6124 : :
6125 : : /* Check if device supports the algorithm */
6126 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6127 : 0 : cap_idx.algo.auth = auth_algo;
6128 : :
6129 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6130 : : &cap_idx);
6131 : :
6132 [ # # ]: 0 : if (cap == NULL)
6133 : : return -1;
6134 : :
6135 : : /* Check if device supports key size and IV size */
6136 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6137 : : tag_size, iv_size) < 0) {
6138 : 0 : return -1;
6139 : : }
6140 : :
6141 : : return 0;
6142 : : }
6143 : :
6144 : : static int
6145 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6146 : : enum rte_crypto_cipher_operation direction)
6147 : : {
6148 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6149 : : struct crypto_unittest_params *ut_params = &unittest_params;
6150 : :
6151 : : int retval;
6152 : : uint8_t *plaintext = NULL;
6153 : : uint8_t *ciphertext = NULL;
6154 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6155 : : unsigned int plaintext_len = 0;
6156 : : unsigned int ciphertext_len = 0;
6157 : : struct rte_cryptodev_info dev_info;
6158 : :
6159 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6160 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6161 : :
6162 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6163 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6164 : : printf("Device doesn't support RAW data-path APIs.\n");
6165 : 0 : return TEST_SKIPPED;
6166 : : }
6167 : :
6168 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6169 : : return TEST_SKIPPED;
6170 : :
6171 : : /* Check if device supports ZUC EEA3 */
6172 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6173 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6174 : : return TEST_SKIPPED;
6175 : :
6176 : : /* Create ZUC session */
6177 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6178 : : direction,
6179 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6180 : 0 : tdata->key.data, tdata->key.len,
6181 : 0 : tdata->cipher_iv.len);
6182 [ # # ]: 0 : if (retval != 0)
6183 : : return retval;
6184 : :
6185 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6186 : :
6187 : : /* Clear mbuf payload */
6188 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6189 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6190 : :
6191 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6192 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6193 : : /* Append data which is padded to a multiple */
6194 : : /* of the algorithms block size */
6195 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6196 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6197 : : plaintext_pad_len);
6198 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6199 : :
6200 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6201 : : } else {
6202 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6203 : : /* Append data which is padded to a multiple */
6204 : : /* of the algorithms block size */
6205 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6206 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6207 : : ciphertext_pad_len);
6208 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6209 : :
6210 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6211 : : }
6212 : :
6213 : : /* Create ZUC operation */
6214 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6215 : 0 : tdata->cipher_iv.len,
6216 : 0 : tdata->plaintext.len,
6217 : 0 : tdata->validCipherOffsetInBits.len);
6218 [ # # ]: 0 : if (retval < 0)
6219 : : return retval;
6220 : :
6221 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6222 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6223 : 0 : tdata->cipher_iv.len);
6224 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6225 : : return retval;
6226 : : } else
6227 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6228 : : ut_params->op);
6229 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6230 : :
6231 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6232 : :
6233 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6234 [ # # ]: 0 : if (ut_params->obuf)
6235 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6236 : : else
6237 : : ciphertext = plaintext;
6238 : :
6239 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6240 : :
6241 : : /* Validate obuf */
6242 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6243 : : ciphertext,
6244 : : tdata->ciphertext.data,
6245 : : tdata->validCipherLenInBits.len,
6246 : : "ZUC Ciphertext data not as expected");
6247 : : } else {
6248 [ # # ]: 0 : if (ut_params->obuf)
6249 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6250 : : else
6251 : : plaintext = ciphertext;
6252 : :
6253 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6254 : :
6255 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6256 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6257 : :
6258 : : /* Validate obuf */
6259 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6260 : : plaintext,
6261 : : reference_plaintext,
6262 : : tdata->validCipherLenInBits.len,
6263 : : "ZUC Plaintext data not as expected");
6264 : : }
6265 : :
6266 : : return 0;
6267 : : }
6268 : :
6269 : : static int
6270 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6271 : : enum rte_crypto_cipher_operation direction)
6272 : : {
6273 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6274 : : struct crypto_unittest_params *ut_params = &unittest_params;
6275 : :
6276 : : int retval;
6277 : :
6278 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6279 : : unsigned int plaintext_len = 0;
6280 : : unsigned int ciphertext_len = 0;
6281 : : const uint8_t *ciphertext, *plaintext;
6282 : : uint8_t buffer[2048];
6283 : : struct rte_cryptodev_info dev_info;
6284 : :
6285 : : /* Check if device supports ZUC EEA3 */
6286 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6287 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6288 : : return TEST_SKIPPED;
6289 : :
6290 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6291 : : return TEST_SKIPPED;
6292 : :
6293 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6294 : :
6295 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6296 : :
6297 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6298 : : printf("Device doesn't support in-place scatter-gather. "
6299 : : "Test Skipped.\n");
6300 : 0 : return TEST_SKIPPED;
6301 : : }
6302 : :
6303 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6304 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6305 : : printf("Device doesn't support RAW data-path APIs.\n");
6306 : 0 : return TEST_SKIPPED;
6307 : : }
6308 : :
6309 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6310 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6311 : :
6312 : : /* Append data which is padded to a multiple */
6313 : : /* of the algorithms block size */
6314 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6315 : :
6316 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6317 : : plaintext_pad_len, 10, 0);
6318 : :
6319 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6320 : 0 : tdata->plaintext.data);
6321 : : } else {
6322 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6323 : :
6324 : : /* Append data which is padded to a multiple */
6325 : : /* of the algorithms block size */
6326 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6327 : :
6328 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6329 : : ciphertext_pad_len, 10, 0);
6330 : :
6331 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6332 : 0 : tdata->ciphertext.data);
6333 : :
6334 : : }
6335 : :
6336 : : /* Create ZUC session */
6337 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6338 : : direction,
6339 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6340 : 0 : tdata->key.data, tdata->key.len,
6341 : 0 : tdata->cipher_iv.len);
6342 [ # # ]: 0 : if (retval < 0)
6343 : : return retval;
6344 : :
6345 : : /* Clear mbuf payload */
6346 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6347 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6348 : : else
6349 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6350 : :
6351 : : /* Create ZUC operation */
6352 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6353 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6354 : 0 : tdata->validCipherOffsetInBits.len);
6355 [ # # ]: 0 : if (retval < 0)
6356 : : return retval;
6357 : :
6358 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6359 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6360 : 0 : tdata->cipher_iv.len);
6361 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6362 : : return retval;
6363 : : } else
6364 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6365 : : ut_params->op);
6366 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6367 : :
6368 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6369 : :
6370 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6371 [ # # ]: 0 : if (ut_params->obuf)
6372 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6373 : : 0, plaintext_len, buffer);
6374 : : else
6375 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6376 : : 0, plaintext_len, buffer);
6377 : :
6378 : : /* Validate obuf */
6379 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6380 : :
6381 : : /* Validate obuf */
6382 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6383 : : ciphertext,
6384 : : tdata->ciphertext.data,
6385 : : tdata->validCipherLenInBits.len,
6386 : : "ZUC Ciphertext data not as expected");
6387 : : } else {
6388 [ # # ]: 0 : if (ut_params->obuf)
6389 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6390 : : 0, ciphertext_len, buffer);
6391 : : else
6392 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6393 : : 0, ciphertext_len, buffer);
6394 : :
6395 : : /* Validate obuf */
6396 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6397 : :
6398 : : /* Validate obuf */
6399 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6400 : : plaintext,
6401 : : tdata->plaintext.data,
6402 : : tdata->validCipherLenInBits.len,
6403 : : "ZUC Plaintext data not as expected");
6404 : : }
6405 : :
6406 : : return 0;
6407 : : }
6408 : :
6409 : : static int
6410 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6411 : : enum rte_crypto_auth_operation auth_op)
6412 : : {
6413 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6414 : : struct crypto_unittest_params *ut_params = &unittest_params;
6415 : :
6416 : : int retval;
6417 : : unsigned plaintext_pad_len;
6418 : : unsigned plaintext_len;
6419 : : uint8_t *plaintext;
6420 : :
6421 : : struct rte_cryptodev_info dev_info;
6422 : :
6423 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6424 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6425 : :
6426 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6427 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6428 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6429 : 0 : return TEST_SKIPPED;
6430 : : }
6431 : :
6432 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6433 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6434 : : printf("Device doesn't support RAW data-path APIs.\n");
6435 : 0 : return TEST_SKIPPED;
6436 : : }
6437 : :
6438 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6439 : : return TEST_SKIPPED;
6440 : :
6441 : : /* Check if device supports ZUC EIA3 */
6442 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6443 : 0 : tdata->key.len, tdata->auth_iv.len,
6444 : 0 : tdata->digest.len) < 0)
6445 : : return TEST_SKIPPED;
6446 : :
6447 : : /* Create ZUC session */
6448 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6449 : 0 : tdata->key.data, tdata->key.len,
6450 : 0 : tdata->auth_iv.len, tdata->digest.len,
6451 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6452 [ # # ]: 0 : if (retval != 0)
6453 : : return retval;
6454 : :
6455 : : /* alloc mbuf and set payload */
6456 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6457 : :
6458 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6459 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6460 : :
6461 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6462 : : /* Append data which is padded to a multiple of */
6463 : : /* the algorithms block size */
6464 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6465 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6466 : : plaintext_pad_len);
6467 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6468 : :
6469 : : /* Create ZUC operation */
6470 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6471 : 0 : tdata->digest.len,
6472 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6473 : : plaintext_pad_len,
6474 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6475 [ # # ]: 0 : if (retval < 0)
6476 : : return retval;
6477 : :
6478 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6479 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6480 : : 0);
6481 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6482 : : return retval;
6483 : : } else
6484 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6485 : : ut_params->op);
6486 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6487 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6488 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6489 : : uint8_t *,
6490 : : plaintext_pad_len);
6491 : :
6492 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6493 : : /* Validate obuf */
6494 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6495 : : ut_params->digest,
6496 : : tdata->digest.data,
6497 : : tdata->digest.len,
6498 : : "ZUC Generated auth tag not as expected");
6499 : : return 0;
6500 : : }
6501 : :
6502 : : /* Validate obuf */
6503 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6504 : : return 0;
6505 : : else
6506 : 0 : return -1;
6507 : :
6508 : : return 0;
6509 : : }
6510 : :
6511 : : static int
6512 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6513 : : uint8_t op_mode, uint8_t verify)
6514 : : {
6515 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6516 : : struct crypto_unittest_params *ut_params = &unittest_params;
6517 : :
6518 : : int retval;
6519 : :
6520 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6521 : : unsigned int plaintext_pad_len;
6522 : : unsigned int plaintext_len;
6523 : : unsigned int ciphertext_pad_len;
6524 : : unsigned int ciphertext_len;
6525 : : unsigned int digest_offset;
6526 : :
6527 : : struct rte_cryptodev_info dev_info;
6528 : :
6529 : : /* Check if device supports ZUC EEA3 */
6530 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6531 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6532 : : return TEST_SKIPPED;
6533 : :
6534 : : /* Check if device supports ZUC EIA3 */
6535 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6536 : 0 : tdata->key.len, tdata->auth_iv.len,
6537 : 0 : tdata->digest.len) < 0)
6538 : : return TEST_SKIPPED;
6539 : :
6540 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6541 : : return TEST_SKIPPED;
6542 : :
6543 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6544 : :
6545 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6546 : :
6547 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6548 : : printf("Device doesn't support digest encrypted.\n");
6549 : 0 : return TEST_SKIPPED;
6550 : : }
6551 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6552 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6553 : : printf("Device doesn't support in-place scatter-gather "
6554 : : "in both input and output mbufs.\n");
6555 : 0 : return TEST_SKIPPED;
6556 : : }
6557 : :
6558 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6559 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6560 : : printf("Device doesn't support RAW data-path APIs.\n");
6561 : 0 : return TEST_SKIPPED;
6562 : : }
6563 : : } else {
6564 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6565 : : return TEST_SKIPPED;
6566 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6567 : : printf("Device doesn't support out-of-place scatter-gather "
6568 : : "in both input and output mbufs.\n");
6569 : 0 : return TEST_SKIPPED;
6570 : : }
6571 : : }
6572 : :
6573 : : /* Create ZUC session */
6574 : 0 : retval = create_wireless_algo_auth_cipher_session(
6575 : 0 : ts_params->valid_devs[0],
6576 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6577 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6578 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6579 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6580 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6581 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6582 : : tdata->key.data, tdata->key.len,
6583 : 0 : tdata->key.data, tdata->key.len,
6584 : 0 : tdata->auth_iv.len, tdata->digest.len,
6585 : 0 : tdata->cipher_iv.len);
6586 : :
6587 [ # # ]: 0 : if (retval != 0)
6588 : : return retval;
6589 : :
6590 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6591 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6592 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6593 : :
6594 : : /* clear mbuf payload */
6595 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6596 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6597 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6598 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6599 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6600 : :
6601 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6602 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6603 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6604 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6605 : :
6606 [ # # ]: 0 : if (verify) {
6607 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6608 : : ciphertext_pad_len);
6609 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6610 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6611 : : ciphertext_len);
6612 : : } else {
6613 : : /* make sure enough space to cover partial digest verify case */
6614 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6615 : : ciphertext_pad_len);
6616 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6617 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6618 : : plaintext_len);
6619 : : }
6620 : :
6621 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6622 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6623 : :
6624 : : /* Create ZUC operation */
6625 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6626 : 0 : tdata->digest.data, tdata->digest.len,
6627 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6628 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6629 : 0 : (tdata->digest.offset_bytes == 0 ?
6630 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6631 : : : tdata->digest.offset_bytes),
6632 : 0 : tdata->validCipherLenInBits.len,
6633 : 0 : tdata->validCipherOffsetInBits.len,
6634 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6635 : : 0,
6636 : : op_mode, 0, verify);
6637 : :
6638 [ # # ]: 0 : if (retval < 0)
6639 : : return retval;
6640 : :
6641 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6642 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6643 : 0 : tdata->cipher_iv.len);
6644 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6645 : : return retval;
6646 : : } else
6647 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6648 : : ut_params->op);
6649 : :
6650 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6651 : :
6652 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6653 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6654 : :
6655 : :
6656 [ # # ]: 0 : if (verify) {
6657 [ # # ]: 0 : if (ut_params->obuf)
6658 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6659 : : uint8_t *);
6660 : : else
6661 : : plaintext = ciphertext;
6662 : :
6663 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6664 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6665 : 0 : debug_hexdump(stdout, "plaintext expected:",
6666 : 0 : tdata->plaintext.data,
6667 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6668 : : } else {
6669 [ # # ]: 0 : if (ut_params->obuf)
6670 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6671 : : uint8_t *);
6672 : : else
6673 : : ciphertext = plaintext;
6674 : :
6675 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6676 : : ciphertext_len);
6677 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6678 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6679 : :
6680 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6681 : : digest_offset = plaintext_pad_len;
6682 : : else
6683 : : digest_offset = tdata->digest.offset_bytes;
6684 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6685 : : uint8_t *, digest_offset);
6686 : :
6687 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6688 : 0 : tdata->digest.len);
6689 : 0 : debug_hexdump(stdout, "digest expected:",
6690 : 0 : tdata->digest.data, tdata->digest.len);
6691 : : }
6692 : :
6693 : : /* Validate obuf */
6694 [ # # ]: 0 : if (verify) {
6695 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6696 : : plaintext,
6697 : : tdata->plaintext.data,
6698 : : tdata->plaintext.len >> 3,
6699 : : "ZUC Plaintext data not as expected");
6700 : : } else {
6701 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6702 : : ciphertext,
6703 : : tdata->ciphertext.data,
6704 : : tdata->ciphertext.len >> 3,
6705 : : "ZUC Ciphertext data not as expected");
6706 : :
6707 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6708 : : ut_params->digest,
6709 : : tdata->digest.data,
6710 : : tdata->digest.len,
6711 : : "ZUC Generated auth tag not as expected");
6712 : : }
6713 : : return 0;
6714 : : }
6715 : :
6716 : : static int
6717 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6718 : : uint8_t op_mode, uint8_t verify)
6719 : : {
6720 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6721 : : struct crypto_unittest_params *ut_params = &unittest_params;
6722 : :
6723 : : int retval;
6724 : :
6725 : : const uint8_t *plaintext = NULL;
6726 : : const uint8_t *ciphertext = NULL;
6727 : : const uint8_t *digest = NULL;
6728 : : unsigned int plaintext_pad_len;
6729 : : unsigned int plaintext_len;
6730 : : unsigned int ciphertext_pad_len;
6731 : : unsigned int ciphertext_len;
6732 : : uint8_t buffer[10000];
6733 : : uint8_t digest_buffer[10000];
6734 : :
6735 : : struct rte_cryptodev_info dev_info;
6736 : :
6737 : : /* Check if device supports ZUC EEA3 */
6738 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6739 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6740 : : return TEST_SKIPPED;
6741 : :
6742 : : /* Check if device supports ZUC EIA3 */
6743 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6744 : 0 : tdata->key.len, tdata->auth_iv.len,
6745 : 0 : tdata->digest.len) < 0)
6746 : : return TEST_SKIPPED;
6747 : :
6748 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6749 : : return TEST_SKIPPED;
6750 : :
6751 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6752 : :
6753 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6754 : :
6755 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6756 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6757 : : printf("Device doesn't support in-place scatter-gather "
6758 : : "in both input and output mbufs.\n");
6759 : 0 : return TEST_SKIPPED;
6760 : : }
6761 : :
6762 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6763 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6764 : : printf("Device doesn't support RAW data-path APIs.\n");
6765 : 0 : return TEST_SKIPPED;
6766 : : }
6767 : : } else {
6768 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6769 : : return TEST_SKIPPED;
6770 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6771 : : printf("Device doesn't support out-of-place scatter-gather "
6772 : : "in both input and output mbufs.\n");
6773 : 0 : return TEST_SKIPPED;
6774 : : }
6775 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6776 : : printf("Device doesn't support digest encrypted.\n");
6777 : 0 : return TEST_SKIPPED;
6778 : : }
6779 : : }
6780 : :
6781 : : /* Create ZUC session */
6782 : 0 : retval = create_wireless_algo_auth_cipher_session(
6783 : 0 : ts_params->valid_devs[0],
6784 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6785 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6786 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6787 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6788 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6789 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6790 : : tdata->key.data, tdata->key.len,
6791 : 0 : tdata->key.data, tdata->key.len,
6792 : 0 : tdata->auth_iv.len, tdata->digest.len,
6793 : 0 : tdata->cipher_iv.len);
6794 : :
6795 [ # # ]: 0 : if (retval != 0)
6796 : : return retval;
6797 : :
6798 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6799 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6800 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6801 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6802 : :
6803 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6804 : : plaintext_pad_len, 15, 0);
6805 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6806 : : "Failed to allocate input buffer in mempool");
6807 : :
6808 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6809 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6810 : : plaintext_pad_len, 15, 0);
6811 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6812 : : "Failed to allocate output buffer in mempool");
6813 : : }
6814 : :
6815 [ # # ]: 0 : if (verify) {
6816 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6817 : 0 : tdata->ciphertext.data);
6818 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6819 : : ciphertext_len, buffer);
6820 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6821 : : ciphertext_len);
6822 : : } else {
6823 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6824 : 0 : tdata->plaintext.data);
6825 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6826 : : plaintext_len, buffer);
6827 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6828 : : plaintext_len);
6829 : : }
6830 : : memset(buffer, 0, sizeof(buffer));
6831 : :
6832 : : /* Create ZUC operation */
6833 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6834 : 0 : tdata->digest.data, tdata->digest.len,
6835 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6836 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6837 : 0 : (tdata->digest.offset_bytes == 0 ?
6838 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6839 : : : tdata->digest.offset_bytes),
6840 : 0 : tdata->validCipherLenInBits.len,
6841 : 0 : tdata->validCipherOffsetInBits.len,
6842 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6843 : : 0,
6844 : : op_mode, 1, verify);
6845 : :
6846 [ # # ]: 0 : if (retval < 0)
6847 : : return retval;
6848 : :
6849 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6850 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6851 : 0 : tdata->cipher_iv.len);
6852 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6853 : : return retval;
6854 : : } else
6855 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6856 : : ut_params->op);
6857 : :
6858 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6859 : :
6860 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6861 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6862 : :
6863 [ # # ]: 0 : if (verify) {
6864 [ # # ]: 0 : if (ut_params->obuf)
6865 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6866 : : plaintext_len, buffer);
6867 : : else
6868 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6869 : : plaintext_len, buffer);
6870 : :
6871 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6872 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6873 : 0 : debug_hexdump(stdout, "plaintext expected:",
6874 : 0 : tdata->plaintext.data,
6875 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6876 : : } else {
6877 [ # # ]: 0 : if (ut_params->obuf)
6878 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6879 : : ciphertext_len, buffer);
6880 : : else
6881 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6882 : : ciphertext_len, buffer);
6883 : :
6884 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6885 : : ciphertext_len);
6886 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6887 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6888 : :
6889 [ # # ]: 0 : if (ut_params->obuf)
6890 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6891 : 0 : (tdata->digest.offset_bytes == 0 ?
6892 : : plaintext_pad_len : tdata->digest.offset_bytes),
6893 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6894 : : else
6895 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6896 : 0 : (tdata->digest.offset_bytes == 0 ?
6897 : : plaintext_pad_len : tdata->digest.offset_bytes),
6898 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6899 : :
6900 : 0 : debug_hexdump(stdout, "digest:", digest,
6901 : 0 : tdata->digest.len);
6902 : 0 : debug_hexdump(stdout, "digest expected:",
6903 : 0 : tdata->digest.data, tdata->digest.len);
6904 : : }
6905 : :
6906 : : /* Validate obuf */
6907 [ # # ]: 0 : if (verify) {
6908 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6909 : : plaintext,
6910 : : tdata->plaintext.data,
6911 : : tdata->plaintext.len >> 3,
6912 : : "ZUC Plaintext data not as expected");
6913 : : } else {
6914 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6915 : : ciphertext,
6916 : : tdata->ciphertext.data,
6917 : : tdata->validDataLenInBits.len,
6918 : : "ZUC Ciphertext data not as expected");
6919 : :
6920 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6921 : : digest,
6922 : : tdata->digest.data,
6923 : : tdata->digest.len,
6924 : : "ZUC Generated auth tag not as expected");
6925 : : }
6926 : : return 0;
6927 : : }
6928 : :
6929 : : static int
6930 : 0 : test_kasumi_encryption_test_case_1(void)
6931 : : {
6932 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
6933 : : }
6934 : :
6935 : : static int
6936 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
6937 : : {
6938 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6939 : : }
6940 : :
6941 : : static int
6942 : 0 : test_kasumi_encryption_test_case_1_oop(void)
6943 : : {
6944 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
6945 : : }
6946 : :
6947 : : static int
6948 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
6949 : : {
6950 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6951 : : }
6952 : :
6953 : : static int
6954 : 0 : test_kasumi_encryption_test_case_2(void)
6955 : : {
6956 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
6957 : : }
6958 : :
6959 : : static int
6960 : 0 : test_kasumi_encryption_test_case_3(void)
6961 : : {
6962 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
6963 : : }
6964 : :
6965 : : static int
6966 : 0 : test_kasumi_encryption_test_case_4(void)
6967 : : {
6968 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
6969 : : }
6970 : :
6971 : : static int
6972 : 0 : test_kasumi_encryption_test_case_5(void)
6973 : : {
6974 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
6975 : : }
6976 : :
6977 : : static int
6978 : 0 : test_kasumi_decryption_test_case_1(void)
6979 : : {
6980 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
6981 : : }
6982 : :
6983 : : static int
6984 : 0 : test_kasumi_decryption_test_case_1_oop(void)
6985 : : {
6986 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
6987 : : }
6988 : :
6989 : : static int
6990 : 0 : test_kasumi_decryption_test_case_2(void)
6991 : : {
6992 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
6993 : : }
6994 : :
6995 : : static int
6996 : 0 : test_kasumi_decryption_test_case_3(void)
6997 : : {
6998 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6999 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7000 : : return TEST_SKIPPED;
7001 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7002 : : }
7003 : :
7004 : : static int
7005 : 0 : test_kasumi_decryption_test_case_4(void)
7006 : : {
7007 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7008 : : }
7009 : :
7010 : : static int
7011 : 0 : test_kasumi_decryption_test_case_5(void)
7012 : : {
7013 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7014 : : }
7015 : : static int
7016 : 0 : test_snow3g_encryption_test_case_1(void)
7017 : : {
7018 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7019 : : }
7020 : :
7021 : : static int
7022 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7023 : : {
7024 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7025 : : }
7026 : :
7027 : : static int
7028 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7029 : : {
7030 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7031 : : }
7032 : :
7033 : : static int
7034 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7035 : : {
7036 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7037 : : }
7038 : :
7039 : : static int
7040 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7041 : : {
7042 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7043 : : }
7044 : :
7045 : : static int
7046 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7047 : : {
7048 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7049 : : }
7050 : :
7051 : : static int
7052 : 0 : test_snow3g_encryption_test_case_2(void)
7053 : : {
7054 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7055 : : }
7056 : :
7057 : : static int
7058 : 0 : test_snow3g_encryption_test_case_3(void)
7059 : : {
7060 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7061 : : }
7062 : :
7063 : : static int
7064 : 0 : test_snow3g_encryption_test_case_4(void)
7065 : : {
7066 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7067 : : }
7068 : :
7069 : : static int
7070 : 0 : test_snow3g_encryption_test_case_5(void)
7071 : : {
7072 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7073 : : }
7074 : :
7075 : : static int
7076 : 0 : test_snow3g_decryption_test_case_1(void)
7077 : : {
7078 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7079 : : }
7080 : :
7081 : : static int
7082 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7083 : : {
7084 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7085 : : }
7086 : :
7087 : : static int
7088 : 0 : test_snow3g_decryption_test_case_2(void)
7089 : : {
7090 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7091 : : }
7092 : :
7093 : : static int
7094 : 0 : test_snow3g_decryption_test_case_3(void)
7095 : : {
7096 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7097 : : }
7098 : :
7099 : : static int
7100 : 0 : test_snow3g_decryption_test_case_4(void)
7101 : : {
7102 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7103 : : }
7104 : :
7105 : : static int
7106 : 0 : test_snow3g_decryption_test_case_5(void)
7107 : : {
7108 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7109 : : }
7110 : :
7111 : : /*
7112 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7113 : : * Pattern digest from snow3g_test_data must be allocated as
7114 : : * 4 last bytes in plaintext.
7115 : : */
7116 : : static void
7117 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7118 : : struct snow3g_hash_test_data *output)
7119 : : {
7120 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7121 : 0 : output->key.len = pattern->key.len;
7122 : :
7123 : 0 : memcpy(output->key.data,
7124 : 0 : pattern->key.data, pattern->key.len);
7125 : :
7126 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7127 : :
7128 : 0 : memcpy(output->auth_iv.data,
7129 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7130 : :
7131 : 0 : output->plaintext.len = pattern->plaintext.len;
7132 : :
7133 : 0 : memcpy(output->plaintext.data,
7134 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7135 : :
7136 : 0 : output->digest.len = pattern->digest.len;
7137 : :
7138 : 0 : memcpy(output->digest.data,
7139 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7140 : : pattern->digest.len);
7141 : :
7142 : 0 : output->validAuthLenInBits.len =
7143 : 0 : pattern->validAuthLenInBits.len;
7144 : : }
7145 : 0 : }
7146 : :
7147 : : /*
7148 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7149 : : */
7150 : : static int
7151 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7152 : : {
7153 : : int ret;
7154 : : struct snow3g_hash_test_data snow3g_hash_data;
7155 : : struct rte_cryptodev_info dev_info;
7156 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7157 : :
7158 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7159 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7160 : :
7161 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7162 : : printf("Device doesn't support encrypted digest operations.\n");
7163 : 0 : return TEST_SKIPPED;
7164 : : }
7165 : :
7166 : : /*
7167 : : * Function prepare data for hash verification test case.
7168 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7169 : : */
7170 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7171 : :
7172 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7173 [ # # ]: 0 : if (ret != 0)
7174 : : return ret;
7175 : :
7176 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7177 : : }
7178 : :
7179 : : static int
7180 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7181 : : {
7182 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7183 : : }
7184 : :
7185 : : static int
7186 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7187 : : {
7188 : 0 : return test_snow3g_auth_cipher(
7189 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7190 : : }
7191 : :
7192 : : static int
7193 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7194 : : {
7195 : 0 : return test_snow3g_auth_cipher(
7196 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7197 : : }
7198 : :
7199 : : static int
7200 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7201 : : {
7202 : 0 : return test_snow3g_auth_cipher(
7203 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7204 : : }
7205 : :
7206 : : static int
7207 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7208 : : {
7209 : 0 : return test_snow3g_auth_cipher(
7210 : : &snow3g_auth_cipher_partial_digest_encryption,
7211 : : IN_PLACE, 0);
7212 : : }
7213 : :
7214 : : static int
7215 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7216 : : {
7217 : 0 : return test_snow3g_auth_cipher(
7218 : : &snow3g_auth_cipher_partial_digest_encryption,
7219 : : OUT_OF_PLACE, 0);
7220 : : }
7221 : :
7222 : : static int
7223 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7224 : : {
7225 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7226 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7227 : : return TEST_SKIPPED;
7228 : 0 : return test_snow3g_auth_cipher_sgl(
7229 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7230 : : }
7231 : :
7232 : : static int
7233 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7234 : : {
7235 : 0 : return test_snow3g_auth_cipher_sgl(
7236 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7237 : : }
7238 : :
7239 : : static int
7240 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7241 : : {
7242 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7243 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7244 : : return TEST_SKIPPED;
7245 : 0 : return test_snow3g_auth_cipher_sgl(
7246 : : &snow3g_auth_cipher_partial_digest_encryption,
7247 : : IN_PLACE, 0);
7248 : : }
7249 : :
7250 : : static int
7251 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7252 : : {
7253 : 0 : return test_snow3g_auth_cipher_sgl(
7254 : : &snow3g_auth_cipher_partial_digest_encryption,
7255 : : OUT_OF_PLACE, 0);
7256 : : }
7257 : :
7258 : : static int
7259 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7260 : : {
7261 : 0 : return test_snow3g_auth_cipher(
7262 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7263 : : }
7264 : :
7265 : : static int
7266 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7267 : : {
7268 : 0 : return test_snow3g_auth_cipher(
7269 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7270 : : }
7271 : :
7272 : : static int
7273 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7274 : : {
7275 : 0 : return test_snow3g_auth_cipher_sgl(
7276 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7277 : : }
7278 : :
7279 : : static int
7280 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7281 : : {
7282 : 0 : return test_snow3g_auth_cipher_sgl(
7283 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7284 : : }
7285 : :
7286 : : static int
7287 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7288 : : {
7289 : 0 : return test_snow3g_auth_cipher(
7290 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7291 : : }
7292 : :
7293 : : static int
7294 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7295 : : {
7296 : 0 : return test_snow3g_auth_cipher(
7297 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7298 : : }
7299 : :
7300 : : static int
7301 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7302 : : {
7303 : 0 : return test_snow3g_auth_cipher(
7304 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7305 : : }
7306 : :
7307 : : static int
7308 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7309 : : {
7310 : 0 : return test_snow3g_auth_cipher(
7311 : : &snow3g_auth_cipher_partial_digest_encryption,
7312 : : IN_PLACE, 1);
7313 : : }
7314 : :
7315 : : static int
7316 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7317 : : {
7318 : 0 : return test_snow3g_auth_cipher(
7319 : : &snow3g_auth_cipher_partial_digest_encryption,
7320 : : OUT_OF_PLACE, 1);
7321 : : }
7322 : :
7323 : : static int
7324 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7325 : : {
7326 : 0 : return test_snow3g_auth_cipher_sgl(
7327 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7328 : : }
7329 : :
7330 : : static int
7331 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7332 : : {
7333 : 0 : return test_snow3g_auth_cipher_sgl(
7334 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7335 : : }
7336 : :
7337 : : static int
7338 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7339 : : {
7340 : 0 : return test_snow3g_auth_cipher_sgl(
7341 : : &snow3g_auth_cipher_partial_digest_encryption,
7342 : : IN_PLACE, 1);
7343 : : }
7344 : :
7345 : : static int
7346 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7347 : : {
7348 : 0 : return test_snow3g_auth_cipher_sgl(
7349 : : &snow3g_auth_cipher_partial_digest_encryption,
7350 : : OUT_OF_PLACE, 1);
7351 : : }
7352 : :
7353 : : static int
7354 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7355 : : {
7356 : 0 : return test_snow3g_auth_cipher(
7357 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7358 : : }
7359 : :
7360 : : static int
7361 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7362 : : {
7363 : 0 : return test_snow3g_auth_cipher(
7364 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7365 : : }
7366 : :
7367 : : static int
7368 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7369 : : {
7370 : 0 : return test_snow3g_auth_cipher_sgl(
7371 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7372 : : }
7373 : :
7374 : : static int
7375 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7376 : : {
7377 : 0 : return test_snow3g_auth_cipher_sgl(
7378 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7379 : : }
7380 : :
7381 : : static int
7382 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7383 : : {
7384 : 0 : return test_snow3g_auth_cipher(
7385 : : &snow3g_test_case_7, IN_PLACE, 0);
7386 : : }
7387 : :
7388 : : static int
7389 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7390 : : {
7391 : 0 : return test_kasumi_auth_cipher(
7392 : : &kasumi_test_case_3, IN_PLACE, 0);
7393 : : }
7394 : :
7395 : : static int
7396 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7397 : : {
7398 : 0 : return test_kasumi_auth_cipher(
7399 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7400 : : }
7401 : :
7402 : : static int
7403 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7404 : : {
7405 : 0 : return test_kasumi_auth_cipher(
7406 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7407 : : }
7408 : :
7409 : : static int
7410 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7411 : : {
7412 : 0 : return test_kasumi_auth_cipher_sgl(
7413 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7414 : : }
7415 : :
7416 : : static int
7417 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7418 : : {
7419 : 0 : return test_kasumi_auth_cipher_sgl(
7420 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7421 : : }
7422 : :
7423 : : static int
7424 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7425 : : {
7426 : 0 : return test_kasumi_auth_cipher(
7427 : : &kasumi_test_case_3, IN_PLACE, 1);
7428 : : }
7429 : :
7430 : : static int
7431 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7432 : : {
7433 : 0 : return test_kasumi_auth_cipher(
7434 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7435 : : }
7436 : :
7437 : : static int
7438 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7439 : : {
7440 : 0 : return test_kasumi_auth_cipher(
7441 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7442 : : }
7443 : :
7444 : : static int
7445 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7446 : : {
7447 : 0 : return test_kasumi_auth_cipher_sgl(
7448 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7449 : : }
7450 : :
7451 : : static int
7452 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7453 : : {
7454 : 0 : return test_kasumi_auth_cipher_sgl(
7455 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7456 : : }
7457 : :
7458 : : static int
7459 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7460 : : {
7461 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7462 : : }
7463 : :
7464 : : static int
7465 : 0 : test_zuc_encryption_test_case_1(void)
7466 : : {
7467 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7468 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7469 : : }
7470 : :
7471 : : static int
7472 : 0 : test_zuc_encryption_test_case_2(void)
7473 : : {
7474 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7475 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7476 : : }
7477 : :
7478 : : static int
7479 : 0 : test_zuc_encryption_test_case_3(void)
7480 : : {
7481 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7482 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7483 : : }
7484 : :
7485 : : static int
7486 : 0 : test_zuc_encryption_test_case_4(void)
7487 : : {
7488 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7489 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7490 : : }
7491 : :
7492 : : static int
7493 : 0 : test_zuc_encryption_test_case_5(void)
7494 : : {
7495 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7496 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7497 : : }
7498 : :
7499 : : static int
7500 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7501 : : {
7502 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7503 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7504 : : }
7505 : :
7506 : : static int
7507 : 0 : test_zuc_decryption_test_case_1(void)
7508 : : {
7509 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7510 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7511 : : }
7512 : :
7513 : : static int
7514 : 0 : test_zuc_decryption_test_case_2(void)
7515 : : {
7516 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7517 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7518 : : }
7519 : :
7520 : : static int
7521 : 0 : test_zuc_decryption_test_case_3(void)
7522 : : {
7523 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7524 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7525 : : }
7526 : :
7527 : : static int
7528 : 0 : test_zuc_decryption_test_case_4(void)
7529 : : {
7530 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7531 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7532 : : }
7533 : :
7534 : : static int
7535 : 0 : test_zuc_decryption_test_case_5(void)
7536 : : {
7537 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7538 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7539 : : }
7540 : :
7541 : : static int
7542 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7543 : : {
7544 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7545 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7546 : : }
7547 : :
7548 : : static int
7549 : 0 : test_zuc_hash_generate_test_case_1(void)
7550 : : {
7551 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7552 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7553 : : }
7554 : :
7555 : : static int
7556 : 0 : test_zuc_hash_generate_test_case_2(void)
7557 : : {
7558 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7559 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7560 : : }
7561 : :
7562 : : static int
7563 : 0 : test_zuc_hash_generate_test_case_3(void)
7564 : : {
7565 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7566 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7567 : : }
7568 : :
7569 : : static int
7570 : 0 : test_zuc_hash_generate_test_case_4(void)
7571 : : {
7572 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7573 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7574 : : }
7575 : :
7576 : : static int
7577 : 0 : test_zuc_hash_generate_test_case_5(void)
7578 : : {
7579 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7580 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7581 : : }
7582 : :
7583 : : static int
7584 : 0 : test_zuc_hash_generate_test_case_6(void)
7585 : : {
7586 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7587 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7588 : : }
7589 : :
7590 : : static int
7591 : 0 : test_zuc_hash_generate_test_case_7(void)
7592 : : {
7593 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7594 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7595 : : }
7596 : :
7597 : : static int
7598 : 0 : test_zuc_hash_generate_test_case_8(void)
7599 : : {
7600 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7601 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7602 : : }
7603 : :
7604 : : static int
7605 : 0 : test_zuc_hash_verify_test_case_1(void)
7606 : : {
7607 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7608 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7609 : : }
7610 : :
7611 : : static int
7612 : 0 : test_zuc_hash_verify_test_case_2(void)
7613 : : {
7614 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7615 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7616 : : }
7617 : :
7618 : : static int
7619 : 0 : test_zuc_hash_verify_test_case_3(void)
7620 : : {
7621 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7622 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7623 : : }
7624 : :
7625 : : static int
7626 : 0 : test_zuc_hash_verify_test_case_4(void)
7627 : : {
7628 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7629 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7630 : : }
7631 : :
7632 : : static int
7633 : 0 : test_zuc_hash_verify_test_case_5(void)
7634 : : {
7635 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7636 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7637 : : }
7638 : :
7639 : : static int
7640 : 0 : test_zuc_hash_verify_test_case_6(void)
7641 : : {
7642 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7643 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7644 : : }
7645 : :
7646 : : static int
7647 : 0 : test_zuc_hash_verify_test_case_7(void)
7648 : : {
7649 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7650 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7651 : : }
7652 : :
7653 : : static int
7654 : 0 : test_zuc_hash_verify_test_case_8(void)
7655 : : {
7656 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7657 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7658 : : }
7659 : :
7660 : : static int
7661 : 0 : test_zuc_cipher_auth_test_case_1(void)
7662 : : {
7663 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7664 : : }
7665 : :
7666 : : static int
7667 : 0 : test_zuc_cipher_auth_test_case_2(void)
7668 : : {
7669 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7670 : : }
7671 : :
7672 : : static int
7673 : 0 : test_zuc_auth_cipher_test_case_1(void)
7674 : : {
7675 : 0 : return test_zuc_auth_cipher(
7676 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7677 : : }
7678 : :
7679 : : static int
7680 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
7681 : : {
7682 : 0 : return test_zuc_auth_cipher(
7683 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7684 : : }
7685 : :
7686 : : static int
7687 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
7688 : : {
7689 : 0 : return test_zuc_auth_cipher_sgl(
7690 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7691 : : }
7692 : :
7693 : : static int
7694 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7695 : : {
7696 : 0 : return test_zuc_auth_cipher_sgl(
7697 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7698 : : }
7699 : :
7700 : : static int
7701 : 0 : test_zuc_auth_cipher_test_case_2(void)
7702 : : {
7703 : 0 : return test_zuc_auth_cipher(
7704 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7705 : : }
7706 : :
7707 : : static int
7708 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
7709 : : {
7710 : 0 : return test_zuc_auth_cipher(
7711 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7712 : : }
7713 : :
7714 : : static int
7715 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
7716 : : {
7717 : 0 : return test_zuc_auth_cipher(
7718 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7719 : : }
7720 : :
7721 : : static int
7722 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
7723 : : {
7724 : 0 : return test_zuc_auth_cipher(
7725 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7726 : : }
7727 : :
7728 : : static int
7729 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7730 : : {
7731 : 0 : return test_zuc_auth_cipher_sgl(
7732 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7733 : : }
7734 : :
7735 : : static int
7736 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7737 : : {
7738 : 0 : return test_zuc_auth_cipher_sgl(
7739 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7740 : : }
7741 : :
7742 : : static int
7743 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
7744 : : {
7745 : 0 : return test_zuc_auth_cipher(
7746 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7747 : : }
7748 : :
7749 : : static int
7750 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
7751 : : {
7752 : 0 : return test_zuc_auth_cipher(
7753 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7754 : : }
7755 : :
7756 : : static int
7757 : 0 : test_zuc256_encryption_test_case_1(void)
7758 : : {
7759 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7760 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7761 : : }
7762 : :
7763 : : static int
7764 : 0 : test_zuc256_encryption_test_case_2(void)
7765 : : {
7766 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7767 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7768 : : }
7769 : :
7770 : : static int
7771 : 0 : test_zuc256_decryption_test_case_1(void)
7772 : : {
7773 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7774 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7775 : : }
7776 : :
7777 : : static int
7778 : 0 : test_zuc256_decryption_test_case_2(void)
7779 : : {
7780 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7781 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7782 : : }
7783 : :
7784 : : static int
7785 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
7786 : : {
7787 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7788 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7789 : : }
7790 : :
7791 : : static int
7792 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
7793 : : {
7794 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7795 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7796 : : }
7797 : :
7798 : : static int
7799 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
7800 : : {
7801 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7802 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7803 : : }
7804 : :
7805 : : static int
7806 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
7807 : : {
7808 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7809 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7810 : : }
7811 : :
7812 : : static int
7813 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
7814 : : {
7815 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7816 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7817 : : }
7818 : :
7819 : : static int
7820 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
7821 : : {
7822 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7823 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7824 : : }
7825 : :
7826 : : static int
7827 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
7828 : : {
7829 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7830 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7831 : : }
7832 : :
7833 : : static int
7834 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
7835 : : {
7836 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7837 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7838 : : }
7839 : :
7840 : : static int
7841 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
7842 : : {
7843 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7844 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7845 : : }
7846 : :
7847 : : static int
7848 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
7849 : : {
7850 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7851 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7852 : : }
7853 : :
7854 : : static int
7855 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7856 : : {
7857 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7858 : : }
7859 : :
7860 : : static int
7861 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7862 : : {
7863 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7864 : : }
7865 : :
7866 : : static int
7867 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
7868 : : {
7869 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
7870 : : }
7871 : :
7872 : : static int
7873 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
7874 : : {
7875 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
7876 : : }
7877 : :
7878 : : static int
7879 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
7880 : : {
7881 : 0 : return test_zuc_auth_cipher(
7882 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
7883 : : }
7884 : :
7885 : : static int
7886 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
7887 : : {
7888 : 0 : return test_zuc_auth_cipher(
7889 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
7890 : : }
7891 : :
7892 : : static int
7893 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
7894 : : {
7895 : 0 : return test_zuc_auth_cipher(
7896 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
7897 : : }
7898 : :
7899 : : static int
7900 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
7901 : : {
7902 : 0 : return test_zuc_auth_cipher(
7903 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
7904 : : }
7905 : :
7906 : : static int
7907 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
7908 : : {
7909 : 0 : return test_zuc_auth_cipher(
7910 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
7911 : : }
7912 : :
7913 : : static int
7914 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
7915 : : {
7916 : 0 : return test_zuc_auth_cipher(
7917 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
7918 : : }
7919 : :
7920 : : static int
7921 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
7922 : : {
7923 : 0 : return test_zuc_auth_cipher(
7924 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
7925 : : }
7926 : :
7927 : : static int
7928 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
7929 : : {
7930 : 0 : return test_zuc_auth_cipher(
7931 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
7932 : : }
7933 : :
7934 : : static int
7935 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7936 : : {
7937 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
7938 : :
7939 : : struct rte_cryptodev_sym_capability_idx cap_idx;
7940 : :
7941 : : /* Check if device supports particular cipher algorithm */
7942 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7943 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
7944 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7945 : : return TEST_SKIPPED;
7946 : :
7947 : : /* Check if device supports particular hash algorithm */
7948 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7949 : 24 : cap_idx.algo.auth = tdata->auth_algo;
7950 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7951 : 12 : return TEST_SKIPPED;
7952 : :
7953 : : return 0;
7954 : : }
7955 : :
7956 : : static int
7957 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7958 : : uint8_t op_mode, uint8_t verify)
7959 : : {
7960 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7961 : : struct crypto_unittest_params *ut_params = &unittest_params;
7962 : :
7963 : : int retval;
7964 : :
7965 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
7966 : : unsigned int plaintext_pad_len;
7967 : : unsigned int plaintext_len;
7968 : : unsigned int ciphertext_pad_len;
7969 : : unsigned int ciphertext_len;
7970 : : unsigned int digest_offset;
7971 : :
7972 : : struct rte_cryptodev_info dev_info;
7973 : : struct rte_crypto_op *op;
7974 : :
7975 : : /* Check if device supports particular algorithms separately */
7976 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
7977 : : return TEST_SKIPPED;
7978 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7979 : : return TEST_SKIPPED;
7980 : :
7981 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7982 : : return TEST_SKIPPED;
7983 : :
7984 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7985 : :
7986 : 8 : uint64_t feat_flags = dev_info.feature_flags;
7987 : :
7988 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7989 : : printf("Device doesn't support digest encrypted.\n");
7990 : 8 : return TEST_SKIPPED;
7991 : : }
7992 : :
7993 : : /* Create the session */
7994 [ # # ]: 0 : if (verify)
7995 : 0 : retval = create_wireless_algo_cipher_auth_session(
7996 : 0 : ts_params->valid_devs[0],
7997 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
7998 : : RTE_CRYPTO_AUTH_OP_VERIFY,
7999 : 0 : tdata->auth_algo,
8000 : 0 : tdata->cipher_algo,
8001 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8002 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8003 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8004 : 0 : tdata->cipher_iv.len);
8005 : : else
8006 : 0 : retval = create_wireless_algo_auth_cipher_session(
8007 : 0 : ts_params->valid_devs[0],
8008 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8009 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8010 : 0 : tdata->auth_algo,
8011 : 0 : tdata->cipher_algo,
8012 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8013 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8014 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8015 : 0 : tdata->cipher_iv.len);
8016 [ # # ]: 0 : if (retval != 0)
8017 : : return retval;
8018 : :
8019 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8020 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8021 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8022 : :
8023 : : /* clear mbuf payload */
8024 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8025 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8026 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8027 : :
8028 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8029 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8030 : : }
8031 : :
8032 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8033 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8034 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8035 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8036 : :
8037 [ # # ]: 0 : if (verify) {
8038 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8039 : : ciphertext_pad_len);
8040 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8041 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8042 : : ciphertext_len);
8043 : : } else {
8044 : : /* make sure enough space to cover partial digest verify case */
8045 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8046 : : ciphertext_pad_len);
8047 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8048 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8049 : : }
8050 : :
8051 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8052 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8053 : :
8054 : : /* Create the operation */
8055 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8056 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8057 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8058 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8059 : 0 : (tdata->digest_enc.offset == 0 ?
8060 : : plaintext_pad_len
8061 : : : tdata->digest_enc.offset),
8062 : 0 : tdata->validCipherLen.len_bits,
8063 : 0 : tdata->cipher.offset_bits,
8064 : 0 : tdata->validAuthLen.len_bits,
8065 [ # # ]: 0 : tdata->auth.offset_bits,
8066 : : op_mode, 0, verify);
8067 : :
8068 [ # # ]: 0 : if (retval < 0)
8069 : : return retval;
8070 : :
8071 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8072 : :
8073 : : /* Check if the op failed because the device doesn't */
8074 : : /* support this particular combination of algorithms */
8075 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8076 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8077 : : printf("Device doesn't support this mixed combination. "
8078 : : "Test Skipped.\n");
8079 : 0 : return TEST_SKIPPED;
8080 : : }
8081 : 0 : ut_params->op = op;
8082 : :
8083 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8084 : :
8085 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8086 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8087 : :
8088 [ # # ]: 0 : if (verify) {
8089 [ # # ]: 0 : if (ut_params->obuf)
8090 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8091 : : uint8_t *);
8092 : : else
8093 : 0 : plaintext = ciphertext +
8094 : 0 : (tdata->cipher.offset_bits >> 3);
8095 : :
8096 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8097 : 0 : tdata->plaintext.len_bits >> 3);
8098 : 0 : debug_hexdump(stdout, "plaintext expected:",
8099 : 0 : tdata->plaintext.data,
8100 : 0 : tdata->plaintext.len_bits >> 3);
8101 : : } else {
8102 [ # # ]: 0 : if (ut_params->obuf)
8103 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8104 : : uint8_t *);
8105 : : else
8106 : : ciphertext = plaintext;
8107 : :
8108 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8109 : : ciphertext_len);
8110 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8111 : 0 : tdata->ciphertext.data,
8112 : 0 : tdata->ciphertext.len_bits >> 3);
8113 : :
8114 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8115 : : digest_offset = plaintext_pad_len;
8116 : : else
8117 : : digest_offset = tdata->digest_enc.offset;
8118 : :
8119 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8120 : : uint8_t *, digest_offset);
8121 : :
8122 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8123 : 0 : tdata->digest_enc.len);
8124 : 0 : debug_hexdump(stdout, "digest expected:",
8125 : : tdata->digest_enc.data,
8126 : 0 : tdata->digest_enc.len);
8127 : : }
8128 : :
8129 [ # # ]: 0 : if (!verify) {
8130 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8131 : : ut_params->digest,
8132 : : tdata->digest_enc.data,
8133 : : tdata->digest_enc.len,
8134 : : "Generated auth tag not as expected");
8135 : : }
8136 : :
8137 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8138 [ # # ]: 0 : if (verify) {
8139 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8140 : : plaintext,
8141 : : tdata->plaintext.data,
8142 : : tdata->plaintext.len_bits >> 3,
8143 : : "Plaintext data not as expected");
8144 : : } else {
8145 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8146 : : ciphertext,
8147 : : tdata->ciphertext.data,
8148 : : tdata->validDataLen.len_bits,
8149 : : "Ciphertext data not as expected");
8150 : : }
8151 : : }
8152 : :
8153 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8154 : : "crypto op processing failed");
8155 : :
8156 : : return 0;
8157 : : }
8158 : :
8159 : : static int
8160 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8161 : : uint8_t op_mode, uint8_t verify)
8162 : : {
8163 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8164 : : struct crypto_unittest_params *ut_params = &unittest_params;
8165 : :
8166 : : int retval;
8167 : :
8168 : : const uint8_t *plaintext = NULL;
8169 : : const uint8_t *ciphertext = NULL;
8170 : : const uint8_t *digest = NULL;
8171 : : unsigned int plaintext_pad_len;
8172 : : unsigned int plaintext_len;
8173 : : unsigned int ciphertext_pad_len;
8174 : : unsigned int ciphertext_len;
8175 : : uint8_t buffer[10000];
8176 : : uint8_t digest_buffer[10000];
8177 : :
8178 : : struct rte_cryptodev_info dev_info;
8179 : : struct rte_crypto_op *op;
8180 : :
8181 : : /* Check if device supports particular algorithms */
8182 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8183 : : return TEST_SKIPPED;
8184 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8185 : : return TEST_SKIPPED;
8186 : :
8187 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8188 : :
8189 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8190 : :
8191 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8192 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8193 : : printf("Device doesn't support in-place scatter-gather "
8194 : : "in both input and output mbufs.\n");
8195 : 0 : return TEST_SKIPPED;
8196 : : }
8197 : : } else {
8198 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8199 : : printf("Device doesn't support out-of-place scatter-gather "
8200 : : "in both input and output mbufs.\n");
8201 : 2 : return TEST_SKIPPED;
8202 : : }
8203 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8204 : : printf("Device doesn't support digest encrypted.\n");
8205 : 0 : return TEST_SKIPPED;
8206 : : }
8207 : : }
8208 : :
8209 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8210 : : return TEST_SKIPPED;
8211 : :
8212 : : /* Create the session */
8213 [ + + ]: 2 : if (verify)
8214 : 1 : retval = create_wireless_algo_cipher_auth_session(
8215 : 1 : ts_params->valid_devs[0],
8216 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8217 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8218 : 1 : tdata->auth_algo,
8219 : 1 : tdata->cipher_algo,
8220 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8221 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8222 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8223 : 1 : tdata->cipher_iv.len);
8224 : : else
8225 : 1 : retval = create_wireless_algo_auth_cipher_session(
8226 : 1 : ts_params->valid_devs[0],
8227 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8228 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8229 : 1 : tdata->auth_algo,
8230 : 1 : tdata->cipher_algo,
8231 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8232 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8233 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8234 : 1 : tdata->cipher_iv.len);
8235 [ + - ]: 2 : if (retval != 0)
8236 : : return retval;
8237 : :
8238 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8239 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8240 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8241 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8242 : :
8243 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8244 : : ciphertext_pad_len, 15, 0);
8245 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8246 : : "Failed to allocate input buffer in mempool");
8247 : :
8248 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8249 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8250 : : plaintext_pad_len, 15, 0);
8251 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8252 : : "Failed to allocate output buffer in mempool");
8253 : : }
8254 : :
8255 [ + + ]: 2 : if (verify) {
8256 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8257 : 1 : tdata->ciphertext.data);
8258 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8259 : : ciphertext_len, buffer);
8260 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8261 : : ciphertext_len);
8262 : : } else {
8263 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8264 : 1 : tdata->plaintext.data);
8265 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8266 : : plaintext_len, buffer);
8267 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8268 : : plaintext_len);
8269 : : }
8270 : : memset(buffer, 0, sizeof(buffer));
8271 : :
8272 : : /* Create the operation */
8273 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8274 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8275 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8276 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8277 : 2 : (tdata->digest_enc.offset == 0 ?
8278 : : plaintext_pad_len
8279 : : : tdata->digest_enc.offset),
8280 : 2 : tdata->validCipherLen.len_bits,
8281 : 2 : tdata->cipher.offset_bits,
8282 : 2 : tdata->validAuthLen.len_bits,
8283 [ + - ]: 2 : tdata->auth.offset_bits,
8284 : : op_mode, 1, verify);
8285 : :
8286 [ + - ]: 2 : if (retval < 0)
8287 : : return retval;
8288 : :
8289 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8290 : :
8291 : : /* Check if the op failed because the device doesn't */
8292 : : /* support this particular combination of algorithms */
8293 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8294 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8295 : : printf("Device doesn't support this mixed combination. "
8296 : : "Test Skipped.\n");
8297 : 0 : return TEST_SKIPPED;
8298 : : }
8299 : 2 : ut_params->op = op;
8300 : :
8301 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8302 : :
8303 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8304 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8305 : :
8306 [ + + ]: 2 : if (verify) {
8307 [ + - ]: 1 : if (ut_params->obuf)
8308 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8309 : : plaintext_len, buffer);
8310 : : else
8311 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8312 : : plaintext_len, buffer);
8313 : :
8314 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8315 : 1 : (tdata->plaintext.len_bits >> 3) -
8316 : 1 : tdata->digest_enc.len);
8317 : 1 : debug_hexdump(stdout, "plaintext expected:",
8318 : 1 : tdata->plaintext.data,
8319 : 1 : (tdata->plaintext.len_bits >> 3) -
8320 : 1 : tdata->digest_enc.len);
8321 : : } else {
8322 [ + - ]: 1 : if (ut_params->obuf)
8323 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8324 : : ciphertext_len, buffer);
8325 : : else
8326 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8327 : : ciphertext_len, buffer);
8328 : :
8329 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8330 : : ciphertext_len);
8331 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8332 : 1 : tdata->ciphertext.data,
8333 : 1 : tdata->ciphertext.len_bits >> 3);
8334 : :
8335 [ + - ]: 1 : if (ut_params->obuf)
8336 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8337 : 1 : (tdata->digest_enc.offset == 0 ?
8338 : : plaintext_pad_len :
8339 : : tdata->digest_enc.offset),
8340 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8341 : : else
8342 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8343 : 0 : (tdata->digest_enc.offset == 0 ?
8344 : : plaintext_pad_len :
8345 : : tdata->digest_enc.offset),
8346 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8347 : :
8348 : 1 : debug_hexdump(stdout, "digest:", digest,
8349 : 1 : tdata->digest_enc.len);
8350 : 1 : debug_hexdump(stdout, "digest expected:",
8351 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8352 : : }
8353 : :
8354 [ + + ]: 2 : if (!verify) {
8355 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8356 : : digest,
8357 : : tdata->digest_enc.data,
8358 : : tdata->digest_enc.len,
8359 : : "Generated auth tag not as expected");
8360 : : }
8361 : :
8362 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8363 [ + + ]: 2 : if (verify) {
8364 [ - + + - : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- + ]
8365 : : plaintext,
8366 : : tdata->plaintext.data,
8367 : : tdata->plaintext.len_bits >> 3,
8368 : : "Plaintext data not as expected");
8369 : : } else {
8370 [ - + - + : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- - ]
8371 : : ciphertext,
8372 : : tdata->ciphertext.data,
8373 : : tdata->validDataLen.len_bits,
8374 : : "Ciphertext data not as expected");
8375 : : }
8376 : : }
8377 : :
8378 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8379 : : "crypto op processing failed");
8380 : :
8381 : : return 0;
8382 : : }
8383 : :
8384 : : /** AUTH AES CMAC + CIPHER AES CTR */
8385 : :
8386 : : static int
8387 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8388 : : {
8389 : 1 : return test_mixed_auth_cipher(
8390 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8391 : : }
8392 : :
8393 : : static int
8394 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8395 : : {
8396 : 1 : return test_mixed_auth_cipher(
8397 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8398 : : }
8399 : :
8400 : : static int
8401 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8402 : : {
8403 : 1 : return test_mixed_auth_cipher_sgl(
8404 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8405 : : }
8406 : :
8407 : : static int
8408 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8409 : : {
8410 : 1 : return test_mixed_auth_cipher_sgl(
8411 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8412 : : }
8413 : :
8414 : : static int
8415 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8416 : : {
8417 : 1 : return test_mixed_auth_cipher(
8418 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8419 : : }
8420 : :
8421 : : static int
8422 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8423 : : {
8424 : 1 : return test_mixed_auth_cipher(
8425 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8426 : : }
8427 : :
8428 : : static int
8429 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8430 : : {
8431 : 1 : return test_mixed_auth_cipher(
8432 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8433 : : }
8434 : :
8435 : : static int
8436 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8437 : : {
8438 : 1 : return test_mixed_auth_cipher(
8439 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8440 : : }
8441 : :
8442 : : static int
8443 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8444 : : {
8445 : 1 : return test_mixed_auth_cipher(
8446 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8447 : : }
8448 : :
8449 : : static int
8450 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8451 : : {
8452 : 1 : return test_mixed_auth_cipher_sgl(
8453 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8454 : : }
8455 : :
8456 : : static int
8457 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8458 : : {
8459 : 1 : return test_mixed_auth_cipher_sgl(
8460 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8461 : : }
8462 : :
8463 : : static int
8464 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8465 : : {
8466 : 1 : return test_mixed_auth_cipher(
8467 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8468 : : }
8469 : :
8470 : : /** MIXED AUTH + CIPHER */
8471 : :
8472 : : static int
8473 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8474 : : {
8475 : 1 : return test_mixed_auth_cipher(
8476 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8477 : : }
8478 : :
8479 : : static int
8480 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8481 : : {
8482 : 1 : return test_mixed_auth_cipher(
8483 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8484 : : }
8485 : :
8486 : : static int
8487 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8488 : : {
8489 : 1 : return test_mixed_auth_cipher(
8490 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8491 : : }
8492 : :
8493 : : static int
8494 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8495 : : {
8496 : 1 : return test_mixed_auth_cipher(
8497 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8498 : : }
8499 : :
8500 : :
8501 : : static int
8502 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8503 : : {
8504 : 1 : return test_mixed_auth_cipher(
8505 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8506 : : }
8507 : :
8508 : : static int
8509 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8510 : : {
8511 : 1 : return test_mixed_auth_cipher(
8512 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8513 : : }
8514 : :
8515 : : static int
8516 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8517 : : {
8518 : 1 : return test_mixed_auth_cipher(
8519 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8520 : : }
8521 : :
8522 : : static int
8523 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8524 : : {
8525 : 1 : return test_mixed_auth_cipher(
8526 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8527 : : }
8528 : :
8529 : : static int
8530 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8531 : : {
8532 : 1 : return test_mixed_auth_cipher(
8533 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8534 : : }
8535 : :
8536 : : static int
8537 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8538 : : {
8539 : 1 : return test_mixed_auth_cipher(
8540 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8541 : : }
8542 : :
8543 : : static int
8544 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8545 : : {
8546 : 1 : return test_mixed_auth_cipher(
8547 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8548 : : }
8549 : :
8550 : : static int
8551 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8552 : : {
8553 : 1 : return test_mixed_auth_cipher(
8554 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8555 : : }
8556 : :
8557 : : static int
8558 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8559 : : {
8560 : 1 : return test_mixed_auth_cipher(
8561 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8562 : : }
8563 : :
8564 : : static int
8565 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8566 : : {
8567 : 1 : return test_mixed_auth_cipher(
8568 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8569 : : }
8570 : :
8571 : : static int
8572 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8573 : : {
8574 : 1 : return test_mixed_auth_cipher_sgl(
8575 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8576 : : }
8577 : :
8578 : : static int
8579 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8580 : : {
8581 : 1 : return test_mixed_auth_cipher(
8582 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8583 : : }
8584 : :
8585 : : static int
8586 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8587 : : {
8588 : 1 : return test_mixed_auth_cipher_sgl(
8589 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8590 : : }
8591 : :
8592 : : static int
8593 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8594 : : {
8595 : 1 : return test_mixed_auth_cipher(
8596 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8597 : : }
8598 : :
8599 : : static int
8600 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8601 : : {
8602 : 1 : return test_mixed_auth_cipher(
8603 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8604 : : }
8605 : :
8606 : : static int
8607 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8608 : : {
8609 : 1 : return test_mixed_auth_cipher(
8610 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8611 : : }
8612 : :
8613 : : static int
8614 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8615 : : {
8616 : 1 : return test_mixed_auth_cipher(
8617 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8618 : : }
8619 : :
8620 : : static int
8621 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8622 : : {
8623 : 1 : return test_mixed_auth_cipher(
8624 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8625 : : }
8626 : :
8627 : : static int
8628 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8629 : : {
8630 : 1 : return test_mixed_auth_cipher(
8631 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8632 : : }
8633 : :
8634 : : static int
8635 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8636 : : {
8637 : 1 : return test_mixed_auth_cipher(
8638 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8639 : : }
8640 : : static int
8641 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8642 : : {
8643 : 1 : return test_mixed_auth_cipher(
8644 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8645 : : }
8646 : :
8647 : : static int
8648 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8649 : : {
8650 : 1 : return test_mixed_auth_cipher(
8651 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8652 : : }
8653 : :
8654 : : static int
8655 : 1 : test_auth_null_cipher_snow_test_case_1(void)
8656 : : {
8657 : 1 : return test_mixed_auth_cipher(
8658 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8659 : : }
8660 : :
8661 : : static int
8662 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
8663 : : {
8664 : 1 : return test_mixed_auth_cipher(
8665 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8666 : : }
8667 : :
8668 : : static int
8669 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
8670 : : {
8671 : 1 : return test_mixed_auth_cipher(
8672 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8673 : : }
8674 : :
8675 : : static int
8676 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
8677 : : {
8678 : 1 : return test_mixed_auth_cipher(
8679 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8680 : : }
8681 : :
8682 : : static int
8683 : 1 : test_auth_snow_cipher_null_test_case_1(void)
8684 : : {
8685 : 1 : return test_mixed_auth_cipher(
8686 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8687 : : }
8688 : :
8689 : : static int
8690 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
8691 : : {
8692 : 1 : return test_mixed_auth_cipher(
8693 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8694 : : }
8695 : :
8696 : : static int
8697 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
8698 : : {
8699 : 1 : return test_mixed_auth_cipher(
8700 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8701 : : }
8702 : :
8703 : : static int
8704 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
8705 : : {
8706 : 1 : return test_mixed_auth_cipher(
8707 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8708 : : }
8709 : :
8710 : : static int
8711 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
8712 : : {
8713 : 1 : return test_mixed_auth_cipher(
8714 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8715 : : }
8716 : :
8717 : : static int
8718 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8719 : : {
8720 : 1 : return test_mixed_auth_cipher(
8721 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8722 : : }
8723 : :
8724 : : static int
8725 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
8726 : : {
8727 : 1 : return test_mixed_auth_cipher(
8728 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8729 : : }
8730 : :
8731 : : static int
8732 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8733 : : {
8734 : 1 : return test_mixed_auth_cipher(
8735 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8736 : : }
8737 : :
8738 : : /* ***** AEAD algorithm Tests ***** */
8739 : :
8740 : : static int
8741 : 81 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8742 : : enum rte_crypto_aead_operation op,
8743 : : const uint8_t *key, const uint8_t key_len,
8744 : : const uint16_t aad_len, const uint8_t auth_len,
8745 : : uint8_t iv_len)
8746 : 81 : {
8747 : 81 : uint8_t aead_key[key_len];
8748 : :
8749 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8750 : : struct crypto_unittest_params *ut_params = &unittest_params;
8751 : :
8752 : : memcpy(aead_key, key, key_len);
8753 : :
8754 : : /* Setup AEAD Parameters */
8755 : 81 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8756 : 81 : ut_params->aead_xform.next = NULL;
8757 : 81 : ut_params->aead_xform.aead.algo = algo;
8758 : 81 : ut_params->aead_xform.aead.op = op;
8759 : 81 : ut_params->aead_xform.aead.key.data = aead_key;
8760 : 81 : ut_params->aead_xform.aead.key.length = key_len;
8761 : 81 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8762 : 81 : ut_params->aead_xform.aead.iv.length = iv_len;
8763 : 81 : ut_params->aead_xform.aead.digest_length = auth_len;
8764 : 81 : ut_params->aead_xform.aead.aad_length = aad_len;
8765 : :
8766 : 81 : debug_hexdump(stdout, "key:", key, key_len);
8767 : :
8768 : : /* Create Crypto session*/
8769 : 81 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8770 : : &ut_params->aead_xform, ts_params->session_mpool);
8771 [ - + - - ]: 81 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8772 : : return TEST_SKIPPED;
8773 [ - + ]: 81 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8774 : : return 0;
8775 : : }
8776 : :
8777 : : static int
8778 : 2 : create_aead_xform(struct rte_crypto_op *op,
8779 : : enum rte_crypto_aead_algorithm algo,
8780 : : enum rte_crypto_aead_operation aead_op,
8781 : : uint8_t *key, const uint8_t key_len,
8782 : : const uint8_t aad_len, const uint8_t auth_len,
8783 : : uint8_t iv_len)
8784 : : {
8785 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8786 : : "failed to allocate space for crypto transform");
8787 : :
8788 : : struct rte_crypto_sym_op *sym_op = op->sym;
8789 : :
8790 : : /* Setup AEAD Parameters */
8791 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8792 : 2 : sym_op->xform->next = NULL;
8793 : 2 : sym_op->xform->aead.algo = algo;
8794 : 2 : sym_op->xform->aead.op = aead_op;
8795 : 2 : sym_op->xform->aead.key.data = key;
8796 : 2 : sym_op->xform->aead.key.length = key_len;
8797 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
8798 : 2 : sym_op->xform->aead.iv.length = iv_len;
8799 : 2 : sym_op->xform->aead.digest_length = auth_len;
8800 : 2 : sym_op->xform->aead.aad_length = aad_len;
8801 : :
8802 : 2 : debug_hexdump(stdout, "key:", key, key_len);
8803 : :
8804 : : return 0;
8805 : : }
8806 : :
8807 : : static int
8808 : 82 : create_aead_operation(enum rte_crypto_aead_operation op,
8809 : : const struct aead_test_data *tdata)
8810 : : {
8811 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8812 : : struct crypto_unittest_params *ut_params = &unittest_params;
8813 : :
8814 : : uint8_t *plaintext, *ciphertext;
8815 : : unsigned int aad_pad_len, plaintext_pad_len;
8816 : :
8817 : : /* Generate Crypto op data structure */
8818 : 82 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8819 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8820 [ - + ]: 82 : TEST_ASSERT_NOT_NULL(ut_params->op,
8821 : : "Failed to allocate symmetric crypto operation struct");
8822 : :
8823 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8824 : :
8825 : : /* Append aad data */
8826 [ + + ]: 82 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8827 : 18 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8828 : 18 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8829 : : aad_pad_len);
8830 [ - + ]: 18 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8831 : : "no room to append aad");
8832 : :
8833 : 18 : sym_op->aead.aad.phys_addr =
8834 : 18 : rte_pktmbuf_iova(ut_params->ibuf);
8835 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8836 : 18 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8837 : 18 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8838 : 18 : tdata->aad.len);
8839 : :
8840 : : /* Append IV at the end of the crypto operation*/
8841 : 18 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8842 : : uint8_t *, IV_OFFSET);
8843 : :
8844 : : /* Copy IV 1 byte after the IV pointer, according to the API */
8845 [ - + ]: 18 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8846 : 18 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
8847 : 18 : tdata->iv.len);
8848 : : } else {
8849 : 64 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8850 : 64 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8851 : : aad_pad_len);
8852 [ - + ]: 64 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8853 : : "no room to append aad");
8854 : :
8855 : 64 : sym_op->aead.aad.phys_addr =
8856 : 64 : rte_pktmbuf_iova(ut_params->ibuf);
8857 : 64 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8858 : 64 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8859 : 64 : tdata->aad.len);
8860 : :
8861 : : /* Append IV at the end of the crypto operation*/
8862 : 64 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8863 : : uint8_t *, IV_OFFSET);
8864 : :
8865 [ - + ]: 64 : if (tdata->iv.len == 0) {
8866 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8867 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
8868 : : AES_GCM_J0_LENGTH);
8869 : : } else {
8870 [ - + ]: 64 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8871 : 64 : debug_hexdump(stdout, "iv:", iv_ptr,
8872 : 64 : tdata->iv.len);
8873 : : }
8874 : : }
8875 : :
8876 : : /* Append plaintext/ciphertext */
8877 [ + + ]: 82 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8878 : 41 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8879 : 41 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8880 : : plaintext_pad_len);
8881 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8882 : :
8883 : 41 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8884 : 41 : debug_hexdump(stdout, "plaintext:", plaintext,
8885 : 41 : tdata->plaintext.len);
8886 : :
8887 [ + + ]: 41 : if (ut_params->obuf) {
8888 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
8889 : : ut_params->obuf,
8890 : 1 : plaintext_pad_len + aad_pad_len);
8891 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
8892 : : "no room to append ciphertext");
8893 : :
8894 : 1 : memset(ciphertext + aad_pad_len, 0,
8895 : 1 : tdata->ciphertext.len);
8896 : : }
8897 : : } else {
8898 : 41 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8899 : 41 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8900 : : plaintext_pad_len);
8901 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(ciphertext,
8902 : : "no room to append ciphertext");
8903 : :
8904 : 41 : memcpy(ciphertext, tdata->ciphertext.data,
8905 : 41 : tdata->ciphertext.len);
8906 : 41 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8907 : 41 : tdata->ciphertext.len);
8908 : :
8909 [ + + ]: 41 : if (ut_params->obuf) {
8910 : : plaintext = (uint8_t *)rte_pktmbuf_append(
8911 : : ut_params->obuf,
8912 : 1 : plaintext_pad_len + aad_pad_len);
8913 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
8914 : : "no room to append plaintext");
8915 : :
8916 : 1 : memset(plaintext + aad_pad_len, 0,
8917 : 1 : tdata->plaintext.len);
8918 : : }
8919 : : }
8920 : :
8921 : : /* Append digest data */
8922 [ + + ]: 82 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8923 : 40 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8924 : 41 : ut_params->obuf ? ut_params->obuf :
8925 : : ut_params->ibuf,
8926 [ + + ]: 41 : tdata->auth_tag.len);
8927 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8928 : : "no room to append digest");
8929 [ + + ]: 41 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8930 [ + + ]: 41 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8931 : : ut_params->obuf ? ut_params->obuf :
8932 : : ut_params->ibuf,
8933 : : plaintext_pad_len +
8934 : : aad_pad_len);
8935 : : } else {
8936 : 82 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8937 : 41 : ut_params->ibuf, tdata->auth_tag.len);
8938 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8939 : : "no room to append digest");
8940 [ - + ]: 41 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8941 : : ut_params->ibuf,
8942 : : plaintext_pad_len + aad_pad_len);
8943 : :
8944 : 41 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8945 [ - + ]: 41 : tdata->auth_tag.len);
8946 : 41 : debug_hexdump(stdout, "digest:",
8947 : 41 : sym_op->aead.digest.data,
8948 : 41 : tdata->auth_tag.len);
8949 : : }
8950 : :
8951 : 82 : sym_op->aead.data.length = tdata->plaintext.len;
8952 : 82 : sym_op->aead.data.offset = aad_pad_len;
8953 : :
8954 : 82 : return 0;
8955 : : }
8956 : :
8957 : : static int
8958 : 40 : test_authenticated_encryption(const struct aead_test_data *tdata)
8959 : : {
8960 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8961 : : struct crypto_unittest_params *ut_params = &unittest_params;
8962 : :
8963 : : int retval;
8964 : : uint8_t *ciphertext, *auth_tag;
8965 : : uint16_t plaintext_pad_len;
8966 : : uint32_t i;
8967 : : struct rte_cryptodev_info dev_info;
8968 : :
8969 : 40 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8970 : 40 : uint64_t feat_flags = dev_info.feature_flags;
8971 : :
8972 [ - + ]: 40 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8973 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8974 : : printf("Device doesn't support RAW data-path APIs.\n");
8975 : 0 : return TEST_SKIPPED;
8976 : : }
8977 : :
8978 : : /* Verify the capabilities */
8979 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8980 : : const struct rte_cryptodev_symmetric_capability *capability;
8981 : 40 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8982 : 40 : cap_idx.algo.aead = tdata->algo;
8983 : 40 : capability = rte_cryptodev_sym_capability_get(
8984 : 40 : ts_params->valid_devs[0], &cap_idx);
8985 [ + - ]: 40 : if (capability == NULL)
8986 : : return TEST_SKIPPED;
8987 [ + + ]: 40 : if (rte_cryptodev_sym_capability_check_aead(
8988 : 40 : capability, tdata->key.len, tdata->auth_tag.len,
8989 : 40 : tdata->aad.len, tdata->iv.len))
8990 : : return TEST_SKIPPED;
8991 : :
8992 : : /* Create AEAD session */
8993 : 39 : retval = create_aead_session(ts_params->valid_devs[0],
8994 : 39 : tdata->algo,
8995 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
8996 : 39 : tdata->key.data, tdata->key.len,
8997 : 39 : tdata->aad.len, tdata->auth_tag.len,
8998 : 39 : tdata->iv.len);
8999 [ + - ]: 39 : if (retval != TEST_SUCCESS)
9000 : : return retval;
9001 : :
9002 [ + + ]: 39 : if (tdata->aad.len > MBUF_SIZE) {
9003 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9004 : : /* Populate full size of add data */
9005 [ + + ]: 4096 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9006 : 4094 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9007 : : } else
9008 : 37 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9009 : :
9010 : : /* clear mbuf payload */
9011 : 39 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9012 : 39 : rte_pktmbuf_tailroom(ut_params->ibuf));
9013 : :
9014 : : /* Create AEAD operation */
9015 : 39 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9016 [ + - ]: 39 : if (retval < 0)
9017 : : return retval;
9018 : :
9019 [ + - ]: 39 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9020 : :
9021 : 39 : ut_params->op->sym->m_src = ut_params->ibuf;
9022 : :
9023 : : /* Process crypto operation */
9024 [ - + ]: 39 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9025 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9026 [ - + ]: 39 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9027 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9028 : : 0);
9029 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9030 : : return retval;
9031 : : } else
9032 [ - + ]: 39 : TEST_ASSERT_NOT_NULL(
9033 : : process_crypto_request(ts_params->valid_devs[0],
9034 : : ut_params->op), "failed to process sym crypto op");
9035 : :
9036 [ - + ]: 39 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9037 : : "crypto op processing failed");
9038 : :
9039 : 39 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9040 : :
9041 [ - + ]: 39 : if (ut_params->op->sym->m_dst) {
9042 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9043 : : uint8_t *);
9044 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9045 : : uint8_t *, plaintext_pad_len);
9046 : : } else {
9047 : 39 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9048 : : uint8_t *,
9049 : : ut_params->op->sym->cipher.data.offset);
9050 : 39 : auth_tag = ciphertext + plaintext_pad_len;
9051 : : }
9052 : :
9053 : 39 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9054 : 39 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9055 : :
9056 : : /* Validate obuf */
9057 [ + + ]: 42 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9058 : : ciphertext,
9059 : : tdata->ciphertext.data,
9060 : : tdata->ciphertext.len,
9061 : : "Ciphertext data not as expected");
9062 : :
9063 [ + + ]: 39 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9064 : : auth_tag,
9065 : : tdata->auth_tag.data,
9066 : : tdata->auth_tag.len,
9067 : : "Generated auth tag not as expected");
9068 : :
9069 : : return 0;
9070 : :
9071 : : }
9072 : :
9073 : : #ifdef RTE_LIB_SECURITY
9074 : : static int
9075 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9076 : : enum rte_security_session_protocol proto)
9077 : : {
9078 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9079 : :
9080 : : const struct rte_security_capability *capabilities;
9081 : : const struct rte_security_capability *capability;
9082 : : uint16_t i = 0;
9083 : :
9084 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9085 : :
9086 : :
9087 : 0 : capabilities = rte_security_capabilities_get(ctx);
9088 : :
9089 [ # # ]: 0 : if (capabilities == NULL)
9090 : : return -ENOTSUP;
9091 : :
9092 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9093 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9094 [ # # ]: 0 : if (capability->action == action &&
9095 [ # # ]: 0 : capability->protocol == proto)
9096 : : return 0;
9097 : : }
9098 : :
9099 : : return -ENOTSUP;
9100 : : }
9101 : :
9102 : : /* Basic algorithm run function for async inplace mode.
9103 : : * Creates a session from input parameters and runs one operation
9104 : : * on input_vec. Checks the output of the crypto operation against
9105 : : * output_vec.
9106 : : */
9107 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9108 : : enum rte_crypto_auth_operation opa,
9109 : : const uint8_t *input_vec, unsigned int input_vec_len,
9110 : : const uint8_t *output_vec,
9111 : : unsigned int output_vec_len,
9112 : : enum rte_crypto_cipher_algorithm cipher_alg,
9113 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9114 : : enum rte_crypto_auth_algorithm auth_alg,
9115 : : const uint8_t *auth_key, uint32_t auth_key_len,
9116 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9117 : : uint8_t packet_direction, uint8_t sn_size,
9118 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9119 : : {
9120 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9121 : : struct crypto_unittest_params *ut_params = &unittest_params;
9122 : : uint8_t *plaintext;
9123 : : int ret = TEST_SUCCESS;
9124 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9125 : : struct rte_cryptodev_info dev_info;
9126 : : uint64_t feat_flags;
9127 : :
9128 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9129 : 0 : feat_flags = dev_info.feature_flags;
9130 : :
9131 : : /* Verify the capabilities */
9132 : : struct rte_security_capability_idx sec_cap_idx;
9133 : :
9134 : 0 : sec_cap_idx.action = ut_params->type;
9135 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9136 : 0 : sec_cap_idx.pdcp.domain = domain;
9137 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9138 : : return TEST_SKIPPED;
9139 : :
9140 : : /* Generate test mbuf data */
9141 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9142 : :
9143 : : /* clear mbuf payload */
9144 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9145 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9146 : :
9147 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9148 : : input_vec_len);
9149 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9150 : :
9151 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9152 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9153 : : printf("Device does not support RAW data-path APIs.\n");
9154 : 0 : return TEST_SKIPPED;
9155 : : }
9156 : : /* Out of place support */
9157 [ # # ]: 0 : if (oop) {
9158 : : /*
9159 : : * For out-op-place we need to alloc another mbuf
9160 : : */
9161 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9162 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9163 : : }
9164 : :
9165 : : /* Setup Cipher Parameters */
9166 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9167 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9168 : 0 : ut_params->cipher_xform.cipher.op = opc;
9169 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9170 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9171 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9172 : : packet_direction ? 4 : 0;
9173 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9174 : :
9175 : : /* Setup HMAC Parameters if ICV header is required */
9176 [ # # ]: 0 : if (auth_alg != 0) {
9177 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9178 : 0 : ut_params->auth_xform.next = NULL;
9179 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9180 : 0 : ut_params->auth_xform.auth.op = opa;
9181 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9182 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9183 : :
9184 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9185 : : } else {
9186 : 0 : ut_params->cipher_xform.next = NULL;
9187 : : }
9188 : :
9189 : 0 : struct rte_security_session_conf sess_conf = {
9190 : 0 : .action_type = ut_params->type,
9191 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9192 : : {.pdcp = {
9193 : : .bearer = bearer,
9194 : : .domain = domain,
9195 : : .pkt_dir = packet_direction,
9196 : : .sn_size = sn_size,
9197 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9198 : : /**
9199 : : * hfn can be set as pdcp_test_hfn[i]
9200 : : * if hfn_ovrd is not set. Here, PDCP
9201 : : * packet direction is just used to
9202 : : * run half of the cases with session
9203 : : * HFN and other half with per packet
9204 : : * HFN.
9205 : : */
9206 : : .hfn_threshold = hfn_threshold,
9207 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9208 : : .sdap_enabled = sdap,
9209 : : } },
9210 : : .crypto_xform = &ut_params->cipher_xform
9211 : : };
9212 : :
9213 : : /* Create security session */
9214 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9215 : : &sess_conf, ts_params->session_mpool);
9216 : :
9217 [ # # ]: 0 : if (!ut_params->sec_session) {
9218 : : printf("TestCase %s()-%d line %d failed %s: ",
9219 : : __func__, i, __LINE__, "Failed to allocate session");
9220 : : ret = TEST_FAILED;
9221 : 0 : goto on_err;
9222 : : }
9223 : :
9224 : : /* Generate crypto op data structure */
9225 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9226 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9227 [ # # ]: 0 : if (!ut_params->op) {
9228 : : printf("TestCase %s()-%d line %d failed %s: ",
9229 : : __func__, i, __LINE__,
9230 : : "Failed to allocate symmetric crypto operation struct");
9231 : : ret = TEST_FAILED;
9232 : 0 : goto on_err;
9233 : : }
9234 : :
9235 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9236 : : uint32_t *, IV_OFFSET);
9237 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9238 : :
9239 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9240 : :
9241 : : /* set crypto operation source mbuf */
9242 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9243 [ # # ]: 0 : if (oop)
9244 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9245 : :
9246 : : /* Process crypto operation */
9247 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9248 : : /* filling lengths */
9249 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9250 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9251 : :
9252 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9253 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9254 : : return ret;
9255 : : } else {
9256 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9257 : : }
9258 [ # # ]: 0 : if (ut_params->op == NULL) {
9259 : : printf("TestCase %s()-%d line %d failed %s: ",
9260 : : __func__, i, __LINE__,
9261 : : "failed to process sym crypto op");
9262 : : ret = TEST_FAILED;
9263 : 0 : goto on_err;
9264 : : }
9265 : :
9266 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9267 : : printf("TestCase %s()-%d line %d failed %s: ",
9268 : : __func__, i, __LINE__, "crypto op processing failed");
9269 : : ret = TEST_FAILED;
9270 : 0 : goto on_err;
9271 : : }
9272 : :
9273 : : /* Validate obuf */
9274 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9275 : : uint8_t *);
9276 [ # # ]: 0 : if (oop) {
9277 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9278 : : uint8_t *);
9279 : : }
9280 : :
9281 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9282 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9283 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9284 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9285 : : ret = TEST_FAILED;
9286 : 0 : goto on_err;
9287 : : }
9288 : :
9289 : 0 : on_err:
9290 : 0 : rte_crypto_op_free(ut_params->op);
9291 : 0 : ut_params->op = NULL;
9292 : :
9293 [ # # ]: 0 : if (ut_params->sec_session)
9294 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9295 : 0 : ut_params->sec_session = NULL;
9296 : :
9297 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9298 : 0 : ut_params->ibuf = NULL;
9299 [ # # ]: 0 : if (oop) {
9300 : 0 : rte_pktmbuf_free(ut_params->obuf);
9301 : 0 : ut_params->obuf = NULL;
9302 : : }
9303 : :
9304 : : return ret;
9305 : : }
9306 : :
9307 : : static int
9308 : 0 : test_pdcp_proto_SGL(int i, int oop,
9309 : : enum rte_crypto_cipher_operation opc,
9310 : : enum rte_crypto_auth_operation opa,
9311 : : uint8_t *input_vec,
9312 : : unsigned int input_vec_len,
9313 : : uint8_t *output_vec,
9314 : : unsigned int output_vec_len,
9315 : : uint32_t fragsz,
9316 : : uint32_t fragsz_oop)
9317 : : {
9318 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9319 : : struct crypto_unittest_params *ut_params = &unittest_params;
9320 : : uint8_t *plaintext;
9321 : : struct rte_mbuf *buf, *buf_oop = NULL;
9322 : : int ret = TEST_SUCCESS;
9323 : : int to_trn = 0;
9324 : : int to_trn_tbl[16];
9325 : : int segs = 1;
9326 : : unsigned int trn_data = 0;
9327 : : struct rte_cryptodev_info dev_info;
9328 : : uint64_t feat_flags;
9329 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9330 : : struct rte_mbuf *temp_mbuf;
9331 : :
9332 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9333 : 0 : feat_flags = dev_info.feature_flags;
9334 : :
9335 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9336 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9337 : : printf("Device does not support RAW data-path APIs.\n");
9338 : 0 : return -ENOTSUP;
9339 : : }
9340 : : /* Verify the capabilities */
9341 : : struct rte_security_capability_idx sec_cap_idx;
9342 : :
9343 : 0 : sec_cap_idx.action = ut_params->type;
9344 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9345 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9346 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9347 : : return TEST_SKIPPED;
9348 : :
9349 : : if (fragsz > input_vec_len)
9350 : : fragsz = input_vec_len;
9351 : :
9352 : 0 : uint16_t plaintext_len = fragsz;
9353 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9354 : :
9355 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9356 : 0 : frag_size_oop = output_vec_len;
9357 : :
9358 : : int ecx = 0;
9359 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9360 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9361 : : return 1;
9362 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9363 : : return 1;
9364 : :
9365 : : /* Out of place support */
9366 [ # # ]: 0 : if (oop) {
9367 : : /*
9368 : : * For out-op-place we need to alloc another mbuf
9369 : : */
9370 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9371 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9372 : 0 : buf_oop = ut_params->obuf;
9373 : : }
9374 : :
9375 : : /* Generate test mbuf data */
9376 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9377 : :
9378 : : /* clear mbuf payload */
9379 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9380 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9381 : :
9382 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9383 : : plaintext_len);
9384 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9385 : : trn_data += plaintext_len;
9386 : :
9387 : 0 : buf = ut_params->ibuf;
9388 : :
9389 : : /*
9390 : : * Loop until no more fragments
9391 : : */
9392 : :
9393 [ # # ]: 0 : while (trn_data < input_vec_len) {
9394 : 0 : ++segs;
9395 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9396 : 0 : (input_vec_len - trn_data) : fragsz;
9397 : :
9398 : 0 : to_trn_tbl[ecx++] = to_trn;
9399 : :
9400 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9401 : : buf = buf->next;
9402 : :
9403 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9404 : : rte_pktmbuf_tailroom(buf));
9405 : :
9406 : : /* OOP */
9407 [ # # ]: 0 : if (oop && !fragsz_oop) {
9408 : 0 : buf_oop->next =
9409 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9410 : : buf_oop = buf_oop->next;
9411 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9412 : : 0, rte_pktmbuf_tailroom(buf_oop));
9413 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9414 : : }
9415 : :
9416 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9417 : : to_trn);
9418 : :
9419 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9420 : 0 : trn_data += to_trn;
9421 : : }
9422 : :
9423 : 0 : ut_params->ibuf->nb_segs = segs;
9424 : :
9425 : : segs = 1;
9426 [ # # ]: 0 : if (fragsz_oop && oop) {
9427 : : to_trn = 0;
9428 : : ecx = 0;
9429 : :
9430 : 0 : trn_data = frag_size_oop;
9431 [ # # ]: 0 : while (trn_data < output_vec_len) {
9432 : 0 : ++segs;
9433 : 0 : to_trn =
9434 : 0 : (output_vec_len - trn_data <
9435 : : frag_size_oop) ?
9436 : 0 : (output_vec_len - trn_data) :
9437 : : frag_size_oop;
9438 : :
9439 : 0 : to_trn_tbl[ecx++] = to_trn;
9440 : :
9441 : 0 : buf_oop->next =
9442 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9443 : : buf_oop = buf_oop->next;
9444 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9445 : : 0, rte_pktmbuf_tailroom(buf_oop));
9446 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9447 : :
9448 : 0 : trn_data += to_trn;
9449 : : }
9450 : 0 : ut_params->obuf->nb_segs = segs;
9451 : : }
9452 : :
9453 : : /* Setup Cipher Parameters */
9454 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9455 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9456 : 0 : ut_params->cipher_xform.cipher.op = opc;
9457 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9458 : 0 : ut_params->cipher_xform.cipher.key.length =
9459 : 0 : pdcp_test_params[i].cipher_key_len;
9460 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9461 : :
9462 : : /* Setup HMAC Parameters if ICV header is required */
9463 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9464 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9465 : 0 : ut_params->auth_xform.next = NULL;
9466 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9467 : 0 : ut_params->auth_xform.auth.op = opa;
9468 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9469 : 0 : ut_params->auth_xform.auth.key.length =
9470 : 0 : pdcp_test_params[i].auth_key_len;
9471 : :
9472 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9473 : : } else {
9474 : 0 : ut_params->cipher_xform.next = NULL;
9475 : : }
9476 : :
9477 : 0 : struct rte_security_session_conf sess_conf = {
9478 : 0 : .action_type = ut_params->type,
9479 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9480 : : {.pdcp = {
9481 : 0 : .bearer = pdcp_test_bearer[i],
9482 : 0 : .domain = pdcp_test_params[i].domain,
9483 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9484 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9485 : 0 : .hfn = pdcp_test_hfn[i],
9486 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9487 : : .hfn_ovrd = 0,
9488 : : } },
9489 : : .crypto_xform = &ut_params->cipher_xform
9490 : : };
9491 : :
9492 : : /* Create security session */
9493 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9494 : : &sess_conf, ts_params->session_mpool);
9495 : :
9496 [ # # ]: 0 : if (!ut_params->sec_session) {
9497 : : printf("TestCase %s()-%d line %d failed %s: ",
9498 : : __func__, i, __LINE__, "Failed to allocate session");
9499 : : ret = TEST_FAILED;
9500 : 0 : goto on_err;
9501 : : }
9502 : :
9503 : : /* Generate crypto op data structure */
9504 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9505 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9506 [ # # ]: 0 : if (!ut_params->op) {
9507 : : printf("TestCase %s()-%d line %d failed %s: ",
9508 : : __func__, i, __LINE__,
9509 : : "Failed to allocate symmetric crypto operation struct");
9510 : : ret = TEST_FAILED;
9511 : 0 : goto on_err;
9512 : : }
9513 : :
9514 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9515 : :
9516 : : /* set crypto operation source mbuf */
9517 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9518 [ # # ]: 0 : if (oop)
9519 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9520 : :
9521 : : /* Process crypto operation */
9522 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9523 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9524 : : /* filling lengths */
9525 [ # # ]: 0 : while (temp_mbuf) {
9526 : 0 : ut_params->op->sym->cipher.data.length
9527 : 0 : += temp_mbuf->pkt_len;
9528 : 0 : ut_params->op->sym->auth.data.length
9529 : 0 : += temp_mbuf->pkt_len;
9530 : 0 : temp_mbuf = temp_mbuf->next;
9531 : : }
9532 : :
9533 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9534 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9535 : : return ret;
9536 : : } else {
9537 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9538 : : ut_params->op);
9539 : : }
9540 [ # # ]: 0 : if (ut_params->op == NULL) {
9541 : : printf("TestCase %s()-%d line %d failed %s: ",
9542 : : __func__, i, __LINE__,
9543 : : "failed to process sym crypto op");
9544 : : ret = TEST_FAILED;
9545 : 0 : goto on_err;
9546 : : }
9547 : :
9548 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9549 : : printf("TestCase %s()-%d line %d failed %s: ",
9550 : : __func__, i, __LINE__, "crypto op processing failed");
9551 : : ret = TEST_FAILED;
9552 : 0 : goto on_err;
9553 : : }
9554 : :
9555 : : /* Validate obuf */
9556 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9557 : : uint8_t *);
9558 [ # # ]: 0 : if (oop) {
9559 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9560 : : uint8_t *);
9561 : : }
9562 [ # # ]: 0 : if (fragsz_oop)
9563 : 0 : fragsz = frag_size_oop;
9564 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9565 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9566 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9567 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9568 : : ret = TEST_FAILED;
9569 : 0 : goto on_err;
9570 : : }
9571 : :
9572 : 0 : buf = ut_params->op->sym->m_src->next;
9573 [ # # ]: 0 : if (oop)
9574 : 0 : buf = ut_params->op->sym->m_dst->next;
9575 : :
9576 : : unsigned int off = fragsz;
9577 : :
9578 : : ecx = 0;
9579 [ # # ]: 0 : while (buf) {
9580 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9581 : : uint8_t *);
9582 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9583 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9584 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9585 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9586 : : to_trn_tbl[ecx]);
9587 : : ret = TEST_FAILED;
9588 : 0 : goto on_err;
9589 : : }
9590 : 0 : off += to_trn_tbl[ecx++];
9591 : 0 : buf = buf->next;
9592 : : }
9593 : 0 : on_err:
9594 : 0 : rte_crypto_op_free(ut_params->op);
9595 : 0 : ut_params->op = NULL;
9596 : :
9597 [ # # ]: 0 : if (ut_params->sec_session)
9598 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9599 : 0 : ut_params->sec_session = NULL;
9600 : :
9601 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9602 : 0 : ut_params->ibuf = NULL;
9603 [ # # ]: 0 : if (oop) {
9604 : 0 : rte_pktmbuf_free(ut_params->obuf);
9605 : 0 : ut_params->obuf = NULL;
9606 : : }
9607 : :
9608 : : return ret;
9609 : : }
9610 : :
9611 : : int
9612 : 0 : test_pdcp_proto_cplane_encap(int i)
9613 : : {
9614 : 0 : return test_pdcp_proto(
9615 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9616 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9617 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9618 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9619 : 0 : pdcp_test_params[i].cipher_key_len,
9620 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9621 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9622 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9623 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9624 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9625 : : }
9626 : :
9627 : : int
9628 : 0 : test_pdcp_proto_uplane_encap(int i)
9629 : : {
9630 : 0 : return test_pdcp_proto(
9631 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9632 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9633 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9634 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9635 : 0 : pdcp_test_params[i].cipher_key_len,
9636 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9637 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9638 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9639 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9640 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9641 : : }
9642 : :
9643 : : int
9644 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
9645 : : {
9646 : 0 : return test_pdcp_proto(
9647 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9648 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9649 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9650 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9651 : 0 : pdcp_test_params[i].cipher_key_len,
9652 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9653 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9654 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9655 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9656 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9657 : : }
9658 : :
9659 : : int
9660 : 0 : test_pdcp_proto_cplane_decap(int i)
9661 : : {
9662 : 0 : return test_pdcp_proto(
9663 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9664 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9665 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9666 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9667 : 0 : pdcp_test_params[i].cipher_key_len,
9668 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9669 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9670 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9671 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9672 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9673 : : }
9674 : :
9675 : : int
9676 : 0 : test_pdcp_proto_uplane_decap(int i)
9677 : : {
9678 : 0 : return test_pdcp_proto(
9679 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9680 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9681 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9682 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9683 : 0 : pdcp_test_params[i].cipher_key_len,
9684 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9685 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9686 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9687 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9688 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9689 : : }
9690 : :
9691 : : int
9692 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
9693 : : {
9694 : 0 : return test_pdcp_proto(
9695 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9696 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9697 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9698 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9699 : 0 : pdcp_test_params[i].cipher_key_len,
9700 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9701 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9702 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9703 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9704 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9705 : : }
9706 : :
9707 : : static int
9708 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
9709 : : {
9710 : : /* i can be used for running any PDCP case
9711 : : * In this case it is uplane 12-bit AES-SNOW DL encap
9712 : : */
9713 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9714 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
9715 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9716 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9717 : : pdcp_test_data_in[i],
9718 : : pdcp_test_data_in_len[i],
9719 : : pdcp_test_data_out[i],
9720 : 0 : pdcp_test_data_in_len[i]+4,
9721 : : 32, 0);
9722 : : }
9723 : : static int
9724 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
9725 : : {
9726 : : /* i can be used for running any PDCP case
9727 : : * In this case it is uplane 18-bit NULL-NULL DL encap
9728 : : */
9729 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9730 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9731 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9732 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9733 : : pdcp_test_data_in[i],
9734 : : pdcp_test_data_in_len[i],
9735 : : pdcp_test_data_out[i],
9736 : 0 : pdcp_test_data_in_len[i]+4,
9737 : : 32, 128);
9738 : : }
9739 : : static int
9740 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
9741 : : {
9742 : : /* i can be used for running any PDCP case
9743 : : * In this case it is uplane 18-bit AES DL encap
9744 : : */
9745 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9746 : : + DOWNLINK;
9747 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9748 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9749 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9750 : : pdcp_test_data_in[i],
9751 : : pdcp_test_data_in_len[i],
9752 : : pdcp_test_data_out[i],
9753 : : pdcp_test_data_in_len[i],
9754 : : 32, 40);
9755 : : }
9756 : : static int
9757 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
9758 : : {
9759 : : /* i can be used for running any PDCP case
9760 : : * In this case it is cplane 12-bit AES-ZUC DL encap
9761 : : */
9762 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9763 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9764 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9765 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9766 : : pdcp_test_data_in[i],
9767 : : pdcp_test_data_in_len[i],
9768 : : pdcp_test_data_out[i],
9769 : 0 : pdcp_test_data_in_len[i]+4,
9770 : : 128, 32);
9771 : : }
9772 : :
9773 : : static int
9774 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
9775 : : {
9776 : : int i = 0, size = 0;
9777 : : int err, all_err = TEST_SUCCESS;
9778 : : const struct pdcp_sdap_test *cur_test;
9779 : :
9780 : : size = RTE_DIM(list_pdcp_sdap_tests);
9781 : :
9782 [ # # ]: 0 : for (i = 0; i < size; i++) {
9783 : : cur_test = &list_pdcp_sdap_tests[i];
9784 : 0 : err = test_pdcp_proto(
9785 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9786 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9787 : 0 : cur_test->in_len, cur_test->data_out,
9788 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9789 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
9790 : 0 : cur_test->param.cipher_key_len,
9791 : 0 : cur_test->param.auth_alg,
9792 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9793 : 0 : cur_test->bearer, cur_test->param.domain,
9794 : 0 : cur_test->packet_direction, cur_test->sn_size,
9795 : 0 : cur_test->hfn,
9796 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
9797 [ # # ]: 0 : if (err) {
9798 : : printf("\t%d) %s: Encapsulation failed\n",
9799 : 0 : cur_test->test_idx,
9800 : 0 : cur_test->param.name);
9801 : : err = TEST_FAILED;
9802 : : } else {
9803 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9804 : 0 : cur_test->param.name);
9805 : : err = TEST_SUCCESS;
9806 : : }
9807 : 0 : all_err += err;
9808 : : }
9809 : :
9810 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9811 : :
9812 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9813 : : }
9814 : :
9815 : : static int
9816 : 0 : test_PDCP_PROTO_short_mac(void)
9817 : : {
9818 : : int i = 0, size = 0;
9819 : : int err, all_err = TEST_SUCCESS;
9820 : : const struct pdcp_short_mac_test *cur_test;
9821 : :
9822 : : size = RTE_DIM(list_pdcp_smac_tests);
9823 : :
9824 [ # # ]: 0 : for (i = 0; i < size; i++) {
9825 : : cur_test = &list_pdcp_smac_tests[i];
9826 : 0 : err = test_pdcp_proto(
9827 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9828 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9829 : 0 : cur_test->in_len, cur_test->data_out,
9830 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9831 : : RTE_CRYPTO_CIPHER_NULL, NULL,
9832 : 0 : 0, cur_test->param.auth_alg,
9833 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9834 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
9835 : : 0, 0, 0);
9836 [ # # ]: 0 : if (err) {
9837 : : printf("\t%d) %s: Short MAC test failed\n",
9838 : 0 : cur_test->test_idx,
9839 : 0 : cur_test->param.name);
9840 : : err = TEST_FAILED;
9841 : : } else {
9842 : : printf("\t%d) %s: Short MAC test PASS\n",
9843 : 0 : cur_test->test_idx,
9844 : 0 : cur_test->param.name);
9845 : 0 : rte_hexdump(stdout, "MAC I",
9846 : 0 : cur_test->data_out + cur_test->in_len + 2,
9847 : : 2);
9848 : : err = TEST_SUCCESS;
9849 : : }
9850 : 0 : all_err += err;
9851 : : }
9852 : :
9853 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9854 : :
9855 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9856 : :
9857 : : }
9858 : :
9859 : : static int
9860 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
9861 : : {
9862 : : int i = 0, size = 0;
9863 : : int err, all_err = TEST_SUCCESS;
9864 : : const struct pdcp_sdap_test *cur_test;
9865 : :
9866 : : size = RTE_DIM(list_pdcp_sdap_tests);
9867 : :
9868 [ # # ]: 0 : for (i = 0; i < size; i++) {
9869 : : cur_test = &list_pdcp_sdap_tests[i];
9870 : 0 : err = test_pdcp_proto(
9871 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9872 : : RTE_CRYPTO_AUTH_OP_VERIFY,
9873 : 0 : cur_test->data_out,
9874 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9875 : 0 : cur_test->data_in, cur_test->in_len,
9876 : 0 : cur_test->param.cipher_alg,
9877 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
9878 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
9879 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
9880 : 0 : cur_test->param.domain, cur_test->packet_direction,
9881 : 0 : cur_test->sn_size, cur_test->hfn,
9882 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
9883 [ # # ]: 0 : if (err) {
9884 : : printf("\t%d) %s: Decapsulation failed\n",
9885 : 0 : cur_test->test_idx,
9886 : 0 : cur_test->param.name);
9887 : : err = TEST_FAILED;
9888 : : } else {
9889 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9890 : 0 : cur_test->param.name);
9891 : : err = TEST_SUCCESS;
9892 : : }
9893 : 0 : all_err += err;
9894 : : }
9895 : :
9896 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9897 : :
9898 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9899 : : }
9900 : :
9901 : : static inline void
9902 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
9903 : : {
9904 : 0 : }
9905 : :
9906 : : static inline void
9907 : 0 : ext_mbuf_memzone_free(int nb_segs)
9908 : : {
9909 : : int i;
9910 : :
9911 [ # # ]: 0 : for (i = 0; i <= nb_segs; i++) {
9912 : : char mz_name[RTE_MEMZONE_NAMESIZE];
9913 : : const struct rte_memzone *memzone;
9914 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9915 : 0 : memzone = rte_memzone_lookup(mz_name);
9916 [ # # ]: 0 : if (memzone != NULL) {
9917 : 0 : rte_memzone_free(memzone);
9918 : : memzone = NULL;
9919 : : }
9920 : : }
9921 : 0 : }
9922 : :
9923 : : static inline struct rte_mbuf *
9924 : 0 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
9925 : : int nb_segs, const void *input_text)
9926 : : {
9927 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
9928 : : size_t data_off = 0;
9929 : : uint8_t *dst;
9930 : : int i, size;
9931 : : int t_len;
9932 : :
9933 [ # # ]: 0 : if (pkt_len < 1) {
9934 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
9935 : 0 : return NULL;
9936 : : }
9937 : :
9938 [ # # ]: 0 : if (nb_segs < 1) {
9939 : : printf("Number of segments must be 1 or more (is %d)\n",
9940 : : nb_segs);
9941 : 0 : return NULL;
9942 : : }
9943 : :
9944 [ # # ]: 0 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
9945 : : size = pkt_len;
9946 : :
9947 : : /* Create chained mbuf_src with external buffer */
9948 [ # # ]: 0 : for (i = 0; size > 0; i++) {
9949 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
9950 : 0 : uint16_t data_len = RTE_MIN(size, t_len);
9951 : : char mz_name[RTE_MEMZONE_NAMESIZE];
9952 : : const struct rte_memzone *memzone;
9953 : : void *ext_buf_addr = NULL;
9954 : : rte_iova_t buf_iova;
9955 : 0 : bool freed = false;
9956 : : uint16_t buf_len;
9957 : :
9958 : 0 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
9959 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
9960 : :
9961 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9962 : 0 : memzone = rte_memzone_lookup(mz_name);
9963 [ # # # # ]: 0 : if (memzone != NULL && memzone->len != buf_len) {
9964 : 0 : rte_memzone_free(memzone);
9965 : : memzone = NULL;
9966 : : }
9967 [ # # ]: 0 : if (memzone == NULL) {
9968 : 0 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
9969 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
9970 [ # # ]: 0 : if (memzone == NULL) {
9971 : : printf("Can't allocate memory zone %s\n", mz_name);
9972 : 0 : return NULL;
9973 : : }
9974 : : }
9975 : :
9976 : 0 : ext_buf_addr = memzone->addr;
9977 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
9978 : :
9979 : : /* Create buffer to hold rte_mbuf header */
9980 : 0 : m = rte_pktmbuf_alloc(mbuf_pool);
9981 [ # # ]: 0 : if (i == 0)
9982 : : mbuf = m;
9983 : :
9984 [ # # ]: 0 : if (m == NULL) {
9985 : : printf("Cannot create segment for source mbuf");
9986 : 0 : goto fail;
9987 : : }
9988 : :
9989 : : /* Save shared data (like callback function) in external buffer's end */
9990 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
9991 : : ext_mbuf_callback_fn_free, &freed);
9992 : : if (ret_shinfo == NULL) {
9993 : : printf("Shared mem initialization failed!\n");
9994 : 0 : goto fail;
9995 : : }
9996 : :
9997 : 0 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
9998 : :
9999 : : /* Attach external buffer to mbuf */
10000 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
10001 : : ret_shinfo);
10002 [ # # ]: 0 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
10003 : : printf("External buffer is not attached to mbuf\n");
10004 : 0 : goto fail;
10005 : : }
10006 : :
10007 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
10008 [ # # ]: 0 : if (dst == NULL) {
10009 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
10010 : 0 : goto fail;
10011 : : }
10012 : :
10013 [ # # ]: 0 : if (mbuf != m)
10014 : : rte_pktmbuf_chain(mbuf, m);
10015 : :
10016 : 0 : size -= data_len;
10017 : 0 : data_off += data_len;
10018 : : }
10019 : :
10020 : : return mbuf;
10021 : :
10022 : : fail:
10023 : 0 : rte_pktmbuf_free(mbuf);
10024 : 0 : ext_mbuf_memzone_free(nb_segs);
10025 : 0 : return NULL;
10026 : : }
10027 : :
10028 : : static int
10029 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10030 : : struct crypto_unittest_params *ut_params,
10031 : : struct rte_security_ipsec_xform *ipsec_xform,
10032 : : const struct ipsec_test_data *td,
10033 : : const struct ipsec_test_flags *flags,
10034 : : int pkt_num)
10035 : : {
10036 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10037 : : enum rte_security_ipsec_sa_direction dir;
10038 : : int ret;
10039 : :
10040 : 0 : dir = ipsec_xform->direction;
10041 : :
10042 : : /* Generate crypto op data structure */
10043 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10044 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10045 [ # # ]: 0 : if (!ut_params->op) {
10046 : : printf("Could not allocate crypto op");
10047 : 0 : return TEST_FAILED;
10048 : : }
10049 : :
10050 : : /* Attach session to operation */
10051 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10052 : :
10053 : : /* Set crypto operation mbufs */
10054 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10055 : 0 : ut_params->op->sym->m_dst = NULL;
10056 : :
10057 : : /* Copy IV in crypto operation when IV generation is disabled */
10058 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10059 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10060 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10061 : : uint8_t *,
10062 : : IV_OFFSET);
10063 : : int len;
10064 : :
10065 [ # # ]: 0 : if (td->aead)
10066 : 0 : len = td->xform.aead.aead.iv.length;
10067 [ # # ]: 0 : else if (td->aes_gmac)
10068 : 0 : len = td->xform.chain.auth.auth.iv.length;
10069 : : else
10070 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10071 : :
10072 : 0 : memcpy(iv, td->iv.data, len);
10073 : : }
10074 : :
10075 : : /* Process crypto operation */
10076 : 0 : process_crypto_request(dev_id, ut_params->op);
10077 : :
10078 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10079 : :
10080 : 0 : rte_crypto_op_free(ut_params->op);
10081 : 0 : ut_params->op = NULL;
10082 : :
10083 : 0 : return ret;
10084 : : }
10085 : :
10086 : : static int
10087 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10088 : : struct crypto_unittest_params *ut_params,
10089 : : void *ctx)
10090 : : {
10091 : : uint64_t timeout, userdata;
10092 : : struct rte_ether_hdr *hdr;
10093 : : struct rte_mbuf *m;
10094 : : void **sec_sess;
10095 : : int ret;
10096 : :
10097 : : RTE_SET_USED(ts_params);
10098 : :
10099 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10100 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10101 : :
10102 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10103 : 0 : ut_params->ibuf->port = 0;
10104 : :
10105 : 0 : sec_sess = &ut_params->sec_session;
10106 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10107 : :
10108 [ # # ]: 0 : if (ret != 1)
10109 : : return TEST_FAILED;
10110 : :
10111 : 0 : ut_params->ibuf = NULL;
10112 : :
10113 : : /* Add a timeout for 1 s */
10114 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10115 : :
10116 : : do {
10117 : : /* Get packet from port 0, queue 0 */
10118 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10119 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10120 : :
10121 [ # # ]: 0 : if (ret == 0) {
10122 : : printf("Could not receive packets from ethdev\n");
10123 : 0 : return TEST_FAILED;
10124 : : }
10125 : :
10126 [ # # ]: 0 : if (m == NULL) {
10127 : : printf("Received mbuf is NULL\n");
10128 : 0 : return TEST_FAILED;
10129 : : }
10130 : :
10131 : 0 : ut_params->ibuf = m;
10132 : :
10133 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10134 : : printf("Received packet is not Rx security processed\n");
10135 : 0 : return TEST_FAILED;
10136 : : }
10137 : :
10138 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10139 : : printf("Received packet has failed Rx security processing\n");
10140 : 0 : return TEST_FAILED;
10141 : : }
10142 : :
10143 : : /*
10144 : : * 'ut_params' is set as userdata. Verify that the field is returned
10145 : : * correctly.
10146 : : */
10147 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10148 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10149 : : printf("Userdata retrieved not matching expected\n");
10150 : 0 : return TEST_FAILED;
10151 : : }
10152 : :
10153 : : /* Trim L2 header */
10154 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10155 : :
10156 : : return TEST_SUCCESS;
10157 : : }
10158 : :
10159 : : static int
10160 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10161 : : struct ipsec_test_data res_d[],
10162 : : int nb_td,
10163 : : bool silent,
10164 : : const struct ipsec_test_flags *flags)
10165 : : {
10166 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10167 : : 0x0000, 0x001a};
10168 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10169 : : 0xe82c, 0x4887};
10170 : : const struct rte_ipv4_hdr *ipv4 =
10171 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10172 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10173 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10174 : : struct crypto_unittest_params *ut_params = &unittest_params;
10175 : : struct rte_security_capability_idx sec_cap_idx;
10176 : : const struct rte_security_capability *sec_cap;
10177 : : struct rte_security_ipsec_xform ipsec_xform;
10178 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10179 : : enum rte_security_ipsec_sa_direction dir;
10180 : : struct ipsec_test_data *res_d_tmp = NULL;
10181 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10182 : : int salt_len, i, ret = TEST_SUCCESS;
10183 : : void *ctx;
10184 : : uint32_t src, dst;
10185 : : uint32_t verify;
10186 : :
10187 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10188 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10189 : :
10190 : : /* Use first test data to create session */
10191 : :
10192 : : /* Copy IPsec xform */
10193 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10194 : :
10195 : 0 : dir = ipsec_xform.direction;
10196 : 0 : verify = flags->tunnel_hdr_verify;
10197 : :
10198 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10199 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10200 : :
10201 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10202 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10203 : 0 : src += 1;
10204 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10205 : 0 : dst += 1;
10206 : : }
10207 : :
10208 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10209 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10210 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10211 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10212 : : sizeof(src));
10213 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10214 : : sizeof(dst));
10215 : :
10216 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10217 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10218 : :
10219 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10220 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10221 : :
10222 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10223 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10224 : :
10225 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10226 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10227 : : TEST_IPSEC_DSCP_VAL;
10228 : :
10229 : : } else {
10230 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10231 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10232 : :
10233 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10234 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10235 : : TEST_IPSEC_DSCP_VAL;
10236 : :
10237 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10238 : : sizeof(v6_src));
10239 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10240 : : sizeof(v6_dst));
10241 : : }
10242 : : }
10243 : :
10244 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10245 : :
10246 : 0 : sec_cap_idx.action = ut_params->type;
10247 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10248 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10249 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10250 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10251 : :
10252 [ # # ]: 0 : if (flags->udp_encap)
10253 : 0 : ipsec_xform.options.udp_encap = 1;
10254 : :
10255 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10256 [ # # ]: 0 : if (sec_cap == NULL)
10257 : : return TEST_SKIPPED;
10258 : :
10259 : : /* Copy cipher session parameters */
10260 [ # # ]: 0 : if (td[0].aead) {
10261 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10262 : : sizeof(ut_params->aead_xform));
10263 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10264 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10265 : :
10266 : : /* Verify crypto capabilities */
10267 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10268 [ # # ]: 0 : if (!silent)
10269 : 0 : RTE_LOG(INFO, USER1,
10270 : : "Crypto capabilities not supported\n");
10271 : 0 : return TEST_SKIPPED;
10272 : : }
10273 [ # # ]: 0 : } else if (td[0].auth_only) {
10274 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10275 : : sizeof(ut_params->auth_xform));
10276 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10277 : :
10278 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10279 [ # # ]: 0 : if (!silent)
10280 : 0 : RTE_LOG(INFO, USER1,
10281 : : "Auth crypto capabilities not supported\n");
10282 : 0 : return TEST_SKIPPED;
10283 : : }
10284 : : } else {
10285 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10286 : : sizeof(ut_params->cipher_xform));
10287 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10288 : : sizeof(ut_params->auth_xform));
10289 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10290 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10291 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10292 : :
10293 : : /* Verify crypto capabilities */
10294 : :
10295 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10296 [ # # ]: 0 : if (!silent)
10297 : 0 : RTE_LOG(INFO, USER1,
10298 : : "Cipher crypto capabilities not supported\n");
10299 : 0 : return TEST_SKIPPED;
10300 : : }
10301 : :
10302 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10303 [ # # ]: 0 : if (!silent)
10304 : 0 : RTE_LOG(INFO, USER1,
10305 : : "Auth crypto capabilities not supported\n");
10306 : 0 : return TEST_SKIPPED;
10307 : : }
10308 : : }
10309 : :
10310 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10311 : : return TEST_SKIPPED;
10312 : :
10313 : 0 : struct rte_security_session_conf sess_conf = {
10314 : 0 : .action_type = ut_params->type,
10315 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10316 : : };
10317 : :
10318 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac) {
10319 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10320 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10321 : : }
10322 : :
10323 [ # # ]: 0 : if (td[0].aead) {
10324 : 0 : sess_conf.ipsec = ipsec_xform;
10325 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10326 [ # # ]: 0 : } else if (td[0].auth_only) {
10327 : 0 : sess_conf.ipsec = ipsec_xform;
10328 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10329 : : } else {
10330 : 0 : sess_conf.ipsec = ipsec_xform;
10331 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10332 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10333 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10334 : : } else {
10335 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10336 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10337 : : }
10338 : : }
10339 : :
10340 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10341 : 0 : sess_conf.userdata = ut_params;
10342 : :
10343 : : /* Create security session */
10344 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10345 : : ts_params->session_mpool);
10346 : :
10347 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10348 : : return TEST_SKIPPED;
10349 : :
10350 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10351 [ # # # # ]: 0 : if (flags->antireplay &&
10352 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10353 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10354 : 0 : ret = rte_security_session_update(ctx,
10355 : : ut_params->sec_session, &sess_conf);
10356 [ # # ]: 0 : if (ret) {
10357 : : printf("Could not update sequence number in "
10358 : : "session\n");
10359 : 0 : return TEST_SKIPPED;
10360 : : }
10361 : : }
10362 : :
10363 : : /* Copy test data before modification */
10364 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10365 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10366 : : ret = TEST_FAILED;
10367 : 0 : goto mbuf_free;
10368 : : }
10369 : :
10370 : : /* Setup source mbuf payload */
10371 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10372 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10373 : 0 : td[i].input_text.len, nb_segs, input_text);
10374 : : } else {
10375 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10376 : 0 : td[i].input_text.len, nb_segs, 0);
10377 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10378 : : }
10379 : :
10380 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10381 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10382 : : ctx);
10383 : : else
10384 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10385 : : ut_params,
10386 : : &ipsec_xform,
10387 : : &td[i], flags,
10388 : : i + 1);
10389 : :
10390 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10391 : 0 : goto mbuf_free;
10392 : :
10393 [ # # ]: 0 : if (res_d != NULL)
10394 : 0 : res_d_tmp = &res_d[i];
10395 : :
10396 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10397 : : res_d_tmp, silent, flags);
10398 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10399 : 0 : goto mbuf_free;
10400 : :
10401 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10402 : : flags, dir);
10403 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10404 : 0 : goto mbuf_free;
10405 : :
10406 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10407 : 0 : ut_params->ibuf = NULL;
10408 : : }
10409 : :
10410 : 0 : mbuf_free:
10411 [ # # ]: 0 : if (flags->use_ext_mbuf)
10412 : 0 : ext_mbuf_memzone_free(nb_segs);
10413 : :
10414 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10415 : 0 : ut_params->ibuf = NULL;
10416 : :
10417 [ # # ]: 0 : if (ut_params->sec_session)
10418 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10419 : 0 : ut_params->sec_session = NULL;
10420 : :
10421 : 0 : return ret;
10422 : : }
10423 : :
10424 : : static int
10425 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10426 : : {
10427 : : struct ipsec_test_data td_outb;
10428 : : struct ipsec_test_flags flags;
10429 : :
10430 : : memset(&flags, 0, sizeof(flags));
10431 : :
10432 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10433 : :
10434 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10435 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10436 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10437 : : /* Disable IV gen to be able to test with known vectors */
10438 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10439 : : }
10440 : :
10441 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10442 : : }
10443 : :
10444 : : static int
10445 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10446 : : {
10447 : : struct ipsec_test_data td_outb;
10448 : : struct ipsec_test_flags flags;
10449 : :
10450 : : memset(&flags, 0, sizeof(flags));
10451 [ # # ]: 0 : flags.use_ext_mbuf = true;
10452 : :
10453 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10454 : :
10455 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10456 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10457 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10458 : : /* Disable IV gen to be able to test with known vectors */
10459 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10460 : : }
10461 : :
10462 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10463 : : }
10464 : :
10465 : : static int
10466 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10467 : : {
10468 : : const struct ipsec_test_data *td = test_data;
10469 : : struct ipsec_test_flags flags;
10470 : : struct ipsec_test_data td_inb;
10471 : :
10472 : : memset(&flags, 0, sizeof(flags));
10473 : :
10474 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10475 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10476 : : else
10477 : : memcpy(&td_inb, td, sizeof(td_inb));
10478 : :
10479 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10480 : : }
10481 : :
10482 : : static int
10483 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10484 : : {
10485 : : struct ipsec_test_data td_outb;
10486 : : struct ipsec_test_flags flags;
10487 : :
10488 : : memset(&flags, 0, sizeof(flags));
10489 : 0 : flags.fragment = true;
10490 : :
10491 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10492 : :
10493 : : /* Disable IV gen to be able to test with known vectors */
10494 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10495 : :
10496 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10497 : : }
10498 : :
10499 : : static int
10500 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10501 : : {
10502 : : const struct ipsec_test_data *td = test_data;
10503 : : struct ipsec_test_flags flags;
10504 : : struct ipsec_test_data td_inb;
10505 : :
10506 : : memset(&flags, 0, sizeof(flags));
10507 : 0 : flags.rx_inject = true;
10508 : :
10509 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10510 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10511 : : else
10512 : : memcpy(&td_inb, td, sizeof(td_inb));
10513 : :
10514 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10515 : : }
10516 : :
10517 : : static int
10518 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10519 : : {
10520 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10521 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10522 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10523 : : int ret;
10524 : :
10525 [ # # ]: 0 : if (flags->iv_gen ||
10526 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10527 : : flags->sa_expiry_pkts_hard)
10528 : : nb_pkts = TEST_SEC_PKTS_MAX;
10529 : :
10530 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10531 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10532 : : sec_alg_list[i].param2,
10533 : : flags,
10534 : : td_outb,
10535 : : nb_pkts);
10536 : :
10537 [ # # ]: 0 : if (!td_outb->aead) {
10538 : : enum rte_crypto_cipher_algorithm cipher_alg;
10539 : : enum rte_crypto_auth_algorithm auth_alg;
10540 : :
10541 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10542 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10543 : :
10544 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10545 : 0 : continue;
10546 : :
10547 : : /* ICV is not applicable for NULL auth */
10548 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10549 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10550 : 0 : continue;
10551 : :
10552 : : /* IV is not applicable for NULL cipher */
10553 [ # # # # ]: 0 : if (flags->iv_gen &&
10554 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10555 : 0 : continue;
10556 : : }
10557 : :
10558 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10559 : : flags);
10560 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10561 : 0 : continue;
10562 : :
10563 [ # # ]: 0 : if (ret == TEST_FAILED)
10564 : : return TEST_FAILED;
10565 : :
10566 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10567 : :
10568 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10569 : : flags);
10570 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10571 : 0 : continue;
10572 : :
10573 [ # # ]: 0 : if (ret == TEST_FAILED)
10574 : : return TEST_FAILED;
10575 : :
10576 [ # # ]: 0 : if (flags->display_alg)
10577 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10578 : :
10579 : 0 : pass_cnt++;
10580 : : }
10581 : :
10582 [ # # ]: 0 : if (pass_cnt > 0)
10583 : : return TEST_SUCCESS;
10584 : : else
10585 : 0 : return TEST_SKIPPED;
10586 : : }
10587 : :
10588 : : static int
10589 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10590 : : {
10591 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10592 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10593 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10594 : : int ret;
10595 : :
10596 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10597 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10598 : : sec_auth_only_alg_list[i].param2,
10599 : : flags,
10600 : : td_outb,
10601 : : nb_pkts);
10602 : :
10603 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10604 : : flags);
10605 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10606 : 0 : continue;
10607 : :
10608 [ # # ]: 0 : if (ret == TEST_FAILED)
10609 : : return TEST_FAILED;
10610 : :
10611 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10612 : :
10613 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10614 : : flags);
10615 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10616 : 0 : continue;
10617 : :
10618 [ # # ]: 0 : if (ret == TEST_FAILED)
10619 : : return TEST_FAILED;
10620 : :
10621 [ # # ]: 0 : if (flags->display_alg)
10622 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10623 : : sec_auth_only_alg_list[i].param2);
10624 : :
10625 : 0 : pass_cnt++;
10626 : : }
10627 : :
10628 [ # # ]: 0 : if (pass_cnt > 0)
10629 : : return TEST_SUCCESS;
10630 : : else
10631 : 0 : return TEST_SKIPPED;
10632 : : }
10633 : :
10634 : : static int
10635 : 0 : test_ipsec_proto_display_list(void)
10636 : : {
10637 : : struct ipsec_test_flags flags;
10638 : :
10639 : : memset(&flags, 0, sizeof(flags));
10640 : :
10641 : 0 : flags.display_alg = true;
10642 : :
10643 : 0 : return test_ipsec_proto_all(&flags);
10644 : : }
10645 : :
10646 : : static int
10647 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10648 : : {
10649 : : struct ipsec_test_flags flags;
10650 : :
10651 : : memset(&flags, 0, sizeof(flags));
10652 : :
10653 : 0 : flags.ah = true;
10654 : 0 : flags.display_alg = true;
10655 : :
10656 : 0 : return test_ipsec_ah_proto_all(&flags);
10657 : : }
10658 : :
10659 : : static int
10660 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10661 : : {
10662 : : struct ipsec_test_flags flags;
10663 : :
10664 : : memset(&flags, 0, sizeof(flags));
10665 : :
10666 : 0 : flags.ah = true;
10667 : 0 : flags.transport = true;
10668 : :
10669 : 0 : return test_ipsec_ah_proto_all(&flags);
10670 : : }
10671 : :
10672 : : static int
10673 : 0 : test_ipsec_proto_iv_gen(void)
10674 : : {
10675 : : struct ipsec_test_flags flags;
10676 : :
10677 : : memset(&flags, 0, sizeof(flags));
10678 : :
10679 : 0 : flags.iv_gen = true;
10680 : :
10681 : 0 : return test_ipsec_proto_all(&flags);
10682 : : }
10683 : :
10684 : : static int
10685 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10686 : : {
10687 : : struct ipsec_test_flags flags;
10688 : :
10689 : : memset(&flags, 0, sizeof(flags));
10690 : :
10691 : 0 : flags.sa_expiry_pkts_soft = true;
10692 : :
10693 : 0 : return test_ipsec_proto_all(&flags);
10694 : : }
10695 : :
10696 : : static int
10697 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10698 : : {
10699 : : struct ipsec_test_flags flags;
10700 : :
10701 : : memset(&flags, 0, sizeof(flags));
10702 : :
10703 : 0 : flags.sa_expiry_pkts_hard = true;
10704 : :
10705 : 0 : return test_ipsec_proto_all(&flags);
10706 : : }
10707 : :
10708 : : static int
10709 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10710 : : {
10711 : : struct ipsec_test_flags flags;
10712 : :
10713 : : memset(&flags, 0, sizeof(flags));
10714 : :
10715 : 0 : flags.icv_corrupt = true;
10716 : :
10717 : 0 : return test_ipsec_proto_all(&flags);
10718 : : }
10719 : :
10720 : : static int
10721 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10722 : : {
10723 : : struct ipsec_test_flags flags;
10724 : :
10725 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10726 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10727 : : return TEST_SKIPPED;
10728 : :
10729 : : memset(&flags, 0, sizeof(flags));
10730 : :
10731 : 0 : flags.udp_encap = true;
10732 : 0 : flags.udp_encap_custom_ports = true;
10733 : :
10734 : 0 : return test_ipsec_proto_all(&flags);
10735 : : }
10736 : :
10737 : : static int
10738 : 0 : test_ipsec_proto_udp_encap(void)
10739 : : {
10740 : : struct ipsec_test_flags flags;
10741 : :
10742 : : memset(&flags, 0, sizeof(flags));
10743 : :
10744 : 0 : flags.udp_encap = true;
10745 : :
10746 : 0 : return test_ipsec_proto_all(&flags);
10747 : : }
10748 : :
10749 : : static int
10750 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10751 : : {
10752 : : struct ipsec_test_flags flags;
10753 : :
10754 : : memset(&flags, 0, sizeof(flags));
10755 : :
10756 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10757 : :
10758 : 0 : return test_ipsec_proto_all(&flags);
10759 : : }
10760 : :
10761 : : static int
10762 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
10763 : : {
10764 : : struct ipsec_test_flags flags;
10765 : :
10766 : : memset(&flags, 0, sizeof(flags));
10767 : :
10768 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10769 : :
10770 : 0 : return test_ipsec_proto_all(&flags);
10771 : : }
10772 : :
10773 : : static int
10774 : 0 : test_ipsec_proto_udp_ports_verify(void)
10775 : : {
10776 : : struct ipsec_test_flags flags;
10777 : :
10778 : : memset(&flags, 0, sizeof(flags));
10779 : :
10780 : 0 : flags.udp_encap = true;
10781 : 0 : flags.udp_ports_verify = true;
10782 : :
10783 : 0 : return test_ipsec_proto_all(&flags);
10784 : : }
10785 : :
10786 : : static int
10787 : 0 : test_ipsec_proto_inner_ip_csum(void)
10788 : : {
10789 : : struct ipsec_test_flags flags;
10790 : :
10791 : : memset(&flags, 0, sizeof(flags));
10792 : :
10793 : 0 : flags.ip_csum = true;
10794 : :
10795 : 0 : return test_ipsec_proto_all(&flags);
10796 : : }
10797 : :
10798 : : static int
10799 : 0 : test_ipsec_proto_inner_l4_csum(void)
10800 : : {
10801 : : struct ipsec_test_flags flags;
10802 : :
10803 : : memset(&flags, 0, sizeof(flags));
10804 : :
10805 : 0 : flags.l4_csum = true;
10806 : :
10807 : 0 : return test_ipsec_proto_all(&flags);
10808 : : }
10809 : :
10810 : : static int
10811 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
10812 : : {
10813 : : struct ipsec_test_flags flags;
10814 : :
10815 : : memset(&flags, 0, sizeof(flags));
10816 : :
10817 : : flags.ipv6 = false;
10818 : : flags.tunnel_ipv6 = false;
10819 : :
10820 : 0 : return test_ipsec_proto_all(&flags);
10821 : : }
10822 : :
10823 : : static int
10824 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
10825 : : {
10826 : : struct ipsec_test_flags flags;
10827 : :
10828 : : memset(&flags, 0, sizeof(flags));
10829 : :
10830 : 0 : flags.ipv6 = true;
10831 : 0 : flags.tunnel_ipv6 = true;
10832 : :
10833 : 0 : return test_ipsec_proto_all(&flags);
10834 : : }
10835 : :
10836 : : static int
10837 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
10838 : : {
10839 : : struct ipsec_test_flags flags;
10840 : :
10841 : : memset(&flags, 0, sizeof(flags));
10842 : :
10843 : : flags.ipv6 = false;
10844 : 0 : flags.tunnel_ipv6 = true;
10845 : :
10846 : 0 : return test_ipsec_proto_all(&flags);
10847 : : }
10848 : :
10849 : : static int
10850 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
10851 : : {
10852 : : struct ipsec_test_flags flags;
10853 : :
10854 : : memset(&flags, 0, sizeof(flags));
10855 : :
10856 : 0 : flags.ipv6 = true;
10857 : : flags.tunnel_ipv6 = false;
10858 : :
10859 : 0 : return test_ipsec_proto_all(&flags);
10860 : : }
10861 : :
10862 : : static int
10863 : 0 : test_ipsec_proto_transport_v4(void)
10864 : : {
10865 : : struct ipsec_test_flags flags;
10866 : :
10867 : : memset(&flags, 0, sizeof(flags));
10868 : :
10869 : : flags.ipv6 = false;
10870 : 0 : flags.transport = true;
10871 : :
10872 : 0 : return test_ipsec_proto_all(&flags);
10873 : : }
10874 : :
10875 : : static int
10876 : 0 : test_ipsec_proto_transport_l4_csum(void)
10877 : : {
10878 : 0 : struct ipsec_test_flags flags = {
10879 : : .l4_csum = true,
10880 : : .transport = true,
10881 : : };
10882 : :
10883 : 0 : return test_ipsec_proto_all(&flags);
10884 : : }
10885 : :
10886 : : static int
10887 : 0 : test_ipsec_proto_stats(void)
10888 : : {
10889 : : struct ipsec_test_flags flags;
10890 : :
10891 : : memset(&flags, 0, sizeof(flags));
10892 : :
10893 : 0 : flags.stats_success = true;
10894 : :
10895 : 0 : return test_ipsec_proto_all(&flags);
10896 : : }
10897 : :
10898 : : static int
10899 : 0 : test_ipsec_proto_pkt_fragment(void)
10900 : : {
10901 : : struct ipsec_test_flags flags;
10902 : :
10903 : : memset(&flags, 0, sizeof(flags));
10904 : :
10905 : 0 : flags.fragment = true;
10906 : :
10907 : 0 : return test_ipsec_proto_all(&flags);
10908 : :
10909 : : }
10910 : :
10911 : : static int
10912 : 0 : test_ipsec_proto_copy_df_inner_0(void)
10913 : : {
10914 : : struct ipsec_test_flags flags;
10915 : :
10916 : : memset(&flags, 0, sizeof(flags));
10917 : :
10918 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10919 : :
10920 : 0 : return test_ipsec_proto_all(&flags);
10921 : : }
10922 : :
10923 : : static int
10924 : 0 : test_ipsec_proto_copy_df_inner_1(void)
10925 : : {
10926 : : struct ipsec_test_flags flags;
10927 : :
10928 : : memset(&flags, 0, sizeof(flags));
10929 : :
10930 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10931 : :
10932 : 0 : return test_ipsec_proto_all(&flags);
10933 : : }
10934 : :
10935 : : static int
10936 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
10937 : : {
10938 : : struct ipsec_test_flags flags;
10939 : :
10940 : : memset(&flags, 0, sizeof(flags));
10941 : :
10942 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10943 : :
10944 : 0 : return test_ipsec_proto_all(&flags);
10945 : : }
10946 : :
10947 : : static int
10948 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
10949 : : {
10950 : : struct ipsec_test_flags flags;
10951 : :
10952 : : memset(&flags, 0, sizeof(flags));
10953 : :
10954 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10955 : :
10956 : 0 : return test_ipsec_proto_all(&flags);
10957 : : }
10958 : :
10959 : : static int
10960 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10961 : : {
10962 : : struct ipsec_test_flags flags;
10963 : :
10964 : : memset(&flags, 0, sizeof(flags));
10965 : :
10966 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10967 : :
10968 : 0 : return test_ipsec_proto_all(&flags);
10969 : : }
10970 : :
10971 : : static int
10972 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
10973 : : {
10974 : : struct ipsec_test_flags flags;
10975 : :
10976 : : memset(&flags, 0, sizeof(flags));
10977 : :
10978 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10979 : :
10980 : 0 : return test_ipsec_proto_all(&flags);
10981 : : }
10982 : :
10983 : : static int
10984 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
10985 : : {
10986 : : struct ipsec_test_flags flags;
10987 : :
10988 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10989 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10990 : : return TEST_SKIPPED;
10991 : :
10992 : : memset(&flags, 0, sizeof(flags));
10993 : :
10994 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10995 : :
10996 : 0 : return test_ipsec_proto_all(&flags);
10997 : : }
10998 : :
10999 : : static int
11000 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11001 : : {
11002 : : struct ipsec_test_flags flags;
11003 : :
11004 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11005 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11006 : : return TEST_SKIPPED;
11007 : :
11008 : : memset(&flags, 0, sizeof(flags));
11009 : :
11010 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11011 : :
11012 : 0 : return test_ipsec_proto_all(&flags);
11013 : : }
11014 : :
11015 : : static int
11016 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11017 : : {
11018 : : struct ipsec_test_flags flags;
11019 : :
11020 : : memset(&flags, 0, sizeof(flags));
11021 : :
11022 : 0 : flags.ipv6 = true;
11023 : 0 : flags.tunnel_ipv6 = true;
11024 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11025 : :
11026 : 0 : return test_ipsec_proto_all(&flags);
11027 : : }
11028 : :
11029 : : static int
11030 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11031 : : {
11032 : : struct ipsec_test_flags flags;
11033 : :
11034 : : memset(&flags, 0, sizeof(flags));
11035 : :
11036 : 0 : flags.ipv6 = true;
11037 : 0 : flags.tunnel_ipv6 = true;
11038 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11039 : :
11040 : 0 : return test_ipsec_proto_all(&flags);
11041 : : }
11042 : :
11043 : : static int
11044 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11045 : : {
11046 : : struct ipsec_test_flags flags;
11047 : :
11048 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11049 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11050 : : return TEST_SKIPPED;
11051 : :
11052 : : memset(&flags, 0, sizeof(flags));
11053 : :
11054 : 0 : flags.ipv6 = true;
11055 : 0 : flags.tunnel_ipv6 = true;
11056 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11057 : :
11058 : 0 : return test_ipsec_proto_all(&flags);
11059 : : }
11060 : :
11061 : : static int
11062 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11063 : : {
11064 : : struct ipsec_test_flags flags;
11065 : :
11066 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11067 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11068 : : return TEST_SKIPPED;
11069 : :
11070 : : memset(&flags, 0, sizeof(flags));
11071 : :
11072 : 0 : flags.ipv6 = true;
11073 : 0 : flags.tunnel_ipv6 = true;
11074 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11075 : :
11076 : 0 : return test_ipsec_proto_all(&flags);
11077 : : }
11078 : :
11079 : : static int
11080 : 0 : test_ipsec_proto_sgl(void)
11081 : : {
11082 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11083 : : struct rte_cryptodev_info dev_info;
11084 : :
11085 : 0 : struct ipsec_test_flags flags = {
11086 : : .nb_segs_in_mbuf = 5
11087 : : };
11088 : :
11089 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11090 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11091 : : printf("Device doesn't support in-place scatter-gather. "
11092 : : "Test Skipped.\n");
11093 : 0 : return TEST_SKIPPED;
11094 : : }
11095 : :
11096 : 0 : return test_ipsec_proto_all(&flags);
11097 : : }
11098 : :
11099 : : static int
11100 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11101 : : {
11102 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11103 : : struct rte_cryptodev_info dev_info;
11104 : :
11105 : 0 : struct ipsec_test_flags flags = {
11106 : : .nb_segs_in_mbuf = 5,
11107 : : .use_ext_mbuf = 1
11108 : : };
11109 : :
11110 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11111 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11112 : : printf("Device doesn't support in-place scatter-gather. "
11113 : : "Test Skipped.\n");
11114 : 0 : return TEST_SKIPPED;
11115 : : }
11116 : :
11117 : 0 : return test_ipsec_proto_all(&flags);
11118 : : }
11119 : :
11120 : : static int
11121 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11122 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11123 : : uint64_t winsz)
11124 : : {
11125 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11126 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11127 : : struct ipsec_test_flags flags;
11128 : : uint32_t i = 0, ret = 0;
11129 : :
11130 [ # # ]: 0 : if (nb_pkts == 0)
11131 : : return TEST_FAILED;
11132 : :
11133 : : memset(&flags, 0, sizeof(flags));
11134 : 0 : flags.antireplay = true;
11135 : :
11136 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11137 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11138 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11139 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11140 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11141 : : }
11142 : :
11143 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11144 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11145 : :
11146 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11147 : : &flags);
11148 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11149 : : return ret;
11150 : :
11151 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11152 : :
11153 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11154 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11155 : : /* Set antireplay flag for packets to be dropped */
11156 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11157 : : }
11158 : :
11159 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11160 : : &flags);
11161 : :
11162 : 0 : return ret;
11163 : : }
11164 : :
11165 : : static int
11166 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11167 : : {
11168 : :
11169 : : uint32_t nb_pkts = 5;
11170 : : bool replayed_pkt[5];
11171 : : uint64_t esn[5];
11172 : :
11173 : : /* 1. Advance the TOP of the window to WS * 2 */
11174 : 0 : esn[0] = winsz * 2;
11175 : : /* 2. Test sequence number within the new window(WS + 1) */
11176 : 0 : esn[1] = winsz + 1;
11177 : : /* 3. Test sequence number less than the window BOTTOM */
11178 : 0 : esn[2] = winsz;
11179 : : /* 4. Test sequence number in the middle of the window */
11180 : 0 : esn[3] = winsz + (winsz / 2);
11181 : : /* 5. Test replay of the packet in the middle of the window */
11182 : 0 : esn[4] = winsz + (winsz / 2);
11183 : :
11184 : 0 : replayed_pkt[0] = false;
11185 : 0 : replayed_pkt[1] = false;
11186 : 0 : replayed_pkt[2] = true;
11187 : 0 : replayed_pkt[3] = false;
11188 : 0 : replayed_pkt[4] = true;
11189 : :
11190 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11191 : : false, winsz);
11192 : : }
11193 : :
11194 : : static int
11195 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11196 : : {
11197 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11198 : : }
11199 : :
11200 : : static int
11201 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11202 : : {
11203 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11204 : : }
11205 : :
11206 : : static int
11207 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11208 : : {
11209 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11210 : : }
11211 : :
11212 : : static int
11213 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11214 : : {
11215 : :
11216 : : uint32_t nb_pkts = 7;
11217 : : bool replayed_pkt[7];
11218 : : uint64_t esn[7];
11219 : :
11220 : : /* Set the initial sequence number */
11221 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11222 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11223 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11224 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11225 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11226 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11227 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11228 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11229 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11230 : : /* 5. Test with duplicate sequence number within
11231 : : * new window (1<<32 - 1)
11232 : : */
11233 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11234 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11235 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11236 : :
11237 : 0 : replayed_pkt[0] = false;
11238 : 0 : replayed_pkt[1] = false;
11239 : 0 : replayed_pkt[2] = false;
11240 : 0 : replayed_pkt[3] = false;
11241 : 0 : replayed_pkt[4] = false;
11242 : 0 : replayed_pkt[5] = true;
11243 : 0 : replayed_pkt[6] = true;
11244 : :
11245 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11246 : : true, winsz);
11247 : : }
11248 : :
11249 : : static int
11250 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11251 : : {
11252 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11253 : : }
11254 : :
11255 : : static int
11256 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11257 : : {
11258 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11259 : : }
11260 : :
11261 : : static int
11262 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11263 : : {
11264 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11265 : : }
11266 : :
11267 : : static int
11268 : 0 : test_PDCP_PROTO_all(void)
11269 : : {
11270 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11271 : : struct crypto_unittest_params *ut_params = &unittest_params;
11272 : : struct rte_cryptodev_info dev_info;
11273 : : int status;
11274 : :
11275 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11276 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11277 : :
11278 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11279 : : return TEST_SKIPPED;
11280 : :
11281 : : /* Set action type */
11282 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11283 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11284 : : gbl_action_type;
11285 : :
11286 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11287 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11288 : : return TEST_SKIPPED;
11289 : :
11290 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11291 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11292 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11293 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11294 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11295 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11296 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11297 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11298 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11299 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11300 : 0 : status += test_PDCP_PROTO_short_mac();
11301 : :
11302 [ # # ]: 0 : if (status)
11303 : : return TEST_FAILED;
11304 : : else
11305 : 0 : return TEST_SUCCESS;
11306 : : }
11307 : :
11308 : : static int
11309 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11310 : : {
11311 : 0 : struct ipsec_test_flags flags = {
11312 : : .dec_ttl_or_hop_limit = true
11313 : : };
11314 : :
11315 : 0 : return test_ipsec_proto_all(&flags);
11316 : : }
11317 : :
11318 : : static int
11319 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11320 : : {
11321 : 0 : struct ipsec_test_flags flags = {
11322 : : .ipv6 = true,
11323 : : .dec_ttl_or_hop_limit = true
11324 : : };
11325 : :
11326 : 0 : return test_ipsec_proto_all(&flags);
11327 : : }
11328 : :
11329 : : static int
11330 : 0 : test_docsis_proto_uplink(const void *data)
11331 : : {
11332 : : const struct docsis_test_data *d_td = data;
11333 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11334 : : struct crypto_unittest_params *ut_params = &unittest_params;
11335 : : uint8_t *plaintext = NULL;
11336 : : uint8_t *ciphertext = NULL;
11337 : : uint8_t *iv_ptr;
11338 : : int32_t cipher_len, crc_len;
11339 : : uint32_t crc_data_len;
11340 : : int ret = TEST_SUCCESS;
11341 : :
11342 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11343 : :
11344 : : /* Verify the capabilities */
11345 : : struct rte_security_capability_idx sec_cap_idx;
11346 : : const struct rte_security_capability *sec_cap;
11347 : : const struct rte_cryptodev_capabilities *crypto_cap;
11348 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11349 : : int j = 0;
11350 : :
11351 : : /* Set action type */
11352 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11353 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11354 : : gbl_action_type;
11355 : :
11356 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11357 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11358 : : return TEST_SKIPPED;
11359 : :
11360 : 0 : sec_cap_idx.action = ut_params->type;
11361 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11362 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11363 : :
11364 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11365 [ # # ]: 0 : if (sec_cap == NULL)
11366 : : return TEST_SKIPPED;
11367 : :
11368 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11369 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11370 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11371 : : crypto_cap->sym.xform_type ==
11372 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11373 : : crypto_cap->sym.cipher.algo ==
11374 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11375 : 0 : sym_cap = &crypto_cap->sym;
11376 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11377 : 0 : d_td->key.len,
11378 : 0 : d_td->iv.len) == 0)
11379 : : break;
11380 : : }
11381 : : }
11382 : :
11383 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11384 : : return TEST_SKIPPED;
11385 : :
11386 : : /* Setup source mbuf payload */
11387 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11388 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11389 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11390 : :
11391 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11392 : 0 : d_td->ciphertext.len);
11393 : :
11394 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11395 : :
11396 : : /* Setup cipher session parameters */
11397 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11398 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11399 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11400 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11401 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11402 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11403 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11404 : 0 : ut_params->cipher_xform.next = NULL;
11405 : :
11406 : : /* Setup DOCSIS session parameters */
11407 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11408 : :
11409 : 0 : struct rte_security_session_conf sess_conf = {
11410 : 0 : .action_type = ut_params->type,
11411 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11412 : : .docsis = ut_params->docsis_xform,
11413 : : .crypto_xform = &ut_params->cipher_xform,
11414 : : };
11415 : :
11416 : : /* Create security session */
11417 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11418 : : ts_params->session_mpool);
11419 : :
11420 [ # # ]: 0 : if (!ut_params->sec_session) {
11421 : : printf("Test function %s line %u: failed to allocate session\n",
11422 : : __func__, __LINE__);
11423 : : ret = TEST_FAILED;
11424 : 0 : goto on_err;
11425 : : }
11426 : :
11427 : : /* Generate crypto op data structure */
11428 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11429 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11430 [ # # ]: 0 : if (!ut_params->op) {
11431 : : printf("Test function %s line %u: failed to allocate symmetric "
11432 : : "crypto operation\n", __func__, __LINE__);
11433 : : ret = TEST_FAILED;
11434 : 0 : goto on_err;
11435 : : }
11436 : :
11437 : : /* Setup CRC operation parameters */
11438 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11439 : 0 : (d_td->ciphertext.len -
11440 : 0 : d_td->ciphertext.crc_offset -
11441 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11442 : : 0;
11443 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11444 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11445 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11446 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11447 : :
11448 : : /* Setup cipher operation parameters */
11449 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11450 : 0 : (d_td->ciphertext.len -
11451 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11452 : : 0;
11453 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11454 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11455 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11456 : :
11457 : : /* Setup cipher IV */
11458 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11459 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11460 : :
11461 : : /* Attach session to operation */
11462 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11463 : :
11464 : : /* Set crypto operation mbufs */
11465 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11466 : 0 : ut_params->op->sym->m_dst = NULL;
11467 : :
11468 : : /* Process crypto operation */
11469 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11470 : : NULL) {
11471 : : printf("Test function %s line %u: failed to process security "
11472 : : "crypto op\n", __func__, __LINE__);
11473 : : ret = TEST_FAILED;
11474 : 0 : goto on_err;
11475 : : }
11476 : :
11477 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11478 : : printf("Test function %s line %u: failed to process crypto op\n",
11479 : : __func__, __LINE__);
11480 : : ret = TEST_FAILED;
11481 : 0 : goto on_err;
11482 : : }
11483 : :
11484 : : /* Validate plaintext */
11485 : : plaintext = ciphertext;
11486 : :
11487 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11488 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11489 : : printf("Test function %s line %u: plaintext not as expected\n",
11490 : : __func__, __LINE__);
11491 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11492 : 0 : d_td->plaintext.len);
11493 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11494 : : ret = TEST_FAILED;
11495 : 0 : goto on_err;
11496 : : }
11497 : :
11498 : 0 : on_err:
11499 : 0 : rte_crypto_op_free(ut_params->op);
11500 : 0 : ut_params->op = NULL;
11501 : :
11502 [ # # ]: 0 : if (ut_params->sec_session)
11503 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11504 : 0 : ut_params->sec_session = NULL;
11505 : :
11506 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11507 : 0 : ut_params->ibuf = NULL;
11508 : :
11509 : 0 : return ret;
11510 : : }
11511 : :
11512 : : static int
11513 : 0 : test_docsis_proto_downlink(const void *data)
11514 : : {
11515 : : const struct docsis_test_data *d_td = data;
11516 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11517 : : struct crypto_unittest_params *ut_params = &unittest_params;
11518 : : uint8_t *plaintext = NULL;
11519 : : uint8_t *ciphertext = NULL;
11520 : : uint8_t *iv_ptr;
11521 : : int32_t cipher_len, crc_len;
11522 : : int ret = TEST_SUCCESS;
11523 : :
11524 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11525 : :
11526 : : /* Verify the capabilities */
11527 : : struct rte_security_capability_idx sec_cap_idx;
11528 : : const struct rte_security_capability *sec_cap;
11529 : : const struct rte_cryptodev_capabilities *crypto_cap;
11530 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11531 : : int j = 0;
11532 : :
11533 : : /* Set action type */
11534 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11535 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11536 : : gbl_action_type;
11537 : :
11538 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11539 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11540 : : return TEST_SKIPPED;
11541 : :
11542 : 0 : sec_cap_idx.action = ut_params->type;
11543 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11544 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11545 : :
11546 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11547 [ # # ]: 0 : if (sec_cap == NULL)
11548 : : return TEST_SKIPPED;
11549 : :
11550 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11551 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11552 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11553 : : crypto_cap->sym.xform_type ==
11554 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11555 : : crypto_cap->sym.cipher.algo ==
11556 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11557 : 0 : sym_cap = &crypto_cap->sym;
11558 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11559 : 0 : d_td->key.len,
11560 : 0 : d_td->iv.len) == 0)
11561 : : break;
11562 : : }
11563 : : }
11564 : :
11565 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11566 : : return TEST_SKIPPED;
11567 : :
11568 : : /* Setup source mbuf payload */
11569 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11570 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11571 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11572 : :
11573 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11574 : 0 : d_td->plaintext.len);
11575 : :
11576 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11577 : :
11578 : : /* Setup cipher session parameters */
11579 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11580 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11581 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11582 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11583 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11584 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11585 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11586 : 0 : ut_params->cipher_xform.next = NULL;
11587 : :
11588 : : /* Setup DOCSIS session parameters */
11589 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11590 : :
11591 : 0 : struct rte_security_session_conf sess_conf = {
11592 : 0 : .action_type = ut_params->type,
11593 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11594 : : .docsis = ut_params->docsis_xform,
11595 : : .crypto_xform = &ut_params->cipher_xform,
11596 : : };
11597 : :
11598 : : /* Create security session */
11599 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11600 : : ts_params->session_mpool);
11601 : :
11602 [ # # ]: 0 : if (!ut_params->sec_session) {
11603 : : printf("Test function %s line %u: failed to allocate session\n",
11604 : : __func__, __LINE__);
11605 : : ret = TEST_FAILED;
11606 : 0 : goto on_err;
11607 : : }
11608 : :
11609 : : /* Generate crypto op data structure */
11610 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11611 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11612 [ # # ]: 0 : if (!ut_params->op) {
11613 : : printf("Test function %s line %u: failed to allocate symmetric "
11614 : : "crypto operation\n", __func__, __LINE__);
11615 : : ret = TEST_FAILED;
11616 : 0 : goto on_err;
11617 : : }
11618 : :
11619 : : /* Setup CRC operation parameters */
11620 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11621 : 0 : (d_td->plaintext.len -
11622 : 0 : d_td->plaintext.crc_offset -
11623 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11624 : : 0;
11625 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11626 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11627 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11628 : :
11629 : : /* Setup cipher operation parameters */
11630 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11631 : 0 : (d_td->plaintext.len -
11632 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11633 : : 0;
11634 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11635 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11636 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11637 : :
11638 : : /* Setup cipher IV */
11639 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11640 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11641 : :
11642 : : /* Attach session to operation */
11643 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11644 : :
11645 : : /* Set crypto operation mbufs */
11646 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11647 : 0 : ut_params->op->sym->m_dst = NULL;
11648 : :
11649 : : /* Process crypto operation */
11650 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11651 : : NULL) {
11652 : : printf("Test function %s line %u: failed to process crypto op\n",
11653 : : __func__, __LINE__);
11654 : : ret = TEST_FAILED;
11655 : 0 : goto on_err;
11656 : : }
11657 : :
11658 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11659 : : printf("Test function %s line %u: crypto op processing failed\n",
11660 : : __func__, __LINE__);
11661 : : ret = TEST_FAILED;
11662 : 0 : goto on_err;
11663 : : }
11664 : :
11665 : : /* Validate ciphertext */
11666 : : ciphertext = plaintext;
11667 : :
11668 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11669 : : printf("Test function %s line %u: plaintext not as expected\n",
11670 : : __func__, __LINE__);
11671 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11672 : 0 : d_td->ciphertext.len);
11673 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11674 : : ret = TEST_FAILED;
11675 : 0 : goto on_err;
11676 : : }
11677 : :
11678 : 0 : on_err:
11679 : 0 : rte_crypto_op_free(ut_params->op);
11680 : 0 : ut_params->op = NULL;
11681 : :
11682 [ # # ]: 0 : if (ut_params->sec_session)
11683 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11684 : 0 : ut_params->sec_session = NULL;
11685 : :
11686 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11687 : 0 : ut_params->ibuf = NULL;
11688 : :
11689 : 0 : return ret;
11690 : : }
11691 : :
11692 : : static void
11693 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11694 : : struct rte_security_tls_record_xform *tls_record_xform)
11695 : : {
11696 : : unsigned int imp_nonce_len;
11697 : : uint8_t *imp_nonce;
11698 : :
11699 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11700 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11701 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11702 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11703 : 0 : break;
11704 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11705 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11706 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11707 : 0 : break;
11708 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
11709 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11710 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11711 : 0 : break;
11712 : : default:
11713 : : return;
11714 : : }
11715 : :
11716 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11717 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11718 : : }
11719 : :
11720 : : static int
11721 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
11722 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
11723 : : const struct tls_record_test_flags *flags)
11724 : : {
11725 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11726 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11727 : : struct crypto_unittest_params *ut_params = &unittest_params;
11728 : : struct rte_security_tls_record_xform tls_record_xform;
11729 : : struct rte_security_capability_idx sec_cap_idx;
11730 : : const struct rte_security_capability *sec_cap;
11731 : : struct tls_record_test_data *res_d_tmp = NULL;
11732 : : enum rte_security_tls_sess_type sess_type;
11733 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
11734 : : struct rte_security_ctx *ctx;
11735 : : int i, ret = TEST_SUCCESS;
11736 : :
11737 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11738 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11739 : :
11740 : : /* Use first test data to create session */
11741 : :
11742 : : /* Copy TLS record xform */
11743 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11744 : :
11745 : 0 : sess_type = tls_record_xform.type;
11746 : :
11747 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
11748 : :
11749 : 0 : sec_cap_idx.action = ut_params->type;
11750 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11751 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
11752 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11753 : :
11754 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11755 [ # # ]: 0 : if (sec_cap == NULL)
11756 : : return TEST_SKIPPED;
11757 : :
11758 : : /* Copy cipher session parameters */
11759 [ # # ]: 0 : if (td[0].aead) {
11760 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11761 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
11762 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11763 : :
11764 : : /* Verify crypto capabilities */
11765 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11766 [ # # ]: 0 : if (!silent)
11767 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11768 : 0 : return TEST_SKIPPED;
11769 : : }
11770 : : } else {
11771 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
11772 : : sizeof(ut_params->cipher_xform));
11773 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
11774 : : sizeof(ut_params->auth_xform));
11775 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
11776 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11777 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
11778 : :
11779 : : /* Verify crypto capabilities */
11780 : :
11781 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
11782 [ # # ]: 0 : if (!silent)
11783 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
11784 : 0 : return TEST_SKIPPED;
11785 : : }
11786 : :
11787 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
11788 [ # # ]: 0 : if (!silent)
11789 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
11790 : 0 : return TEST_SKIPPED;
11791 : : }
11792 : : }
11793 : :
11794 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
11795 : : return TEST_SKIPPED;
11796 : :
11797 : 0 : struct rte_security_session_conf sess_conf = {
11798 : 0 : .action_type = ut_params->type,
11799 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
11800 : : };
11801 : :
11802 [ # # ]: 0 : if (td[0].aead)
11803 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
11804 : :
11805 : 0 : sess_conf.tls_record = tls_record_xform;
11806 : :
11807 [ # # ]: 0 : if (td[0].aead) {
11808 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
11809 : : } else {
11810 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
11811 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
11812 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
11813 : : } else {
11814 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
11815 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
11816 : : }
11817 : : }
11818 : :
11819 : : /* Create security session */
11820 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11821 : : ts_params->session_mpool);
11822 [ # # ]: 0 : if (ut_params->sec_session == NULL)
11823 : : return TEST_SKIPPED;
11824 : :
11825 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
11826 : : /* Setup source mbuf payload */
11827 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, td[i].input_text.len,
11828 : : nb_segs, 0);
11829 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
11830 : :
11831 : : /* Generate crypto op data structure */
11832 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11833 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11834 [ # # ]: 0 : if (ut_params->op == NULL) {
11835 : : printf("Could not allocate crypto op");
11836 : : ret = TEST_FAILED;
11837 : 0 : goto crypto_op_free;
11838 : : }
11839 : :
11840 : : /* Attach session to operation */
11841 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11842 : :
11843 : : /* Set crypto operation mbufs */
11844 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11845 : 0 : ut_params->op->sym->m_dst = NULL;
11846 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
11847 : :
11848 : : /* Copy IV in crypto operation when IV generation is disabled */
11849 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE &&
11850 [ # # ]: 0 : tls_record_xform.options.iv_gen_disable == 1) {
11851 : : uint8_t *iv;
11852 : : int len;
11853 : :
11854 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
11855 [ # # ]: 0 : if (td[i].aead)
11856 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
11857 : : else
11858 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
11859 : 0 : memcpy(iv, td[i].iv.data, len);
11860 : : }
11861 : :
11862 : : /* Process crypto operation */
11863 : 0 : process_crypto_request(dev_id, ut_params->op);
11864 : :
11865 : 0 : ret = test_tls_record_status_check(ut_params->op);
11866 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11867 : 0 : goto crypto_op_free;
11868 : :
11869 [ # # ]: 0 : if (res_d != NULL)
11870 : 0 : res_d_tmp = &res_d[i];
11871 : :
11872 : 0 : ret = test_tls_record_post_process(ut_params->ibuf, &td[i], res_d_tmp, silent);
11873 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11874 : 0 : goto crypto_op_free;
11875 : :
11876 : :
11877 : 0 : rte_crypto_op_free(ut_params->op);
11878 : 0 : ut_params->op = NULL;
11879 : :
11880 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11881 : 0 : ut_params->ibuf = NULL;
11882 : : }
11883 : :
11884 : 0 : crypto_op_free:
11885 : 0 : rte_crypto_op_free(ut_params->op);
11886 : 0 : ut_params->op = NULL;
11887 : :
11888 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11889 : 0 : ut_params->ibuf = NULL;
11890 : :
11891 [ # # ]: 0 : if (ut_params->sec_session)
11892 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11893 : 0 : ut_params->sec_session = NULL;
11894 : :
11895 : : RTE_SET_USED(flags);
11896 : :
11897 : 0 : return ret;
11898 : : }
11899 : :
11900 : : static int
11901 : 0 : test_tls_record_proto_known_vec(const void *test_data)
11902 : : {
11903 : : struct tls_record_test_data td_write;
11904 : : struct tls_record_test_flags flags;
11905 : :
11906 : : memset(&flags, 0, sizeof(flags));
11907 : :
11908 : : memcpy(&td_write, test_data, sizeof(td_write));
11909 : :
11910 : : /* Disable IV gen to be able to test with known vectors */
11911 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
11912 : :
11913 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
11914 : : }
11915 : :
11916 : : static int
11917 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
11918 : : {
11919 : : const struct tls_record_test_data *td = test_data;
11920 : : struct tls_record_test_flags flags;
11921 : : struct tls_record_test_data td_inb;
11922 : :
11923 : : memset(&flags, 0, sizeof(flags));
11924 : :
11925 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
11926 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
11927 : : else
11928 : : memcpy(&td_inb, td, sizeof(td_inb));
11929 : :
11930 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
11931 : : }
11932 : :
11933 : : static int
11934 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
11935 : : {
11936 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
11937 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
11938 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
11939 : : int ret;
11940 : :
11941 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
11942 : 0 : test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2, flags,
11943 : : td_outb, nb_pkts);
11944 : :
11945 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
11946 [ # # ]: 0 : if (ret == TEST_SKIPPED)
11947 : 0 : continue;
11948 : :
11949 [ # # ]: 0 : if (ret == TEST_FAILED)
11950 : : return TEST_FAILED;
11951 : :
11952 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
11953 : :
11954 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
11955 [ # # ]: 0 : if (ret == TEST_SKIPPED)
11956 : 0 : continue;
11957 : :
11958 [ # # ]: 0 : if (ret == TEST_FAILED)
11959 : : return TEST_FAILED;
11960 : :
11961 [ # # ]: 0 : if (flags->display_alg)
11962 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
11963 : :
11964 : 0 : pass_cnt++;
11965 : : }
11966 : :
11967 [ # # ]: 0 : if (pass_cnt > 0)
11968 : : return TEST_SUCCESS;
11969 : : else
11970 : 0 : return TEST_SKIPPED;
11971 : : }
11972 : :
11973 : : static int
11974 : 0 : test_tls_record_proto_display_list(void)
11975 : : {
11976 : : struct tls_record_test_flags flags;
11977 : :
11978 : : memset(&flags, 0, sizeof(flags));
11979 : :
11980 : 0 : flags.display_alg = true;
11981 : :
11982 : 0 : return test_tls_record_proto_all(&flags);
11983 : : }
11984 : :
11985 : : static int
11986 : 0 : test_tls_record_proto_sgl(void)
11987 : : {
11988 : 0 : struct tls_record_test_flags flags = {
11989 : : .nb_segs_in_mbuf = 5
11990 : : };
11991 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11992 : : struct rte_cryptodev_info dev_info;
11993 : :
11994 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11995 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11996 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
11997 : 0 : return TEST_SKIPPED;
11998 : : }
11999 : :
12000 : 0 : return test_tls_record_proto_all(&flags);
12001 : : }
12002 : :
12003 : : #endif
12004 : :
12005 : : static int
12006 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
12007 : : {
12008 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
12009 : : }
12010 : :
12011 : : static int
12012 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
12013 : : {
12014 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
12015 : : }
12016 : :
12017 : : static int
12018 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
12019 : : {
12020 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
12021 : : }
12022 : :
12023 : : static int
12024 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
12025 : : {
12026 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
12027 : : }
12028 : :
12029 : : static int
12030 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
12031 : : {
12032 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
12033 : : }
12034 : :
12035 : : static int
12036 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
12037 : : {
12038 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
12039 : : }
12040 : :
12041 : : static int
12042 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
12043 : : {
12044 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
12045 : : }
12046 : :
12047 : : static int
12048 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
12049 : : {
12050 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
12051 : : }
12052 : :
12053 : : static int
12054 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
12055 : : {
12056 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
12057 : : }
12058 : :
12059 : : static int
12060 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
12061 : : {
12062 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
12063 : : }
12064 : :
12065 : : static int
12066 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
12067 : : {
12068 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
12069 : : }
12070 : :
12071 : : static int
12072 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
12073 : : {
12074 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
12075 : : }
12076 : :
12077 : : static int
12078 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
12079 : : {
12080 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
12081 : : }
12082 : :
12083 : : static int
12084 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
12085 : : {
12086 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
12087 : : }
12088 : :
12089 : : static int
12090 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
12091 : : {
12092 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
12093 : : }
12094 : :
12095 : : static int
12096 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
12097 : : {
12098 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
12099 : : }
12100 : :
12101 : : static int
12102 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
12103 : : {
12104 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
12105 : : }
12106 : :
12107 : : static int
12108 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
12109 : : {
12110 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
12111 : : }
12112 : :
12113 : : static int
12114 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
12115 : : {
12116 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
12117 : : }
12118 : :
12119 : : static int
12120 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
12121 : : {
12122 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
12123 : : }
12124 : :
12125 : : static int
12126 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
12127 : : {
12128 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
12129 : : }
12130 : :
12131 : : static int
12132 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
12133 : : {
12134 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
12135 : : }
12136 : :
12137 : : static int
12138 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
12139 : : {
12140 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
12141 : : }
12142 : :
12143 : : static int
12144 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
12145 : : {
12146 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
12147 : : }
12148 : :
12149 : : static int
12150 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
12151 : : {
12152 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
12153 : : }
12154 : :
12155 : : static int
12156 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
12157 : : {
12158 : : struct aead_test_data tdata;
12159 : : int res;
12160 : :
12161 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12162 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12163 : 1 : tdata.iv.data[0] += 1;
12164 : 1 : res = test_authenticated_encryption(&tdata);
12165 [ + - ]: 1 : if (res == TEST_SKIPPED)
12166 : : return res;
12167 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12168 : : return TEST_SUCCESS;
12169 : : }
12170 : :
12171 : : static int
12172 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
12173 : : {
12174 : : struct aead_test_data tdata;
12175 : : int res;
12176 : :
12177 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12178 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12179 : 1 : tdata.plaintext.data[0] += 1;
12180 : 1 : res = test_authenticated_encryption(&tdata);
12181 [ + - ]: 1 : if (res == TEST_SKIPPED)
12182 : : return res;
12183 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12184 : : return TEST_SUCCESS;
12185 : : }
12186 : :
12187 : : static int
12188 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
12189 : : {
12190 : : struct aead_test_data tdata;
12191 : : int res;
12192 : :
12193 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12194 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12195 : 1 : tdata.ciphertext.data[0] += 1;
12196 : 1 : res = test_authenticated_encryption(&tdata);
12197 [ + - ]: 1 : if (res == TEST_SKIPPED)
12198 : : return res;
12199 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12200 : : return TEST_SUCCESS;
12201 : : }
12202 : :
12203 : : static int
12204 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
12205 : : {
12206 : : struct aead_test_data tdata;
12207 : : int res;
12208 : :
12209 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12210 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12211 : 1 : tdata.aad.len += 1;
12212 : 1 : res = test_authenticated_encryption(&tdata);
12213 [ + - ]: 1 : if (res == TEST_SKIPPED)
12214 : : return res;
12215 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12216 : : return TEST_SUCCESS;
12217 : : }
12218 : :
12219 : : static int
12220 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
12221 : 1 : {
12222 : : struct aead_test_data tdata;
12223 : : uint8_t aad[gcm_test_case_7.aad.len];
12224 : : int res;
12225 : :
12226 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12227 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12228 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12229 : 1 : aad[0] += 1;
12230 : 1 : tdata.aad.data = aad;
12231 : 1 : res = test_authenticated_encryption(&tdata);
12232 [ + - ]: 1 : if (res == TEST_SKIPPED)
12233 : : return res;
12234 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12235 : : return TEST_SUCCESS;
12236 : : }
12237 : :
12238 : : static int
12239 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
12240 : : {
12241 : : struct aead_test_data tdata;
12242 : : int res;
12243 : :
12244 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12245 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12246 : 1 : tdata.auth_tag.data[0] += 1;
12247 : 1 : res = test_authenticated_encryption(&tdata);
12248 [ + - ]: 1 : if (res == TEST_SKIPPED)
12249 : : return res;
12250 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12251 : : return TEST_SUCCESS;
12252 : : }
12253 : :
12254 : : static int
12255 : 40 : test_authenticated_decryption(const struct aead_test_data *tdata)
12256 : : {
12257 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12258 : : struct crypto_unittest_params *ut_params = &unittest_params;
12259 : :
12260 : : int retval;
12261 : : uint8_t *plaintext;
12262 : : uint32_t i;
12263 : : struct rte_cryptodev_info dev_info;
12264 : :
12265 : 40 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12266 : 40 : uint64_t feat_flags = dev_info.feature_flags;
12267 : :
12268 [ - + ]: 40 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12269 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12270 : : printf("Device doesn't support RAW data-path APIs.\n");
12271 : 0 : return TEST_SKIPPED;
12272 : : }
12273 : :
12274 : : /* Verify the capabilities */
12275 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12276 : : const struct rte_cryptodev_symmetric_capability *capability;
12277 : 40 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12278 : 40 : cap_idx.algo.aead = tdata->algo;
12279 : 40 : capability = rte_cryptodev_sym_capability_get(
12280 : 40 : ts_params->valid_devs[0], &cap_idx);
12281 [ + - ]: 40 : if (capability == NULL)
12282 : : return TEST_SKIPPED;
12283 [ + + ]: 40 : if (rte_cryptodev_sym_capability_check_aead(
12284 : 40 : capability, tdata->key.len, tdata->auth_tag.len,
12285 : 40 : tdata->aad.len, tdata->iv.len))
12286 : : return TEST_SKIPPED;
12287 : :
12288 : : /* Create AEAD session */
12289 : 39 : retval = create_aead_session(ts_params->valid_devs[0],
12290 : 39 : tdata->algo,
12291 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12292 : 39 : tdata->key.data, tdata->key.len,
12293 : 39 : tdata->aad.len, tdata->auth_tag.len,
12294 : 39 : tdata->iv.len);
12295 [ + - ]: 39 : if (retval != TEST_SUCCESS)
12296 : : return retval;
12297 : :
12298 : : /* alloc mbuf and set payload */
12299 [ + + ]: 39 : if (tdata->aad.len > MBUF_SIZE) {
12300 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12301 : : /* Populate full size of add data */
12302 [ + + ]: 4096 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
12303 : 4094 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
12304 : : } else
12305 : 37 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12306 : :
12307 : 39 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12308 : 39 : rte_pktmbuf_tailroom(ut_params->ibuf));
12309 : :
12310 : : /* Create AEAD operation */
12311 : 39 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12312 [ + - ]: 39 : if (retval < 0)
12313 : : return retval;
12314 : :
12315 [ + - ]: 39 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12316 : :
12317 : 39 : ut_params->op->sym->m_src = ut_params->ibuf;
12318 : :
12319 : : /* Process crypto operation */
12320 [ - + ]: 39 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12321 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12322 [ - + ]: 39 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12323 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12324 : : 0);
12325 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12326 : : return retval;
12327 : : } else
12328 [ + + ]: 39 : TEST_ASSERT_NOT_NULL(
12329 : : process_crypto_request(ts_params->valid_devs[0],
12330 : : ut_params->op), "failed to process sym crypto op");
12331 : :
12332 [ - + ]: 34 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12333 : : "crypto op processing failed");
12334 : :
12335 [ - + ]: 34 : if (ut_params->op->sym->m_dst)
12336 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
12337 : : uint8_t *);
12338 : : else
12339 : 34 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12340 : : uint8_t *,
12341 : : ut_params->op->sym->cipher.data.offset);
12342 : :
12343 : 34 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12344 : :
12345 : : /* Validate obuf */
12346 [ + + ]: 35 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12347 : : plaintext,
12348 : : tdata->plaintext.data,
12349 : : tdata->plaintext.len,
12350 : : "Plaintext data not as expected");
12351 : :
12352 [ - + ]: 33 : TEST_ASSERT_EQUAL(ut_params->op->status,
12353 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12354 : : "Authentication failed");
12355 : :
12356 : : return 0;
12357 : : }
12358 : :
12359 : : static int
12360 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
12361 : : {
12362 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
12363 : : }
12364 : :
12365 : : static int
12366 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
12367 : : {
12368 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
12369 : : }
12370 : :
12371 : : static int
12372 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
12373 : : {
12374 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
12375 : : }
12376 : :
12377 : : static int
12378 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
12379 : : {
12380 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
12381 : : }
12382 : :
12383 : : static int
12384 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
12385 : : {
12386 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
12387 : : }
12388 : :
12389 : : static int
12390 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
12391 : : {
12392 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
12393 : : }
12394 : :
12395 : : static int
12396 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
12397 : : {
12398 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
12399 : : }
12400 : :
12401 : : static int
12402 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
12403 : : {
12404 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
12405 : : }
12406 : :
12407 : : static int
12408 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
12409 : : {
12410 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
12411 : : }
12412 : :
12413 : : static int
12414 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
12415 : : {
12416 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
12417 : : }
12418 : :
12419 : : static int
12420 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
12421 : : {
12422 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
12423 : : }
12424 : :
12425 : : static int
12426 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
12427 : : {
12428 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
12429 : : }
12430 : :
12431 : : static int
12432 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
12433 : : {
12434 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
12435 : : }
12436 : :
12437 : : static int
12438 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
12439 : : {
12440 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
12441 : : }
12442 : :
12443 : : static int
12444 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
12445 : : {
12446 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
12447 : : }
12448 : :
12449 : : static int
12450 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
12451 : : {
12452 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
12453 : : }
12454 : :
12455 : : static int
12456 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
12457 : : {
12458 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
12459 : : }
12460 : :
12461 : : static int
12462 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
12463 : : {
12464 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
12465 : : }
12466 : :
12467 : : static int
12468 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
12469 : : {
12470 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
12471 : : }
12472 : :
12473 : : static int
12474 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
12475 : : {
12476 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
12477 : : }
12478 : :
12479 : : static int
12480 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
12481 : : {
12482 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
12483 : : }
12484 : :
12485 : : static int
12486 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
12487 : : {
12488 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
12489 : : }
12490 : :
12491 : : static int
12492 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
12493 : : {
12494 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
12495 : : }
12496 : :
12497 : : static int
12498 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
12499 : : {
12500 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
12501 : : }
12502 : :
12503 : : static int
12504 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
12505 : : {
12506 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
12507 : : }
12508 : :
12509 : : static int
12510 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
12511 : : {
12512 : : struct aead_test_data tdata;
12513 : : int res;
12514 : :
12515 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12516 : 1 : tdata.iv.data[0] += 1;
12517 : 1 : res = test_authenticated_decryption(&tdata);
12518 [ + - ]: 1 : if (res == TEST_SKIPPED)
12519 : : return res;
12520 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12521 : : return TEST_SUCCESS;
12522 : : }
12523 : :
12524 : : static int
12525 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
12526 : : {
12527 : : struct aead_test_data tdata;
12528 : : int res;
12529 : :
12530 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12531 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12532 : 1 : tdata.plaintext.data[0] += 1;
12533 : 1 : res = test_authenticated_decryption(&tdata);
12534 [ + - ]: 1 : if (res == TEST_SKIPPED)
12535 : : return res;
12536 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12537 : : return TEST_SUCCESS;
12538 : : }
12539 : :
12540 : : static int
12541 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
12542 : : {
12543 : : struct aead_test_data tdata;
12544 : : int res;
12545 : :
12546 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12547 : 1 : tdata.ciphertext.data[0] += 1;
12548 : 1 : res = test_authenticated_decryption(&tdata);
12549 [ + - ]: 1 : if (res == TEST_SKIPPED)
12550 : : return res;
12551 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12552 : : return TEST_SUCCESS;
12553 : : }
12554 : :
12555 : : static int
12556 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
12557 : : {
12558 : : struct aead_test_data tdata;
12559 : : int res;
12560 : :
12561 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12562 : 1 : tdata.aad.len += 1;
12563 : 1 : res = test_authenticated_decryption(&tdata);
12564 [ + - ]: 1 : if (res == TEST_SKIPPED)
12565 : : return res;
12566 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12567 : : return TEST_SUCCESS;
12568 : : }
12569 : :
12570 : : static int
12571 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
12572 : 1 : {
12573 : : struct aead_test_data tdata;
12574 : : uint8_t aad[gcm_test_case_7.aad.len];
12575 : : int res;
12576 : :
12577 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12578 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12579 : 1 : aad[0] += 1;
12580 : 1 : tdata.aad.data = aad;
12581 : 1 : res = test_authenticated_decryption(&tdata);
12582 [ + - ]: 1 : if (res == TEST_SKIPPED)
12583 : : return res;
12584 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12585 : : return TEST_SUCCESS;
12586 : : }
12587 : :
12588 : : static int
12589 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
12590 : : {
12591 : : struct aead_test_data tdata;
12592 : : int res;
12593 : :
12594 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12595 : 1 : tdata.auth_tag.data[0] += 1;
12596 : 1 : res = test_authenticated_decryption(&tdata);
12597 [ + - ]: 1 : if (res == TEST_SKIPPED)
12598 : : return res;
12599 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
12600 : : return TEST_SUCCESS;
12601 : : }
12602 : :
12603 : : static int
12604 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
12605 : : {
12606 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12607 : : struct crypto_unittest_params *ut_params = &unittest_params;
12608 : :
12609 : : int retval;
12610 : : uint8_t *ciphertext, *auth_tag;
12611 : : uint16_t plaintext_pad_len;
12612 : : struct rte_cryptodev_info dev_info;
12613 : :
12614 : : /* Verify the capabilities */
12615 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12616 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12617 : 1 : cap_idx.algo.aead = tdata->algo;
12618 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12619 : : &cap_idx) == NULL)
12620 : : return TEST_SKIPPED;
12621 : :
12622 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12623 : 1 : uint64_t feat_flags = dev_info.feature_flags;
12624 : :
12625 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12626 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
12627 : : return TEST_SKIPPED;
12628 : :
12629 : : /* not supported with CPU crypto */
12630 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12631 : : return TEST_SKIPPED;
12632 : :
12633 : : /* Create AEAD session */
12634 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
12635 : 1 : tdata->algo,
12636 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
12637 : 1 : tdata->key.data, tdata->key.len,
12638 : 1 : tdata->aad.len, tdata->auth_tag.len,
12639 : 1 : tdata->iv.len);
12640 [ + - ]: 1 : if (retval < 0)
12641 : : return retval;
12642 : :
12643 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12644 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12645 : :
12646 : : /* clear mbuf payload */
12647 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12648 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
12649 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12650 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
12651 : :
12652 : : /* Create AEAD operation */
12653 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12654 [ + - ]: 1 : if (retval < 0)
12655 : : return retval;
12656 : :
12657 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12658 : :
12659 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
12660 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
12661 : :
12662 : : /* Process crypto operation */
12663 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12664 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12665 : : 0);
12666 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12667 : : return retval;
12668 : : } else
12669 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12670 : : ut_params->op), "failed to process sym crypto op");
12671 : :
12672 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12673 : : "crypto op processing failed");
12674 : :
12675 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12676 : :
12677 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12678 : : ut_params->op->sym->cipher.data.offset);
12679 : 1 : auth_tag = ciphertext + plaintext_pad_len;
12680 : :
12681 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12682 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12683 : :
12684 : : /* Validate obuf */
12685 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12686 : : ciphertext,
12687 : : tdata->ciphertext.data,
12688 : : tdata->ciphertext.len,
12689 : : "Ciphertext data not as expected");
12690 : :
12691 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12692 : : auth_tag,
12693 : : tdata->auth_tag.data,
12694 : : tdata->auth_tag.len,
12695 : : "Generated auth tag not as expected");
12696 : :
12697 : : return 0;
12698 : :
12699 : : }
12700 : :
12701 : : static int
12702 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
12703 : : {
12704 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
12705 : : }
12706 : :
12707 : : static int
12708 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
12709 : : {
12710 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12711 : : struct crypto_unittest_params *ut_params = &unittest_params;
12712 : :
12713 : : int retval;
12714 : : uint8_t *plaintext;
12715 : : struct rte_cryptodev_info dev_info;
12716 : :
12717 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12718 : : uint64_t feat_flags = dev_info.feature_flags;
12719 : :
12720 : : /* Verify the capabilities */
12721 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12722 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12723 : 1 : cap_idx.algo.aead = tdata->algo;
12724 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12725 : : &cap_idx) == NULL)
12726 : : return TEST_SKIPPED;
12727 : :
12728 : : /* not supported with CPU crypto and raw data-path APIs*/
12729 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
12730 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
12731 : : return TEST_SKIPPED;
12732 : :
12733 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12734 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12735 : : printf("Device does not support RAW data-path APIs.\n");
12736 : : return TEST_SKIPPED;
12737 : : }
12738 : :
12739 : : /* Create AEAD session */
12740 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
12741 : 1 : tdata->algo,
12742 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12743 : 1 : tdata->key.data, tdata->key.len,
12744 : 1 : tdata->aad.len, tdata->auth_tag.len,
12745 : 1 : tdata->iv.len);
12746 [ + - ]: 1 : if (retval < 0)
12747 : : return retval;
12748 : :
12749 : : /* alloc mbuf and set payload */
12750 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12751 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12752 : :
12753 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12754 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
12755 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12756 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
12757 : :
12758 : : /* Create AEAD operation */
12759 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12760 [ + - ]: 1 : if (retval < 0)
12761 : : return retval;
12762 : :
12763 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12764 : :
12765 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
12766 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
12767 : :
12768 : : /* Process crypto operation */
12769 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12770 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12771 : : 0);
12772 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12773 : : return retval;
12774 : : } else
12775 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12776 : : ut_params->op), "failed to process sym crypto op");
12777 : :
12778 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12779 : : "crypto op processing failed");
12780 : :
12781 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12782 : : ut_params->op->sym->cipher.data.offset);
12783 : :
12784 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12785 : :
12786 : : /* Validate obuf */
12787 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12788 : : plaintext,
12789 : : tdata->plaintext.data,
12790 : : tdata->plaintext.len,
12791 : : "Plaintext data not as expected");
12792 : :
12793 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
12794 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12795 : : "Authentication failed");
12796 : : return 0;
12797 : : }
12798 : :
12799 : : static int
12800 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
12801 : : {
12802 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
12803 : : }
12804 : :
12805 : : static int
12806 : 1 : test_authenticated_encryption_sessionless(
12807 : : const struct aead_test_data *tdata)
12808 : 1 : {
12809 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12810 : : struct crypto_unittest_params *ut_params = &unittest_params;
12811 : :
12812 : : int retval;
12813 : : uint8_t *ciphertext, *auth_tag;
12814 : : uint16_t plaintext_pad_len;
12815 : 1 : uint8_t key[tdata->key.len + 1];
12816 : : struct rte_cryptodev_info dev_info;
12817 : :
12818 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12819 : 1 : uint64_t feat_flags = dev_info.feature_flags;
12820 : :
12821 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12822 : : printf("Device doesn't support Sessionless ops.\n");
12823 : 0 : return TEST_SKIPPED;
12824 : : }
12825 : :
12826 : : /* not supported with CPU crypto */
12827 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12828 : : return TEST_SKIPPED;
12829 : :
12830 : : /* Verify the capabilities */
12831 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12832 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12833 : 1 : cap_idx.algo.aead = tdata->algo;
12834 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12835 : : &cap_idx) == NULL)
12836 : : return TEST_SKIPPED;
12837 : :
12838 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12839 : :
12840 : : /* clear mbuf payload */
12841 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12842 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12843 : :
12844 : : /* Create AEAD operation */
12845 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12846 [ + - ]: 1 : if (retval < 0)
12847 : : return retval;
12848 : :
12849 : : /* Create GCM xform */
12850 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
12851 : 1 : retval = create_aead_xform(ut_params->op,
12852 : 1 : tdata->algo,
12853 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
12854 : : key, tdata->key.len,
12855 : 1 : tdata->aad.len, tdata->auth_tag.len,
12856 : 1 : tdata->iv.len);
12857 [ + - ]: 1 : if (retval < 0)
12858 : : return retval;
12859 : :
12860 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
12861 : :
12862 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12863 : : RTE_CRYPTO_OP_SESSIONLESS,
12864 : : "crypto op session type not sessionless");
12865 : :
12866 : : /* Process crypto operation */
12867 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12868 : : ut_params->op), "failed to process sym crypto op");
12869 : :
12870 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12871 : :
12872 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12873 : : "crypto op status not success");
12874 : :
12875 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12876 : :
12877 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12878 : : ut_params->op->sym->cipher.data.offset);
12879 : 1 : auth_tag = ciphertext + plaintext_pad_len;
12880 : :
12881 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12882 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12883 : :
12884 : : /* Validate obuf */
12885 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12886 : : ciphertext,
12887 : : tdata->ciphertext.data,
12888 : : tdata->ciphertext.len,
12889 : : "Ciphertext data not as expected");
12890 : :
12891 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12892 : : auth_tag,
12893 : : tdata->auth_tag.data,
12894 : : tdata->auth_tag.len,
12895 : : "Generated auth tag not as expected");
12896 : :
12897 : : return 0;
12898 : :
12899 : : }
12900 : :
12901 : : static int
12902 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
12903 : : {
12904 : 1 : return test_authenticated_encryption_sessionless(
12905 : : &gcm_test_case_5);
12906 : : }
12907 : :
12908 : : static int
12909 : 1 : test_authenticated_decryption_sessionless(
12910 : : const struct aead_test_data *tdata)
12911 : 1 : {
12912 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12913 : : struct crypto_unittest_params *ut_params = &unittest_params;
12914 : :
12915 : : int retval;
12916 : : uint8_t *plaintext;
12917 : 1 : uint8_t key[tdata->key.len + 1];
12918 : : struct rte_cryptodev_info dev_info;
12919 : :
12920 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12921 : 1 : uint64_t feat_flags = dev_info.feature_flags;
12922 : :
12923 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12924 : : printf("Device doesn't support Sessionless ops.\n");
12925 : 0 : return TEST_SKIPPED;
12926 : : }
12927 : :
12928 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12929 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12930 : : printf("Device doesn't support RAW data-path APIs.\n");
12931 : 0 : return TEST_SKIPPED;
12932 : : }
12933 : :
12934 : : /* not supported with CPU crypto */
12935 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12936 : : return TEST_SKIPPED;
12937 : :
12938 : : /* Verify the capabilities */
12939 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12940 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12941 : 1 : cap_idx.algo.aead = tdata->algo;
12942 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12943 : : &cap_idx) == NULL)
12944 : : return TEST_SKIPPED;
12945 : :
12946 : : /* alloc mbuf and set payload */
12947 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12948 : :
12949 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12950 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12951 : :
12952 : : /* Create AEAD operation */
12953 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12954 [ + - ]: 1 : if (retval < 0)
12955 : : return retval;
12956 : :
12957 : : /* Create AEAD xform */
12958 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
12959 : 1 : retval = create_aead_xform(ut_params->op,
12960 : 1 : tdata->algo,
12961 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12962 : : key, tdata->key.len,
12963 : 1 : tdata->aad.len, tdata->auth_tag.len,
12964 : 1 : tdata->iv.len);
12965 [ + - ]: 1 : if (retval < 0)
12966 : : return retval;
12967 : :
12968 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
12969 : :
12970 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12971 : : RTE_CRYPTO_OP_SESSIONLESS,
12972 : : "crypto op session type not sessionless");
12973 : :
12974 : : /* Process crypto operation */
12975 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12976 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12977 : : 0);
12978 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12979 : : return retval;
12980 : : } else
12981 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
12982 : : ts_params->valid_devs[0], ut_params->op),
12983 : : "failed to process sym crypto op");
12984 : :
12985 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12986 : :
12987 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12988 : : "crypto op status not success");
12989 : :
12990 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12991 : : ut_params->op->sym->cipher.data.offset);
12992 : :
12993 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12994 : :
12995 : : /* Validate obuf */
12996 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12997 : : plaintext,
12998 : : tdata->plaintext.data,
12999 : : tdata->plaintext.len,
13000 : : "Plaintext data not as expected");
13001 : :
13002 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
13003 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13004 : : "Authentication failed");
13005 : : return 0;
13006 : : }
13007 : :
13008 : : static int
13009 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
13010 : : {
13011 : 1 : return test_authenticated_decryption_sessionless(
13012 : : &gcm_test_case_5);
13013 : : }
13014 : :
13015 : : static int
13016 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
13017 : : {
13018 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
13019 : : }
13020 : :
13021 : : static int
13022 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
13023 : : {
13024 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
13025 : : }
13026 : :
13027 : : static int
13028 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
13029 : : {
13030 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
13031 : : }
13032 : :
13033 : : static int
13034 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
13035 : : {
13036 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
13037 : : }
13038 : :
13039 : : static int
13040 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
13041 : : {
13042 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
13043 : : }
13044 : :
13045 : : static int
13046 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
13047 : : {
13048 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
13049 : : }
13050 : :
13051 : : static int
13052 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
13053 : : {
13054 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
13055 : : }
13056 : :
13057 : : static int
13058 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
13059 : : {
13060 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
13061 : : }
13062 : :
13063 : : static int
13064 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
13065 : : {
13066 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
13067 : : }
13068 : :
13069 : : static int
13070 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
13071 : : {
13072 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
13073 : : }
13074 : :
13075 : : static int
13076 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
13077 : : {
13078 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
13079 : : }
13080 : :
13081 : : static int
13082 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
13083 : : {
13084 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
13085 : : }
13086 : :
13087 : : static int
13088 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
13089 : : {
13090 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
13091 : : }
13092 : :
13093 : : static int
13094 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
13095 : : {
13096 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
13097 : : }
13098 : :
13099 : : static int
13100 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
13101 : : {
13102 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
13103 : : }
13104 : :
13105 : : static int
13106 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
13107 : : {
13108 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
13109 : : }
13110 : :
13111 : : static int
13112 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
13113 : : {
13114 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
13115 : : }
13116 : :
13117 : : static int
13118 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
13119 : : {
13120 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
13121 : : }
13122 : :
13123 : : static int
13124 : 1 : test_stats(void)
13125 : : {
13126 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13127 : : struct rte_cryptodev_stats stats;
13128 : :
13129 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13130 : : return TEST_SKIPPED;
13131 : :
13132 : : /* Verify the capabilities */
13133 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13134 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13135 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
13136 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13137 : : &cap_idx) == NULL)
13138 : : return TEST_SKIPPED;
13139 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13140 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13141 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13142 : : &cap_idx) == NULL)
13143 : : return TEST_SKIPPED;
13144 : :
13145 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
13146 : : == -ENOTSUP)
13147 : : return TEST_SKIPPED;
13148 : :
13149 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13150 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
13151 : : &stats) == -ENODEV),
13152 : : "rte_cryptodev_stats_get invalid dev failed");
13153 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
13154 : : "rte_cryptodev_stats_get invalid Param failed");
13155 : :
13156 : : /* Test expected values */
13157 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
13158 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13159 : : &stats),
13160 : : "rte_cryptodev_stats_get failed");
13161 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
13162 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
13163 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
13164 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
13165 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
13166 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
13167 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
13168 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
13169 : :
13170 : : /* invalid device but should ignore and not reset device stats*/
13171 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
13172 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13173 : : &stats),
13174 : : "rte_cryptodev_stats_get failed");
13175 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
13176 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
13177 : :
13178 : : /* check that a valid reset clears stats */
13179 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13180 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13181 : : &stats),
13182 : : "rte_cryptodev_stats_get failed");
13183 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
13184 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
13185 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
13186 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
13187 : :
13188 : : return TEST_SUCCESS;
13189 : : }
13190 : :
13191 : : static int
13192 : 1 : test_device_reconfigure(void)
13193 : : {
13194 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13195 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
13196 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
13197 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
13198 : 1 : .mp_session = ts_params->session_mpool
13199 : : };
13200 : : uint16_t qp_id, dev_id, num_devs = 0;
13201 : :
13202 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
13203 : : "Need at least %d devices for test", 1);
13204 : :
13205 : 1 : dev_id = ts_params->valid_devs[0];
13206 : :
13207 : : /* Stop the device in case it's started so it can be configured */
13208 : 1 : rte_cryptodev_stop(dev_id);
13209 : :
13210 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13211 : : "Failed test for rte_cryptodev_configure: "
13212 : : "dev_num %u", dev_id);
13213 : :
13214 : : /* Reconfigure with same configure params */
13215 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13216 : : "Failed test for rte_cryptodev_configure: "
13217 : : "dev_num %u", dev_id);
13218 : :
13219 : : /* Reconfigure with just one queue pair */
13220 : 1 : ts_params->conf.nb_queue_pairs = 1;
13221 : :
13222 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13223 : : &ts_params->conf),
13224 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
13225 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13226 : :
13227 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13228 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13229 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13230 : : rte_cryptodev_socket_id(
13231 : : ts_params->valid_devs[0])),
13232 : : "Failed test for "
13233 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13234 : : "%u on qp %u on cryptodev %u",
13235 : : qp_conf.nb_descriptors, qp_id,
13236 : : ts_params->valid_devs[0]);
13237 : : }
13238 : :
13239 : : /* Reconfigure with max number of queue pairs */
13240 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
13241 : :
13242 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13243 : : &ts_params->conf),
13244 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
13245 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13246 : :
13247 : 1 : qp_conf.mp_session = ts_params->session_mpool;
13248 : :
13249 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13250 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13251 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13252 : : rte_cryptodev_socket_id(
13253 : : ts_params->valid_devs[0])),
13254 : : "Failed test for "
13255 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13256 : : "%u on qp %u on cryptodev %u",
13257 : : qp_conf.nb_descriptors, qp_id,
13258 : : ts_params->valid_devs[0]);
13259 : : }
13260 : :
13261 : : /* Start the device */
13262 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
13263 : : "Failed to start cryptodev %u",
13264 : : ts_params->valid_devs[0]);
13265 : :
13266 : : /* Test expected values */
13267 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
13268 : : }
13269 : :
13270 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
13271 : : struct crypto_unittest_params *ut_params,
13272 : : enum rte_crypto_auth_operation op,
13273 : : const struct HMAC_MD5_vector *test_case)
13274 : : {
13275 : : uint8_t key[64];
13276 : :
13277 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
13278 : :
13279 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13280 : 4 : ut_params->auth_xform.next = NULL;
13281 : 4 : ut_params->auth_xform.auth.op = op;
13282 : :
13283 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
13284 : :
13285 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
13286 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
13287 : 4 : ut_params->auth_xform.auth.key.data = key;
13288 : :
13289 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
13290 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
13291 : : ts_params->session_mpool);
13292 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13293 : : return TEST_SKIPPED;
13294 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13295 : :
13296 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13297 : :
13298 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13299 : : rte_pktmbuf_tailroom(ut_params->ibuf));
13300 : :
13301 : 4 : return 0;
13302 : : }
13303 : :
13304 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
13305 : : const struct HMAC_MD5_vector *test_case,
13306 : : uint8_t **plaintext)
13307 : : {
13308 : : uint16_t plaintext_pad_len;
13309 : :
13310 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13311 : :
13312 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13313 : : 16);
13314 : :
13315 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13316 : : plaintext_pad_len);
13317 : 4 : memcpy(*plaintext, test_case->plaintext.data,
13318 : 4 : test_case->plaintext.len);
13319 : :
13320 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13321 : : ut_params->ibuf, MD5_DIGEST_LEN);
13322 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13323 : : "no room to append digest");
13324 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13325 : : ut_params->ibuf, plaintext_pad_len);
13326 : :
13327 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13328 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
13329 [ - + ]: 2 : test_case->auth_tag.len);
13330 : : }
13331 : :
13332 : 4 : sym_op->auth.data.offset = 0;
13333 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
13334 : :
13335 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13336 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
13337 : :
13338 : 4 : return 0;
13339 : : }
13340 : :
13341 : : static int
13342 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
13343 : : {
13344 : : uint16_t plaintext_pad_len;
13345 : : uint8_t *plaintext, *auth_tag;
13346 : : int ret;
13347 : :
13348 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13349 : : struct crypto_unittest_params *ut_params = &unittest_params;
13350 : : struct rte_cryptodev_info dev_info;
13351 : :
13352 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13353 : 2 : uint64_t feat_flags = dev_info.feature_flags;
13354 : :
13355 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13356 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13357 : : printf("Device doesn't support RAW data-path APIs.\n");
13358 : 0 : return TEST_SKIPPED;
13359 : : }
13360 : :
13361 : : /* Verify the capabilities */
13362 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13363 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13364 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13365 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13366 : : &cap_idx) == NULL)
13367 : : return TEST_SKIPPED;
13368 : :
13369 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
13370 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
13371 : : return TEST_FAILED;
13372 : :
13373 : : /* Generate Crypto op data structure */
13374 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13375 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13376 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
13377 : : "Failed to allocate symmetric crypto operation struct");
13378 : :
13379 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13380 : : 16);
13381 : :
13382 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13383 : : return TEST_FAILED;
13384 : :
13385 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13386 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13387 : : ut_params->op);
13388 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13389 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13390 [ # # ]: 0 : if (ret != TEST_SUCCESS)
13391 : : return ret;
13392 : : } else
13393 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
13394 : : process_crypto_request(ts_params->valid_devs[0],
13395 : : ut_params->op),
13396 : : "failed to process sym crypto op");
13397 : :
13398 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13399 : : "crypto op processing failed");
13400 : :
13401 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
13402 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13403 : : uint8_t *, plaintext_pad_len);
13404 : : } else {
13405 : 2 : auth_tag = plaintext + plaintext_pad_len;
13406 : : }
13407 : :
13408 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13409 : : auth_tag,
13410 : : test_case->auth_tag.data,
13411 : : test_case->auth_tag.len,
13412 : : "HMAC_MD5 generated tag not as expected");
13413 : :
13414 : : return TEST_SUCCESS;
13415 : : }
13416 : :
13417 : : static int
13418 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
13419 : : {
13420 : : uint8_t *plaintext;
13421 : : int ret;
13422 : :
13423 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13424 : : struct crypto_unittest_params *ut_params = &unittest_params;
13425 : : struct rte_cryptodev_info dev_info;
13426 : :
13427 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13428 : 2 : uint64_t feat_flags = dev_info.feature_flags;
13429 : :
13430 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13431 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13432 : : printf("Device doesn't support RAW data-path APIs.\n");
13433 : 0 : return TEST_SKIPPED;
13434 : : }
13435 : :
13436 : : /* Verify the capabilities */
13437 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13438 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13439 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13440 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13441 : : &cap_idx) == NULL)
13442 : : return TEST_SKIPPED;
13443 : :
13444 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
13445 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
13446 : : return TEST_FAILED;
13447 : : }
13448 : :
13449 : : /* Generate Crypto op data structure */
13450 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13451 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13452 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
13453 : : "Failed to allocate symmetric crypto operation struct");
13454 : :
13455 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13456 : : return TEST_FAILED;
13457 : :
13458 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13459 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13460 : : ut_params->op);
13461 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13462 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13463 [ # # ]: 0 : if (ret != TEST_SUCCESS)
13464 : : return ret;
13465 : : } else
13466 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
13467 : : process_crypto_request(ts_params->valid_devs[0],
13468 : : ut_params->op),
13469 : : "failed to process sym crypto op");
13470 : :
13471 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13472 : : "HMAC_MD5 crypto op processing failed");
13473 : :
13474 : : return TEST_SUCCESS;
13475 : : }
13476 : :
13477 : : static int
13478 : 1 : test_MD5_HMAC_generate_case_1(void)
13479 : : {
13480 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
13481 : : }
13482 : :
13483 : : static int
13484 : 1 : test_MD5_HMAC_verify_case_1(void)
13485 : : {
13486 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
13487 : : }
13488 : :
13489 : : static int
13490 : 1 : test_MD5_HMAC_generate_case_2(void)
13491 : : {
13492 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
13493 : : }
13494 : :
13495 : : static int
13496 : 1 : test_MD5_HMAC_verify_case_2(void)
13497 : : {
13498 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
13499 : : }
13500 : :
13501 : : static int
13502 : 1 : test_multi_session(void)
13503 : : {
13504 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13505 : : struct crypto_unittest_params *ut_params = &unittest_params;
13506 : : struct rte_cryptodev_info dev_info;
13507 : : int i, nb_sess, ret = TEST_SUCCESS;
13508 : : void **sessions;
13509 : :
13510 : : /* Verify the capabilities */
13511 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13512 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13513 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13514 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13515 : : &cap_idx) == NULL)
13516 : : return TEST_SKIPPED;
13517 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13518 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13519 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13520 : : &cap_idx) == NULL)
13521 : : return TEST_SKIPPED;
13522 : :
13523 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
13524 : : aes_cbc_key, hmac_sha512_key);
13525 : :
13526 : :
13527 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13528 : :
13529 : 1 : sessions = rte_malloc(NULL,
13530 : : sizeof(void *) *
13531 : : (MAX_NB_SESSIONS + 1), 0);
13532 : :
13533 : : /* Create multiple crypto sessions*/
13534 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
13535 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
13536 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
13537 : : ts_params->session_mpool);
13538 [ - + - - ]: 4 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13539 : : nb_sess = i;
13540 : : ret = TEST_SKIPPED;
13541 : : break;
13542 : : }
13543 : :
13544 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sessions[i],
13545 : : "Session creation failed at session number %u",
13546 : : i);
13547 : :
13548 : : /* Attempt to send a request on each session */
13549 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13550 : : sessions[i],
13551 : : ut_params,
13552 : : ts_params,
13553 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
13554 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
13555 : : aes_cbc_iv);
13556 : :
13557 : : /* free crypto operation structure */
13558 : 4 : rte_crypto_op_free(ut_params->op);
13559 : :
13560 : : /*
13561 : : * free mbuf - both obuf and ibuf are usually the same,
13562 : : * so check if they point at the same address is necessary,
13563 : : * to avoid freeing the mbuf twice.
13564 : : */
13565 [ + - ]: 4 : if (ut_params->obuf) {
13566 : 4 : rte_pktmbuf_free(ut_params->obuf);
13567 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
13568 : 4 : ut_params->ibuf = 0;
13569 : 4 : ut_params->obuf = 0;
13570 : : }
13571 [ - + ]: 4 : if (ut_params->ibuf) {
13572 : 0 : rte_pktmbuf_free(ut_params->ibuf);
13573 : 0 : ut_params->ibuf = 0;
13574 : : }
13575 : :
13576 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
13577 : 0 : i++;
13578 : 0 : break;
13579 : : }
13580 : : }
13581 : :
13582 : : nb_sess = i;
13583 : :
13584 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
13585 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13586 : 4 : sessions[i]);
13587 : : }
13588 : :
13589 : 1 : rte_free(sessions);
13590 : :
13591 [ + - ]: 1 : if (ret != TEST_SKIPPED)
13592 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
13593 : :
13594 : : return ret;
13595 : : }
13596 : :
13597 : : struct multi_session_params {
13598 : : struct crypto_unittest_params ut_params;
13599 : : uint8_t *cipher_key;
13600 : : uint8_t *hmac_key;
13601 : : const uint8_t *cipher;
13602 : : const uint8_t *digest;
13603 : : uint8_t *iv;
13604 : : };
13605 : :
13606 : : #define MB_SESSION_NUMBER 3
13607 : :
13608 : : static int
13609 : 1 : test_multi_session_random_usage(void)
13610 : : {
13611 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13612 : : struct rte_cryptodev_info dev_info;
13613 : : int index = 0, ret = TEST_SUCCESS;
13614 : : uint32_t nb_sess, i, j;
13615 : : void **sessions;
13616 : 1 : struct multi_session_params ut_paramz[] = {
13617 : :
13618 : : {
13619 : : .cipher_key = ms_aes_cbc_key0,
13620 : : .hmac_key = ms_hmac_key0,
13621 : : .cipher = ms_aes_cbc_cipher0,
13622 : : .digest = ms_hmac_digest0,
13623 : : .iv = ms_aes_cbc_iv0
13624 : : },
13625 : : {
13626 : : .cipher_key = ms_aes_cbc_key1,
13627 : : .hmac_key = ms_hmac_key1,
13628 : : .cipher = ms_aes_cbc_cipher1,
13629 : : .digest = ms_hmac_digest1,
13630 : : .iv = ms_aes_cbc_iv1
13631 : : },
13632 : : {
13633 : : .cipher_key = ms_aes_cbc_key2,
13634 : : .hmac_key = ms_hmac_key2,
13635 : : .cipher = ms_aes_cbc_cipher2,
13636 : : .digest = ms_hmac_digest2,
13637 : : .iv = ms_aes_cbc_iv2
13638 : : },
13639 : :
13640 : : };
13641 : :
13642 : : /* Verify the capabilities */
13643 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13644 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13645 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13646 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13647 : : &cap_idx) == NULL)
13648 : : return TEST_SKIPPED;
13649 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13650 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13651 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13652 : : &cap_idx) == NULL)
13653 : : return TEST_SKIPPED;
13654 : :
13655 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13656 : :
13657 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
13658 : : * MAX_NB_SESSIONS) + 1, 0);
13659 : :
13660 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
13661 : :
13662 [ + + ]: 3 : rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
13663 : : sizeof(struct crypto_unittest_params));
13664 : :
13665 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
13666 : : &ut_paramz[i].ut_params,
13667 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
13668 : :
13669 : : /* Create multiple crypto sessions*/
13670 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
13671 : 3 : ts_params->valid_devs[0],
13672 : : &ut_paramz[i].ut_params.auth_xform,
13673 : : ts_params->session_mpool);
13674 [ - + - - ]: 3 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13675 : : nb_sess = i;
13676 : : ret = TEST_SKIPPED;
13677 : 0 : goto session_clear;
13678 : : }
13679 : :
13680 [ - + ]: 3 : TEST_ASSERT_NOT_NULL(sessions[i],
13681 : : "Session creation failed at session number %u",
13682 : : i);
13683 : : }
13684 : :
13685 : : nb_sess = i;
13686 : :
13687 : 1 : srand(time(NULL));
13688 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
13689 : :
13690 : 1 : j = rand() % MB_SESSION_NUMBER;
13691 : :
13692 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13693 : 1 : sessions[j],
13694 : : &ut_paramz[j].ut_params,
13695 : : ts_params, ut_paramz[j].cipher,
13696 : : ut_paramz[j].digest,
13697 : 1 : ut_paramz[j].iv);
13698 : :
13699 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
13700 : :
13701 : : /*
13702 : : * free mbuf - both obuf and ibuf are usually the same,
13703 : : * so check if they point at the same address is necessary,
13704 : : * to avoid freeing the mbuf twice.
13705 : : */
13706 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
13707 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
13708 : 1 : if (ut_paramz[j].ut_params.ibuf
13709 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
13710 : 1 : ut_paramz[j].ut_params.ibuf = 0;
13711 : 1 : ut_paramz[j].ut_params.obuf = 0;
13712 : : }
13713 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
13714 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
13715 : 0 : ut_paramz[j].ut_params.ibuf = 0;
13716 : : }
13717 : :
13718 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
13719 : 1 : index = i;
13720 : 1 : break;
13721 : : }
13722 : : }
13723 : :
13724 : 0 : session_clear:
13725 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
13726 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13727 : 3 : sessions[i]);
13728 : : }
13729 : :
13730 : 1 : rte_free(sessions);
13731 : :
13732 [ + - ]: 1 : if (ret != TEST_SKIPPED)
13733 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
13734 : :
13735 : : return TEST_SUCCESS;
13736 : : }
13737 : :
13738 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
13739 : : 0xab, 0xab, 0xab, 0xab,
13740 : : 0xab, 0xab, 0xab, 0xab,
13741 : : 0xab, 0xab, 0xab, 0xab};
13742 : :
13743 : : static int
13744 : 0 : test_null_invalid_operation(void)
13745 : : {
13746 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13747 : : struct crypto_unittest_params *ut_params = &unittest_params;
13748 : :
13749 : : /* This test is for NULL PMD only */
13750 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
13751 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13752 : : return TEST_SKIPPED;
13753 : :
13754 : : /* Setup Cipher Parameters */
13755 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13756 : 0 : ut_params->cipher_xform.next = NULL;
13757 : :
13758 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
13759 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13760 : :
13761 : : /* Create Crypto session*/
13762 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13763 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
13764 : : ts_params->session_mpool);
13765 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
13766 : : "Session creation succeeded unexpectedly");
13767 : :
13768 : : /* Setup HMAC Parameters */
13769 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13770 : 0 : ut_params->auth_xform.next = NULL;
13771 : :
13772 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
13773 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13774 : :
13775 : : /* Create Crypto session*/
13776 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13777 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
13778 : : ts_params->session_mpool);
13779 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
13780 : : "Session creation succeeded unexpectedly");
13781 : :
13782 : : return TEST_SUCCESS;
13783 : : }
13784 : :
13785 : :
13786 : : #define NULL_BURST_LENGTH (32)
13787 : :
13788 : : static int
13789 : 2 : test_null_burst_operation(void)
13790 : : {
13791 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13792 : : struct crypto_unittest_params *ut_params = &unittest_params;
13793 : :
13794 : : unsigned i, burst_len = NULL_BURST_LENGTH;
13795 : :
13796 : 2 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
13797 : 2 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
13798 : :
13799 : : /* This test is for NULL PMD only */
13800 [ - + ]: 2 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
13801 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13802 : : return TEST_SKIPPED;
13803 : :
13804 : : /* Setup Cipher Parameters */
13805 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13806 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
13807 : :
13808 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
13809 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13810 : :
13811 : : /* Setup HMAC Parameters */
13812 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13813 : 0 : ut_params->auth_xform.next = NULL;
13814 : :
13815 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
13816 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13817 : :
13818 : : /* Create Crypto session*/
13819 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13820 : 0 : ts_params->valid_devs[0],
13821 : : &ut_params->auth_xform,
13822 : : ts_params->session_mpool);
13823 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13824 : : return TEST_SKIPPED;
13825 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13826 : :
13827 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
13828 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
13829 : : burst_len, "failed to generate burst of crypto ops");
13830 : :
13831 : : /* Generate an operation for each mbuf in burst */
13832 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
13833 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13834 : :
13835 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
13836 : :
13837 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
13838 : : sizeof(unsigned));
13839 : 0 : *data = i;
13840 : :
13841 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
13842 : :
13843 : 0 : burst[i]->sym->m_src = m;
13844 : : }
13845 : :
13846 : : /* Process crypto operation */
13847 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
13848 : : 0, burst, burst_len),
13849 : : burst_len,
13850 : : "Error enqueuing burst");
13851 : :
13852 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
13853 : : 0, burst_dequeued, burst_len),
13854 : : burst_len,
13855 : : "Error dequeuing burst");
13856 : :
13857 : :
13858 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
13859 [ # # ]: 0 : TEST_ASSERT_EQUAL(
13860 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
13861 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
13862 : : uint32_t *),
13863 : : "data not as expected");
13864 : :
13865 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
13866 : 0 : rte_crypto_op_free(burst[i]);
13867 : : }
13868 : :
13869 : : return TEST_SUCCESS;
13870 : : }
13871 : :
13872 : : static uint16_t
13873 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13874 : : uint16_t nb_ops, void *user_param)
13875 : : {
13876 : : RTE_SET_USED(dev_id);
13877 : : RTE_SET_USED(qp_id);
13878 : : RTE_SET_USED(ops);
13879 : : RTE_SET_USED(user_param);
13880 : :
13881 : : printf("crypto enqueue callback called\n");
13882 : 0 : return nb_ops;
13883 : : }
13884 : :
13885 : : static uint16_t
13886 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13887 : : uint16_t nb_ops, void *user_param)
13888 : : {
13889 : : RTE_SET_USED(dev_id);
13890 : : RTE_SET_USED(qp_id);
13891 : : RTE_SET_USED(ops);
13892 : : RTE_SET_USED(user_param);
13893 : :
13894 : : printf("crypto dequeue callback called\n");
13895 : 0 : return nb_ops;
13896 : : }
13897 : :
13898 : : /*
13899 : : * Thread using enqueue/dequeue callback with RCU.
13900 : : */
13901 : : static int
13902 : 2 : test_enqdeq_callback_thread(void *arg)
13903 : : {
13904 : : RTE_SET_USED(arg);
13905 : : /* DP thread calls rte_cryptodev_enqueue_burst()/
13906 : : * rte_cryptodev_dequeue_burst() and invokes callback.
13907 : : */
13908 : 2 : test_null_burst_operation();
13909 : 2 : return 0;
13910 : : }
13911 : :
13912 : : static int
13913 : 1 : test_enq_callback_setup(void)
13914 : : {
13915 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13916 : : struct rte_cryptodev_info dev_info;
13917 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
13918 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
13919 : : };
13920 : :
13921 : : struct rte_cryptodev_cb *cb;
13922 : : uint16_t qp_id = 0;
13923 : :
13924 : : /* Stop the device in case it's started so it can be configured */
13925 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
13926 : :
13927 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13928 : :
13929 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13930 : : &ts_params->conf),
13931 : : "Failed to configure cryptodev %u",
13932 : : ts_params->valid_devs[0]);
13933 : :
13934 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13935 : 1 : qp_conf.mp_session = ts_params->session_mpool;
13936 : :
13937 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13938 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13939 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13940 : : "Failed test for "
13941 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13942 : : "%u on qp %u on cryptodev %u",
13943 : : qp_conf.nb_descriptors, qp_id,
13944 : : ts_params->valid_devs[0]);
13945 : :
13946 : : /* Test with invalid crypto device */
13947 : 1 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
13948 : : qp_id, test_enq_callback, NULL);
13949 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13950 : : "cryptodev %u did not fail",
13951 : : qp_id, RTE_CRYPTO_MAX_DEVS);
13952 : :
13953 : : /* Test with invalid queue pair */
13954 : 1 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13955 : 1 : dev_info.max_nb_queue_pairs + 1,
13956 : : test_enq_callback, NULL);
13957 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13958 : : "cryptodev %u did not fail",
13959 : : dev_info.max_nb_queue_pairs + 1,
13960 : : ts_params->valid_devs[0]);
13961 : :
13962 : : /* Test with NULL callback */
13963 : 1 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13964 : : qp_id, NULL, NULL);
13965 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13966 : : "cryptodev %u did not fail",
13967 : : qp_id, ts_params->valid_devs[0]);
13968 : :
13969 : : /* Test with valid configuration */
13970 : 1 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13971 : : qp_id, test_enq_callback, NULL);
13972 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
13973 : : "qp %u on cryptodev %u",
13974 : : qp_id, ts_params->valid_devs[0]);
13975 : :
13976 : 1 : rte_cryptodev_start(ts_params->valid_devs[0]);
13977 : :
13978 : : /* Launch a thread */
13979 : 1 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
13980 : : rte_get_next_lcore(-1, 1, 0));
13981 : :
13982 : : /* Wait until reader exited. */
13983 : 1 : rte_eal_mp_wait_lcore();
13984 : :
13985 : : /* Test with invalid crypto device */
13986 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13987 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
13988 : : "Expected call to fail as crypto device is invalid");
13989 : :
13990 : : /* Test with invalid queue pair */
13991 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13992 : : ts_params->valid_devs[0],
13993 : : dev_info.max_nb_queue_pairs + 1, cb),
13994 : : "Expected call to fail as queue pair is invalid");
13995 : :
13996 : : /* Test with NULL callback */
13997 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13998 : : ts_params->valid_devs[0], qp_id, NULL),
13999 : : "Expected call to fail as callback is NULL");
14000 : :
14001 : : /* Test with valid configuration */
14002 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
14003 : : ts_params->valid_devs[0], qp_id, cb),
14004 : : "Failed test to remove callback on "
14005 : : "qp %u on cryptodev %u",
14006 : : qp_id, ts_params->valid_devs[0]);
14007 : :
14008 : : return TEST_SUCCESS;
14009 : : }
14010 : :
14011 : : static int
14012 : 1 : test_deq_callback_setup(void)
14013 : : {
14014 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14015 : : struct rte_cryptodev_info dev_info;
14016 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14017 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
14018 : : };
14019 : :
14020 : : struct rte_cryptodev_cb *cb;
14021 : : uint16_t qp_id = 0;
14022 : :
14023 : : /* Stop the device in case it's started so it can be configured */
14024 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
14025 : :
14026 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14027 : :
14028 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14029 : : &ts_params->conf),
14030 : : "Failed to configure cryptodev %u",
14031 : : ts_params->valid_devs[0]);
14032 : :
14033 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14034 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14035 : :
14036 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14037 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14038 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14039 : : "Failed test for "
14040 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14041 : : "%u on qp %u on cryptodev %u",
14042 : : qp_conf.nb_descriptors, qp_id,
14043 : : ts_params->valid_devs[0]);
14044 : :
14045 : : /* Test with invalid crypto device */
14046 : 1 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
14047 : : qp_id, test_deq_callback, NULL);
14048 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14049 : : "cryptodev %u did not fail",
14050 : : qp_id, RTE_CRYPTO_MAX_DEVS);
14051 : :
14052 : : /* Test with invalid queue pair */
14053 : 1 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14054 : 1 : dev_info.max_nb_queue_pairs + 1,
14055 : : test_deq_callback, NULL);
14056 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14057 : : "cryptodev %u did not fail",
14058 : : dev_info.max_nb_queue_pairs + 1,
14059 : : ts_params->valid_devs[0]);
14060 : :
14061 : : /* Test with NULL callback */
14062 : 1 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14063 : : qp_id, NULL, NULL);
14064 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14065 : : "cryptodev %u did not fail",
14066 : : qp_id, ts_params->valid_devs[0]);
14067 : :
14068 : : /* Test with valid configuration */
14069 : 1 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14070 : : qp_id, test_deq_callback, NULL);
14071 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14072 : : "qp %u on cryptodev %u",
14073 : : qp_id, ts_params->valid_devs[0]);
14074 : :
14075 : 1 : rte_cryptodev_start(ts_params->valid_devs[0]);
14076 : :
14077 : : /* Launch a thread */
14078 : 1 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14079 : : rte_get_next_lcore(-1, 1, 0));
14080 : :
14081 : : /* Wait until reader exited. */
14082 : 1 : rte_eal_mp_wait_lcore();
14083 : :
14084 : : /* Test with invalid crypto device */
14085 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14086 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14087 : : "Expected call to fail as crypto device is invalid");
14088 : :
14089 : : /* Test with invalid queue pair */
14090 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14091 : : ts_params->valid_devs[0],
14092 : : dev_info.max_nb_queue_pairs + 1, cb),
14093 : : "Expected call to fail as queue pair is invalid");
14094 : :
14095 : : /* Test with NULL callback */
14096 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14097 : : ts_params->valid_devs[0], qp_id, NULL),
14098 : : "Expected call to fail as callback is NULL");
14099 : :
14100 : : /* Test with valid configuration */
14101 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
14102 : : ts_params->valid_devs[0], qp_id, cb),
14103 : : "Failed test to remove callback on "
14104 : : "qp %u on cryptodev %u",
14105 : : qp_id, ts_params->valid_devs[0]);
14106 : :
14107 : : return TEST_SUCCESS;
14108 : : }
14109 : :
14110 : : static void
14111 : : generate_gmac_large_plaintext(uint8_t *data)
14112 : : {
14113 : : uint16_t i;
14114 : :
14115 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
14116 : 4082 : memcpy(&data[i], &data[0], 32);
14117 : : }
14118 : :
14119 : : static int
14120 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
14121 : : const struct gmac_test_data *tdata)
14122 : : {
14123 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14124 : : struct crypto_unittest_params *ut_params = &unittest_params;
14125 : : struct rte_crypto_sym_op *sym_op;
14126 : :
14127 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14128 : :
14129 : : /* Generate Crypto op data structure */
14130 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14131 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14132 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
14133 : : "Failed to allocate symmetric crypto operation struct");
14134 : :
14135 : : sym_op = ut_params->op->sym;
14136 : :
14137 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14138 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
14139 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14140 : : "no room to append digest");
14141 : :
14142 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14143 : : ut_params->ibuf, plaintext_pad_len);
14144 : :
14145 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14146 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14147 [ - + ]: 4 : tdata->gmac_tag.len);
14148 : 4 : debug_hexdump(stdout, "digest:",
14149 : 4 : sym_op->auth.digest.data,
14150 : 4 : tdata->gmac_tag.len);
14151 : : }
14152 : :
14153 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14154 : : uint8_t *, IV_OFFSET);
14155 : :
14156 [ - + ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14157 : :
14158 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14159 : :
14160 : 8 : sym_op->cipher.data.length = 0;
14161 : 8 : sym_op->cipher.data.offset = 0;
14162 : :
14163 : 8 : sym_op->auth.data.offset = 0;
14164 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
14165 : :
14166 : 8 : return 0;
14167 : : }
14168 : :
14169 : : static int
14170 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
14171 : : const struct gmac_test_data *tdata,
14172 : : void *digest_mem, uint64_t digest_phys)
14173 : : {
14174 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14175 : : struct crypto_unittest_params *ut_params = &unittest_params;
14176 : : struct rte_crypto_sym_op *sym_op;
14177 : :
14178 : : /* Generate Crypto op data structure */
14179 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14180 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14181 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14182 : : "Failed to allocate symmetric crypto operation struct");
14183 : :
14184 : : sym_op = ut_params->op->sym;
14185 : :
14186 : 0 : sym_op->auth.digest.data = digest_mem;
14187 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14188 : : "no room to append digest");
14189 : :
14190 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
14191 : :
14192 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14193 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14194 [ # # ]: 0 : tdata->gmac_tag.len);
14195 : 0 : debug_hexdump(stdout, "digest:",
14196 : 0 : sym_op->auth.digest.data,
14197 : 0 : tdata->gmac_tag.len);
14198 : : }
14199 : :
14200 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14201 : : uint8_t *, IV_OFFSET);
14202 : :
14203 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14204 : :
14205 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14206 : :
14207 : 0 : sym_op->cipher.data.length = 0;
14208 : 0 : sym_op->cipher.data.offset = 0;
14209 : :
14210 : 0 : sym_op->auth.data.offset = 0;
14211 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
14212 : :
14213 : 0 : return 0;
14214 : : }
14215 : :
14216 : 8 : static int create_gmac_session(uint8_t dev_id,
14217 : : const struct gmac_test_data *tdata,
14218 : : enum rte_crypto_auth_operation auth_op)
14219 : 8 : {
14220 : 8 : uint8_t auth_key[tdata->key.len];
14221 : :
14222 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14223 : : struct crypto_unittest_params *ut_params = &unittest_params;
14224 : :
14225 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
14226 : :
14227 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14228 : 8 : ut_params->auth_xform.next = NULL;
14229 : :
14230 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
14231 : 8 : ut_params->auth_xform.auth.op = auth_op;
14232 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
14233 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
14234 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
14235 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14236 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
14237 : :
14238 : :
14239 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14240 : : &ut_params->auth_xform, ts_params->session_mpool);
14241 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14242 : : return TEST_SKIPPED;
14243 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14244 : :
14245 : : return 0;
14246 : : }
14247 : :
14248 : : static int
14249 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
14250 : : {
14251 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14252 : : struct crypto_unittest_params *ut_params = &unittest_params;
14253 : : struct rte_cryptodev_info dev_info;
14254 : :
14255 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14256 : 4 : uint64_t feat_flags = dev_info.feature_flags;
14257 : :
14258 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14259 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14260 : : printf("Device doesn't support RAW data-path APIs.\n");
14261 : 0 : return TEST_SKIPPED;
14262 : : }
14263 : :
14264 : : int retval;
14265 : :
14266 : : uint8_t *auth_tag, *plaintext;
14267 : : uint16_t plaintext_pad_len;
14268 : :
14269 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14270 : : "No GMAC length in the source data");
14271 : :
14272 : : /* Verify the capabilities */
14273 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14274 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14275 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14276 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14277 : : &cap_idx) == NULL)
14278 : : return TEST_SKIPPED;
14279 : :
14280 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
14281 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14282 : :
14283 [ + - ]: 4 : if (retval == TEST_SKIPPED)
14284 : : return TEST_SKIPPED;
14285 [ + - ]: 4 : if (retval < 0)
14286 : : return retval;
14287 : :
14288 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
14289 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14290 : : else
14291 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14292 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14293 : : "Failed to allocate input buffer in mempool");
14294 : :
14295 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14296 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14297 : :
14298 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14299 : : /*
14300 : : * Runtime generate the large plain text instead of use hard code
14301 : : * plain text vector. It is done to avoid create huge source file
14302 : : * with the test vector.
14303 : : */
14304 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14305 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
14306 : :
14307 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14308 : : plaintext_pad_len);
14309 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14310 : :
14311 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14312 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
14313 : 4 : tdata->plaintext.len);
14314 : :
14315 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
14316 : : tdata);
14317 : :
14318 [ + - ]: 4 : if (retval < 0)
14319 : : return retval;
14320 : :
14321 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14322 : :
14323 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14324 : :
14325 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14326 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14327 : : ut_params->op);
14328 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14329 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14330 : : 0);
14331 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14332 : : return retval;
14333 : : } else
14334 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
14335 : : process_crypto_request(ts_params->valid_devs[0],
14336 : : ut_params->op), "failed to process sym crypto op");
14337 : :
14338 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14339 : : "crypto op processing failed");
14340 : :
14341 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
14342 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14343 : : uint8_t *, plaintext_pad_len);
14344 : : } else {
14345 : 4 : auth_tag = plaintext + plaintext_pad_len;
14346 : : }
14347 : :
14348 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14349 : :
14350 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14351 : : auth_tag,
14352 : : tdata->gmac_tag.data,
14353 : : tdata->gmac_tag.len,
14354 : : "GMAC Generated auth tag not as expected");
14355 : :
14356 : : return 0;
14357 : : }
14358 : :
14359 : : static int
14360 : 1 : test_AES_GMAC_authentication_test_case_1(void)
14361 : : {
14362 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
14363 : : }
14364 : :
14365 : : static int
14366 : 1 : test_AES_GMAC_authentication_test_case_2(void)
14367 : : {
14368 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
14369 : : }
14370 : :
14371 : : static int
14372 : 1 : test_AES_GMAC_authentication_test_case_3(void)
14373 : : {
14374 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
14375 : : }
14376 : :
14377 : : static int
14378 : 1 : test_AES_GMAC_authentication_test_case_4(void)
14379 : : {
14380 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
14381 : : }
14382 : :
14383 : : static int
14384 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
14385 : : {
14386 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14387 : : struct crypto_unittest_params *ut_params = &unittest_params;
14388 : : int retval;
14389 : : uint32_t plaintext_pad_len;
14390 : : uint8_t *plaintext;
14391 : : struct rte_cryptodev_info dev_info;
14392 : :
14393 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14394 : 4 : uint64_t feat_flags = dev_info.feature_flags;
14395 : :
14396 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14397 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14398 : : printf("Device doesn't support RAW data-path APIs.\n");
14399 : 0 : return TEST_SKIPPED;
14400 : : }
14401 : :
14402 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14403 : : "No GMAC length in the source data");
14404 : :
14405 : : /* Verify the capabilities */
14406 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14407 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14408 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14409 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14410 : : &cap_idx) == NULL)
14411 : : return TEST_SKIPPED;
14412 : :
14413 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
14414 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
14415 : :
14416 [ + - ]: 4 : if (retval == TEST_SKIPPED)
14417 : : return TEST_SKIPPED;
14418 [ + - ]: 4 : if (retval < 0)
14419 : : return retval;
14420 : :
14421 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
14422 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14423 : : else
14424 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14425 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14426 : : "Failed to allocate input buffer in mempool");
14427 : :
14428 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14429 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14430 : :
14431 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14432 : :
14433 : : /*
14434 : : * Runtime generate the large plain text instead of use hard code
14435 : : * plain text vector. It is done to avoid create huge source file
14436 : : * with the test vector.
14437 : : */
14438 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14439 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
14440 : :
14441 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14442 : : plaintext_pad_len);
14443 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14444 : :
14445 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14446 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
14447 : 4 : tdata->plaintext.len);
14448 : :
14449 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
14450 : : tdata);
14451 : :
14452 [ + - ]: 4 : if (retval < 0)
14453 : : return retval;
14454 : :
14455 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14456 : :
14457 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14458 : :
14459 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14460 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14461 : : ut_params->op);
14462 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14463 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14464 : : 0);
14465 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14466 : : return retval;
14467 : : } else
14468 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
14469 : : process_crypto_request(ts_params->valid_devs[0],
14470 : : ut_params->op), "failed to process sym crypto op");
14471 : :
14472 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14473 : : "crypto op processing failed");
14474 : :
14475 : : return 0;
14476 : :
14477 : : }
14478 : :
14479 : : static int
14480 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
14481 : : {
14482 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
14483 : : }
14484 : :
14485 : : static int
14486 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
14487 : : {
14488 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
14489 : : }
14490 : :
14491 : : static int
14492 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
14493 : : {
14494 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
14495 : : }
14496 : :
14497 : : static int
14498 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
14499 : : {
14500 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
14501 : : }
14502 : :
14503 : : static int
14504 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
14505 : : uint32_t fragsz)
14506 : : {
14507 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14508 : : struct crypto_unittest_params *ut_params = &unittest_params;
14509 : : struct rte_cryptodev_info dev_info;
14510 : : uint64_t feature_flags;
14511 : : unsigned int trn_data = 0;
14512 : : void *digest_mem = NULL;
14513 : : uint32_t segs = 1;
14514 : : unsigned int to_trn = 0;
14515 : : struct rte_mbuf *buf = NULL;
14516 : : uint8_t *auth_tag, *plaintext;
14517 : : int retval;
14518 : :
14519 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14520 : : "No GMAC length in the source data");
14521 : :
14522 : : /* Verify the capabilities */
14523 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14524 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14525 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14526 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14527 : : &cap_idx) == NULL)
14528 : : return TEST_SKIPPED;
14529 : :
14530 : : /* Check for any input SGL support */
14531 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14532 : 4 : feature_flags = dev_info.feature_flags;
14533 : :
14534 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
14535 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
14536 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
14537 : : return TEST_SKIPPED;
14538 : :
14539 : 0 : if (fragsz > tdata->plaintext.len)
14540 : : fragsz = tdata->plaintext.len;
14541 : :
14542 : 0 : uint16_t plaintext_len = fragsz;
14543 : :
14544 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
14545 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14546 : :
14547 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14548 : : return TEST_SKIPPED;
14549 [ # # ]: 0 : if (retval < 0)
14550 : : return retval;
14551 : :
14552 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14553 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14554 : : "Failed to allocate input buffer in mempool");
14555 : :
14556 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14557 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14558 : :
14559 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14560 : : plaintext_len);
14561 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14562 : :
14563 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14564 : :
14565 : : trn_data += plaintext_len;
14566 : :
14567 : 0 : buf = ut_params->ibuf;
14568 : :
14569 : : /*
14570 : : * Loop until no more fragments
14571 : : */
14572 : :
14573 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
14574 : 0 : ++segs;
14575 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14576 : : (tdata->plaintext.len - trn_data) : fragsz;
14577 : :
14578 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14579 : : buf = buf->next;
14580 : :
14581 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14582 : : rte_pktmbuf_tailroom(buf));
14583 : :
14584 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14585 : : to_trn);
14586 : :
14587 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
14588 : : to_trn);
14589 : 0 : trn_data += to_trn;
14590 [ # # ]: 0 : if (trn_data == tdata->plaintext.len)
14591 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14592 : 0 : tdata->gmac_tag.len);
14593 : : }
14594 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
14595 : :
14596 : : /*
14597 : : * Place digest at the end of the last buffer
14598 : : */
14599 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14600 : :
14601 [ # # ]: 0 : if (!digest_mem) {
14602 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14603 : 0 : + tdata->gmac_tag.len);
14604 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14605 : : tdata->plaintext.len);
14606 : : }
14607 : :
14608 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
14609 : : tdata, digest_mem, digest_phys);
14610 : :
14611 [ # # ]: 0 : if (retval < 0)
14612 : : return retval;
14613 : :
14614 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14615 : :
14616 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
14617 : :
14618 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14619 : : return TEST_SKIPPED;
14620 : :
14621 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
14622 : : process_crypto_request(ts_params->valid_devs[0],
14623 : : ut_params->op), "failed to process sym crypto op");
14624 : :
14625 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14626 : : "crypto op processing failed");
14627 : :
14628 : : auth_tag = digest_mem;
14629 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14630 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14631 : : auth_tag,
14632 : : tdata->gmac_tag.data,
14633 : : tdata->gmac_tag.len,
14634 : : "GMAC Generated auth tag not as expected");
14635 : :
14636 : : return 0;
14637 : : }
14638 : :
14639 : : /* Segment size not multiple of block size (16B) */
14640 : : static int
14641 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
14642 : : {
14643 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
14644 : : }
14645 : :
14646 : : static int
14647 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
14648 : : {
14649 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
14650 : : }
14651 : :
14652 : : static int
14653 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
14654 : : {
14655 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
14656 : : }
14657 : :
14658 : : /* Segment size not multiple of block size (16B) */
14659 : : static int
14660 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
14661 : : {
14662 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
14663 : : }
14664 : :
14665 : : struct test_crypto_vector {
14666 : : enum rte_crypto_cipher_algorithm crypto_algo;
14667 : : unsigned int cipher_offset;
14668 : : unsigned int cipher_len;
14669 : :
14670 : : struct {
14671 : : uint8_t data[64];
14672 : : unsigned int len;
14673 : : } cipher_key;
14674 : :
14675 : : struct {
14676 : : uint8_t data[64];
14677 : : unsigned int len;
14678 : : } iv;
14679 : :
14680 : : struct {
14681 : : const uint8_t *data;
14682 : : unsigned int len;
14683 : : } plaintext;
14684 : :
14685 : : struct {
14686 : : const uint8_t *data;
14687 : : unsigned int len;
14688 : : } ciphertext;
14689 : :
14690 : : enum rte_crypto_auth_algorithm auth_algo;
14691 : : unsigned int auth_offset;
14692 : :
14693 : : struct {
14694 : : uint8_t data[128];
14695 : : unsigned int len;
14696 : : } auth_key;
14697 : :
14698 : : struct {
14699 : : const uint8_t *data;
14700 : : unsigned int len;
14701 : : } aad;
14702 : :
14703 : : struct {
14704 : : uint8_t data[128];
14705 : : unsigned int len;
14706 : : } digest;
14707 : : };
14708 : :
14709 : : static const struct test_crypto_vector
14710 : : hmac_sha1_test_crypto_vector = {
14711 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14712 : : .plaintext = {
14713 : : .data = plaintext_hash,
14714 : : .len = 512
14715 : : },
14716 : : .auth_key = {
14717 : : .data = {
14718 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14719 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14720 : : 0xDE, 0xF4, 0xDE, 0xAD
14721 : : },
14722 : : .len = 20
14723 : : },
14724 : : .digest = {
14725 : : .data = {
14726 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
14727 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
14728 : : 0x3F, 0x91, 0x64, 0x59
14729 : : },
14730 : : .len = 20
14731 : : }
14732 : : };
14733 : :
14734 : : static const struct test_crypto_vector
14735 : : aes128_gmac_test_vector = {
14736 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
14737 : : .plaintext = {
14738 : : .data = plaintext_hash,
14739 : : .len = 512
14740 : : },
14741 : : .iv = {
14742 : : .data = {
14743 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14744 : : 0x08, 0x09, 0x0A, 0x0B
14745 : : },
14746 : : .len = 12
14747 : : },
14748 : : .auth_key = {
14749 : : .data = {
14750 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14751 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
14752 : : },
14753 : : .len = 16
14754 : : },
14755 : : .digest = {
14756 : : .data = {
14757 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
14758 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
14759 : : },
14760 : : .len = 16
14761 : : }
14762 : : };
14763 : :
14764 : : static const struct test_crypto_vector
14765 : : aes128cbc_hmac_sha1_test_vector = {
14766 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14767 : : .cipher_offset = 0,
14768 : : .cipher_len = 512,
14769 : : .cipher_key = {
14770 : : .data = {
14771 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14772 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14773 : : },
14774 : : .len = 16
14775 : : },
14776 : : .iv = {
14777 : : .data = {
14778 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14779 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14780 : : },
14781 : : .len = 16
14782 : : },
14783 : : .plaintext = {
14784 : : .data = plaintext_hash,
14785 : : .len = 512
14786 : : },
14787 : : .ciphertext = {
14788 : : .data = ciphertext512_aes128cbc,
14789 : : .len = 512
14790 : : },
14791 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14792 : : .auth_offset = 0,
14793 : : .auth_key = {
14794 : : .data = {
14795 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14796 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14797 : : 0xDE, 0xF4, 0xDE, 0xAD
14798 : : },
14799 : : .len = 20
14800 : : },
14801 : : .digest = {
14802 : : .data = {
14803 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
14804 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14805 : : 0x18, 0x8C, 0x1D, 0x32
14806 : : },
14807 : : .len = 20
14808 : : }
14809 : : };
14810 : :
14811 : : static const struct test_crypto_vector
14812 : : aes128cbc_hmac_sha1_aad_test_vector = {
14813 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14814 : : .cipher_offset = 8,
14815 : : .cipher_len = 496,
14816 : : .cipher_key = {
14817 : : .data = {
14818 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14819 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14820 : : },
14821 : : .len = 16
14822 : : },
14823 : : .iv = {
14824 : : .data = {
14825 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14826 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14827 : : },
14828 : : .len = 16
14829 : : },
14830 : : .plaintext = {
14831 : : .data = plaintext_hash,
14832 : : .len = 512
14833 : : },
14834 : : .ciphertext = {
14835 : : .data = ciphertext512_aes128cbc_aad,
14836 : : .len = 512
14837 : : },
14838 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14839 : : .auth_offset = 0,
14840 : : .auth_key = {
14841 : : .data = {
14842 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14843 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14844 : : 0xDE, 0xF4, 0xDE, 0xAD
14845 : : },
14846 : : .len = 20
14847 : : },
14848 : : .digest = {
14849 : : .data = {
14850 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
14851 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
14852 : : 0x62, 0x0F, 0xFB, 0x10
14853 : : },
14854 : : .len = 20
14855 : : }
14856 : : };
14857 : :
14858 : : static void
14859 : : data_corruption(uint8_t *data)
14860 : : {
14861 : 3 : data[0] += 1;
14862 : 3 : }
14863 : :
14864 : : static void
14865 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
14866 : : {
14867 : 3 : data[tag_offset] += 1;
14868 : 3 : }
14869 : :
14870 : : static int
14871 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
14872 : : uint8_t dev_id,
14873 : : const struct test_crypto_vector *reference,
14874 : : enum rte_crypto_auth_operation auth_op)
14875 : 2 : {
14876 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14877 : 2 : uint8_t auth_key[reference->auth_key.len + 1];
14878 : :
14879 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14880 : :
14881 : : /* Setup Authentication Parameters */
14882 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14883 : 2 : ut_params->auth_xform.auth.op = auth_op;
14884 : 2 : ut_params->auth_xform.next = NULL;
14885 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
14886 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14887 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
14888 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
14889 : :
14890 : : /* Create Crypto session*/
14891 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14892 : : &ut_params->auth_xform,
14893 : : ts_params->session_mpool);
14894 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14895 : 0 : return TEST_SKIPPED;
14896 : :
14897 : : return 0;
14898 : : }
14899 : :
14900 : : static int
14901 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
14902 : : uint8_t dev_id,
14903 : : const struct test_crypto_vector *reference,
14904 : : enum rte_crypto_auth_operation auth_op,
14905 : : enum rte_crypto_cipher_operation cipher_op)
14906 : 4 : {
14907 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14908 : 4 : uint8_t cipher_key[reference->cipher_key.len + 1];
14909 : 4 : uint8_t auth_key[reference->auth_key.len + 1];
14910 : :
14911 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
14912 : : reference->cipher_key.len);
14913 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14914 : :
14915 : : /* Setup Authentication Parameters */
14916 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14917 : 4 : ut_params->auth_xform.auth.op = auth_op;
14918 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
14919 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14920 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
14921 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
14922 : :
14923 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
14924 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14925 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
14926 : : } else {
14927 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
14928 : :
14929 : : /* Setup Cipher Parameters */
14930 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14931 : 2 : ut_params->cipher_xform.next = NULL;
14932 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14933 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
14934 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
14935 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14936 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14937 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14938 : : }
14939 : :
14940 : : /* Create Crypto session*/
14941 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14942 : : &ut_params->auth_xform,
14943 : : ts_params->session_mpool);
14944 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14945 : 0 : return TEST_SKIPPED;
14946 : :
14947 : : return 0;
14948 : : }
14949 : :
14950 : : static int
14951 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
14952 : : struct crypto_unittest_params *ut_params,
14953 : : const struct test_crypto_vector *reference,
14954 : : unsigned int auth_generate)
14955 : : {
14956 : : /* Generate Crypto op data structure */
14957 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14958 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14959 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14960 : : "Failed to allocate pktmbuf offload");
14961 : :
14962 : : /* Set crypto operation data parameters */
14963 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14964 : :
14965 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14966 : :
14967 : : /* set crypto operation source mbuf */
14968 : 2 : sym_op->m_src = ut_params->ibuf;
14969 : :
14970 : : /* digest */
14971 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14972 : 2 : ut_params->ibuf, reference->digest.len);
14973 : :
14974 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14975 : : "no room to append auth tag");
14976 : :
14977 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14978 : : ut_params->ibuf, reference->plaintext.len);
14979 : :
14980 [ - + ]: 2 : if (auth_generate)
14981 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
14982 : : else
14983 : 2 : memcpy(sym_op->auth.digest.data,
14984 : 2 : reference->digest.data,
14985 : 2 : reference->digest.len);
14986 : :
14987 : 2 : debug_hexdump(stdout, "digest:",
14988 : 2 : sym_op->auth.digest.data,
14989 : 2 : reference->digest.len);
14990 : :
14991 : 2 : sym_op->auth.data.length = reference->plaintext.len;
14992 : 2 : sym_op->auth.data.offset = 0;
14993 : :
14994 : 2 : return 0;
14995 : : }
14996 : :
14997 : : static int
14998 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
14999 : : struct crypto_unittest_params *ut_params,
15000 : : const struct test_crypto_vector *reference,
15001 : : unsigned int auth_generate)
15002 : : {
15003 : : /* Generate Crypto op data structure */
15004 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15005 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15006 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
15007 : : "Failed to allocate pktmbuf offload");
15008 : :
15009 : : /* Set crypto operation data parameters */
15010 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15011 : :
15012 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15013 : :
15014 : : /* set crypto operation source mbuf */
15015 : 2 : sym_op->m_src = ut_params->ibuf;
15016 : :
15017 : : /* digest */
15018 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15019 : 2 : ut_params->ibuf, reference->digest.len);
15020 : :
15021 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15022 : : "no room to append auth tag");
15023 : :
15024 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15025 : : ut_params->ibuf, reference->ciphertext.len);
15026 : :
15027 [ - + ]: 2 : if (auth_generate)
15028 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
15029 : : else
15030 : 2 : memcpy(sym_op->auth.digest.data,
15031 : 2 : reference->digest.data,
15032 : 2 : reference->digest.len);
15033 : :
15034 : 2 : debug_hexdump(stdout, "digest:",
15035 : 2 : sym_op->auth.digest.data,
15036 : 2 : reference->digest.len);
15037 : :
15038 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15039 [ - + ]: 2 : reference->iv.data, reference->iv.len);
15040 : :
15041 : 2 : sym_op->cipher.data.length = 0;
15042 : 2 : sym_op->cipher.data.offset = 0;
15043 : :
15044 : 2 : sym_op->auth.data.length = reference->plaintext.len;
15045 : 2 : sym_op->auth.data.offset = 0;
15046 : :
15047 : 2 : return 0;
15048 : : }
15049 : :
15050 : : static int
15051 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
15052 : : struct crypto_unittest_params *ut_params,
15053 : : const struct test_crypto_vector *reference,
15054 : : unsigned int auth_generate)
15055 : : {
15056 : : /* Generate Crypto op data structure */
15057 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15058 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15059 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
15060 : : "Failed to allocate pktmbuf offload");
15061 : :
15062 : : /* Set crypto operation data parameters */
15063 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15064 : :
15065 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15066 : :
15067 : : /* set crypto operation source mbuf */
15068 : 4 : sym_op->m_src = ut_params->ibuf;
15069 : :
15070 : : /* digest */
15071 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15072 : 4 : ut_params->ibuf, reference->digest.len);
15073 : :
15074 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15075 : : "no room to append auth tag");
15076 : :
15077 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15078 : : ut_params->ibuf, reference->ciphertext.len);
15079 : :
15080 [ - + ]: 4 : if (auth_generate)
15081 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
15082 : : else
15083 : 4 : memcpy(sym_op->auth.digest.data,
15084 : 4 : reference->digest.data,
15085 : 4 : reference->digest.len);
15086 : :
15087 : 4 : debug_hexdump(stdout, "digest:",
15088 : 4 : sym_op->auth.digest.data,
15089 : 4 : reference->digest.len);
15090 : :
15091 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15092 [ - + ]: 4 : reference->iv.data, reference->iv.len);
15093 : :
15094 : 4 : sym_op->cipher.data.length = reference->cipher_len;
15095 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
15096 : :
15097 : 4 : sym_op->auth.data.length = reference->plaintext.len;
15098 : 4 : sym_op->auth.data.offset = reference->auth_offset;
15099 : :
15100 : 4 : return 0;
15101 : : }
15102 : :
15103 : : static int
15104 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15105 : : struct crypto_unittest_params *ut_params,
15106 : : const struct test_crypto_vector *reference)
15107 : : {
15108 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
15109 : : }
15110 : :
15111 : : static int
15112 : : create_auth_verify_GMAC_operation(
15113 : : struct crypto_testsuite_params *ts_params,
15114 : : struct crypto_unittest_params *ut_params,
15115 : : const struct test_crypto_vector *reference)
15116 : : {
15117 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
15118 : : }
15119 : :
15120 : : static int
15121 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15122 : : struct crypto_unittest_params *ut_params,
15123 : : const struct test_crypto_vector *reference)
15124 : : {
15125 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
15126 : : }
15127 : :
15128 : : static int
15129 : 2 : test_authentication_verify_fail_when_data_corruption(
15130 : : struct crypto_testsuite_params *ts_params,
15131 : : struct crypto_unittest_params *ut_params,
15132 : : const struct test_crypto_vector *reference,
15133 : : unsigned int data_corrupted)
15134 : : {
15135 : : int retval;
15136 : :
15137 : : uint8_t *plaintext;
15138 : : struct rte_cryptodev_info dev_info;
15139 : :
15140 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15141 : 2 : uint64_t feat_flags = dev_info.feature_flags;
15142 : :
15143 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15144 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15145 : : printf("Device doesn't support RAW data-path APIs.\n");
15146 : 0 : return TEST_SKIPPED;
15147 : : }
15148 : :
15149 : : /* Verify the capabilities */
15150 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15151 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15152 : 2 : cap_idx.algo.auth = reference->auth_algo;
15153 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15154 : : &cap_idx) == NULL)
15155 : : return TEST_SKIPPED;
15156 : :
15157 : :
15158 : : /* Create session */
15159 : 2 : retval = create_auth_session(ut_params,
15160 : 2 : ts_params->valid_devs[0],
15161 : : reference,
15162 : : RTE_CRYPTO_AUTH_OP_VERIFY);
15163 : :
15164 [ + - ]: 2 : if (retval == TEST_SKIPPED)
15165 : : return TEST_SKIPPED;
15166 [ + - ]: 2 : if (retval < 0)
15167 : : return retval;
15168 : :
15169 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15170 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15171 : : "Failed to allocate input buffer in mempool");
15172 : :
15173 : : /* clear mbuf payload */
15174 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15175 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15176 : :
15177 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15178 : 2 : reference->plaintext.len);
15179 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15180 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15181 : :
15182 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
15183 : 2 : reference->plaintext.len);
15184 : :
15185 : : /* Create operation */
15186 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
15187 : :
15188 [ + - ]: 2 : if (retval < 0)
15189 : : return retval;
15190 : :
15191 [ + + ]: 2 : if (data_corrupted)
15192 : : data_corruption(plaintext);
15193 : : else
15194 : 1 : tag_corruption(plaintext, reference->plaintext.len);
15195 : :
15196 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15197 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15198 : : ut_params->op);
15199 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15200 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15201 : : "authentication not failed");
15202 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15203 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15204 : : 0);
15205 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15206 : : return retval;
15207 : : } else {
15208 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15209 : : ut_params->op);
15210 : : }
15211 [ - + ]: 2 : if (ut_params->op == NULL)
15212 : : return 0;
15213 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
15214 : 0 : return 0;
15215 : :
15216 : : return -1;
15217 : : }
15218 : :
15219 : : static int
15220 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
15221 : : struct crypto_testsuite_params *ts_params,
15222 : : struct crypto_unittest_params *ut_params,
15223 : : const struct test_crypto_vector *reference,
15224 : : unsigned int data_corrupted)
15225 : : {
15226 : : int retval;
15227 : : uint8_t *plaintext;
15228 : : struct rte_cryptodev_info dev_info;
15229 : :
15230 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15231 : 2 : uint64_t feat_flags = dev_info.feature_flags;
15232 : :
15233 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15234 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15235 : : printf("Device doesn't support RAW data-path APIs.\n");
15236 : 0 : return TEST_SKIPPED;
15237 : : }
15238 : :
15239 : : /* Verify the capabilities */
15240 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15241 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15242 : 2 : cap_idx.algo.auth = reference->auth_algo;
15243 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15244 : : &cap_idx) == NULL)
15245 : : return TEST_SKIPPED;
15246 : :
15247 : : /* Create session */
15248 : 2 : retval = create_auth_cipher_session(ut_params,
15249 : 2 : ts_params->valid_devs[0],
15250 : : reference,
15251 : : RTE_CRYPTO_AUTH_OP_VERIFY,
15252 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
15253 [ + - ]: 2 : if (retval == TEST_SKIPPED)
15254 : : return TEST_SKIPPED;
15255 [ + - ]: 2 : if (retval < 0)
15256 : : return retval;
15257 : :
15258 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15259 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15260 : : "Failed to allocate input buffer in mempool");
15261 : :
15262 : : /* clear mbuf payload */
15263 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15264 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15265 : :
15266 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15267 : 2 : reference->plaintext.len);
15268 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15269 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15270 : :
15271 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
15272 : 2 : reference->plaintext.len);
15273 : :
15274 : : /* Create operation */
15275 : : retval = create_auth_verify_GMAC_operation(ts_params,
15276 : : ut_params,
15277 : : reference);
15278 : :
15279 [ + - ]: 2 : if (retval < 0)
15280 : : return retval;
15281 : :
15282 [ + + ]: 2 : if (data_corrupted)
15283 : : data_corruption(plaintext);
15284 : : else
15285 : 1 : tag_corruption(plaintext, reference->aad.len);
15286 : :
15287 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15288 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15289 : : ut_params->op);
15290 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15291 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15292 : : "authentication not failed");
15293 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15294 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15295 : : 0);
15296 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15297 : 0 : return retval;
15298 : : } else {
15299 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15300 : : ut_params->op);
15301 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15302 : : }
15303 : :
15304 : : return 0;
15305 : : }
15306 : :
15307 : : static int
15308 : 2 : test_authenticated_decryption_fail_when_corruption(
15309 : : struct crypto_testsuite_params *ts_params,
15310 : : struct crypto_unittest_params *ut_params,
15311 : : const struct test_crypto_vector *reference,
15312 : : unsigned int data_corrupted)
15313 : : {
15314 : : int retval;
15315 : :
15316 : : uint8_t *ciphertext;
15317 : : struct rte_cryptodev_info dev_info;
15318 : :
15319 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15320 : 2 : uint64_t feat_flags = dev_info.feature_flags;
15321 : :
15322 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15323 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15324 : : printf("Device doesn't support RAW data-path APIs.\n");
15325 : 0 : return TEST_SKIPPED;
15326 : : }
15327 : :
15328 : : /* Verify the capabilities */
15329 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15330 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15331 : 2 : cap_idx.algo.auth = reference->auth_algo;
15332 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15333 : : &cap_idx) == NULL)
15334 : : return TEST_SKIPPED;
15335 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15336 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
15337 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15338 : : &cap_idx) == NULL)
15339 : : return TEST_SKIPPED;
15340 : :
15341 : : /* Create session */
15342 : 2 : retval = create_auth_cipher_session(ut_params,
15343 : 2 : ts_params->valid_devs[0],
15344 : : reference,
15345 : : RTE_CRYPTO_AUTH_OP_VERIFY,
15346 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
15347 [ + - ]: 2 : if (retval == TEST_SKIPPED)
15348 : : return TEST_SKIPPED;
15349 [ + - ]: 2 : if (retval < 0)
15350 : : return retval;
15351 : :
15352 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15353 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15354 : : "Failed to allocate input buffer in mempool");
15355 : :
15356 : : /* clear mbuf payload */
15357 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15358 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15359 : :
15360 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15361 : 2 : reference->ciphertext.len);
15362 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15363 : 2 : memcpy(ciphertext, reference->ciphertext.data,
15364 : 2 : reference->ciphertext.len);
15365 : :
15366 : : /* Create operation */
15367 : : retval = create_cipher_auth_verify_operation(ts_params,
15368 : : ut_params,
15369 : : reference);
15370 : :
15371 [ + - ]: 2 : if (retval < 0)
15372 : : return retval;
15373 : :
15374 [ + + ]: 2 : if (data_corrupted)
15375 : : data_corruption(ciphertext);
15376 : : else
15377 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
15378 : :
15379 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15380 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15381 : : ut_params->op);
15382 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15383 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15384 : : "authentication not failed");
15385 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15386 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15387 : : 0);
15388 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15389 : 0 : return retval;
15390 : : } else {
15391 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15392 : : ut_params->op);
15393 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15394 : : }
15395 : :
15396 : : return 0;
15397 : : }
15398 : :
15399 : : static int
15400 : 1 : test_authenticated_encrypt_with_esn(
15401 : : struct crypto_testsuite_params *ts_params,
15402 : : struct crypto_unittest_params *ut_params,
15403 : : const struct test_crypto_vector *reference)
15404 : 1 : {
15405 : : int retval;
15406 : :
15407 : : uint8_t *authciphertext, *plaintext, *auth_tag;
15408 : : uint16_t plaintext_pad_len;
15409 : 1 : uint8_t cipher_key[reference->cipher_key.len + 1];
15410 : 1 : uint8_t auth_key[reference->auth_key.len + 1];
15411 : : struct rte_cryptodev_info dev_info;
15412 : :
15413 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15414 : 1 : uint64_t feat_flags = dev_info.feature_flags;
15415 : :
15416 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15417 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15418 : : printf("Device doesn't support RAW data-path APIs.\n");
15419 : 0 : return TEST_SKIPPED;
15420 : : }
15421 : :
15422 : : /* Verify the capabilities */
15423 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15424 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15425 : 1 : cap_idx.algo.auth = reference->auth_algo;
15426 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15427 : : &cap_idx) == NULL)
15428 : : return TEST_SKIPPED;
15429 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15430 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
15431 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15432 : : &cap_idx) == NULL)
15433 : : return TEST_SKIPPED;
15434 : :
15435 : : /* Create session */
15436 : 1 : memcpy(cipher_key, reference->cipher_key.data,
15437 : 1 : reference->cipher_key.len);
15438 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15439 : :
15440 : : /* Setup Cipher Parameters */
15441 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15442 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15443 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15444 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
15445 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15446 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15447 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15448 : :
15449 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15450 : :
15451 : : /* Setup Authentication Parameters */
15452 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15453 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15454 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15455 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15456 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
15457 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15458 : 1 : ut_params->auth_xform.next = NULL;
15459 : :
15460 : : /* Create Crypto session*/
15461 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
15462 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15463 : : ts_params->session_mpool);
15464 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15465 : : return TEST_SKIPPED;
15466 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15467 : :
15468 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15469 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15470 : : "Failed to allocate input buffer in mempool");
15471 : :
15472 : : /* clear mbuf payload */
15473 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15474 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15475 : :
15476 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15477 : 1 : reference->plaintext.len);
15478 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15479 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15480 : :
15481 : : /* Create operation */
15482 : 1 : retval = create_cipher_auth_operation(ts_params,
15483 : : ut_params,
15484 : : reference, 0);
15485 : :
15486 [ + - ]: 1 : if (retval < 0)
15487 : : return retval;
15488 : :
15489 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15490 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15491 : : ut_params->op);
15492 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15493 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15494 : : 0);
15495 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15496 : : return retval;
15497 : : } else
15498 : 1 : ut_params->op = process_crypto_request(
15499 : 1 : ts_params->valid_devs[0], ut_params->op);
15500 : :
15501 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
15502 : :
15503 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15504 : : "crypto op processing failed");
15505 : :
15506 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
15507 : :
15508 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
15509 : : ut_params->op->sym->auth.data.offset);
15510 : 1 : auth_tag = authciphertext + plaintext_pad_len;
15511 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
15512 : 1 : reference->ciphertext.len);
15513 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
15514 : :
15515 : : /* Validate obuf */
15516 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15517 : : authciphertext,
15518 : : reference->ciphertext.data,
15519 : : reference->ciphertext.len,
15520 : : "Ciphertext data not as expected");
15521 : :
15522 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15523 : : auth_tag,
15524 : : reference->digest.data,
15525 : : reference->digest.len,
15526 : : "Generated digest not as expected");
15527 : :
15528 : : return TEST_SUCCESS;
15529 : :
15530 : : }
15531 : :
15532 : : static int
15533 : 1 : test_authenticated_decrypt_with_esn(
15534 : : struct crypto_testsuite_params *ts_params,
15535 : : struct crypto_unittest_params *ut_params,
15536 : : const struct test_crypto_vector *reference)
15537 : 1 : {
15538 : : int retval;
15539 : :
15540 : : uint8_t *ciphertext;
15541 : 1 : uint8_t cipher_key[reference->cipher_key.len + 1];
15542 : 1 : uint8_t auth_key[reference->auth_key.len + 1];
15543 : : struct rte_cryptodev_info dev_info;
15544 : :
15545 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15546 : 1 : uint64_t feat_flags = dev_info.feature_flags;
15547 : :
15548 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15549 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15550 : : printf("Device doesn't support RAW data-path APIs.\n");
15551 : 0 : return TEST_SKIPPED;
15552 : : }
15553 : :
15554 : : /* Verify the capabilities */
15555 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15556 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15557 : 1 : cap_idx.algo.auth = reference->auth_algo;
15558 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15559 : : &cap_idx) == NULL)
15560 : : return TEST_SKIPPED;
15561 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15562 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
15563 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15564 : : &cap_idx) == NULL)
15565 : : return TEST_SKIPPED;
15566 : :
15567 : : /* Create session */
15568 : 1 : memcpy(cipher_key, reference->cipher_key.data,
15569 : 1 : reference->cipher_key.len);
15570 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15571 : :
15572 : : /* Setup Authentication Parameters */
15573 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15574 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
15575 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15576 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15577 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
15578 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15579 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
15580 : :
15581 : : /* Setup Cipher Parameters */
15582 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15583 : 1 : ut_params->cipher_xform.next = NULL;
15584 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15585 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
15586 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
15587 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15588 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15589 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15590 : :
15591 : : /* Create Crypto session*/
15592 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
15593 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
15594 : : ts_params->session_mpool);
15595 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15596 : : return TEST_SKIPPED;
15597 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15598 : :
15599 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15600 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15601 : : "Failed to allocate input buffer in mempool");
15602 : :
15603 : : /* clear mbuf payload */
15604 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15605 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15606 : :
15607 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15608 : 1 : reference->ciphertext.len);
15609 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15610 : 1 : memcpy(ciphertext, reference->ciphertext.data,
15611 : 1 : reference->ciphertext.len);
15612 : :
15613 : : /* Create operation */
15614 : : retval = create_cipher_auth_verify_operation(ts_params,
15615 : : ut_params,
15616 : : reference);
15617 : :
15618 [ + - ]: 1 : if (retval < 0)
15619 : : return retval;
15620 : :
15621 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15622 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15623 : : ut_params->op);
15624 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15625 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15626 : : 0);
15627 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15628 : : return retval;
15629 : : } else
15630 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15631 : : ut_params->op);
15632 : :
15633 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
15634 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
15635 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15636 : : "crypto op processing passed");
15637 : :
15638 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
15639 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
15640 : :
15641 : : return 0;
15642 : : }
15643 : :
15644 : : static int
15645 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
15646 : : const struct aead_test_data *tdata,
15647 : : void *digest_mem, uint64_t digest_phys)
15648 : : {
15649 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15650 : : struct crypto_unittest_params *ut_params = &unittest_params;
15651 : :
15652 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
15653 : 1 : const unsigned int iv_len = tdata->iv.len;
15654 : 1 : unsigned int aad_len = tdata->aad.len;
15655 : : unsigned int aad_len_pad = 0;
15656 : :
15657 : : /* Generate Crypto op data structure */
15658 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15659 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15660 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
15661 : : "Failed to allocate symmetric crypto operation struct");
15662 : :
15663 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15664 : :
15665 : 1 : sym_op->aead.digest.data = digest_mem;
15666 : :
15667 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
15668 : : "no room to append digest");
15669 : :
15670 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
15671 : :
15672 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
15673 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
15674 : : auth_tag_len);
15675 : 0 : debug_hexdump(stdout, "digest:",
15676 : 0 : sym_op->aead.digest.data,
15677 : : auth_tag_len);
15678 : : }
15679 : :
15680 : : /* Append aad data */
15681 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
15682 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15683 : : uint8_t *, IV_OFFSET);
15684 : :
15685 : : /* Copy IV 1 byte after the IV pointer, according to the API */
15686 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
15687 : :
15688 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
15689 : :
15690 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15691 : : ut_params->ibuf, aad_len);
15692 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15693 : : "no room to prepend aad");
15694 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15695 : : ut_params->ibuf);
15696 : :
15697 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
15698 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
15699 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15700 : :
15701 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15702 : 0 : debug_hexdump(stdout, "aad:",
15703 : 0 : sym_op->aead.aad.data, aad_len);
15704 : : } else {
15705 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15706 : : uint8_t *, IV_OFFSET);
15707 : :
15708 [ - + ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
15709 : :
15710 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
15711 : :
15712 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15713 : : ut_params->ibuf, aad_len_pad);
15714 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15715 : : "no room to prepend aad");
15716 [ - + ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15717 : : ut_params->ibuf);
15718 : :
15719 [ - + ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
15720 [ - + ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15721 : :
15722 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15723 : 1 : debug_hexdump(stdout, "aad:",
15724 : 1 : sym_op->aead.aad.data, aad_len);
15725 : : }
15726 : :
15727 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
15728 : 1 : sym_op->aead.data.offset = aad_len_pad;
15729 : :
15730 : 1 : return 0;
15731 : : }
15732 : :
15733 : : #define SGL_MAX_NO 16
15734 : :
15735 : : static int
15736 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
15737 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
15738 : : {
15739 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15740 : : struct crypto_unittest_params *ut_params = &unittest_params;
15741 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
15742 : : int retval;
15743 : : int to_trn = 0;
15744 : : int to_trn_tbl[SGL_MAX_NO];
15745 : : int segs = 1;
15746 : : unsigned int trn_data = 0;
15747 : : uint8_t *plaintext, *ciphertext, *auth_tag;
15748 : : struct rte_cryptodev_info dev_info;
15749 : :
15750 : : /* Verify the capabilities */
15751 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15752 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
15753 : 3 : cap_idx.algo.aead = tdata->algo;
15754 [ + - ]: 3 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15755 : : &cap_idx) == NULL)
15756 : : return TEST_SKIPPED;
15757 : :
15758 : : /*
15759 : : * SGL not supported on AESNI_MB PMD CPU crypto,
15760 : : * OOP not supported on AESNI_GCM CPU crypto
15761 : : */
15762 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
15763 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
15764 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
15765 : : return TEST_SKIPPED;
15766 : :
15767 : : /* Detailed check for the particular SGL support flag */
15768 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15769 [ - + ]: 3 : if (!oop) {
15770 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
15771 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
15772 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
15773 : : return TEST_SKIPPED;
15774 : :
15775 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15776 : :
15777 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15778 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15779 : : printf("Device doesn't support RAW data-path APIs.\n");
15780 : 0 : return TEST_SKIPPED;
15781 : : }
15782 : : } else {
15783 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
15784 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
15785 : : tdata->plaintext.len;
15786 : : /* Raw data path API does not support OOP */
15787 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
15788 : : return TEST_SKIPPED;
15789 [ + + ]: 3 : if (sgl_in && !sgl_out) {
15790 [ + - ]: 1 : if (!(dev_info.feature_flags &
15791 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
15792 : : return TEST_SKIPPED;
15793 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
15794 [ # # ]: 0 : if (!(dev_info.feature_flags &
15795 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
15796 : : return TEST_SKIPPED;
15797 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
15798 [ - + ]: 2 : if (!(dev_info.feature_flags &
15799 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
15800 : : return TEST_SKIPPED;
15801 : : }
15802 : : }
15803 : :
15804 : 1 : if (fragsz > tdata->plaintext.len)
15805 : : fragsz = tdata->plaintext.len;
15806 : :
15807 : 1 : uint16_t plaintext_len = fragsz;
15808 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
15809 : :
15810 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
15811 : 0 : frag_size_oop = tdata->plaintext.len;
15812 : :
15813 : : int ecx = 0;
15814 : : void *digest_mem = NULL;
15815 : :
15816 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
15817 : :
15818 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
15819 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
15820 : : return 1;
15821 : : } else {
15822 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
15823 : : return 1;
15824 : : }
15825 : :
15826 : : /*
15827 : : * For out-op-place we need to alloc another mbuf
15828 : : */
15829 [ + - ]: 1 : if (oop) {
15830 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15831 : : rte_pktmbuf_append(ut_params->obuf,
15832 : 1 : frag_size_oop + prepend_len);
15833 : 1 : buf_oop = ut_params->obuf;
15834 : : }
15835 : :
15836 : : /* Create AEAD session */
15837 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
15838 : 1 : tdata->algo,
15839 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
15840 : 1 : tdata->key.data, tdata->key.len,
15841 : 1 : tdata->aad.len, tdata->auth_tag.len,
15842 : 1 : tdata->iv.len);
15843 [ + - ]: 1 : if (retval < 0)
15844 : : return retval;
15845 : :
15846 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15847 : :
15848 : : /* clear mbuf payload */
15849 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15850 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15851 : :
15852 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15853 : : plaintext_len);
15854 : :
15855 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15856 : :
15857 : : trn_data += plaintext_len;
15858 : :
15859 : 1 : buf = ut_params->ibuf;
15860 : :
15861 : : /*
15862 : : * Loop until no more fragments
15863 : : */
15864 : :
15865 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
15866 : 5 : ++segs;
15867 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15868 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
15869 : :
15870 : 5 : to_trn_tbl[ecx++] = to_trn;
15871 : :
15872 [ - + ]: 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15873 : : buf = buf->next;
15874 : :
15875 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15876 : : rte_pktmbuf_tailroom(buf));
15877 : :
15878 : : /* OOP */
15879 [ - + ]: 5 : if (oop && !fragsz_oop) {
15880 : 0 : buf_last_oop = buf_oop->next =
15881 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
15882 : : buf_oop = buf_oop->next;
15883 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15884 : : 0, rte_pktmbuf_tailroom(buf_oop));
15885 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
15886 : : }
15887 : :
15888 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15889 : : to_trn);
15890 : :
15891 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15892 : : to_trn);
15893 : 5 : trn_data += to_trn;
15894 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
15895 [ + - ]: 1 : if (oop) {
15896 [ - + ]: 1 : if (!fragsz_oop)
15897 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
15898 : 0 : tdata->auth_tag.len);
15899 : : } else
15900 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15901 : 0 : tdata->auth_tag.len);
15902 : : }
15903 : : }
15904 : :
15905 : : uint64_t digest_phys = 0;
15906 : :
15907 : 1 : ut_params->ibuf->nb_segs = segs;
15908 : :
15909 : : segs = 1;
15910 [ + - ]: 1 : if (fragsz_oop && oop) {
15911 : : to_trn = 0;
15912 : : ecx = 0;
15913 : :
15914 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
15915 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
15916 : 1 : tdata->auth_tag.len);
15917 : :
15918 : 1 : digest_phys = rte_pktmbuf_iova_offset(
15919 : : ut_params->obuf,
15920 : : tdata->plaintext.len + prepend_len);
15921 : : }
15922 : :
15923 : : trn_data = frag_size_oop;
15924 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
15925 : 0 : ++segs;
15926 : 0 : to_trn =
15927 : 0 : (tdata->plaintext.len - trn_data <
15928 : : frag_size_oop) ?
15929 : 0 : (tdata->plaintext.len - trn_data) :
15930 : : frag_size_oop;
15931 : :
15932 : 0 : to_trn_tbl[ecx++] = to_trn;
15933 : :
15934 : 0 : buf_last_oop = buf_oop->next =
15935 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
15936 : : buf_oop = buf_oop->next;
15937 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15938 : : 0, rte_pktmbuf_tailroom(buf_oop));
15939 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
15940 : :
15941 : 0 : trn_data += to_trn;
15942 : :
15943 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15944 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
15945 : 0 : tdata->auth_tag.len);
15946 : : }
15947 : : }
15948 : :
15949 : 1 : ut_params->obuf->nb_segs = segs;
15950 : : }
15951 : :
15952 : : /*
15953 : : * Place digest at the end of the last buffer
15954 : : */
15955 [ - + ]: 1 : if (!digest_phys)
15956 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15957 [ - + ]: 1 : if (oop && buf_last_oop)
15958 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
15959 : :
15960 [ - + ]: 1 : if (!digest_mem && !oop) {
15961 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15962 : 0 : + tdata->auth_tag.len);
15963 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15964 : : tdata->plaintext.len);
15965 : : }
15966 : :
15967 : : /* Create AEAD operation */
15968 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
15969 : : tdata, digest_mem, digest_phys);
15970 : :
15971 [ + - ]: 1 : if (retval < 0)
15972 : : return retval;
15973 : :
15974 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15975 : :
15976 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
15977 [ + - ]: 1 : if (oop)
15978 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
15979 : :
15980 : : /* Process crypto operation */
15981 [ - + ]: 1 : if (oop == IN_PLACE &&
15982 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15983 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
15984 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15985 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
15986 : : 0);
15987 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15988 : : return retval;
15989 : : } else
15990 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
15991 : : process_crypto_request(ts_params->valid_devs[0],
15992 : : ut_params->op), "failed to process sym crypto op");
15993 : :
15994 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15995 : : "crypto op processing failed");
15996 : :
15997 : :
15998 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
15999 : : uint8_t *, prepend_len);
16000 [ + - ]: 1 : if (oop) {
16001 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
16002 : : uint8_t *, prepend_len);
16003 : : }
16004 : :
16005 [ + - ]: 1 : if (fragsz_oop)
16006 : : fragsz = fragsz_oop;
16007 : :
16008 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16009 : : ciphertext,
16010 : : tdata->ciphertext.data,
16011 : : fragsz,
16012 : : "Ciphertext data not as expected");
16013 : :
16014 : 1 : buf = ut_params->op->sym->m_src->next;
16015 [ + - ]: 1 : if (oop)
16016 : 1 : buf = ut_params->op->sym->m_dst->next;
16017 : :
16018 : : unsigned int off = fragsz;
16019 : :
16020 : : ecx = 0;
16021 [ - + ]: 1 : while (buf) {
16022 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
16023 : : uint8_t *);
16024 : :
16025 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16026 : : ciphertext,
16027 : : tdata->ciphertext.data + off,
16028 : : to_trn_tbl[ecx],
16029 : : "Ciphertext data not as expected");
16030 : :
16031 : 0 : off += to_trn_tbl[ecx++];
16032 : 0 : buf = buf->next;
16033 : : }
16034 : :
16035 : : auth_tag = digest_mem;
16036 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16037 : : auth_tag,
16038 : : tdata->auth_tag.data,
16039 : : tdata->auth_tag.len,
16040 : : "Generated auth tag not as expected");
16041 : :
16042 : : return 0;
16043 : : }
16044 : :
16045 : : static int
16046 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
16047 : : {
16048 : 1 : return test_authenticated_encryption_SGL(
16049 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
16050 : : }
16051 : :
16052 : : static int
16053 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
16054 : : {
16055 : 1 : return test_authenticated_encryption_SGL(
16056 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
16057 : : }
16058 : :
16059 : : static int
16060 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
16061 : : {
16062 : 1 : return test_authenticated_encryption_SGL(
16063 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
16064 : : gcm_test_case_8.plaintext.len);
16065 : : }
16066 : :
16067 : : static int
16068 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
16069 : : {
16070 : : /* This test is not for OPENSSL PMD */
16071 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
16072 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
16073 : : return TEST_SKIPPED;
16074 : :
16075 : 0 : return test_authenticated_encryption_SGL(
16076 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
16077 : : }
16078 : :
16079 : : static int
16080 : : test_authentication_verify_fail_when_data_corrupted(
16081 : : struct crypto_testsuite_params *ts_params,
16082 : : struct crypto_unittest_params *ut_params,
16083 : : const struct test_crypto_vector *reference)
16084 : : {
16085 : 1 : return test_authentication_verify_fail_when_data_corruption(
16086 : : ts_params, ut_params, reference, 1);
16087 : : }
16088 : :
16089 : : static int
16090 : : test_authentication_verify_fail_when_tag_corrupted(
16091 : : struct crypto_testsuite_params *ts_params,
16092 : : struct crypto_unittest_params *ut_params,
16093 : : const struct test_crypto_vector *reference)
16094 : : {
16095 : 1 : return test_authentication_verify_fail_when_data_corruption(
16096 : : ts_params, ut_params, reference, 0);
16097 : : }
16098 : :
16099 : : static int
16100 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
16101 : : struct crypto_testsuite_params *ts_params,
16102 : : struct crypto_unittest_params *ut_params,
16103 : : const struct test_crypto_vector *reference)
16104 : : {
16105 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
16106 : : ts_params, ut_params, reference, 1);
16107 : : }
16108 : :
16109 : : static int
16110 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
16111 : : struct crypto_testsuite_params *ts_params,
16112 : : struct crypto_unittest_params *ut_params,
16113 : : const struct test_crypto_vector *reference)
16114 : : {
16115 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
16116 : : ts_params, ut_params, reference, 0);
16117 : : }
16118 : :
16119 : : static int
16120 : : test_authenticated_decryption_fail_when_data_corrupted(
16121 : : struct crypto_testsuite_params *ts_params,
16122 : : struct crypto_unittest_params *ut_params,
16123 : : const struct test_crypto_vector *reference)
16124 : : {
16125 : 1 : return test_authenticated_decryption_fail_when_corruption(
16126 : : ts_params, ut_params, reference, 1);
16127 : : }
16128 : :
16129 : : static int
16130 : : test_authenticated_decryption_fail_when_tag_corrupted(
16131 : : struct crypto_testsuite_params *ts_params,
16132 : : struct crypto_unittest_params *ut_params,
16133 : : const struct test_crypto_vector *reference)
16134 : : {
16135 : 1 : return test_authenticated_decryption_fail_when_corruption(
16136 : : ts_params, ut_params, reference, 0);
16137 : : }
16138 : :
16139 : : static int
16140 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
16141 : : {
16142 : 1 : return test_authentication_verify_fail_when_data_corrupted(
16143 : : &testsuite_params, &unittest_params,
16144 : : &hmac_sha1_test_crypto_vector);
16145 : : }
16146 : :
16147 : : static int
16148 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
16149 : : {
16150 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
16151 : : &testsuite_params, &unittest_params,
16152 : : &hmac_sha1_test_crypto_vector);
16153 : : }
16154 : :
16155 : : static int
16156 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
16157 : : {
16158 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
16159 : : &testsuite_params, &unittest_params,
16160 : : &aes128_gmac_test_vector);
16161 : : }
16162 : :
16163 : : static int
16164 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
16165 : : {
16166 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
16167 : : &testsuite_params, &unittest_params,
16168 : : &aes128_gmac_test_vector);
16169 : : }
16170 : :
16171 : : static int
16172 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
16173 : : {
16174 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
16175 : : &testsuite_params,
16176 : : &unittest_params,
16177 : : &aes128cbc_hmac_sha1_test_vector);
16178 : : }
16179 : :
16180 : : static int
16181 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
16182 : : {
16183 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
16184 : : &testsuite_params,
16185 : : &unittest_params,
16186 : : &aes128cbc_hmac_sha1_test_vector);
16187 : : }
16188 : :
16189 : : static int
16190 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16191 : : {
16192 : 1 : return test_authenticated_encrypt_with_esn(
16193 : : &testsuite_params,
16194 : : &unittest_params,
16195 : : &aes128cbc_hmac_sha1_aad_test_vector);
16196 : : }
16197 : :
16198 : : static int
16199 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16200 : : {
16201 : 1 : return test_authenticated_decrypt_with_esn(
16202 : : &testsuite_params,
16203 : : &unittest_params,
16204 : : &aes128cbc_hmac_sha1_aad_test_vector);
16205 : : }
16206 : :
16207 : : static int
16208 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
16209 : : {
16210 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
16211 : : }
16212 : :
16213 : : static int
16214 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
16215 : : {
16216 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
16217 : : }
16218 : :
16219 : : static int
16220 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
16221 : : {
16222 : 0 : return test_authenticated_encryption_SGL(
16223 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
16224 : : chacha20_poly1305_case_2.plaintext.len);
16225 : : }
16226 : :
16227 : : #ifdef RTE_CRYPTO_SCHEDULER
16228 : :
16229 : : /* global AESNI worker IDs for the scheduler test */
16230 : : uint8_t aesni_ids[2];
16231 : :
16232 : : static int
16233 : 0 : scheduler_testsuite_setup(void)
16234 : : {
16235 : : uint32_t i = 0;
16236 : : int32_t nb_devs, ret;
16237 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
16238 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
16239 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
16240 : : uint16_t worker_core_count = 0;
16241 : : uint16_t socket_id = 0;
16242 : :
16243 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
16244 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
16245 : :
16246 : : /* Identify the Worker Cores
16247 : : * Use 2 worker cores for the device args
16248 : : */
16249 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
16250 [ # # ]: 0 : if (worker_core_count > 1)
16251 : : break;
16252 : : snprintf(vdev_args, sizeof(vdev_args),
16253 : : "%s%d", temp_str, i);
16254 : : strcpy(temp_str, vdev_args);
16255 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
16256 : 0 : worker_core_count++;
16257 : 0 : socket_id = rte_lcore_to_socket_id(i);
16258 : : }
16259 [ # # ]: 0 : if (worker_core_count != 2) {
16260 : 0 : RTE_LOG(ERR, USER1,
16261 : : "Cryptodev scheduler test require at least "
16262 : : "two worker cores to run. "
16263 : : "Please use the correct coremask.\n");
16264 : 0 : return TEST_FAILED;
16265 : : }
16266 : : strcpy(temp_str, vdev_args);
16267 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
16268 : : temp_str, socket_id);
16269 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
16270 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
16271 : 0 : rte_cryptodev_driver_id_get(
16272 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
16273 [ # # ]: 0 : if (nb_devs < 1) {
16274 : 0 : ret = rte_vdev_init(
16275 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
16276 : : vdev_args);
16277 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16278 : : "Failed to create instance %u of pmd : %s",
16279 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16280 : : }
16281 : : }
16282 : 0 : return testsuite_setup();
16283 : : }
16284 : :
16285 : : static int
16286 : 0 : test_scheduler_attach_worker_op(void)
16287 : : {
16288 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16289 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16290 : : uint32_t i, nb_devs_attached = 0;
16291 : : int ret;
16292 : : char vdev_name[32];
16293 : 0 : unsigned int count = rte_cryptodev_count();
16294 : :
16295 : : /* create 2 AESNI_MB vdevs on top of existing devices */
16296 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
16297 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
16298 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
16299 : : i);
16300 : 0 : ret = rte_vdev_init(vdev_name, NULL);
16301 : :
16302 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16303 : : "Failed to create instance %u of"
16304 : : " pmd : %s",
16305 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16306 : :
16307 : : if (ret < 0) {
16308 : : RTE_LOG(ERR, USER1,
16309 : : "Failed to create 2 AESNI MB PMDs.\n");
16310 : : return TEST_SKIPPED;
16311 : : }
16312 : : }
16313 : :
16314 : : /* attach 2 AESNI_MB cdevs */
16315 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
16316 : : struct rte_cryptodev_info info;
16317 : : unsigned int session_size;
16318 : :
16319 : 0 : rte_cryptodev_info_get(i, &info);
16320 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
16321 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
16322 : 0 : continue;
16323 : :
16324 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
16325 : : /*
16326 : : * Create the session mempool again, since now there are new devices
16327 : : * to use the mempool.
16328 : : */
16329 [ # # ]: 0 : if (ts_params->session_mpool) {
16330 : 0 : rte_mempool_free(ts_params->session_mpool);
16331 : 0 : ts_params->session_mpool = NULL;
16332 : : }
16333 : :
16334 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
16335 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
16336 : 0 : RTE_LOG(ERR, USER1,
16337 : : "Device does not support "
16338 : : "at least %u sessions\n",
16339 : : MAX_NB_SESSIONS);
16340 : 0 : return TEST_FAILED;
16341 : : }
16342 : : /*
16343 : : * Create mempool with maximum number of sessions,
16344 : : * to include the session headers
16345 : : */
16346 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
16347 : 0 : ts_params->session_mpool =
16348 : 0 : rte_cryptodev_sym_session_pool_create(
16349 : : "test_sess_mp",
16350 : : MAX_NB_SESSIONS, session_size,
16351 : : 0, 0, SOCKET_ID_ANY);
16352 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
16353 : : "session mempool allocation failed");
16354 : : }
16355 : :
16356 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
16357 : :
16358 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
16359 : : (uint8_t)i);
16360 : :
16361 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16362 : : "Failed to attach device %u of pmd : %s", i,
16363 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16364 : :
16365 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
16366 : :
16367 : 0 : nb_devs_attached++;
16368 : : }
16369 : :
16370 : : return 0;
16371 : : }
16372 : :
16373 : : static int
16374 : 0 : test_scheduler_detach_worker_op(void)
16375 : : {
16376 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16377 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16378 : : uint32_t i;
16379 : : int ret;
16380 : :
16381 [ # # ]: 0 : for (i = 0; i < 2; i++) {
16382 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
16383 : 0 : aesni_ids[i]);
16384 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16385 : : "Failed to detach device %u", aesni_ids[i]);
16386 : : }
16387 : :
16388 : : return 0;
16389 : : }
16390 : :
16391 : : static int
16392 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
16393 : : {
16394 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16395 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16396 : : /* set mode */
16397 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
16398 : : scheduler_mode);
16399 : : }
16400 : :
16401 : : static int
16402 : 0 : test_scheduler_mode_roundrobin_op(void)
16403 : : {
16404 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
16405 : : 0, "Failed to set roundrobin mode");
16406 : : return 0;
16407 : :
16408 : : }
16409 : :
16410 : : static int
16411 : 0 : test_scheduler_mode_multicore_op(void)
16412 : : {
16413 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
16414 : : 0, "Failed to set multicore mode");
16415 : :
16416 : : return 0;
16417 : : }
16418 : :
16419 : : static int
16420 : 0 : test_scheduler_mode_failover_op(void)
16421 : : {
16422 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
16423 : : 0, "Failed to set failover mode");
16424 : :
16425 : : return 0;
16426 : : }
16427 : :
16428 : : static int
16429 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
16430 : : {
16431 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
16432 : : 0, "Failed to set pktsize mode");
16433 : :
16434 : : return 0;
16435 : : }
16436 : :
16437 : : static int
16438 : 0 : scheduler_multicore_testsuite_setup(void)
16439 : : {
16440 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16441 : : return TEST_SKIPPED;
16442 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
16443 : 0 : return TEST_SKIPPED;
16444 : : return 0;
16445 : : }
16446 : :
16447 : : static int
16448 : 0 : scheduler_roundrobin_testsuite_setup(void)
16449 : : {
16450 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16451 : : return TEST_SKIPPED;
16452 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
16453 : 0 : return TEST_SKIPPED;
16454 : : return 0;
16455 : : }
16456 : :
16457 : : static int
16458 : 0 : scheduler_failover_testsuite_setup(void)
16459 : : {
16460 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16461 : : return TEST_SKIPPED;
16462 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
16463 : 0 : return TEST_SKIPPED;
16464 : : return 0;
16465 : : }
16466 : :
16467 : : static int
16468 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
16469 : : {
16470 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16471 : : return TEST_SKIPPED;
16472 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
16473 : 0 : return TEST_SKIPPED;
16474 : : return 0;
16475 : : }
16476 : :
16477 : : static void
16478 : 0 : scheduler_mode_testsuite_teardown(void)
16479 : : {
16480 : 0 : test_scheduler_detach_worker_op();
16481 : 0 : }
16482 : :
16483 : : #endif /* RTE_CRYPTO_SCHEDULER */
16484 : :
16485 : : static struct unit_test_suite end_testsuite = {
16486 : : .suite_name = NULL,
16487 : : .setup = NULL,
16488 : : .teardown = NULL,
16489 : : .unit_test_suites = NULL
16490 : : };
16491 : :
16492 : : #ifdef RTE_LIB_SECURITY
16493 : : static struct unit_test_suite ipsec_proto_testsuite = {
16494 : : .suite_name = "IPsec Proto Unit Test Suite",
16495 : : .setup = ipsec_proto_testsuite_setup,
16496 : : .unit_test_cases = {
16497 : : TEST_CASE_NAMED_WITH_DATA(
16498 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16499 : : ut_setup_security, ut_teardown,
16500 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
16501 : : TEST_CASE_NAMED_WITH_DATA(
16502 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
16503 : : ut_setup_security, ut_teardown,
16504 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
16505 : : TEST_CASE_NAMED_WITH_DATA(
16506 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16507 : : ut_setup_security, ut_teardown,
16508 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
16509 : : TEST_CASE_NAMED_WITH_DATA(
16510 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16511 : : ut_setup_security, ut_teardown,
16512 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
16513 : : TEST_CASE_NAMED_WITH_DATA(
16514 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16515 : : ut_setup_security, ut_teardown,
16516 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
16517 : : TEST_CASE_NAMED_WITH_DATA(
16518 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16519 : : ut_setup_security, ut_teardown,
16520 : : test_ipsec_proto_known_vec,
16521 : : &pkt_aes_128_cbc_md5),
16522 : : TEST_CASE_NAMED_WITH_DATA(
16523 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16524 : : ut_setup_security, ut_teardown,
16525 : : test_ipsec_proto_known_vec,
16526 : : &pkt_aes_128_cbc_hmac_sha256),
16527 : : TEST_CASE_NAMED_WITH_DATA(
16528 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16529 : : ut_setup_security, ut_teardown,
16530 : : test_ipsec_proto_known_vec,
16531 : : &pkt_aes_128_cbc_hmac_sha384),
16532 : : TEST_CASE_NAMED_WITH_DATA(
16533 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16534 : : ut_setup_security, ut_teardown,
16535 : : test_ipsec_proto_known_vec,
16536 : : &pkt_aes_128_cbc_hmac_sha512),
16537 : : TEST_CASE_NAMED_WITH_DATA(
16538 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16539 : : ut_setup_security, ut_teardown,
16540 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
16541 : : TEST_CASE_NAMED_WITH_DATA(
16542 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16543 : : ut_setup_security, ut_teardown,
16544 : : test_ipsec_proto_known_vec,
16545 : : &pkt_aes_128_cbc_hmac_sha256_v6),
16546 : : TEST_CASE_NAMED_WITH_DATA(
16547 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16548 : : ut_setup_security, ut_teardown,
16549 : : test_ipsec_proto_known_vec,
16550 : : &pkt_null_aes_xcbc),
16551 : : TEST_CASE_NAMED_WITH_DATA(
16552 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16553 : : ut_setup_security, ut_teardown,
16554 : : test_ipsec_proto_known_vec,
16555 : : &pkt_des_cbc_hmac_sha256),
16556 : : TEST_CASE_NAMED_WITH_DATA(
16557 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16558 : : ut_setup_security, ut_teardown,
16559 : : test_ipsec_proto_known_vec,
16560 : : &pkt_des_cbc_hmac_sha384),
16561 : : TEST_CASE_NAMED_WITH_DATA(
16562 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16563 : : ut_setup_security, ut_teardown,
16564 : : test_ipsec_proto_known_vec,
16565 : : &pkt_des_cbc_hmac_sha512),
16566 : : TEST_CASE_NAMED_WITH_DATA(
16567 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16568 : : ut_setup_security, ut_teardown,
16569 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
16570 : : TEST_CASE_NAMED_WITH_DATA(
16571 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16572 : : ut_setup_security, ut_teardown,
16573 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
16574 : : TEST_CASE_NAMED_WITH_DATA(
16575 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16576 : : ut_setup_security, ut_teardown,
16577 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
16578 : : TEST_CASE_NAMED_WITH_DATA(
16579 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16580 : : ut_setup_security, ut_teardown,
16581 : : test_ipsec_proto_known_vec,
16582 : : &pkt_des_cbc_hmac_sha256_v6),
16583 : : TEST_CASE_NAMED_WITH_DATA(
16584 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16585 : : ut_setup_security, ut_teardown,
16586 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
16587 : : TEST_CASE_NAMED_WITH_DATA(
16588 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16589 : : ut_setup_security, ut_teardown,
16590 : : test_ipsec_proto_known_vec,
16591 : : &pkt_ah_tunnel_sha256),
16592 : : TEST_CASE_NAMED_WITH_DATA(
16593 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16594 : : ut_setup_security, ut_teardown,
16595 : : test_ipsec_proto_known_vec,
16596 : : &pkt_ah_transport_sha256),
16597 : : TEST_CASE_NAMED_WITH_DATA(
16598 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16599 : : ut_setup_security, ut_teardown,
16600 : : test_ipsec_proto_known_vec,
16601 : : &pkt_ah_ipv4_aes_gmac_128),
16602 : : TEST_CASE_NAMED_WITH_DATA(
16603 : : "Outbound fragmented packet",
16604 : : ut_setup_security, ut_teardown,
16605 : : test_ipsec_proto_known_vec_fragmented,
16606 : : &pkt_aes_128_gcm_frag),
16607 : : TEST_CASE_NAMED_WITH_DATA(
16608 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16609 : : ut_setup_security, ut_teardown,
16610 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
16611 : : TEST_CASE_NAMED_WITH_DATA(
16612 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16613 : : ut_setup_security, ut_teardown,
16614 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
16615 : : TEST_CASE_NAMED_WITH_DATA(
16616 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16617 : : ut_setup_security, ut_teardown,
16618 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
16619 : : TEST_CASE_NAMED_WITH_DATA(
16620 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16621 : : ut_setup_security, ut_teardown,
16622 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
16623 : : TEST_CASE_NAMED_WITH_DATA(
16624 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
16625 : : ut_setup_security, ut_teardown,
16626 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
16627 : : TEST_CASE_NAMED_WITH_DATA(
16628 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16629 : : ut_setup_security, ut_teardown,
16630 : : test_ipsec_proto_known_vec_inb,
16631 : : &pkt_aes_128_cbc_md5),
16632 : : TEST_CASE_NAMED_WITH_DATA(
16633 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16634 : : ut_setup_security, ut_teardown,
16635 : : test_ipsec_proto_known_vec_inb,
16636 : : &pkt_aes_128_cbc_hmac_sha256),
16637 : : TEST_CASE_NAMED_WITH_DATA(
16638 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16639 : : ut_setup_security, ut_teardown,
16640 : : test_ipsec_proto_known_vec_inb,
16641 : : &pkt_aes_128_cbc_hmac_sha384),
16642 : : TEST_CASE_NAMED_WITH_DATA(
16643 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16644 : : ut_setup_security, ut_teardown,
16645 : : test_ipsec_proto_known_vec_inb,
16646 : : &pkt_aes_128_cbc_hmac_sha512),
16647 : : TEST_CASE_NAMED_WITH_DATA(
16648 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16649 : : ut_setup_security, ut_teardown,
16650 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
16651 : : TEST_CASE_NAMED_WITH_DATA(
16652 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16653 : : ut_setup_security, ut_teardown,
16654 : : test_ipsec_proto_known_vec_inb,
16655 : : &pkt_aes_128_cbc_hmac_sha256_v6),
16656 : : TEST_CASE_NAMED_WITH_DATA(
16657 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16658 : : ut_setup_security, ut_teardown,
16659 : : test_ipsec_proto_known_vec_inb,
16660 : : &pkt_null_aes_xcbc),
16661 : : TEST_CASE_NAMED_WITH_DATA(
16662 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16663 : : ut_setup_security, ut_teardown,
16664 : : test_ipsec_proto_known_vec_inb,
16665 : : &pkt_des_cbc_hmac_sha256),
16666 : : TEST_CASE_NAMED_WITH_DATA(
16667 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16668 : : ut_setup_security, ut_teardown,
16669 : : test_ipsec_proto_known_vec_inb,
16670 : : &pkt_des_cbc_hmac_sha384),
16671 : : TEST_CASE_NAMED_WITH_DATA(
16672 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16673 : : ut_setup_security, ut_teardown,
16674 : : test_ipsec_proto_known_vec_inb,
16675 : : &pkt_des_cbc_hmac_sha512),
16676 : : TEST_CASE_NAMED_WITH_DATA(
16677 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16678 : : ut_setup_security, ut_teardown,
16679 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
16680 : : TEST_CASE_NAMED_WITH_DATA(
16681 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16682 : : ut_setup_security, ut_teardown,
16683 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
16684 : : TEST_CASE_NAMED_WITH_DATA(
16685 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16686 : : ut_setup_security, ut_teardown,
16687 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
16688 : : TEST_CASE_NAMED_WITH_DATA(
16689 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16690 : : ut_setup_security, ut_teardown,
16691 : : test_ipsec_proto_known_vec_inb,
16692 : : &pkt_des_cbc_hmac_sha256_v6),
16693 : : TEST_CASE_NAMED_WITH_DATA(
16694 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16695 : : ut_setup_security, ut_teardown,
16696 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
16697 : : TEST_CASE_NAMED_WITH_DATA(
16698 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16699 : : ut_setup_security, ut_teardown,
16700 : : test_ipsec_proto_known_vec_inb,
16701 : : &pkt_ah_tunnel_sha256),
16702 : : TEST_CASE_NAMED_WITH_DATA(
16703 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16704 : : ut_setup_security, ut_teardown,
16705 : : test_ipsec_proto_known_vec_inb,
16706 : : &pkt_ah_transport_sha256),
16707 : : TEST_CASE_NAMED_WITH_DATA(
16708 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16709 : : ut_setup_security, ut_teardown,
16710 : : test_ipsec_proto_known_vec_inb,
16711 : : &pkt_ah_ipv4_aes_gmac_128),
16712 : : TEST_CASE_NAMED_ST(
16713 : : "Combined test alg list",
16714 : : ut_setup_security, ut_teardown,
16715 : : test_ipsec_proto_display_list),
16716 : : TEST_CASE_NAMED_ST(
16717 : : "Combined test alg list (AH)",
16718 : : ut_setup_security, ut_teardown,
16719 : : test_ipsec_proto_ah_tunnel_ipv4),
16720 : : TEST_CASE_NAMED_ST(
16721 : : "IV generation",
16722 : : ut_setup_security, ut_teardown,
16723 : : test_ipsec_proto_iv_gen),
16724 : : TEST_CASE_NAMED_ST(
16725 : : "UDP encapsulation",
16726 : : ut_setup_security, ut_teardown,
16727 : : test_ipsec_proto_udp_encap),
16728 : : TEST_CASE_NAMED_ST(
16729 : : "UDP encapsulation with custom ports",
16730 : : ut_setup_security, ut_teardown,
16731 : : test_ipsec_proto_udp_encap_custom_ports),
16732 : : TEST_CASE_NAMED_ST(
16733 : : "UDP encapsulation ports verification test",
16734 : : ut_setup_security, ut_teardown,
16735 : : test_ipsec_proto_udp_ports_verify),
16736 : : TEST_CASE_NAMED_ST(
16737 : : "SA expiry packets soft",
16738 : : ut_setup_security, ut_teardown,
16739 : : test_ipsec_proto_sa_exp_pkts_soft),
16740 : : TEST_CASE_NAMED_ST(
16741 : : "SA expiry packets hard",
16742 : : ut_setup_security, ut_teardown,
16743 : : test_ipsec_proto_sa_exp_pkts_hard),
16744 : : TEST_CASE_NAMED_ST(
16745 : : "Negative test: ICV corruption",
16746 : : ut_setup_security, ut_teardown,
16747 : : test_ipsec_proto_err_icv_corrupt),
16748 : : TEST_CASE_NAMED_ST(
16749 : : "Tunnel dst addr verification",
16750 : : ut_setup_security, ut_teardown,
16751 : : test_ipsec_proto_tunnel_dst_addr_verify),
16752 : : TEST_CASE_NAMED_ST(
16753 : : "Tunnel src and dst addr verification",
16754 : : ut_setup_security, ut_teardown,
16755 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
16756 : : TEST_CASE_NAMED_ST(
16757 : : "Inner IP checksum",
16758 : : ut_setup_security, ut_teardown,
16759 : : test_ipsec_proto_inner_ip_csum),
16760 : : TEST_CASE_NAMED_ST(
16761 : : "Inner L4 checksum",
16762 : : ut_setup_security, ut_teardown,
16763 : : test_ipsec_proto_inner_l4_csum),
16764 : : TEST_CASE_NAMED_ST(
16765 : : "Tunnel IPv4 in IPv4",
16766 : : ut_setup_security, ut_teardown,
16767 : : test_ipsec_proto_tunnel_v4_in_v4),
16768 : : TEST_CASE_NAMED_ST(
16769 : : "Tunnel IPv6 in IPv6",
16770 : : ut_setup_security, ut_teardown,
16771 : : test_ipsec_proto_tunnel_v6_in_v6),
16772 : : TEST_CASE_NAMED_ST(
16773 : : "Tunnel IPv4 in IPv6",
16774 : : ut_setup_security, ut_teardown,
16775 : : test_ipsec_proto_tunnel_v4_in_v6),
16776 : : TEST_CASE_NAMED_ST(
16777 : : "Tunnel IPv6 in IPv4",
16778 : : ut_setup_security, ut_teardown,
16779 : : test_ipsec_proto_tunnel_v6_in_v4),
16780 : : TEST_CASE_NAMED_ST(
16781 : : "Transport IPv4",
16782 : : ut_setup_security, ut_teardown,
16783 : : test_ipsec_proto_transport_v4),
16784 : : TEST_CASE_NAMED_ST(
16785 : : "AH transport IPv4",
16786 : : ut_setup_security, ut_teardown,
16787 : : test_ipsec_proto_ah_transport_ipv4),
16788 : : TEST_CASE_NAMED_ST(
16789 : : "Transport l4 checksum",
16790 : : ut_setup_security, ut_teardown,
16791 : : test_ipsec_proto_transport_l4_csum),
16792 : : TEST_CASE_NAMED_ST(
16793 : : "Statistics: success",
16794 : : ut_setup_security, ut_teardown,
16795 : : test_ipsec_proto_stats),
16796 : : TEST_CASE_NAMED_ST(
16797 : : "Fragmented packet",
16798 : : ut_setup_security, ut_teardown,
16799 : : test_ipsec_proto_pkt_fragment),
16800 : : TEST_CASE_NAMED_ST(
16801 : : "Tunnel header copy DF (inner 0)",
16802 : : ut_setup_security, ut_teardown,
16803 : : test_ipsec_proto_copy_df_inner_0),
16804 : : TEST_CASE_NAMED_ST(
16805 : : "Tunnel header copy DF (inner 1)",
16806 : : ut_setup_security, ut_teardown,
16807 : : test_ipsec_proto_copy_df_inner_1),
16808 : : TEST_CASE_NAMED_ST(
16809 : : "Tunnel header set DF 0 (inner 1)",
16810 : : ut_setup_security, ut_teardown,
16811 : : test_ipsec_proto_set_df_0_inner_1),
16812 : : TEST_CASE_NAMED_ST(
16813 : : "Tunnel header set DF 1 (inner 0)",
16814 : : ut_setup_security, ut_teardown,
16815 : : test_ipsec_proto_set_df_1_inner_0),
16816 : : TEST_CASE_NAMED_ST(
16817 : : "Tunnel header IPv4 copy DSCP (inner 0)",
16818 : : ut_setup_security, ut_teardown,
16819 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
16820 : : TEST_CASE_NAMED_ST(
16821 : : "Tunnel header IPv4 copy DSCP (inner 1)",
16822 : : ut_setup_security, ut_teardown,
16823 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
16824 : : TEST_CASE_NAMED_ST(
16825 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
16826 : : ut_setup_security, ut_teardown,
16827 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
16828 : : TEST_CASE_NAMED_ST(
16829 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
16830 : : ut_setup_security, ut_teardown,
16831 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
16832 : : TEST_CASE_NAMED_ST(
16833 : : "Tunnel header IPv6 copy DSCP (inner 0)",
16834 : : ut_setup_security, ut_teardown,
16835 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
16836 : : TEST_CASE_NAMED_ST(
16837 : : "Tunnel header IPv6 copy DSCP (inner 1)",
16838 : : ut_setup_security, ut_teardown,
16839 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
16840 : : TEST_CASE_NAMED_ST(
16841 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
16842 : : ut_setup_security, ut_teardown,
16843 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
16844 : : TEST_CASE_NAMED_ST(
16845 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
16846 : : ut_setup_security, ut_teardown,
16847 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
16848 : : TEST_CASE_NAMED_WITH_DATA(
16849 : : "Antireplay with window size 1024",
16850 : : ut_setup_security, ut_teardown,
16851 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
16852 : : TEST_CASE_NAMED_WITH_DATA(
16853 : : "Antireplay with window size 2048",
16854 : : ut_setup_security, ut_teardown,
16855 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
16856 : : TEST_CASE_NAMED_WITH_DATA(
16857 : : "Antireplay with window size 4096",
16858 : : ut_setup_security, ut_teardown,
16859 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
16860 : : TEST_CASE_NAMED_WITH_DATA(
16861 : : "ESN and Antireplay with window size 1024",
16862 : : ut_setup_security, ut_teardown,
16863 : : test_ipsec_proto_pkt_esn_antireplay1024,
16864 : : &pkt_aes_128_gcm),
16865 : : TEST_CASE_NAMED_WITH_DATA(
16866 : : "ESN and Antireplay with window size 2048",
16867 : : ut_setup_security, ut_teardown,
16868 : : test_ipsec_proto_pkt_esn_antireplay2048,
16869 : : &pkt_aes_128_gcm),
16870 : : TEST_CASE_NAMED_WITH_DATA(
16871 : : "ESN and Antireplay with window size 4096",
16872 : : ut_setup_security, ut_teardown,
16873 : : test_ipsec_proto_pkt_esn_antireplay4096,
16874 : : &pkt_aes_128_gcm),
16875 : : TEST_CASE_NAMED_ST(
16876 : : "Tunnel header IPv4 decrement inner TTL",
16877 : : ut_setup_security, ut_teardown,
16878 : : test_ipsec_proto_ipv4_ttl_decrement),
16879 : : TEST_CASE_NAMED_ST(
16880 : : "Tunnel header IPv6 decrement inner hop limit",
16881 : : ut_setup_security, ut_teardown,
16882 : : test_ipsec_proto_ipv6_hop_limit_decrement),
16883 : : TEST_CASE_NAMED_ST(
16884 : : "Multi-segmented mode",
16885 : : ut_setup_security, ut_teardown,
16886 : : test_ipsec_proto_sgl),
16887 : : TEST_CASE_NAMED_ST(
16888 : : "Multi-segmented external mbuf mode",
16889 : : ut_setup_security, ut_teardown,
16890 : : test_ipsec_proto_sgl_ext_mbuf),
16891 : : TEST_CASE_NAMED_WITH_DATA(
16892 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
16893 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
16894 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
16895 : : TEST_CASES_END() /**< NULL terminate unit test array */
16896 : : }
16897 : : };
16898 : :
16899 : : static struct unit_test_suite pdcp_proto_testsuite = {
16900 : : .suite_name = "PDCP Proto Unit Test Suite",
16901 : : .setup = pdcp_proto_testsuite_setup,
16902 : : .unit_test_cases = {
16903 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
16904 : : test_PDCP_PROTO_all),
16905 : : TEST_CASES_END() /**< NULL terminate unit test array */
16906 : : }
16907 : : };
16908 : :
16909 : : static struct unit_test_suite tls12_record_proto_testsuite = {
16910 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
16911 : : .setup = tls_record_proto_testsuite_setup,
16912 : : .unit_test_cases = {
16913 : : TEST_CASE_NAMED_WITH_DATA(
16914 : : "Write record known vector AES-GCM-128 (vector 1)",
16915 : : ut_setup_security, ut_teardown,
16916 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
16917 : : TEST_CASE_NAMED_WITH_DATA(
16918 : : "Write record known vector AES-GCM-128 (vector 2)",
16919 : : ut_setup_security, ut_teardown,
16920 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
16921 : : TEST_CASE_NAMED_WITH_DATA(
16922 : : "Write record known vector AES-GCM-256",
16923 : : ut_setup_security, ut_teardown,
16924 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
16925 : : TEST_CASE_NAMED_WITH_DATA(
16926 : : "Write record known vector AES-CBC-128-SHA1",
16927 : : ut_setup_security, ut_teardown,
16928 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
16929 : : TEST_CASE_NAMED_WITH_DATA(
16930 : : "Write record known vector AES-128-CBC-SHA256",
16931 : : ut_setup_security, ut_teardown,
16932 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
16933 : : TEST_CASE_NAMED_WITH_DATA(
16934 : : "Write record known vector AES-256-CBC-SHA1",
16935 : : ut_setup_security, ut_teardown,
16936 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
16937 : : TEST_CASE_NAMED_WITH_DATA(
16938 : : "Write record known vector AES-256-CBC-SHA256",
16939 : : ut_setup_security, ut_teardown,
16940 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
16941 : : TEST_CASE_NAMED_WITH_DATA(
16942 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
16943 : : ut_setup_security, ut_teardown,
16944 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
16945 : : TEST_CASE_NAMED_WITH_DATA(
16946 : : "Write record known vector NULL-SHA1-HMAC",
16947 : : ut_setup_security, ut_teardown,
16948 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
16949 : : TEST_CASE_NAMED_WITH_DATA(
16950 : : "Write record known vector CHACHA20-POLY1305",
16951 : : ut_setup_security, ut_teardown,
16952 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
16953 : :
16954 : : TEST_CASE_NAMED_WITH_DATA(
16955 : : "Read record known vector AES-GCM-128 (vector 1)",
16956 : : ut_setup_security, ut_teardown,
16957 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
16958 : : TEST_CASE_NAMED_WITH_DATA(
16959 : : "Read record known vector AES-GCM-128 (vector 2)",
16960 : : ut_setup_security, ut_teardown,
16961 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
16962 : : TEST_CASE_NAMED_WITH_DATA(
16963 : : "Read record known vector AES-GCM-256",
16964 : : ut_setup_security, ut_teardown,
16965 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
16966 : : TEST_CASE_NAMED_WITH_DATA(
16967 : : "Read record known vector AES-128-CBC-SHA1",
16968 : : ut_setup_security, ut_teardown,
16969 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
16970 : : TEST_CASE_NAMED_WITH_DATA(
16971 : : "Read record known vector AES-128-CBC-SHA256",
16972 : : ut_setup_security, ut_teardown,
16973 : : test_tls_record_proto_known_vec_read,
16974 : : &tls_test_data_aes_128_cbc_sha256_hmac),
16975 : : TEST_CASE_NAMED_WITH_DATA(
16976 : : "Read record known vector AES-256-CBC-SHA1",
16977 : : ut_setup_security, ut_teardown,
16978 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
16979 : : TEST_CASE_NAMED_WITH_DATA(
16980 : : "Read record known vector AES-256-CBC-SHA256",
16981 : : ut_setup_security, ut_teardown,
16982 : : test_tls_record_proto_known_vec_read,
16983 : : &tls_test_data_aes_256_cbc_sha256_hmac),
16984 : : TEST_CASE_NAMED_WITH_DATA(
16985 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
16986 : : ut_setup_security, ut_teardown,
16987 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
16988 : : TEST_CASE_NAMED_WITH_DATA(
16989 : : "Read record known vector NULL-SHA1-HMAC",
16990 : : ut_setup_security, ut_teardown,
16991 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
16992 : : TEST_CASE_NAMED_WITH_DATA(
16993 : : "Read record known vector CHACHA20-POLY1305",
16994 : : ut_setup_security, ut_teardown,
16995 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
16996 : :
16997 : : TEST_CASE_NAMED_ST(
16998 : : "Combined test alg list",
16999 : : ut_setup_security, ut_teardown,
17000 : : test_tls_record_proto_display_list),
17001 : : TEST_CASE_NAMED_ST(
17002 : : "Multi-segmented mode",
17003 : : ut_setup_security, ut_teardown,
17004 : : test_tls_record_proto_sgl),
17005 : : TEST_CASES_END() /**< NULL terminate unit test array */
17006 : : }
17007 : : };
17008 : :
17009 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
17010 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
17011 : : .setup = tls_record_proto_testsuite_setup,
17012 : : .unit_test_cases = {
17013 : : TEST_CASE_NAMED_WITH_DATA(
17014 : : "Write record known vector AES-GCM-128",
17015 : : ut_setup_security, ut_teardown,
17016 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
17017 : : TEST_CASE_NAMED_WITH_DATA(
17018 : : "Write record known vector AES-GCM-256",
17019 : : ut_setup_security, ut_teardown,
17020 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
17021 : : TEST_CASE_NAMED_WITH_DATA(
17022 : : "Write record known vector AES-128-CBC-SHA1",
17023 : : ut_setup_security, ut_teardown,
17024 : : test_tls_record_proto_known_vec,
17025 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
17026 : : TEST_CASE_NAMED_WITH_DATA(
17027 : : "Write record known vector AES-128-CBC-SHA256",
17028 : : ut_setup_security, ut_teardown,
17029 : : test_tls_record_proto_known_vec,
17030 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
17031 : : TEST_CASE_NAMED_WITH_DATA(
17032 : : "Write record known vector AES-256-CBC-SHA1",
17033 : : ut_setup_security, ut_teardown,
17034 : : test_tls_record_proto_known_vec,
17035 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
17036 : : TEST_CASE_NAMED_WITH_DATA(
17037 : : "Write record known vector AES-256-CBC-SHA256",
17038 : : ut_setup_security, ut_teardown,
17039 : : test_tls_record_proto_known_vec,
17040 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
17041 : : TEST_CASE_NAMED_WITH_DATA(
17042 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
17043 : : ut_setup_security, ut_teardown,
17044 : : test_tls_record_proto_known_vec,
17045 : : &dtls_test_data_3des_cbc_sha1_hmac),
17046 : : TEST_CASE_NAMED_WITH_DATA(
17047 : : "Write record known vector NULL-SHA1-HMAC",
17048 : : ut_setup_security, ut_teardown,
17049 : : test_tls_record_proto_known_vec,
17050 : : &dtls_test_data_null_cipher_sha1_hmac),
17051 : : TEST_CASE_NAMED_WITH_DATA(
17052 : : "Write record known vector CHACHA20-POLY1305",
17053 : : ut_setup_security, ut_teardown,
17054 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
17055 : : TEST_CASE_NAMED_WITH_DATA(
17056 : : "Read record known vector AES-GCM-128",
17057 : : ut_setup_security, ut_teardown,
17058 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
17059 : : TEST_CASE_NAMED_WITH_DATA(
17060 : : "Read record known vector AES-GCM-256",
17061 : : ut_setup_security, ut_teardown,
17062 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
17063 : : TEST_CASE_NAMED_WITH_DATA(
17064 : : "Read record known vector AES-128-CBC-SHA1",
17065 : : ut_setup_security, ut_teardown,
17066 : : test_tls_record_proto_known_vec_read,
17067 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
17068 : : TEST_CASE_NAMED_WITH_DATA(
17069 : : "Read record known vector AES-128-CBC-SHA256",
17070 : : ut_setup_security, ut_teardown,
17071 : : test_tls_record_proto_known_vec_read,
17072 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
17073 : : TEST_CASE_NAMED_WITH_DATA(
17074 : : "Read record known vector AES-256-CBC-SHA1",
17075 : : ut_setup_security, ut_teardown,
17076 : : test_tls_record_proto_known_vec_read,
17077 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
17078 : : TEST_CASE_NAMED_WITH_DATA(
17079 : : "Read record known vector AES-256-CBC-SHA256",
17080 : : ut_setup_security, ut_teardown,
17081 : : test_tls_record_proto_known_vec_read,
17082 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
17083 : : TEST_CASE_NAMED_WITH_DATA(
17084 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
17085 : : ut_setup_security, ut_teardown,
17086 : : test_tls_record_proto_known_vec_read,
17087 : : &dtls_test_data_3des_cbc_sha1_hmac),
17088 : : TEST_CASE_NAMED_WITH_DATA(
17089 : : "Read record known vector NULL-SHA1-HMAC",
17090 : : ut_setup_security, ut_teardown,
17091 : : test_tls_record_proto_known_vec_read,
17092 : : &dtls_test_data_null_cipher_sha1_hmac),
17093 : : TEST_CASE_NAMED_WITH_DATA(
17094 : : "Read record known vector CHACHA20-POLY1305",
17095 : : ut_setup_security, ut_teardown,
17096 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
17097 : :
17098 : : TEST_CASE_NAMED_ST(
17099 : : "Combined test alg list",
17100 : : ut_setup_security, ut_teardown,
17101 : : test_tls_record_proto_display_list),
17102 : : TEST_CASE_NAMED_ST(
17103 : : "Multi-segmented mode",
17104 : : ut_setup_security, ut_teardown,
17105 : : test_tls_record_proto_sgl),
17106 : : TEST_CASES_END() /**< NULL terminate unit test array */
17107 : : }
17108 : : };
17109 : :
17110 : : #define ADD_UPLINK_TESTCASE(data) \
17111 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
17112 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
17113 : :
17114 : : #define ADD_DOWNLINK_TESTCASE(data) \
17115 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
17116 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
17117 : :
17118 : : static struct unit_test_suite docsis_proto_testsuite = {
17119 : : .suite_name = "DOCSIS Proto Unit Test Suite",
17120 : : .setup = docsis_proto_testsuite_setup,
17121 : : .unit_test_cases = {
17122 : : /* Uplink */
17123 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
17124 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
17125 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
17126 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
17127 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
17128 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
17129 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
17130 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
17131 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
17132 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
17133 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
17134 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
17135 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
17136 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
17137 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
17138 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
17139 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
17140 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
17141 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
17142 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
17143 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
17144 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
17145 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
17146 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
17147 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
17148 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
17149 : : /* Downlink */
17150 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
17151 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
17152 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
17153 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
17154 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
17155 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
17156 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
17157 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
17158 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
17159 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
17160 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
17161 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
17162 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
17163 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
17164 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
17165 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
17166 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
17167 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
17168 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
17169 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
17170 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
17171 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
17172 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
17173 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
17174 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
17175 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
17176 : : TEST_CASES_END() /**< NULL terminate unit test array */
17177 : : }
17178 : : };
17179 : : #endif
17180 : :
17181 : : static struct unit_test_suite cryptodev_gen_testsuite = {
17182 : : .suite_name = "Crypto General Unit Test Suite",
17183 : : .setup = crypto_gen_testsuite_setup,
17184 : : .unit_test_cases = {
17185 : : TEST_CASE_ST(ut_setup, ut_teardown,
17186 : : test_device_reconfigure),
17187 : : TEST_CASE_ST(ut_setup, ut_teardown,
17188 : : test_device_configure_invalid_dev_id),
17189 : : TEST_CASE_ST(ut_setup, ut_teardown,
17190 : : test_queue_pair_descriptor_setup),
17191 : : TEST_CASE_ST(ut_setup, ut_teardown,
17192 : : test_device_configure_invalid_queue_pair_ids),
17193 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
17194 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
17195 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
17196 : : TEST_CASES_END() /**< NULL terminate unit test array */
17197 : : }
17198 : : };
17199 : :
17200 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
17201 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
17202 : : .setup = negative_hmac_sha1_testsuite_setup,
17203 : : .unit_test_cases = {
17204 : : /** Negative tests */
17205 : : TEST_CASE_ST(ut_setup, ut_teardown,
17206 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
17207 : : TEST_CASE_ST(ut_setup, ut_teardown,
17208 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
17209 : : TEST_CASE_ST(ut_setup, ut_teardown,
17210 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
17211 : : TEST_CASE_ST(ut_setup, ut_teardown,
17212 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
17213 : :
17214 : : TEST_CASES_END() /**< NULL terminate unit test array */
17215 : : }
17216 : : };
17217 : :
17218 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
17219 : : .suite_name = "Multi Session Unit Test Suite",
17220 : : .setup = multi_session_testsuite_setup,
17221 : : .unit_test_cases = {
17222 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
17223 : : TEST_CASE_ST(ut_setup, ut_teardown,
17224 : : test_multi_session_random_usage),
17225 : :
17226 : : TEST_CASES_END() /**< NULL terminate unit test array */
17227 : : }
17228 : : };
17229 : :
17230 : : static struct unit_test_suite cryptodev_null_testsuite = {
17231 : : .suite_name = "NULL Test Suite",
17232 : : .setup = null_testsuite_setup,
17233 : : .unit_test_cases = {
17234 : : TEST_CASE_ST(ut_setup, ut_teardown,
17235 : : test_null_invalid_operation),
17236 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
17237 : : TEST_CASES_END()
17238 : : }
17239 : : };
17240 : :
17241 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
17242 : : .suite_name = "AES CCM Authenticated Test Suite",
17243 : : .setup = aes_ccm_auth_testsuite_setup,
17244 : : .unit_test_cases = {
17245 : : /** AES CCM Authenticated Encryption 128 bits key*/
17246 : : TEST_CASE_ST(ut_setup, ut_teardown,
17247 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
17248 : : TEST_CASE_ST(ut_setup, ut_teardown,
17249 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
17250 : : TEST_CASE_ST(ut_setup, ut_teardown,
17251 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
17252 : :
17253 : : /** AES CCM Authenticated Decryption 128 bits key*/
17254 : : TEST_CASE_ST(ut_setup, ut_teardown,
17255 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
17256 : : TEST_CASE_ST(ut_setup, ut_teardown,
17257 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
17258 : : TEST_CASE_ST(ut_setup, ut_teardown,
17259 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
17260 : :
17261 : : /** AES CCM Authenticated Encryption 192 bits key */
17262 : : TEST_CASE_ST(ut_setup, ut_teardown,
17263 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
17264 : : TEST_CASE_ST(ut_setup, ut_teardown,
17265 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
17266 : : TEST_CASE_ST(ut_setup, ut_teardown,
17267 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
17268 : :
17269 : : /** AES CCM Authenticated Decryption 192 bits key*/
17270 : : TEST_CASE_ST(ut_setup, ut_teardown,
17271 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
17272 : : TEST_CASE_ST(ut_setup, ut_teardown,
17273 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
17274 : : TEST_CASE_ST(ut_setup, ut_teardown,
17275 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
17276 : :
17277 : : /** AES CCM Authenticated Encryption 256 bits key */
17278 : : TEST_CASE_ST(ut_setup, ut_teardown,
17279 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
17280 : : TEST_CASE_ST(ut_setup, ut_teardown,
17281 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
17282 : : TEST_CASE_ST(ut_setup, ut_teardown,
17283 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
17284 : :
17285 : : /** AES CCM Authenticated Decryption 256 bits key*/
17286 : : TEST_CASE_ST(ut_setup, ut_teardown,
17287 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
17288 : : TEST_CASE_ST(ut_setup, ut_teardown,
17289 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
17290 : : TEST_CASE_ST(ut_setup, ut_teardown,
17291 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
17292 : : TEST_CASES_END()
17293 : : }
17294 : : };
17295 : :
17296 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
17297 : : .suite_name = "AES GCM Authenticated Test Suite",
17298 : : .setup = aes_gcm_auth_testsuite_setup,
17299 : : .unit_test_cases = {
17300 : : /** AES GCM Authenticated Encryption */
17301 : : TEST_CASE_ST(ut_setup, ut_teardown,
17302 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
17303 : : TEST_CASE_ST(ut_setup, ut_teardown,
17304 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
17305 : : TEST_CASE_ST(ut_setup, ut_teardown,
17306 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
17307 : : TEST_CASE_ST(ut_setup, ut_teardown,
17308 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
17309 : : TEST_CASE_ST(ut_setup, ut_teardown,
17310 : : test_AES_GCM_authenticated_encryption_test_case_1),
17311 : : TEST_CASE_ST(ut_setup, ut_teardown,
17312 : : test_AES_GCM_authenticated_encryption_test_case_2),
17313 : : TEST_CASE_ST(ut_setup, ut_teardown,
17314 : : test_AES_GCM_authenticated_encryption_test_case_3),
17315 : : TEST_CASE_ST(ut_setup, ut_teardown,
17316 : : test_AES_GCM_authenticated_encryption_test_case_4),
17317 : : TEST_CASE_ST(ut_setup, ut_teardown,
17318 : : test_AES_GCM_authenticated_encryption_test_case_5),
17319 : : TEST_CASE_ST(ut_setup, ut_teardown,
17320 : : test_AES_GCM_authenticated_encryption_test_case_6),
17321 : : TEST_CASE_ST(ut_setup, ut_teardown,
17322 : : test_AES_GCM_authenticated_encryption_test_case_7),
17323 : : TEST_CASE_ST(ut_setup, ut_teardown,
17324 : : test_AES_GCM_authenticated_encryption_test_case_8),
17325 : : TEST_CASE_ST(ut_setup, ut_teardown,
17326 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
17327 : :
17328 : : /** AES GCM Authenticated Decryption */
17329 : : TEST_CASE_ST(ut_setup, ut_teardown,
17330 : : test_AES_GCM_authenticated_decryption_test_case_1),
17331 : : TEST_CASE_ST(ut_setup, ut_teardown,
17332 : : test_AES_GCM_authenticated_decryption_test_case_2),
17333 : : TEST_CASE_ST(ut_setup, ut_teardown,
17334 : : test_AES_GCM_authenticated_decryption_test_case_3),
17335 : : TEST_CASE_ST(ut_setup, ut_teardown,
17336 : : test_AES_GCM_authenticated_decryption_test_case_4),
17337 : : TEST_CASE_ST(ut_setup, ut_teardown,
17338 : : test_AES_GCM_authenticated_decryption_test_case_5),
17339 : : TEST_CASE_ST(ut_setup, ut_teardown,
17340 : : test_AES_GCM_authenticated_decryption_test_case_6),
17341 : : TEST_CASE_ST(ut_setup, ut_teardown,
17342 : : test_AES_GCM_authenticated_decryption_test_case_7),
17343 : : TEST_CASE_ST(ut_setup, ut_teardown,
17344 : : test_AES_GCM_authenticated_decryption_test_case_8),
17345 : : TEST_CASE_ST(ut_setup, ut_teardown,
17346 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
17347 : :
17348 : : /** AES GCM Authenticated Encryption 192 bits key */
17349 : : TEST_CASE_ST(ut_setup, ut_teardown,
17350 : : test_AES_GCM_auth_encryption_test_case_192_1),
17351 : : TEST_CASE_ST(ut_setup, ut_teardown,
17352 : : test_AES_GCM_auth_encryption_test_case_192_2),
17353 : : TEST_CASE_ST(ut_setup, ut_teardown,
17354 : : test_AES_GCM_auth_encryption_test_case_192_3),
17355 : : TEST_CASE_ST(ut_setup, ut_teardown,
17356 : : test_AES_GCM_auth_encryption_test_case_192_4),
17357 : : TEST_CASE_ST(ut_setup, ut_teardown,
17358 : : test_AES_GCM_auth_encryption_test_case_192_5),
17359 : : TEST_CASE_ST(ut_setup, ut_teardown,
17360 : : test_AES_GCM_auth_encryption_test_case_192_6),
17361 : : TEST_CASE_ST(ut_setup, ut_teardown,
17362 : : test_AES_GCM_auth_encryption_test_case_192_7),
17363 : :
17364 : : /** AES GCM Authenticated Decryption 192 bits key */
17365 : : TEST_CASE_ST(ut_setup, ut_teardown,
17366 : : test_AES_GCM_auth_decryption_test_case_192_1),
17367 : : TEST_CASE_ST(ut_setup, ut_teardown,
17368 : : test_AES_GCM_auth_decryption_test_case_192_2),
17369 : : TEST_CASE_ST(ut_setup, ut_teardown,
17370 : : test_AES_GCM_auth_decryption_test_case_192_3),
17371 : : TEST_CASE_ST(ut_setup, ut_teardown,
17372 : : test_AES_GCM_auth_decryption_test_case_192_4),
17373 : : TEST_CASE_ST(ut_setup, ut_teardown,
17374 : : test_AES_GCM_auth_decryption_test_case_192_5),
17375 : : TEST_CASE_ST(ut_setup, ut_teardown,
17376 : : test_AES_GCM_auth_decryption_test_case_192_6),
17377 : : TEST_CASE_ST(ut_setup, ut_teardown,
17378 : : test_AES_GCM_auth_decryption_test_case_192_7),
17379 : :
17380 : : /** AES GCM Authenticated Encryption 256 bits key */
17381 : : TEST_CASE_ST(ut_setup, ut_teardown,
17382 : : test_AES_GCM_auth_encryption_test_case_256_1),
17383 : : TEST_CASE_ST(ut_setup, ut_teardown,
17384 : : test_AES_GCM_auth_encryption_test_case_256_2),
17385 : : TEST_CASE_ST(ut_setup, ut_teardown,
17386 : : test_AES_GCM_auth_encryption_test_case_256_3),
17387 : : TEST_CASE_ST(ut_setup, ut_teardown,
17388 : : test_AES_GCM_auth_encryption_test_case_256_4),
17389 : : TEST_CASE_ST(ut_setup, ut_teardown,
17390 : : test_AES_GCM_auth_encryption_test_case_256_5),
17391 : : TEST_CASE_ST(ut_setup, ut_teardown,
17392 : : test_AES_GCM_auth_encryption_test_case_256_6),
17393 : : TEST_CASE_ST(ut_setup, ut_teardown,
17394 : : test_AES_GCM_auth_encryption_test_case_256_7),
17395 : :
17396 : : /** AES GCM Authenticated Decryption 256 bits key */
17397 : : TEST_CASE_ST(ut_setup, ut_teardown,
17398 : : test_AES_GCM_auth_decryption_test_case_256_1),
17399 : : TEST_CASE_ST(ut_setup, ut_teardown,
17400 : : test_AES_GCM_auth_decryption_test_case_256_2),
17401 : : TEST_CASE_ST(ut_setup, ut_teardown,
17402 : : test_AES_GCM_auth_decryption_test_case_256_3),
17403 : : TEST_CASE_ST(ut_setup, ut_teardown,
17404 : : test_AES_GCM_auth_decryption_test_case_256_4),
17405 : : TEST_CASE_ST(ut_setup, ut_teardown,
17406 : : test_AES_GCM_auth_decryption_test_case_256_5),
17407 : : TEST_CASE_ST(ut_setup, ut_teardown,
17408 : : test_AES_GCM_auth_decryption_test_case_256_6),
17409 : : TEST_CASE_ST(ut_setup, ut_teardown,
17410 : : test_AES_GCM_auth_decryption_test_case_256_7),
17411 : :
17412 : : /** AES GCM Authenticated Encryption big aad size */
17413 : : TEST_CASE_ST(ut_setup, ut_teardown,
17414 : : test_AES_GCM_auth_encryption_test_case_aad_1),
17415 : : TEST_CASE_ST(ut_setup, ut_teardown,
17416 : : test_AES_GCM_auth_encryption_test_case_aad_2),
17417 : :
17418 : : /** AES GCM Authenticated Decryption big aad size */
17419 : : TEST_CASE_ST(ut_setup, ut_teardown,
17420 : : test_AES_GCM_auth_decryption_test_case_aad_1),
17421 : : TEST_CASE_ST(ut_setup, ut_teardown,
17422 : : test_AES_GCM_auth_decryption_test_case_aad_2),
17423 : :
17424 : : /** Out of place tests */
17425 : : TEST_CASE_ST(ut_setup, ut_teardown,
17426 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
17427 : : TEST_CASE_ST(ut_setup, ut_teardown,
17428 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
17429 : :
17430 : : /** Session-less tests */
17431 : : TEST_CASE_ST(ut_setup, ut_teardown,
17432 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
17433 : : TEST_CASE_ST(ut_setup, ut_teardown,
17434 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
17435 : :
17436 : : TEST_CASES_END()
17437 : : }
17438 : : };
17439 : :
17440 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
17441 : : .suite_name = "AES GMAC Authentication Test Suite",
17442 : : .setup = aes_gmac_auth_testsuite_setup,
17443 : : .unit_test_cases = {
17444 : : TEST_CASE_ST(ut_setup, ut_teardown,
17445 : : test_AES_GMAC_authentication_test_case_1),
17446 : : TEST_CASE_ST(ut_setup, ut_teardown,
17447 : : test_AES_GMAC_authentication_verify_test_case_1),
17448 : : TEST_CASE_ST(ut_setup, ut_teardown,
17449 : : test_AES_GMAC_authentication_test_case_2),
17450 : : TEST_CASE_ST(ut_setup, ut_teardown,
17451 : : test_AES_GMAC_authentication_verify_test_case_2),
17452 : : TEST_CASE_ST(ut_setup, ut_teardown,
17453 : : test_AES_GMAC_authentication_test_case_3),
17454 : : TEST_CASE_ST(ut_setup, ut_teardown,
17455 : : test_AES_GMAC_authentication_verify_test_case_3),
17456 : : TEST_CASE_ST(ut_setup, ut_teardown,
17457 : : test_AES_GMAC_authentication_test_case_4),
17458 : : TEST_CASE_ST(ut_setup, ut_teardown,
17459 : : test_AES_GMAC_authentication_verify_test_case_4),
17460 : : TEST_CASE_ST(ut_setup, ut_teardown,
17461 : : test_AES_GMAC_authentication_SGL_40B),
17462 : : TEST_CASE_ST(ut_setup, ut_teardown,
17463 : : test_AES_GMAC_authentication_SGL_80B),
17464 : : TEST_CASE_ST(ut_setup, ut_teardown,
17465 : : test_AES_GMAC_authentication_SGL_2048B),
17466 : : TEST_CASE_ST(ut_setup, ut_teardown,
17467 : : test_AES_GMAC_authentication_SGL_2047B),
17468 : :
17469 : : TEST_CASES_END()
17470 : : }
17471 : : };
17472 : :
17473 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
17474 : : .suite_name = "Chacha20-Poly1305 Test Suite",
17475 : : .setup = chacha20_poly1305_testsuite_setup,
17476 : : .unit_test_cases = {
17477 : : TEST_CASE_ST(ut_setup, ut_teardown,
17478 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
17479 : : TEST_CASE_ST(ut_setup, ut_teardown,
17480 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
17481 : : TEST_CASE_ST(ut_setup, ut_teardown,
17482 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
17483 : : TEST_CASES_END()
17484 : : }
17485 : : };
17486 : :
17487 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
17488 : : .suite_name = "SNOW 3G Test Suite",
17489 : : .setup = snow3g_testsuite_setup,
17490 : : .unit_test_cases = {
17491 : : /** SNOW 3G encrypt only (UEA2) */
17492 : : TEST_CASE_ST(ut_setup, ut_teardown,
17493 : : test_snow3g_encryption_test_case_1),
17494 : : TEST_CASE_ST(ut_setup, ut_teardown,
17495 : : test_snow3g_encryption_test_case_2),
17496 : : TEST_CASE_ST(ut_setup, ut_teardown,
17497 : : test_snow3g_encryption_test_case_3),
17498 : : TEST_CASE_ST(ut_setup, ut_teardown,
17499 : : test_snow3g_encryption_test_case_4),
17500 : : TEST_CASE_ST(ut_setup, ut_teardown,
17501 : : test_snow3g_encryption_test_case_5),
17502 : :
17503 : : TEST_CASE_ST(ut_setup, ut_teardown,
17504 : : test_snow3g_encryption_test_case_1_oop),
17505 : : TEST_CASE_ST(ut_setup, ut_teardown,
17506 : : test_snow3g_encryption_test_case_1_oop_sgl),
17507 : : TEST_CASE_ST(ut_setup, ut_teardown,
17508 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
17509 : : TEST_CASE_ST(ut_setup, ut_teardown,
17510 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
17511 : : TEST_CASE_ST(ut_setup, ut_teardown,
17512 : : test_snow3g_encryption_test_case_1_offset_oop),
17513 : : TEST_CASE_ST(ut_setup, ut_teardown,
17514 : : test_snow3g_decryption_test_case_1_oop),
17515 : :
17516 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
17517 : : TEST_CASE_ST(ut_setup, ut_teardown,
17518 : : test_snow3g_auth_cipher_test_case_1),
17519 : : TEST_CASE_ST(ut_setup, ut_teardown,
17520 : : test_snow3g_auth_cipher_test_case_2),
17521 : : TEST_CASE_ST(ut_setup, ut_teardown,
17522 : : test_snow3g_auth_cipher_test_case_2_oop),
17523 : : TEST_CASE_ST(ut_setup, ut_teardown,
17524 : : test_snow3g_auth_cipher_part_digest_enc),
17525 : : TEST_CASE_ST(ut_setup, ut_teardown,
17526 : : test_snow3g_auth_cipher_part_digest_enc_oop),
17527 : : TEST_CASE_ST(ut_setup, ut_teardown,
17528 : : test_snow3g_auth_cipher_test_case_3_sgl),
17529 : : TEST_CASE_ST(ut_setup, ut_teardown,
17530 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
17531 : : TEST_CASE_ST(ut_setup, ut_teardown,
17532 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
17533 : : TEST_CASE_ST(ut_setup, ut_teardown,
17534 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
17535 : : TEST_CASE_ST(ut_setup, ut_teardown,
17536 : : test_snow3g_auth_cipher_total_digest_enc_1),
17537 : : TEST_CASE_ST(ut_setup, ut_teardown,
17538 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
17539 : : TEST_CASE_ST(ut_setup, ut_teardown,
17540 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
17541 : : TEST_CASE_ST(ut_setup, ut_teardown,
17542 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
17543 : :
17544 : : /** SNOW 3G decrypt (UEA2), then verify auth */
17545 : : TEST_CASE_ST(ut_setup, ut_teardown,
17546 : : test_snow3g_auth_cipher_verify_test_case_1),
17547 : : TEST_CASE_ST(ut_setup, ut_teardown,
17548 : : test_snow3g_auth_cipher_verify_test_case_2),
17549 : : TEST_CASE_ST(ut_setup, ut_teardown,
17550 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
17551 : : TEST_CASE_ST(ut_setup, ut_teardown,
17552 : : test_snow3g_auth_cipher_verify_part_digest_enc),
17553 : : TEST_CASE_ST(ut_setup, ut_teardown,
17554 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
17555 : : TEST_CASE_ST(ut_setup, ut_teardown,
17556 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
17557 : : TEST_CASE_ST(ut_setup, ut_teardown,
17558 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
17559 : : TEST_CASE_ST(ut_setup, ut_teardown,
17560 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
17561 : : TEST_CASE_ST(ut_setup, ut_teardown,
17562 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
17563 : : TEST_CASE_ST(ut_setup, ut_teardown,
17564 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
17565 : : TEST_CASE_ST(ut_setup, ut_teardown,
17566 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
17567 : : TEST_CASE_ST(ut_setup, ut_teardown,
17568 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
17569 : : TEST_CASE_ST(ut_setup, ut_teardown,
17570 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
17571 : :
17572 : : /** SNOW 3G decrypt only (UEA2) */
17573 : : TEST_CASE_ST(ut_setup, ut_teardown,
17574 : : test_snow3g_decryption_test_case_1),
17575 : : TEST_CASE_ST(ut_setup, ut_teardown,
17576 : : test_snow3g_decryption_test_case_2),
17577 : : TEST_CASE_ST(ut_setup, ut_teardown,
17578 : : test_snow3g_decryption_test_case_3),
17579 : : TEST_CASE_ST(ut_setup, ut_teardown,
17580 : : test_snow3g_decryption_test_case_4),
17581 : : TEST_CASE_ST(ut_setup, ut_teardown,
17582 : : test_snow3g_decryption_test_case_5),
17583 : : TEST_CASE_ST(ut_setup, ut_teardown,
17584 : : test_snow3g_decryption_with_digest_test_case_1),
17585 : : TEST_CASE_ST(ut_setup, ut_teardown,
17586 : : test_snow3g_hash_generate_test_case_1),
17587 : : TEST_CASE_ST(ut_setup, ut_teardown,
17588 : : test_snow3g_hash_generate_test_case_2),
17589 : : TEST_CASE_ST(ut_setup, ut_teardown,
17590 : : test_snow3g_hash_generate_test_case_3),
17591 : :
17592 : : /* Tests with buffers which length is not byte-aligned */
17593 : : TEST_CASE_ST(ut_setup, ut_teardown,
17594 : : test_snow3g_hash_generate_test_case_4),
17595 : : TEST_CASE_ST(ut_setup, ut_teardown,
17596 : : test_snow3g_hash_generate_test_case_5),
17597 : : TEST_CASE_ST(ut_setup, ut_teardown,
17598 : : test_snow3g_hash_generate_test_case_6),
17599 : : TEST_CASE_ST(ut_setup, ut_teardown,
17600 : : test_snow3g_hash_verify_test_case_1),
17601 : : TEST_CASE_ST(ut_setup, ut_teardown,
17602 : : test_snow3g_hash_verify_test_case_2),
17603 : : TEST_CASE_ST(ut_setup, ut_teardown,
17604 : : test_snow3g_hash_verify_test_case_3),
17605 : :
17606 : : /* Tests with buffers which length is not byte-aligned */
17607 : : TEST_CASE_ST(ut_setup, ut_teardown,
17608 : : test_snow3g_hash_verify_test_case_4),
17609 : : TEST_CASE_ST(ut_setup, ut_teardown,
17610 : : test_snow3g_hash_verify_test_case_5),
17611 : : TEST_CASE_ST(ut_setup, ut_teardown,
17612 : : test_snow3g_hash_verify_test_case_6),
17613 : : TEST_CASE_ST(ut_setup, ut_teardown,
17614 : : test_snow3g_cipher_auth_test_case_1),
17615 : : TEST_CASE_ST(ut_setup, ut_teardown,
17616 : : test_snow3g_auth_cipher_with_digest_test_case_1),
17617 : : TEST_CASES_END()
17618 : : }
17619 : : };
17620 : :
17621 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
17622 : : .suite_name = "ZUC Test Suite",
17623 : : .setup = zuc_testsuite_setup,
17624 : : .unit_test_cases = {
17625 : : /** ZUC encrypt only (EEA3) */
17626 : : TEST_CASE_ST(ut_setup, ut_teardown,
17627 : : test_zuc_encryption_test_case_1),
17628 : : TEST_CASE_ST(ut_setup, ut_teardown,
17629 : : test_zuc_encryption_test_case_2),
17630 : : TEST_CASE_ST(ut_setup, ut_teardown,
17631 : : test_zuc_encryption_test_case_3),
17632 : : TEST_CASE_ST(ut_setup, ut_teardown,
17633 : : test_zuc_encryption_test_case_4),
17634 : : TEST_CASE_ST(ut_setup, ut_teardown,
17635 : : test_zuc_encryption_test_case_5),
17636 : : TEST_CASE_ST(ut_setup, ut_teardown,
17637 : : test_zuc_encryption_test_case_6_sgl),
17638 : :
17639 : : /** ZUC decrypt only (EEA3) */
17640 : : TEST_CASE_ST(ut_setup, ut_teardown,
17641 : : test_zuc_decryption_test_case_1),
17642 : : TEST_CASE_ST(ut_setup, ut_teardown,
17643 : : test_zuc_decryption_test_case_2),
17644 : : TEST_CASE_ST(ut_setup, ut_teardown,
17645 : : test_zuc_decryption_test_case_3),
17646 : : TEST_CASE_ST(ut_setup, ut_teardown,
17647 : : test_zuc_decryption_test_case_4),
17648 : : TEST_CASE_ST(ut_setup, ut_teardown,
17649 : : test_zuc_decryption_test_case_5),
17650 : : TEST_CASE_ST(ut_setup, ut_teardown,
17651 : : test_zuc_decryption_test_case_6_sgl),
17652 : :
17653 : : /** ZUC authenticate (EIA3) */
17654 : : TEST_CASE_ST(ut_setup, ut_teardown,
17655 : : test_zuc_hash_generate_test_case_1),
17656 : : TEST_CASE_ST(ut_setup, ut_teardown,
17657 : : test_zuc_hash_generate_test_case_2),
17658 : : TEST_CASE_ST(ut_setup, ut_teardown,
17659 : : test_zuc_hash_generate_test_case_3),
17660 : : TEST_CASE_ST(ut_setup, ut_teardown,
17661 : : test_zuc_hash_generate_test_case_4),
17662 : : TEST_CASE_ST(ut_setup, ut_teardown,
17663 : : test_zuc_hash_generate_test_case_5),
17664 : : TEST_CASE_ST(ut_setup, ut_teardown,
17665 : : test_zuc_hash_generate_test_case_6),
17666 : : TEST_CASE_ST(ut_setup, ut_teardown,
17667 : : test_zuc_hash_generate_test_case_7),
17668 : : TEST_CASE_ST(ut_setup, ut_teardown,
17669 : : test_zuc_hash_generate_test_case_8),
17670 : :
17671 : : /** ZUC verify (EIA3) */
17672 : : TEST_CASE_ST(ut_setup, ut_teardown,
17673 : : test_zuc_hash_verify_test_case_1),
17674 : : TEST_CASE_ST(ut_setup, ut_teardown,
17675 : : test_zuc_hash_verify_test_case_2),
17676 : : TEST_CASE_ST(ut_setup, ut_teardown,
17677 : : test_zuc_hash_verify_test_case_3),
17678 : : TEST_CASE_ST(ut_setup, ut_teardown,
17679 : : test_zuc_hash_verify_test_case_4),
17680 : : TEST_CASE_ST(ut_setup, ut_teardown,
17681 : : test_zuc_hash_verify_test_case_5),
17682 : : TEST_CASE_ST(ut_setup, ut_teardown,
17683 : : test_zuc_hash_verify_test_case_6),
17684 : : TEST_CASE_ST(ut_setup, ut_teardown,
17685 : : test_zuc_hash_verify_test_case_7),
17686 : : TEST_CASE_ST(ut_setup, ut_teardown,
17687 : : test_zuc_hash_verify_test_case_8),
17688 : :
17689 : : /** ZUC alg-chain (EEA3/EIA3) */
17690 : : TEST_CASE_ST(ut_setup, ut_teardown,
17691 : : test_zuc_cipher_auth_test_case_1),
17692 : : TEST_CASE_ST(ut_setup, ut_teardown,
17693 : : test_zuc_cipher_auth_test_case_2),
17694 : :
17695 : : /** ZUC generate auth, then encrypt (EEA3) */
17696 : : TEST_CASE_ST(ut_setup, ut_teardown,
17697 : : test_zuc_auth_cipher_test_case_1),
17698 : : TEST_CASE_ST(ut_setup, ut_teardown,
17699 : : test_zuc_auth_cipher_test_case_1_oop),
17700 : : TEST_CASE_ST(ut_setup, ut_teardown,
17701 : : test_zuc_auth_cipher_test_case_1_sgl),
17702 : : TEST_CASE_ST(ut_setup, ut_teardown,
17703 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
17704 : : TEST_CASE_ST(ut_setup, ut_teardown,
17705 : : test_zuc_auth_cipher_test_case_2),
17706 : : TEST_CASE_ST(ut_setup, ut_teardown,
17707 : : test_zuc_auth_cipher_test_case_2_oop),
17708 : :
17709 : : /** ZUC decrypt (EEA3), then verify auth */
17710 : : TEST_CASE_ST(ut_setup, ut_teardown,
17711 : : test_zuc_auth_cipher_verify_test_case_1),
17712 : : TEST_CASE_ST(ut_setup, ut_teardown,
17713 : : test_zuc_auth_cipher_verify_test_case_1_oop),
17714 : : TEST_CASE_ST(ut_setup, ut_teardown,
17715 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
17716 : : TEST_CASE_ST(ut_setup, ut_teardown,
17717 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
17718 : : TEST_CASE_ST(ut_setup, ut_teardown,
17719 : : test_zuc_auth_cipher_verify_test_case_2),
17720 : : TEST_CASE_ST(ut_setup, ut_teardown,
17721 : : test_zuc_auth_cipher_verify_test_case_2_oop),
17722 : :
17723 : : /** ZUC-256 encrypt only **/
17724 : : TEST_CASE_ST(ut_setup, ut_teardown,
17725 : : test_zuc256_encryption_test_case_1),
17726 : : TEST_CASE_ST(ut_setup, ut_teardown,
17727 : : test_zuc256_encryption_test_case_2),
17728 : :
17729 : : /** ZUC-256 decrypt only **/
17730 : : TEST_CASE_ST(ut_setup, ut_teardown,
17731 : : test_zuc256_decryption_test_case_1),
17732 : : TEST_CASE_ST(ut_setup, ut_teardown,
17733 : : test_zuc256_decryption_test_case_2),
17734 : :
17735 : : /** ZUC-256 authentication only **/
17736 : : TEST_CASE_ST(ut_setup, ut_teardown,
17737 : : test_zuc256_hash_generate_4b_tag_test_case_1),
17738 : : TEST_CASE_ST(ut_setup, ut_teardown,
17739 : : test_zuc256_hash_generate_4b_tag_test_case_2),
17740 : : TEST_CASE_ST(ut_setup, ut_teardown,
17741 : : test_zuc256_hash_generate_4b_tag_test_case_3),
17742 : : TEST_CASE_ST(ut_setup, ut_teardown,
17743 : : test_zuc256_hash_generate_8b_tag_test_case_1),
17744 : : TEST_CASE_ST(ut_setup, ut_teardown,
17745 : : test_zuc256_hash_generate_16b_tag_test_case_1),
17746 : :
17747 : : /** ZUC-256 authentication verify only **/
17748 : : TEST_CASE_ST(ut_setup, ut_teardown,
17749 : : test_zuc256_hash_verify_4b_tag_test_case_1),
17750 : : TEST_CASE_ST(ut_setup, ut_teardown,
17751 : : test_zuc256_hash_verify_4b_tag_test_case_2),
17752 : : TEST_CASE_ST(ut_setup, ut_teardown,
17753 : : test_zuc256_hash_verify_4b_tag_test_case_3),
17754 : : TEST_CASE_ST(ut_setup, ut_teardown,
17755 : : test_zuc256_hash_verify_8b_tag_test_case_1),
17756 : : TEST_CASE_ST(ut_setup, ut_teardown,
17757 : : test_zuc256_hash_verify_16b_tag_test_case_1),
17758 : :
17759 : : /** ZUC-256 encrypt and authenticate **/
17760 : : TEST_CASE_ST(ut_setup, ut_teardown,
17761 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
17762 : : TEST_CASE_ST(ut_setup, ut_teardown,
17763 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
17764 : : TEST_CASE_ST(ut_setup, ut_teardown,
17765 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
17766 : : TEST_CASE_ST(ut_setup, ut_teardown,
17767 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
17768 : :
17769 : : /** ZUC-256 generate auth, then encrypt */
17770 : : TEST_CASE_ST(ut_setup, ut_teardown,
17771 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
17772 : : TEST_CASE_ST(ut_setup, ut_teardown,
17773 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
17774 : : TEST_CASE_ST(ut_setup, ut_teardown,
17775 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
17776 : : TEST_CASE_ST(ut_setup, ut_teardown,
17777 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
17778 : :
17779 : : /** ZUC-256 decrypt, then verify auth */
17780 : : TEST_CASE_ST(ut_setup, ut_teardown,
17781 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
17782 : : TEST_CASE_ST(ut_setup, ut_teardown,
17783 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
17784 : : TEST_CASE_ST(ut_setup, ut_teardown,
17785 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
17786 : : TEST_CASE_ST(ut_setup, ut_teardown,
17787 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
17788 : :
17789 : : TEST_CASES_END()
17790 : : }
17791 : : };
17792 : :
17793 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
17794 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
17795 : : .setup = hmac_md5_auth_testsuite_setup,
17796 : : .unit_test_cases = {
17797 : : TEST_CASE_ST(ut_setup, ut_teardown,
17798 : : test_MD5_HMAC_generate_case_1),
17799 : : TEST_CASE_ST(ut_setup, ut_teardown,
17800 : : test_MD5_HMAC_verify_case_1),
17801 : : TEST_CASE_ST(ut_setup, ut_teardown,
17802 : : test_MD5_HMAC_generate_case_2),
17803 : : TEST_CASE_ST(ut_setup, ut_teardown,
17804 : : test_MD5_HMAC_verify_case_2),
17805 : : TEST_CASES_END()
17806 : : }
17807 : : };
17808 : :
17809 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
17810 : : .suite_name = "Kasumi Test Suite",
17811 : : .setup = kasumi_testsuite_setup,
17812 : : .unit_test_cases = {
17813 : : /** KASUMI hash only (UIA1) */
17814 : : TEST_CASE_ST(ut_setup, ut_teardown,
17815 : : test_kasumi_hash_generate_test_case_1),
17816 : : TEST_CASE_ST(ut_setup, ut_teardown,
17817 : : test_kasumi_hash_generate_test_case_2),
17818 : : TEST_CASE_ST(ut_setup, ut_teardown,
17819 : : test_kasumi_hash_generate_test_case_3),
17820 : : TEST_CASE_ST(ut_setup, ut_teardown,
17821 : : test_kasumi_hash_generate_test_case_4),
17822 : : TEST_CASE_ST(ut_setup, ut_teardown,
17823 : : test_kasumi_hash_generate_test_case_5),
17824 : : TEST_CASE_ST(ut_setup, ut_teardown,
17825 : : test_kasumi_hash_generate_test_case_6),
17826 : :
17827 : : TEST_CASE_ST(ut_setup, ut_teardown,
17828 : : test_kasumi_hash_verify_test_case_1),
17829 : : TEST_CASE_ST(ut_setup, ut_teardown,
17830 : : test_kasumi_hash_verify_test_case_2),
17831 : : TEST_CASE_ST(ut_setup, ut_teardown,
17832 : : test_kasumi_hash_verify_test_case_3),
17833 : : TEST_CASE_ST(ut_setup, ut_teardown,
17834 : : test_kasumi_hash_verify_test_case_4),
17835 : : TEST_CASE_ST(ut_setup, ut_teardown,
17836 : : test_kasumi_hash_verify_test_case_5),
17837 : :
17838 : : /** KASUMI encrypt only (UEA1) */
17839 : : TEST_CASE_ST(ut_setup, ut_teardown,
17840 : : test_kasumi_encryption_test_case_1),
17841 : : TEST_CASE_ST(ut_setup, ut_teardown,
17842 : : test_kasumi_encryption_test_case_1_sgl),
17843 : : TEST_CASE_ST(ut_setup, ut_teardown,
17844 : : test_kasumi_encryption_test_case_1_oop),
17845 : : TEST_CASE_ST(ut_setup, ut_teardown,
17846 : : test_kasumi_encryption_test_case_1_oop_sgl),
17847 : : TEST_CASE_ST(ut_setup, ut_teardown,
17848 : : test_kasumi_encryption_test_case_2),
17849 : : TEST_CASE_ST(ut_setup, ut_teardown,
17850 : : test_kasumi_encryption_test_case_3),
17851 : : TEST_CASE_ST(ut_setup, ut_teardown,
17852 : : test_kasumi_encryption_test_case_4),
17853 : : TEST_CASE_ST(ut_setup, ut_teardown,
17854 : : test_kasumi_encryption_test_case_5),
17855 : :
17856 : : /** KASUMI decrypt only (UEA1) */
17857 : : TEST_CASE_ST(ut_setup, ut_teardown,
17858 : : test_kasumi_decryption_test_case_1),
17859 : : TEST_CASE_ST(ut_setup, ut_teardown,
17860 : : test_kasumi_decryption_test_case_2),
17861 : : TEST_CASE_ST(ut_setup, ut_teardown,
17862 : : test_kasumi_decryption_test_case_3),
17863 : : TEST_CASE_ST(ut_setup, ut_teardown,
17864 : : test_kasumi_decryption_test_case_4),
17865 : : TEST_CASE_ST(ut_setup, ut_teardown,
17866 : : test_kasumi_decryption_test_case_5),
17867 : : TEST_CASE_ST(ut_setup, ut_teardown,
17868 : : test_kasumi_decryption_test_case_1_oop),
17869 : : TEST_CASE_ST(ut_setup, ut_teardown,
17870 : : test_kasumi_cipher_auth_test_case_1),
17871 : :
17872 : : /** KASUMI generate auth, then encrypt (F8) */
17873 : : TEST_CASE_ST(ut_setup, ut_teardown,
17874 : : test_kasumi_auth_cipher_test_case_1),
17875 : : TEST_CASE_ST(ut_setup, ut_teardown,
17876 : : test_kasumi_auth_cipher_test_case_2),
17877 : : TEST_CASE_ST(ut_setup, ut_teardown,
17878 : : test_kasumi_auth_cipher_test_case_2_oop),
17879 : : TEST_CASE_ST(ut_setup, ut_teardown,
17880 : : test_kasumi_auth_cipher_test_case_2_sgl),
17881 : : TEST_CASE_ST(ut_setup, ut_teardown,
17882 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
17883 : :
17884 : : /** KASUMI decrypt (F8), then verify auth */
17885 : : TEST_CASE_ST(ut_setup, ut_teardown,
17886 : : test_kasumi_auth_cipher_verify_test_case_1),
17887 : : TEST_CASE_ST(ut_setup, ut_teardown,
17888 : : test_kasumi_auth_cipher_verify_test_case_2),
17889 : : TEST_CASE_ST(ut_setup, ut_teardown,
17890 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
17891 : : TEST_CASE_ST(ut_setup, ut_teardown,
17892 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
17893 : : TEST_CASE_ST(ut_setup, ut_teardown,
17894 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
17895 : :
17896 : : TEST_CASES_END()
17897 : : }
17898 : : };
17899 : :
17900 : : static struct unit_test_suite cryptodev_esn_testsuite = {
17901 : : .suite_name = "ESN Test Suite",
17902 : : .setup = esn_testsuite_setup,
17903 : : .unit_test_cases = {
17904 : : TEST_CASE_ST(ut_setup, ut_teardown,
17905 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
17906 : : TEST_CASE_ST(ut_setup, ut_teardown,
17907 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
17908 : : TEST_CASES_END()
17909 : : }
17910 : : };
17911 : :
17912 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
17913 : : .suite_name = "Negative AES GCM Test Suite",
17914 : : .setup = negative_aes_gcm_testsuite_setup,
17915 : : .unit_test_cases = {
17916 : : TEST_CASE_ST(ut_setup, ut_teardown,
17917 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
17918 : : TEST_CASE_ST(ut_setup, ut_teardown,
17919 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
17920 : : TEST_CASE_ST(ut_setup, ut_teardown,
17921 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
17922 : : TEST_CASE_ST(ut_setup, ut_teardown,
17923 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
17924 : : TEST_CASE_ST(ut_setup, ut_teardown,
17925 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
17926 : : TEST_CASE_ST(ut_setup, ut_teardown,
17927 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
17928 : : TEST_CASE_ST(ut_setup, ut_teardown,
17929 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
17930 : : TEST_CASE_ST(ut_setup, ut_teardown,
17931 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
17932 : : TEST_CASE_ST(ut_setup, ut_teardown,
17933 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
17934 : : TEST_CASE_ST(ut_setup, ut_teardown,
17935 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
17936 : : TEST_CASE_ST(ut_setup, ut_teardown,
17937 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
17938 : : TEST_CASE_ST(ut_setup, ut_teardown,
17939 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
17940 : :
17941 : : TEST_CASES_END()
17942 : : }
17943 : : };
17944 : :
17945 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
17946 : : .suite_name = "Negative AES GMAC Test Suite",
17947 : : .setup = negative_aes_gmac_testsuite_setup,
17948 : : .unit_test_cases = {
17949 : : TEST_CASE_ST(ut_setup, ut_teardown,
17950 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
17951 : : TEST_CASE_ST(ut_setup, ut_teardown,
17952 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
17953 : :
17954 : : TEST_CASES_END()
17955 : : }
17956 : : };
17957 : :
17958 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
17959 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
17960 : : .setup = mixed_cipher_hash_testsuite_setup,
17961 : : .unit_test_cases = {
17962 : : /** AUTH AES CMAC + CIPHER AES CTR */
17963 : : TEST_CASE_ST(ut_setup, ut_teardown,
17964 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
17965 : : TEST_CASE_ST(ut_setup, ut_teardown,
17966 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17967 : : TEST_CASE_ST(ut_setup, ut_teardown,
17968 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17969 : : TEST_CASE_ST(ut_setup, ut_teardown,
17970 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17971 : : TEST_CASE_ST(ut_setup, ut_teardown,
17972 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
17973 : : TEST_CASE_ST(ut_setup, ut_teardown,
17974 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17975 : : TEST_CASE_ST(ut_setup, ut_teardown,
17976 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17977 : : TEST_CASE_ST(ut_setup, ut_teardown,
17978 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17979 : : TEST_CASE_ST(ut_setup, ut_teardown,
17980 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
17981 : : TEST_CASE_ST(ut_setup, ut_teardown,
17982 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17983 : : TEST_CASE_ST(ut_setup, ut_teardown,
17984 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
17985 : : TEST_CASE_ST(ut_setup, ut_teardown,
17986 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17987 : :
17988 : : /** AUTH ZUC + CIPHER SNOW3G */
17989 : : TEST_CASE_ST(ut_setup, ut_teardown,
17990 : : test_auth_zuc_cipher_snow_test_case_1),
17991 : : TEST_CASE_ST(ut_setup, ut_teardown,
17992 : : test_verify_auth_zuc_cipher_snow_test_case_1),
17993 : : TEST_CASE_ST(ut_setup, ut_teardown,
17994 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
17995 : : TEST_CASE_ST(ut_setup, ut_teardown,
17996 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
17997 : : /** AUTH AES CMAC + CIPHER SNOW3G */
17998 : : TEST_CASE_ST(ut_setup, ut_teardown,
17999 : : test_auth_aes_cmac_cipher_snow_test_case_1),
18000 : : TEST_CASE_ST(ut_setup, ut_teardown,
18001 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
18002 : : TEST_CASE_ST(ut_setup, ut_teardown,
18003 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18004 : : TEST_CASE_ST(ut_setup, ut_teardown,
18005 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18006 : : /** AUTH ZUC + CIPHER AES CTR */
18007 : : TEST_CASE_ST(ut_setup, ut_teardown,
18008 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
18009 : : TEST_CASE_ST(ut_setup, ut_teardown,
18010 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
18011 : : TEST_CASE_ST(ut_setup, ut_teardown,
18012 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18013 : : TEST_CASE_ST(ut_setup, ut_teardown,
18014 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18015 : : /** AUTH SNOW3G + CIPHER AES CTR */
18016 : : TEST_CASE_ST(ut_setup, ut_teardown,
18017 : : test_auth_snow_cipher_aes_ctr_test_case_1),
18018 : : TEST_CASE_ST(ut_setup, ut_teardown,
18019 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
18020 : : TEST_CASE_ST(ut_setup, ut_teardown,
18021 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18022 : : TEST_CASE_ST(ut_setup, ut_teardown,
18023 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18024 : : TEST_CASE_ST(ut_setup, ut_teardown,
18025 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18026 : : TEST_CASE_ST(ut_setup, ut_teardown,
18027 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18028 : : /** AUTH SNOW3G + CIPHER ZUC */
18029 : : TEST_CASE_ST(ut_setup, ut_teardown,
18030 : : test_auth_snow_cipher_zuc_test_case_1),
18031 : : TEST_CASE_ST(ut_setup, ut_teardown,
18032 : : test_verify_auth_snow_cipher_zuc_test_case_1),
18033 : : TEST_CASE_ST(ut_setup, ut_teardown,
18034 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
18035 : : TEST_CASE_ST(ut_setup, ut_teardown,
18036 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
18037 : : /** AUTH AES CMAC + CIPHER ZUC */
18038 : : TEST_CASE_ST(ut_setup, ut_teardown,
18039 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
18040 : : TEST_CASE_ST(ut_setup, ut_teardown,
18041 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
18042 : : TEST_CASE_ST(ut_setup, ut_teardown,
18043 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18044 : : TEST_CASE_ST(ut_setup, ut_teardown,
18045 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18046 : :
18047 : : /** AUTH NULL + CIPHER SNOW3G */
18048 : : TEST_CASE_ST(ut_setup, ut_teardown,
18049 : : test_auth_null_cipher_snow_test_case_1),
18050 : : TEST_CASE_ST(ut_setup, ut_teardown,
18051 : : test_verify_auth_null_cipher_snow_test_case_1),
18052 : : /** AUTH NULL + CIPHER ZUC */
18053 : : TEST_CASE_ST(ut_setup, ut_teardown,
18054 : : test_auth_null_cipher_zuc_test_case_1),
18055 : : TEST_CASE_ST(ut_setup, ut_teardown,
18056 : : test_verify_auth_null_cipher_zuc_test_case_1),
18057 : : /** AUTH SNOW3G + CIPHER NULL */
18058 : : TEST_CASE_ST(ut_setup, ut_teardown,
18059 : : test_auth_snow_cipher_null_test_case_1),
18060 : : TEST_CASE_ST(ut_setup, ut_teardown,
18061 : : test_verify_auth_snow_cipher_null_test_case_1),
18062 : : /** AUTH ZUC + CIPHER NULL */
18063 : : TEST_CASE_ST(ut_setup, ut_teardown,
18064 : : test_auth_zuc_cipher_null_test_case_1),
18065 : : TEST_CASE_ST(ut_setup, ut_teardown,
18066 : : test_verify_auth_zuc_cipher_null_test_case_1),
18067 : : /** AUTH NULL + CIPHER AES CTR */
18068 : : TEST_CASE_ST(ut_setup, ut_teardown,
18069 : : test_auth_null_cipher_aes_ctr_test_case_1),
18070 : : TEST_CASE_ST(ut_setup, ut_teardown,
18071 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
18072 : : /** AUTH AES CMAC + CIPHER NULL */
18073 : : TEST_CASE_ST(ut_setup, ut_teardown,
18074 : : test_auth_aes_cmac_cipher_null_test_case_1),
18075 : : TEST_CASE_ST(ut_setup, ut_teardown,
18076 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
18077 : : TEST_CASES_END()
18078 : : }
18079 : : };
18080 : :
18081 : : static int
18082 : 1 : run_cryptodev_testsuite(const char *pmd_name)
18083 : : {
18084 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
18085 : 1 : const enum blockcipher_test_type blk_suites[] = {
18086 : : BLKCIPHER_AES_CHAIN_TYPE,
18087 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
18088 : : BLKCIPHER_AES_DOCSIS_TYPE,
18089 : : BLKCIPHER_3DES_CHAIN_TYPE,
18090 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
18091 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
18092 : : BLKCIPHER_DES_DOCSIS_TYPE,
18093 : : BLKCIPHER_SM4_CHAIN_TYPE,
18094 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
18095 : : BLKCIPHER_AUTHONLY_TYPE};
18096 : 1 : struct unit_test_suite *static_suites[] = {
18097 : : &cryptodev_multi_session_testsuite,
18098 : : &cryptodev_null_testsuite,
18099 : : &cryptodev_aes_ccm_auth_testsuite,
18100 : : &cryptodev_aes_gcm_auth_testsuite,
18101 : : &cryptodev_aes_gmac_auth_testsuite,
18102 : : &cryptodev_snow3g_testsuite,
18103 : : &cryptodev_chacha20_poly1305_testsuite,
18104 : : &cryptodev_zuc_testsuite,
18105 : : &cryptodev_hmac_md5_auth_testsuite,
18106 : : &cryptodev_kasumi_testsuite,
18107 : : &cryptodev_esn_testsuite,
18108 : : &cryptodev_negative_aes_gcm_testsuite,
18109 : : &cryptodev_negative_aes_gmac_testsuite,
18110 : : &cryptodev_mixed_cipher_hash_testsuite,
18111 : : &cryptodev_negative_hmac_sha1_testsuite,
18112 : : &cryptodev_gen_testsuite,
18113 : : #ifdef RTE_LIB_SECURITY
18114 : : &ipsec_proto_testsuite,
18115 : : &pdcp_proto_testsuite,
18116 : : &docsis_proto_testsuite,
18117 : : &tls12_record_proto_testsuite,
18118 : : &dtls12_record_proto_testsuite,
18119 : : #endif
18120 : : &end_testsuite
18121 : : };
18122 : : static struct unit_test_suite ts = {
18123 : : .suite_name = "Cryptodev Unit Test Suite",
18124 : : .setup = testsuite_setup,
18125 : : .teardown = testsuite_teardown,
18126 : : .unit_test_cases = {TEST_CASES_END()}
18127 : : };
18128 : :
18129 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
18130 : :
18131 [ - + ]: 1 : if (gbl_driver_id == -1) {
18132 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
18133 : 0 : return TEST_SKIPPED;
18134 : : }
18135 : :
18136 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
18137 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
18138 : :
18139 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
18140 [ + + ]: 23 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
18141 : 1 : ret = unit_test_suite_runner(&ts);
18142 : :
18143 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
18144 : 1 : free(ts.unit_test_suites);
18145 : 1 : return ret;
18146 : : }
18147 : :
18148 : : static int
18149 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
18150 : : {
18151 : : struct rte_cryptodev_info dev_info;
18152 : : uint8_t i, nb_devs;
18153 : : int driver_id;
18154 : :
18155 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
18156 [ # # ]: 0 : if (driver_id == -1) {
18157 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
18158 : 0 : return TEST_SKIPPED;
18159 : : }
18160 : :
18161 : 0 : nb_devs = rte_cryptodev_count();
18162 [ # # ]: 0 : if (nb_devs < 1) {
18163 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
18164 : 0 : return TEST_SKIPPED;
18165 : : }
18166 : :
18167 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
18168 : 0 : rte_cryptodev_info_get(i, &dev_info);
18169 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
18170 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
18171 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
18172 : : flag_name);
18173 : 0 : return TEST_SKIPPED;
18174 : : }
18175 : : return 0; /* found */
18176 : : }
18177 : : }
18178 : :
18179 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
18180 : 0 : return TEST_SKIPPED;
18181 : : }
18182 : :
18183 : : static int
18184 : 0 : test_cryptodev_qat(void)
18185 : : {
18186 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
18187 : : }
18188 : :
18189 : : static int
18190 : 0 : test_cryptodev_uadk(void)
18191 : : {
18192 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
18193 : : }
18194 : :
18195 : : static int
18196 : 0 : test_cryptodev_virtio(void)
18197 : : {
18198 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
18199 : : }
18200 : :
18201 : : static int
18202 : 0 : test_cryptodev_aesni_mb(void)
18203 : : {
18204 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18205 : : }
18206 : :
18207 : : static int
18208 : 0 : test_cryptodev_cpu_aesni_mb(void)
18209 : : {
18210 : : int32_t rc;
18211 : 0 : enum rte_security_session_action_type at = gbl_action_type;
18212 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18213 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18214 : 0 : gbl_action_type = at;
18215 : 0 : return rc;
18216 : : }
18217 : :
18218 : : static int
18219 : 0 : test_cryptodev_chacha_poly_mb(void)
18220 : : {
18221 : : int32_t rc;
18222 : 0 : enum rte_security_session_action_type at = gbl_action_type;
18223 : 0 : rc = run_cryptodev_testsuite(
18224 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
18225 : 0 : gbl_action_type = at;
18226 : 0 : return rc;
18227 : : }
18228 : :
18229 : : static int
18230 : 1 : test_cryptodev_openssl(void)
18231 : : {
18232 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
18233 : : }
18234 : :
18235 : : static int
18236 : 0 : test_cryptodev_aesni_gcm(void)
18237 : : {
18238 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18239 : : }
18240 : :
18241 : : static int
18242 : 0 : test_cryptodev_cpu_aesni_gcm(void)
18243 : : {
18244 : : int32_t rc;
18245 : 0 : enum rte_security_session_action_type at = gbl_action_type;
18246 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18247 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18248 : 0 : gbl_action_type = at;
18249 : 0 : return rc;
18250 : : }
18251 : :
18252 : : static int
18253 : 0 : test_cryptodev_mlx5(void)
18254 : : {
18255 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
18256 : : }
18257 : :
18258 : : static int
18259 : 0 : test_cryptodev_null(void)
18260 : : {
18261 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
18262 : : }
18263 : :
18264 : : static int
18265 : 0 : test_cryptodev_sw_snow3g(void)
18266 : : {
18267 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
18268 : : }
18269 : :
18270 : : static int
18271 : 0 : test_cryptodev_sw_kasumi(void)
18272 : : {
18273 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
18274 : : }
18275 : :
18276 : : static int
18277 : 0 : test_cryptodev_sw_zuc(void)
18278 : : {
18279 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
18280 : : }
18281 : :
18282 : : static int
18283 : 0 : test_cryptodev_armv8(void)
18284 : : {
18285 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
18286 : : }
18287 : :
18288 : : static int
18289 : 0 : test_cryptodev_mrvl(void)
18290 : : {
18291 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
18292 : : }
18293 : :
18294 : : #ifdef RTE_CRYPTO_SCHEDULER
18295 : :
18296 : : static int
18297 : 0 : test_cryptodev_scheduler(void)
18298 : : {
18299 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
18300 : 0 : const enum blockcipher_test_type blk_suites[] = {
18301 : : BLKCIPHER_AES_CHAIN_TYPE,
18302 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
18303 : : BLKCIPHER_AUTHONLY_TYPE
18304 : : };
18305 : : static struct unit_test_suite scheduler_multicore = {
18306 : : .suite_name = "Scheduler Multicore Unit Test Suite",
18307 : : .setup = scheduler_multicore_testsuite_setup,
18308 : : .teardown = scheduler_mode_testsuite_teardown,
18309 : : .unit_test_cases = {TEST_CASES_END()}
18310 : : };
18311 : : static struct unit_test_suite scheduler_round_robin = {
18312 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
18313 : : .setup = scheduler_roundrobin_testsuite_setup,
18314 : : .teardown = scheduler_mode_testsuite_teardown,
18315 : : .unit_test_cases = {TEST_CASES_END()}
18316 : : };
18317 : : static struct unit_test_suite scheduler_failover = {
18318 : : .suite_name = "Scheduler Failover Unit Test Suite",
18319 : : .setup = scheduler_failover_testsuite_setup,
18320 : : .teardown = scheduler_mode_testsuite_teardown,
18321 : : .unit_test_cases = {TEST_CASES_END()}
18322 : : };
18323 : : static struct unit_test_suite scheduler_pkt_size_distr = {
18324 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
18325 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
18326 : : .teardown = scheduler_mode_testsuite_teardown,
18327 : : .unit_test_cases = {TEST_CASES_END()}
18328 : : };
18329 : 0 : struct unit_test_suite *sched_mode_suites[] = {
18330 : : &scheduler_multicore,
18331 : : &scheduler_round_robin,
18332 : : &scheduler_failover,
18333 : : &scheduler_pkt_size_distr
18334 : : };
18335 : : static struct unit_test_suite scheduler_config = {
18336 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
18337 : : .unit_test_cases = {
18338 : : TEST_CASE(test_scheduler_attach_worker_op),
18339 : : TEST_CASE(test_scheduler_mode_multicore_op),
18340 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
18341 : : TEST_CASE(test_scheduler_mode_failover_op),
18342 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
18343 : : TEST_CASE(test_scheduler_detach_worker_op),
18344 : :
18345 : : TEST_CASES_END() /**< NULL terminate array */
18346 : : }
18347 : : };
18348 : 0 : struct unit_test_suite *static_suites[] = {
18349 : : &scheduler_config,
18350 : : &end_testsuite
18351 : : };
18352 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
18353 : : #ifdef RTE_LIB_SECURITY
18354 : : &docsis_proto_testsuite,
18355 : : #endif
18356 : : &end_testsuite
18357 : : };
18358 : : static struct unit_test_suite ts = {
18359 : : .suite_name = "Scheduler Unit Test Suite",
18360 : : .setup = scheduler_testsuite_setup,
18361 : : .teardown = testsuite_teardown,
18362 : : .unit_test_cases = {TEST_CASES_END()}
18363 : : };
18364 : :
18365 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
18366 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
18367 : :
18368 [ # # ]: 0 : if (gbl_driver_id == -1) {
18369 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
18370 : 0 : return TEST_SKIPPED;
18371 : : }
18372 : :
18373 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
18374 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
18375 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
18376 : 0 : return TEST_SKIPPED;
18377 : : }
18378 : :
18379 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
18380 : : uint8_t blk_i = 0;
18381 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
18382 : : (struct unit_test_suite *) *
18383 : : (RTE_DIM(blk_suites) +
18384 : : RTE_DIM(sched_mode_static_suites) + 1));
18385 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
18386 : : blk_suites, RTE_DIM(blk_suites));
18387 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
18388 : : sched_mode_static_suites,
18389 : : RTE_DIM(sched_mode_static_suites));
18390 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
18391 : : }
18392 : :
18393 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
18394 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
18395 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
18396 : : RTE_DIM(sched_mode_suites));
18397 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
18398 : 0 : ret = unit_test_suite_runner(&ts);
18399 : :
18400 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
18401 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
18402 : : (*sched_mode_suites[sched_i]),
18403 : : RTE_DIM(blk_suites));
18404 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
18405 : : }
18406 : 0 : free(ts.unit_test_suites);
18407 : 0 : return ret;
18408 : : }
18409 : :
18410 : 238 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
18411 : :
18412 : : #endif
18413 : :
18414 : : static int
18415 : 0 : test_cryptodev_dpaa2_sec(void)
18416 : : {
18417 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
18418 : : }
18419 : :
18420 : : static int
18421 : 0 : test_cryptodev_dpaa_sec(void)
18422 : : {
18423 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
18424 : : }
18425 : :
18426 : : static int
18427 : 0 : test_cryptodev_ccp(void)
18428 : : {
18429 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
18430 : : }
18431 : :
18432 : : static int
18433 : 0 : test_cryptodev_octeontx(void)
18434 : : {
18435 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
18436 : : }
18437 : :
18438 : : static int
18439 : 0 : test_cryptodev_caam_jr(void)
18440 : : {
18441 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
18442 : : }
18443 : :
18444 : : static int
18445 : 0 : test_cryptodev_nitrox(void)
18446 : : {
18447 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
18448 : : }
18449 : :
18450 : : static int
18451 : 0 : test_cryptodev_bcmfs(void)
18452 : : {
18453 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
18454 : : }
18455 : :
18456 : : static int
18457 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
18458 : : {
18459 : : int ret;
18460 : :
18461 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
18462 [ # # ]: 0 : if (ret)
18463 : : return ret;
18464 : :
18465 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
18466 : 0 : ret = run_cryptodev_testsuite(pmd_name);
18467 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
18468 : :
18469 : 0 : return ret;
18470 : : }
18471 : :
18472 : : static int
18473 : 0 : test_cryptodev_qat_raw_api(void)
18474 : : {
18475 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
18476 : : }
18477 : :
18478 : : static int
18479 : 0 : test_cryptodev_cn9k(void)
18480 : : {
18481 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
18482 : : }
18483 : :
18484 : : static int
18485 : 0 : test_cryptodev_cn10k(void)
18486 : : {
18487 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
18488 : : }
18489 : :
18490 : : static int
18491 : 0 : test_cryptodev_cn10k_raw_api(void)
18492 : : {
18493 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
18494 : : }
18495 : :
18496 : : static int
18497 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
18498 : : {
18499 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
18500 : : }
18501 : :
18502 : : static int
18503 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
18504 : : {
18505 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
18506 : : }
18507 : :
18508 : 238 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
18509 : : test_cryptodev_cn10k_raw_api);
18510 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
18511 : : test_cryptodev_dpaa2_sec_raw_api);
18512 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
18513 : : test_cryptodev_dpaa_sec_raw_api);
18514 : 238 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
18515 : : test_cryptodev_qat_raw_api);
18516 : 238 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
18517 : 238 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
18518 : 238 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
18519 : : test_cryptodev_cpu_aesni_mb);
18520 : 238 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
18521 : : test_cryptodev_chacha_poly_mb);
18522 : 238 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
18523 : 238 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
18524 : 238 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
18525 : : test_cryptodev_cpu_aesni_gcm);
18526 : 238 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
18527 : 238 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
18528 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
18529 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
18530 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
18531 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
18532 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
18533 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
18534 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
18535 : 238 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
18536 : 238 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
18537 : 238 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
18538 : 238 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
18539 : 238 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
18540 : 238 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
18541 : 238 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
18542 : 238 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
18543 : 238 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
|