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 : :
57 : : #define SDAP_DISABLED 0
58 : : #define SDAP_ENABLED 1
59 : : #endif
60 : :
61 : : #define VDEV_ARGS_SIZE 100
62 : : #define MAX_NB_SESSIONS 4
63 : :
64 : : #define MAX_DRV_SERVICE_CTX_SIZE 256
65 : :
66 : : #define MAX_RAW_DEQUEUE_COUNT 65535
67 : :
68 : : #define IN_PLACE 0
69 : : #define OUT_OF_PLACE 1
70 : :
71 : : static int gbl_driver_id;
72 : :
73 : : static enum rte_security_session_action_type gbl_action_type =
74 : : RTE_SECURITY_ACTION_TYPE_NONE;
75 : :
76 : : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
77 : :
78 : : struct crypto_unittest_params {
79 : : struct rte_crypto_sym_xform cipher_xform;
80 : : struct rte_crypto_sym_xform auth_xform;
81 : : struct rte_crypto_sym_xform aead_xform;
82 : : #ifdef RTE_LIB_SECURITY
83 : : struct rte_security_docsis_xform docsis_xform;
84 : : #endif
85 : :
86 : : union {
87 : : void *sess;
88 : : #ifdef RTE_LIB_SECURITY
89 : : void *sec_session;
90 : : #endif
91 : : };
92 : : #ifdef RTE_LIB_SECURITY
93 : : enum rte_security_session_action_type type;
94 : : #endif
95 : : struct rte_crypto_op *op;
96 : :
97 : : struct rte_mbuf *obuf, *ibuf;
98 : :
99 : : uint8_t *digest;
100 : : };
101 : :
102 : : #define ALIGN_POW2_ROUNDUP(num, align) \
103 : : (((num) + (align) - 1) & ~((align) - 1))
104 : :
105 : : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
106 : : for (j = 0; j < num_child_ts; index++, j++) \
107 : : parent_ts.unit_test_suites[index] = child_ts[j]
108 : :
109 : : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
110 : : for (j = 0; j < num_blk_types; index++, j++) \
111 : : parent_ts.unit_test_suites[index] = \
112 : : build_blockcipher_test_suite(blk_types[j])
113 : :
114 : : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
115 : : for (j = index; j < index + num_blk_types; j++) \
116 : : free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
117 : :
118 : : /*
119 : : * Forward declarations.
120 : : */
121 : : static int
122 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
123 : : struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 : : uint8_t *hmac_key);
125 : :
126 : : static int
127 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
128 : : struct crypto_unittest_params *ut_params,
129 : : struct crypto_testsuite_params *ts_param,
130 : : const uint8_t *cipher,
131 : : const uint8_t *digest,
132 : : const uint8_t *iv);
133 : :
134 : : static int
135 : : security_proto_supported(enum rte_security_session_action_type action,
136 : : enum rte_security_session_protocol proto);
137 : :
138 : : static int
139 : : dev_configure_and_start(uint64_t ff_disable);
140 : :
141 : : static int
142 : : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
143 : : const enum rte_crypto_cipher_algorithm cipher_algo,
144 : : const uint16_t key_size, const uint16_t iv_size);
145 : :
146 : : static int
147 : : check_auth_capability(const struct crypto_testsuite_params *ts_params,
148 : : const enum rte_crypto_auth_algorithm auth_algo,
149 : : const uint16_t key_size, const uint16_t iv_size,
150 : : const uint16_t tag_size);
151 : :
152 : : static struct rte_mbuf *
153 : 0 : setup_test_string(struct rte_mempool *mpool,
154 : : const char *string, size_t len, uint8_t blocksize)
155 : : {
156 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
157 [ # # ]: 0 : size_t t_len = len - (blocksize ? (len % blocksize) : 0);
158 : :
159 [ # # ]: 0 : if (m) {
160 : : char *dst;
161 : :
162 : 0 : memset(m->buf_addr, 0, m->buf_len);
163 : 0 : dst = rte_pktmbuf_append(m, t_len);
164 [ # # ]: 0 : if (!dst) {
165 : 0 : rte_pktmbuf_free(m);
166 : 0 : return NULL;
167 : : }
168 [ # # ]: 0 : if (string != NULL)
169 : : rte_memcpy(dst, string, t_len);
170 : : else
171 : : memset(dst, 0, t_len);
172 : : }
173 : :
174 : : return m;
175 : : }
176 : :
177 : : /* Get number of bytes in X bits (rounding up) */
178 : : static uint32_t
179 : : ceil_byte_length(uint32_t num_bits)
180 : : {
181 : 0 : if (num_bits % 8)
182 : 0 : return ((num_bits >> 3) + 1);
183 : : else
184 : 0 : return (num_bits >> 3);
185 : : }
186 : :
187 : : static void
188 : 0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
189 : : uint8_t is_op_success)
190 : : {
191 : : struct rte_crypto_op *op = user_data;
192 [ # # ]: 0 : op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
193 : : RTE_CRYPTO_OP_STATUS_ERROR;
194 : 0 : }
195 : :
196 : : static struct crypto_testsuite_params testsuite_params = { NULL };
197 : : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
198 : : static struct crypto_unittest_params unittest_params;
199 : :
200 : : int
201 : 0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
202 : : struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
203 : : uint8_t len_in_bits, uint8_t cipher_iv_len)
204 : : {
205 : 0 : struct rte_crypto_sym_op *sop = op->sym;
206 : 0 : struct rte_crypto_op *ret_op = NULL;
207 : : struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
208 : : struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
209 : : union rte_crypto_sym_ofs ofs;
210 : : struct rte_crypto_sym_vec vec;
211 : : struct rte_crypto_sgl sgl, dest_sgl;
212 : : uint32_t max_len;
213 : : union rte_cryptodev_session_ctx sess;
214 : : uint64_t auth_end_iova;
215 : : uint32_t count = 0;
216 : : struct rte_crypto_raw_dp_ctx *ctx;
217 : : uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
218 : : auth_len = 0;
219 : : int32_t n;
220 : : uint32_t n_success;
221 : : int ctx_service_size;
222 : 0 : int32_t status = 0;
223 : : int enqueue_status, dequeue_status;
224 : : struct crypto_unittest_params *ut_params = &unittest_params;
225 : 0 : int is_sgl = sop->m_src->nb_segs > 1;
226 : : int ret = TEST_SUCCESS, is_oop = 0;
227 : :
228 : 0 : ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
229 [ # # ]: 0 : if (ctx_service_size < 0)
230 : : return TEST_SKIPPED;
231 : :
232 : 0 : ctx = malloc(ctx_service_size);
233 [ # # ]: 0 : if (ctx == NULL)
234 : : return TEST_FAILED;
235 : :
236 : : /* Both are enums, setting crypto_sess will suit any session type */
237 : 0 : sess.crypto_sess = op->sym->session;
238 : :
239 : 0 : ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
240 [ # # ]: 0 : if (ret == -ENOTSUP) {
241 : : ret = TEST_SKIPPED;
242 : 0 : goto exit;
243 [ # # ]: 0 : } else if (ret) {
244 : : ret = TEST_FAILED;
245 : 0 : goto exit;
246 : : }
247 : :
248 : 0 : cipher_iv.iova = 0;
249 : 0 : cipher_iv.va = NULL;
250 : 0 : aad_auth_iv.iova = 0;
251 : 0 : aad_auth_iv.va = NULL;
252 : 0 : digest.iova = 0;
253 : 0 : digest.va = NULL;
254 : 0 : sgl.vec = data_vec;
255 : 0 : vec.num = 1;
256 : 0 : vec.src_sgl = &sgl;
257 : 0 : vec.iv = &cipher_iv;
258 : 0 : vec.digest = &digest;
259 : 0 : vec.aad = &aad_auth_iv;
260 : 0 : vec.status = &status;
261 : :
262 : 0 : ofs.raw = 0;
263 : :
264 [ # # # # ]: 0 : if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
265 : : is_oop = 1;
266 : :
267 [ # # ]: 0 : if (is_cipher && is_auth) {
268 : 0 : cipher_offset = sop->cipher.data.offset;
269 : 0 : cipher_len = sop->cipher.data.length;
270 : 0 : auth_offset = sop->auth.data.offset;
271 : 0 : auth_len = sop->auth.data.length;
272 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len,
273 : : auth_offset + auth_len);
274 [ # # ]: 0 : if (len_in_bits) {
275 : 0 : max_len = max_len >> 3;
276 : 0 : cipher_offset = cipher_offset >> 3;
277 : 0 : auth_offset = auth_offset >> 3;
278 : 0 : cipher_len = cipher_len >> 3;
279 : 0 : auth_len = auth_len >> 3;
280 : : }
281 : 0 : ofs.ofs.cipher.head = cipher_offset;
282 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
283 : 0 : ofs.ofs.auth.head = auth_offset;
284 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
285 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
286 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
287 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
288 : : op, void *, IV_OFFSET + cipher_iv_len);
289 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
290 : : cipher_iv_len);
291 : 0 : digest.va = (void *)sop->auth.digest.data;
292 : 0 : digest.iova = sop->auth.digest.phys_addr;
293 : :
294 [ # # ]: 0 : if (is_sgl) {
295 : 0 : uint32_t remaining_off = auth_offset + auth_len;
296 : 0 : struct rte_mbuf *sgl_buf = sop->m_src;
297 [ # # ]: 0 : if (is_oop)
298 : : sgl_buf = sop->m_dst;
299 : :
300 : 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
301 [ # # # # ]: 0 : && sgl_buf->next != NULL) {
302 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
303 : : sgl_buf = sgl_buf->next;
304 : : }
305 : :
306 : 0 : auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
307 : : sgl_buf, remaining_off);
308 : : } else {
309 : 0 : auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
310 : 0 : auth_offset + auth_len;
311 : : }
312 : : /* Then check if digest-encrypted conditions are met */
313 [ # # # # ]: 0 : if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
314 [ # # ]: 0 : (digest.iova == auth_end_iova) && is_sgl)
315 : 0 : max_len = RTE_MAX(max_len,
316 : : auth_offset + auth_len +
317 : : ut_params->auth_xform.auth.digest_length);
318 : :
319 [ # # ]: 0 : } else if (is_cipher) {
320 : 0 : cipher_offset = sop->cipher.data.offset;
321 : 0 : cipher_len = sop->cipher.data.length;
322 : 0 : max_len = cipher_len + cipher_offset;
323 [ # # ]: 0 : if (len_in_bits) {
324 : 0 : max_len = max_len >> 3;
325 : 0 : cipher_offset = cipher_offset >> 3;
326 : 0 : cipher_len = cipher_len >> 3;
327 : : }
328 : 0 : ofs.ofs.cipher.head = cipher_offset;
329 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
330 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
331 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
332 : :
333 [ # # ]: 0 : } else if (is_auth) {
334 : 0 : auth_offset = sop->auth.data.offset;
335 : 0 : auth_len = sop->auth.data.length;
336 : 0 : max_len = auth_len + auth_offset;
337 [ # # ]: 0 : if (len_in_bits) {
338 : 0 : max_len = max_len >> 3;
339 : 0 : auth_offset = auth_offset >> 3;
340 : 0 : auth_len = auth_len >> 3;
341 : : }
342 : 0 : ofs.ofs.auth.head = auth_offset;
343 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
344 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
345 : : op, void *, IV_OFFSET + cipher_iv_len);
346 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
347 : : cipher_iv_len);
348 : 0 : digest.va = (void *)sop->auth.digest.data;
349 : 0 : digest.iova = sop->auth.digest.phys_addr;
350 : :
351 : : } else { /* aead */
352 : 0 : cipher_offset = sop->aead.data.offset;
353 : 0 : cipher_len = sop->aead.data.length;
354 : 0 : max_len = cipher_len + cipher_offset;
355 [ # # ]: 0 : if (len_in_bits) {
356 : 0 : max_len = max_len >> 3;
357 : 0 : cipher_offset = cipher_offset >> 3;
358 : 0 : cipher_len = cipher_len >> 3;
359 : : }
360 : 0 : ofs.ofs.cipher.head = cipher_offset;
361 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
362 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
363 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
364 : 0 : aad_auth_iv.va = (void *)sop->aead.aad.data;
365 : 0 : aad_auth_iv.iova = sop->aead.aad.phys_addr;
366 : 0 : digest.va = (void *)sop->aead.digest.data;
367 : 0 : digest.iova = sop->aead.digest.phys_addr;
368 : : }
369 : :
370 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
371 : : data_vec, RTE_DIM(data_vec));
372 [ # # # # ]: 0 : if (n < 0 || n > sop->m_src->nb_segs) {
373 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
374 : 0 : goto exit;
375 : : }
376 : :
377 : 0 : sgl.num = n;
378 : : /* Out of place */
379 [ # # ]: 0 : if (is_oop) {
380 : 0 : dest_sgl.vec = dest_data_vec;
381 : 0 : vec.dest_sgl = &dest_sgl;
382 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
383 : : dest_data_vec, RTE_DIM(dest_data_vec));
384 [ # # # # ]: 0 : if (n < 0 || n > sop->m_dst->nb_segs) {
385 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
386 : 0 : goto exit;
387 : : }
388 : 0 : dest_sgl.num = n;
389 : : } else
390 : 0 : vec.dest_sgl = NULL;
391 : :
392 [ # # ]: 0 : if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
393 : : &enqueue_status) < 1) {
394 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
395 : 0 : goto exit;
396 : : }
397 : :
398 [ # # ]: 0 : if (enqueue_status == 0) {
399 : 0 : status = rte_cryptodev_raw_enqueue_done(ctx, 1);
400 [ # # ]: 0 : if (status < 0) {
401 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
402 : 0 : goto exit;
403 : : }
404 [ # # ]: 0 : } else if (enqueue_status < 0) {
405 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
406 : 0 : goto exit;
407 : : }
408 : :
409 : 0 : n = n_success = 0;
410 [ # # # # ]: 0 : while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
411 : 0 : n = rte_cryptodev_raw_dequeue_burst(ctx,
412 : : NULL, 1, post_process_raw_dp_op,
413 : : (void **)&ret_op, 0, &n_success,
414 : : &dequeue_status);
415 [ # # ]: 0 : if (dequeue_status < 0) {
416 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
417 : 0 : goto exit;
418 : : }
419 [ # # ]: 0 : if (n == 0)
420 : : rte_pause();
421 : : }
422 : :
423 [ # # # # ]: 0 : if (n == 1 && dequeue_status == 0) {
424 [ # # ]: 0 : if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
425 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
426 : 0 : goto exit;
427 : : }
428 : : }
429 : :
430 [ # # # # ]: 0 : op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
431 [ # # ]: 0 : ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
432 [ # # ]: 0 : n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
433 : : RTE_CRYPTO_OP_STATUS_SUCCESS;
434 : :
435 : 0 : exit:
436 : 0 : free(ctx);
437 : 0 : return ret;
438 : : }
439 : :
440 : : static void
441 : 0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
442 : : {
443 : : int32_t n, st;
444 : : struct rte_crypto_sym_op *sop;
445 : : union rte_crypto_sym_ofs ofs;
446 : : struct rte_crypto_sgl sgl;
447 : : struct rte_crypto_sym_vec symvec;
448 : : struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
449 : : struct rte_crypto_vec vec[UINT8_MAX];
450 : :
451 : : sop = op->sym;
452 : :
453 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
454 : : sop->aead.data.length, vec, RTE_DIM(vec));
455 : :
456 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
457 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
458 : 0 : return;
459 : : }
460 : :
461 : 0 : sgl.vec = vec;
462 : 0 : sgl.num = n;
463 : 0 : symvec.src_sgl = &sgl;
464 : 0 : symvec.iv = &iv_ptr;
465 : 0 : symvec.digest = &digest_ptr;
466 : 0 : symvec.aad = &aad_ptr;
467 : 0 : symvec.status = &st;
468 : 0 : symvec.num = 1;
469 : :
470 : : /* for CPU crypto the IOVA address is not required */
471 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
472 : 0 : digest_ptr.va = (void *)sop->aead.digest.data;
473 : 0 : aad_ptr.va = (void *)sop->aead.aad.data;
474 : :
475 : 0 : ofs.raw = 0;
476 : :
477 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
478 : : &symvec);
479 : :
480 [ # # ]: 0 : if (n != 1)
481 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
482 : : else
483 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
484 : : }
485 : :
486 : : static void
487 : 0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
488 : : {
489 : : int32_t n, st;
490 : : struct rte_crypto_sym_op *sop;
491 : : union rte_crypto_sym_ofs ofs;
492 : : struct rte_crypto_sgl sgl;
493 : : struct rte_crypto_sym_vec symvec;
494 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
495 : : struct rte_crypto_vec vec[UINT8_MAX];
496 : :
497 : : sop = op->sym;
498 : :
499 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
500 : : sop->auth.data.length, vec, RTE_DIM(vec));
501 : :
502 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
503 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
504 : 0 : return;
505 : : }
506 : :
507 : 0 : sgl.vec = vec;
508 : 0 : sgl.num = n;
509 : 0 : symvec.src_sgl = &sgl;
510 : 0 : symvec.iv = &iv_ptr;
511 : 0 : symvec.digest = &digest_ptr;
512 : 0 : symvec.status = &st;
513 : 0 : symvec.num = 1;
514 : :
515 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
516 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
517 : :
518 : 0 : ofs.raw = 0;
519 : 0 : ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
520 : 0 : ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
521 : 0 : (sop->cipher.data.offset + sop->cipher.data.length);
522 : :
523 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
524 : : &symvec);
525 : :
526 [ # # ]: 0 : if (n != 1)
527 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
528 : : else
529 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
530 : : }
531 : :
532 : : static struct rte_crypto_op *
533 : 0 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
534 : : {
535 : :
536 [ # # ]: 0 : RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
537 : :
538 [ # # ]: 0 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
539 : 0 : RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
540 : 0 : return NULL;
541 : : }
542 : :
543 : 0 : op = NULL;
544 : :
545 [ # # ]: 0 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
546 : : rte_pause();
547 : :
548 [ # # ]: 0 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
549 : 0 : RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
550 : 0 : return NULL;
551 : : }
552 : :
553 : : return op;
554 : : }
555 : :
556 : : static int
557 : 0 : testsuite_setup(void)
558 : : {
559 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
560 : : struct rte_cryptodev_info info;
561 : : uint32_t i = 0, nb_devs, dev_id;
562 : : uint16_t qp_id;
563 : :
564 : : memset(ts_params, 0, sizeof(*ts_params));
565 : :
566 : 0 : ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
567 [ # # ]: 0 : if (ts_params->mbuf_pool == NULL) {
568 : : /* Not already created so create */
569 : 0 : ts_params->mbuf_pool = rte_pktmbuf_pool_create(
570 : : "CRYPTO_MBUFPOOL",
571 : : NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
572 : 0 : rte_socket_id());
573 [ # # ]: 0 : if (ts_params->mbuf_pool == NULL) {
574 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
575 : 0 : return TEST_FAILED;
576 : : }
577 : : }
578 : :
579 : 0 : ts_params->large_mbuf_pool = rte_mempool_lookup(
580 : : "CRYPTO_LARGE_MBUFPOOL");
581 [ # # ]: 0 : if (ts_params->large_mbuf_pool == NULL) {
582 : : /* Not already created so create */
583 : 0 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
584 : : "CRYPTO_LARGE_MBUFPOOL",
585 : : 1, 0, 0, UINT16_MAX,
586 : 0 : rte_socket_id());
587 [ # # ]: 0 : if (ts_params->large_mbuf_pool == NULL) {
588 : 0 : RTE_LOG(ERR, USER1,
589 : : "Can't create CRYPTO_LARGE_MBUFPOOL\n");
590 : 0 : return TEST_FAILED;
591 : : }
592 : : }
593 : :
594 : 0 : ts_params->op_mpool = rte_crypto_op_pool_create(
595 : : "MBUF_CRYPTO_SYM_OP_POOL",
596 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC,
597 : : NUM_MBUFS, MBUF_CACHE_SIZE,
598 : : DEFAULT_NUM_XFORMS *
599 : : sizeof(struct rte_crypto_sym_xform) +
600 : : MAXIMUM_IV_LENGTH,
601 : 0 : rte_socket_id());
602 [ # # ]: 0 : if (ts_params->op_mpool == NULL) {
603 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
604 : 0 : return TEST_FAILED;
605 : : }
606 : :
607 : 0 : nb_devs = rte_cryptodev_count();
608 [ # # ]: 0 : if (nb_devs < 1) {
609 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
610 : 0 : return TEST_SKIPPED;
611 : : }
612 : :
613 [ # # ]: 0 : if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
614 : 0 : RTE_LOG(WARNING, USER1, "No %s devices found?\n",
615 : : rte_cryptodev_driver_name_get(gbl_driver_id));
616 : 0 : return TEST_SKIPPED;
617 : : }
618 : :
619 : : /* Create list of valid crypto devs */
620 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
621 : 0 : rte_cryptodev_info_get(i, &info);
622 [ # # ]: 0 : if (info.driver_id == gbl_driver_id)
623 : 0 : ts_params->valid_devs[ts_params->valid_dev_count++] = i;
624 : : }
625 : :
626 [ # # ]: 0 : if (ts_params->valid_dev_count < 1)
627 : : return TEST_FAILED;
628 : :
629 : : /* Set up all the qps on the first of the valid devices found */
630 : :
631 : 0 : dev_id = ts_params->valid_devs[0];
632 : :
633 : 0 : rte_cryptodev_info_get(dev_id, &info);
634 : :
635 : 0 : ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
636 : 0 : ts_params->conf.socket_id = SOCKET_ID_ANY;
637 : 0 : ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
638 : :
639 : : unsigned int session_size =
640 : 0 : rte_cryptodev_sym_get_private_session_size(dev_id);
641 : :
642 : : #ifdef RTE_LIB_SECURITY
643 : 0 : unsigned int security_session_size = rte_security_session_get_size(
644 : : rte_cryptodev_get_sec_ctx(dev_id));
645 : :
646 : : if (session_size < security_session_size)
647 : : session_size = security_session_size;
648 : : #endif
649 : : /*
650 : : * Create mempool with maximum number of sessions.
651 : : */
652 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
653 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
654 : 0 : RTE_LOG(ERR, USER1, "Device does not support "
655 : : "at least %u sessions\n",
656 : : MAX_NB_SESSIONS);
657 : 0 : return TEST_FAILED;
658 : : }
659 : :
660 : 0 : ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
661 : : "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
662 : : SOCKET_ID_ANY);
663 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
664 : : "session mempool allocation failed");
665 : :
666 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
667 : : &ts_params->conf),
668 : : "Failed to configure cryptodev %u with %u qps",
669 : : dev_id, ts_params->conf.nb_queue_pairs);
670 : :
671 : 0 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
672 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
673 : :
674 [ # # ]: 0 : for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
675 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
676 : : dev_id, qp_id, &ts_params->qp_conf,
677 : : rte_cryptodev_socket_id(dev_id)),
678 : : "Failed to setup queue pair %u on cryptodev %u",
679 : : qp_id, dev_id);
680 : : }
681 : :
682 : : return TEST_SUCCESS;
683 : : }
684 : :
685 : : static void
686 : 0 : testsuite_teardown(void)
687 : : {
688 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
689 : : int res;
690 : :
691 [ # # ]: 0 : if (ts_params->mbuf_pool != NULL) {
692 : 0 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
693 : : rte_mempool_avail_count(ts_params->mbuf_pool));
694 : : }
695 : :
696 [ # # ]: 0 : if (ts_params->op_mpool != NULL) {
697 : 0 : RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
698 : : rte_mempool_avail_count(ts_params->op_mpool));
699 : : }
700 : :
701 [ # # ]: 0 : if (ts_params->session_mpool != NULL) {
702 : 0 : rte_mempool_free(ts_params->session_mpool);
703 : 0 : ts_params->session_mpool = NULL;
704 : : }
705 : :
706 : 0 : res = rte_cryptodev_close(ts_params->valid_devs[0]);
707 [ # # ]: 0 : if (res)
708 : 0 : RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
709 : 0 : }
710 : :
711 : : static int
712 : 0 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
713 : : const int *algs, uint16_t num_algs)
714 : : {
715 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
716 : : bool some_alg_supported = FALSE;
717 : : uint16_t i;
718 : :
719 [ # # ]: 0 : for (i = 0; i < num_algs && !some_alg_supported; i++) {
720 : 0 : struct rte_cryptodev_sym_capability_idx alg = {
721 : 0 : type, {algs[i]}
722 : : };
723 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(dev_id,
724 : : &alg) != NULL)
725 : : some_alg_supported = TRUE;
726 : : }
727 [ # # ]: 0 : if (!some_alg_supported)
728 : 0 : return TEST_SKIPPED;
729 : :
730 : : return 0;
731 : : }
732 : :
733 : : int
734 : 0 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
735 : : uint16_t num_ciphers)
736 : : {
737 : 0 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
738 : : (const int *) ciphers, num_ciphers);
739 : : }
740 : :
741 : : int
742 : 0 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
743 : : uint16_t num_auths)
744 : : {
745 : 0 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
746 : : (const int *) auths, num_auths);
747 : : }
748 : :
749 : : int
750 : 0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
751 : : uint16_t num_aeads)
752 : : {
753 : 0 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
754 : : (const int *) aeads, num_aeads);
755 : : }
756 : :
757 : : static int
758 : 0 : null_testsuite_setup(void)
759 : : {
760 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
761 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
762 : : struct rte_cryptodev_info dev_info;
763 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
764 : : RTE_CRYPTO_CIPHER_NULL
765 : : };
766 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
767 : : RTE_CRYPTO_AUTH_NULL
768 : : };
769 : :
770 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
771 : :
772 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
773 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
774 : : "testsuite not met\n");
775 : 0 : return TEST_SKIPPED;
776 : : }
777 : :
778 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
779 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
780 : : RTE_DIM(auths)) != 0) {
781 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for NULL "
782 : : "testsuite not met\n");
783 : 0 : return TEST_SKIPPED;
784 : : }
785 : :
786 : : return 0;
787 : : }
788 : :
789 : : static int
790 : 0 : crypto_gen_testsuite_setup(void)
791 : : {
792 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
793 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
794 : : struct rte_cryptodev_info dev_info;
795 : :
796 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
797 : :
798 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
799 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
800 : : "testsuite not met\n");
801 : 0 : return TEST_SKIPPED;
802 : : }
803 : :
804 : : return 0;
805 : : }
806 : :
807 : : #ifdef RTE_LIB_SECURITY
808 : : static int
809 : 0 : ipsec_proto_testsuite_setup(void)
810 : : {
811 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
812 : : struct crypto_unittest_params *ut_params = &unittest_params;
813 : : struct rte_cryptodev_info dev_info;
814 : : int ret = 0;
815 : :
816 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
817 : :
818 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
819 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
820 : : "testsuite not met\n");
821 : 0 : return TEST_SKIPPED;
822 : : }
823 : :
824 : : /* Reconfigure to enable security */
825 : 0 : ret = dev_configure_and_start(0);
826 [ # # ]: 0 : if (ret != TEST_SUCCESS)
827 : : return ret;
828 : :
829 : : /* Set action type */
830 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
831 : :
832 [ # # ]: 0 : if (security_proto_supported(
833 : : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
834 : : RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
835 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
836 : : "test not met\n");
837 : : ret = TEST_SKIPPED;
838 : : }
839 : :
840 : 0 : test_ipsec_alg_list_populate();
841 : 0 : test_ipsec_ah_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 : 0 : pdcp_proto_testsuite_setup(void)
854 : : {
855 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
856 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
857 : : struct rte_cryptodev_info dev_info;
858 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
859 : : RTE_CRYPTO_CIPHER_NULL,
860 : : RTE_CRYPTO_CIPHER_AES_CTR,
861 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
862 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
863 : : };
864 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
865 : : RTE_CRYPTO_AUTH_NULL,
866 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
867 : : RTE_CRYPTO_AUTH_AES_CMAC,
868 : : RTE_CRYPTO_AUTH_ZUC_EIA3
869 : : };
870 : :
871 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
872 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
873 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
874 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
875 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
876 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
877 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
878 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
879 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
880 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
881 : :
882 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
883 : :
884 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
885 : : !(dev_info.feature_flags &
886 : : RTE_CRYPTODEV_FF_SECURITY)) {
887 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
888 : : "testsuite not met\n");
889 : 0 : return TEST_SKIPPED;
890 : : }
891 : :
892 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
893 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
894 : : RTE_DIM(auths)) != 0) {
895 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
896 : : "testsuite not met\n");
897 : 0 : return TEST_SKIPPED;
898 : : }
899 : :
900 : : return 0;
901 : : }
902 : :
903 : : static int
904 : 0 : docsis_proto_testsuite_setup(void)
905 : : {
906 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
907 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
908 : : struct rte_cryptodev_info dev_info;
909 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
910 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
911 : : };
912 : :
913 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
914 : :
915 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
916 : : !(dev_info.feature_flags &
917 : : RTE_CRYPTODEV_FF_SECURITY)) {
918 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
919 : : "Proto testsuite not met\n");
920 : 0 : return TEST_SKIPPED;
921 : : }
922 : :
923 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
924 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
925 : : "testsuite not met\n");
926 : 0 : return TEST_SKIPPED;
927 : : }
928 : :
929 : : return 0;
930 : : }
931 : : #endif
932 : :
933 : : static int
934 : 0 : aes_ccm_auth_testsuite_setup(void)
935 : : {
936 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
937 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
938 : : struct rte_cryptodev_info dev_info;
939 : 0 : const enum rte_crypto_aead_algorithm aeads[] = {
940 : : RTE_CRYPTO_AEAD_AES_CCM
941 : : };
942 : :
943 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
944 : :
945 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
946 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
947 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
948 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
949 : : "testsuite not met\n");
950 : 0 : return TEST_SKIPPED;
951 : : }
952 : :
953 [ # # ]: 0 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
954 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
955 : : "testsuite not met\n");
956 : 0 : return TEST_SKIPPED;
957 : : }
958 : :
959 : : return 0;
960 : : }
961 : :
962 : : static int
963 : 0 : aes_gcm_auth_testsuite_setup(void)
964 : : {
965 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
966 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
967 : : struct rte_cryptodev_info dev_info;
968 : 0 : const enum rte_crypto_aead_algorithm aeads[] = {
969 : : RTE_CRYPTO_AEAD_AES_GCM
970 : : };
971 : :
972 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
973 : :
974 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
975 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
976 : : "testsuite not met\n");
977 : 0 : return TEST_SKIPPED;
978 : : }
979 : :
980 [ # # ]: 0 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
981 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
982 : : "testsuite not met\n");
983 : 0 : return TEST_SKIPPED;
984 : : }
985 : :
986 : : return 0;
987 : : }
988 : :
989 : : static int
990 : 0 : aes_gmac_auth_testsuite_setup(void)
991 : : {
992 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
993 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
994 : : struct rte_cryptodev_info dev_info;
995 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
996 : : RTE_CRYPTO_AUTH_AES_GMAC
997 : : };
998 : :
999 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1000 : :
1001 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1002 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1003 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1004 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1005 : : "testsuite not met\n");
1006 : 0 : return TEST_SKIPPED;
1007 : : }
1008 : :
1009 [ # # ]: 0 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1010 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1011 : : "testsuite not met\n");
1012 : 0 : return TEST_SKIPPED;
1013 : : }
1014 : :
1015 : : return 0;
1016 : : }
1017 : :
1018 : : static int
1019 : 0 : chacha20_poly1305_testsuite_setup(void)
1020 : : {
1021 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1022 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1023 : : struct rte_cryptodev_info dev_info;
1024 : 0 : const enum rte_crypto_aead_algorithm aeads[] = {
1025 : : RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1026 : : };
1027 : :
1028 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1029 : :
1030 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1031 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1032 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1033 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1034 : : "Chacha20-Poly1305 testsuite not met\n");
1035 : 0 : return TEST_SKIPPED;
1036 : : }
1037 : :
1038 [ # # ]: 0 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1039 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for "
1040 : : "Chacha20-Poly1305 testsuite not met\n");
1041 : 0 : return TEST_SKIPPED;
1042 : : }
1043 : :
1044 : : return 0;
1045 : : }
1046 : :
1047 : : static int
1048 : 0 : snow3g_testsuite_setup(void)
1049 : : {
1050 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1051 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1052 : : struct rte_cryptodev_info dev_info;
1053 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1054 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1055 : :
1056 : : };
1057 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1058 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2
1059 : : };
1060 : :
1061 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1062 : :
1063 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1064 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1065 : : "testsuite not met\n");
1066 : 0 : return TEST_SKIPPED;
1067 : : }
1068 : :
1069 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1070 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1071 : : RTE_DIM(auths)) != 0) {
1072 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1073 : : "testsuite not met\n");
1074 : 0 : return TEST_SKIPPED;
1075 : : }
1076 : :
1077 : : return 0;
1078 : : }
1079 : :
1080 : : static int
1081 : 0 : zuc_testsuite_setup(void)
1082 : : {
1083 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1084 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1085 : : struct rte_cryptodev_info dev_info;
1086 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1087 : : RTE_CRYPTO_CIPHER_ZUC_EEA3
1088 : : };
1089 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1090 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1091 : : };
1092 : :
1093 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1094 : :
1095 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1096 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1097 : : "testsuite not met\n");
1098 : 0 : return TEST_SKIPPED;
1099 : : }
1100 : :
1101 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1102 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1103 : : RTE_DIM(auths)) != 0) {
1104 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1105 : : "testsuite not met\n");
1106 : 0 : return TEST_SKIPPED;
1107 : : }
1108 : :
1109 : : return 0;
1110 : : }
1111 : :
1112 : : static int
1113 : 0 : hmac_md5_auth_testsuite_setup(void)
1114 : : {
1115 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1116 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1117 : : struct rte_cryptodev_info dev_info;
1118 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1119 : : RTE_CRYPTO_AUTH_MD5_HMAC
1120 : : };
1121 : :
1122 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1123 : :
1124 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1125 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1126 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1127 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1128 : : "Auth testsuite not met\n");
1129 : 0 : return TEST_SKIPPED;
1130 : : }
1131 : :
1132 [ # # ]: 0 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1133 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1134 : : "testsuite not met\n");
1135 : 0 : return TEST_SKIPPED;
1136 : : }
1137 : :
1138 : : return 0;
1139 : : }
1140 : :
1141 : : static int
1142 : 0 : kasumi_testsuite_setup(void)
1143 : : {
1144 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1145 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1146 : : struct rte_cryptodev_info dev_info;
1147 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1148 : : RTE_CRYPTO_CIPHER_KASUMI_F8
1149 : : };
1150 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1151 : : RTE_CRYPTO_AUTH_KASUMI_F9
1152 : : };
1153 : :
1154 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1155 : :
1156 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1157 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1158 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1159 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1160 : : "testsuite not met\n");
1161 : 0 : return TEST_SKIPPED;
1162 : : }
1163 : :
1164 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1165 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1166 : : RTE_DIM(auths)) != 0) {
1167 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1168 : : "testsuite not met\n");
1169 : 0 : return TEST_SKIPPED;
1170 : : }
1171 : :
1172 : : return 0;
1173 : : }
1174 : :
1175 : : static int
1176 : 0 : negative_aes_gcm_testsuite_setup(void)
1177 : : {
1178 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1179 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1180 : : struct rte_cryptodev_info dev_info;
1181 : 0 : const enum rte_crypto_aead_algorithm aeads[] = {
1182 : : RTE_CRYPTO_AEAD_AES_GCM
1183 : : };
1184 : :
1185 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1186 : :
1187 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1188 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1189 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1190 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1191 : : "AES GCM testsuite not met\n");
1192 : 0 : return TEST_SKIPPED;
1193 : : }
1194 : :
1195 [ # # ]: 0 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1196 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1197 : : "AES GCM testsuite not met\n");
1198 : 0 : return TEST_SKIPPED;
1199 : : }
1200 : :
1201 : : return 0;
1202 : : }
1203 : :
1204 : : static int
1205 : 0 : negative_aes_gmac_testsuite_setup(void)
1206 : : {
1207 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1208 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1209 : : struct rte_cryptodev_info dev_info;
1210 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1211 : : RTE_CRYPTO_AUTH_AES_GMAC
1212 : : };
1213 : :
1214 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1215 : :
1216 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1217 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1218 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1219 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1220 : : "AES GMAC testsuite not met\n");
1221 : 0 : return TEST_SKIPPED;
1222 : : }
1223 : :
1224 [ # # ]: 0 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1225 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1226 : : "AES GMAC testsuite not met\n");
1227 : 0 : return TEST_SKIPPED;
1228 : : }
1229 : :
1230 : : return 0;
1231 : : }
1232 : :
1233 : : static int
1234 : 0 : mixed_cipher_hash_testsuite_setup(void)
1235 : : {
1236 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1237 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1238 : : struct rte_cryptodev_info dev_info;
1239 : : uint64_t feat_flags;
1240 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1241 : : RTE_CRYPTO_CIPHER_NULL,
1242 : : RTE_CRYPTO_CIPHER_AES_CTR,
1243 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
1244 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1245 : : };
1246 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1247 : : RTE_CRYPTO_AUTH_NULL,
1248 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1249 : : RTE_CRYPTO_AUTH_AES_CMAC,
1250 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1251 : : };
1252 : :
1253 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1254 : 0 : feat_flags = dev_info.feature_flags;
1255 : :
1256 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1257 [ # # ]: 0 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1258 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1259 : : "Cipher Hash testsuite not met\n");
1260 : 0 : return TEST_SKIPPED;
1261 : : }
1262 : :
1263 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1264 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1265 : : RTE_DIM(auths)) != 0) {
1266 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1267 : : "Cipher Hash testsuite not met\n");
1268 : 0 : return TEST_SKIPPED;
1269 : : }
1270 : :
1271 : : return 0;
1272 : : }
1273 : :
1274 : : static int
1275 : 0 : esn_testsuite_setup(void)
1276 : : {
1277 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1278 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1279 : : struct rte_cryptodev_info dev_info;
1280 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1281 : : RTE_CRYPTO_CIPHER_AES_CBC
1282 : : };
1283 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1284 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1285 : : };
1286 : :
1287 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1288 : :
1289 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1290 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1291 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1292 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1293 : : "testsuite not met\n");
1294 : 0 : return TEST_SKIPPED;
1295 : : }
1296 : :
1297 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1298 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1299 : : RTE_DIM(auths)) != 0) {
1300 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1301 : : "testsuite not met\n");
1302 : 0 : return TEST_SKIPPED;
1303 : : }
1304 : :
1305 : : return 0;
1306 : : }
1307 : :
1308 : : static int
1309 : 0 : multi_session_testsuite_setup(void)
1310 : : {
1311 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1312 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1313 : : struct rte_cryptodev_info dev_info;
1314 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1315 : : RTE_CRYPTO_CIPHER_AES_CBC
1316 : : };
1317 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1318 : : RTE_CRYPTO_AUTH_SHA512_HMAC
1319 : : };
1320 : :
1321 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1322 : :
1323 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1324 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1325 : : "Session testsuite not met\n");
1326 : 0 : return TEST_SKIPPED;
1327 : : }
1328 : :
1329 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1330 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1331 : : RTE_DIM(auths)) != 0) {
1332 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1333 : : "Session testsuite not met\n");
1334 : 0 : return TEST_SKIPPED;
1335 : : }
1336 : :
1337 : : return 0;
1338 : : }
1339 : :
1340 : : static int
1341 : 0 : negative_hmac_sha1_testsuite_setup(void)
1342 : : {
1343 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1344 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
1345 : : struct rte_cryptodev_info dev_info;
1346 : 0 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1347 : : RTE_CRYPTO_CIPHER_AES_CBC
1348 : : };
1349 : 0 : const enum rte_crypto_auth_algorithm auths[] = {
1350 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1351 : : };
1352 : :
1353 : 0 : rte_cryptodev_info_get(dev_id, &dev_info);
1354 : :
1355 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1356 [ # # ]: 0 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1357 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1358 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1359 : : "HMAC SHA1 testsuite not met\n");
1360 : 0 : return TEST_SKIPPED;
1361 : : }
1362 : :
1363 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1364 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1365 : : RTE_DIM(auths)) != 0) {
1366 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1367 : : "HMAC SHA1 testsuite not met\n");
1368 : 0 : return TEST_SKIPPED;
1369 : : }
1370 : :
1371 : : return 0;
1372 : : }
1373 : :
1374 : : static int
1375 : 0 : dev_configure_and_start(uint64_t ff_disable)
1376 : : {
1377 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1378 : : struct crypto_unittest_params *ut_params = &unittest_params;
1379 : :
1380 : : uint16_t qp_id;
1381 : :
1382 : : /* Clear unit test parameters before running test */
1383 : : memset(ut_params, 0, sizeof(*ut_params));
1384 : :
1385 : : /* Reconfigure device to default parameters */
1386 : 0 : ts_params->conf.socket_id = SOCKET_ID_ANY;
1387 : 0 : ts_params->conf.ff_disable = ff_disable;
1388 : 0 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1389 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
1390 : :
1391 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1392 : : &ts_params->conf),
1393 : : "Failed to configure cryptodev %u",
1394 : : ts_params->valid_devs[0]);
1395 : :
1396 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1397 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1398 : : ts_params->valid_devs[0], qp_id,
1399 : : &ts_params->qp_conf,
1400 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1401 : : "Failed to setup queue pair %u on cryptodev %u",
1402 : : qp_id, ts_params->valid_devs[0]);
1403 : : }
1404 : :
1405 : :
1406 : 0 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1407 : :
1408 : : /* Start the device */
1409 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1410 : : "Failed to start cryptodev %u",
1411 : : ts_params->valid_devs[0]);
1412 : :
1413 : : return TEST_SUCCESS;
1414 : : }
1415 : :
1416 : : int
1417 : 0 : ut_setup(void)
1418 : : {
1419 : : /* Configure and start the device with security feature disabled */
1420 : 0 : return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1421 : : }
1422 : :
1423 : : static int
1424 : 0 : ut_setup_security(void)
1425 : : {
1426 : : /* Configure and start the device with no features disabled */
1427 : 0 : return dev_configure_and_start(0);
1428 : : }
1429 : :
1430 : : static int
1431 : 0 : ut_setup_security_rx_inject(void)
1432 : : {
1433 : 0 : struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1434 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1435 : 0 : struct rte_eth_conf port_conf = {
1436 : : .rxmode = {
1437 : : .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1438 : : RTE_ETH_RX_OFFLOAD_SECURITY,
1439 : : },
1440 : : .txmode = {
1441 : : .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1442 : : },
1443 : : .lpbk_mode = 1, /* Enable loopback */
1444 : : };
1445 : : struct rte_cryptodev_info dev_info;
1446 : 0 : struct rte_eth_rxconf rx_conf = {
1447 : : .rx_thresh = {
1448 : : .pthresh = 8,
1449 : : .hthresh = 8,
1450 : : .wthresh = 8,
1451 : : },
1452 : : .rx_free_thresh = 32,
1453 : : };
1454 : : uint16_t nb_ports;
1455 : : void *sec_ctx;
1456 : : int ret;
1457 : :
1458 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1459 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1460 : : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1461 : 0 : RTE_LOG(INFO, USER1,
1462 : : "Feature requirements for IPsec Rx inject test case not met\n");
1463 : 0 : return TEST_SKIPPED;
1464 : : }
1465 : :
1466 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1467 [ # # ]: 0 : if (sec_ctx == NULL)
1468 : : return TEST_SKIPPED;
1469 : :
1470 : 0 : nb_ports = rte_eth_dev_count_avail();
1471 [ # # ]: 0 : if (nb_ports == 0)
1472 : : return TEST_SKIPPED;
1473 : :
1474 : 0 : ret = rte_eth_dev_configure(0 /* port_id */,
1475 : : 1 /* nb_rx_queue */,
1476 : : 0 /* nb_tx_queue */,
1477 : : &port_conf);
1478 [ # # ]: 0 : if (ret) {
1479 : : printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1480 : 0 : return TEST_SKIPPED;
1481 : : }
1482 : :
1483 : : /* Rx queue setup */
1484 : 0 : ret = rte_eth_rx_queue_setup(0 /* port_id */,
1485 : : 0 /* rx_queue_id */,
1486 : : 1024 /* nb_rx_desc */,
1487 : : SOCKET_ID_ANY,
1488 : : &rx_conf,
1489 : : mbuf_pool);
1490 [ # # ]: 0 : if (ret) {
1491 : : printf("Could not setup eth port 0 queue 0\n");
1492 : 0 : return TEST_SKIPPED;
1493 : : }
1494 : :
1495 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1496 [ # # ]: 0 : if (ret) {
1497 : : printf("Could not enable Rx inject offload");
1498 : 0 : return TEST_SKIPPED;
1499 : : }
1500 : :
1501 : 0 : ret = rte_eth_dev_start(0);
1502 [ # # ]: 0 : if (ret) {
1503 : : printf("Could not start ethdev");
1504 : 0 : return TEST_SKIPPED;
1505 : : }
1506 : :
1507 : 0 : ret = rte_eth_promiscuous_enable(0);
1508 [ # # ]: 0 : if (ret) {
1509 : : printf("Could not enable promiscuous mode");
1510 : 0 : return TEST_SKIPPED;
1511 : : }
1512 : :
1513 : : /* Configure and start cryptodev with no features disabled */
1514 : 0 : return dev_configure_and_start(0);
1515 : : }
1516 : :
1517 : : void
1518 : 0 : ut_teardown(void)
1519 : : {
1520 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1521 : : struct crypto_unittest_params *ut_params = &unittest_params;
1522 : :
1523 : : /* free crypto session structure */
1524 : : #ifdef RTE_LIB_SECURITY
1525 [ # # ]: 0 : if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1526 [ # # ]: 0 : if (ut_params->sec_session) {
1527 : 0 : rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1528 : 0 : (ts_params->valid_devs[0]),
1529 : : ut_params->sec_session);
1530 : 0 : ut_params->sec_session = NULL;
1531 : : }
1532 : : } else
1533 : : #endif
1534 : : {
1535 [ # # ]: 0 : if (ut_params->sess) {
1536 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1537 : : ut_params->sess);
1538 : 0 : ut_params->sess = NULL;
1539 : : }
1540 : : }
1541 : :
1542 : : /* free crypto operation structure */
1543 : 0 : rte_crypto_op_free(ut_params->op);
1544 : :
1545 : : /*
1546 : : * free mbuf - both obuf and ibuf are usually the same,
1547 : : * so check if they point at the same address is necessary,
1548 : : * to avoid freeing the mbuf twice.
1549 : : */
1550 [ # # ]: 0 : if (ut_params->obuf) {
1551 : 0 : rte_pktmbuf_free(ut_params->obuf);
1552 [ # # ]: 0 : if (ut_params->ibuf == ut_params->obuf)
1553 : 0 : ut_params->ibuf = 0;
1554 : 0 : ut_params->obuf = 0;
1555 : : }
1556 [ # # ]: 0 : if (ut_params->ibuf) {
1557 : 0 : rte_pktmbuf_free(ut_params->ibuf);
1558 : 0 : ut_params->ibuf = 0;
1559 : : }
1560 : :
1561 [ # # ]: 0 : if (ts_params->mbuf_pool != NULL)
1562 : 0 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1563 : : rte_mempool_avail_count(ts_params->mbuf_pool));
1564 : :
1565 : : /* Stop the device */
1566 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1567 : 0 : }
1568 : :
1569 : : static void
1570 : 0 : ut_teardown_rx_inject(void)
1571 : : {
1572 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1573 : : void *sec_ctx;
1574 : : int ret;
1575 : :
1576 [ # # ]: 0 : if (rte_eth_dev_count_avail() != 0) {
1577 : 0 : ret = rte_eth_dev_reset(0);
1578 [ # # ]: 0 : if (ret)
1579 : : printf("Could not reset eth port 0");
1580 : :
1581 : : }
1582 : :
1583 : 0 : ut_teardown();
1584 : :
1585 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1586 [ # # ]: 0 : if (sec_ctx == NULL)
1587 : : return;
1588 : :
1589 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1590 [ # # ]: 0 : if (ret) {
1591 : : printf("Could not disable Rx inject offload");
1592 : 0 : return;
1593 : : }
1594 : : }
1595 : :
1596 : : static int
1597 : 0 : test_device_configure_invalid_dev_id(void)
1598 : : {
1599 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1600 : : uint16_t dev_id, num_devs = 0;
1601 : :
1602 [ # # ]: 0 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1603 : : "Need at least %d devices for test", 1);
1604 : :
1605 : : /* valid dev_id values */
1606 : 0 : dev_id = ts_params->valid_devs[0];
1607 : :
1608 : : /* Stop the device in case it's started so it can be configured */
1609 : 0 : rte_cryptodev_stop(dev_id);
1610 : :
1611 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1612 : : "Failed test for rte_cryptodev_configure: "
1613 : : "invalid dev_num %u", dev_id);
1614 : :
1615 : : /* invalid dev_id values */
1616 : : dev_id = num_devs;
1617 : :
1618 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1619 : : "Failed test for rte_cryptodev_configure: "
1620 : : "invalid dev_num %u", dev_id);
1621 : :
1622 : : dev_id = 0xff;
1623 : :
1624 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1625 : : "Failed test for rte_cryptodev_configure:"
1626 : : "invalid dev_num %u", dev_id);
1627 : :
1628 : : return TEST_SUCCESS;
1629 : : }
1630 : :
1631 : : static int
1632 : 0 : test_device_configure_invalid_queue_pair_ids(void)
1633 : : {
1634 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1635 : 0 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1636 : :
1637 : : /* Stop the device in case it's started so it can be configured */
1638 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1639 : :
1640 : : /* valid - max value queue pairs */
1641 : 0 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1642 : :
1643 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1644 : : &ts_params->conf),
1645 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1646 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1647 : :
1648 : : /* valid - one queue pairs */
1649 : 0 : ts_params->conf.nb_queue_pairs = 1;
1650 : :
1651 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1652 : : &ts_params->conf),
1653 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1654 : : ts_params->valid_devs[0],
1655 : : ts_params->conf.nb_queue_pairs);
1656 : :
1657 : :
1658 : : /* invalid - zero queue pairs */
1659 : 0 : ts_params->conf.nb_queue_pairs = 0;
1660 : :
1661 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1662 : : &ts_params->conf),
1663 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1664 : : " invalid qps: %u",
1665 : : ts_params->valid_devs[0],
1666 : : ts_params->conf.nb_queue_pairs);
1667 : :
1668 : :
1669 : : /* invalid - max value supported by field queue pairs */
1670 : 0 : ts_params->conf.nb_queue_pairs = UINT16_MAX;
1671 : :
1672 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1673 : : &ts_params->conf),
1674 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1675 : : " invalid qps: %u",
1676 : : ts_params->valid_devs[0],
1677 : : ts_params->conf.nb_queue_pairs);
1678 : :
1679 : :
1680 : : /* invalid - max value + 1 queue pairs */
1681 : 0 : ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1682 : :
1683 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1684 : : &ts_params->conf),
1685 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1686 : : " invalid qps: %u",
1687 : : ts_params->valid_devs[0],
1688 : : ts_params->conf.nb_queue_pairs);
1689 : :
1690 : : /* revert to original testsuite value */
1691 : 0 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1692 : :
1693 : 0 : return TEST_SUCCESS;
1694 : : }
1695 : :
1696 : : static int
1697 : 0 : test_queue_pair_descriptor_setup(void)
1698 : : {
1699 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1700 : 0 : struct rte_cryptodev_qp_conf qp_conf = {
1701 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1702 : : };
1703 : : uint16_t qp_id;
1704 : :
1705 : : /* Stop the device in case it's started so it can be configured */
1706 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1707 : :
1708 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1709 : : &ts_params->conf),
1710 : : "Failed to configure cryptodev %u",
1711 : : ts_params->valid_devs[0]);
1712 : :
1713 : : /*
1714 : : * Test various ring sizes on this device. memzones can't be
1715 : : * freed so are re-used if ring is released and re-created.
1716 : : */
1717 : 0 : qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1718 : 0 : qp_conf.mp_session = ts_params->session_mpool;
1719 : :
1720 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1721 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1722 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1723 : : rte_cryptodev_socket_id(
1724 : : ts_params->valid_devs[0])),
1725 : : "Failed test for "
1726 : : "rte_cryptodev_queue_pair_setup: num_inflights "
1727 : : "%u on qp %u on cryptodev %u",
1728 : : qp_conf.nb_descriptors, qp_id,
1729 : : ts_params->valid_devs[0]);
1730 : : }
1731 : :
1732 : 0 : qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1733 : :
1734 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1735 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1736 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1737 : : rte_cryptodev_socket_id(
1738 : : ts_params->valid_devs[0])),
1739 : : "Failed test for"
1740 : : " rte_cryptodev_queue_pair_setup: num_inflights"
1741 : : " %u on qp %u on cryptodev %u",
1742 : : qp_conf.nb_descriptors, qp_id,
1743 : : ts_params->valid_devs[0]);
1744 : : }
1745 : :
1746 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1747 : :
1748 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1749 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1750 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1751 : : rte_cryptodev_socket_id(
1752 : : ts_params->valid_devs[0])),
1753 : : "Failed test for "
1754 : : "rte_cryptodev_queue_pair_setup: num_inflights"
1755 : : " %u on qp %u on cryptodev %u",
1756 : : qp_conf.nb_descriptors, qp_id,
1757 : : ts_params->valid_devs[0]);
1758 : : }
1759 : :
1760 : 0 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1761 : :
1762 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1763 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1764 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1765 : : rte_cryptodev_socket_id(
1766 : : ts_params->valid_devs[0])),
1767 : : "Failed test for"
1768 : : " rte_cryptodev_queue_pair_setup:"
1769 : : "num_inflights %u on qp %u on cryptodev %u",
1770 : : qp_conf.nb_descriptors, qp_id,
1771 : : ts_params->valid_devs[0]);
1772 : : }
1773 : :
1774 : : /* test invalid queue pair id */
1775 : 0 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1776 : :
1777 : : qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1778 : :
1779 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1780 : : ts_params->valid_devs[0],
1781 : : qp_id, &qp_conf,
1782 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1783 : : "Failed test for rte_cryptodev_queue_pair_setup:"
1784 : : "invalid qp %u on cryptodev %u",
1785 : : qp_id, ts_params->valid_devs[0]);
1786 : :
1787 : : qp_id = 0xffff; /*invalid*/
1788 : :
1789 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1790 : : ts_params->valid_devs[0],
1791 : : qp_id, &qp_conf,
1792 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1793 : : "Failed test for rte_cryptodev_queue_pair_setup:"
1794 : : "invalid qp %u on cryptodev %u",
1795 : : qp_id, ts_params->valid_devs[0]);
1796 : :
1797 : : return TEST_SUCCESS;
1798 : : }
1799 : :
1800 : : /* ***** Plaintext data for tests ***** */
1801 : :
1802 : : const char catch_22_quote_1[] =
1803 : : "There was only one catch and that was Catch-22, which "
1804 : : "specified that a concern for one's safety in the face of "
1805 : : "dangers that were real and immediate was the process of a "
1806 : : "rational mind. Orr was crazy and could be grounded. All he "
1807 : : "had to do was ask; and as soon as he did, he would no longer "
1808 : : "be crazy and would have to fly more missions. Orr would be "
1809 : : "crazy to fly more missions and sane if he didn't, but if he "
1810 : : "was sane he had to fly them. If he flew them he was crazy "
1811 : : "and didn't have to; but if he didn't want to he was sane and "
1812 : : "had to. Yossarian was moved very deeply by the absolute "
1813 : : "simplicity of this clause of Catch-22 and let out a "
1814 : : "respectful whistle. \"That's some catch, that Catch-22\", he "
1815 : : "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1816 : :
1817 : : const char catch_22_quote[] =
1818 : : "What a lousy earth! He wondered how many people were "
1819 : : "destitute that same night even in his own prosperous country, "
1820 : : "how many homes were shanties, how many husbands were drunk "
1821 : : "and wives socked, and how many children were bullied, abused, "
1822 : : "or abandoned. How many families hungered for food they could "
1823 : : "not afford to buy? How many hearts were broken? How many "
1824 : : "suicides would take place that same night, how many people "
1825 : : "would go insane? How many cockroaches and landlords would "
1826 : : "triumph? How many winners were losers, successes failures, "
1827 : : "and rich men poor men? How many wise guys were stupid? How "
1828 : : "many happy endings were unhappy endings? How many honest men "
1829 : : "were liars, brave men cowards, loyal men traitors, how many "
1830 : : "sainted men were corrupt, how many people in positions of "
1831 : : "trust had sold their souls to bodyguards, how many had never "
1832 : : "had souls? How many straight-and-narrow paths were crooked "
1833 : : "paths? How many best families were worst families and how "
1834 : : "many good people were bad people? When you added them all up "
1835 : : "and then subtracted, you might be left with only the children, "
1836 : : "and perhaps with Albert Einstein and an old violinist or "
1837 : : "sculptor somewhere.";
1838 : :
1839 : : #define QUOTE_480_BYTES (480)
1840 : : #define QUOTE_512_BYTES (512)
1841 : : #define QUOTE_768_BYTES (768)
1842 : : #define QUOTE_1024_BYTES (1024)
1843 : :
1844 : :
1845 : :
1846 : : /* ***** SHA1 Hash Tests ***** */
1847 : :
1848 : : #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1849 : :
1850 : : static uint8_t hmac_sha1_key[] = {
1851 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1852 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1853 : : 0xDE, 0xF4, 0xDE, 0xAD };
1854 : :
1855 : : /* ***** SHA224 Hash Tests ***** */
1856 : :
1857 : : #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1858 : :
1859 : :
1860 : : /* ***** AES-CBC Cipher Tests ***** */
1861 : :
1862 : : #define CIPHER_KEY_LENGTH_AES_CBC (16)
1863 : : #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1864 : :
1865 : : static uint8_t aes_cbc_key[] = {
1866 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1867 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1868 : :
1869 : : static uint8_t aes_cbc_iv[] = {
1870 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1871 : : 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1872 : :
1873 : :
1874 : : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1875 : :
1876 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1877 : : 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1878 : : 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1879 : : 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1880 : : 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1881 : : 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1882 : : 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1883 : : 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1884 : : 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1885 : : 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1886 : : 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1887 : : 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1888 : : 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1889 : : 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1890 : : 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1891 : : 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1892 : : 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1893 : : 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1894 : : 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1895 : : 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1896 : : 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1897 : : 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1898 : : 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1899 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1900 : : 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1901 : : 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1902 : : 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1903 : : 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1904 : : 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1905 : : 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1906 : : 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1907 : : 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1908 : : 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1909 : : 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1910 : : 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1911 : : 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1912 : : 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1913 : : 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1914 : : 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1915 : : 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1916 : : 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1917 : : 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1918 : : 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1919 : : 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1920 : : 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1921 : : 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1922 : : 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1923 : : 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1924 : : 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1925 : : 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1926 : : 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1927 : : 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1928 : : 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1929 : : 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1930 : : 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1931 : : 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1932 : : 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1933 : : 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1934 : : 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1935 : : 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1936 : : 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1937 : : 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1938 : : 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1939 : : 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1940 : : 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1941 : : };
1942 : :
1943 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1944 : : 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1945 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1946 : : 0x18, 0x8c, 0x1d, 0x32
1947 : : };
1948 : :
1949 : :
1950 : : /* Multisession Vector context Test */
1951 : : /*Begin Session 0 */
1952 : : static uint8_t ms_aes_cbc_key0[] = {
1953 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1954 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1955 : : };
1956 : :
1957 : : static uint8_t ms_aes_cbc_iv0[] = {
1958 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1959 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1960 : : };
1961 : :
1962 : : static const uint8_t ms_aes_cbc_cipher0[] = {
1963 : : 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1964 : : 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1965 : : 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1966 : : 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1967 : : 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1968 : : 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1969 : : 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1970 : : 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1971 : : 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1972 : : 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1973 : : 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1974 : : 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1975 : : 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1976 : : 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1977 : : 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1978 : : 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1979 : : 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1980 : : 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1981 : : 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1982 : : 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1983 : : 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1984 : : 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1985 : : 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1986 : : 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1987 : : 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1988 : : 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1989 : : 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1990 : : 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1991 : : 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1992 : : 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1993 : : 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1994 : : 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1995 : : 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1996 : : 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1997 : : 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1998 : : 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1999 : : 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2000 : : 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2001 : : 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2002 : : 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2003 : : 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2004 : : 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2005 : : 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2006 : : 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2007 : : 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2008 : : 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2009 : : 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2010 : : 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2011 : : 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2012 : : 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2013 : : 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2014 : : 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2015 : : 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2016 : : 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2017 : : 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2018 : : 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2019 : : 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2020 : : 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2021 : : 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2022 : : 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2023 : : 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2024 : : 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2025 : : 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2026 : : 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2027 : : };
2028 : :
2029 : :
2030 : : static uint8_t ms_hmac_key0[] = {
2031 : : 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2032 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2033 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2034 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2035 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2036 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2037 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2038 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2039 : : };
2040 : :
2041 : : static const uint8_t ms_hmac_digest0[] = {
2042 : : 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2043 : : 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2044 : : 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2045 : : 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2046 : : 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2047 : : 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2048 : : 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2049 : : 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2050 : : };
2051 : :
2052 : : /* End Session 0 */
2053 : : /* Begin session 1 */
2054 : :
2055 : : static uint8_t ms_aes_cbc_key1[] = {
2056 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2057 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2058 : : };
2059 : :
2060 : : static uint8_t ms_aes_cbc_iv1[] = {
2061 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2062 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2063 : : };
2064 : :
2065 : : static const uint8_t ms_aes_cbc_cipher1[] = {
2066 : : 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2067 : : 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2068 : : 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2069 : : 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2070 : : 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2071 : : 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2072 : : 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2073 : : 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2074 : : 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2075 : : 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2076 : : 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2077 : : 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2078 : : 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2079 : : 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2080 : : 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2081 : : 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2082 : : 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2083 : : 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2084 : : 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2085 : : 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2086 : : 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2087 : : 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2088 : : 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2089 : : 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2090 : : 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2091 : : 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2092 : : 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2093 : : 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2094 : : 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2095 : : 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2096 : : 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2097 : : 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2098 : : 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2099 : : 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2100 : : 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2101 : : 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2102 : : 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2103 : : 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2104 : : 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2105 : : 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2106 : : 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2107 : : 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2108 : : 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2109 : : 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2110 : : 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2111 : : 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2112 : : 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2113 : : 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2114 : : 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2115 : : 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2116 : : 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2117 : : 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2118 : : 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2119 : : 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2120 : : 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2121 : : 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2122 : : 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2123 : : 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2124 : : 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2125 : : 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2126 : : 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2127 : : 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2128 : : 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2129 : : 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2130 : :
2131 : : };
2132 : :
2133 : : static uint8_t ms_hmac_key1[] = {
2134 : : 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2135 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2136 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2137 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2138 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2139 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2140 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2141 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2142 : : };
2143 : :
2144 : : static const uint8_t ms_hmac_digest1[] = {
2145 : : 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2146 : : 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2147 : : 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2148 : : 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2149 : : 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2150 : : 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2151 : : 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2152 : : 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2153 : : };
2154 : : /* End Session 1 */
2155 : : /* Begin Session 2 */
2156 : : static uint8_t ms_aes_cbc_key2[] = {
2157 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2158 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2159 : : };
2160 : :
2161 : : static uint8_t ms_aes_cbc_iv2[] = {
2162 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2163 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2164 : : };
2165 : :
2166 : : static const uint8_t ms_aes_cbc_cipher2[] = {
2167 : : 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2168 : : 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2169 : : 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2170 : : 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2171 : : 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2172 : : 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2173 : : 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2174 : : 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2175 : : 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2176 : : 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2177 : : 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2178 : : 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2179 : : 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2180 : : 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2181 : : 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2182 : : 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2183 : : 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2184 : : 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2185 : : 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2186 : : 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2187 : : 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2188 : : 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2189 : : 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2190 : : 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2191 : : 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2192 : : 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2193 : : 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2194 : : 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2195 : : 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2196 : : 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2197 : : 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2198 : : 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2199 : : 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2200 : : 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2201 : : 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2202 : : 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2203 : : 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2204 : : 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2205 : : 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2206 : : 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2207 : : 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2208 : : 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2209 : : 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2210 : : 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2211 : : 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2212 : : 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2213 : : 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2214 : : 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2215 : : 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2216 : : 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2217 : : 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2218 : : 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2219 : : 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2220 : : 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2221 : : 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2222 : : 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2223 : : 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2224 : : 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2225 : : 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2226 : : 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2227 : : 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2228 : : 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2229 : : 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2230 : : 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2231 : : };
2232 : :
2233 : : static uint8_t ms_hmac_key2[] = {
2234 : : 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2235 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2236 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2237 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2238 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2239 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2240 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2241 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2242 : : };
2243 : :
2244 : : static const uint8_t ms_hmac_digest2[] = {
2245 : : 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2246 : : 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2247 : : 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2248 : : 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2249 : : 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2250 : : 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2251 : : 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2252 : : 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2253 : : };
2254 : :
2255 : : /* End Session 2 */
2256 : :
2257 : :
2258 : : static int
2259 : 0 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2260 : : {
2261 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2262 : : struct crypto_unittest_params *ut_params = &unittest_params;
2263 : : /* Verify the capabilities */
2264 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2265 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2266 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2267 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2268 : : &cap_idx) == NULL)
2269 : : return TEST_SKIPPED;
2270 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2271 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2272 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2273 : : &cap_idx) == NULL)
2274 : : return TEST_SKIPPED;
2275 : :
2276 : : /* Generate test mbuf data and space for digest */
2277 : 0 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2278 : : catch_22_quote, QUOTE_512_BYTES, 0);
2279 : :
2280 : 0 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2281 : : DIGEST_BYTE_LENGTH_SHA1);
2282 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2283 : :
2284 : : /* Setup Cipher Parameters */
2285 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2286 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2287 : :
2288 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2289 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2290 : 0 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2291 : 0 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2292 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2293 : 0 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2294 : :
2295 : : /* Setup HMAC Parameters */
2296 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2297 : :
2298 : 0 : ut_params->auth_xform.next = NULL;
2299 : :
2300 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2301 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2302 : 0 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2303 : 0 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2304 : 0 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2305 : :
2306 : 0 : rte_errno = 0;
2307 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
2308 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2309 : : ts_params->session_mpool);
2310 [ # # ]: 0 : if (rte_errno == ENOTSUP)
2311 : : return TEST_SKIPPED;
2312 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2313 : :
2314 : : /* Generate crypto op data structure */
2315 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2316 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2317 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2318 : : "Failed to allocate symmetric crypto operation struct");
2319 : :
2320 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2321 : :
2322 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2323 : :
2324 : : /* set crypto operation source mbuf */
2325 : 0 : sym_op->m_src = ut_params->ibuf;
2326 : :
2327 : : /* Set crypto operation authentication parameters */
2328 : 0 : sym_op->auth.digest.data = ut_params->digest;
2329 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2330 : : ut_params->ibuf, QUOTE_512_BYTES);
2331 : :
2332 : 0 : sym_op->auth.data.offset = 0;
2333 : 0 : sym_op->auth.data.length = QUOTE_512_BYTES;
2334 : :
2335 : : /* Copy IV at the end of the crypto operation */
2336 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2337 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2338 : :
2339 : : /* Set crypto operation cipher parameters */
2340 : 0 : sym_op->cipher.data.offset = 0;
2341 : 0 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2342 : :
2343 : : /* Process crypto operation */
2344 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2345 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2346 : : ut_params->op);
2347 : : else
2348 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
2349 : : process_crypto_request(ts_params->valid_devs[0],
2350 : : ut_params->op),
2351 : : "failed to process sym crypto op");
2352 : :
2353 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2354 : : "crypto op processing failed");
2355 : :
2356 : : /* Validate obuf */
2357 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2358 : : uint8_t *);
2359 : :
2360 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2361 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2362 : : QUOTE_512_BYTES,
2363 : : "ciphertext data not as expected");
2364 : :
2365 : 0 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2366 : :
2367 [ # # # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2368 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2369 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2370 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2371 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2372 : : DIGEST_BYTE_LENGTH_SHA1,
2373 : : "Generated digest data not as expected");
2374 : :
2375 : : return TEST_SUCCESS;
2376 : : }
2377 : :
2378 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2379 : :
2380 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2381 : :
2382 : : static uint8_t hmac_sha512_key[] = {
2383 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2384 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2385 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2386 : : 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2387 : : 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2388 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2389 : : 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2390 : : 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2391 : :
2392 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2393 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2394 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2395 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2396 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2397 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2398 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2399 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2400 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2401 : :
2402 : :
2403 : :
2404 : : static int
2405 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2406 : : struct crypto_unittest_params *ut_params,
2407 : : uint8_t *cipher_key,
2408 : : uint8_t *hmac_key);
2409 : :
2410 : : static int
2411 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2412 : : struct crypto_unittest_params *ut_params,
2413 : : struct crypto_testsuite_params *ts_params,
2414 : : const uint8_t *cipher,
2415 : : const uint8_t *digest,
2416 : : const uint8_t *iv);
2417 : :
2418 : :
2419 : : static int
2420 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2421 : : struct crypto_unittest_params *ut_params,
2422 : : uint8_t *cipher_key,
2423 : : uint8_t *hmac_key)
2424 : : {
2425 : :
2426 : : /* Setup Cipher Parameters */
2427 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2428 : 0 : ut_params->cipher_xform.next = NULL;
2429 : :
2430 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2431 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2432 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2433 : 0 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2434 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2435 : 0 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2436 : :
2437 : : /* Setup HMAC Parameters */
2438 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2439 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2440 : :
2441 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2442 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2443 : 0 : ut_params->auth_xform.auth.key.data = hmac_key;
2444 : 0 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2445 : 0 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2446 : :
2447 : : return TEST_SUCCESS;
2448 : : }
2449 : :
2450 : :
2451 : : static int
2452 : 0 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2453 : : struct crypto_unittest_params *ut_params,
2454 : : struct crypto_testsuite_params *ts_params,
2455 : : const uint8_t *cipher,
2456 : : const uint8_t *digest,
2457 : : const uint8_t *iv)
2458 : : {
2459 : : int ret;
2460 : :
2461 : : /* Generate test mbuf data and digest */
2462 : 0 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2463 : : (const char *)
2464 : : cipher,
2465 : : QUOTE_512_BYTES, 0);
2466 : :
2467 : 0 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2468 : : DIGEST_BYTE_LENGTH_SHA512);
2469 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2470 : :
2471 : : rte_memcpy(ut_params->digest,
2472 : : digest,
2473 : : DIGEST_BYTE_LENGTH_SHA512);
2474 : :
2475 : : /* Generate Crypto op data structure */
2476 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2477 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2478 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2479 : : "Failed to allocate symmetric crypto operation struct");
2480 : :
2481 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2482 : :
2483 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2484 : :
2485 : : /* set crypto operation source mbuf */
2486 : 0 : sym_op->m_src = ut_params->ibuf;
2487 : :
2488 : 0 : sym_op->auth.digest.data = ut_params->digest;
2489 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2490 : : ut_params->ibuf, QUOTE_512_BYTES);
2491 : :
2492 : 0 : sym_op->auth.data.offset = 0;
2493 : 0 : sym_op->auth.data.length = QUOTE_512_BYTES;
2494 : :
2495 : : /* Copy IV at the end of the crypto operation */
2496 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2497 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2498 : :
2499 : 0 : sym_op->cipher.data.offset = 0;
2500 : 0 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2501 : :
2502 : : /* Process crypto operation */
2503 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2504 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2505 : : ut_params->op);
2506 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2507 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2508 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2509 : : return ret;
2510 : : } else
2511 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
2512 : : process_crypto_request(ts_params->valid_devs[0],
2513 : : ut_params->op),
2514 : : "failed to process sym crypto op");
2515 : :
2516 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2517 : : "crypto op processing failed");
2518 : :
2519 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
2520 : :
2521 : : /* Validate obuf */
2522 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2523 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2524 : : catch_22_quote,
2525 : : QUOTE_512_BYTES,
2526 : : "Plaintext data not as expected");
2527 : :
2528 : : /* Validate obuf */
2529 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2530 : : "Digest verification failed");
2531 : :
2532 : : return TEST_SUCCESS;
2533 : : }
2534 : :
2535 : : /* ***** SNOW 3G Tests ***** */
2536 : : static int
2537 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2538 : : const uint8_t *key, const uint8_t key_len,
2539 : : const uint8_t iv_len, const uint8_t auth_len,
2540 : : enum rte_crypto_auth_operation op,
2541 : : enum rte_crypto_auth_algorithm algo)
2542 : 0 : {
2543 : 0 : uint8_t hash_key[key_len];
2544 : :
2545 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2546 : : struct crypto_unittest_params *ut_params = &unittest_params;
2547 : :
2548 : : memcpy(hash_key, key, key_len);
2549 : :
2550 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2551 : :
2552 : : /* Setup Authentication Parameters */
2553 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2554 : 0 : ut_params->auth_xform.next = NULL;
2555 : :
2556 : 0 : ut_params->auth_xform.auth.op = op;
2557 : 0 : ut_params->auth_xform.auth.algo = algo;
2558 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2559 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2560 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2561 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2562 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2563 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2564 : : &ut_params->auth_xform, ts_params->session_mpool);
2565 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2566 : : return TEST_SKIPPED;
2567 : :
2568 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2569 : : return 0;
2570 : : }
2571 : :
2572 : : static int
2573 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2574 : : enum rte_crypto_cipher_operation op,
2575 : : enum rte_crypto_cipher_algorithm algo,
2576 : : const uint8_t *key, const uint8_t key_len,
2577 : : uint8_t iv_len)
2578 : 0 : {
2579 : 0 : uint8_t cipher_key[key_len];
2580 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2581 : : struct crypto_unittest_params *ut_params = &unittest_params;
2582 : :
2583 : : memcpy(cipher_key, key, key_len);
2584 : :
2585 : : /* Setup Cipher Parameters */
2586 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2587 : 0 : ut_params->cipher_xform.next = NULL;
2588 : :
2589 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2590 : 0 : ut_params->cipher_xform.cipher.op = op;
2591 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2592 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2593 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2594 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2595 : :
2596 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2597 : :
2598 : : /* Create Crypto session */
2599 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2600 : : &ut_params->cipher_xform, ts_params->session_mpool);
2601 : :
2602 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2603 : : return TEST_SKIPPED;
2604 : :
2605 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2606 : : return 0;
2607 : : }
2608 : :
2609 : : static int
2610 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2611 : : unsigned int cipher_len,
2612 : : unsigned int cipher_offset)
2613 : : {
2614 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2615 : : struct crypto_unittest_params *ut_params = &unittest_params;
2616 : :
2617 : : /* Generate Crypto op data structure */
2618 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2619 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2620 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2621 : : "Failed to allocate pktmbuf offload");
2622 : :
2623 : : /* Set crypto operation data parameters */
2624 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2625 : :
2626 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2627 : :
2628 : : /* set crypto operation source mbuf */
2629 : 0 : sym_op->m_src = ut_params->ibuf;
2630 : :
2631 : : /* iv */
2632 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2633 : : iv, iv_len);
2634 : 0 : sym_op->cipher.data.length = cipher_len;
2635 : 0 : sym_op->cipher.data.offset = cipher_offset;
2636 : 0 : return 0;
2637 : : }
2638 : :
2639 : : static int
2640 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2641 : : unsigned int cipher_len,
2642 : : unsigned int cipher_offset)
2643 : : {
2644 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2645 : : struct crypto_unittest_params *ut_params = &unittest_params;
2646 : :
2647 : : /* Generate Crypto op data structure */
2648 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2649 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2650 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2651 : : "Failed to allocate pktmbuf offload");
2652 : :
2653 : : /* Set crypto operation data parameters */
2654 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2655 : :
2656 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2657 : :
2658 : : /* set crypto operation source mbuf */
2659 : 0 : sym_op->m_src = ut_params->ibuf;
2660 : 0 : sym_op->m_dst = ut_params->obuf;
2661 : :
2662 : : /* iv */
2663 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2664 : : iv, iv_len);
2665 : 0 : sym_op->cipher.data.length = cipher_len;
2666 : 0 : sym_op->cipher.data.offset = cipher_offset;
2667 : 0 : return 0;
2668 : : }
2669 : :
2670 : : static int
2671 : 0 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2672 : : enum rte_crypto_cipher_operation cipher_op,
2673 : : enum rte_crypto_auth_operation auth_op,
2674 : : enum rte_crypto_auth_algorithm auth_algo,
2675 : : enum rte_crypto_cipher_algorithm cipher_algo,
2676 : : const uint8_t *a_key, uint8_t a_key_len,
2677 : : const uint8_t *c_key, uint8_t c_key_len,
2678 : : uint8_t auth_iv_len, uint8_t auth_len,
2679 : : uint8_t cipher_iv_len)
2680 : :
2681 : : {
2682 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2683 : : struct crypto_unittest_params *ut_params = &unittest_params;
2684 : :
2685 : : /* Setup Authentication Parameters */
2686 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2687 : 0 : ut_params->auth_xform.next = NULL;
2688 : :
2689 : 0 : ut_params->auth_xform.auth.op = auth_op;
2690 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
2691 : 0 : ut_params->auth_xform.auth.key.length = a_key_len;
2692 : 0 : ut_params->auth_xform.auth.key.data = a_key;
2693 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2694 : : /* Auth IV will be after cipher IV */
2695 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2696 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2697 : :
2698 : : /* Setup Cipher Parameters */
2699 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2700 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2701 : :
2702 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2703 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
2704 : 0 : ut_params->cipher_xform.cipher.key.data = c_key;
2705 : 0 : ut_params->cipher_xform.cipher.key.length = c_key_len;
2706 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2707 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2708 : :
2709 : 0 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
2710 : 0 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2711 : :
2712 : : /* Create Crypto session*/
2713 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2714 : : &ut_params->cipher_xform, ts_params->session_mpool);
2715 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2716 : : return TEST_SKIPPED;
2717 : :
2718 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2719 : : return 0;
2720 : : }
2721 : :
2722 : : static int
2723 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
2724 : : enum rte_crypto_cipher_operation cipher_op,
2725 : : enum rte_crypto_auth_operation auth_op,
2726 : : enum rte_crypto_auth_algorithm auth_algo,
2727 : : enum rte_crypto_cipher_algorithm cipher_algo,
2728 : : const struct wireless_test_data *tdata)
2729 : 0 : {
2730 : 0 : const uint8_t key_len = tdata->key.len;
2731 : 0 : uint8_t cipher_auth_key[key_len];
2732 : :
2733 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2734 : : struct crypto_unittest_params *ut_params = &unittest_params;
2735 : 0 : const uint8_t *key = tdata->key.data;
2736 : 0 : const uint8_t auth_len = tdata->digest.len;
2737 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
2738 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
2739 : :
2740 : : memcpy(cipher_auth_key, key, key_len);
2741 : :
2742 : : /* Setup Authentication Parameters */
2743 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2744 : 0 : ut_params->auth_xform.next = NULL;
2745 : :
2746 : 0 : ut_params->auth_xform.auth.op = auth_op;
2747 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
2748 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2749 : : /* Hash key = cipher key */
2750 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
2751 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2752 : : /* Auth IV will be after cipher IV */
2753 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2754 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2755 : :
2756 : : /* Setup Cipher Parameters */
2757 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2758 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2759 : :
2760 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2761 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
2762 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2763 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2764 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2765 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2766 : :
2767 : :
2768 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2769 : :
2770 : : /* Create Crypto session*/
2771 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2772 : : &ut_params->cipher_xform, ts_params->session_mpool);
2773 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2774 : : return TEST_SKIPPED;
2775 : :
2776 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2777 : : return 0;
2778 : : }
2779 : :
2780 : : static int
2781 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2782 : : const struct wireless_test_data *tdata)
2783 : : {
2784 : 0 : return create_wireless_cipher_auth_session(dev_id,
2785 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2786 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2787 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2788 : : }
2789 : :
2790 : : static int
2791 : 0 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2792 : : enum rte_crypto_cipher_operation cipher_op,
2793 : : enum rte_crypto_auth_operation auth_op,
2794 : : enum rte_crypto_auth_algorithm auth_algo,
2795 : : enum rte_crypto_cipher_algorithm cipher_algo,
2796 : : const uint8_t *a_key, const uint8_t a_key_len,
2797 : : const uint8_t *c_key, const uint8_t c_key_len,
2798 : : uint8_t auth_iv_len, uint8_t auth_len,
2799 : : uint8_t cipher_iv_len)
2800 : : {
2801 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2802 : : struct crypto_unittest_params *ut_params = &unittest_params;
2803 : :
2804 : : /* Setup Authentication Parameters */
2805 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2806 : 0 : ut_params->auth_xform.auth.op = auth_op;
2807 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2808 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
2809 : 0 : ut_params->auth_xform.auth.key.length = a_key_len;
2810 : 0 : ut_params->auth_xform.auth.key.data = a_key;
2811 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2812 : : /* Auth IV will be after cipher IV */
2813 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2814 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2815 : :
2816 : : /* Setup Cipher Parameters */
2817 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2818 : 0 : ut_params->cipher_xform.next = NULL;
2819 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2820 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
2821 : 0 : ut_params->cipher_xform.cipher.key.data = c_key;
2822 : 0 : ut_params->cipher_xform.cipher.key.length = c_key_len;
2823 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2824 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2825 : :
2826 : 0 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
2827 : 0 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2828 : :
2829 : : /* Create Crypto session*/
2830 [ # # ]: 0 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2831 : 0 : ut_params->auth_xform.next = NULL;
2832 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2833 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2834 : : &ut_params->cipher_xform, ts_params->session_mpool);
2835 : : } else
2836 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2837 : : &ut_params->auth_xform, ts_params->session_mpool);
2838 : :
2839 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2840 : : return TEST_SKIPPED;
2841 : :
2842 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2843 : :
2844 : : return 0;
2845 : : }
2846 : :
2847 : : static int
2848 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2849 : : unsigned int auth_tag_len,
2850 : : const uint8_t *iv, unsigned int iv_len,
2851 : : unsigned int data_pad_len,
2852 : : enum rte_crypto_auth_operation op,
2853 : : unsigned int auth_len, unsigned int auth_offset)
2854 : : {
2855 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2856 : :
2857 : : struct crypto_unittest_params *ut_params = &unittest_params;
2858 : :
2859 : : /* Generate Crypto op data structure */
2860 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2861 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2862 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2863 : : "Failed to allocate pktmbuf offload");
2864 : :
2865 : : /* Set crypto operation data parameters */
2866 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2867 : :
2868 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2869 : :
2870 : : /* set crypto operation source mbuf */
2871 : 0 : sym_op->m_src = ut_params->ibuf;
2872 : :
2873 : : /* iv */
2874 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2875 : : iv, iv_len);
2876 : : /* digest */
2877 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2878 : : ut_params->ibuf, auth_tag_len);
2879 : :
2880 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2881 : : "no room to append auth tag");
2882 : 0 : ut_params->digest = sym_op->auth.digest.data;
2883 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2884 : : ut_params->ibuf, data_pad_len);
2885 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2886 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
2887 : : else
2888 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2889 : :
2890 : 0 : debug_hexdump(stdout, "digest:",
2891 : 0 : sym_op->auth.digest.data,
2892 : : auth_tag_len);
2893 : :
2894 : 0 : sym_op->auth.data.length = auth_len;
2895 : 0 : sym_op->auth.data.offset = auth_offset;
2896 : :
2897 : 0 : return 0;
2898 : : }
2899 : :
2900 : : static int
2901 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2902 : : enum rte_crypto_auth_operation op)
2903 : : {
2904 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2905 : : struct crypto_unittest_params *ut_params = &unittest_params;
2906 : :
2907 : 0 : const uint8_t *auth_tag = tdata->digest.data;
2908 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
2909 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2910 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2911 : :
2912 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
2913 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2914 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
2915 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
2916 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2917 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
2918 : :
2919 : : /* Generate Crypto op data structure */
2920 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2921 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2922 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2923 : : "Failed to allocate pktmbuf offload");
2924 : : /* Set crypto operation data parameters */
2925 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2926 : :
2927 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2928 : :
2929 : : /* set crypto operation source mbuf */
2930 : 0 : sym_op->m_src = ut_params->ibuf;
2931 : :
2932 : : /* digest */
2933 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2934 : : ut_params->ibuf, auth_tag_len);
2935 : :
2936 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2937 : : "no room to append auth tag");
2938 : 0 : ut_params->digest = sym_op->auth.digest.data;
2939 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2940 : : ut_params->ibuf, data_pad_len);
2941 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2942 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
2943 : : else
2944 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2945 : :
2946 : 0 : debug_hexdump(stdout, "digest:",
2947 : 0 : sym_op->auth.digest.data,
2948 : : auth_tag_len);
2949 : :
2950 : : /* Copy cipher and auth IVs at the end of the crypto operation */
2951 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2952 : : IV_OFFSET);
2953 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2954 : 0 : iv_ptr += cipher_iv_len;
2955 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2956 : :
2957 : 0 : sym_op->cipher.data.length = cipher_len;
2958 : 0 : sym_op->cipher.data.offset = 0;
2959 : 0 : sym_op->auth.data.length = auth_len;
2960 : 0 : sym_op->auth.data.offset = 0;
2961 : :
2962 : 0 : return 0;
2963 : : }
2964 : :
2965 : : static int
2966 : : create_zuc_cipher_hash_generate_operation(
2967 : : const struct wireless_test_data *tdata)
2968 : : {
2969 : 0 : return create_wireless_cipher_hash_operation(tdata,
2970 : : RTE_CRYPTO_AUTH_OP_GENERATE);
2971 : : }
2972 : :
2973 : : static int
2974 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2975 : : const unsigned auth_tag_len,
2976 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
2977 : : unsigned data_pad_len,
2978 : : enum rte_crypto_auth_operation op,
2979 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2980 : : const unsigned cipher_len, const unsigned cipher_offset,
2981 : : const unsigned auth_len, const unsigned auth_offset)
2982 : : {
2983 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2984 : : struct crypto_unittest_params *ut_params = &unittest_params;
2985 : :
2986 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
2987 : : ut_params->cipher_xform.cipher.algo;
2988 : 0 : enum rte_crypto_auth_algorithm auth_algo =
2989 : : ut_params->auth_xform.auth.algo;
2990 : :
2991 : : /* Generate Crypto op data structure */
2992 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2993 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2994 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2995 : : "Failed to allocate pktmbuf offload");
2996 : : /* Set crypto operation data parameters */
2997 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2998 : :
2999 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3000 : :
3001 : : /* set crypto operation source mbuf */
3002 : 0 : sym_op->m_src = ut_params->ibuf;
3003 : :
3004 : : /* digest */
3005 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3006 : : ut_params->ibuf, auth_tag_len);
3007 : :
3008 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3009 : : "no room to append auth tag");
3010 : 0 : ut_params->digest = sym_op->auth.digest.data;
3011 : :
3012 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3013 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3014 : : ut_params->ibuf, data_pad_len);
3015 : : } else {
3016 : : struct rte_mbuf *m = ut_params->ibuf;
3017 : : unsigned int offset = data_pad_len;
3018 : :
3019 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3020 : 0 : offset -= m->data_len;
3021 : : m = m->next;
3022 : : }
3023 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3024 : : m, offset);
3025 : : }
3026 : :
3027 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3028 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3029 : : else
3030 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3031 : :
3032 : 0 : debug_hexdump(stdout, "digest:",
3033 : 0 : sym_op->auth.digest.data,
3034 : : auth_tag_len);
3035 : :
3036 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3037 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3038 : : IV_OFFSET);
3039 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3040 : 0 : iv_ptr += cipher_iv_len;
3041 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3042 : :
3043 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3044 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3045 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3046 : 0 : sym_op->cipher.data.length = cipher_len;
3047 : 0 : sym_op->cipher.data.offset = cipher_offset;
3048 : : } else {
3049 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3050 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3051 : : }
3052 : :
3053 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3054 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3055 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3056 : 0 : sym_op->auth.data.length = auth_len;
3057 : 0 : sym_op->auth.data.offset = auth_offset;
3058 : : } else {
3059 : 0 : sym_op->auth.data.length = auth_len >> 3;
3060 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3061 : : }
3062 : :
3063 : : return 0;
3064 : : }
3065 : :
3066 : : static int
3067 : 0 : create_wireless_algo_auth_cipher_operation(
3068 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3069 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3070 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3071 : : unsigned int data_pad_len,
3072 : : unsigned int cipher_len, unsigned int cipher_offset,
3073 : : unsigned int auth_len, unsigned int auth_offset,
3074 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3075 : : {
3076 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3077 : : struct crypto_unittest_params *ut_params = &unittest_params;
3078 : :
3079 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
3080 : : ut_params->cipher_xform.cipher.algo;
3081 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3082 : : ut_params->auth_xform.auth.algo;
3083 : :
3084 : : /* Generate Crypto op data structure */
3085 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3086 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3087 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3088 : : "Failed to allocate pktmbuf offload");
3089 : :
3090 : : /* Set crypto operation data parameters */
3091 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3092 : :
3093 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3094 : :
3095 : : /* set crypto operation mbufs */
3096 : 0 : sym_op->m_src = ut_params->ibuf;
3097 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
3098 : 0 : sym_op->m_dst = ut_params->obuf;
3099 : :
3100 : : /* digest */
3101 [ # # ]: 0 : if (!do_sgl) {
3102 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3103 : : (op_mode == IN_PLACE ?
3104 : : ut_params->ibuf : ut_params->obuf),
3105 : : uint8_t *, data_pad_len);
3106 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3107 : : (op_mode == IN_PLACE ?
3108 : : ut_params->ibuf : ut_params->obuf),
3109 : : data_pad_len);
3110 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3111 : : } else {
3112 : 0 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3113 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3114 [ # # ]: 0 : sym_op->m_src : sym_op->m_dst);
3115 [ # # ]: 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3116 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3117 : 0 : sgl_buf = sgl_buf->next;
3118 : : }
3119 : :
3120 : : /* The last segment should be large enough to hold full digest */
3121 [ # # ]: 0 : if (sgl_buf->data_len < auth_tag_len) {
3122 : 0 : rte_pktmbuf_free(sgl_buf->next);
3123 : 0 : sgl_buf->next = NULL;
3124 [ # # # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3125 : : auth_tag_len - sgl_buf->data_len),
3126 : : "No room to append auth tag");
3127 : : }
3128 : :
3129 : 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3130 : : uint8_t *, remaining_off);
3131 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3132 : : remaining_off);
3133 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3134 [ # # ]: 0 : while (sgl_buf->next != NULL) {
3135 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3136 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3137 : 0 : sgl_buf = sgl_buf->next;
3138 : : }
3139 : : }
3140 : :
3141 : : /* Copy digest for the verification */
3142 [ # # ]: 0 : if (verify)
3143 : 0 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3144 : :
3145 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3146 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3147 : : ut_params->op, uint8_t *, IV_OFFSET);
3148 : :
3149 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3150 : 0 : iv_ptr += cipher_iv_len;
3151 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3152 : :
3153 : : /* Only copy over the offset data needed from src to dst in OOP,
3154 : : * if the auth and cipher offsets are not aligned
3155 : : */
3156 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
3157 [ # # ]: 0 : if (cipher_offset > auth_offset)
3158 : 0 : rte_memcpy(
3159 : 0 : rte_pktmbuf_mtod_offset(
3160 : : sym_op->m_dst,
3161 : : uint8_t *, auth_offset >> 3),
3162 : 0 : rte_pktmbuf_mtod_offset(
3163 : : sym_op->m_src,
3164 : : uint8_t *, auth_offset >> 3),
3165 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3166 : : }
3167 : :
3168 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3169 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3170 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3171 : 0 : sym_op->cipher.data.length = cipher_len;
3172 : 0 : sym_op->cipher.data.offset = cipher_offset;
3173 : : } else {
3174 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3175 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3176 : : }
3177 : :
3178 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3179 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3180 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3181 : 0 : sym_op->auth.data.length = auth_len;
3182 : 0 : sym_op->auth.data.offset = auth_offset;
3183 : : } else {
3184 : 0 : sym_op->auth.data.length = auth_len >> 3;
3185 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3186 : : }
3187 : :
3188 : : return 0;
3189 : : }
3190 : :
3191 : : static int
3192 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3193 : : {
3194 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3195 : : struct crypto_unittest_params *ut_params = &unittest_params;
3196 : :
3197 : : int retval;
3198 : : unsigned plaintext_pad_len;
3199 : : unsigned plaintext_len;
3200 : : uint8_t *plaintext;
3201 : : struct rte_cryptodev_info dev_info;
3202 : :
3203 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3204 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3205 : :
3206 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3207 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3208 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3209 : 0 : return TEST_SKIPPED;
3210 : : }
3211 : :
3212 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3213 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3214 : : printf("Device doesn't support RAW data-path APIs.\n");
3215 : 0 : return TEST_SKIPPED;
3216 : : }
3217 : :
3218 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3219 : : return TEST_SKIPPED;
3220 : :
3221 : : /* Verify the capabilities */
3222 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3223 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3224 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3225 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3226 : : &cap_idx) == NULL)
3227 : : return TEST_SKIPPED;
3228 : :
3229 : : /* Create SNOW 3G session */
3230 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3231 : 0 : tdata->key.data, tdata->key.len,
3232 : 0 : tdata->auth_iv.len, tdata->digest.len,
3233 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3234 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3235 [ # # ]: 0 : if (retval < 0)
3236 : : return retval;
3237 : :
3238 : : /* alloc mbuf and set payload */
3239 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3240 : :
3241 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3242 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3243 : :
3244 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3245 : : /* Append data which is padded to a multiple of */
3246 : : /* the algorithms block size */
3247 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3248 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3249 : : plaintext_pad_len);
3250 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3251 : :
3252 : : /* Create SNOW 3G operation */
3253 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3254 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3255 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3256 : 0 : tdata->validAuthLenInBits.len,
3257 : : 0);
3258 [ # # ]: 0 : if (retval < 0)
3259 : : return retval;
3260 : :
3261 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3262 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3263 : : 0);
3264 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3265 : : return retval;
3266 : : } else
3267 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3268 : : ut_params->op);
3269 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3270 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3271 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3272 : 0 : + plaintext_pad_len;
3273 : :
3274 : : /* Validate obuf */
3275 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3276 : : ut_params->digest,
3277 : : tdata->digest.data,
3278 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3279 : : "SNOW 3G Generated auth tag not as expected");
3280 : :
3281 : : return 0;
3282 : : }
3283 : :
3284 : : static int
3285 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3286 : : {
3287 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3288 : : struct crypto_unittest_params *ut_params = &unittest_params;
3289 : :
3290 : : int retval;
3291 : : unsigned plaintext_pad_len;
3292 : : unsigned plaintext_len;
3293 : : uint8_t *plaintext;
3294 : : struct rte_cryptodev_info dev_info;
3295 : :
3296 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3297 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3298 : :
3299 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3300 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3301 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3302 : 0 : return TEST_SKIPPED;
3303 : : }
3304 : :
3305 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3306 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3307 : : printf("Device doesn't support RAW data-path APIs.\n");
3308 : 0 : return TEST_SKIPPED;
3309 : : }
3310 : :
3311 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3312 : : return TEST_SKIPPED;
3313 : :
3314 : : /* Verify the capabilities */
3315 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3316 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3317 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3318 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3319 : : &cap_idx) == NULL)
3320 : : return TEST_SKIPPED;
3321 : :
3322 : : /* Create SNOW 3G session */
3323 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3324 : 0 : tdata->key.data, tdata->key.len,
3325 : 0 : tdata->auth_iv.len, tdata->digest.len,
3326 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3327 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3328 [ # # ]: 0 : if (retval < 0)
3329 : : return retval;
3330 : : /* alloc mbuf and set payload */
3331 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3332 : :
3333 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3334 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3335 : :
3336 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3337 : : /* Append data which is padded to a multiple of */
3338 : : /* the algorithms block size */
3339 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3340 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3341 : : plaintext_pad_len);
3342 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3343 : :
3344 : : /* Create SNOW 3G operation */
3345 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3346 : 0 : tdata->digest.len,
3347 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3348 : : plaintext_pad_len,
3349 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3350 : 0 : tdata->validAuthLenInBits.len,
3351 : : 0);
3352 [ # # ]: 0 : if (retval < 0)
3353 : : return retval;
3354 : :
3355 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3356 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3357 : : 0);
3358 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3359 : : return retval;
3360 : : } else
3361 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3362 : : ut_params->op);
3363 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3364 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3365 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3366 : 0 : + plaintext_pad_len;
3367 : :
3368 : : /* Validate obuf */
3369 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3370 : : return 0;
3371 : : else
3372 : 0 : return -1;
3373 : :
3374 : : return 0;
3375 : : }
3376 : :
3377 : : static int
3378 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3379 : : {
3380 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3381 : : struct crypto_unittest_params *ut_params = &unittest_params;
3382 : :
3383 : : int retval;
3384 : : unsigned plaintext_pad_len;
3385 : : unsigned plaintext_len;
3386 : : uint8_t *plaintext;
3387 : : struct rte_cryptodev_info dev_info;
3388 : :
3389 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3390 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3391 : :
3392 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3393 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3394 : : printf("Device doesn't support RAW data-path APIs.\n");
3395 : 0 : return TEST_SKIPPED;
3396 : : }
3397 : :
3398 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3399 : : return TEST_SKIPPED;
3400 : :
3401 : : /* Verify the capabilities */
3402 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3403 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3404 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3405 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3406 : : &cap_idx) == NULL)
3407 : : return TEST_SKIPPED;
3408 : :
3409 : : /* Create KASUMI session */
3410 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3411 : 0 : tdata->key.data, tdata->key.len,
3412 : 0 : 0, tdata->digest.len,
3413 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3414 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3415 [ # # ]: 0 : if (retval < 0)
3416 : : return retval;
3417 : :
3418 : : /* alloc mbuf and set payload */
3419 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3420 : :
3421 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3422 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3423 : :
3424 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3425 : : /* Append data which is padded to a multiple of */
3426 : : /* the algorithms block size */
3427 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3428 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3429 : : plaintext_pad_len);
3430 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3431 : :
3432 : : /* Create KASUMI operation */
3433 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3434 : : NULL, 0,
3435 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3436 : 0 : tdata->plaintext.len,
3437 : : 0);
3438 [ # # ]: 0 : if (retval < 0)
3439 : : return retval;
3440 : :
3441 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3442 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3443 : : ut_params->op);
3444 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3445 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3446 : : 0);
3447 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3448 : : return retval;
3449 : : } else
3450 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3451 : : ut_params->op);
3452 : :
3453 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3454 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3455 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3456 : 0 : + plaintext_pad_len;
3457 : :
3458 : : /* Validate obuf */
3459 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3460 : : ut_params->digest,
3461 : : tdata->digest.data,
3462 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3463 : : "KASUMI Generated auth tag not as expected");
3464 : :
3465 : : return 0;
3466 : : }
3467 : :
3468 : : static int
3469 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3470 : : {
3471 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3472 : : struct crypto_unittest_params *ut_params = &unittest_params;
3473 : :
3474 : : int retval;
3475 : : unsigned plaintext_pad_len;
3476 : : unsigned plaintext_len;
3477 : : uint8_t *plaintext;
3478 : : struct rte_cryptodev_info dev_info;
3479 : :
3480 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3481 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3482 : :
3483 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3484 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3485 : : printf("Device doesn't support RAW data-path APIs.\n");
3486 : 0 : return TEST_SKIPPED;
3487 : : }
3488 : :
3489 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3490 : : return TEST_SKIPPED;
3491 : :
3492 : : /* Verify the capabilities */
3493 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3494 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3495 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3496 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3497 : : &cap_idx) == NULL)
3498 : : return TEST_SKIPPED;
3499 : :
3500 : : /* Create KASUMI session */
3501 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3502 : 0 : tdata->key.data, tdata->key.len,
3503 : 0 : 0, tdata->digest.len,
3504 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3505 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3506 [ # # ]: 0 : if (retval < 0)
3507 : : return retval;
3508 : : /* alloc mbuf and set payload */
3509 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3510 : :
3511 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3512 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3513 : :
3514 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3515 : : /* Append data which is padded to a multiple */
3516 : : /* of the algorithms block size */
3517 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3518 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3519 : : plaintext_pad_len);
3520 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3521 : :
3522 : : /* Create KASUMI operation */
3523 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3524 : 0 : tdata->digest.len,
3525 : : NULL, 0,
3526 : : plaintext_pad_len,
3527 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3528 : 0 : tdata->plaintext.len,
3529 : : 0);
3530 [ # # ]: 0 : if (retval < 0)
3531 : : return retval;
3532 : :
3533 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3534 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3535 : : 0);
3536 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3537 : : return retval;
3538 : : } else
3539 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3540 : : ut_params->op);
3541 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3542 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3543 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3544 : 0 : + plaintext_pad_len;
3545 : :
3546 : : /* Validate obuf */
3547 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3548 : : return 0;
3549 : : else
3550 : 0 : return -1;
3551 : :
3552 : : return 0;
3553 : : }
3554 : :
3555 : : static int
3556 : 0 : test_snow3g_hash_generate_test_case_1(void)
3557 : : {
3558 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3559 : : }
3560 : :
3561 : : static int
3562 : 0 : test_snow3g_hash_generate_test_case_2(void)
3563 : : {
3564 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3565 : : }
3566 : :
3567 : : static int
3568 : 0 : test_snow3g_hash_generate_test_case_3(void)
3569 : : {
3570 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3571 : : }
3572 : :
3573 : : static int
3574 : 0 : test_snow3g_hash_generate_test_case_4(void)
3575 : : {
3576 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3577 : : }
3578 : :
3579 : : static int
3580 : 0 : test_snow3g_hash_generate_test_case_5(void)
3581 : : {
3582 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3583 : : }
3584 : :
3585 : : static int
3586 : 0 : test_snow3g_hash_generate_test_case_6(void)
3587 : : {
3588 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3589 : : }
3590 : :
3591 : : static int
3592 : 0 : test_snow3g_hash_verify_test_case_1(void)
3593 : : {
3594 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3595 : :
3596 : : }
3597 : :
3598 : : static int
3599 : 0 : test_snow3g_hash_verify_test_case_2(void)
3600 : : {
3601 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3602 : : }
3603 : :
3604 : : static int
3605 : 0 : test_snow3g_hash_verify_test_case_3(void)
3606 : : {
3607 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3608 : : }
3609 : :
3610 : : static int
3611 : 0 : test_snow3g_hash_verify_test_case_4(void)
3612 : : {
3613 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3614 : : }
3615 : :
3616 : : static int
3617 : 0 : test_snow3g_hash_verify_test_case_5(void)
3618 : : {
3619 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3620 : : }
3621 : :
3622 : : static int
3623 : 0 : test_snow3g_hash_verify_test_case_6(void)
3624 : : {
3625 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3626 : : }
3627 : :
3628 : : static int
3629 : 0 : test_kasumi_hash_generate_test_case_1(void)
3630 : : {
3631 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
3632 : : }
3633 : :
3634 : : static int
3635 : 0 : test_kasumi_hash_generate_test_case_2(void)
3636 : : {
3637 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
3638 : : }
3639 : :
3640 : : static int
3641 : 0 : test_kasumi_hash_generate_test_case_3(void)
3642 : : {
3643 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
3644 : : }
3645 : :
3646 : : static int
3647 : 0 : test_kasumi_hash_generate_test_case_4(void)
3648 : : {
3649 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
3650 : : }
3651 : :
3652 : : static int
3653 : 0 : test_kasumi_hash_generate_test_case_5(void)
3654 : : {
3655 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
3656 : : }
3657 : :
3658 : : static int
3659 : 0 : test_kasumi_hash_generate_test_case_6(void)
3660 : : {
3661 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
3662 : : }
3663 : :
3664 : : static int
3665 : 0 : test_kasumi_hash_verify_test_case_1(void)
3666 : : {
3667 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3668 : : }
3669 : :
3670 : : static int
3671 : 0 : test_kasumi_hash_verify_test_case_2(void)
3672 : : {
3673 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3674 : : }
3675 : :
3676 : : static int
3677 : 0 : test_kasumi_hash_verify_test_case_3(void)
3678 : : {
3679 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3680 : : }
3681 : :
3682 : : static int
3683 : 0 : test_kasumi_hash_verify_test_case_4(void)
3684 : : {
3685 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3686 : : }
3687 : :
3688 : : static int
3689 : 0 : test_kasumi_hash_verify_test_case_5(void)
3690 : : {
3691 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3692 : : }
3693 : :
3694 : : static int
3695 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
3696 : : {
3697 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3698 : : struct crypto_unittest_params *ut_params = &unittest_params;
3699 : :
3700 : : int retval;
3701 : : uint8_t *plaintext, *ciphertext;
3702 : : unsigned plaintext_pad_len;
3703 : : unsigned plaintext_len;
3704 : : struct rte_cryptodev_info dev_info;
3705 : :
3706 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3707 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3708 : :
3709 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3710 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3711 : : printf("Device doesn't support RAW data-path APIs.\n");
3712 : 0 : return TEST_SKIPPED;
3713 : : }
3714 : :
3715 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3716 : : return TEST_SKIPPED;
3717 : :
3718 : : /* Verify the capabilities */
3719 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3720 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3721 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3722 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3723 : : &cap_idx) == NULL)
3724 : : return TEST_SKIPPED;
3725 : :
3726 : : /* Create KASUMI session */
3727 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3728 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3729 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3730 : 0 : tdata->key.data, tdata->key.len,
3731 : 0 : tdata->cipher_iv.len);
3732 [ # # ]: 0 : if (retval < 0)
3733 : : return retval;
3734 : :
3735 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3736 : :
3737 : : /* Clear mbuf payload */
3738 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3739 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3740 : :
3741 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3742 : : /* Append data which is padded to a multiple */
3743 : : /* of the algorithms block size */
3744 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3745 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3746 : : plaintext_pad_len);
3747 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3748 : :
3749 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3750 : :
3751 : : /* Create KASUMI operation */
3752 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3753 : 0 : tdata->cipher_iv.len,
3754 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3755 : 0 : tdata->validCipherOffsetInBits.len);
3756 [ # # ]: 0 : if (retval < 0)
3757 : : return retval;
3758 : :
3759 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3760 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3761 : 0 : tdata->cipher_iv.len);
3762 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3763 : : return retval;
3764 : : } else
3765 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3766 : : ut_params->op);
3767 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3768 : :
3769 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3770 [ # # ]: 0 : if (ut_params->obuf)
3771 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3772 : : else
3773 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3774 : :
3775 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3776 : :
3777 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3778 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3779 : : /* Validate obuf */
3780 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3781 : : ciphertext,
3782 : : reference_ciphertext,
3783 : : tdata->validCipherLenInBits.len,
3784 : : "KASUMI Ciphertext data not as expected");
3785 : : return 0;
3786 : : }
3787 : :
3788 : : static int
3789 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3790 : : {
3791 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3792 : : struct crypto_unittest_params *ut_params = &unittest_params;
3793 : :
3794 : : int retval;
3795 : :
3796 : : unsigned int plaintext_pad_len;
3797 : : unsigned int plaintext_len;
3798 : :
3799 : : uint8_t buffer[10000];
3800 : : const uint8_t *ciphertext;
3801 : :
3802 : : struct rte_cryptodev_info dev_info;
3803 : :
3804 : : /* Verify the capabilities */
3805 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3806 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3807 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3808 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3809 : : &cap_idx) == NULL)
3810 : : return TEST_SKIPPED;
3811 : :
3812 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3813 : :
3814 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3815 : :
3816 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3817 : : printf("Device doesn't support in-place scatter-gather. "
3818 : : "Test Skipped.\n");
3819 : 0 : return TEST_SKIPPED;
3820 : : }
3821 : :
3822 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3823 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3824 : : printf("Device doesn't support RAW data-path APIs.\n");
3825 : 0 : return TEST_SKIPPED;
3826 : : }
3827 : :
3828 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3829 : : return TEST_SKIPPED;
3830 : :
3831 : : /* Create KASUMI session */
3832 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3833 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3834 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3835 : 0 : tdata->key.data, tdata->key.len,
3836 : 0 : tdata->cipher_iv.len);
3837 [ # # ]: 0 : if (retval < 0)
3838 : : return retval;
3839 : :
3840 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3841 : :
3842 : :
3843 : : /* Append data which is padded to a multiple */
3844 : : /* of the algorithms block size */
3845 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3846 : :
3847 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3848 : : plaintext_pad_len, 10, 0);
3849 : :
3850 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3851 : :
3852 : : /* Create KASUMI operation */
3853 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3854 : 0 : tdata->cipher_iv.len,
3855 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3856 : 0 : tdata->validCipherOffsetInBits.len);
3857 [ # # ]: 0 : if (retval < 0)
3858 : : return retval;
3859 : :
3860 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3861 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3862 : 0 : tdata->cipher_iv.len);
3863 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3864 : : return retval;
3865 : : } else
3866 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3867 : : ut_params->op);
3868 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3869 : :
3870 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3871 : :
3872 [ # # ]: 0 : if (ut_params->obuf)
3873 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3874 : : plaintext_len, buffer);
3875 : : else
3876 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3877 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
3878 : : plaintext_len, buffer);
3879 : :
3880 : : /* Validate obuf */
3881 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3882 : :
3883 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3884 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3885 : : /* Validate obuf */
3886 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3887 : : ciphertext,
3888 : : reference_ciphertext,
3889 : : tdata->validCipherLenInBits.len,
3890 : : "KASUMI Ciphertext data not as expected");
3891 : : return 0;
3892 : : }
3893 : :
3894 : : static int
3895 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3896 : : {
3897 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3898 : : struct crypto_unittest_params *ut_params = &unittest_params;
3899 : :
3900 : : int retval;
3901 : : uint8_t *plaintext, *ciphertext;
3902 : : unsigned plaintext_pad_len;
3903 : : unsigned plaintext_len;
3904 : :
3905 : : /* Verify the capabilities */
3906 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3907 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3908 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3909 : : /* Data-path service does not support OOP */
3910 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3911 : : &cap_idx) == NULL)
3912 : : return TEST_SKIPPED;
3913 : :
3914 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3915 : : return TEST_SKIPPED;
3916 : :
3917 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3918 : : return TEST_SKIPPED;
3919 : :
3920 : : /* Create KASUMI session */
3921 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3922 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3923 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3924 : 0 : tdata->key.data, tdata->key.len,
3925 : 0 : tdata->cipher_iv.len);
3926 [ # # ]: 0 : if (retval < 0)
3927 : : return retval;
3928 : :
3929 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3930 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3931 : :
3932 : : /* Clear mbuf payload */
3933 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3934 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
3935 : :
3936 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3937 : : /* Append data which is padded to a multiple */
3938 : : /* of the algorithms block size */
3939 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3940 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3941 : : plaintext_pad_len);
3942 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3943 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3944 : :
3945 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3946 : :
3947 : : /* Create KASUMI operation */
3948 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3949 : 0 : tdata->cipher_iv.len,
3950 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3951 : 0 : tdata->validCipherOffsetInBits.len);
3952 [ # # ]: 0 : if (retval < 0)
3953 : : return retval;
3954 : :
3955 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3956 : : ut_params->op);
3957 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3958 : :
3959 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3960 [ # # ]: 0 : if (ut_params->obuf)
3961 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3962 : : else
3963 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3964 : :
3965 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3966 : :
3967 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3968 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3969 : : /* Validate obuf */
3970 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3971 : : ciphertext,
3972 : : reference_ciphertext,
3973 : : tdata->validCipherLenInBits.len,
3974 : : "KASUMI Ciphertext data not as expected");
3975 : : return 0;
3976 : : }
3977 : :
3978 : : static int
3979 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3980 : : {
3981 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3982 : : struct crypto_unittest_params *ut_params = &unittest_params;
3983 : :
3984 : : int retval;
3985 : : unsigned int plaintext_pad_len;
3986 : : unsigned int plaintext_len;
3987 : :
3988 : : const uint8_t *ciphertext;
3989 : : uint8_t buffer[2048];
3990 : :
3991 : : struct rte_cryptodev_info dev_info;
3992 : :
3993 : : /* Verify the capabilities */
3994 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3995 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3996 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3997 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3998 : : &cap_idx) == NULL)
3999 : : return TEST_SKIPPED;
4000 : :
4001 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4002 : : return TEST_SKIPPED;
4003 : :
4004 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4005 : : return TEST_SKIPPED;
4006 : :
4007 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4008 : :
4009 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4010 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4011 : : printf("Device doesn't support out-of-place scatter-gather "
4012 : : "in both input and output mbufs. "
4013 : : "Test Skipped.\n");
4014 : 0 : return TEST_SKIPPED;
4015 : : }
4016 : :
4017 : : /* Create KASUMI session */
4018 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4019 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4020 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4021 : 0 : tdata->key.data, tdata->key.len,
4022 : 0 : tdata->cipher_iv.len);
4023 [ # # ]: 0 : if (retval < 0)
4024 : : return retval;
4025 : :
4026 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4027 : : /* Append data which is padded to a multiple */
4028 : : /* of the algorithms block size */
4029 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4030 : :
4031 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4032 : : plaintext_pad_len, 10, 0);
4033 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4034 : : plaintext_pad_len, 3, 0);
4035 : :
4036 : : /* Append data which is padded to a multiple */
4037 : : /* of the algorithms block size */
4038 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4039 : :
4040 : : /* Create KASUMI operation */
4041 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4042 : 0 : tdata->cipher_iv.len,
4043 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4044 : 0 : tdata->validCipherOffsetInBits.len);
4045 [ # # ]: 0 : if (retval < 0)
4046 : : return retval;
4047 : :
4048 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4049 : : ut_params->op);
4050 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4051 : :
4052 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4053 [ # # ]: 0 : if (ut_params->obuf)
4054 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4055 : : plaintext_pad_len, buffer);
4056 : : else
4057 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4058 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4059 : : plaintext_pad_len, buffer);
4060 : :
4061 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4062 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4063 : : /* Validate obuf */
4064 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4065 : : ciphertext,
4066 : : reference_ciphertext,
4067 : : tdata->validCipherLenInBits.len,
4068 : : "KASUMI Ciphertext data not as expected");
4069 : : return 0;
4070 : : }
4071 : :
4072 : :
4073 : : static int
4074 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4075 : : {
4076 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4077 : : struct crypto_unittest_params *ut_params = &unittest_params;
4078 : :
4079 : : int retval;
4080 : : uint8_t *ciphertext, *plaintext;
4081 : : unsigned ciphertext_pad_len;
4082 : : unsigned ciphertext_len;
4083 : :
4084 : : /* Verify the capabilities */
4085 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4086 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4087 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4088 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4089 : : &cap_idx) == NULL)
4090 : : return TEST_SKIPPED;
4091 : :
4092 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4093 : : return TEST_SKIPPED;
4094 : :
4095 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4096 : : return TEST_SKIPPED;
4097 : :
4098 : : /* Create KASUMI session */
4099 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4100 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4101 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4102 : 0 : tdata->key.data, tdata->key.len,
4103 : 0 : tdata->cipher_iv.len);
4104 [ # # ]: 0 : if (retval < 0)
4105 : : return retval;
4106 : :
4107 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4108 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4109 : :
4110 : : /* Clear mbuf payload */
4111 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4112 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4113 : :
4114 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4115 : : /* Append data which is padded to a multiple */
4116 : : /* of the algorithms block size */
4117 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4118 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4119 : : ciphertext_pad_len);
4120 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4121 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4122 : :
4123 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4124 : :
4125 : : /* Create KASUMI operation */
4126 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4127 : 0 : tdata->cipher_iv.len,
4128 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4129 : 0 : tdata->validCipherOffsetInBits.len);
4130 [ # # ]: 0 : if (retval < 0)
4131 : : return retval;
4132 : :
4133 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4134 : : ut_params->op);
4135 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4136 : :
4137 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4138 [ # # ]: 0 : if (ut_params->obuf)
4139 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4140 : : else
4141 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4142 : :
4143 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4144 : :
4145 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4146 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4147 : : /* Validate obuf */
4148 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4149 : : plaintext,
4150 : : reference_plaintext,
4151 : : tdata->validCipherLenInBits.len,
4152 : : "KASUMI Plaintext data not as expected");
4153 : : return 0;
4154 : : }
4155 : :
4156 : : static int
4157 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4158 : : {
4159 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4160 : : struct crypto_unittest_params *ut_params = &unittest_params;
4161 : :
4162 : : int retval;
4163 : : uint8_t *ciphertext, *plaintext;
4164 : : unsigned ciphertext_pad_len;
4165 : : unsigned ciphertext_len;
4166 : : struct rte_cryptodev_info dev_info;
4167 : :
4168 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4169 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4170 : :
4171 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4172 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4173 : : printf("Device doesn't support RAW data-path APIs.\n");
4174 : 0 : return TEST_SKIPPED;
4175 : : }
4176 : :
4177 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4178 : : return TEST_SKIPPED;
4179 : :
4180 : : /* Verify the capabilities */
4181 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4182 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4183 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4184 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4185 : : &cap_idx) == NULL)
4186 : : return TEST_SKIPPED;
4187 : :
4188 : : /* Create KASUMI session */
4189 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4190 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4191 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4192 : 0 : tdata->key.data, tdata->key.len,
4193 : 0 : tdata->cipher_iv.len);
4194 [ # # ]: 0 : if (retval < 0)
4195 : : return retval;
4196 : :
4197 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4198 : :
4199 : : /* Clear mbuf payload */
4200 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4201 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4202 : :
4203 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4204 : : /* Append data which is padded to a multiple */
4205 : : /* of the algorithms block size */
4206 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4207 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4208 : : ciphertext_pad_len);
4209 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4210 : :
4211 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4212 : :
4213 : : /* Create KASUMI operation */
4214 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4215 : 0 : tdata->cipher_iv.len,
4216 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4217 : 0 : tdata->validCipherOffsetInBits.len);
4218 [ # # ]: 0 : if (retval < 0)
4219 : : return retval;
4220 : :
4221 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4222 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4223 : : 0);
4224 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4225 : : return retval;
4226 : : } else
4227 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4228 : : ut_params->op);
4229 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4230 : :
4231 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4232 [ # # ]: 0 : if (ut_params->obuf)
4233 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4234 : : else
4235 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4236 : :
4237 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4238 : :
4239 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4240 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4241 : : /* Validate obuf */
4242 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4243 : : plaintext,
4244 : : reference_plaintext,
4245 : : tdata->validCipherLenInBits.len,
4246 : : "KASUMI Plaintext data not as expected");
4247 : : return 0;
4248 : : }
4249 : :
4250 : : static int
4251 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4252 : : {
4253 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4254 : : struct crypto_unittest_params *ut_params = &unittest_params;
4255 : :
4256 : : int retval;
4257 : : uint8_t *plaintext, *ciphertext;
4258 : : unsigned plaintext_pad_len;
4259 : : unsigned plaintext_len;
4260 : : struct rte_cryptodev_info dev_info;
4261 : :
4262 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4263 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4264 : :
4265 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4266 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4267 : : printf("Device doesn't support RAW data-path APIs.\n");
4268 : 0 : return TEST_SKIPPED;
4269 : : }
4270 : :
4271 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4272 : : return TEST_SKIPPED;
4273 : :
4274 : : /* Verify the capabilities */
4275 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4276 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4277 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4278 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4279 : : &cap_idx) == NULL)
4280 : : return TEST_SKIPPED;
4281 : :
4282 : : /* Create SNOW 3G session */
4283 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4284 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4285 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4286 : 0 : tdata->key.data, tdata->key.len,
4287 : 0 : tdata->cipher_iv.len);
4288 [ # # ]: 0 : if (retval < 0)
4289 : : return retval;
4290 : :
4291 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4292 : :
4293 : : /* Clear mbuf payload */
4294 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4295 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4296 : :
4297 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4298 : : /* Append data which is padded to a multiple of */
4299 : : /* the algorithms block size */
4300 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4301 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4302 : : plaintext_pad_len);
4303 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4304 : :
4305 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4306 : :
4307 : : /* Create SNOW 3G operation */
4308 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4309 : 0 : tdata->cipher_iv.len,
4310 : 0 : tdata->validCipherLenInBits.len,
4311 : : 0);
4312 [ # # ]: 0 : if (retval < 0)
4313 : : return retval;
4314 : :
4315 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4316 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4317 : 0 : tdata->cipher_iv.len);
4318 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4319 : : return retval;
4320 : : } else
4321 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4322 : : ut_params->op);
4323 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4324 : :
4325 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4326 [ # # ]: 0 : if (ut_params->obuf)
4327 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4328 : : else
4329 : : ciphertext = plaintext;
4330 : :
4331 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4332 : :
4333 : : /* Validate obuf */
4334 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4335 : : ciphertext,
4336 : : tdata->ciphertext.data,
4337 : : tdata->validDataLenInBits.len,
4338 : : "SNOW 3G Ciphertext data not as expected");
4339 : : return 0;
4340 : : }
4341 : :
4342 : :
4343 : : static int
4344 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4345 : : {
4346 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4347 : : struct crypto_unittest_params *ut_params = &unittest_params;
4348 : : uint8_t *plaintext, *ciphertext;
4349 : :
4350 : : int retval;
4351 : : unsigned plaintext_pad_len;
4352 : : unsigned plaintext_len;
4353 : : struct rte_cryptodev_info dev_info;
4354 : :
4355 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4356 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4357 : :
4358 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4359 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4360 : : printf("Device does not support RAW data-path APIs.\n");
4361 : 0 : return -ENOTSUP;
4362 : : }
4363 : :
4364 : : /* Verify the capabilities */
4365 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4366 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4367 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4368 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4369 : : &cap_idx) == NULL)
4370 : : return TEST_SKIPPED;
4371 : :
4372 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4373 : : return TEST_SKIPPED;
4374 : :
4375 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4376 : : return TEST_SKIPPED;
4377 : :
4378 : : /* Create SNOW 3G session */
4379 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4380 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4381 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4382 : 0 : tdata->key.data, tdata->key.len,
4383 : 0 : tdata->cipher_iv.len);
4384 [ # # ]: 0 : if (retval < 0)
4385 : : return retval;
4386 : :
4387 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4388 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4389 : :
4390 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4391 : : "Failed to allocate input buffer in mempool");
4392 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4393 : : "Failed to allocate output buffer in mempool");
4394 : :
4395 : : /* Clear mbuf payload */
4396 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4397 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4398 : :
4399 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4400 : : /* Append data which is padded to a multiple of */
4401 : : /* the algorithms block size */
4402 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4403 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4404 : : plaintext_pad_len);
4405 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4406 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4407 : :
4408 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4409 : :
4410 : : /* Create SNOW 3G operation */
4411 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4412 : 0 : tdata->cipher_iv.len,
4413 : 0 : tdata->validCipherLenInBits.len,
4414 : : 0);
4415 [ # # ]: 0 : if (retval < 0)
4416 : : return retval;
4417 : :
4418 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4419 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4420 : 0 : tdata->cipher_iv.len);
4421 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4422 : : return retval;
4423 : : } else
4424 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4425 : : ut_params->op);
4426 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4427 : :
4428 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4429 [ # # ]: 0 : if (ut_params->obuf)
4430 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4431 : : else
4432 : : ciphertext = plaintext;
4433 : :
4434 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4435 : :
4436 : : /* Validate obuf */
4437 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4438 : : ciphertext,
4439 : : tdata->ciphertext.data,
4440 : : tdata->validDataLenInBits.len,
4441 : : "SNOW 3G Ciphertext data not as expected");
4442 : : return 0;
4443 : : }
4444 : :
4445 : : static int
4446 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4447 : : uint8_t sgl_in, uint8_t sgl_out)
4448 : : {
4449 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4450 : : struct crypto_unittest_params *ut_params = &unittest_params;
4451 : :
4452 : : int retval;
4453 : : unsigned int plaintext_pad_len;
4454 : : unsigned int plaintext_len;
4455 : : uint8_t buffer[10000];
4456 : : const uint8_t *ciphertext;
4457 : :
4458 : : struct rte_cryptodev_info dev_info;
4459 : :
4460 : : /* Verify the capabilities */
4461 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4462 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4463 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4464 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4465 : : &cap_idx) == NULL)
4466 : : return TEST_SKIPPED;
4467 : :
4468 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4469 : : return TEST_SKIPPED;
4470 : :
4471 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4472 : : return TEST_SKIPPED;
4473 : :
4474 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4475 : :
4476 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4477 : :
4478 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4479 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4480 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4481 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4482 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4483 : : printf("Device doesn't support out-of-place scatter gather type. "
4484 : : "Test Skipped.\n");
4485 : 0 : return TEST_SKIPPED;
4486 : : }
4487 : :
4488 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4489 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4490 : : printf("Device does not support RAW data-path APIs.\n");
4491 : 0 : return -ENOTSUP;
4492 : : }
4493 : :
4494 : : /* Create SNOW 3G session */
4495 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4496 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4497 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4498 : 0 : tdata->key.data, tdata->key.len,
4499 : 0 : tdata->cipher_iv.len);
4500 [ # # ]: 0 : if (retval < 0)
4501 : : return retval;
4502 : :
4503 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4504 : : /* Append data which is padded to a multiple of */
4505 : : /* the algorithms block size */
4506 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4507 : :
4508 [ # # ]: 0 : if (sgl_in)
4509 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4510 : : plaintext_pad_len, 10, 0);
4511 : : else {
4512 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4513 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4514 : : }
4515 : :
4516 [ # # ]: 0 : if (sgl_out)
4517 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4518 : : plaintext_pad_len, 3, 0);
4519 : : else {
4520 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4521 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4522 : : }
4523 : :
4524 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4525 : : "Failed to allocate input buffer in mempool");
4526 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4527 : : "Failed to allocate output buffer in mempool");
4528 : :
4529 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4530 : :
4531 : : /* Create SNOW 3G operation */
4532 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4533 : 0 : tdata->cipher_iv.len,
4534 : 0 : tdata->validCipherLenInBits.len,
4535 : : 0);
4536 [ # # ]: 0 : if (retval < 0)
4537 : : return retval;
4538 : :
4539 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4540 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4541 : 0 : tdata->cipher_iv.len);
4542 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4543 : : return retval;
4544 : : } else
4545 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4546 : : ut_params->op);
4547 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4548 : :
4549 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4550 [ # # ]: 0 : if (ut_params->obuf)
4551 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4552 : : plaintext_len, buffer);
4553 : : else
4554 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4555 : : plaintext_len, buffer);
4556 : :
4557 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4558 : :
4559 : : /* Validate obuf */
4560 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4561 : : ciphertext,
4562 : : tdata->ciphertext.data,
4563 : : tdata->validDataLenInBits.len,
4564 : : "SNOW 3G Ciphertext data not as expected");
4565 : :
4566 : : return 0;
4567 : : }
4568 : :
4569 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4570 : : static void
4571 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4572 : : {
4573 : : uint8_t curr_byte, prev_byte;
4574 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4575 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4576 : : unsigned i;
4577 : :
4578 : 0 : prev_byte = buffer[0];
4579 : 0 : buffer[0] >>= offset;
4580 : :
4581 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4582 : 0 : curr_byte = buffer[i];
4583 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4584 : 0 : (curr_byte >> offset);
4585 : : prev_byte = curr_byte;
4586 : : }
4587 : 0 : }
4588 : :
4589 : : static int
4590 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4591 : : {
4592 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4593 : : struct crypto_unittest_params *ut_params = &unittest_params;
4594 : : uint8_t *plaintext, *ciphertext;
4595 : : int retval;
4596 : : uint32_t plaintext_len;
4597 : : uint32_t plaintext_pad_len;
4598 : : uint8_t extra_offset = 4;
4599 : : uint8_t *expected_ciphertext_shifted;
4600 : : struct rte_cryptodev_info dev_info;
4601 : :
4602 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4603 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4604 : :
4605 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4606 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4607 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4608 : 0 : return TEST_SKIPPED;
4609 : : }
4610 : :
4611 : : /* Verify the capabilities */
4612 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4613 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4614 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4615 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4616 : : &cap_idx) == NULL)
4617 : : return TEST_SKIPPED;
4618 : :
4619 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4620 : : return TEST_SKIPPED;
4621 : :
4622 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4623 : : return TEST_SKIPPED;
4624 : :
4625 : : /* Create SNOW 3G session */
4626 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4627 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4628 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4629 : 0 : tdata->key.data, tdata->key.len,
4630 : 0 : tdata->cipher_iv.len);
4631 [ # # ]: 0 : if (retval < 0)
4632 : : return retval;
4633 : :
4634 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4635 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4636 : :
4637 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4638 : : "Failed to allocate input buffer in mempool");
4639 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4640 : : "Failed to allocate output buffer in mempool");
4641 : :
4642 : : /* Clear mbuf payload */
4643 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4644 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4645 : :
4646 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4647 : : /*
4648 : : * Append data which is padded to a
4649 : : * multiple of the algorithms block size
4650 : : */
4651 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4652 : :
4653 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4654 : : plaintext_pad_len);
4655 : :
4656 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4657 : :
4658 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4659 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4660 : :
4661 : : #ifdef RTE_APP_TEST_DEBUG
4662 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4663 : : #endif
4664 : : /* Create SNOW 3G operation */
4665 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4666 : 0 : tdata->cipher_iv.len,
4667 : 0 : tdata->validCipherLenInBits.len,
4668 : : extra_offset);
4669 [ # # ]: 0 : if (retval < 0)
4670 : : return retval;
4671 : :
4672 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4673 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4674 : 0 : tdata->cipher_iv.len);
4675 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4676 : : return retval;
4677 : : } else
4678 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4679 : : ut_params->op);
4680 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4681 : :
4682 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4683 [ # # ]: 0 : if (ut_params->obuf)
4684 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4685 : : else
4686 : : ciphertext = plaintext;
4687 : :
4688 : : #ifdef RTE_APP_TEST_DEBUG
4689 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4690 : : #endif
4691 : :
4692 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4693 : :
4694 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4695 : : "failed to reserve memory for ciphertext shifted\n");
4696 : :
4697 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4698 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
4699 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4700 : : extra_offset);
4701 : : /* Validate obuf */
4702 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
4703 : : ciphertext,
4704 : : expected_ciphertext_shifted,
4705 : : tdata->validDataLenInBits.len,
4706 : : extra_offset,
4707 : : "SNOW 3G Ciphertext data not as expected");
4708 : : return 0;
4709 : : }
4710 : :
4711 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4712 : : {
4713 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4714 : : struct crypto_unittest_params *ut_params = &unittest_params;
4715 : :
4716 : : int retval;
4717 : :
4718 : : uint8_t *plaintext, *ciphertext;
4719 : : unsigned ciphertext_pad_len;
4720 : : unsigned ciphertext_len;
4721 : : struct rte_cryptodev_info dev_info;
4722 : :
4723 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4724 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4725 : :
4726 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4727 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4728 : : printf("Device doesn't support RAW data-path APIs.\n");
4729 : 0 : return TEST_SKIPPED;
4730 : : }
4731 : :
4732 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4733 : : return TEST_SKIPPED;
4734 : :
4735 : : /* Verify the capabilities */
4736 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4737 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4738 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4739 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4740 : : &cap_idx) == NULL)
4741 : : return TEST_SKIPPED;
4742 : :
4743 : : /* Create SNOW 3G session */
4744 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4745 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4746 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4747 : 0 : tdata->key.data, tdata->key.len,
4748 : 0 : tdata->cipher_iv.len);
4749 [ # # ]: 0 : if (retval < 0)
4750 : : return retval;
4751 : :
4752 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4753 : :
4754 : : /* Clear mbuf payload */
4755 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4756 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4757 : :
4758 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4759 : : /* Append data which is padded to a multiple of */
4760 : : /* the algorithms block size */
4761 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4762 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4763 : : ciphertext_pad_len);
4764 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4765 : :
4766 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4767 : :
4768 : : /* Create SNOW 3G operation */
4769 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4770 : 0 : tdata->cipher_iv.len,
4771 : 0 : tdata->validCipherLenInBits.len,
4772 : 0 : tdata->cipher.offset_bits);
4773 [ # # ]: 0 : if (retval < 0)
4774 : : return retval;
4775 : :
4776 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4777 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4778 : 0 : tdata->cipher_iv.len);
4779 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4780 : : return retval;
4781 : : } else
4782 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4783 : : ut_params->op);
4784 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4785 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4786 [ # # ]: 0 : if (ut_params->obuf)
4787 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4788 : : else
4789 : : plaintext = ciphertext;
4790 : :
4791 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4792 : :
4793 : : /* Validate obuf */
4794 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
4795 : : tdata->plaintext.data,
4796 : : tdata->validDataLenInBits.len,
4797 : : "SNOW 3G Plaintext data not as expected");
4798 : : return 0;
4799 : : }
4800 : :
4801 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4802 : : {
4803 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4804 : : struct crypto_unittest_params *ut_params = &unittest_params;
4805 : :
4806 : : int retval;
4807 : :
4808 : : uint8_t *plaintext, *ciphertext;
4809 : : unsigned ciphertext_pad_len;
4810 : : unsigned ciphertext_len;
4811 : : struct rte_cryptodev_info dev_info;
4812 : :
4813 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4814 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4815 : :
4816 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4817 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4818 : : printf("Device does not support RAW data-path APIs.\n");
4819 : 0 : return -ENOTSUP;
4820 : : }
4821 : : /* Verify the capabilities */
4822 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4823 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4824 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4825 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4826 : : &cap_idx) == NULL)
4827 : : return TEST_SKIPPED;
4828 : :
4829 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4830 : : return TEST_SKIPPED;
4831 : :
4832 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4833 : : return TEST_SKIPPED;
4834 : :
4835 : : /* Create SNOW 3G session */
4836 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4837 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4838 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4839 : 0 : tdata->key.data, tdata->key.len,
4840 : 0 : tdata->cipher_iv.len);
4841 [ # # ]: 0 : if (retval < 0)
4842 : : return retval;
4843 : :
4844 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4845 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4846 : :
4847 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4848 : : "Failed to allocate input buffer");
4849 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4850 : : "Failed to allocate output buffer");
4851 : :
4852 : : /* Clear mbuf payload */
4853 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4854 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4855 : :
4856 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4857 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
4858 : :
4859 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4860 : : /* Append data which is padded to a multiple of */
4861 : : /* the algorithms block size */
4862 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4863 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4864 : : ciphertext_pad_len);
4865 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4866 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4867 : :
4868 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4869 : :
4870 : : /* Create SNOW 3G operation */
4871 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4872 : 0 : tdata->cipher_iv.len,
4873 : 0 : tdata->validCipherLenInBits.len,
4874 : : 0);
4875 [ # # ]: 0 : if (retval < 0)
4876 : : return retval;
4877 : :
4878 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4879 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4880 : 0 : tdata->cipher_iv.len);
4881 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4882 : : return retval;
4883 : : } else
4884 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4885 : : ut_params->op);
4886 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4887 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4888 [ # # ]: 0 : if (ut_params->obuf)
4889 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4890 : : else
4891 : : plaintext = ciphertext;
4892 : :
4893 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4894 : :
4895 : : /* Validate obuf */
4896 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
4897 : : tdata->plaintext.data,
4898 : : tdata->validDataLenInBits.len,
4899 : : "SNOW 3G Plaintext data not as expected");
4900 : : return 0;
4901 : : }
4902 : :
4903 : : static int
4904 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4905 : : {
4906 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4907 : : struct crypto_unittest_params *ut_params = &unittest_params;
4908 : :
4909 : : int retval;
4910 : :
4911 : : uint8_t *plaintext, *ciphertext;
4912 : : unsigned int plaintext_pad_len;
4913 : : unsigned int plaintext_len;
4914 : :
4915 : : struct rte_cryptodev_info dev_info;
4916 : :
4917 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4918 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4919 : :
4920 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4921 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
4922 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
4923 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4924 : 0 : return TEST_SKIPPED;
4925 : : }
4926 : :
4927 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4928 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4929 : : printf("Device doesn't support RAW data-path APIs.\n");
4930 : 0 : return TEST_SKIPPED;
4931 : : }
4932 : :
4933 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4934 : : return TEST_SKIPPED;
4935 : :
4936 : : /* Check if device supports ZUC EEA3 */
4937 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
4938 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
4939 : : return TEST_SKIPPED;
4940 : :
4941 : : /* Check if device supports ZUC EIA3 */
4942 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
4943 : 0 : tdata->key.len, tdata->auth_iv.len,
4944 : 0 : tdata->digest.len) < 0)
4945 : : return TEST_SKIPPED;
4946 : :
4947 : : /* Create ZUC session */
4948 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
4949 : 0 : ts_params->valid_devs[0],
4950 : : tdata);
4951 [ # # ]: 0 : if (retval != 0)
4952 : : return retval;
4953 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4954 : :
4955 : : /* clear mbuf payload */
4956 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4957 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4958 : :
4959 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4960 : : /* Append data which is padded to a multiple of */
4961 : : /* the algorithms block size */
4962 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4963 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4964 : : plaintext_pad_len);
4965 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4966 : :
4967 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4968 : :
4969 : : /* Create ZUC operation */
4970 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
4971 [ # # ]: 0 : if (retval < 0)
4972 : : return retval;
4973 : :
4974 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4975 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
4976 : 0 : tdata->cipher_iv.len);
4977 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4978 : : return retval;
4979 : : } else
4980 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4981 : : ut_params->op);
4982 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4983 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
4984 [ # # ]: 0 : if (ut_params->obuf)
4985 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4986 : : else
4987 : : ciphertext = plaintext;
4988 : :
4989 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4990 : : /* Validate obuf */
4991 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4992 : : ciphertext,
4993 : : tdata->ciphertext.data,
4994 : : tdata->validDataLenInBits.len,
4995 : : "ZUC Ciphertext data not as expected");
4996 : :
4997 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4998 : 0 : + plaintext_pad_len;
4999 : :
5000 : : /* Validate obuf */
5001 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5002 : : ut_params->digest,
5003 : : tdata->digest.data,
5004 : : tdata->digest.len,
5005 : : "ZUC Generated auth tag not as expected");
5006 : : return 0;
5007 : : }
5008 : :
5009 : : static int
5010 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5011 : : {
5012 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5013 : : struct crypto_unittest_params *ut_params = &unittest_params;
5014 : :
5015 : : int retval;
5016 : :
5017 : : uint8_t *plaintext, *ciphertext;
5018 : : unsigned plaintext_pad_len;
5019 : : unsigned plaintext_len;
5020 : : struct rte_cryptodev_info dev_info;
5021 : :
5022 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5023 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5024 : :
5025 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5026 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5027 : : printf("Device doesn't support RAW data-path APIs.\n");
5028 : 0 : return TEST_SKIPPED;
5029 : : }
5030 : :
5031 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5032 : : return TEST_SKIPPED;
5033 : :
5034 : : /* Verify the capabilities */
5035 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5036 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5037 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5038 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5039 : : &cap_idx) == NULL)
5040 : : return TEST_SKIPPED;
5041 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5042 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5043 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5044 : : &cap_idx) == NULL)
5045 : : return TEST_SKIPPED;
5046 : :
5047 : : /* Create SNOW 3G session */
5048 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5049 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5050 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5051 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5052 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5053 : : tdata->key.data, tdata->key.len,
5054 : 0 : tdata->key.data, tdata->key.len,
5055 : 0 : tdata->auth_iv.len, tdata->digest.len,
5056 : 0 : tdata->cipher_iv.len);
5057 [ # # ]: 0 : if (retval != 0)
5058 : : return retval;
5059 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5060 : :
5061 : : /* clear mbuf payload */
5062 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5063 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5064 : :
5065 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5066 : : /* Append data which is padded to a multiple of */
5067 : : /* the algorithms block size */
5068 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5069 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5070 : : plaintext_pad_len);
5071 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5072 : :
5073 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5074 : :
5075 : : /* Create SNOW 3G operation */
5076 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5077 : 0 : tdata->digest.len, tdata->auth_iv.data,
5078 : 0 : tdata->auth_iv.len,
5079 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5080 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5081 : 0 : tdata->validCipherLenInBits.len,
5082 : : 0,
5083 : 0 : tdata->validAuthLenInBits.len,
5084 : : 0
5085 : : );
5086 [ # # ]: 0 : if (retval < 0)
5087 : : return retval;
5088 : :
5089 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5090 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5091 : 0 : tdata->cipher_iv.len);
5092 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5093 : : return retval;
5094 : : } else
5095 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5096 : : ut_params->op);
5097 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5098 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5099 [ # # ]: 0 : if (ut_params->obuf)
5100 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5101 : : else
5102 : : ciphertext = plaintext;
5103 : :
5104 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5105 : : /* Validate obuf */
5106 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5107 : : ciphertext,
5108 : : tdata->ciphertext.data,
5109 : : tdata->validDataLenInBits.len,
5110 : : "SNOW 3G Ciphertext data not as expected");
5111 : :
5112 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5113 : 0 : + plaintext_pad_len;
5114 : :
5115 : : /* Validate obuf */
5116 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5117 : : ut_params->digest,
5118 : : tdata->digest.data,
5119 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5120 : : "SNOW 3G Generated auth tag not as expected");
5121 : : return 0;
5122 : : }
5123 : :
5124 : : static int
5125 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5126 : : uint8_t op_mode, uint8_t verify)
5127 : : {
5128 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5129 : : struct crypto_unittest_params *ut_params = &unittest_params;
5130 : :
5131 : : int retval;
5132 : :
5133 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5134 : : unsigned int plaintext_pad_len;
5135 : : unsigned int plaintext_len;
5136 : : unsigned int ciphertext_pad_len;
5137 : : unsigned int ciphertext_len;
5138 : :
5139 : : struct rte_cryptodev_info dev_info;
5140 : :
5141 : : /* Verify the capabilities */
5142 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5143 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5144 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5145 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5146 : : &cap_idx) == NULL)
5147 : : return TEST_SKIPPED;
5148 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5149 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5150 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5151 : : &cap_idx) == NULL)
5152 : : return TEST_SKIPPED;
5153 : :
5154 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5155 : : return TEST_SKIPPED;
5156 : :
5157 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5158 : :
5159 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5160 : :
5161 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5162 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5163 : : printf("Device doesn't support digest encrypted.\n");
5164 : 0 : return TEST_SKIPPED;
5165 : : }
5166 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5167 : : return TEST_SKIPPED;
5168 : : }
5169 : :
5170 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5171 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5172 : : printf("Device doesn't support RAW data-path APIs.\n");
5173 : 0 : return TEST_SKIPPED;
5174 : : }
5175 : :
5176 : : /* Create SNOW 3G session */
5177 : 0 : retval = create_wireless_algo_auth_cipher_session(
5178 : 0 : ts_params->valid_devs[0],
5179 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5180 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5181 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5182 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5183 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5184 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5185 : : tdata->key.data, tdata->key.len,
5186 : 0 : tdata->key.data, tdata->key.len,
5187 : 0 : tdata->auth_iv.len, tdata->digest.len,
5188 : 0 : tdata->cipher_iv.len);
5189 [ # # ]: 0 : if (retval != 0)
5190 : : return retval;
5191 : :
5192 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5193 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5194 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5195 : :
5196 : : /* clear mbuf payload */
5197 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5198 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5199 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5200 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5201 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5202 : :
5203 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5204 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5205 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5206 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5207 : :
5208 [ # # ]: 0 : if (verify) {
5209 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5210 : : ciphertext_pad_len);
5211 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5212 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5213 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5214 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5215 : : ciphertext_len);
5216 : : } else {
5217 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5218 : : plaintext_pad_len);
5219 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5220 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5221 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5222 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5223 : : }
5224 : :
5225 : : /* Create SNOW 3G operation */
5226 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5227 : 0 : tdata->digest.data, tdata->digest.len,
5228 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5229 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5230 : 0 : (tdata->digest.offset_bytes == 0 ?
5231 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5232 : : : tdata->digest.offset_bytes),
5233 : 0 : tdata->validCipherLenInBits.len,
5234 : 0 : tdata->cipher.offset_bits,
5235 : 0 : tdata->validAuthLenInBits.len,
5236 [ # # ]: 0 : tdata->auth.offset_bits,
5237 : : op_mode, 0, verify);
5238 : :
5239 [ # # ]: 0 : if (retval < 0)
5240 : : return retval;
5241 : :
5242 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5243 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5244 : 0 : tdata->cipher_iv.len);
5245 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5246 : : return retval;
5247 : : } else
5248 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5249 : : ut_params->op);
5250 : :
5251 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5252 : :
5253 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5254 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5255 : :
5256 [ # # ]: 0 : if (verify) {
5257 [ # # ]: 0 : if (ut_params->obuf)
5258 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5259 : : uint8_t *);
5260 : : else
5261 : 0 : plaintext = ciphertext +
5262 : 0 : (tdata->cipher.offset_bits >> 3);
5263 : :
5264 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5265 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5266 : 0 : debug_hexdump(stdout, "plaintext expected:",
5267 : 0 : tdata->plaintext.data,
5268 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5269 : : } else {
5270 [ # # ]: 0 : if (ut_params->obuf)
5271 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5272 : : uint8_t *);
5273 : : else
5274 : : ciphertext = plaintext;
5275 : :
5276 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5277 : : ciphertext_len);
5278 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5279 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5280 : :
5281 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5282 : 0 : + (tdata->digest.offset_bytes == 0 ?
5283 [ # # ]: 0 : plaintext_pad_len : tdata->digest.offset_bytes);
5284 : :
5285 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5286 : 0 : tdata->digest.len);
5287 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5288 : 0 : tdata->digest.len);
5289 : : }
5290 : :
5291 : : /* Validate obuf */
5292 [ # # ]: 0 : if (verify) {
5293 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5294 : : plaintext,
5295 : : tdata->plaintext.data,
5296 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5297 : : (tdata->digest.len << 3)),
5298 : : tdata->cipher.offset_bits,
5299 : : "SNOW 3G Plaintext data not as expected");
5300 : : } else {
5301 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5302 : : ciphertext,
5303 : : tdata->ciphertext.data,
5304 : : (tdata->validDataLenInBits.len -
5305 : : tdata->cipher.offset_bits),
5306 : : tdata->cipher.offset_bits,
5307 : : "SNOW 3G Ciphertext data not as expected");
5308 : :
5309 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5310 : : ut_params->digest,
5311 : : tdata->digest.data,
5312 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5313 : : "SNOW 3G Generated auth tag not as expected");
5314 : : }
5315 : : return 0;
5316 : : }
5317 : :
5318 : : static int
5319 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5320 : : uint8_t op_mode, uint8_t verify)
5321 : : {
5322 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5323 : : struct crypto_unittest_params *ut_params = &unittest_params;
5324 : :
5325 : : int retval;
5326 : :
5327 : : const uint8_t *plaintext = NULL;
5328 : : const uint8_t *ciphertext = NULL;
5329 : : const uint8_t *digest = NULL;
5330 : : unsigned int plaintext_pad_len;
5331 : : unsigned int plaintext_len;
5332 : : unsigned int ciphertext_pad_len;
5333 : : unsigned int ciphertext_len;
5334 : : uint8_t buffer[10000];
5335 : : uint8_t digest_buffer[10000];
5336 : :
5337 : : struct rte_cryptodev_info dev_info;
5338 : :
5339 : : /* Verify the capabilities */
5340 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5341 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5342 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5343 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5344 : : &cap_idx) == NULL)
5345 : : return TEST_SKIPPED;
5346 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5347 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5348 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5349 : : &cap_idx) == NULL)
5350 : : return TEST_SKIPPED;
5351 : :
5352 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5353 : : return TEST_SKIPPED;
5354 : :
5355 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5356 : :
5357 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5358 : :
5359 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5360 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5361 : : printf("Device doesn't support in-place scatter-gather "
5362 : : "in both input and output mbufs.\n");
5363 : 0 : return TEST_SKIPPED;
5364 : : }
5365 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5366 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5367 : : printf("Device doesn't support RAW data-path APIs.\n");
5368 : 0 : return TEST_SKIPPED;
5369 : : }
5370 : : } else {
5371 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5372 : : return TEST_SKIPPED;
5373 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5374 : : printf("Device doesn't support out-of-place scatter-gather "
5375 : : "in both input and output mbufs.\n");
5376 : 0 : return TEST_SKIPPED;
5377 : : }
5378 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5379 : : printf("Device doesn't support digest encrypted.\n");
5380 : 0 : return TEST_SKIPPED;
5381 : : }
5382 : : }
5383 : :
5384 : : /* Create SNOW 3G session */
5385 : 0 : retval = create_wireless_algo_auth_cipher_session(
5386 : 0 : ts_params->valid_devs[0],
5387 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5388 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5389 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5390 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5391 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5392 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5393 : : tdata->key.data, tdata->key.len,
5394 : 0 : tdata->key.data, tdata->key.len,
5395 : 0 : tdata->auth_iv.len, tdata->digest.len,
5396 : 0 : tdata->cipher_iv.len);
5397 : :
5398 [ # # ]: 0 : if (retval != 0)
5399 : : return retval;
5400 : :
5401 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5402 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5403 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5404 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5405 : :
5406 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5407 : : plaintext_pad_len, 15, 0);
5408 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5409 : : "Failed to allocate input buffer in mempool");
5410 : :
5411 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5412 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5413 : : plaintext_pad_len, 15, 0);
5414 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5415 : : "Failed to allocate output buffer in mempool");
5416 : : }
5417 : :
5418 [ # # ]: 0 : if (verify) {
5419 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5420 : 0 : tdata->ciphertext.data);
5421 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5422 : : ciphertext_len, buffer);
5423 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5424 : : ciphertext_len);
5425 : : } else {
5426 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5427 : 0 : tdata->plaintext.data);
5428 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5429 : : plaintext_len, buffer);
5430 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5431 : : plaintext_len);
5432 : : }
5433 : : memset(buffer, 0, sizeof(buffer));
5434 : :
5435 : : /* Create SNOW 3G operation */
5436 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5437 : 0 : tdata->digest.data, tdata->digest.len,
5438 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5439 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5440 : 0 : (tdata->digest.offset_bytes == 0 ?
5441 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5442 : : : tdata->digest.offset_bytes),
5443 : 0 : tdata->validCipherLenInBits.len,
5444 : 0 : tdata->cipher.offset_bits,
5445 : 0 : tdata->validAuthLenInBits.len,
5446 [ # # ]: 0 : tdata->auth.offset_bits,
5447 : : op_mode, 1, verify);
5448 : :
5449 [ # # ]: 0 : if (retval < 0)
5450 : : return retval;
5451 : :
5452 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5453 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5454 : 0 : tdata->cipher_iv.len);
5455 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5456 : : return retval;
5457 : : } else
5458 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5459 : : ut_params->op);
5460 : :
5461 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5462 : :
5463 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5464 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5465 : :
5466 [ # # ]: 0 : if (verify) {
5467 [ # # ]: 0 : if (ut_params->obuf)
5468 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5469 : : plaintext_len, buffer);
5470 : : else
5471 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5472 : : plaintext_len, buffer);
5473 : :
5474 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5475 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5476 : 0 : debug_hexdump(stdout, "plaintext expected:",
5477 : 0 : tdata->plaintext.data,
5478 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5479 : : } else {
5480 [ # # ]: 0 : if (ut_params->obuf)
5481 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5482 : : ciphertext_len, buffer);
5483 : : else
5484 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5485 : : ciphertext_len, buffer);
5486 : :
5487 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5488 : : ciphertext_len);
5489 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5490 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5491 : :
5492 [ # # ]: 0 : if (ut_params->obuf)
5493 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5494 : 0 : (tdata->digest.offset_bytes == 0 ?
5495 : : plaintext_pad_len : tdata->digest.offset_bytes),
5496 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5497 : : else
5498 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5499 : 0 : (tdata->digest.offset_bytes == 0 ?
5500 : : plaintext_pad_len : tdata->digest.offset_bytes),
5501 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5502 : :
5503 : 0 : debug_hexdump(stdout, "digest:", digest,
5504 : 0 : tdata->digest.len);
5505 : 0 : debug_hexdump(stdout, "digest expected:",
5506 : 0 : tdata->digest.data, tdata->digest.len);
5507 : : }
5508 : :
5509 : : /* Validate obuf */
5510 [ # # ]: 0 : if (verify) {
5511 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5512 : : plaintext,
5513 : : tdata->plaintext.data,
5514 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5515 : : (tdata->digest.len << 3)),
5516 : : tdata->cipher.offset_bits,
5517 : : "SNOW 3G Plaintext data not as expected");
5518 : : } else {
5519 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5520 : : ciphertext,
5521 : : tdata->ciphertext.data,
5522 : : (tdata->validDataLenInBits.len -
5523 : : tdata->cipher.offset_bits),
5524 : : tdata->cipher.offset_bits,
5525 : : "SNOW 3G Ciphertext data not as expected");
5526 : :
5527 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5528 : : digest,
5529 : : tdata->digest.data,
5530 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5531 : : "SNOW 3G Generated auth tag not as expected");
5532 : : }
5533 : : return 0;
5534 : : }
5535 : :
5536 : : static int
5537 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5538 : : uint8_t op_mode, uint8_t verify)
5539 : : {
5540 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5541 : : struct crypto_unittest_params *ut_params = &unittest_params;
5542 : :
5543 : : int retval;
5544 : :
5545 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5546 : : unsigned int plaintext_pad_len;
5547 : : unsigned int plaintext_len;
5548 : : unsigned int ciphertext_pad_len;
5549 : : unsigned int ciphertext_len;
5550 : :
5551 : : struct rte_cryptodev_info dev_info;
5552 : :
5553 : : /* Verify the capabilities */
5554 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5555 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5556 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5557 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5558 : : &cap_idx) == NULL)
5559 : : return TEST_SKIPPED;
5560 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5561 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5562 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5563 : : &cap_idx) == NULL)
5564 : : return TEST_SKIPPED;
5565 : :
5566 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5567 : :
5568 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5569 : :
5570 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5571 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5572 : : printf("Device doesn't support RAW data-path APIs.\n");
5573 : 0 : return TEST_SKIPPED;
5574 : : }
5575 : :
5576 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5577 : : return TEST_SKIPPED;
5578 : :
5579 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5580 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5581 : : return TEST_SKIPPED;
5582 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5583 : : printf("Device doesn't support digest encrypted.\n");
5584 : 0 : return TEST_SKIPPED;
5585 : : }
5586 : : }
5587 : :
5588 : : /* Create KASUMI session */
5589 : 0 : retval = create_wireless_algo_auth_cipher_session(
5590 : 0 : ts_params->valid_devs[0],
5591 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5592 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5593 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5594 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5595 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5596 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5597 : : tdata->key.data, tdata->key.len,
5598 : 0 : tdata->key.data, tdata->key.len,
5599 : 0 : 0, tdata->digest.len,
5600 : 0 : tdata->cipher_iv.len);
5601 : :
5602 [ # # ]: 0 : if (retval != 0)
5603 : : return retval;
5604 : :
5605 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5606 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5607 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5608 : :
5609 : : /* clear mbuf payload */
5610 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5611 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5612 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5613 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5614 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5615 : :
5616 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5617 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5618 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5619 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5620 : :
5621 [ # # ]: 0 : if (verify) {
5622 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5623 : : ciphertext_pad_len);
5624 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5625 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5626 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5627 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5628 : : ciphertext_len);
5629 : : } else {
5630 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5631 : : plaintext_pad_len);
5632 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5633 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5634 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5635 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5636 : : plaintext_len);
5637 : : }
5638 : :
5639 : : /* Create KASUMI operation */
5640 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5641 : 0 : tdata->digest.data, tdata->digest.len,
5642 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5643 : : NULL, 0,
5644 : 0 : (tdata->digest.offset_bytes == 0 ?
5645 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5646 : : : tdata->digest.offset_bytes),
5647 : 0 : tdata->validCipherLenInBits.len,
5648 : 0 : tdata->validCipherOffsetInBits.len,
5649 [ # # ]: 0 : tdata->validAuthLenInBits.len,
5650 : : 0,
5651 : : op_mode, 0, verify);
5652 : :
5653 [ # # ]: 0 : if (retval < 0)
5654 : : return retval;
5655 : :
5656 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5657 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5658 : 0 : tdata->cipher_iv.len);
5659 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5660 : : return retval;
5661 : : } else
5662 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5663 : : ut_params->op);
5664 : :
5665 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5666 : :
5667 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5668 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5669 : :
5670 : :
5671 [ # # ]: 0 : if (verify) {
5672 [ # # ]: 0 : if (ut_params->obuf)
5673 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5674 : : uint8_t *);
5675 : : else
5676 : : plaintext = ciphertext;
5677 : :
5678 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5679 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5680 : 0 : debug_hexdump(stdout, "plaintext expected:",
5681 : 0 : tdata->plaintext.data,
5682 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5683 : : } else {
5684 [ # # ]: 0 : if (ut_params->obuf)
5685 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5686 : : uint8_t *);
5687 : : else
5688 : : ciphertext = plaintext;
5689 : :
5690 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5691 : : ciphertext_len);
5692 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5693 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5694 : :
5695 : 0 : ut_params->digest = rte_pktmbuf_mtod(
5696 : 0 : ut_params->obuf, uint8_t *) +
5697 : 0 : (tdata->digest.offset_bytes == 0 ?
5698 [ # # ]: 0 : plaintext_pad_len : tdata->digest.offset_bytes);
5699 : :
5700 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5701 : 0 : tdata->digest.len);
5702 : 0 : debug_hexdump(stdout, "digest expected:",
5703 : 0 : tdata->digest.data, tdata->digest.len);
5704 : : }
5705 : :
5706 : : /* Validate obuf */
5707 [ # # ]: 0 : if (verify) {
5708 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5709 : : plaintext,
5710 : : tdata->plaintext.data,
5711 : : tdata->plaintext.len >> 3,
5712 : : "KASUMI Plaintext data not as expected");
5713 : : } else {
5714 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5715 : : ciphertext,
5716 : : tdata->ciphertext.data,
5717 : : tdata->ciphertext.len >> 3,
5718 : : "KASUMI Ciphertext data not as expected");
5719 : :
5720 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5721 : : ut_params->digest,
5722 : : tdata->digest.data,
5723 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
5724 : : "KASUMI Generated auth tag not as expected");
5725 : : }
5726 : : return 0;
5727 : : }
5728 : :
5729 : : static int
5730 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5731 : : uint8_t op_mode, uint8_t verify)
5732 : : {
5733 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5734 : : struct crypto_unittest_params *ut_params = &unittest_params;
5735 : :
5736 : : int retval;
5737 : :
5738 : : const uint8_t *plaintext = NULL;
5739 : : const uint8_t *ciphertext = NULL;
5740 : : const uint8_t *digest = NULL;
5741 : : unsigned int plaintext_pad_len;
5742 : : unsigned int plaintext_len;
5743 : : unsigned int ciphertext_pad_len;
5744 : : unsigned int ciphertext_len;
5745 : : uint8_t buffer[10000];
5746 : : uint8_t digest_buffer[10000];
5747 : :
5748 : : struct rte_cryptodev_info dev_info;
5749 : :
5750 : : /* Verify the capabilities */
5751 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5752 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5753 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5754 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5755 : : &cap_idx) == NULL)
5756 : : return TEST_SKIPPED;
5757 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5758 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5759 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5760 : : &cap_idx) == NULL)
5761 : : return TEST_SKIPPED;
5762 : :
5763 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5764 : : return TEST_SKIPPED;
5765 : :
5766 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5767 : :
5768 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5769 : :
5770 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5771 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5772 : : printf("Device doesn't support in-place scatter-gather "
5773 : : "in both input and output mbufs.\n");
5774 : 0 : return TEST_SKIPPED;
5775 : : }
5776 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5777 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5778 : : printf("Device doesn't support RAW data-path APIs.\n");
5779 : 0 : return TEST_SKIPPED;
5780 : : }
5781 : : } else {
5782 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5783 : : return TEST_SKIPPED;
5784 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5785 : : printf("Device doesn't support out-of-place scatter-gather "
5786 : : "in both input and output mbufs.\n");
5787 : 0 : return TEST_SKIPPED;
5788 : : }
5789 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5790 : : printf("Device doesn't support digest encrypted.\n");
5791 : 0 : return TEST_SKIPPED;
5792 : : }
5793 : : }
5794 : :
5795 : : /* Create KASUMI session */
5796 : 0 : retval = create_wireless_algo_auth_cipher_session(
5797 : 0 : ts_params->valid_devs[0],
5798 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5799 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5800 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5801 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5802 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5803 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5804 : : tdata->key.data, tdata->key.len,
5805 : 0 : tdata->key.data, tdata->key.len,
5806 : 0 : 0, tdata->digest.len,
5807 : 0 : tdata->cipher_iv.len);
5808 : :
5809 [ # # ]: 0 : if (retval != 0)
5810 : : return retval;
5811 : :
5812 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5813 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5814 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5815 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5816 : :
5817 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5818 : : plaintext_pad_len, 15, 0);
5819 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5820 : : "Failed to allocate input buffer in mempool");
5821 : :
5822 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5823 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5824 : : plaintext_pad_len, 15, 0);
5825 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5826 : : "Failed to allocate output buffer in mempool");
5827 : : }
5828 : :
5829 [ # # ]: 0 : if (verify) {
5830 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5831 : 0 : tdata->ciphertext.data);
5832 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5833 : : ciphertext_len, buffer);
5834 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5835 : : ciphertext_len);
5836 : : } else {
5837 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5838 : 0 : tdata->plaintext.data);
5839 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5840 : : plaintext_len, buffer);
5841 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5842 : : plaintext_len);
5843 : : }
5844 : : memset(buffer, 0, sizeof(buffer));
5845 : :
5846 : : /* Create KASUMI operation */
5847 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5848 : 0 : tdata->digest.data, tdata->digest.len,
5849 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5850 : : NULL, 0,
5851 : 0 : (tdata->digest.offset_bytes == 0 ?
5852 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5853 : : : tdata->digest.offset_bytes),
5854 : 0 : tdata->validCipherLenInBits.len,
5855 : 0 : tdata->validCipherOffsetInBits.len,
5856 [ # # ]: 0 : tdata->validAuthLenInBits.len,
5857 : : 0,
5858 : : op_mode, 1, verify);
5859 : :
5860 [ # # ]: 0 : if (retval < 0)
5861 : : return retval;
5862 : :
5863 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5864 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5865 : 0 : tdata->cipher_iv.len);
5866 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5867 : : return retval;
5868 : : } else
5869 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5870 : : ut_params->op);
5871 : :
5872 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5873 : :
5874 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5875 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5876 : :
5877 [ # # ]: 0 : if (verify) {
5878 [ # # ]: 0 : if (ut_params->obuf)
5879 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5880 : : plaintext_len, buffer);
5881 : : else
5882 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5883 : : plaintext_len, buffer);
5884 : :
5885 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5886 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5887 : 0 : debug_hexdump(stdout, "plaintext expected:",
5888 : 0 : tdata->plaintext.data,
5889 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5890 : : } else {
5891 [ # # ]: 0 : if (ut_params->obuf)
5892 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5893 : : ciphertext_len, buffer);
5894 : : else
5895 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5896 : : ciphertext_len, buffer);
5897 : :
5898 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5899 : : ciphertext_len);
5900 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5901 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5902 : :
5903 [ # # ]: 0 : if (ut_params->obuf)
5904 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5905 : 0 : (tdata->digest.offset_bytes == 0 ?
5906 : : plaintext_pad_len : tdata->digest.offset_bytes),
5907 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5908 : : else
5909 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5910 : 0 : (tdata->digest.offset_bytes == 0 ?
5911 : : plaintext_pad_len : tdata->digest.offset_bytes),
5912 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5913 : :
5914 : 0 : debug_hexdump(stdout, "digest:", digest,
5915 : 0 : tdata->digest.len);
5916 : 0 : debug_hexdump(stdout, "digest expected:",
5917 : 0 : tdata->digest.data, tdata->digest.len);
5918 : : }
5919 : :
5920 : : /* Validate obuf */
5921 [ # # ]: 0 : if (verify) {
5922 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5923 : : plaintext,
5924 : : tdata->plaintext.data,
5925 : : tdata->plaintext.len >> 3,
5926 : : "KASUMI Plaintext data not as expected");
5927 : : } else {
5928 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5929 : : ciphertext,
5930 : : tdata->ciphertext.data,
5931 : : tdata->validDataLenInBits.len,
5932 : : "KASUMI Ciphertext data not as expected");
5933 : :
5934 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5935 : : digest,
5936 : : tdata->digest.data,
5937 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
5938 : : "KASUMI Generated auth tag not as expected");
5939 : : }
5940 : : return 0;
5941 : : }
5942 : :
5943 : : static int
5944 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5945 : : {
5946 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5947 : : struct crypto_unittest_params *ut_params = &unittest_params;
5948 : :
5949 : : int retval;
5950 : :
5951 : : uint8_t *plaintext, *ciphertext;
5952 : : unsigned plaintext_pad_len;
5953 : : unsigned plaintext_len;
5954 : : struct rte_cryptodev_info dev_info;
5955 : :
5956 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5957 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5958 : :
5959 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5960 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5961 : : printf("Device doesn't support RAW data-path APIs.\n");
5962 : 0 : return TEST_SKIPPED;
5963 : : }
5964 : :
5965 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5966 : : return TEST_SKIPPED;
5967 : :
5968 : : /* Verify the capabilities */
5969 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5970 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5971 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5972 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5973 : : &cap_idx) == NULL)
5974 : : return TEST_SKIPPED;
5975 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5976 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5977 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5978 : : &cap_idx) == NULL)
5979 : : return TEST_SKIPPED;
5980 : :
5981 : : /* Create KASUMI session */
5982 : 0 : retval = create_wireless_algo_cipher_auth_session(
5983 : 0 : ts_params->valid_devs[0],
5984 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5985 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5986 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5987 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5988 : : tdata->key.data, tdata->key.len,
5989 : 0 : tdata->key.data, tdata->key.len,
5990 : 0 : 0, tdata->digest.len,
5991 : 0 : tdata->cipher_iv.len);
5992 [ # # ]: 0 : if (retval != 0)
5993 : : return retval;
5994 : :
5995 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5996 : :
5997 : : /* clear mbuf payload */
5998 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5999 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6000 : :
6001 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6002 : : /* Append data which is padded to a multiple of */
6003 : : /* the algorithms block size */
6004 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6005 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6006 : : plaintext_pad_len);
6007 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6008 : :
6009 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6010 : :
6011 : : /* Create KASUMI operation */
6012 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6013 : 0 : tdata->digest.len, NULL, 0,
6014 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6015 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6016 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6017 : 0 : tdata->validCipherOffsetInBits.len,
6018 : 0 : tdata->validAuthLenInBits.len,
6019 : : 0
6020 : : );
6021 [ # # ]: 0 : if (retval < 0)
6022 : : return retval;
6023 : :
6024 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6025 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6026 : 0 : tdata->cipher_iv.len);
6027 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6028 : : return retval;
6029 : : } else
6030 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6031 : : ut_params->op);
6032 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6033 : :
6034 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6035 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6036 : : else
6037 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6038 : :
6039 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6040 : : tdata->validCipherOffsetInBits.len >> 3);
6041 : :
6042 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6043 : 0 : + plaintext_pad_len;
6044 : :
6045 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6046 : : (tdata->validCipherOffsetInBits.len >> 3);
6047 : : /* Validate obuf */
6048 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6049 : : ciphertext,
6050 : : reference_ciphertext,
6051 : : tdata->validCipherLenInBits.len,
6052 : : "KASUMI Ciphertext data not as expected");
6053 : :
6054 : : /* Validate obuf */
6055 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6056 : : ut_params->digest,
6057 : : tdata->digest.data,
6058 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6059 : : "KASUMI Generated auth tag not as expected");
6060 : : return 0;
6061 : : }
6062 : :
6063 : : static int
6064 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6065 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6066 : : const uint16_t key_size, const uint16_t iv_size)
6067 : : {
6068 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6069 : : const struct rte_cryptodev_symmetric_capability *cap;
6070 : :
6071 : : /* Check if device supports the algorithm */
6072 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6073 : 0 : cap_idx.algo.cipher = cipher_algo;
6074 : :
6075 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6076 : : &cap_idx);
6077 : :
6078 [ # # ]: 0 : if (cap == NULL)
6079 : : return -1;
6080 : :
6081 : : /* Check if device supports key size and IV size */
6082 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6083 : : iv_size) < 0) {
6084 : 0 : return -1;
6085 : : }
6086 : :
6087 : : return 0;
6088 : : }
6089 : :
6090 : : static int
6091 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6092 : : const enum rte_crypto_auth_algorithm auth_algo,
6093 : : const uint16_t key_size, const uint16_t iv_size,
6094 : : const uint16_t tag_size)
6095 : : {
6096 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6097 : : const struct rte_cryptodev_symmetric_capability *cap;
6098 : :
6099 : : /* Check if device supports the algorithm */
6100 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6101 : 0 : cap_idx.algo.auth = auth_algo;
6102 : :
6103 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6104 : : &cap_idx);
6105 : :
6106 [ # # ]: 0 : if (cap == NULL)
6107 : : return -1;
6108 : :
6109 : : /* Check if device supports key size and IV size */
6110 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6111 : : tag_size, iv_size) < 0) {
6112 : 0 : return -1;
6113 : : }
6114 : :
6115 : : return 0;
6116 : : }
6117 : :
6118 : : static int
6119 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6120 : : enum rte_crypto_cipher_operation direction)
6121 : : {
6122 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6123 : : struct crypto_unittest_params *ut_params = &unittest_params;
6124 : :
6125 : : int retval;
6126 : : uint8_t *plaintext = NULL;
6127 : : uint8_t *ciphertext = NULL;
6128 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6129 : : unsigned int plaintext_len = 0;
6130 : : unsigned int ciphertext_len = 0;
6131 : : struct rte_cryptodev_info dev_info;
6132 : :
6133 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6134 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6135 : :
6136 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6137 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6138 : : printf("Device doesn't support RAW data-path APIs.\n");
6139 : 0 : return TEST_SKIPPED;
6140 : : }
6141 : :
6142 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6143 : : return TEST_SKIPPED;
6144 : :
6145 : : /* Check if device supports ZUC EEA3 */
6146 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6147 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6148 : : return TEST_SKIPPED;
6149 : :
6150 : : /* Create ZUC session */
6151 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6152 : : direction,
6153 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6154 : 0 : tdata->key.data, tdata->key.len,
6155 : 0 : tdata->cipher_iv.len);
6156 [ # # ]: 0 : if (retval != 0)
6157 : : return retval;
6158 : :
6159 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6160 : :
6161 : : /* Clear mbuf payload */
6162 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6163 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6164 : :
6165 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6166 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6167 : : /* Append data which is padded to a multiple */
6168 : : /* of the algorithms block size */
6169 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6170 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6171 : : plaintext_pad_len);
6172 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6173 : :
6174 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6175 : : } else {
6176 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6177 : : /* Append data which is padded to a multiple */
6178 : : /* of the algorithms block size */
6179 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6180 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6181 : : ciphertext_pad_len);
6182 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6183 : :
6184 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6185 : : }
6186 : :
6187 : : /* Create ZUC operation */
6188 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6189 : 0 : tdata->cipher_iv.len,
6190 : 0 : tdata->plaintext.len,
6191 : 0 : tdata->validCipherOffsetInBits.len);
6192 [ # # ]: 0 : if (retval < 0)
6193 : : return retval;
6194 : :
6195 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6196 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6197 : 0 : tdata->cipher_iv.len);
6198 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6199 : : return retval;
6200 : : } else
6201 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6202 : : ut_params->op);
6203 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6204 : :
6205 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6206 : :
6207 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6208 [ # # ]: 0 : if (ut_params->obuf)
6209 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6210 : : else
6211 : : ciphertext = plaintext;
6212 : :
6213 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6214 : :
6215 : : /* Validate obuf */
6216 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6217 : : ciphertext,
6218 : : tdata->ciphertext.data,
6219 : : tdata->validCipherLenInBits.len,
6220 : : "ZUC Ciphertext data not as expected");
6221 : : } else {
6222 [ # # ]: 0 : if (ut_params->obuf)
6223 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6224 : : else
6225 : : plaintext = ciphertext;
6226 : :
6227 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6228 : :
6229 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6230 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6231 : :
6232 : : /* Validate obuf */
6233 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6234 : : plaintext,
6235 : : reference_plaintext,
6236 : : tdata->validCipherLenInBits.len,
6237 : : "ZUC Plaintext data not as expected");
6238 : : }
6239 : :
6240 : : return 0;
6241 : : }
6242 : :
6243 : : static int
6244 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6245 : : enum rte_crypto_cipher_operation direction)
6246 : : {
6247 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6248 : : struct crypto_unittest_params *ut_params = &unittest_params;
6249 : :
6250 : : int retval;
6251 : :
6252 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6253 : : unsigned int plaintext_len = 0;
6254 : : unsigned int ciphertext_len = 0;
6255 : : const uint8_t *ciphertext, *plaintext;
6256 : : uint8_t buffer[2048];
6257 : : struct rte_cryptodev_info dev_info;
6258 : :
6259 : : /* Check if device supports ZUC EEA3 */
6260 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6261 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6262 : : return TEST_SKIPPED;
6263 : :
6264 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6265 : : return TEST_SKIPPED;
6266 : :
6267 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6268 : :
6269 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6270 : :
6271 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6272 : : printf("Device doesn't support in-place scatter-gather. "
6273 : : "Test Skipped.\n");
6274 : 0 : return TEST_SKIPPED;
6275 : : }
6276 : :
6277 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6278 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6279 : : printf("Device doesn't support RAW data-path APIs.\n");
6280 : 0 : return TEST_SKIPPED;
6281 : : }
6282 : :
6283 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6284 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6285 : :
6286 : : /* Append data which is padded to a multiple */
6287 : : /* of the algorithms block size */
6288 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6289 : :
6290 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6291 : : plaintext_pad_len, 10, 0);
6292 : :
6293 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6294 : 0 : tdata->plaintext.data);
6295 : : } else {
6296 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6297 : :
6298 : : /* Append data which is padded to a multiple */
6299 : : /* of the algorithms block size */
6300 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6301 : :
6302 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6303 : : ciphertext_pad_len, 10, 0);
6304 : :
6305 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6306 : 0 : tdata->ciphertext.data);
6307 : :
6308 : : }
6309 : :
6310 : : /* Create ZUC session */
6311 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6312 : : direction,
6313 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6314 : 0 : tdata->key.data, tdata->key.len,
6315 : 0 : tdata->cipher_iv.len);
6316 [ # # ]: 0 : if (retval < 0)
6317 : : return retval;
6318 : :
6319 : : /* Clear mbuf payload */
6320 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6321 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6322 : : else
6323 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6324 : :
6325 : : /* Create ZUC operation */
6326 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6327 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6328 : 0 : tdata->validCipherOffsetInBits.len);
6329 [ # # ]: 0 : if (retval < 0)
6330 : : return retval;
6331 : :
6332 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6333 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6334 : 0 : tdata->cipher_iv.len);
6335 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6336 : : return retval;
6337 : : } else
6338 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6339 : : ut_params->op);
6340 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6341 : :
6342 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6343 : :
6344 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6345 [ # # ]: 0 : if (ut_params->obuf)
6346 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6347 : : 0, plaintext_len, buffer);
6348 : : else
6349 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6350 : : 0, plaintext_len, buffer);
6351 : :
6352 : : /* Validate obuf */
6353 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6354 : :
6355 : : /* Validate obuf */
6356 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6357 : : ciphertext,
6358 : : tdata->ciphertext.data,
6359 : : tdata->validCipherLenInBits.len,
6360 : : "ZUC Ciphertext data not as expected");
6361 : : } else {
6362 [ # # ]: 0 : if (ut_params->obuf)
6363 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6364 : : 0, ciphertext_len, buffer);
6365 : : else
6366 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6367 : : 0, ciphertext_len, buffer);
6368 : :
6369 : : /* Validate obuf */
6370 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6371 : :
6372 : : /* Validate obuf */
6373 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6374 : : plaintext,
6375 : : tdata->plaintext.data,
6376 : : tdata->validCipherLenInBits.len,
6377 : : "ZUC Plaintext data not as expected");
6378 : : }
6379 : :
6380 : : return 0;
6381 : : }
6382 : :
6383 : : static int
6384 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6385 : : enum rte_crypto_auth_operation auth_op)
6386 : : {
6387 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6388 : : struct crypto_unittest_params *ut_params = &unittest_params;
6389 : :
6390 : : int retval;
6391 : : unsigned plaintext_pad_len;
6392 : : unsigned plaintext_len;
6393 : : uint8_t *plaintext;
6394 : :
6395 : : struct rte_cryptodev_info dev_info;
6396 : :
6397 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6398 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6399 : :
6400 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6401 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6402 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6403 : 0 : return TEST_SKIPPED;
6404 : : }
6405 : :
6406 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6407 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6408 : : printf("Device doesn't support RAW data-path APIs.\n");
6409 : 0 : return TEST_SKIPPED;
6410 : : }
6411 : :
6412 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6413 : : return TEST_SKIPPED;
6414 : :
6415 : : /* Check if device supports ZUC EIA3 */
6416 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6417 : 0 : tdata->key.len, tdata->auth_iv.len,
6418 : 0 : tdata->digest.len) < 0)
6419 : : return TEST_SKIPPED;
6420 : :
6421 : : /* Create ZUC session */
6422 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6423 : 0 : tdata->key.data, tdata->key.len,
6424 : 0 : tdata->auth_iv.len, tdata->digest.len,
6425 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6426 [ # # ]: 0 : if (retval != 0)
6427 : : return retval;
6428 : :
6429 : : /* alloc mbuf and set payload */
6430 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6431 : :
6432 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6433 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6434 : :
6435 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6436 : : /* Append data which is padded to a multiple of */
6437 : : /* the algorithms block size */
6438 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6439 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6440 : : plaintext_pad_len);
6441 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6442 : :
6443 : : /* Create ZUC operation */
6444 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6445 : 0 : tdata->digest.len,
6446 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6447 : : plaintext_pad_len,
6448 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6449 [ # # ]: 0 : if (retval < 0)
6450 : : return retval;
6451 : :
6452 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6453 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6454 : : 0);
6455 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6456 : : return retval;
6457 : : } else
6458 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6459 : : ut_params->op);
6460 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6461 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6462 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6463 : 0 : + plaintext_pad_len;
6464 : :
6465 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6466 : : /* Validate obuf */
6467 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6468 : : ut_params->digest,
6469 : : tdata->digest.data,
6470 : : tdata->digest.len,
6471 : : "ZUC Generated auth tag not as expected");
6472 : : return 0;
6473 : : }
6474 : :
6475 : : /* Validate obuf */
6476 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6477 : : return 0;
6478 : : else
6479 : 0 : return -1;
6480 : :
6481 : : return 0;
6482 : : }
6483 : :
6484 : : static int
6485 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6486 : : uint8_t op_mode, uint8_t verify)
6487 : : {
6488 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6489 : : struct crypto_unittest_params *ut_params = &unittest_params;
6490 : :
6491 : : int retval;
6492 : :
6493 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6494 : : unsigned int plaintext_pad_len;
6495 : : unsigned int plaintext_len;
6496 : : unsigned int ciphertext_pad_len;
6497 : : unsigned int ciphertext_len;
6498 : :
6499 : : struct rte_cryptodev_info dev_info;
6500 : :
6501 : : /* Check if device supports ZUC EEA3 */
6502 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6503 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6504 : : return TEST_SKIPPED;
6505 : :
6506 : : /* Check if device supports ZUC EIA3 */
6507 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6508 : 0 : tdata->key.len, tdata->auth_iv.len,
6509 : 0 : tdata->digest.len) < 0)
6510 : : return TEST_SKIPPED;
6511 : :
6512 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6513 : : return TEST_SKIPPED;
6514 : :
6515 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6516 : :
6517 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6518 : :
6519 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6520 : : printf("Device doesn't support digest encrypted.\n");
6521 : 0 : return TEST_SKIPPED;
6522 : : }
6523 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6524 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6525 : : printf("Device doesn't support in-place scatter-gather "
6526 : : "in both input and output mbufs.\n");
6527 : 0 : return TEST_SKIPPED;
6528 : : }
6529 : :
6530 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6531 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6532 : : printf("Device doesn't support RAW data-path APIs.\n");
6533 : 0 : return TEST_SKIPPED;
6534 : : }
6535 : : } else {
6536 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6537 : : return TEST_SKIPPED;
6538 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6539 : : printf("Device doesn't support out-of-place scatter-gather "
6540 : : "in both input and output mbufs.\n");
6541 : 0 : return TEST_SKIPPED;
6542 : : }
6543 : : }
6544 : :
6545 : : /* Create ZUC session */
6546 : 0 : retval = create_wireless_algo_auth_cipher_session(
6547 : 0 : ts_params->valid_devs[0],
6548 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6549 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6550 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6551 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6552 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6553 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6554 : : tdata->key.data, tdata->key.len,
6555 : 0 : tdata->key.data, tdata->key.len,
6556 : 0 : tdata->auth_iv.len, tdata->digest.len,
6557 : 0 : tdata->cipher_iv.len);
6558 : :
6559 [ # # ]: 0 : if (retval != 0)
6560 : : return retval;
6561 : :
6562 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6563 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6564 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6565 : :
6566 : : /* clear mbuf payload */
6567 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6568 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6569 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6570 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6571 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6572 : :
6573 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6574 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6575 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6576 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6577 : :
6578 [ # # ]: 0 : if (verify) {
6579 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6580 : : ciphertext_pad_len);
6581 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6582 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6583 : : ciphertext_len);
6584 : : } else {
6585 : : /* make sure enough space to cover partial digest verify case */
6586 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6587 : : ciphertext_pad_len);
6588 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6589 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6590 : : plaintext_len);
6591 : : }
6592 : :
6593 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6594 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6595 : :
6596 : : /* Create ZUC operation */
6597 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6598 : 0 : tdata->digest.data, tdata->digest.len,
6599 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6600 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6601 : 0 : (tdata->digest.offset_bytes == 0 ?
6602 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6603 : : : tdata->digest.offset_bytes),
6604 : 0 : tdata->validCipherLenInBits.len,
6605 : 0 : tdata->validCipherOffsetInBits.len,
6606 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6607 : : 0,
6608 : : op_mode, 0, verify);
6609 : :
6610 [ # # ]: 0 : if (retval < 0)
6611 : : return retval;
6612 : :
6613 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6614 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6615 : 0 : tdata->cipher_iv.len);
6616 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6617 : : return retval;
6618 : : } else
6619 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6620 : : ut_params->op);
6621 : :
6622 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6623 : :
6624 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6625 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6626 : :
6627 : :
6628 [ # # ]: 0 : if (verify) {
6629 [ # # ]: 0 : if (ut_params->obuf)
6630 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6631 : : uint8_t *);
6632 : : else
6633 : : plaintext = ciphertext;
6634 : :
6635 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6636 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6637 : 0 : debug_hexdump(stdout, "plaintext expected:",
6638 : 0 : tdata->plaintext.data,
6639 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6640 : : } else {
6641 [ # # ]: 0 : if (ut_params->obuf)
6642 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6643 : : uint8_t *);
6644 : : else
6645 : : ciphertext = plaintext;
6646 : :
6647 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6648 : : ciphertext_len);
6649 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6650 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6651 : :
6652 : 0 : ut_params->digest = rte_pktmbuf_mtod(
6653 : 0 : ut_params->obuf, uint8_t *) +
6654 : 0 : (tdata->digest.offset_bytes == 0 ?
6655 [ # # ]: 0 : plaintext_pad_len : tdata->digest.offset_bytes);
6656 : :
6657 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6658 : 0 : tdata->digest.len);
6659 : 0 : debug_hexdump(stdout, "digest expected:",
6660 : 0 : tdata->digest.data, tdata->digest.len);
6661 : : }
6662 : :
6663 : : /* Validate obuf */
6664 [ # # ]: 0 : if (verify) {
6665 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6666 : : plaintext,
6667 : : tdata->plaintext.data,
6668 : : tdata->plaintext.len >> 3,
6669 : : "ZUC Plaintext data not as expected");
6670 : : } else {
6671 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6672 : : ciphertext,
6673 : : tdata->ciphertext.data,
6674 : : tdata->ciphertext.len >> 3,
6675 : : "ZUC Ciphertext data not as expected");
6676 : :
6677 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6678 : : ut_params->digest,
6679 : : tdata->digest.data,
6680 : : tdata->digest.len,
6681 : : "ZUC Generated auth tag not as expected");
6682 : : }
6683 : : return 0;
6684 : : }
6685 : :
6686 : : static int
6687 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6688 : : uint8_t op_mode, uint8_t verify)
6689 : : {
6690 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6691 : : struct crypto_unittest_params *ut_params = &unittest_params;
6692 : :
6693 : : int retval;
6694 : :
6695 : : const uint8_t *plaintext = NULL;
6696 : : const uint8_t *ciphertext = NULL;
6697 : : const uint8_t *digest = NULL;
6698 : : unsigned int plaintext_pad_len;
6699 : : unsigned int plaintext_len;
6700 : : unsigned int ciphertext_pad_len;
6701 : : unsigned int ciphertext_len;
6702 : : uint8_t buffer[10000];
6703 : : uint8_t digest_buffer[10000];
6704 : :
6705 : : struct rte_cryptodev_info dev_info;
6706 : :
6707 : : /* Check if device supports ZUC EEA3 */
6708 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6709 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6710 : : return TEST_SKIPPED;
6711 : :
6712 : : /* Check if device supports ZUC EIA3 */
6713 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6714 : 0 : tdata->key.len, tdata->auth_iv.len,
6715 : 0 : tdata->digest.len) < 0)
6716 : : return TEST_SKIPPED;
6717 : :
6718 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6719 : : return TEST_SKIPPED;
6720 : :
6721 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6722 : :
6723 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6724 : :
6725 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6726 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6727 : : printf("Device doesn't support in-place scatter-gather "
6728 : : "in both input and output mbufs.\n");
6729 : 0 : return TEST_SKIPPED;
6730 : : }
6731 : :
6732 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6733 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6734 : : printf("Device doesn't support RAW data-path APIs.\n");
6735 : 0 : return TEST_SKIPPED;
6736 : : }
6737 : : } else {
6738 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6739 : : return TEST_SKIPPED;
6740 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6741 : : printf("Device doesn't support out-of-place scatter-gather "
6742 : : "in both input and output mbufs.\n");
6743 : 0 : return TEST_SKIPPED;
6744 : : }
6745 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6746 : : printf("Device doesn't support digest encrypted.\n");
6747 : 0 : return TEST_SKIPPED;
6748 : : }
6749 : : }
6750 : :
6751 : : /* Create ZUC session */
6752 : 0 : retval = create_wireless_algo_auth_cipher_session(
6753 : 0 : ts_params->valid_devs[0],
6754 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6755 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6756 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6757 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6758 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6759 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6760 : : tdata->key.data, tdata->key.len,
6761 : 0 : tdata->key.data, tdata->key.len,
6762 : 0 : tdata->auth_iv.len, tdata->digest.len,
6763 : 0 : tdata->cipher_iv.len);
6764 : :
6765 [ # # ]: 0 : if (retval != 0)
6766 : : return retval;
6767 : :
6768 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6769 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6770 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6771 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6772 : :
6773 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6774 : : plaintext_pad_len, 15, 0);
6775 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6776 : : "Failed to allocate input buffer in mempool");
6777 : :
6778 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6779 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6780 : : plaintext_pad_len, 15, 0);
6781 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6782 : : "Failed to allocate output buffer in mempool");
6783 : : }
6784 : :
6785 [ # # ]: 0 : if (verify) {
6786 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6787 : 0 : tdata->ciphertext.data);
6788 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6789 : : ciphertext_len, buffer);
6790 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6791 : : ciphertext_len);
6792 : : } else {
6793 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6794 : 0 : tdata->plaintext.data);
6795 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6796 : : plaintext_len, buffer);
6797 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6798 : : plaintext_len);
6799 : : }
6800 : : memset(buffer, 0, sizeof(buffer));
6801 : :
6802 : : /* Create ZUC operation */
6803 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6804 : 0 : tdata->digest.data, tdata->digest.len,
6805 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6806 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6807 : 0 : (tdata->digest.offset_bytes == 0 ?
6808 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6809 : : : tdata->digest.offset_bytes),
6810 : 0 : tdata->validCipherLenInBits.len,
6811 : 0 : tdata->validCipherOffsetInBits.len,
6812 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6813 : : 0,
6814 : : op_mode, 1, verify);
6815 : :
6816 [ # # ]: 0 : if (retval < 0)
6817 : : return retval;
6818 : :
6819 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6820 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6821 : 0 : tdata->cipher_iv.len);
6822 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6823 : : return retval;
6824 : : } else
6825 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6826 : : ut_params->op);
6827 : :
6828 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6829 : :
6830 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6831 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6832 : :
6833 [ # # ]: 0 : if (verify) {
6834 [ # # ]: 0 : if (ut_params->obuf)
6835 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6836 : : plaintext_len, buffer);
6837 : : else
6838 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6839 : : plaintext_len, buffer);
6840 : :
6841 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6842 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6843 : 0 : debug_hexdump(stdout, "plaintext expected:",
6844 : 0 : tdata->plaintext.data,
6845 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6846 : : } else {
6847 [ # # ]: 0 : if (ut_params->obuf)
6848 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6849 : : ciphertext_len, buffer);
6850 : : else
6851 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6852 : : ciphertext_len, buffer);
6853 : :
6854 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6855 : : ciphertext_len);
6856 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6857 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6858 : :
6859 [ # # ]: 0 : if (ut_params->obuf)
6860 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6861 : 0 : (tdata->digest.offset_bytes == 0 ?
6862 : : plaintext_pad_len : tdata->digest.offset_bytes),
6863 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6864 : : else
6865 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6866 : 0 : (tdata->digest.offset_bytes == 0 ?
6867 : : plaintext_pad_len : tdata->digest.offset_bytes),
6868 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6869 : :
6870 : 0 : debug_hexdump(stdout, "digest:", digest,
6871 : 0 : tdata->digest.len);
6872 : 0 : debug_hexdump(stdout, "digest expected:",
6873 : 0 : tdata->digest.data, tdata->digest.len);
6874 : : }
6875 : :
6876 : : /* Validate obuf */
6877 [ # # ]: 0 : if (verify) {
6878 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6879 : : plaintext,
6880 : : tdata->plaintext.data,
6881 : : tdata->plaintext.len >> 3,
6882 : : "ZUC Plaintext data not as expected");
6883 : : } else {
6884 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6885 : : ciphertext,
6886 : : tdata->ciphertext.data,
6887 : : tdata->validDataLenInBits.len,
6888 : : "ZUC Ciphertext data not as expected");
6889 : :
6890 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6891 : : digest,
6892 : : tdata->digest.data,
6893 : : tdata->digest.len,
6894 : : "ZUC Generated auth tag not as expected");
6895 : : }
6896 : : return 0;
6897 : : }
6898 : :
6899 : : static int
6900 : 0 : test_kasumi_encryption_test_case_1(void)
6901 : : {
6902 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
6903 : : }
6904 : :
6905 : : static int
6906 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
6907 : : {
6908 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6909 : : }
6910 : :
6911 : : static int
6912 : 0 : test_kasumi_encryption_test_case_1_oop(void)
6913 : : {
6914 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
6915 : : }
6916 : :
6917 : : static int
6918 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
6919 : : {
6920 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6921 : : }
6922 : :
6923 : : static int
6924 : 0 : test_kasumi_encryption_test_case_2(void)
6925 : : {
6926 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
6927 : : }
6928 : :
6929 : : static int
6930 : 0 : test_kasumi_encryption_test_case_3(void)
6931 : : {
6932 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
6933 : : }
6934 : :
6935 : : static int
6936 : 0 : test_kasumi_encryption_test_case_4(void)
6937 : : {
6938 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
6939 : : }
6940 : :
6941 : : static int
6942 : 0 : test_kasumi_encryption_test_case_5(void)
6943 : : {
6944 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
6945 : : }
6946 : :
6947 : : static int
6948 : 0 : test_kasumi_decryption_test_case_1(void)
6949 : : {
6950 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
6951 : : }
6952 : :
6953 : : static int
6954 : 0 : test_kasumi_decryption_test_case_1_oop(void)
6955 : : {
6956 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
6957 : : }
6958 : :
6959 : : static int
6960 : 0 : test_kasumi_decryption_test_case_2(void)
6961 : : {
6962 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
6963 : : }
6964 : :
6965 : : static int
6966 : 0 : test_kasumi_decryption_test_case_3(void)
6967 : : {
6968 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6969 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6970 : : return TEST_SKIPPED;
6971 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
6972 : : }
6973 : :
6974 : : static int
6975 : 0 : test_kasumi_decryption_test_case_4(void)
6976 : : {
6977 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
6978 : : }
6979 : :
6980 : : static int
6981 : 0 : test_kasumi_decryption_test_case_5(void)
6982 : : {
6983 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
6984 : : }
6985 : : static int
6986 : 0 : test_snow3g_encryption_test_case_1(void)
6987 : : {
6988 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
6989 : : }
6990 : :
6991 : : static int
6992 : 0 : test_snow3g_encryption_test_case_1_oop(void)
6993 : : {
6994 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
6995 : : }
6996 : :
6997 : : static int
6998 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
6999 : : {
7000 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7001 : : }
7002 : :
7003 : : static int
7004 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7005 : : {
7006 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7007 : : }
7008 : :
7009 : : static int
7010 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7011 : : {
7012 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7013 : : }
7014 : :
7015 : : static int
7016 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7017 : : {
7018 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7019 : : }
7020 : :
7021 : : static int
7022 : 0 : test_snow3g_encryption_test_case_2(void)
7023 : : {
7024 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7025 : : }
7026 : :
7027 : : static int
7028 : 0 : test_snow3g_encryption_test_case_3(void)
7029 : : {
7030 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7031 : : }
7032 : :
7033 : : static int
7034 : 0 : test_snow3g_encryption_test_case_4(void)
7035 : : {
7036 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7037 : : }
7038 : :
7039 : : static int
7040 : 0 : test_snow3g_encryption_test_case_5(void)
7041 : : {
7042 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7043 : : }
7044 : :
7045 : : static int
7046 : 0 : test_snow3g_decryption_test_case_1(void)
7047 : : {
7048 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7049 : : }
7050 : :
7051 : : static int
7052 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7053 : : {
7054 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7055 : : }
7056 : :
7057 : : static int
7058 : 0 : test_snow3g_decryption_test_case_2(void)
7059 : : {
7060 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7061 : : }
7062 : :
7063 : : static int
7064 : 0 : test_snow3g_decryption_test_case_3(void)
7065 : : {
7066 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7067 : : }
7068 : :
7069 : : static int
7070 : 0 : test_snow3g_decryption_test_case_4(void)
7071 : : {
7072 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7073 : : }
7074 : :
7075 : : static int
7076 : 0 : test_snow3g_decryption_test_case_5(void)
7077 : : {
7078 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7079 : : }
7080 : :
7081 : : /*
7082 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7083 : : * Pattern digest from snow3g_test_data must be allocated as
7084 : : * 4 last bytes in plaintext.
7085 : : */
7086 : : static void
7087 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7088 : : struct snow3g_hash_test_data *output)
7089 : : {
7090 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7091 : 0 : output->key.len = pattern->key.len;
7092 : :
7093 : 0 : memcpy(output->key.data,
7094 : 0 : pattern->key.data, pattern->key.len);
7095 : :
7096 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7097 : :
7098 : 0 : memcpy(output->auth_iv.data,
7099 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7100 : :
7101 : 0 : output->plaintext.len = pattern->plaintext.len;
7102 : :
7103 : 0 : memcpy(output->plaintext.data,
7104 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7105 : :
7106 : 0 : output->digest.len = pattern->digest.len;
7107 : :
7108 : 0 : memcpy(output->digest.data,
7109 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7110 : : pattern->digest.len);
7111 : :
7112 : 0 : output->validAuthLenInBits.len =
7113 : 0 : pattern->validAuthLenInBits.len;
7114 : : }
7115 : 0 : }
7116 : :
7117 : : /*
7118 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7119 : : */
7120 : : static int
7121 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7122 : : {
7123 : : int ret;
7124 : : struct snow3g_hash_test_data snow3g_hash_data;
7125 : : struct rte_cryptodev_info dev_info;
7126 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7127 : :
7128 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7129 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7130 : :
7131 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7132 : : printf("Device doesn't support encrypted digest operations.\n");
7133 : 0 : return TEST_SKIPPED;
7134 : : }
7135 : :
7136 : : /*
7137 : : * Function prepare data for hash verification test case.
7138 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7139 : : */
7140 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7141 : :
7142 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7143 [ # # ]: 0 : if (ret != 0)
7144 : : return ret;
7145 : :
7146 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7147 : : }
7148 : :
7149 : : static int
7150 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7151 : : {
7152 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7153 : : }
7154 : :
7155 : : static int
7156 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7157 : : {
7158 : 0 : return test_snow3g_auth_cipher(
7159 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7160 : : }
7161 : :
7162 : : static int
7163 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7164 : : {
7165 : 0 : return test_snow3g_auth_cipher(
7166 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7167 : : }
7168 : :
7169 : : static int
7170 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7171 : : {
7172 : 0 : return test_snow3g_auth_cipher(
7173 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7174 : : }
7175 : :
7176 : : static int
7177 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7178 : : {
7179 : 0 : return test_snow3g_auth_cipher(
7180 : : &snow3g_auth_cipher_partial_digest_encryption,
7181 : : IN_PLACE, 0);
7182 : : }
7183 : :
7184 : : static int
7185 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7186 : : {
7187 : 0 : return test_snow3g_auth_cipher(
7188 : : &snow3g_auth_cipher_partial_digest_encryption,
7189 : : OUT_OF_PLACE, 0);
7190 : : }
7191 : :
7192 : : static int
7193 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7194 : : {
7195 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7196 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7197 : : return TEST_SKIPPED;
7198 : 0 : return test_snow3g_auth_cipher_sgl(
7199 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7200 : : }
7201 : :
7202 : : static int
7203 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7204 : : {
7205 : 0 : return test_snow3g_auth_cipher_sgl(
7206 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7207 : : }
7208 : :
7209 : : static int
7210 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7211 : : {
7212 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7213 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7214 : : return TEST_SKIPPED;
7215 : 0 : return test_snow3g_auth_cipher_sgl(
7216 : : &snow3g_auth_cipher_partial_digest_encryption,
7217 : : IN_PLACE, 0);
7218 : : }
7219 : :
7220 : : static int
7221 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7222 : : {
7223 : 0 : return test_snow3g_auth_cipher_sgl(
7224 : : &snow3g_auth_cipher_partial_digest_encryption,
7225 : : OUT_OF_PLACE, 0);
7226 : : }
7227 : :
7228 : : static int
7229 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7230 : : {
7231 : 0 : return test_snow3g_auth_cipher(
7232 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7233 : : }
7234 : :
7235 : : static int
7236 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7237 : : {
7238 : 0 : return test_snow3g_auth_cipher(
7239 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7240 : : }
7241 : :
7242 : : static int
7243 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7244 : : {
7245 : 0 : return test_snow3g_auth_cipher_sgl(
7246 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7247 : : }
7248 : :
7249 : : static int
7250 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7251 : : {
7252 : 0 : return test_snow3g_auth_cipher_sgl(
7253 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7254 : : }
7255 : :
7256 : : static int
7257 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7258 : : {
7259 : 0 : return test_snow3g_auth_cipher(
7260 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7261 : : }
7262 : :
7263 : : static int
7264 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7265 : : {
7266 : 0 : return test_snow3g_auth_cipher(
7267 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7268 : : }
7269 : :
7270 : : static int
7271 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7272 : : {
7273 : 0 : return test_snow3g_auth_cipher(
7274 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7275 : : }
7276 : :
7277 : : static int
7278 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7279 : : {
7280 : 0 : return test_snow3g_auth_cipher(
7281 : : &snow3g_auth_cipher_partial_digest_encryption,
7282 : : IN_PLACE, 1);
7283 : : }
7284 : :
7285 : : static int
7286 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7287 : : {
7288 : 0 : return test_snow3g_auth_cipher(
7289 : : &snow3g_auth_cipher_partial_digest_encryption,
7290 : : OUT_OF_PLACE, 1);
7291 : : }
7292 : :
7293 : : static int
7294 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7295 : : {
7296 : 0 : return test_snow3g_auth_cipher_sgl(
7297 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7298 : : }
7299 : :
7300 : : static int
7301 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7302 : : {
7303 : 0 : return test_snow3g_auth_cipher_sgl(
7304 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7305 : : }
7306 : :
7307 : : static int
7308 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7309 : : {
7310 : 0 : return test_snow3g_auth_cipher_sgl(
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_sgl(void)
7317 : : {
7318 : 0 : return test_snow3g_auth_cipher_sgl(
7319 : : &snow3g_auth_cipher_partial_digest_encryption,
7320 : : OUT_OF_PLACE, 1);
7321 : : }
7322 : :
7323 : : static int
7324 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7325 : : {
7326 : 0 : return test_snow3g_auth_cipher(
7327 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7328 : : }
7329 : :
7330 : : static int
7331 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7332 : : {
7333 : 0 : return test_snow3g_auth_cipher(
7334 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7335 : : }
7336 : :
7337 : : static int
7338 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7339 : : {
7340 : 0 : return test_snow3g_auth_cipher_sgl(
7341 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7342 : : }
7343 : :
7344 : : static int
7345 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7346 : : {
7347 : 0 : return test_snow3g_auth_cipher_sgl(
7348 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7349 : : }
7350 : :
7351 : : static int
7352 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7353 : : {
7354 : 0 : return test_snow3g_auth_cipher(
7355 : : &snow3g_test_case_7, IN_PLACE, 0);
7356 : : }
7357 : :
7358 : : static int
7359 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7360 : : {
7361 : 0 : return test_kasumi_auth_cipher(
7362 : : &kasumi_test_case_3, IN_PLACE, 0);
7363 : : }
7364 : :
7365 : : static int
7366 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7367 : : {
7368 : 0 : return test_kasumi_auth_cipher(
7369 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7370 : : }
7371 : :
7372 : : static int
7373 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7374 : : {
7375 : 0 : return test_kasumi_auth_cipher(
7376 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7377 : : }
7378 : :
7379 : : static int
7380 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7381 : : {
7382 : 0 : return test_kasumi_auth_cipher_sgl(
7383 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7384 : : }
7385 : :
7386 : : static int
7387 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7388 : : {
7389 : 0 : return test_kasumi_auth_cipher_sgl(
7390 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7391 : : }
7392 : :
7393 : : static int
7394 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7395 : : {
7396 : 0 : return test_kasumi_auth_cipher(
7397 : : &kasumi_test_case_3, IN_PLACE, 1);
7398 : : }
7399 : :
7400 : : static int
7401 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7402 : : {
7403 : 0 : return test_kasumi_auth_cipher(
7404 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7405 : : }
7406 : :
7407 : : static int
7408 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7409 : : {
7410 : 0 : return test_kasumi_auth_cipher(
7411 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7412 : : }
7413 : :
7414 : : static int
7415 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7416 : : {
7417 : 0 : return test_kasumi_auth_cipher_sgl(
7418 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7419 : : }
7420 : :
7421 : : static int
7422 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7423 : : {
7424 : 0 : return test_kasumi_auth_cipher_sgl(
7425 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7426 : : }
7427 : :
7428 : : static int
7429 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7430 : : {
7431 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7432 : : }
7433 : :
7434 : : static int
7435 : 0 : test_zuc_encryption_test_case_1(void)
7436 : : {
7437 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7438 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7439 : : }
7440 : :
7441 : : static int
7442 : 0 : test_zuc_encryption_test_case_2(void)
7443 : : {
7444 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7445 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7446 : : }
7447 : :
7448 : : static int
7449 : 0 : test_zuc_encryption_test_case_3(void)
7450 : : {
7451 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7452 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7453 : : }
7454 : :
7455 : : static int
7456 : 0 : test_zuc_encryption_test_case_4(void)
7457 : : {
7458 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7459 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7460 : : }
7461 : :
7462 : : static int
7463 : 0 : test_zuc_encryption_test_case_5(void)
7464 : : {
7465 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7466 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7467 : : }
7468 : :
7469 : : static int
7470 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7471 : : {
7472 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7473 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7474 : : }
7475 : :
7476 : : static int
7477 : 0 : test_zuc_decryption_test_case_1(void)
7478 : : {
7479 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7480 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7481 : : }
7482 : :
7483 : : static int
7484 : 0 : test_zuc_decryption_test_case_2(void)
7485 : : {
7486 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7487 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7488 : : }
7489 : :
7490 : : static int
7491 : 0 : test_zuc_decryption_test_case_3(void)
7492 : : {
7493 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7494 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7495 : : }
7496 : :
7497 : : static int
7498 : 0 : test_zuc_decryption_test_case_4(void)
7499 : : {
7500 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7501 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7502 : : }
7503 : :
7504 : : static int
7505 : 0 : test_zuc_decryption_test_case_5(void)
7506 : : {
7507 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7508 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7509 : : }
7510 : :
7511 : : static int
7512 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7513 : : {
7514 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7515 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7516 : : }
7517 : :
7518 : : static int
7519 : 0 : test_zuc_hash_generate_test_case_1(void)
7520 : : {
7521 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7522 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7523 : : }
7524 : :
7525 : : static int
7526 : 0 : test_zuc_hash_generate_test_case_2(void)
7527 : : {
7528 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7529 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7530 : : }
7531 : :
7532 : : static int
7533 : 0 : test_zuc_hash_generate_test_case_3(void)
7534 : : {
7535 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7536 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7537 : : }
7538 : :
7539 : : static int
7540 : 0 : test_zuc_hash_generate_test_case_4(void)
7541 : : {
7542 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7543 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7544 : : }
7545 : :
7546 : : static int
7547 : 0 : test_zuc_hash_generate_test_case_5(void)
7548 : : {
7549 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7550 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7551 : : }
7552 : :
7553 : : static int
7554 : 0 : test_zuc_hash_generate_test_case_6(void)
7555 : : {
7556 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7557 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7558 : : }
7559 : :
7560 : : static int
7561 : 0 : test_zuc_hash_generate_test_case_7(void)
7562 : : {
7563 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7564 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7565 : : }
7566 : :
7567 : : static int
7568 : 0 : test_zuc_hash_generate_test_case_8(void)
7569 : : {
7570 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7571 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7572 : : }
7573 : :
7574 : : static int
7575 : 0 : test_zuc_hash_verify_test_case_1(void)
7576 : : {
7577 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7578 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7579 : : }
7580 : :
7581 : : static int
7582 : 0 : test_zuc_hash_verify_test_case_2(void)
7583 : : {
7584 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7585 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7586 : : }
7587 : :
7588 : : static int
7589 : 0 : test_zuc_hash_verify_test_case_3(void)
7590 : : {
7591 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7592 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7593 : : }
7594 : :
7595 : : static int
7596 : 0 : test_zuc_hash_verify_test_case_4(void)
7597 : : {
7598 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7599 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7600 : : }
7601 : :
7602 : : static int
7603 : 0 : test_zuc_hash_verify_test_case_5(void)
7604 : : {
7605 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7606 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7607 : : }
7608 : :
7609 : : static int
7610 : 0 : test_zuc_hash_verify_test_case_6(void)
7611 : : {
7612 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7613 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7614 : : }
7615 : :
7616 : : static int
7617 : 0 : test_zuc_hash_verify_test_case_7(void)
7618 : : {
7619 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7620 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7621 : : }
7622 : :
7623 : : static int
7624 : 0 : test_zuc_hash_verify_test_case_8(void)
7625 : : {
7626 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7627 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7628 : : }
7629 : :
7630 : : static int
7631 : 0 : test_zuc_cipher_auth_test_case_1(void)
7632 : : {
7633 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7634 : : }
7635 : :
7636 : : static int
7637 : 0 : test_zuc_cipher_auth_test_case_2(void)
7638 : : {
7639 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7640 : : }
7641 : :
7642 : : static int
7643 : 0 : test_zuc_auth_cipher_test_case_1(void)
7644 : : {
7645 : 0 : return test_zuc_auth_cipher(
7646 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7647 : : }
7648 : :
7649 : : static int
7650 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
7651 : : {
7652 : 0 : return test_zuc_auth_cipher(
7653 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7654 : : }
7655 : :
7656 : : static int
7657 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
7658 : : {
7659 : 0 : return test_zuc_auth_cipher_sgl(
7660 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7661 : : }
7662 : :
7663 : : static int
7664 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7665 : : {
7666 : 0 : return test_zuc_auth_cipher_sgl(
7667 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7668 : : }
7669 : :
7670 : : static int
7671 : 0 : test_zuc_auth_cipher_test_case_2(void)
7672 : : {
7673 : 0 : return test_zuc_auth_cipher(
7674 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7675 : : }
7676 : :
7677 : : static int
7678 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
7679 : : {
7680 : 0 : return test_zuc_auth_cipher(
7681 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7682 : : }
7683 : :
7684 : : static int
7685 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
7686 : : {
7687 : 0 : return test_zuc_auth_cipher(
7688 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7689 : : }
7690 : :
7691 : : static int
7692 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
7693 : : {
7694 : 0 : return test_zuc_auth_cipher(
7695 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7696 : : }
7697 : :
7698 : : static int
7699 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7700 : : {
7701 : 0 : return test_zuc_auth_cipher_sgl(
7702 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7703 : : }
7704 : :
7705 : : static int
7706 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7707 : : {
7708 : 0 : return test_zuc_auth_cipher_sgl(
7709 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7710 : : }
7711 : :
7712 : : static int
7713 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
7714 : : {
7715 : 0 : return test_zuc_auth_cipher(
7716 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7717 : : }
7718 : :
7719 : : static int
7720 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
7721 : : {
7722 : 0 : return test_zuc_auth_cipher(
7723 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7724 : : }
7725 : :
7726 : : static int
7727 : 0 : test_zuc256_encryption_test_case_1(void)
7728 : : {
7729 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7730 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7731 : : }
7732 : :
7733 : : static int
7734 : 0 : test_zuc256_encryption_test_case_2(void)
7735 : : {
7736 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7737 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7738 : : }
7739 : :
7740 : : static int
7741 : 0 : test_zuc256_decryption_test_case_1(void)
7742 : : {
7743 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7744 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7745 : : }
7746 : :
7747 : : static int
7748 : 0 : test_zuc256_decryption_test_case_2(void)
7749 : : {
7750 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7751 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7752 : : }
7753 : :
7754 : : static int
7755 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
7756 : : {
7757 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7758 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7759 : : }
7760 : :
7761 : : static int
7762 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
7763 : : {
7764 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7765 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7766 : : }
7767 : :
7768 : : static int
7769 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
7770 : : {
7771 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7772 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7773 : : }
7774 : :
7775 : : static int
7776 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
7777 : : {
7778 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7779 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7780 : : }
7781 : :
7782 : : static int
7783 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
7784 : : {
7785 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7786 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7787 : : }
7788 : :
7789 : : static int
7790 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
7791 : : {
7792 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7793 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7794 : : }
7795 : :
7796 : : static int
7797 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
7798 : : {
7799 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7800 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7801 : : }
7802 : :
7803 : : static int
7804 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
7805 : : {
7806 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7807 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7808 : : }
7809 : :
7810 : : static int
7811 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
7812 : : {
7813 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7814 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7815 : : }
7816 : :
7817 : : static int
7818 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
7819 : : {
7820 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7821 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7822 : : }
7823 : :
7824 : : static int
7825 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7826 : : {
7827 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7828 : : }
7829 : :
7830 : : static int
7831 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7832 : : {
7833 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7834 : : }
7835 : :
7836 : : static int
7837 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
7838 : : {
7839 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
7840 : : }
7841 : :
7842 : : static int
7843 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
7844 : : {
7845 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
7846 : : }
7847 : :
7848 : : static int
7849 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
7850 : : {
7851 : 0 : return test_zuc_auth_cipher(
7852 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
7853 : : }
7854 : :
7855 : : static int
7856 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
7857 : : {
7858 : 0 : return test_zuc_auth_cipher(
7859 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
7860 : : }
7861 : :
7862 : : static int
7863 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
7864 : : {
7865 : 0 : return test_zuc_auth_cipher(
7866 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
7867 : : }
7868 : :
7869 : : static int
7870 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
7871 : : {
7872 : 0 : return test_zuc_auth_cipher(
7873 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
7874 : : }
7875 : :
7876 : : static int
7877 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
7878 : : {
7879 : 0 : return test_zuc_auth_cipher(
7880 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
7881 : : }
7882 : :
7883 : : static int
7884 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
7885 : : {
7886 : 0 : return test_zuc_auth_cipher(
7887 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
7888 : : }
7889 : :
7890 : : static int
7891 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
7892 : : {
7893 : 0 : return test_zuc_auth_cipher(
7894 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
7895 : : }
7896 : :
7897 : : static int
7898 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
7899 : : {
7900 : 0 : return test_zuc_auth_cipher(
7901 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
7902 : : }
7903 : :
7904 : : static int
7905 : 0 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7906 : : {
7907 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
7908 : :
7909 : : struct rte_cryptodev_sym_capability_idx cap_idx;
7910 : :
7911 : : /* Check if device supports particular cipher algorithm */
7912 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7913 : 0 : cap_idx.algo.cipher = tdata->cipher_algo;
7914 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7915 : : return TEST_SKIPPED;
7916 : :
7917 : : /* Check if device supports particular hash algorithm */
7918 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7919 : 0 : cap_idx.algo.auth = tdata->auth_algo;
7920 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7921 : 0 : return TEST_SKIPPED;
7922 : :
7923 : : return 0;
7924 : : }
7925 : :
7926 : : static int
7927 : 0 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7928 : : uint8_t op_mode, uint8_t verify)
7929 : : {
7930 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7931 : : struct crypto_unittest_params *ut_params = &unittest_params;
7932 : :
7933 : : int retval;
7934 : :
7935 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
7936 : : unsigned int plaintext_pad_len;
7937 : : unsigned int plaintext_len;
7938 : : unsigned int ciphertext_pad_len;
7939 : : unsigned int ciphertext_len;
7940 : :
7941 : : struct rte_cryptodev_info dev_info;
7942 : : struct rte_crypto_op *op;
7943 : :
7944 : : /* Check if device supports particular algorithms separately */
7945 [ # # ]: 0 : if (test_mixed_check_if_unsupported(tdata))
7946 : : return TEST_SKIPPED;
7947 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7948 : : return TEST_SKIPPED;
7949 : :
7950 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7951 : : return TEST_SKIPPED;
7952 : :
7953 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7954 : :
7955 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7956 : :
7957 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7958 : : printf("Device doesn't support digest encrypted.\n");
7959 : 0 : return TEST_SKIPPED;
7960 : : }
7961 : :
7962 : : /* Create the session */
7963 [ # # ]: 0 : if (verify)
7964 : 0 : retval = create_wireless_algo_cipher_auth_session(
7965 : 0 : ts_params->valid_devs[0],
7966 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
7967 : : RTE_CRYPTO_AUTH_OP_VERIFY,
7968 : 0 : tdata->auth_algo,
7969 : 0 : tdata->cipher_algo,
7970 : 0 : tdata->auth_key.data, tdata->auth_key.len,
7971 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
7972 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
7973 : 0 : tdata->cipher_iv.len);
7974 : : else
7975 : 0 : retval = create_wireless_algo_auth_cipher_session(
7976 : 0 : ts_params->valid_devs[0],
7977 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7978 : : RTE_CRYPTO_AUTH_OP_GENERATE,
7979 : 0 : tdata->auth_algo,
7980 : 0 : tdata->cipher_algo,
7981 : 0 : tdata->auth_key.data, tdata->auth_key.len,
7982 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
7983 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
7984 : 0 : tdata->cipher_iv.len);
7985 [ # # ]: 0 : if (retval != 0)
7986 : : return retval;
7987 : :
7988 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7989 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
7990 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7991 : :
7992 : : /* clear mbuf payload */
7993 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7994 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
7995 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
7996 : :
7997 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7998 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
7999 : : }
8000 : :
8001 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8002 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8003 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8004 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8005 : :
8006 [ # # ]: 0 : if (verify) {
8007 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8008 : : ciphertext_pad_len);
8009 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8010 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8011 : : ciphertext_len);
8012 : : } else {
8013 : : /* make sure enough space to cover partial digest verify case */
8014 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8015 : : ciphertext_pad_len);
8016 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8017 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8018 : : }
8019 : :
8020 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8021 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8022 : :
8023 : : /* Create the operation */
8024 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8025 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8026 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8027 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8028 : 0 : (tdata->digest_enc.offset == 0 ?
8029 : : plaintext_pad_len
8030 : : : tdata->digest_enc.offset),
8031 : 0 : tdata->validCipherLen.len_bits,
8032 : 0 : tdata->cipher.offset_bits,
8033 : 0 : tdata->validAuthLen.len_bits,
8034 [ # # ]: 0 : tdata->auth.offset_bits,
8035 : : op_mode, 0, verify);
8036 : :
8037 [ # # ]: 0 : if (retval < 0)
8038 : : return retval;
8039 : :
8040 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8041 : :
8042 : : /* Check if the op failed because the device doesn't */
8043 : : /* support this particular combination of algorithms */
8044 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8045 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8046 : : printf("Device doesn't support this mixed combination. "
8047 : : "Test Skipped.\n");
8048 : 0 : return TEST_SKIPPED;
8049 : : }
8050 : 0 : ut_params->op = op;
8051 : :
8052 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8053 : :
8054 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8055 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8056 : :
8057 [ # # ]: 0 : if (verify) {
8058 [ # # ]: 0 : if (ut_params->obuf)
8059 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8060 : : uint8_t *);
8061 : : else
8062 : 0 : plaintext = ciphertext +
8063 : 0 : (tdata->cipher.offset_bits >> 3);
8064 : :
8065 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8066 : 0 : tdata->plaintext.len_bits >> 3);
8067 : 0 : debug_hexdump(stdout, "plaintext expected:",
8068 : 0 : tdata->plaintext.data,
8069 : 0 : tdata->plaintext.len_bits >> 3);
8070 : : } else {
8071 [ # # ]: 0 : if (ut_params->obuf)
8072 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8073 : : uint8_t *);
8074 : : else
8075 : : ciphertext = plaintext;
8076 : :
8077 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8078 : : ciphertext_len);
8079 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8080 : 0 : tdata->ciphertext.data,
8081 : 0 : tdata->ciphertext.len_bits >> 3);
8082 : :
8083 : 0 : ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
8084 : 0 : + (tdata->digest_enc.offset == 0 ?
8085 [ # # ]: 0 : plaintext_pad_len : tdata->digest_enc.offset);
8086 : :
8087 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8088 : 0 : tdata->digest_enc.len);
8089 : 0 : debug_hexdump(stdout, "digest expected:",
8090 : : tdata->digest_enc.data,
8091 : 0 : tdata->digest_enc.len);
8092 : : }
8093 : :
8094 [ # # ]: 0 : if (!verify) {
8095 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8096 : : ut_params->digest,
8097 : : tdata->digest_enc.data,
8098 : : tdata->digest_enc.len,
8099 : : "Generated auth tag not as expected");
8100 : : }
8101 : :
8102 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8103 [ # # ]: 0 : if (verify) {
8104 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8105 : : plaintext,
8106 : : tdata->plaintext.data,
8107 : : tdata->plaintext.len_bits >> 3,
8108 : : "Plaintext data not as expected");
8109 : : } else {
8110 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8111 : : ciphertext,
8112 : : tdata->ciphertext.data,
8113 : : tdata->validDataLen.len_bits,
8114 : : "Ciphertext data not as expected");
8115 : : }
8116 : : }
8117 : :
8118 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8119 : : "crypto op processing failed");
8120 : :
8121 : : return 0;
8122 : : }
8123 : :
8124 : : static int
8125 : 0 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8126 : : uint8_t op_mode, uint8_t verify)
8127 : : {
8128 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8129 : : struct crypto_unittest_params *ut_params = &unittest_params;
8130 : :
8131 : : int retval;
8132 : :
8133 : : const uint8_t *plaintext = NULL;
8134 : : const uint8_t *ciphertext = NULL;
8135 : : const uint8_t *digest = NULL;
8136 : : unsigned int plaintext_pad_len;
8137 : : unsigned int plaintext_len;
8138 : : unsigned int ciphertext_pad_len;
8139 : : unsigned int ciphertext_len;
8140 : : uint8_t buffer[10000];
8141 : : uint8_t digest_buffer[10000];
8142 : :
8143 : : struct rte_cryptodev_info dev_info;
8144 : : struct rte_crypto_op *op;
8145 : :
8146 : : /* Check if device supports particular algorithms */
8147 [ # # ]: 0 : if (test_mixed_check_if_unsupported(tdata))
8148 : : return TEST_SKIPPED;
8149 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8150 : : return TEST_SKIPPED;
8151 : :
8152 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8153 : :
8154 : 0 : uint64_t feat_flags = dev_info.feature_flags;
8155 : :
8156 [ # # ]: 0 : if (op_mode == IN_PLACE) {
8157 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8158 : : printf("Device doesn't support in-place scatter-gather "
8159 : : "in both input and output mbufs.\n");
8160 : 0 : return TEST_SKIPPED;
8161 : : }
8162 : : } else {
8163 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8164 : : printf("Device doesn't support out-of-place scatter-gather "
8165 : : "in both input and output mbufs.\n");
8166 : 0 : return TEST_SKIPPED;
8167 : : }
8168 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8169 : : printf("Device doesn't support digest encrypted.\n");
8170 : 0 : return TEST_SKIPPED;
8171 : : }
8172 : : }
8173 : :
8174 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8175 : : return TEST_SKIPPED;
8176 : :
8177 : : /* Create the session */
8178 [ # # ]: 0 : if (verify)
8179 : 0 : retval = create_wireless_algo_cipher_auth_session(
8180 : 0 : ts_params->valid_devs[0],
8181 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8182 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8183 : 0 : tdata->auth_algo,
8184 : 0 : tdata->cipher_algo,
8185 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8186 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8187 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8188 : 0 : tdata->cipher_iv.len);
8189 : : else
8190 : 0 : retval = create_wireless_algo_auth_cipher_session(
8191 : 0 : ts_params->valid_devs[0],
8192 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8193 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8194 : 0 : tdata->auth_algo,
8195 : 0 : tdata->cipher_algo,
8196 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8197 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8198 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8199 : 0 : tdata->cipher_iv.len);
8200 [ # # ]: 0 : if (retval != 0)
8201 : : return retval;
8202 : :
8203 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8204 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8205 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8206 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8207 : :
8208 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8209 : : ciphertext_pad_len, 15, 0);
8210 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8211 : : "Failed to allocate input buffer in mempool");
8212 : :
8213 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8214 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8215 : : plaintext_pad_len, 15, 0);
8216 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8217 : : "Failed to allocate output buffer in mempool");
8218 : : }
8219 : :
8220 [ # # ]: 0 : if (verify) {
8221 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8222 : 0 : tdata->ciphertext.data);
8223 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8224 : : ciphertext_len, buffer);
8225 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8226 : : ciphertext_len);
8227 : : } else {
8228 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8229 : 0 : tdata->plaintext.data);
8230 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8231 : : plaintext_len, buffer);
8232 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8233 : : plaintext_len);
8234 : : }
8235 : : memset(buffer, 0, sizeof(buffer));
8236 : :
8237 : : /* Create the operation */
8238 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8239 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8240 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8241 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8242 : 0 : (tdata->digest_enc.offset == 0 ?
8243 : : plaintext_pad_len
8244 : : : tdata->digest_enc.offset),
8245 : 0 : tdata->validCipherLen.len_bits,
8246 : 0 : tdata->cipher.offset_bits,
8247 : 0 : tdata->validAuthLen.len_bits,
8248 [ # # ]: 0 : tdata->auth.offset_bits,
8249 : : op_mode, 1, verify);
8250 : :
8251 [ # # ]: 0 : if (retval < 0)
8252 : : return retval;
8253 : :
8254 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8255 : :
8256 : : /* Check if the op failed because the device doesn't */
8257 : : /* support this particular combination of algorithms */
8258 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8259 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8260 : : printf("Device doesn't support this mixed combination. "
8261 : : "Test Skipped.\n");
8262 : 0 : return TEST_SKIPPED;
8263 : : }
8264 : 0 : ut_params->op = op;
8265 : :
8266 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8267 : :
8268 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8269 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8270 : :
8271 [ # # ]: 0 : if (verify) {
8272 [ # # ]: 0 : if (ut_params->obuf)
8273 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8274 : : plaintext_len, buffer);
8275 : : else
8276 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8277 : : plaintext_len, buffer);
8278 : :
8279 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8280 : 0 : (tdata->plaintext.len_bits >> 3) -
8281 : 0 : tdata->digest_enc.len);
8282 : 0 : debug_hexdump(stdout, "plaintext expected:",
8283 : 0 : tdata->plaintext.data,
8284 : 0 : (tdata->plaintext.len_bits >> 3) -
8285 : 0 : tdata->digest_enc.len);
8286 : : } else {
8287 [ # # ]: 0 : if (ut_params->obuf)
8288 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8289 : : ciphertext_len, buffer);
8290 : : else
8291 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8292 : : ciphertext_len, buffer);
8293 : :
8294 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8295 : : ciphertext_len);
8296 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8297 : 0 : tdata->ciphertext.data,
8298 : 0 : tdata->ciphertext.len_bits >> 3);
8299 : :
8300 [ # # ]: 0 : if (ut_params->obuf)
8301 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
8302 : 0 : (tdata->digest_enc.offset == 0 ?
8303 : : plaintext_pad_len :
8304 : : tdata->digest_enc.offset),
8305 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8306 : : else
8307 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8308 : 0 : (tdata->digest_enc.offset == 0 ?
8309 : : plaintext_pad_len :
8310 : : tdata->digest_enc.offset),
8311 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8312 : :
8313 : 0 : debug_hexdump(stdout, "digest:", digest,
8314 : 0 : tdata->digest_enc.len);
8315 : 0 : debug_hexdump(stdout, "digest expected:",
8316 : 0 : tdata->digest_enc.data, tdata->digest_enc.len);
8317 : : }
8318 : :
8319 [ # # ]: 0 : if (!verify) {
8320 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8321 : : digest,
8322 : : tdata->digest_enc.data,
8323 : : tdata->digest_enc.len,
8324 : : "Generated auth tag not as expected");
8325 : : }
8326 : :
8327 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8328 [ # # ]: 0 : if (verify) {
8329 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8330 : : plaintext,
8331 : : tdata->plaintext.data,
8332 : : tdata->plaintext.len_bits >> 3,
8333 : : "Plaintext data not as expected");
8334 : : } else {
8335 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8336 : : ciphertext,
8337 : : tdata->ciphertext.data,
8338 : : tdata->validDataLen.len_bits,
8339 : : "Ciphertext data not as expected");
8340 : : }
8341 : : }
8342 : :
8343 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8344 : : "crypto op processing failed");
8345 : :
8346 : : return 0;
8347 : : }
8348 : :
8349 : : /** AUTH AES CMAC + CIPHER AES CTR */
8350 : :
8351 : : static int
8352 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8353 : : {
8354 : 0 : return test_mixed_auth_cipher(
8355 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8356 : : }
8357 : :
8358 : : static int
8359 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8360 : : {
8361 : 0 : return test_mixed_auth_cipher(
8362 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8363 : : }
8364 : :
8365 : : static int
8366 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8367 : : {
8368 : 0 : return test_mixed_auth_cipher_sgl(
8369 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8370 : : }
8371 : :
8372 : : static int
8373 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8374 : : {
8375 : 0 : return test_mixed_auth_cipher_sgl(
8376 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8377 : : }
8378 : :
8379 : : static int
8380 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8381 : : {
8382 : 0 : return test_mixed_auth_cipher(
8383 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8384 : : }
8385 : :
8386 : : static int
8387 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8388 : : {
8389 : 0 : return test_mixed_auth_cipher(
8390 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8391 : : }
8392 : :
8393 : : static int
8394 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8395 : : {
8396 : 0 : return test_mixed_auth_cipher(
8397 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8398 : : }
8399 : :
8400 : : static int
8401 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8402 : : {
8403 : 0 : return test_mixed_auth_cipher(
8404 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8405 : : }
8406 : :
8407 : : static int
8408 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8409 : : {
8410 : 0 : return test_mixed_auth_cipher(
8411 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8412 : : }
8413 : :
8414 : : static int
8415 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8416 : : {
8417 : 0 : return test_mixed_auth_cipher_sgl(
8418 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8419 : : }
8420 : :
8421 : : static int
8422 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8423 : : {
8424 : 0 : return test_mixed_auth_cipher_sgl(
8425 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8426 : : }
8427 : :
8428 : : static int
8429 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8430 : : {
8431 : 0 : return test_mixed_auth_cipher(
8432 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8433 : : }
8434 : :
8435 : : /** MIXED AUTH + CIPHER */
8436 : :
8437 : : static int
8438 : 0 : test_auth_zuc_cipher_snow_test_case_1(void)
8439 : : {
8440 : 0 : return test_mixed_auth_cipher(
8441 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8442 : : }
8443 : :
8444 : : static int
8445 : 0 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8446 : : {
8447 : 0 : return test_mixed_auth_cipher(
8448 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8449 : : }
8450 : :
8451 : : static int
8452 : 0 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8453 : : {
8454 : 0 : return test_mixed_auth_cipher(
8455 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8456 : : }
8457 : :
8458 : : static int
8459 : 0 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8460 : : {
8461 : 0 : return test_mixed_auth_cipher(
8462 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8463 : : }
8464 : :
8465 : :
8466 : : static int
8467 : 0 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8468 : : {
8469 : 0 : return test_mixed_auth_cipher(
8470 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8471 : : }
8472 : :
8473 : : static int
8474 : 0 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8475 : : {
8476 : 0 : return test_mixed_auth_cipher(
8477 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8478 : : }
8479 : :
8480 : : static int
8481 : 0 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8482 : : {
8483 : 0 : return test_mixed_auth_cipher(
8484 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8485 : : }
8486 : :
8487 : : static int
8488 : 0 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8489 : : {
8490 : 0 : return test_mixed_auth_cipher(
8491 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8492 : : }
8493 : :
8494 : : static int
8495 : 0 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8496 : : {
8497 : 0 : return test_mixed_auth_cipher(
8498 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8499 : : }
8500 : :
8501 : : static int
8502 : 0 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8503 : : {
8504 : 0 : return test_mixed_auth_cipher(
8505 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8506 : : }
8507 : :
8508 : : static int
8509 : 0 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8510 : : {
8511 : 0 : return test_mixed_auth_cipher(
8512 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8513 : : }
8514 : :
8515 : : static int
8516 : 0 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8517 : : {
8518 : 0 : return test_mixed_auth_cipher(
8519 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8520 : : }
8521 : :
8522 : : static int
8523 : 0 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8524 : : {
8525 : 0 : return test_mixed_auth_cipher(
8526 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8527 : : }
8528 : :
8529 : : static int
8530 : 0 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8531 : : {
8532 : 0 : return test_mixed_auth_cipher(
8533 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8534 : : }
8535 : :
8536 : : static int
8537 : 0 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8538 : : {
8539 : 0 : return test_mixed_auth_cipher_sgl(
8540 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8541 : : }
8542 : :
8543 : : static int
8544 : 0 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8545 : : {
8546 : 0 : return test_mixed_auth_cipher(
8547 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8548 : : }
8549 : :
8550 : : static int
8551 : 0 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8552 : : {
8553 : 0 : return test_mixed_auth_cipher_sgl(
8554 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8555 : : }
8556 : :
8557 : : static int
8558 : 0 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8559 : : {
8560 : 0 : return test_mixed_auth_cipher(
8561 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8562 : : }
8563 : :
8564 : : static int
8565 : 0 : test_auth_snow_cipher_zuc_test_case_1(void)
8566 : : {
8567 : 0 : return test_mixed_auth_cipher(
8568 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8569 : : }
8570 : :
8571 : : static int
8572 : 0 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8573 : : {
8574 : 0 : return test_mixed_auth_cipher(
8575 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8576 : : }
8577 : :
8578 : : static int
8579 : 0 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8580 : : {
8581 : 0 : return test_mixed_auth_cipher(
8582 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8583 : : }
8584 : :
8585 : : static int
8586 : 0 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8587 : : {
8588 : 0 : return test_mixed_auth_cipher(
8589 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8590 : : }
8591 : :
8592 : : static int
8593 : 0 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8594 : : {
8595 : 0 : return test_mixed_auth_cipher(
8596 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8597 : : }
8598 : :
8599 : : static int
8600 : 0 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8601 : : {
8602 : 0 : return test_mixed_auth_cipher(
8603 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8604 : : }
8605 : : static int
8606 : 0 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8607 : : {
8608 : 0 : return test_mixed_auth_cipher(
8609 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8610 : : }
8611 : :
8612 : : static int
8613 : 0 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8614 : : {
8615 : 0 : return test_mixed_auth_cipher(
8616 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8617 : : }
8618 : :
8619 : : static int
8620 : 0 : test_auth_null_cipher_snow_test_case_1(void)
8621 : : {
8622 : 0 : return test_mixed_auth_cipher(
8623 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8624 : : }
8625 : :
8626 : : static int
8627 : 0 : test_verify_auth_null_cipher_snow_test_case_1(void)
8628 : : {
8629 : 0 : return test_mixed_auth_cipher(
8630 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8631 : : }
8632 : :
8633 : : static int
8634 : 0 : test_auth_null_cipher_zuc_test_case_1(void)
8635 : : {
8636 : 0 : return test_mixed_auth_cipher(
8637 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8638 : : }
8639 : :
8640 : : static int
8641 : 0 : test_verify_auth_null_cipher_zuc_test_case_1(void)
8642 : : {
8643 : 0 : return test_mixed_auth_cipher(
8644 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8645 : : }
8646 : :
8647 : : static int
8648 : 0 : test_auth_snow_cipher_null_test_case_1(void)
8649 : : {
8650 : 0 : return test_mixed_auth_cipher(
8651 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8652 : : }
8653 : :
8654 : : static int
8655 : 0 : test_verify_auth_snow_cipher_null_test_case_1(void)
8656 : : {
8657 : 0 : return test_mixed_auth_cipher(
8658 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8659 : : }
8660 : :
8661 : : static int
8662 : 0 : test_auth_zuc_cipher_null_test_case_1(void)
8663 : : {
8664 : 0 : return test_mixed_auth_cipher(
8665 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8666 : : }
8667 : :
8668 : : static int
8669 : 0 : test_verify_auth_zuc_cipher_null_test_case_1(void)
8670 : : {
8671 : 0 : return test_mixed_auth_cipher(
8672 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8673 : : }
8674 : :
8675 : : static int
8676 : 0 : test_auth_null_cipher_aes_ctr_test_case_1(void)
8677 : : {
8678 : 0 : return test_mixed_auth_cipher(
8679 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8680 : : }
8681 : :
8682 : : static int
8683 : 0 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8684 : : {
8685 : 0 : return test_mixed_auth_cipher(
8686 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8687 : : }
8688 : :
8689 : : static int
8690 : 0 : test_auth_aes_cmac_cipher_null_test_case_1(void)
8691 : : {
8692 : 0 : return test_mixed_auth_cipher(
8693 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8694 : : }
8695 : :
8696 : : static int
8697 : 0 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8698 : : {
8699 : 0 : return test_mixed_auth_cipher(
8700 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8701 : : }
8702 : :
8703 : : /* ***** AEAD algorithm Tests ***** */
8704 : :
8705 : : static int
8706 : 0 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8707 : : enum rte_crypto_aead_operation op,
8708 : : const uint8_t *key, const uint8_t key_len,
8709 : : const uint16_t aad_len, const uint8_t auth_len,
8710 : : uint8_t iv_len)
8711 : 0 : {
8712 : 0 : uint8_t aead_key[key_len];
8713 : :
8714 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8715 : : struct crypto_unittest_params *ut_params = &unittest_params;
8716 : :
8717 : : memcpy(aead_key, key, key_len);
8718 : :
8719 : : /* Setup AEAD Parameters */
8720 : 0 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8721 : 0 : ut_params->aead_xform.next = NULL;
8722 : 0 : ut_params->aead_xform.aead.algo = algo;
8723 : 0 : ut_params->aead_xform.aead.op = op;
8724 : 0 : ut_params->aead_xform.aead.key.data = aead_key;
8725 : 0 : ut_params->aead_xform.aead.key.length = key_len;
8726 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8727 : 0 : ut_params->aead_xform.aead.iv.length = iv_len;
8728 : 0 : ut_params->aead_xform.aead.digest_length = auth_len;
8729 : 0 : ut_params->aead_xform.aead.aad_length = aad_len;
8730 : :
8731 : 0 : debug_hexdump(stdout, "key:", key, key_len);
8732 : :
8733 : : /* Create Crypto session*/
8734 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8735 : : &ut_params->aead_xform, ts_params->session_mpool);
8736 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8737 : : return TEST_SKIPPED;
8738 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8739 : : return 0;
8740 : : }
8741 : :
8742 : : static int
8743 : 0 : create_aead_xform(struct rte_crypto_op *op,
8744 : : enum rte_crypto_aead_algorithm algo,
8745 : : enum rte_crypto_aead_operation aead_op,
8746 : : uint8_t *key, const uint8_t key_len,
8747 : : const uint8_t aad_len, const uint8_t auth_len,
8748 : : uint8_t iv_len)
8749 : : {
8750 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8751 : : "failed to allocate space for crypto transform");
8752 : :
8753 : : struct rte_crypto_sym_op *sym_op = op->sym;
8754 : :
8755 : : /* Setup AEAD Parameters */
8756 : 0 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8757 : 0 : sym_op->xform->next = NULL;
8758 : 0 : sym_op->xform->aead.algo = algo;
8759 : 0 : sym_op->xform->aead.op = aead_op;
8760 : 0 : sym_op->xform->aead.key.data = key;
8761 : 0 : sym_op->xform->aead.key.length = key_len;
8762 : 0 : sym_op->xform->aead.iv.offset = IV_OFFSET;
8763 : 0 : sym_op->xform->aead.iv.length = iv_len;
8764 : 0 : sym_op->xform->aead.digest_length = auth_len;
8765 : 0 : sym_op->xform->aead.aad_length = aad_len;
8766 : :
8767 : 0 : debug_hexdump(stdout, "key:", key, key_len);
8768 : :
8769 : : return 0;
8770 : : }
8771 : :
8772 : : static int
8773 : 0 : create_aead_operation(enum rte_crypto_aead_operation op,
8774 : : const struct aead_test_data *tdata)
8775 : : {
8776 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8777 : : struct crypto_unittest_params *ut_params = &unittest_params;
8778 : :
8779 : : uint8_t *plaintext, *ciphertext;
8780 : : unsigned int aad_pad_len, plaintext_pad_len;
8781 : :
8782 : : /* Generate Crypto op data structure */
8783 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8784 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8785 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
8786 : : "Failed to allocate symmetric crypto operation struct");
8787 : :
8788 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8789 : :
8790 : : /* Append aad data */
8791 [ # # ]: 0 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8792 : 0 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8793 : 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8794 : : aad_pad_len);
8795 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8796 : : "no room to append aad");
8797 : :
8798 : 0 : sym_op->aead.aad.phys_addr =
8799 : 0 : rte_pktmbuf_iova(ut_params->ibuf);
8800 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8801 : 0 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8802 : 0 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8803 : 0 : tdata->aad.len);
8804 : :
8805 : : /* Append IV at the end of the crypto operation*/
8806 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8807 : : uint8_t *, IV_OFFSET);
8808 : :
8809 : : /* Copy IV 1 byte after the IV pointer, according to the API */
8810 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8811 : 0 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
8812 : 0 : tdata->iv.len);
8813 : : } else {
8814 : 0 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8815 : 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8816 : : aad_pad_len);
8817 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8818 : : "no room to append aad");
8819 : :
8820 : 0 : sym_op->aead.aad.phys_addr =
8821 : 0 : rte_pktmbuf_iova(ut_params->ibuf);
8822 : 0 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8823 : 0 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8824 : 0 : tdata->aad.len);
8825 : :
8826 : : /* Append IV at the end of the crypto operation*/
8827 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8828 : : uint8_t *, IV_OFFSET);
8829 : :
8830 [ # # ]: 0 : if (tdata->iv.len == 0) {
8831 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8832 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
8833 : : AES_GCM_J0_LENGTH);
8834 : : } else {
8835 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8836 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
8837 : 0 : tdata->iv.len);
8838 : : }
8839 : : }
8840 : :
8841 : : /* Append plaintext/ciphertext */
8842 [ # # ]: 0 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8843 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8844 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8845 : : plaintext_pad_len);
8846 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8847 : :
8848 : 0 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8849 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8850 : 0 : tdata->plaintext.len);
8851 : :
8852 [ # # ]: 0 : if (ut_params->obuf) {
8853 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
8854 : : ut_params->obuf,
8855 : 0 : plaintext_pad_len + aad_pad_len);
8856 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext,
8857 : : "no room to append ciphertext");
8858 : :
8859 : 0 : memset(ciphertext + aad_pad_len, 0,
8860 : 0 : tdata->ciphertext.len);
8861 : : }
8862 : : } else {
8863 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8864 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8865 : : plaintext_pad_len);
8866 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext,
8867 : : "no room to append ciphertext");
8868 : :
8869 : 0 : memcpy(ciphertext, tdata->ciphertext.data,
8870 : 0 : tdata->ciphertext.len);
8871 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8872 : 0 : tdata->ciphertext.len);
8873 : :
8874 [ # # ]: 0 : if (ut_params->obuf) {
8875 : : plaintext = (uint8_t *)rte_pktmbuf_append(
8876 : : ut_params->obuf,
8877 : 0 : plaintext_pad_len + aad_pad_len);
8878 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext,
8879 : : "no room to append plaintext");
8880 : :
8881 : 0 : memset(plaintext + aad_pad_len, 0,
8882 : 0 : tdata->plaintext.len);
8883 : : }
8884 : : }
8885 : :
8886 : : /* Append digest data */
8887 [ # # ]: 0 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8888 : 0 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8889 : 0 : ut_params->obuf ? ut_params->obuf :
8890 : : ut_params->ibuf,
8891 [ # # ]: 0 : tdata->auth_tag.len);
8892 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8893 : : "no room to append digest");
8894 [ # # ]: 0 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8895 [ # # ]: 0 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8896 : : ut_params->obuf ? ut_params->obuf :
8897 : : ut_params->ibuf,
8898 : : plaintext_pad_len +
8899 : : aad_pad_len);
8900 : : } else {
8901 : 0 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8902 : 0 : ut_params->ibuf, tdata->auth_tag.len);
8903 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8904 : : "no room to append digest");
8905 [ # # ]: 0 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8906 : : ut_params->ibuf,
8907 : : plaintext_pad_len + aad_pad_len);
8908 : :
8909 : 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8910 [ # # ]: 0 : tdata->auth_tag.len);
8911 : 0 : debug_hexdump(stdout, "digest:",
8912 : 0 : sym_op->aead.digest.data,
8913 : 0 : tdata->auth_tag.len);
8914 : : }
8915 : :
8916 : 0 : sym_op->aead.data.length = tdata->plaintext.len;
8917 : 0 : sym_op->aead.data.offset = aad_pad_len;
8918 : :
8919 : 0 : return 0;
8920 : : }
8921 : :
8922 : : static int
8923 : 0 : test_authenticated_encryption(const struct aead_test_data *tdata)
8924 : : {
8925 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8926 : : struct crypto_unittest_params *ut_params = &unittest_params;
8927 : :
8928 : : int retval;
8929 : : uint8_t *ciphertext, *auth_tag;
8930 : : uint16_t plaintext_pad_len;
8931 : : uint32_t i;
8932 : : struct rte_cryptodev_info dev_info;
8933 : :
8934 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8935 : 0 : uint64_t feat_flags = dev_info.feature_flags;
8936 : :
8937 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8938 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8939 : : printf("Device doesn't support RAW data-path APIs.\n");
8940 : 0 : return TEST_SKIPPED;
8941 : : }
8942 : :
8943 : : /* Verify the capabilities */
8944 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8945 : : const struct rte_cryptodev_symmetric_capability *capability;
8946 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8947 : 0 : cap_idx.algo.aead = tdata->algo;
8948 : 0 : capability = rte_cryptodev_sym_capability_get(
8949 : 0 : ts_params->valid_devs[0], &cap_idx);
8950 [ # # ]: 0 : if (capability == NULL)
8951 : : return TEST_SKIPPED;
8952 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_aead(
8953 : 0 : capability, tdata->key.len, tdata->auth_tag.len,
8954 : 0 : tdata->aad.len, tdata->iv.len))
8955 : : return TEST_SKIPPED;
8956 : :
8957 : : /* Create AEAD session */
8958 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
8959 : 0 : tdata->algo,
8960 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
8961 : 0 : tdata->key.data, tdata->key.len,
8962 : 0 : tdata->aad.len, tdata->auth_tag.len,
8963 : 0 : tdata->iv.len);
8964 [ # # ]: 0 : if (retval != TEST_SUCCESS)
8965 : : return retval;
8966 : :
8967 [ # # ]: 0 : if (tdata->aad.len > MBUF_SIZE) {
8968 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8969 : : /* Populate full size of add data */
8970 [ # # ]: 0 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8971 : 0 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8972 : : } else
8973 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8974 : :
8975 : : /* clear mbuf payload */
8976 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8977 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8978 : :
8979 : : /* Create AEAD operation */
8980 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8981 [ # # ]: 0 : if (retval < 0)
8982 : : return retval;
8983 : :
8984 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8985 : :
8986 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
8987 : :
8988 : : /* Process crypto operation */
8989 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8990 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8991 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8992 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
8993 : : 0);
8994 [ # # ]: 0 : if (retval != TEST_SUCCESS)
8995 : : return retval;
8996 : : } else
8997 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
8998 : : process_crypto_request(ts_params->valid_devs[0],
8999 : : ut_params->op), "failed to process sym crypto op");
9000 : :
9001 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9002 : : "crypto op processing failed");
9003 : :
9004 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9005 : :
9006 [ # # ]: 0 : if (ut_params->op->sym->m_dst) {
9007 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9008 : : uint8_t *);
9009 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9010 : : uint8_t *, plaintext_pad_len);
9011 : : } else {
9012 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9013 : : uint8_t *,
9014 : : ut_params->op->sym->cipher.data.offset);
9015 : 0 : auth_tag = ciphertext + plaintext_pad_len;
9016 : : }
9017 : :
9018 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9019 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9020 : :
9021 : : /* Validate obuf */
9022 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9023 : : ciphertext,
9024 : : tdata->ciphertext.data,
9025 : : tdata->ciphertext.len,
9026 : : "Ciphertext data not as expected");
9027 : :
9028 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9029 : : auth_tag,
9030 : : tdata->auth_tag.data,
9031 : : tdata->auth_tag.len,
9032 : : "Generated auth tag not as expected");
9033 : :
9034 : : return 0;
9035 : :
9036 : : }
9037 : :
9038 : : #ifdef RTE_LIB_SECURITY
9039 : : static int
9040 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9041 : : enum rte_security_session_protocol proto)
9042 : : {
9043 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9044 : :
9045 : : const struct rte_security_capability *capabilities;
9046 : : const struct rte_security_capability *capability;
9047 : : uint16_t i = 0;
9048 : :
9049 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9050 : :
9051 : :
9052 : 0 : capabilities = rte_security_capabilities_get(ctx);
9053 : :
9054 [ # # ]: 0 : if (capabilities == NULL)
9055 : : return -ENOTSUP;
9056 : :
9057 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9058 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9059 [ # # ]: 0 : if (capability->action == action &&
9060 [ # # ]: 0 : capability->protocol == proto)
9061 : : return 0;
9062 : : }
9063 : :
9064 : : return -ENOTSUP;
9065 : : }
9066 : :
9067 : : /* Basic algorithm run function for async inplace mode.
9068 : : * Creates a session from input parameters and runs one operation
9069 : : * on input_vec. Checks the output of the crypto operation against
9070 : : * output_vec.
9071 : : */
9072 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9073 : : enum rte_crypto_auth_operation opa,
9074 : : const uint8_t *input_vec, unsigned int input_vec_len,
9075 : : const uint8_t *output_vec,
9076 : : unsigned int output_vec_len,
9077 : : enum rte_crypto_cipher_algorithm cipher_alg,
9078 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9079 : : enum rte_crypto_auth_algorithm auth_alg,
9080 : : const uint8_t *auth_key, uint32_t auth_key_len,
9081 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9082 : : uint8_t packet_direction, uint8_t sn_size,
9083 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9084 : : {
9085 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9086 : : struct crypto_unittest_params *ut_params = &unittest_params;
9087 : : uint8_t *plaintext;
9088 : : int ret = TEST_SUCCESS;
9089 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9090 : : struct rte_cryptodev_info dev_info;
9091 : : uint64_t feat_flags;
9092 : :
9093 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9094 : 0 : feat_flags = dev_info.feature_flags;
9095 : :
9096 : : /* Verify the capabilities */
9097 : : struct rte_security_capability_idx sec_cap_idx;
9098 : :
9099 : 0 : sec_cap_idx.action = ut_params->type;
9100 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9101 : 0 : sec_cap_idx.pdcp.domain = domain;
9102 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9103 : : return TEST_SKIPPED;
9104 : :
9105 : : /* Generate test mbuf data */
9106 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9107 : :
9108 : : /* clear mbuf payload */
9109 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9110 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9111 : :
9112 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9113 : : input_vec_len);
9114 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9115 : :
9116 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9117 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9118 : : printf("Device does not support RAW data-path APIs.\n");
9119 : 0 : return TEST_SKIPPED;
9120 : : }
9121 : : /* Out of place support */
9122 [ # # ]: 0 : if (oop) {
9123 : : /*
9124 : : * For out-op-place we need to alloc another mbuf
9125 : : */
9126 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9127 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9128 : : }
9129 : :
9130 : : /* Setup Cipher Parameters */
9131 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9132 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9133 : 0 : ut_params->cipher_xform.cipher.op = opc;
9134 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9135 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9136 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9137 : : packet_direction ? 4 : 0;
9138 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9139 : :
9140 : : /* Setup HMAC Parameters if ICV header is required */
9141 [ # # ]: 0 : if (auth_alg != 0) {
9142 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9143 : 0 : ut_params->auth_xform.next = NULL;
9144 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9145 : 0 : ut_params->auth_xform.auth.op = opa;
9146 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9147 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9148 : :
9149 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9150 : : } else {
9151 : 0 : ut_params->cipher_xform.next = NULL;
9152 : : }
9153 : :
9154 : 0 : struct rte_security_session_conf sess_conf = {
9155 : 0 : .action_type = ut_params->type,
9156 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9157 : : {.pdcp = {
9158 : : .bearer = bearer,
9159 : : .domain = domain,
9160 : : .pkt_dir = packet_direction,
9161 : : .sn_size = sn_size,
9162 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9163 : : /**
9164 : : * hfn can be set as pdcp_test_hfn[i]
9165 : : * if hfn_ovrd is not set. Here, PDCP
9166 : : * packet direction is just used to
9167 : : * run half of the cases with session
9168 : : * HFN and other half with per packet
9169 : : * HFN.
9170 : : */
9171 : : .hfn_threshold = hfn_threshold,
9172 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9173 : : .sdap_enabled = sdap,
9174 : : } },
9175 : : .crypto_xform = &ut_params->cipher_xform
9176 : : };
9177 : :
9178 : : /* Create security session */
9179 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9180 : : &sess_conf, ts_params->session_mpool);
9181 : :
9182 [ # # ]: 0 : if (!ut_params->sec_session) {
9183 : : printf("TestCase %s()-%d line %d failed %s: ",
9184 : : __func__, i, __LINE__, "Failed to allocate session");
9185 : : ret = TEST_FAILED;
9186 : 0 : goto on_err;
9187 : : }
9188 : :
9189 : : /* Generate crypto op data structure */
9190 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9191 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9192 [ # # ]: 0 : if (!ut_params->op) {
9193 : : printf("TestCase %s()-%d line %d failed %s: ",
9194 : : __func__, i, __LINE__,
9195 : : "Failed to allocate symmetric crypto operation struct");
9196 : : ret = TEST_FAILED;
9197 : 0 : goto on_err;
9198 : : }
9199 : :
9200 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9201 : : uint32_t *, IV_OFFSET);
9202 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9203 : :
9204 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9205 : :
9206 : : /* set crypto operation source mbuf */
9207 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9208 [ # # ]: 0 : if (oop)
9209 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9210 : :
9211 : : /* Process crypto operation */
9212 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9213 : : /* filling lengths */
9214 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9215 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9216 : :
9217 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9218 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9219 : : return ret;
9220 : : } else {
9221 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9222 : : }
9223 [ # # ]: 0 : if (ut_params->op == NULL) {
9224 : : printf("TestCase %s()-%d line %d failed %s: ",
9225 : : __func__, i, __LINE__,
9226 : : "failed to process sym crypto op");
9227 : : ret = TEST_FAILED;
9228 : 0 : goto on_err;
9229 : : }
9230 : :
9231 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9232 : : printf("TestCase %s()-%d line %d failed %s: ",
9233 : : __func__, i, __LINE__, "crypto op processing failed");
9234 : : ret = TEST_FAILED;
9235 : 0 : goto on_err;
9236 : : }
9237 : :
9238 : : /* Validate obuf */
9239 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9240 : : uint8_t *);
9241 [ # # ]: 0 : if (oop) {
9242 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9243 : : uint8_t *);
9244 : : }
9245 : :
9246 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9247 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9248 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9249 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9250 : : ret = TEST_FAILED;
9251 : 0 : goto on_err;
9252 : : }
9253 : :
9254 : 0 : on_err:
9255 : 0 : rte_crypto_op_free(ut_params->op);
9256 : 0 : ut_params->op = NULL;
9257 : :
9258 [ # # ]: 0 : if (ut_params->sec_session)
9259 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9260 : 0 : ut_params->sec_session = NULL;
9261 : :
9262 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9263 : 0 : ut_params->ibuf = NULL;
9264 [ # # ]: 0 : if (oop) {
9265 : 0 : rte_pktmbuf_free(ut_params->obuf);
9266 : 0 : ut_params->obuf = NULL;
9267 : : }
9268 : :
9269 : : return ret;
9270 : : }
9271 : :
9272 : : static int
9273 : 0 : test_pdcp_proto_SGL(int i, int oop,
9274 : : enum rte_crypto_cipher_operation opc,
9275 : : enum rte_crypto_auth_operation opa,
9276 : : uint8_t *input_vec,
9277 : : unsigned int input_vec_len,
9278 : : uint8_t *output_vec,
9279 : : unsigned int output_vec_len,
9280 : : uint32_t fragsz,
9281 : : uint32_t fragsz_oop)
9282 : : {
9283 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9284 : : struct crypto_unittest_params *ut_params = &unittest_params;
9285 : : uint8_t *plaintext;
9286 : : struct rte_mbuf *buf, *buf_oop = NULL;
9287 : : int ret = TEST_SUCCESS;
9288 : : int to_trn = 0;
9289 : : int to_trn_tbl[16];
9290 : : int segs = 1;
9291 : : unsigned int trn_data = 0;
9292 : : struct rte_cryptodev_info dev_info;
9293 : : uint64_t feat_flags;
9294 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9295 : : struct rte_mbuf *temp_mbuf;
9296 : :
9297 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9298 : 0 : feat_flags = dev_info.feature_flags;
9299 : :
9300 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9301 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9302 : : printf("Device does not support RAW data-path APIs.\n");
9303 : 0 : return -ENOTSUP;
9304 : : }
9305 : : /* Verify the capabilities */
9306 : : struct rte_security_capability_idx sec_cap_idx;
9307 : :
9308 : 0 : sec_cap_idx.action = ut_params->type;
9309 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9310 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9311 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9312 : : return TEST_SKIPPED;
9313 : :
9314 : : if (fragsz > input_vec_len)
9315 : : fragsz = input_vec_len;
9316 : :
9317 : 0 : uint16_t plaintext_len = fragsz;
9318 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9319 : :
9320 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9321 : 0 : frag_size_oop = output_vec_len;
9322 : :
9323 : : int ecx = 0;
9324 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9325 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9326 : : return 1;
9327 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9328 : : return 1;
9329 : :
9330 : : /* Out of place support */
9331 [ # # ]: 0 : if (oop) {
9332 : : /*
9333 : : * For out-op-place we need to alloc another mbuf
9334 : : */
9335 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9336 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9337 : 0 : buf_oop = ut_params->obuf;
9338 : : }
9339 : :
9340 : : /* Generate test mbuf data */
9341 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9342 : :
9343 : : /* clear mbuf payload */
9344 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9345 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9346 : :
9347 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9348 : : plaintext_len);
9349 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9350 : : trn_data += plaintext_len;
9351 : :
9352 : 0 : buf = ut_params->ibuf;
9353 : :
9354 : : /*
9355 : : * Loop until no more fragments
9356 : : */
9357 : :
9358 [ # # ]: 0 : while (trn_data < input_vec_len) {
9359 : 0 : ++segs;
9360 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9361 : 0 : (input_vec_len - trn_data) : fragsz;
9362 : :
9363 : 0 : to_trn_tbl[ecx++] = to_trn;
9364 : :
9365 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9366 : : buf = buf->next;
9367 : :
9368 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9369 : : rte_pktmbuf_tailroom(buf));
9370 : :
9371 : : /* OOP */
9372 [ # # ]: 0 : if (oop && !fragsz_oop) {
9373 : 0 : buf_oop->next =
9374 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9375 : : buf_oop = buf_oop->next;
9376 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9377 : : 0, rte_pktmbuf_tailroom(buf_oop));
9378 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9379 : : }
9380 : :
9381 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9382 : : to_trn);
9383 : :
9384 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9385 : 0 : trn_data += to_trn;
9386 : : }
9387 : :
9388 : 0 : ut_params->ibuf->nb_segs = segs;
9389 : :
9390 : : segs = 1;
9391 [ # # ]: 0 : if (fragsz_oop && oop) {
9392 : : to_trn = 0;
9393 : : ecx = 0;
9394 : :
9395 : 0 : trn_data = frag_size_oop;
9396 [ # # ]: 0 : while (trn_data < output_vec_len) {
9397 : 0 : ++segs;
9398 : 0 : to_trn =
9399 : 0 : (output_vec_len - trn_data <
9400 : : frag_size_oop) ?
9401 : 0 : (output_vec_len - trn_data) :
9402 : : frag_size_oop;
9403 : :
9404 : 0 : to_trn_tbl[ecx++] = to_trn;
9405 : :
9406 : 0 : buf_oop->next =
9407 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9408 : : buf_oop = buf_oop->next;
9409 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9410 : : 0, rte_pktmbuf_tailroom(buf_oop));
9411 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9412 : :
9413 : 0 : trn_data += to_trn;
9414 : : }
9415 : 0 : ut_params->obuf->nb_segs = segs;
9416 : : }
9417 : :
9418 : : /* Setup Cipher Parameters */
9419 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9420 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9421 : 0 : ut_params->cipher_xform.cipher.op = opc;
9422 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9423 : 0 : ut_params->cipher_xform.cipher.key.length =
9424 : 0 : pdcp_test_params[i].cipher_key_len;
9425 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9426 : :
9427 : : /* Setup HMAC Parameters if ICV header is required */
9428 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9429 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9430 : 0 : ut_params->auth_xform.next = NULL;
9431 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9432 : 0 : ut_params->auth_xform.auth.op = opa;
9433 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9434 : 0 : ut_params->auth_xform.auth.key.length =
9435 : 0 : pdcp_test_params[i].auth_key_len;
9436 : :
9437 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9438 : : } else {
9439 : 0 : ut_params->cipher_xform.next = NULL;
9440 : : }
9441 : :
9442 : 0 : struct rte_security_session_conf sess_conf = {
9443 : 0 : .action_type = ut_params->type,
9444 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9445 : : {.pdcp = {
9446 : 0 : .bearer = pdcp_test_bearer[i],
9447 : 0 : .domain = pdcp_test_params[i].domain,
9448 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9449 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9450 : 0 : .hfn = pdcp_test_hfn[i],
9451 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9452 : : .hfn_ovrd = 0,
9453 : : } },
9454 : : .crypto_xform = &ut_params->cipher_xform
9455 : : };
9456 : :
9457 : : /* Create security session */
9458 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9459 : : &sess_conf, ts_params->session_mpool);
9460 : :
9461 [ # # ]: 0 : if (!ut_params->sec_session) {
9462 : : printf("TestCase %s()-%d line %d failed %s: ",
9463 : : __func__, i, __LINE__, "Failed to allocate session");
9464 : : ret = TEST_FAILED;
9465 : 0 : goto on_err;
9466 : : }
9467 : :
9468 : : /* Generate crypto op data structure */
9469 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9470 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9471 [ # # ]: 0 : if (!ut_params->op) {
9472 : : printf("TestCase %s()-%d line %d failed %s: ",
9473 : : __func__, i, __LINE__,
9474 : : "Failed to allocate symmetric crypto operation struct");
9475 : : ret = TEST_FAILED;
9476 : 0 : goto on_err;
9477 : : }
9478 : :
9479 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9480 : :
9481 : : /* set crypto operation source mbuf */
9482 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9483 [ # # ]: 0 : if (oop)
9484 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9485 : :
9486 : : /* Process crypto operation */
9487 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9488 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9489 : : /* filling lengths */
9490 [ # # ]: 0 : while (temp_mbuf) {
9491 : 0 : ut_params->op->sym->cipher.data.length
9492 : 0 : += temp_mbuf->pkt_len;
9493 : 0 : ut_params->op->sym->auth.data.length
9494 : 0 : += temp_mbuf->pkt_len;
9495 : 0 : temp_mbuf = temp_mbuf->next;
9496 : : }
9497 : :
9498 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9499 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9500 : : return ret;
9501 : : } else {
9502 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9503 : : ut_params->op);
9504 : : }
9505 [ # # ]: 0 : if (ut_params->op == NULL) {
9506 : : printf("TestCase %s()-%d line %d failed %s: ",
9507 : : __func__, i, __LINE__,
9508 : : "failed to process sym crypto op");
9509 : : ret = TEST_FAILED;
9510 : 0 : goto on_err;
9511 : : }
9512 : :
9513 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9514 : : printf("TestCase %s()-%d line %d failed %s: ",
9515 : : __func__, i, __LINE__, "crypto op processing failed");
9516 : : ret = TEST_FAILED;
9517 : 0 : goto on_err;
9518 : : }
9519 : :
9520 : : /* Validate obuf */
9521 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9522 : : uint8_t *);
9523 [ # # ]: 0 : if (oop) {
9524 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9525 : : uint8_t *);
9526 : : }
9527 [ # # ]: 0 : if (fragsz_oop)
9528 : 0 : fragsz = frag_size_oop;
9529 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9530 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9531 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9532 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9533 : : ret = TEST_FAILED;
9534 : 0 : goto on_err;
9535 : : }
9536 : :
9537 : 0 : buf = ut_params->op->sym->m_src->next;
9538 [ # # ]: 0 : if (oop)
9539 : 0 : buf = ut_params->op->sym->m_dst->next;
9540 : :
9541 : : unsigned int off = fragsz;
9542 : :
9543 : : ecx = 0;
9544 [ # # ]: 0 : while (buf) {
9545 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9546 : : uint8_t *);
9547 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9548 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9549 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9550 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9551 : : to_trn_tbl[ecx]);
9552 : : ret = TEST_FAILED;
9553 : 0 : goto on_err;
9554 : : }
9555 : 0 : off += to_trn_tbl[ecx++];
9556 : 0 : buf = buf->next;
9557 : : }
9558 : 0 : on_err:
9559 : 0 : rte_crypto_op_free(ut_params->op);
9560 : 0 : ut_params->op = NULL;
9561 : :
9562 [ # # ]: 0 : if (ut_params->sec_session)
9563 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9564 : 0 : ut_params->sec_session = NULL;
9565 : :
9566 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9567 : 0 : ut_params->ibuf = NULL;
9568 [ # # ]: 0 : if (oop) {
9569 : 0 : rte_pktmbuf_free(ut_params->obuf);
9570 : 0 : ut_params->obuf = NULL;
9571 : : }
9572 : :
9573 : : return ret;
9574 : : }
9575 : :
9576 : : int
9577 : 0 : test_pdcp_proto_cplane_encap(int i)
9578 : : {
9579 : 0 : return test_pdcp_proto(
9580 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9581 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9582 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9583 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9584 : 0 : pdcp_test_params[i].cipher_key_len,
9585 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9586 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9587 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9588 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9589 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9590 : : }
9591 : :
9592 : : int
9593 : 0 : test_pdcp_proto_uplane_encap(int i)
9594 : : {
9595 : 0 : return test_pdcp_proto(
9596 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9597 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9598 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9599 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9600 : 0 : pdcp_test_params[i].cipher_key_len,
9601 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9602 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9603 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9604 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9605 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9606 : : }
9607 : :
9608 : : int
9609 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
9610 : : {
9611 : 0 : return test_pdcp_proto(
9612 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9613 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9614 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9615 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9616 : 0 : pdcp_test_params[i].cipher_key_len,
9617 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9618 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9619 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9620 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9621 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9622 : : }
9623 : :
9624 : : int
9625 : 0 : test_pdcp_proto_cplane_decap(int i)
9626 : : {
9627 : 0 : return test_pdcp_proto(
9628 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9629 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9630 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9631 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9632 : 0 : pdcp_test_params[i].cipher_key_len,
9633 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9634 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9635 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9636 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9637 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9638 : : }
9639 : :
9640 : : int
9641 : 0 : test_pdcp_proto_uplane_decap(int i)
9642 : : {
9643 : 0 : return test_pdcp_proto(
9644 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9645 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9646 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9647 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9648 : 0 : pdcp_test_params[i].cipher_key_len,
9649 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9650 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9651 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9652 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9653 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9654 : : }
9655 : :
9656 : : int
9657 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
9658 : : {
9659 : 0 : return test_pdcp_proto(
9660 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9661 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9662 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9663 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9664 : 0 : pdcp_test_params[i].cipher_key_len,
9665 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9666 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9667 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9668 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9669 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9670 : : }
9671 : :
9672 : : static int
9673 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
9674 : : {
9675 : : /* i can be used for running any PDCP case
9676 : : * In this case it is uplane 12-bit AES-SNOW DL encap
9677 : : */
9678 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9679 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
9680 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9681 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9682 : : pdcp_test_data_in[i],
9683 : : pdcp_test_data_in_len[i],
9684 : : pdcp_test_data_out[i],
9685 : 0 : pdcp_test_data_in_len[i]+4,
9686 : : 32, 0);
9687 : : }
9688 : : static int
9689 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
9690 : : {
9691 : : /* i can be used for running any PDCP case
9692 : : * In this case it is uplane 18-bit NULL-NULL DL encap
9693 : : */
9694 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9695 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9696 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9697 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9698 : : pdcp_test_data_in[i],
9699 : : pdcp_test_data_in_len[i],
9700 : : pdcp_test_data_out[i],
9701 : 0 : pdcp_test_data_in_len[i]+4,
9702 : : 32, 128);
9703 : : }
9704 : : static int
9705 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
9706 : : {
9707 : : /* i can be used for running any PDCP case
9708 : : * In this case it is uplane 18-bit AES DL encap
9709 : : */
9710 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9711 : : + DOWNLINK;
9712 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9713 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9714 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9715 : : pdcp_test_data_in[i],
9716 : : pdcp_test_data_in_len[i],
9717 : : pdcp_test_data_out[i],
9718 : : pdcp_test_data_in_len[i],
9719 : : 32, 40);
9720 : : }
9721 : : static int
9722 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
9723 : : {
9724 : : /* i can be used for running any PDCP case
9725 : : * In this case it is cplane 12-bit AES-ZUC DL encap
9726 : : */
9727 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9728 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9729 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9730 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9731 : : pdcp_test_data_in[i],
9732 : : pdcp_test_data_in_len[i],
9733 : : pdcp_test_data_out[i],
9734 : 0 : pdcp_test_data_in_len[i]+4,
9735 : : 128, 32);
9736 : : }
9737 : :
9738 : : static int
9739 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
9740 : : {
9741 : : int i = 0, size = 0;
9742 : : int err, all_err = TEST_SUCCESS;
9743 : : const struct pdcp_sdap_test *cur_test;
9744 : :
9745 : : size = RTE_DIM(list_pdcp_sdap_tests);
9746 : :
9747 [ # # ]: 0 : for (i = 0; i < size; i++) {
9748 : : cur_test = &list_pdcp_sdap_tests[i];
9749 : 0 : err = test_pdcp_proto(
9750 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9751 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9752 : 0 : cur_test->in_len, cur_test->data_out,
9753 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9754 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
9755 : 0 : cur_test->param.cipher_key_len,
9756 : 0 : cur_test->param.auth_alg,
9757 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9758 : 0 : cur_test->bearer, cur_test->param.domain,
9759 : 0 : cur_test->packet_direction, cur_test->sn_size,
9760 : 0 : cur_test->hfn,
9761 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
9762 [ # # ]: 0 : if (err) {
9763 : : printf("\t%d) %s: Encapsulation failed\n",
9764 : 0 : cur_test->test_idx,
9765 : 0 : cur_test->param.name);
9766 : : err = TEST_FAILED;
9767 : : } else {
9768 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9769 : 0 : cur_test->param.name);
9770 : : err = TEST_SUCCESS;
9771 : : }
9772 : 0 : all_err += err;
9773 : : }
9774 : :
9775 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9776 : :
9777 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9778 : : }
9779 : :
9780 : : static int
9781 : 0 : test_PDCP_PROTO_short_mac(void)
9782 : : {
9783 : : int i = 0, size = 0;
9784 : : int err, all_err = TEST_SUCCESS;
9785 : : const struct pdcp_short_mac_test *cur_test;
9786 : :
9787 : : size = RTE_DIM(list_pdcp_smac_tests);
9788 : :
9789 [ # # ]: 0 : for (i = 0; i < size; i++) {
9790 : : cur_test = &list_pdcp_smac_tests[i];
9791 : 0 : err = test_pdcp_proto(
9792 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9793 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9794 : 0 : cur_test->in_len, cur_test->data_out,
9795 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9796 : : RTE_CRYPTO_CIPHER_NULL, NULL,
9797 : 0 : 0, cur_test->param.auth_alg,
9798 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9799 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
9800 : : 0, 0, 0);
9801 [ # # ]: 0 : if (err) {
9802 : : printf("\t%d) %s: Short MAC test failed\n",
9803 : 0 : cur_test->test_idx,
9804 : 0 : cur_test->param.name);
9805 : : err = TEST_FAILED;
9806 : : } else {
9807 : : printf("\t%d) %s: Short MAC test PASS\n",
9808 : 0 : cur_test->test_idx,
9809 : 0 : cur_test->param.name);
9810 : 0 : rte_hexdump(stdout, "MAC I",
9811 : 0 : cur_test->data_out + cur_test->in_len + 2,
9812 : : 2);
9813 : : err = TEST_SUCCESS;
9814 : : }
9815 : 0 : all_err += err;
9816 : : }
9817 : :
9818 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9819 : :
9820 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9821 : :
9822 : : }
9823 : :
9824 : : static int
9825 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
9826 : : {
9827 : : int i = 0, size = 0;
9828 : : int err, all_err = TEST_SUCCESS;
9829 : : const struct pdcp_sdap_test *cur_test;
9830 : :
9831 : : size = RTE_DIM(list_pdcp_sdap_tests);
9832 : :
9833 [ # # ]: 0 : for (i = 0; i < size; i++) {
9834 : : cur_test = &list_pdcp_sdap_tests[i];
9835 : 0 : err = test_pdcp_proto(
9836 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9837 : : RTE_CRYPTO_AUTH_OP_VERIFY,
9838 : 0 : cur_test->data_out,
9839 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9840 : 0 : cur_test->data_in, cur_test->in_len,
9841 : 0 : cur_test->param.cipher_alg,
9842 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
9843 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
9844 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
9845 : 0 : cur_test->param.domain, cur_test->packet_direction,
9846 : 0 : cur_test->sn_size, cur_test->hfn,
9847 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
9848 [ # # ]: 0 : if (err) {
9849 : : printf("\t%d) %s: Decapsulation failed\n",
9850 : 0 : cur_test->test_idx,
9851 : 0 : cur_test->param.name);
9852 : : err = TEST_FAILED;
9853 : : } else {
9854 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9855 : 0 : cur_test->param.name);
9856 : : err = TEST_SUCCESS;
9857 : : }
9858 : 0 : all_err += err;
9859 : : }
9860 : :
9861 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9862 : :
9863 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9864 : : }
9865 : :
9866 : : static inline void
9867 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
9868 : : {
9869 : 0 : }
9870 : :
9871 : : static inline void
9872 : 0 : ext_mbuf_memzone_free(int nb_segs)
9873 : : {
9874 : : int i;
9875 : :
9876 [ # # ]: 0 : for (i = 0; i <= nb_segs; i++) {
9877 : : char mz_name[RTE_MEMZONE_NAMESIZE];
9878 : : const struct rte_memzone *memzone;
9879 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9880 : 0 : memzone = rte_memzone_lookup(mz_name);
9881 [ # # ]: 0 : if (memzone != NULL) {
9882 : 0 : rte_memzone_free(memzone);
9883 : : memzone = NULL;
9884 : : }
9885 : : }
9886 : 0 : }
9887 : :
9888 : : static inline struct rte_mbuf *
9889 : 0 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
9890 : : int nb_segs, const void *input_text)
9891 : : {
9892 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
9893 : : size_t data_off = 0;
9894 : : uint8_t *dst;
9895 : : int i, size;
9896 : : int t_len;
9897 : :
9898 [ # # ]: 0 : if (pkt_len < 1) {
9899 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
9900 : 0 : return NULL;
9901 : : }
9902 : :
9903 [ # # ]: 0 : if (nb_segs < 1) {
9904 : : printf("Number of segments must be 1 or more (is %d)\n",
9905 : : nb_segs);
9906 : 0 : return NULL;
9907 : : }
9908 : :
9909 [ # # ]: 0 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
9910 : : size = pkt_len;
9911 : :
9912 : : /* Create chained mbuf_src with external buffer */
9913 [ # # ]: 0 : for (i = 0; size > 0; i++) {
9914 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
9915 : 0 : uint16_t data_len = RTE_MIN(size, t_len);
9916 : : char mz_name[RTE_MEMZONE_NAMESIZE];
9917 : : const struct rte_memzone *memzone;
9918 : : void *ext_buf_addr = NULL;
9919 : : rte_iova_t buf_iova;
9920 : 0 : bool freed = false;
9921 : : uint16_t buf_len;
9922 : :
9923 : 0 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
9924 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
9925 : :
9926 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9927 : 0 : memzone = rte_memzone_lookup(mz_name);
9928 [ # # # # ]: 0 : if (memzone != NULL && memzone->len != buf_len) {
9929 : 0 : rte_memzone_free(memzone);
9930 : : memzone = NULL;
9931 : : }
9932 [ # # ]: 0 : if (memzone == NULL) {
9933 : 0 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
9934 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
9935 [ # # ]: 0 : if (memzone == NULL) {
9936 : : printf("Can't allocate memory zone %s\n", mz_name);
9937 : 0 : return NULL;
9938 : : }
9939 : : }
9940 : :
9941 : 0 : ext_buf_addr = memzone->addr;
9942 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
9943 : :
9944 : : /* Create buffer to hold rte_mbuf header */
9945 : 0 : m = rte_pktmbuf_alloc(mbuf_pool);
9946 [ # # ]: 0 : if (i == 0)
9947 : : mbuf = m;
9948 : :
9949 [ # # ]: 0 : if (m == NULL) {
9950 : : printf("Cannot create segment for source mbuf");
9951 : 0 : goto fail;
9952 : : }
9953 : :
9954 : : /* Save shared data (like callback function) in external buffer's end */
9955 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
9956 : : ext_mbuf_callback_fn_free, &freed);
9957 : : if (ret_shinfo == NULL) {
9958 : : printf("Shared mem initialization failed!\n");
9959 : 0 : goto fail;
9960 : : }
9961 : :
9962 : 0 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
9963 : :
9964 : : /* Attach external buffer to mbuf */
9965 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
9966 : : ret_shinfo);
9967 [ # # ]: 0 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
9968 : : printf("External buffer is not attached to mbuf\n");
9969 : 0 : goto fail;
9970 : : }
9971 : :
9972 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
9973 [ # # ]: 0 : if (dst == NULL) {
9974 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
9975 : 0 : goto fail;
9976 : : }
9977 : :
9978 [ # # ]: 0 : if (mbuf != m)
9979 : : rte_pktmbuf_chain(mbuf, m);
9980 : :
9981 : 0 : size -= data_len;
9982 : 0 : data_off += data_len;
9983 : : }
9984 : :
9985 : : return mbuf;
9986 : :
9987 : : fail:
9988 : 0 : rte_pktmbuf_free(mbuf);
9989 : 0 : ext_mbuf_memzone_free(nb_segs);
9990 : 0 : return NULL;
9991 : : }
9992 : :
9993 : : static int
9994 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
9995 : : struct crypto_unittest_params *ut_params,
9996 : : struct rte_security_ipsec_xform *ipsec_xform,
9997 : : const struct ipsec_test_data *td,
9998 : : const struct ipsec_test_flags *flags,
9999 : : int pkt_num)
10000 : : {
10001 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10002 : : enum rte_security_ipsec_sa_direction dir;
10003 : : int ret;
10004 : :
10005 : 0 : dir = ipsec_xform->direction;
10006 : :
10007 : : /* Generate crypto op data structure */
10008 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10009 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10010 [ # # ]: 0 : if (!ut_params->op) {
10011 : : printf("Could not allocate crypto op");
10012 : 0 : return TEST_FAILED;
10013 : : }
10014 : :
10015 : : /* Attach session to operation */
10016 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10017 : :
10018 : : /* Set crypto operation mbufs */
10019 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10020 : 0 : ut_params->op->sym->m_dst = NULL;
10021 : :
10022 : : /* Copy IV in crypto operation when IV generation is disabled */
10023 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10024 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10025 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10026 : : uint8_t *,
10027 : : IV_OFFSET);
10028 : : int len;
10029 : :
10030 [ # # ]: 0 : if (td->aead)
10031 : 0 : len = td->xform.aead.aead.iv.length;
10032 [ # # ]: 0 : else if (td->aes_gmac)
10033 : 0 : len = td->xform.chain.auth.auth.iv.length;
10034 : : else
10035 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10036 : :
10037 : 0 : memcpy(iv, td->iv.data, len);
10038 : : }
10039 : :
10040 : : /* Process crypto operation */
10041 : 0 : process_crypto_request(dev_id, ut_params->op);
10042 : :
10043 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10044 : :
10045 : 0 : rte_crypto_op_free(ut_params->op);
10046 : 0 : ut_params->op = NULL;
10047 : :
10048 : 0 : return ret;
10049 : : }
10050 : :
10051 : : static int
10052 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10053 : : struct crypto_unittest_params *ut_params,
10054 : : void *ctx)
10055 : : {
10056 : : uint64_t timeout, userdata;
10057 : : struct rte_ether_hdr *hdr;
10058 : : struct rte_mbuf *m;
10059 : : void **sec_sess;
10060 : : int ret;
10061 : :
10062 : : RTE_SET_USED(ts_params);
10063 : :
10064 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10065 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10066 : :
10067 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10068 : 0 : ut_params->ibuf->port = 0;
10069 : :
10070 : 0 : sec_sess = &ut_params->sec_session;
10071 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10072 : :
10073 [ # # ]: 0 : if (ret != 1)
10074 : : return TEST_FAILED;
10075 : :
10076 : 0 : ut_params->ibuf = NULL;
10077 : :
10078 : : /* Add a timeout for 1 s */
10079 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10080 : :
10081 : : do {
10082 : : /* Get packet from port 0, queue 0 */
10083 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10084 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10085 : :
10086 [ # # ]: 0 : if (ret == 0) {
10087 : : printf("Could not receive packets from ethdev\n");
10088 : 0 : return TEST_FAILED;
10089 : : }
10090 : :
10091 [ # # ]: 0 : if (m == NULL) {
10092 : : printf("Received mbuf is NULL\n");
10093 : 0 : return TEST_FAILED;
10094 : : }
10095 : :
10096 : 0 : ut_params->ibuf = m;
10097 : :
10098 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10099 : : printf("Received packet is not Rx security processed\n");
10100 : 0 : return TEST_FAILED;
10101 : : }
10102 : :
10103 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10104 : : printf("Received packet has failed Rx security processing\n");
10105 : 0 : return TEST_FAILED;
10106 : : }
10107 : :
10108 : : /*
10109 : : * 'ut_params' is set as userdata. Verify that the field is returned
10110 : : * correctly.
10111 : : */
10112 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10113 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10114 : : printf("Userdata retrieved not matching expected\n");
10115 : 0 : return TEST_FAILED;
10116 : : }
10117 : :
10118 : : /* Trim L2 header */
10119 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10120 : :
10121 : : return TEST_SUCCESS;
10122 : : }
10123 : :
10124 : : static int
10125 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10126 : : struct ipsec_test_data res_d[],
10127 : : int nb_td,
10128 : : bool silent,
10129 : : const struct ipsec_test_flags *flags)
10130 : : {
10131 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10132 : : 0x0000, 0x001a};
10133 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10134 : : 0xe82c, 0x4887};
10135 : : const struct rte_ipv4_hdr *ipv4 =
10136 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10137 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10138 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10139 : : struct crypto_unittest_params *ut_params = &unittest_params;
10140 : : struct rte_security_capability_idx sec_cap_idx;
10141 : : const struct rte_security_capability *sec_cap;
10142 : : struct rte_security_ipsec_xform ipsec_xform;
10143 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10144 : : enum rte_security_ipsec_sa_direction dir;
10145 : : struct ipsec_test_data *res_d_tmp = NULL;
10146 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10147 : : int salt_len, i, ret = TEST_SUCCESS;
10148 : : void *ctx;
10149 : : uint32_t src, dst;
10150 : : uint32_t verify;
10151 : :
10152 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10153 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10154 : :
10155 : : /* Use first test data to create session */
10156 : :
10157 : : /* Copy IPsec xform */
10158 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10159 : :
10160 : 0 : dir = ipsec_xform.direction;
10161 : 0 : verify = flags->tunnel_hdr_verify;
10162 : :
10163 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10164 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10165 : :
10166 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10167 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10168 : 0 : src += 1;
10169 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10170 : 0 : dst += 1;
10171 : : }
10172 : :
10173 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10174 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10175 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10176 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10177 : : sizeof(src));
10178 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10179 : : sizeof(dst));
10180 : :
10181 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10182 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10183 : :
10184 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10185 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10186 : :
10187 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10188 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10189 : :
10190 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10191 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10192 : : TEST_IPSEC_DSCP_VAL;
10193 : :
10194 : : } else {
10195 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10196 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10197 : :
10198 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10199 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10200 : : TEST_IPSEC_DSCP_VAL;
10201 : :
10202 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10203 : : sizeof(v6_src));
10204 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10205 : : sizeof(v6_dst));
10206 : : }
10207 : : }
10208 : :
10209 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10210 : :
10211 : 0 : sec_cap_idx.action = ut_params->type;
10212 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10213 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10214 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10215 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10216 : :
10217 [ # # ]: 0 : if (flags->udp_encap)
10218 : 0 : ipsec_xform.options.udp_encap = 1;
10219 : :
10220 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10221 [ # # ]: 0 : if (sec_cap == NULL)
10222 : : return TEST_SKIPPED;
10223 : :
10224 : : /* Copy cipher session parameters */
10225 [ # # ]: 0 : if (td[0].aead) {
10226 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10227 : : sizeof(ut_params->aead_xform));
10228 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10229 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10230 : :
10231 : : /* Verify crypto capabilities */
10232 [ # # ]: 0 : if (test_ipsec_crypto_caps_aead_verify(
10233 : : sec_cap,
10234 : : &ut_params->aead_xform) != 0) {
10235 [ # # ]: 0 : if (!silent)
10236 : 0 : RTE_LOG(INFO, USER1,
10237 : : "Crypto capabilities not supported\n");
10238 : 0 : return TEST_SKIPPED;
10239 : : }
10240 [ # # ]: 0 : } else if (td[0].auth_only) {
10241 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10242 : : sizeof(ut_params->auth_xform));
10243 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10244 : :
10245 [ # # ]: 0 : if (test_ipsec_crypto_caps_auth_verify(
10246 : : sec_cap,
10247 : : &ut_params->auth_xform) != 0) {
10248 [ # # ]: 0 : if (!silent)
10249 : 0 : RTE_LOG(INFO, USER1,
10250 : : "Auth crypto capabilities not supported\n");
10251 : 0 : return TEST_SKIPPED;
10252 : : }
10253 : : } else {
10254 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10255 : : sizeof(ut_params->cipher_xform));
10256 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10257 : : sizeof(ut_params->auth_xform));
10258 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10259 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10260 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10261 : :
10262 : : /* Verify crypto capabilities */
10263 : :
10264 [ # # ]: 0 : if (test_ipsec_crypto_caps_cipher_verify(
10265 : : sec_cap,
10266 : : &ut_params->cipher_xform) != 0) {
10267 [ # # ]: 0 : if (!silent)
10268 : 0 : RTE_LOG(INFO, USER1,
10269 : : "Cipher crypto capabilities not supported\n");
10270 : 0 : return TEST_SKIPPED;
10271 : : }
10272 : :
10273 [ # # ]: 0 : if (test_ipsec_crypto_caps_auth_verify(
10274 : : sec_cap,
10275 : : &ut_params->auth_xform) != 0) {
10276 [ # # ]: 0 : if (!silent)
10277 : 0 : RTE_LOG(INFO, USER1,
10278 : : "Auth crypto capabilities not supported\n");
10279 : 0 : return TEST_SKIPPED;
10280 : : }
10281 : : }
10282 : :
10283 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10284 : : return TEST_SKIPPED;
10285 : :
10286 : 0 : struct rte_security_session_conf sess_conf = {
10287 : 0 : .action_type = ut_params->type,
10288 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10289 : : };
10290 : :
10291 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac) {
10292 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10293 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10294 : : }
10295 : :
10296 [ # # ]: 0 : if (td[0].aead) {
10297 : 0 : sess_conf.ipsec = ipsec_xform;
10298 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10299 [ # # ]: 0 : } else if (td[0].auth_only) {
10300 : 0 : sess_conf.ipsec = ipsec_xform;
10301 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10302 : : } else {
10303 : 0 : sess_conf.ipsec = ipsec_xform;
10304 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10305 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10306 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10307 : : } else {
10308 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10309 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10310 : : }
10311 : : }
10312 : :
10313 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10314 : 0 : sess_conf.userdata = ut_params;
10315 : :
10316 : : /* Create security session */
10317 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10318 : : ts_params->session_mpool);
10319 : :
10320 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10321 : : return TEST_SKIPPED;
10322 : :
10323 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10324 [ # # # # ]: 0 : if (flags->antireplay &&
10325 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10326 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10327 : 0 : ret = rte_security_session_update(ctx,
10328 : : ut_params->sec_session, &sess_conf);
10329 [ # # ]: 0 : if (ret) {
10330 : : printf("Could not update sequence number in "
10331 : : "session\n");
10332 : 0 : return TEST_SKIPPED;
10333 : : }
10334 : : }
10335 : :
10336 : : /* Copy test data before modification */
10337 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10338 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10339 : : ret = TEST_FAILED;
10340 : 0 : goto mbuf_free;
10341 : : }
10342 : :
10343 : : /* Setup source mbuf payload */
10344 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10345 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10346 : 0 : td[i].input_text.len, nb_segs, input_text);
10347 : : } else {
10348 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10349 : 0 : td[i].input_text.len, nb_segs, 0);
10350 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10351 : : }
10352 : :
10353 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10354 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10355 : : ctx);
10356 : : else
10357 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10358 : : ut_params,
10359 : : &ipsec_xform,
10360 : : &td[i], flags,
10361 : : i + 1);
10362 : :
10363 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10364 : 0 : goto mbuf_free;
10365 : :
10366 [ # # ]: 0 : if (res_d != NULL)
10367 : 0 : res_d_tmp = &res_d[i];
10368 : :
10369 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10370 : : res_d_tmp, silent, flags);
10371 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10372 : 0 : goto mbuf_free;
10373 : :
10374 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10375 : : flags, dir);
10376 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10377 : 0 : goto mbuf_free;
10378 : :
10379 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10380 : 0 : ut_params->ibuf = NULL;
10381 : : }
10382 : :
10383 : 0 : mbuf_free:
10384 [ # # ]: 0 : if (flags->use_ext_mbuf)
10385 : 0 : ext_mbuf_memzone_free(nb_segs);
10386 : :
10387 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10388 : 0 : ut_params->ibuf = NULL;
10389 : :
10390 [ # # ]: 0 : if (ut_params->sec_session)
10391 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10392 : 0 : ut_params->sec_session = NULL;
10393 : :
10394 : 0 : return ret;
10395 : : }
10396 : :
10397 : : static int
10398 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10399 : : {
10400 : : struct ipsec_test_data td_outb;
10401 : : struct ipsec_test_flags flags;
10402 : :
10403 : : memset(&flags, 0, sizeof(flags));
10404 : :
10405 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10406 : :
10407 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10408 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10409 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10410 : : /* Disable IV gen to be able to test with known vectors */
10411 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10412 : : }
10413 : :
10414 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10415 : : }
10416 : :
10417 : : static int
10418 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10419 : : {
10420 : : struct ipsec_test_data td_outb;
10421 : : struct ipsec_test_flags flags;
10422 : :
10423 : : memset(&flags, 0, sizeof(flags));
10424 [ # # ]: 0 : flags.use_ext_mbuf = true;
10425 : :
10426 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10427 : :
10428 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10429 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10430 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10431 : : /* Disable IV gen to be able to test with known vectors */
10432 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10433 : : }
10434 : :
10435 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10436 : : }
10437 : :
10438 : : static int
10439 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10440 : : {
10441 : : const struct ipsec_test_data *td = test_data;
10442 : : struct ipsec_test_flags flags;
10443 : : struct ipsec_test_data td_inb;
10444 : :
10445 : : memset(&flags, 0, sizeof(flags));
10446 : :
10447 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10448 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10449 : : else
10450 : : memcpy(&td_inb, td, sizeof(td_inb));
10451 : :
10452 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10453 : : }
10454 : :
10455 : : static int
10456 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10457 : : {
10458 : : struct ipsec_test_data td_outb;
10459 : : struct ipsec_test_flags flags;
10460 : :
10461 : : memset(&flags, 0, sizeof(flags));
10462 : 0 : flags.fragment = true;
10463 : :
10464 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10465 : :
10466 : : /* Disable IV gen to be able to test with known vectors */
10467 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10468 : :
10469 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10470 : : }
10471 : :
10472 : : static int
10473 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10474 : : {
10475 : : const struct ipsec_test_data *td = test_data;
10476 : : struct ipsec_test_flags flags;
10477 : : struct ipsec_test_data td_inb;
10478 : :
10479 : : memset(&flags, 0, sizeof(flags));
10480 : 0 : flags.rx_inject = true;
10481 : :
10482 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10483 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10484 : : else
10485 : : memcpy(&td_inb, td, sizeof(td_inb));
10486 : :
10487 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10488 : : }
10489 : :
10490 : : static int
10491 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10492 : : {
10493 : : struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10494 : : struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10495 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10496 : : int ret;
10497 : :
10498 [ # # ]: 0 : if (flags->iv_gen ||
10499 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10500 : : flags->sa_expiry_pkts_hard)
10501 : : nb_pkts = IPSEC_TEST_PACKETS_MAX;
10502 : :
10503 [ # # ]: 0 : for (i = 0; i < RTE_DIM(alg_list); i++) {
10504 : 0 : test_ipsec_td_prepare(alg_list[i].param1,
10505 : : alg_list[i].param2,
10506 : : flags,
10507 : : td_outb,
10508 : : nb_pkts);
10509 : :
10510 [ # # ]: 0 : if (!td_outb->aead) {
10511 : : enum rte_crypto_cipher_algorithm cipher_alg;
10512 : : enum rte_crypto_auth_algorithm auth_alg;
10513 : :
10514 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10515 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10516 : :
10517 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10518 : 0 : continue;
10519 : :
10520 : : /* ICV is not applicable for NULL auth */
10521 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10522 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10523 : 0 : continue;
10524 : :
10525 : : /* IV is not applicable for NULL cipher */
10526 [ # # # # ]: 0 : if (flags->iv_gen &&
10527 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10528 : 0 : continue;
10529 : : }
10530 : :
10531 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10532 : : flags);
10533 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10534 : 0 : continue;
10535 : :
10536 [ # # ]: 0 : if (ret == TEST_FAILED)
10537 : : return TEST_FAILED;
10538 : :
10539 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10540 : :
10541 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10542 : : flags);
10543 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10544 : 0 : continue;
10545 : :
10546 [ # # ]: 0 : if (ret == TEST_FAILED)
10547 : : return TEST_FAILED;
10548 : :
10549 [ # # ]: 0 : if (flags->display_alg)
10550 : 0 : test_ipsec_display_alg(alg_list[i].param1,
10551 : : alg_list[i].param2);
10552 : :
10553 : 0 : pass_cnt++;
10554 : : }
10555 : :
10556 [ # # ]: 0 : if (pass_cnt > 0)
10557 : : return TEST_SUCCESS;
10558 : : else
10559 : 0 : return TEST_SKIPPED;
10560 : : }
10561 : :
10562 : : static int
10563 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10564 : : {
10565 : : struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10566 : : struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10567 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10568 : : int ret;
10569 : :
10570 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ah_alg_list); i++) {
10571 : 0 : test_ipsec_td_prepare(ah_alg_list[i].param1,
10572 : : ah_alg_list[i].param2,
10573 : : flags,
10574 : : td_outb,
10575 : : nb_pkts);
10576 : :
10577 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10578 : : flags);
10579 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10580 : 0 : continue;
10581 : :
10582 [ # # ]: 0 : if (ret == TEST_FAILED)
10583 : : return TEST_FAILED;
10584 : :
10585 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10586 : :
10587 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10588 : : flags);
10589 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10590 : 0 : continue;
10591 : :
10592 [ # # ]: 0 : if (ret == TEST_FAILED)
10593 : : return TEST_FAILED;
10594 : :
10595 [ # # ]: 0 : if (flags->display_alg)
10596 : 0 : test_ipsec_display_alg(ah_alg_list[i].param1,
10597 : : ah_alg_list[i].param2);
10598 : :
10599 : 0 : pass_cnt++;
10600 : : }
10601 : :
10602 [ # # ]: 0 : if (pass_cnt > 0)
10603 : : return TEST_SUCCESS;
10604 : : else
10605 : 0 : return TEST_SKIPPED;
10606 : : }
10607 : :
10608 : : static int
10609 : 0 : test_ipsec_proto_display_list(void)
10610 : : {
10611 : : struct ipsec_test_flags flags;
10612 : :
10613 : : memset(&flags, 0, sizeof(flags));
10614 : :
10615 : 0 : flags.display_alg = true;
10616 : :
10617 : 0 : return test_ipsec_proto_all(&flags);
10618 : : }
10619 : :
10620 : : static int
10621 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10622 : : {
10623 : : struct ipsec_test_flags flags;
10624 : :
10625 : : memset(&flags, 0, sizeof(flags));
10626 : :
10627 : 0 : flags.ah = true;
10628 : 0 : flags.display_alg = true;
10629 : :
10630 : 0 : return test_ipsec_ah_proto_all(&flags);
10631 : : }
10632 : :
10633 : : static int
10634 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10635 : : {
10636 : : struct ipsec_test_flags flags;
10637 : :
10638 : : memset(&flags, 0, sizeof(flags));
10639 : :
10640 : 0 : flags.ah = true;
10641 : 0 : flags.transport = true;
10642 : :
10643 : 0 : return test_ipsec_ah_proto_all(&flags);
10644 : : }
10645 : :
10646 : : static int
10647 : 0 : test_ipsec_proto_iv_gen(void)
10648 : : {
10649 : : struct ipsec_test_flags flags;
10650 : :
10651 : : memset(&flags, 0, sizeof(flags));
10652 : :
10653 : 0 : flags.iv_gen = true;
10654 : :
10655 : 0 : return test_ipsec_proto_all(&flags);
10656 : : }
10657 : :
10658 : : static int
10659 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10660 : : {
10661 : : struct ipsec_test_flags flags;
10662 : :
10663 : : memset(&flags, 0, sizeof(flags));
10664 : :
10665 : 0 : flags.sa_expiry_pkts_soft = true;
10666 : :
10667 : 0 : return test_ipsec_proto_all(&flags);
10668 : : }
10669 : :
10670 : : static int
10671 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10672 : : {
10673 : : struct ipsec_test_flags flags;
10674 : :
10675 : : memset(&flags, 0, sizeof(flags));
10676 : :
10677 : 0 : flags.sa_expiry_pkts_hard = true;
10678 : :
10679 : 0 : return test_ipsec_proto_all(&flags);
10680 : : }
10681 : :
10682 : : static int
10683 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10684 : : {
10685 : : struct ipsec_test_flags flags;
10686 : :
10687 : : memset(&flags, 0, sizeof(flags));
10688 : :
10689 : 0 : flags.icv_corrupt = true;
10690 : :
10691 : 0 : return test_ipsec_proto_all(&flags);
10692 : : }
10693 : :
10694 : : static int
10695 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10696 : : {
10697 : : struct ipsec_test_flags flags;
10698 : :
10699 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10700 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10701 : : return TEST_SKIPPED;
10702 : :
10703 : : memset(&flags, 0, sizeof(flags));
10704 : :
10705 : 0 : flags.udp_encap = true;
10706 : 0 : flags.udp_encap_custom_ports = true;
10707 : :
10708 : 0 : return test_ipsec_proto_all(&flags);
10709 : : }
10710 : :
10711 : : static int
10712 : 0 : test_ipsec_proto_udp_encap(void)
10713 : : {
10714 : : struct ipsec_test_flags flags;
10715 : :
10716 : : memset(&flags, 0, sizeof(flags));
10717 : :
10718 : 0 : flags.udp_encap = true;
10719 : :
10720 : 0 : return test_ipsec_proto_all(&flags);
10721 : : }
10722 : :
10723 : : static int
10724 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10725 : : {
10726 : : struct ipsec_test_flags flags;
10727 : :
10728 : : memset(&flags, 0, sizeof(flags));
10729 : :
10730 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10731 : :
10732 : 0 : return test_ipsec_proto_all(&flags);
10733 : : }
10734 : :
10735 : : static int
10736 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
10737 : : {
10738 : : struct ipsec_test_flags flags;
10739 : :
10740 : : memset(&flags, 0, sizeof(flags));
10741 : :
10742 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10743 : :
10744 : 0 : return test_ipsec_proto_all(&flags);
10745 : : }
10746 : :
10747 : : static int
10748 : 0 : test_ipsec_proto_udp_ports_verify(void)
10749 : : {
10750 : : struct ipsec_test_flags flags;
10751 : :
10752 : : memset(&flags, 0, sizeof(flags));
10753 : :
10754 : 0 : flags.udp_encap = true;
10755 : 0 : flags.udp_ports_verify = true;
10756 : :
10757 : 0 : return test_ipsec_proto_all(&flags);
10758 : : }
10759 : :
10760 : : static int
10761 : 0 : test_ipsec_proto_inner_ip_csum(void)
10762 : : {
10763 : : struct ipsec_test_flags flags;
10764 : :
10765 : : memset(&flags, 0, sizeof(flags));
10766 : :
10767 : 0 : flags.ip_csum = true;
10768 : :
10769 : 0 : return test_ipsec_proto_all(&flags);
10770 : : }
10771 : :
10772 : : static int
10773 : 0 : test_ipsec_proto_inner_l4_csum(void)
10774 : : {
10775 : : struct ipsec_test_flags flags;
10776 : :
10777 : : memset(&flags, 0, sizeof(flags));
10778 : :
10779 : 0 : flags.l4_csum = true;
10780 : :
10781 : 0 : return test_ipsec_proto_all(&flags);
10782 : : }
10783 : :
10784 : : static int
10785 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
10786 : : {
10787 : : struct ipsec_test_flags flags;
10788 : :
10789 : : memset(&flags, 0, sizeof(flags));
10790 : :
10791 : : flags.ipv6 = false;
10792 : : flags.tunnel_ipv6 = false;
10793 : :
10794 : 0 : return test_ipsec_proto_all(&flags);
10795 : : }
10796 : :
10797 : : static int
10798 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
10799 : : {
10800 : : struct ipsec_test_flags flags;
10801 : :
10802 : : memset(&flags, 0, sizeof(flags));
10803 : :
10804 : 0 : flags.ipv6 = true;
10805 : 0 : flags.tunnel_ipv6 = true;
10806 : :
10807 : 0 : return test_ipsec_proto_all(&flags);
10808 : : }
10809 : :
10810 : : static int
10811 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
10812 : : {
10813 : : struct ipsec_test_flags flags;
10814 : :
10815 : : memset(&flags, 0, sizeof(flags));
10816 : :
10817 : : flags.ipv6 = false;
10818 : 0 : flags.tunnel_ipv6 = true;
10819 : :
10820 : 0 : return test_ipsec_proto_all(&flags);
10821 : : }
10822 : :
10823 : : static int
10824 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
10825 : : {
10826 : : struct ipsec_test_flags flags;
10827 : :
10828 : : memset(&flags, 0, sizeof(flags));
10829 : :
10830 : 0 : flags.ipv6 = true;
10831 : : flags.tunnel_ipv6 = false;
10832 : :
10833 : 0 : return test_ipsec_proto_all(&flags);
10834 : : }
10835 : :
10836 : : static int
10837 : 0 : test_ipsec_proto_transport_v4(void)
10838 : : {
10839 : : struct ipsec_test_flags flags;
10840 : :
10841 : : memset(&flags, 0, sizeof(flags));
10842 : :
10843 : : flags.ipv6 = false;
10844 : 0 : flags.transport = true;
10845 : :
10846 : 0 : return test_ipsec_proto_all(&flags);
10847 : : }
10848 : :
10849 : : static int
10850 : 0 : test_ipsec_proto_transport_l4_csum(void)
10851 : : {
10852 : 0 : struct ipsec_test_flags flags = {
10853 : : .l4_csum = true,
10854 : : .transport = true,
10855 : : };
10856 : :
10857 : 0 : return test_ipsec_proto_all(&flags);
10858 : : }
10859 : :
10860 : : static int
10861 : 0 : test_ipsec_proto_stats(void)
10862 : : {
10863 : : struct ipsec_test_flags flags;
10864 : :
10865 : : memset(&flags, 0, sizeof(flags));
10866 : :
10867 : 0 : flags.stats_success = true;
10868 : :
10869 : 0 : return test_ipsec_proto_all(&flags);
10870 : : }
10871 : :
10872 : : static int
10873 : 0 : test_ipsec_proto_pkt_fragment(void)
10874 : : {
10875 : : struct ipsec_test_flags flags;
10876 : :
10877 : : memset(&flags, 0, sizeof(flags));
10878 : :
10879 : 0 : flags.fragment = true;
10880 : :
10881 : 0 : return test_ipsec_proto_all(&flags);
10882 : :
10883 : : }
10884 : :
10885 : : static int
10886 : 0 : test_ipsec_proto_copy_df_inner_0(void)
10887 : : {
10888 : : struct ipsec_test_flags flags;
10889 : :
10890 : : memset(&flags, 0, sizeof(flags));
10891 : :
10892 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10893 : :
10894 : 0 : return test_ipsec_proto_all(&flags);
10895 : : }
10896 : :
10897 : : static int
10898 : 0 : test_ipsec_proto_copy_df_inner_1(void)
10899 : : {
10900 : : struct ipsec_test_flags flags;
10901 : :
10902 : : memset(&flags, 0, sizeof(flags));
10903 : :
10904 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10905 : :
10906 : 0 : return test_ipsec_proto_all(&flags);
10907 : : }
10908 : :
10909 : : static int
10910 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
10911 : : {
10912 : : struct ipsec_test_flags flags;
10913 : :
10914 : : memset(&flags, 0, sizeof(flags));
10915 : :
10916 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10917 : :
10918 : 0 : return test_ipsec_proto_all(&flags);
10919 : : }
10920 : :
10921 : : static int
10922 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
10923 : : {
10924 : : struct ipsec_test_flags flags;
10925 : :
10926 : : memset(&flags, 0, sizeof(flags));
10927 : :
10928 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10929 : :
10930 : 0 : return test_ipsec_proto_all(&flags);
10931 : : }
10932 : :
10933 : : static int
10934 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10935 : : {
10936 : : struct ipsec_test_flags flags;
10937 : :
10938 : : memset(&flags, 0, sizeof(flags));
10939 : :
10940 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10941 : :
10942 : 0 : return test_ipsec_proto_all(&flags);
10943 : : }
10944 : :
10945 : : static int
10946 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
10947 : : {
10948 : : struct ipsec_test_flags flags;
10949 : :
10950 : : memset(&flags, 0, sizeof(flags));
10951 : :
10952 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10953 : :
10954 : 0 : return test_ipsec_proto_all(&flags);
10955 : : }
10956 : :
10957 : : static int
10958 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
10959 : : {
10960 : : struct ipsec_test_flags flags;
10961 : :
10962 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10963 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10964 : : return TEST_SKIPPED;
10965 : :
10966 : : memset(&flags, 0, sizeof(flags));
10967 : :
10968 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10969 : :
10970 : 0 : return test_ipsec_proto_all(&flags);
10971 : : }
10972 : :
10973 : : static int
10974 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
10975 : : {
10976 : : struct ipsec_test_flags flags;
10977 : :
10978 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10979 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10980 : : return TEST_SKIPPED;
10981 : :
10982 : : memset(&flags, 0, sizeof(flags));
10983 : :
10984 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
10985 : :
10986 : 0 : return test_ipsec_proto_all(&flags);
10987 : : }
10988 : :
10989 : : static int
10990 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
10991 : : {
10992 : : struct ipsec_test_flags flags;
10993 : :
10994 : : memset(&flags, 0, sizeof(flags));
10995 : :
10996 : 0 : flags.ipv6 = true;
10997 : 0 : flags.tunnel_ipv6 = true;
10998 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10999 : :
11000 : 0 : return test_ipsec_proto_all(&flags);
11001 : : }
11002 : :
11003 : : static int
11004 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11005 : : {
11006 : : struct ipsec_test_flags flags;
11007 : :
11008 : : memset(&flags, 0, sizeof(flags));
11009 : :
11010 : 0 : flags.ipv6 = true;
11011 : 0 : flags.tunnel_ipv6 = true;
11012 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11013 : :
11014 : 0 : return test_ipsec_proto_all(&flags);
11015 : : }
11016 : :
11017 : : static int
11018 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11019 : : {
11020 : : struct ipsec_test_flags flags;
11021 : :
11022 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11023 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11024 : : return TEST_SKIPPED;
11025 : :
11026 : : memset(&flags, 0, sizeof(flags));
11027 : :
11028 : 0 : flags.ipv6 = true;
11029 : 0 : flags.tunnel_ipv6 = true;
11030 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11031 : :
11032 : 0 : return test_ipsec_proto_all(&flags);
11033 : : }
11034 : :
11035 : : static int
11036 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11037 : : {
11038 : : struct ipsec_test_flags flags;
11039 : :
11040 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11041 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11042 : : return TEST_SKIPPED;
11043 : :
11044 : : memset(&flags, 0, sizeof(flags));
11045 : :
11046 : 0 : flags.ipv6 = true;
11047 : 0 : flags.tunnel_ipv6 = true;
11048 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11049 : :
11050 : 0 : return test_ipsec_proto_all(&flags);
11051 : : }
11052 : :
11053 : : static int
11054 : 0 : test_ipsec_proto_sgl(void)
11055 : : {
11056 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11057 : : struct rte_cryptodev_info dev_info;
11058 : :
11059 : 0 : struct ipsec_test_flags flags = {
11060 : : .nb_segs_in_mbuf = 5
11061 : : };
11062 : :
11063 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11064 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11065 : : printf("Device doesn't support in-place scatter-gather. "
11066 : : "Test Skipped.\n");
11067 : 0 : return TEST_SKIPPED;
11068 : : }
11069 : :
11070 : 0 : return test_ipsec_proto_all(&flags);
11071 : : }
11072 : :
11073 : : static int
11074 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11075 : : {
11076 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11077 : : struct rte_cryptodev_info dev_info;
11078 : :
11079 : 0 : struct ipsec_test_flags flags = {
11080 : : .nb_segs_in_mbuf = 5,
11081 : : .use_ext_mbuf = 1
11082 : : };
11083 : :
11084 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11085 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11086 : : printf("Device doesn't support in-place scatter-gather. "
11087 : : "Test Skipped.\n");
11088 : 0 : return TEST_SKIPPED;
11089 : : }
11090 : :
11091 : 0 : return test_ipsec_proto_all(&flags);
11092 : : }
11093 : :
11094 : : static int
11095 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11096 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11097 : : uint64_t winsz)
11098 : : {
11099 : : struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
11100 : : struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
11101 : : struct ipsec_test_flags flags;
11102 : : uint32_t i = 0, ret = 0;
11103 : :
11104 [ # # ]: 0 : if (nb_pkts == 0)
11105 : : return TEST_FAILED;
11106 : :
11107 : : memset(&flags, 0, sizeof(flags));
11108 : 0 : flags.antireplay = true;
11109 : :
11110 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11111 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11112 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11113 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11114 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11115 : : }
11116 : :
11117 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11118 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11119 : :
11120 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11121 : : &flags);
11122 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11123 : : return ret;
11124 : :
11125 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11126 : :
11127 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11128 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11129 : : /* Set antireplay flag for packets to be dropped */
11130 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11131 : : }
11132 : :
11133 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11134 : : &flags);
11135 : :
11136 : 0 : return ret;
11137 : : }
11138 : :
11139 : : static int
11140 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11141 : : {
11142 : :
11143 : : uint32_t nb_pkts = 5;
11144 : : bool replayed_pkt[5];
11145 : : uint64_t esn[5];
11146 : :
11147 : : /* 1. Advance the TOP of the window to WS * 2 */
11148 : 0 : esn[0] = winsz * 2;
11149 : : /* 2. Test sequence number within the new window(WS + 1) */
11150 : 0 : esn[1] = winsz + 1;
11151 : : /* 3. Test sequence number less than the window BOTTOM */
11152 : 0 : esn[2] = winsz;
11153 : : /* 4. Test sequence number in the middle of the window */
11154 : 0 : esn[3] = winsz + (winsz / 2);
11155 : : /* 5. Test replay of the packet in the middle of the window */
11156 : 0 : esn[4] = winsz + (winsz / 2);
11157 : :
11158 : 0 : replayed_pkt[0] = false;
11159 : 0 : replayed_pkt[1] = false;
11160 : 0 : replayed_pkt[2] = true;
11161 : 0 : replayed_pkt[3] = false;
11162 : 0 : replayed_pkt[4] = true;
11163 : :
11164 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11165 : : false, winsz);
11166 : : }
11167 : :
11168 : : static int
11169 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11170 : : {
11171 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11172 : : }
11173 : :
11174 : : static int
11175 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11176 : : {
11177 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11178 : : }
11179 : :
11180 : : static int
11181 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11182 : : {
11183 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11184 : : }
11185 : :
11186 : : static int
11187 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11188 : : {
11189 : :
11190 : : uint32_t nb_pkts = 7;
11191 : : bool replayed_pkt[7];
11192 : : uint64_t esn[7];
11193 : :
11194 : : /* Set the initial sequence number */
11195 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11196 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11197 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11198 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11199 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11200 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11201 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11202 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11203 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11204 : : /* 5. Test with duplicate sequence number within
11205 : : * new window (1<<32 - 1)
11206 : : */
11207 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11208 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11209 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11210 : :
11211 : 0 : replayed_pkt[0] = false;
11212 : 0 : replayed_pkt[1] = false;
11213 : 0 : replayed_pkt[2] = false;
11214 : 0 : replayed_pkt[3] = false;
11215 : 0 : replayed_pkt[4] = false;
11216 : 0 : replayed_pkt[5] = true;
11217 : 0 : replayed_pkt[6] = true;
11218 : :
11219 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11220 : : true, winsz);
11221 : : }
11222 : :
11223 : : static int
11224 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11225 : : {
11226 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11227 : : }
11228 : :
11229 : : static int
11230 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11231 : : {
11232 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11233 : : }
11234 : :
11235 : : static int
11236 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11237 : : {
11238 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11239 : : }
11240 : :
11241 : : static int
11242 : 0 : test_PDCP_PROTO_all(void)
11243 : : {
11244 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11245 : : struct crypto_unittest_params *ut_params = &unittest_params;
11246 : : struct rte_cryptodev_info dev_info;
11247 : : int status;
11248 : :
11249 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11250 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11251 : :
11252 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11253 : : return TEST_SKIPPED;
11254 : :
11255 : : /* Set action type */
11256 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11257 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11258 : : gbl_action_type;
11259 : :
11260 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11261 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11262 : : return TEST_SKIPPED;
11263 : :
11264 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11265 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11266 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11267 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11268 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11269 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11270 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11271 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11272 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11273 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11274 : 0 : status += test_PDCP_PROTO_short_mac();
11275 : :
11276 [ # # ]: 0 : if (status)
11277 : : return TEST_FAILED;
11278 : : else
11279 : 0 : return TEST_SUCCESS;
11280 : : }
11281 : :
11282 : : static int
11283 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11284 : : {
11285 : 0 : struct ipsec_test_flags flags = {
11286 : : .dec_ttl_or_hop_limit = true
11287 : : };
11288 : :
11289 : 0 : return test_ipsec_proto_all(&flags);
11290 : : }
11291 : :
11292 : : static int
11293 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11294 : : {
11295 : 0 : struct ipsec_test_flags flags = {
11296 : : .ipv6 = true,
11297 : : .dec_ttl_or_hop_limit = true
11298 : : };
11299 : :
11300 : 0 : return test_ipsec_proto_all(&flags);
11301 : : }
11302 : :
11303 : : static int
11304 : 0 : test_docsis_proto_uplink(const void *data)
11305 : : {
11306 : : const struct docsis_test_data *d_td = data;
11307 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11308 : : struct crypto_unittest_params *ut_params = &unittest_params;
11309 : : uint8_t *plaintext = NULL;
11310 : : uint8_t *ciphertext = NULL;
11311 : : uint8_t *iv_ptr;
11312 : : int32_t cipher_len, crc_len;
11313 : : uint32_t crc_data_len;
11314 : : int ret = TEST_SUCCESS;
11315 : :
11316 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11317 : :
11318 : : /* Verify the capabilities */
11319 : : struct rte_security_capability_idx sec_cap_idx;
11320 : : const struct rte_security_capability *sec_cap;
11321 : : const struct rte_cryptodev_capabilities *crypto_cap;
11322 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11323 : : int j = 0;
11324 : :
11325 : : /* Set action type */
11326 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11327 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11328 : : gbl_action_type;
11329 : :
11330 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11331 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11332 : : return TEST_SKIPPED;
11333 : :
11334 : 0 : sec_cap_idx.action = ut_params->type;
11335 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11336 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11337 : :
11338 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11339 [ # # ]: 0 : if (sec_cap == NULL)
11340 : : return TEST_SKIPPED;
11341 : :
11342 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11343 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11344 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11345 : : crypto_cap->sym.xform_type ==
11346 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11347 : : crypto_cap->sym.cipher.algo ==
11348 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11349 : 0 : sym_cap = &crypto_cap->sym;
11350 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11351 : 0 : d_td->key.len,
11352 : 0 : d_td->iv.len) == 0)
11353 : : break;
11354 : : }
11355 : : }
11356 : :
11357 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11358 : : return TEST_SKIPPED;
11359 : :
11360 : : /* Setup source mbuf payload */
11361 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11362 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11363 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11364 : :
11365 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11366 : 0 : d_td->ciphertext.len);
11367 : :
11368 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11369 : :
11370 : : /* Setup cipher session parameters */
11371 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11372 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11373 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11374 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11375 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11376 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11377 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11378 : 0 : ut_params->cipher_xform.next = NULL;
11379 : :
11380 : : /* Setup DOCSIS session parameters */
11381 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11382 : :
11383 : 0 : struct rte_security_session_conf sess_conf = {
11384 : 0 : .action_type = ut_params->type,
11385 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11386 : : .docsis = ut_params->docsis_xform,
11387 : : .crypto_xform = &ut_params->cipher_xform,
11388 : : };
11389 : :
11390 : : /* Create security session */
11391 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11392 : : ts_params->session_mpool);
11393 : :
11394 [ # # ]: 0 : if (!ut_params->sec_session) {
11395 : : printf("Test function %s line %u: failed to allocate session\n",
11396 : : __func__, __LINE__);
11397 : : ret = TEST_FAILED;
11398 : 0 : goto on_err;
11399 : : }
11400 : :
11401 : : /* Generate crypto op data structure */
11402 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11403 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11404 [ # # ]: 0 : if (!ut_params->op) {
11405 : : printf("Test function %s line %u: failed to allocate symmetric "
11406 : : "crypto operation\n", __func__, __LINE__);
11407 : : ret = TEST_FAILED;
11408 : 0 : goto on_err;
11409 : : }
11410 : :
11411 : : /* Setup CRC operation parameters */
11412 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11413 : 0 : (d_td->ciphertext.len -
11414 : 0 : d_td->ciphertext.crc_offset -
11415 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11416 : : 0;
11417 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11418 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11419 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11420 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11421 : :
11422 : : /* Setup cipher operation parameters */
11423 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11424 : 0 : (d_td->ciphertext.len -
11425 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11426 : : 0;
11427 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11428 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11429 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11430 : :
11431 : : /* Setup cipher IV */
11432 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11433 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11434 : :
11435 : : /* Attach session to operation */
11436 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11437 : :
11438 : : /* Set crypto operation mbufs */
11439 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11440 : 0 : ut_params->op->sym->m_dst = NULL;
11441 : :
11442 : : /* Process crypto operation */
11443 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11444 : : NULL) {
11445 : : printf("Test function %s line %u: failed to process security "
11446 : : "crypto op\n", __func__, __LINE__);
11447 : : ret = TEST_FAILED;
11448 : 0 : goto on_err;
11449 : : }
11450 : :
11451 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11452 : : printf("Test function %s line %u: failed to process crypto op\n",
11453 : : __func__, __LINE__);
11454 : : ret = TEST_FAILED;
11455 : 0 : goto on_err;
11456 : : }
11457 : :
11458 : : /* Validate plaintext */
11459 : : plaintext = ciphertext;
11460 : :
11461 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11462 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11463 : : printf("Test function %s line %u: plaintext not as expected\n",
11464 : : __func__, __LINE__);
11465 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11466 : 0 : d_td->plaintext.len);
11467 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11468 : : ret = TEST_FAILED;
11469 : 0 : goto on_err;
11470 : : }
11471 : :
11472 : 0 : on_err:
11473 : 0 : rte_crypto_op_free(ut_params->op);
11474 : 0 : ut_params->op = NULL;
11475 : :
11476 [ # # ]: 0 : if (ut_params->sec_session)
11477 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11478 : 0 : ut_params->sec_session = NULL;
11479 : :
11480 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11481 : 0 : ut_params->ibuf = NULL;
11482 : :
11483 : 0 : return ret;
11484 : : }
11485 : :
11486 : : static int
11487 : 0 : test_docsis_proto_downlink(const void *data)
11488 : : {
11489 : : const struct docsis_test_data *d_td = data;
11490 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11491 : : struct crypto_unittest_params *ut_params = &unittest_params;
11492 : : uint8_t *plaintext = NULL;
11493 : : uint8_t *ciphertext = NULL;
11494 : : uint8_t *iv_ptr;
11495 : : int32_t cipher_len, crc_len;
11496 : : int ret = TEST_SUCCESS;
11497 : :
11498 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11499 : :
11500 : : /* Verify the capabilities */
11501 : : struct rte_security_capability_idx sec_cap_idx;
11502 : : const struct rte_security_capability *sec_cap;
11503 : : const struct rte_cryptodev_capabilities *crypto_cap;
11504 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11505 : : int j = 0;
11506 : :
11507 : : /* Set action type */
11508 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11509 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11510 : : gbl_action_type;
11511 : :
11512 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11513 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11514 : : return TEST_SKIPPED;
11515 : :
11516 : 0 : sec_cap_idx.action = ut_params->type;
11517 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11518 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11519 : :
11520 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11521 [ # # ]: 0 : if (sec_cap == NULL)
11522 : : return TEST_SKIPPED;
11523 : :
11524 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11525 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11526 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11527 : : crypto_cap->sym.xform_type ==
11528 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11529 : : crypto_cap->sym.cipher.algo ==
11530 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11531 : 0 : sym_cap = &crypto_cap->sym;
11532 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11533 : 0 : d_td->key.len,
11534 : 0 : d_td->iv.len) == 0)
11535 : : break;
11536 : : }
11537 : : }
11538 : :
11539 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11540 : : return TEST_SKIPPED;
11541 : :
11542 : : /* Setup source mbuf payload */
11543 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11544 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11545 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11546 : :
11547 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11548 : 0 : d_td->plaintext.len);
11549 : :
11550 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11551 : :
11552 : : /* Setup cipher session parameters */
11553 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11554 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11555 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11556 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11557 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11558 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11559 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11560 : 0 : ut_params->cipher_xform.next = NULL;
11561 : :
11562 : : /* Setup DOCSIS session parameters */
11563 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11564 : :
11565 : 0 : struct rte_security_session_conf sess_conf = {
11566 : 0 : .action_type = ut_params->type,
11567 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11568 : : .docsis = ut_params->docsis_xform,
11569 : : .crypto_xform = &ut_params->cipher_xform,
11570 : : };
11571 : :
11572 : : /* Create security session */
11573 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11574 : : ts_params->session_mpool);
11575 : :
11576 [ # # ]: 0 : if (!ut_params->sec_session) {
11577 : : printf("Test function %s line %u: failed to allocate session\n",
11578 : : __func__, __LINE__);
11579 : : ret = TEST_FAILED;
11580 : 0 : goto on_err;
11581 : : }
11582 : :
11583 : : /* Generate crypto op data structure */
11584 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11585 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11586 [ # # ]: 0 : if (!ut_params->op) {
11587 : : printf("Test function %s line %u: failed to allocate symmetric "
11588 : : "crypto operation\n", __func__, __LINE__);
11589 : : ret = TEST_FAILED;
11590 : 0 : goto on_err;
11591 : : }
11592 : :
11593 : : /* Setup CRC operation parameters */
11594 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11595 : 0 : (d_td->plaintext.len -
11596 : 0 : d_td->plaintext.crc_offset -
11597 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11598 : : 0;
11599 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11600 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11601 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11602 : :
11603 : : /* Setup cipher operation parameters */
11604 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11605 : 0 : (d_td->plaintext.len -
11606 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11607 : : 0;
11608 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11609 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11610 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11611 : :
11612 : : /* Setup cipher IV */
11613 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11614 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11615 : :
11616 : : /* Attach session to operation */
11617 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11618 : :
11619 : : /* Set crypto operation mbufs */
11620 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11621 : 0 : ut_params->op->sym->m_dst = NULL;
11622 : :
11623 : : /* Process crypto operation */
11624 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11625 : : NULL) {
11626 : : printf("Test function %s line %u: failed to process crypto op\n",
11627 : : __func__, __LINE__);
11628 : : ret = TEST_FAILED;
11629 : 0 : goto on_err;
11630 : : }
11631 : :
11632 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11633 : : printf("Test function %s line %u: crypto op processing failed\n",
11634 : : __func__, __LINE__);
11635 : : ret = TEST_FAILED;
11636 : 0 : goto on_err;
11637 : : }
11638 : :
11639 : : /* Validate ciphertext */
11640 : : ciphertext = plaintext;
11641 : :
11642 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11643 : : printf("Test function %s line %u: plaintext not as expected\n",
11644 : : __func__, __LINE__);
11645 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11646 : 0 : d_td->ciphertext.len);
11647 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11648 : : ret = TEST_FAILED;
11649 : 0 : goto on_err;
11650 : : }
11651 : :
11652 : 0 : on_err:
11653 : 0 : rte_crypto_op_free(ut_params->op);
11654 : 0 : ut_params->op = NULL;
11655 : :
11656 [ # # ]: 0 : if (ut_params->sec_session)
11657 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11658 : 0 : ut_params->sec_session = NULL;
11659 : :
11660 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11661 : 0 : ut_params->ibuf = NULL;
11662 : :
11663 : 0 : return ret;
11664 : : }
11665 : : #endif
11666 : :
11667 : : static int
11668 : 0 : test_AES_GCM_authenticated_encryption_test_case_1(void)
11669 : : {
11670 : 0 : return test_authenticated_encryption(&gcm_test_case_1);
11671 : : }
11672 : :
11673 : : static int
11674 : 0 : test_AES_GCM_authenticated_encryption_test_case_2(void)
11675 : : {
11676 : 0 : return test_authenticated_encryption(&gcm_test_case_2);
11677 : : }
11678 : :
11679 : : static int
11680 : 0 : test_AES_GCM_authenticated_encryption_test_case_3(void)
11681 : : {
11682 : 0 : return test_authenticated_encryption(&gcm_test_case_3);
11683 : : }
11684 : :
11685 : : static int
11686 : 0 : test_AES_GCM_authenticated_encryption_test_case_4(void)
11687 : : {
11688 : 0 : return test_authenticated_encryption(&gcm_test_case_4);
11689 : : }
11690 : :
11691 : : static int
11692 : 0 : test_AES_GCM_authenticated_encryption_test_case_5(void)
11693 : : {
11694 : 0 : return test_authenticated_encryption(&gcm_test_case_5);
11695 : : }
11696 : :
11697 : : static int
11698 : 0 : test_AES_GCM_authenticated_encryption_test_case_6(void)
11699 : : {
11700 : 0 : return test_authenticated_encryption(&gcm_test_case_6);
11701 : : }
11702 : :
11703 : : static int
11704 : 0 : test_AES_GCM_authenticated_encryption_test_case_7(void)
11705 : : {
11706 : 0 : return test_authenticated_encryption(&gcm_test_case_7);
11707 : : }
11708 : :
11709 : : static int
11710 : 0 : test_AES_GCM_authenticated_encryption_test_case_8(void)
11711 : : {
11712 : 0 : return test_authenticated_encryption(&gcm_test_case_8);
11713 : : }
11714 : :
11715 : : static int
11716 : 0 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
11717 : : {
11718 : 0 : return test_authenticated_encryption(&gcm_J0_test_case_1);
11719 : : }
11720 : :
11721 : : static int
11722 : 0 : test_AES_GCM_auth_encryption_test_case_192_1(void)
11723 : : {
11724 : 0 : return test_authenticated_encryption(&gcm_test_case_192_1);
11725 : : }
11726 : :
11727 : : static int
11728 : 0 : test_AES_GCM_auth_encryption_test_case_192_2(void)
11729 : : {
11730 : 0 : return test_authenticated_encryption(&gcm_test_case_192_2);
11731 : : }
11732 : :
11733 : : static int
11734 : 0 : test_AES_GCM_auth_encryption_test_case_192_3(void)
11735 : : {
11736 : 0 : return test_authenticated_encryption(&gcm_test_case_192_3);
11737 : : }
11738 : :
11739 : : static int
11740 : 0 : test_AES_GCM_auth_encryption_test_case_192_4(void)
11741 : : {
11742 : 0 : return test_authenticated_encryption(&gcm_test_case_192_4);
11743 : : }
11744 : :
11745 : : static int
11746 : 0 : test_AES_GCM_auth_encryption_test_case_192_5(void)
11747 : : {
11748 : 0 : return test_authenticated_encryption(&gcm_test_case_192_5);
11749 : : }
11750 : :
11751 : : static int
11752 : 0 : test_AES_GCM_auth_encryption_test_case_192_6(void)
11753 : : {
11754 : 0 : return test_authenticated_encryption(&gcm_test_case_192_6);
11755 : : }
11756 : :
11757 : : static int
11758 : 0 : test_AES_GCM_auth_encryption_test_case_192_7(void)
11759 : : {
11760 : 0 : return test_authenticated_encryption(&gcm_test_case_192_7);
11761 : : }
11762 : :
11763 : : static int
11764 : 0 : test_AES_GCM_auth_encryption_test_case_256_1(void)
11765 : : {
11766 : 0 : return test_authenticated_encryption(&gcm_test_case_256_1);
11767 : : }
11768 : :
11769 : : static int
11770 : 0 : test_AES_GCM_auth_encryption_test_case_256_2(void)
11771 : : {
11772 : 0 : return test_authenticated_encryption(&gcm_test_case_256_2);
11773 : : }
11774 : :
11775 : : static int
11776 : 0 : test_AES_GCM_auth_encryption_test_case_256_3(void)
11777 : : {
11778 : 0 : return test_authenticated_encryption(&gcm_test_case_256_3);
11779 : : }
11780 : :
11781 : : static int
11782 : 0 : test_AES_GCM_auth_encryption_test_case_256_4(void)
11783 : : {
11784 : 0 : return test_authenticated_encryption(&gcm_test_case_256_4);
11785 : : }
11786 : :
11787 : : static int
11788 : 0 : test_AES_GCM_auth_encryption_test_case_256_5(void)
11789 : : {
11790 : 0 : return test_authenticated_encryption(&gcm_test_case_256_5);
11791 : : }
11792 : :
11793 : : static int
11794 : 0 : test_AES_GCM_auth_encryption_test_case_256_6(void)
11795 : : {
11796 : 0 : return test_authenticated_encryption(&gcm_test_case_256_6);
11797 : : }
11798 : :
11799 : : static int
11800 : 0 : test_AES_GCM_auth_encryption_test_case_256_7(void)
11801 : : {
11802 : 0 : return test_authenticated_encryption(&gcm_test_case_256_7);
11803 : : }
11804 : :
11805 : : static int
11806 : 0 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
11807 : : {
11808 : 0 : return test_authenticated_encryption(&gcm_test_case_aad_1);
11809 : : }
11810 : :
11811 : : static int
11812 : 0 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
11813 : : {
11814 : 0 : return test_authenticated_encryption(&gcm_test_case_aad_2);
11815 : : }
11816 : :
11817 : : static int
11818 : 0 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
11819 : : {
11820 : : struct aead_test_data tdata;
11821 : : int res;
11822 : :
11823 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11824 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11825 : 0 : tdata.iv.data[0] += 1;
11826 : 0 : res = test_authenticated_encryption(&tdata);
11827 [ # # ]: 0 : if (res == TEST_SKIPPED)
11828 : : return res;
11829 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11830 : : return TEST_SUCCESS;
11831 : : }
11832 : :
11833 : : static int
11834 : 0 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
11835 : : {
11836 : : struct aead_test_data tdata;
11837 : : int res;
11838 : :
11839 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11840 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11841 : 0 : tdata.plaintext.data[0] += 1;
11842 : 0 : res = test_authenticated_encryption(&tdata);
11843 [ # # ]: 0 : if (res == TEST_SKIPPED)
11844 : : return res;
11845 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11846 : : return TEST_SUCCESS;
11847 : : }
11848 : :
11849 : : static int
11850 : 0 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
11851 : : {
11852 : : struct aead_test_data tdata;
11853 : : int res;
11854 : :
11855 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11856 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11857 : 0 : tdata.ciphertext.data[0] += 1;
11858 : 0 : res = test_authenticated_encryption(&tdata);
11859 [ # # ]: 0 : if (res == TEST_SKIPPED)
11860 : : return res;
11861 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11862 : : return TEST_SUCCESS;
11863 : : }
11864 : :
11865 : : static int
11866 : 0 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
11867 : : {
11868 : : struct aead_test_data tdata;
11869 : : int res;
11870 : :
11871 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11872 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11873 : 0 : tdata.aad.len += 1;
11874 : 0 : res = test_authenticated_encryption(&tdata);
11875 [ # # ]: 0 : if (res == TEST_SKIPPED)
11876 : : return res;
11877 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11878 : : return TEST_SUCCESS;
11879 : : }
11880 : :
11881 : : static int
11882 : 0 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
11883 : 0 : {
11884 : : struct aead_test_data tdata;
11885 : : uint8_t aad[gcm_test_case_7.aad.len];
11886 : : int res;
11887 : :
11888 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11889 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11890 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
11891 : 0 : aad[0] += 1;
11892 : 0 : tdata.aad.data = aad;
11893 : 0 : res = test_authenticated_encryption(&tdata);
11894 [ # # ]: 0 : if (res == TEST_SKIPPED)
11895 : : return res;
11896 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11897 : : return TEST_SUCCESS;
11898 : : }
11899 : :
11900 : : static int
11901 : 0 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
11902 : : {
11903 : : struct aead_test_data tdata;
11904 : : int res;
11905 : :
11906 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11907 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11908 : 0 : tdata.auth_tag.data[0] += 1;
11909 : 0 : res = test_authenticated_encryption(&tdata);
11910 [ # # ]: 0 : if (res == TEST_SKIPPED)
11911 : : return res;
11912 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11913 : : return TEST_SUCCESS;
11914 : : }
11915 : :
11916 : : static int
11917 : 0 : test_authenticated_decryption(const struct aead_test_data *tdata)
11918 : : {
11919 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11920 : : struct crypto_unittest_params *ut_params = &unittest_params;
11921 : :
11922 : : int retval;
11923 : : uint8_t *plaintext;
11924 : : uint32_t i;
11925 : : struct rte_cryptodev_info dev_info;
11926 : :
11927 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11928 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11929 : :
11930 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11931 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11932 : : printf("Device doesn't support RAW data-path APIs.\n");
11933 : 0 : return TEST_SKIPPED;
11934 : : }
11935 : :
11936 : : /* Verify the capabilities */
11937 : : struct rte_cryptodev_sym_capability_idx cap_idx;
11938 : : const struct rte_cryptodev_symmetric_capability *capability;
11939 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11940 : 0 : cap_idx.algo.aead = tdata->algo;
11941 : 0 : capability = rte_cryptodev_sym_capability_get(
11942 : 0 : ts_params->valid_devs[0], &cap_idx);
11943 [ # # ]: 0 : if (capability == NULL)
11944 : : return TEST_SKIPPED;
11945 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_aead(
11946 : 0 : capability, tdata->key.len, tdata->auth_tag.len,
11947 : 0 : tdata->aad.len, tdata->iv.len))
11948 : : return TEST_SKIPPED;
11949 : :
11950 : : /* Create AEAD session */
11951 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
11952 : 0 : tdata->algo,
11953 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
11954 : 0 : tdata->key.data, tdata->key.len,
11955 : 0 : tdata->aad.len, tdata->auth_tag.len,
11956 : 0 : tdata->iv.len);
11957 [ # # ]: 0 : if (retval != TEST_SUCCESS)
11958 : : return retval;
11959 : :
11960 : : /* alloc mbuf and set payload */
11961 [ # # ]: 0 : if (tdata->aad.len > MBUF_SIZE) {
11962 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11963 : : /* Populate full size of add data */
11964 [ # # ]: 0 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
11965 : 0 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
11966 : : } else
11967 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11968 : :
11969 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11970 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
11971 : :
11972 : : /* Create AEAD operation */
11973 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11974 [ # # ]: 0 : if (retval < 0)
11975 : : return retval;
11976 : :
11977 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11978 : :
11979 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11980 : :
11981 : : /* Process crypto operation */
11982 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11983 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11984 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
11985 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
11986 : : 0);
11987 [ # # ]: 0 : if (retval != TEST_SUCCESS)
11988 : : return retval;
11989 : : } else
11990 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
11991 : : process_crypto_request(ts_params->valid_devs[0],
11992 : : ut_params->op), "failed to process sym crypto op");
11993 : :
11994 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11995 : : "crypto op processing failed");
11996 : :
11997 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
11998 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
11999 : : uint8_t *);
12000 : : else
12001 : 0 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12002 : : uint8_t *,
12003 : : ut_params->op->sym->cipher.data.offset);
12004 : :
12005 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12006 : :
12007 : : /* Validate obuf */
12008 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12009 : : plaintext,
12010 : : tdata->plaintext.data,
12011 : : tdata->plaintext.len,
12012 : : "Plaintext data not as expected");
12013 : :
12014 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
12015 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12016 : : "Authentication failed");
12017 : :
12018 : : return 0;
12019 : : }
12020 : :
12021 : : static int
12022 : 0 : test_AES_GCM_authenticated_decryption_test_case_1(void)
12023 : : {
12024 : 0 : return test_authenticated_decryption(&gcm_test_case_1);
12025 : : }
12026 : :
12027 : : static int
12028 : 0 : test_AES_GCM_authenticated_decryption_test_case_2(void)
12029 : : {
12030 : 0 : return test_authenticated_decryption(&gcm_test_case_2);
12031 : : }
12032 : :
12033 : : static int
12034 : 0 : test_AES_GCM_authenticated_decryption_test_case_3(void)
12035 : : {
12036 : 0 : return test_authenticated_decryption(&gcm_test_case_3);
12037 : : }
12038 : :
12039 : : static int
12040 : 0 : test_AES_GCM_authenticated_decryption_test_case_4(void)
12041 : : {
12042 : 0 : return test_authenticated_decryption(&gcm_test_case_4);
12043 : : }
12044 : :
12045 : : static int
12046 : 0 : test_AES_GCM_authenticated_decryption_test_case_5(void)
12047 : : {
12048 : 0 : return test_authenticated_decryption(&gcm_test_case_5);
12049 : : }
12050 : :
12051 : : static int
12052 : 0 : test_AES_GCM_authenticated_decryption_test_case_6(void)
12053 : : {
12054 : 0 : return test_authenticated_decryption(&gcm_test_case_6);
12055 : : }
12056 : :
12057 : : static int
12058 : 0 : test_AES_GCM_authenticated_decryption_test_case_7(void)
12059 : : {
12060 : 0 : return test_authenticated_decryption(&gcm_test_case_7);
12061 : : }
12062 : :
12063 : : static int
12064 : 0 : test_AES_GCM_authenticated_decryption_test_case_8(void)
12065 : : {
12066 : 0 : return test_authenticated_decryption(&gcm_test_case_8);
12067 : : }
12068 : :
12069 : : static int
12070 : 0 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
12071 : : {
12072 : 0 : return test_authenticated_decryption(&gcm_J0_test_case_1);
12073 : : }
12074 : :
12075 : : static int
12076 : 0 : test_AES_GCM_auth_decryption_test_case_192_1(void)
12077 : : {
12078 : 0 : return test_authenticated_decryption(&gcm_test_case_192_1);
12079 : : }
12080 : :
12081 : : static int
12082 : 0 : test_AES_GCM_auth_decryption_test_case_192_2(void)
12083 : : {
12084 : 0 : return test_authenticated_decryption(&gcm_test_case_192_2);
12085 : : }
12086 : :
12087 : : static int
12088 : 0 : test_AES_GCM_auth_decryption_test_case_192_3(void)
12089 : : {
12090 : 0 : return test_authenticated_decryption(&gcm_test_case_192_3);
12091 : : }
12092 : :
12093 : : static int
12094 : 0 : test_AES_GCM_auth_decryption_test_case_192_4(void)
12095 : : {
12096 : 0 : return test_authenticated_decryption(&gcm_test_case_192_4);
12097 : : }
12098 : :
12099 : : static int
12100 : 0 : test_AES_GCM_auth_decryption_test_case_192_5(void)
12101 : : {
12102 : 0 : return test_authenticated_decryption(&gcm_test_case_192_5);
12103 : : }
12104 : :
12105 : : static int
12106 : 0 : test_AES_GCM_auth_decryption_test_case_192_6(void)
12107 : : {
12108 : 0 : return test_authenticated_decryption(&gcm_test_case_192_6);
12109 : : }
12110 : :
12111 : : static int
12112 : 0 : test_AES_GCM_auth_decryption_test_case_192_7(void)
12113 : : {
12114 : 0 : return test_authenticated_decryption(&gcm_test_case_192_7);
12115 : : }
12116 : :
12117 : : static int
12118 : 0 : test_AES_GCM_auth_decryption_test_case_256_1(void)
12119 : : {
12120 : 0 : return test_authenticated_decryption(&gcm_test_case_256_1);
12121 : : }
12122 : :
12123 : : static int
12124 : 0 : test_AES_GCM_auth_decryption_test_case_256_2(void)
12125 : : {
12126 : 0 : return test_authenticated_decryption(&gcm_test_case_256_2);
12127 : : }
12128 : :
12129 : : static int
12130 : 0 : test_AES_GCM_auth_decryption_test_case_256_3(void)
12131 : : {
12132 : 0 : return test_authenticated_decryption(&gcm_test_case_256_3);
12133 : : }
12134 : :
12135 : : static int
12136 : 0 : test_AES_GCM_auth_decryption_test_case_256_4(void)
12137 : : {
12138 : 0 : return test_authenticated_decryption(&gcm_test_case_256_4);
12139 : : }
12140 : :
12141 : : static int
12142 : 0 : test_AES_GCM_auth_decryption_test_case_256_5(void)
12143 : : {
12144 : 0 : return test_authenticated_decryption(&gcm_test_case_256_5);
12145 : : }
12146 : :
12147 : : static int
12148 : 0 : test_AES_GCM_auth_decryption_test_case_256_6(void)
12149 : : {
12150 : 0 : return test_authenticated_decryption(&gcm_test_case_256_6);
12151 : : }
12152 : :
12153 : : static int
12154 : 0 : test_AES_GCM_auth_decryption_test_case_256_7(void)
12155 : : {
12156 : 0 : return test_authenticated_decryption(&gcm_test_case_256_7);
12157 : : }
12158 : :
12159 : : static int
12160 : 0 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
12161 : : {
12162 : 0 : return test_authenticated_decryption(&gcm_test_case_aad_1);
12163 : : }
12164 : :
12165 : : static int
12166 : 0 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
12167 : : {
12168 : 0 : return test_authenticated_decryption(&gcm_test_case_aad_2);
12169 : : }
12170 : :
12171 : : static int
12172 : 0 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
12173 : : {
12174 : : struct aead_test_data tdata;
12175 : : int res;
12176 : :
12177 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12178 : 0 : tdata.iv.data[0] += 1;
12179 : 0 : res = test_authenticated_decryption(&tdata);
12180 [ # # ]: 0 : if (res == TEST_SKIPPED)
12181 : : return res;
12182 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12183 : : return TEST_SUCCESS;
12184 : : }
12185 : :
12186 : : static int
12187 : 0 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
12188 : : {
12189 : : struct aead_test_data tdata;
12190 : : int res;
12191 : :
12192 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12193 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12194 : 0 : tdata.plaintext.data[0] += 1;
12195 : 0 : res = test_authenticated_decryption(&tdata);
12196 [ # # ]: 0 : if (res == TEST_SKIPPED)
12197 : : return res;
12198 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12199 : : return TEST_SUCCESS;
12200 : : }
12201 : :
12202 : : static int
12203 : 0 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
12204 : : {
12205 : : struct aead_test_data tdata;
12206 : : int res;
12207 : :
12208 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12209 : 0 : tdata.ciphertext.data[0] += 1;
12210 : 0 : res = test_authenticated_decryption(&tdata);
12211 [ # # ]: 0 : if (res == TEST_SKIPPED)
12212 : : return res;
12213 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12214 : : return TEST_SUCCESS;
12215 : : }
12216 : :
12217 : : static int
12218 : 0 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
12219 : : {
12220 : : struct aead_test_data tdata;
12221 : : int res;
12222 : :
12223 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12224 : 0 : tdata.aad.len += 1;
12225 : 0 : res = test_authenticated_decryption(&tdata);
12226 [ # # ]: 0 : if (res == TEST_SKIPPED)
12227 : : return res;
12228 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12229 : : return TEST_SUCCESS;
12230 : : }
12231 : :
12232 : : static int
12233 : 0 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
12234 : 0 : {
12235 : : struct aead_test_data tdata;
12236 : : uint8_t aad[gcm_test_case_7.aad.len];
12237 : : int res;
12238 : :
12239 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12240 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12241 : 0 : aad[0] += 1;
12242 : 0 : tdata.aad.data = aad;
12243 : 0 : res = test_authenticated_decryption(&tdata);
12244 [ # # ]: 0 : if (res == TEST_SKIPPED)
12245 : : return res;
12246 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12247 : : return TEST_SUCCESS;
12248 : : }
12249 : :
12250 : : static int
12251 : 0 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
12252 : : {
12253 : : struct aead_test_data tdata;
12254 : : int res;
12255 : :
12256 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12257 : 0 : tdata.auth_tag.data[0] += 1;
12258 : 0 : res = test_authenticated_decryption(&tdata);
12259 [ # # ]: 0 : if (res == TEST_SKIPPED)
12260 : : return res;
12261 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
12262 : : return TEST_SUCCESS;
12263 : : }
12264 : :
12265 : : static int
12266 : 0 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
12267 : : {
12268 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12269 : : struct crypto_unittest_params *ut_params = &unittest_params;
12270 : :
12271 : : int retval;
12272 : : uint8_t *ciphertext, *auth_tag;
12273 : : uint16_t plaintext_pad_len;
12274 : : struct rte_cryptodev_info dev_info;
12275 : :
12276 : : /* Verify the capabilities */
12277 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12278 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12279 : 0 : cap_idx.algo.aead = tdata->algo;
12280 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12281 : : &cap_idx) == NULL)
12282 : : return TEST_SKIPPED;
12283 : :
12284 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12285 : 0 : uint64_t feat_flags = dev_info.feature_flags;
12286 : :
12287 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12288 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
12289 : : return TEST_SKIPPED;
12290 : :
12291 : : /* not supported with CPU crypto */
12292 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12293 : : return TEST_SKIPPED;
12294 : :
12295 : : /* Create AEAD session */
12296 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
12297 : 0 : tdata->algo,
12298 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
12299 : 0 : tdata->key.data, tdata->key.len,
12300 : 0 : tdata->aad.len, tdata->auth_tag.len,
12301 : 0 : tdata->iv.len);
12302 [ # # ]: 0 : if (retval < 0)
12303 : : return retval;
12304 : :
12305 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12306 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12307 : :
12308 : : /* clear mbuf payload */
12309 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12310 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
12311 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12312 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
12313 : :
12314 : : /* Create AEAD operation */
12315 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12316 [ # # ]: 0 : if (retval < 0)
12317 : : return retval;
12318 : :
12319 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12320 : :
12321 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12322 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12323 : :
12324 : : /* Process crypto operation */
12325 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12326 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12327 : : 0);
12328 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12329 : : return retval;
12330 : : } else
12331 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12332 : : ut_params->op), "failed to process sym crypto op");
12333 : :
12334 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12335 : : "crypto op processing failed");
12336 : :
12337 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12338 : :
12339 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12340 : : ut_params->op->sym->cipher.data.offset);
12341 : 0 : auth_tag = ciphertext + plaintext_pad_len;
12342 : :
12343 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12344 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12345 : :
12346 : : /* Validate obuf */
12347 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12348 : : ciphertext,
12349 : : tdata->ciphertext.data,
12350 : : tdata->ciphertext.len,
12351 : : "Ciphertext data not as expected");
12352 : :
12353 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12354 : : auth_tag,
12355 : : tdata->auth_tag.data,
12356 : : tdata->auth_tag.len,
12357 : : "Generated auth tag not as expected");
12358 : :
12359 : : return 0;
12360 : :
12361 : : }
12362 : :
12363 : : static int
12364 : 0 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
12365 : : {
12366 : 0 : return test_authenticated_encryption_oop(&gcm_test_case_5);
12367 : : }
12368 : :
12369 : : static int
12370 : 0 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
12371 : : {
12372 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12373 : : struct crypto_unittest_params *ut_params = &unittest_params;
12374 : :
12375 : : int retval;
12376 : : uint8_t *plaintext;
12377 : : struct rte_cryptodev_info dev_info;
12378 : :
12379 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12380 : : uint64_t feat_flags = dev_info.feature_flags;
12381 : :
12382 : : /* Verify the capabilities */
12383 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12384 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12385 : 0 : cap_idx.algo.aead = tdata->algo;
12386 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12387 : : &cap_idx) == NULL)
12388 : : return TEST_SKIPPED;
12389 : :
12390 : : /* not supported with CPU crypto and raw data-path APIs*/
12391 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
12392 [ # # ]: 0 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
12393 : : return TEST_SKIPPED;
12394 : :
12395 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12396 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12397 : : printf("Device does not support RAW data-path APIs.\n");
12398 : : return TEST_SKIPPED;
12399 : : }
12400 : :
12401 : : /* Create AEAD session */
12402 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
12403 : 0 : tdata->algo,
12404 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12405 : 0 : tdata->key.data, tdata->key.len,
12406 : 0 : tdata->aad.len, tdata->auth_tag.len,
12407 : 0 : tdata->iv.len);
12408 [ # # ]: 0 : if (retval < 0)
12409 : : return retval;
12410 : :
12411 : : /* alloc mbuf and set payload */
12412 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12413 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12414 : :
12415 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12416 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
12417 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12418 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
12419 : :
12420 : : /* Create AEAD operation */
12421 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12422 [ # # ]: 0 : if (retval < 0)
12423 : : return retval;
12424 : :
12425 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12426 : :
12427 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12428 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12429 : :
12430 : : /* Process crypto operation */
12431 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12432 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12433 : : 0);
12434 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12435 : : return retval;
12436 : : } else
12437 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12438 : : ut_params->op), "failed to process sym crypto op");
12439 : :
12440 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12441 : : "crypto op processing failed");
12442 : :
12443 : 0 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12444 : : ut_params->op->sym->cipher.data.offset);
12445 : :
12446 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12447 : :
12448 : : /* Validate obuf */
12449 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12450 : : plaintext,
12451 : : tdata->plaintext.data,
12452 : : tdata->plaintext.len,
12453 : : "Plaintext data not as expected");
12454 : :
12455 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
12456 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12457 : : "Authentication failed");
12458 : : return 0;
12459 : : }
12460 : :
12461 : : static int
12462 : 0 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
12463 : : {
12464 : 0 : return test_authenticated_decryption_oop(&gcm_test_case_5);
12465 : : }
12466 : :
12467 : : static int
12468 : 0 : test_authenticated_encryption_sessionless(
12469 : : const struct aead_test_data *tdata)
12470 : 0 : {
12471 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12472 : : struct crypto_unittest_params *ut_params = &unittest_params;
12473 : :
12474 : : int retval;
12475 : : uint8_t *ciphertext, *auth_tag;
12476 : : uint16_t plaintext_pad_len;
12477 : 0 : uint8_t key[tdata->key.len + 1];
12478 : : struct rte_cryptodev_info dev_info;
12479 : :
12480 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12481 : 0 : uint64_t feat_flags = dev_info.feature_flags;
12482 : :
12483 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12484 : : printf("Device doesn't support Sessionless ops.\n");
12485 : 0 : return TEST_SKIPPED;
12486 : : }
12487 : :
12488 : : /* not supported with CPU crypto */
12489 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12490 : : return TEST_SKIPPED;
12491 : :
12492 : : /* Verify the capabilities */
12493 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12494 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12495 : 0 : cap_idx.algo.aead = tdata->algo;
12496 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12497 : : &cap_idx) == NULL)
12498 : : return TEST_SKIPPED;
12499 : :
12500 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12501 : :
12502 : : /* clear mbuf payload */
12503 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12504 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12505 : :
12506 : : /* Create AEAD operation */
12507 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12508 [ # # ]: 0 : if (retval < 0)
12509 : : return retval;
12510 : :
12511 : : /* Create GCM xform */
12512 : 0 : memcpy(key, tdata->key.data, tdata->key.len);
12513 : 0 : retval = create_aead_xform(ut_params->op,
12514 : 0 : tdata->algo,
12515 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
12516 : : key, tdata->key.len,
12517 : 0 : tdata->aad.len, tdata->auth_tag.len,
12518 : 0 : tdata->iv.len);
12519 [ # # ]: 0 : if (retval < 0)
12520 : : return retval;
12521 : :
12522 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12523 : :
12524 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12525 : : RTE_CRYPTO_OP_SESSIONLESS,
12526 : : "crypto op session type not sessionless");
12527 : :
12528 : : /* Process crypto operation */
12529 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12530 : : ut_params->op), "failed to process sym crypto op");
12531 : :
12532 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12533 : :
12534 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12535 : : "crypto op status not success");
12536 : :
12537 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12538 : :
12539 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12540 : : ut_params->op->sym->cipher.data.offset);
12541 : 0 : auth_tag = ciphertext + plaintext_pad_len;
12542 : :
12543 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12544 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12545 : :
12546 : : /* Validate obuf */
12547 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12548 : : ciphertext,
12549 : : tdata->ciphertext.data,
12550 : : tdata->ciphertext.len,
12551 : : "Ciphertext data not as expected");
12552 : :
12553 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12554 : : auth_tag,
12555 : : tdata->auth_tag.data,
12556 : : tdata->auth_tag.len,
12557 : : "Generated auth tag not as expected");
12558 : :
12559 : : return 0;
12560 : :
12561 : : }
12562 : :
12563 : : static int
12564 : 0 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
12565 : : {
12566 : 0 : return test_authenticated_encryption_sessionless(
12567 : : &gcm_test_case_5);
12568 : : }
12569 : :
12570 : : static int
12571 : 0 : test_authenticated_decryption_sessionless(
12572 : : const struct aead_test_data *tdata)
12573 : 0 : {
12574 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12575 : : struct crypto_unittest_params *ut_params = &unittest_params;
12576 : :
12577 : : int retval;
12578 : : uint8_t *plaintext;
12579 : 0 : uint8_t key[tdata->key.len + 1];
12580 : : struct rte_cryptodev_info dev_info;
12581 : :
12582 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12583 : 0 : uint64_t feat_flags = dev_info.feature_flags;
12584 : :
12585 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12586 : : printf("Device doesn't support Sessionless ops.\n");
12587 : 0 : return TEST_SKIPPED;
12588 : : }
12589 : :
12590 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12591 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12592 : : printf("Device doesn't support RAW data-path APIs.\n");
12593 : 0 : return TEST_SKIPPED;
12594 : : }
12595 : :
12596 : : /* not supported with CPU crypto */
12597 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12598 : : return TEST_SKIPPED;
12599 : :
12600 : : /* Verify the capabilities */
12601 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12602 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12603 : 0 : cap_idx.algo.aead = tdata->algo;
12604 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12605 : : &cap_idx) == NULL)
12606 : : return TEST_SKIPPED;
12607 : :
12608 : : /* alloc mbuf and set payload */
12609 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12610 : :
12611 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12612 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12613 : :
12614 : : /* Create AEAD operation */
12615 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12616 [ # # ]: 0 : if (retval < 0)
12617 : : return retval;
12618 : :
12619 : : /* Create AEAD xform */
12620 : 0 : memcpy(key, tdata->key.data, tdata->key.len);
12621 : 0 : retval = create_aead_xform(ut_params->op,
12622 : 0 : tdata->algo,
12623 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12624 : : key, tdata->key.len,
12625 : 0 : tdata->aad.len, tdata->auth_tag.len,
12626 : 0 : tdata->iv.len);
12627 [ # # ]: 0 : if (retval < 0)
12628 : : return retval;
12629 : :
12630 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12631 : :
12632 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12633 : : RTE_CRYPTO_OP_SESSIONLESS,
12634 : : "crypto op session type not sessionless");
12635 : :
12636 : : /* Process crypto operation */
12637 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12638 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12639 : : 0);
12640 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12641 : : return retval;
12642 : : } else
12643 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(
12644 : : ts_params->valid_devs[0], ut_params->op),
12645 : : "failed to process sym crypto op");
12646 : :
12647 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12648 : :
12649 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12650 : : "crypto op status not success");
12651 : :
12652 : 0 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12653 : : ut_params->op->sym->cipher.data.offset);
12654 : :
12655 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12656 : :
12657 : : /* Validate obuf */
12658 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12659 : : plaintext,
12660 : : tdata->plaintext.data,
12661 : : tdata->plaintext.len,
12662 : : "Plaintext data not as expected");
12663 : :
12664 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
12665 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12666 : : "Authentication failed");
12667 : : return 0;
12668 : : }
12669 : :
12670 : : static int
12671 : 0 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
12672 : : {
12673 : 0 : return test_authenticated_decryption_sessionless(
12674 : : &gcm_test_case_5);
12675 : : }
12676 : :
12677 : : static int
12678 : 0 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
12679 : : {
12680 : 0 : return test_authenticated_encryption(&ccm_test_case_128_1);
12681 : : }
12682 : :
12683 : : static int
12684 : 0 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
12685 : : {
12686 : 0 : return test_authenticated_encryption(&ccm_test_case_128_2);
12687 : : }
12688 : :
12689 : : static int
12690 : 0 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
12691 : : {
12692 : 0 : return test_authenticated_encryption(&ccm_test_case_128_3);
12693 : : }
12694 : :
12695 : : static int
12696 : 0 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
12697 : : {
12698 : 0 : return test_authenticated_decryption(&ccm_test_case_128_1);
12699 : : }
12700 : :
12701 : : static int
12702 : 0 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
12703 : : {
12704 : 0 : return test_authenticated_decryption(&ccm_test_case_128_2);
12705 : : }
12706 : :
12707 : : static int
12708 : 0 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
12709 : : {
12710 : 0 : return test_authenticated_decryption(&ccm_test_case_128_3);
12711 : : }
12712 : :
12713 : : static int
12714 : 0 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
12715 : : {
12716 : 0 : return test_authenticated_encryption(&ccm_test_case_192_1);
12717 : : }
12718 : :
12719 : : static int
12720 : 0 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
12721 : : {
12722 : 0 : return test_authenticated_encryption(&ccm_test_case_192_2);
12723 : : }
12724 : :
12725 : : static int
12726 : 0 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
12727 : : {
12728 : 0 : return test_authenticated_encryption(&ccm_test_case_192_3);
12729 : : }
12730 : :
12731 : : static int
12732 : 0 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
12733 : : {
12734 : 0 : return test_authenticated_decryption(&ccm_test_case_192_1);
12735 : : }
12736 : :
12737 : : static int
12738 : 0 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
12739 : : {
12740 : 0 : return test_authenticated_decryption(&ccm_test_case_192_2);
12741 : : }
12742 : :
12743 : : static int
12744 : 0 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
12745 : : {
12746 : 0 : return test_authenticated_decryption(&ccm_test_case_192_3);
12747 : : }
12748 : :
12749 : : static int
12750 : 0 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
12751 : : {
12752 : 0 : return test_authenticated_encryption(&ccm_test_case_256_1);
12753 : : }
12754 : :
12755 : : static int
12756 : 0 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
12757 : : {
12758 : 0 : return test_authenticated_encryption(&ccm_test_case_256_2);
12759 : : }
12760 : :
12761 : : static int
12762 : 0 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
12763 : : {
12764 : 0 : return test_authenticated_encryption(&ccm_test_case_256_3);
12765 : : }
12766 : :
12767 : : static int
12768 : 0 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
12769 : : {
12770 : 0 : return test_authenticated_decryption(&ccm_test_case_256_1);
12771 : : }
12772 : :
12773 : : static int
12774 : 0 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
12775 : : {
12776 : 0 : return test_authenticated_decryption(&ccm_test_case_256_2);
12777 : : }
12778 : :
12779 : : static int
12780 : 0 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
12781 : : {
12782 : 0 : return test_authenticated_decryption(&ccm_test_case_256_3);
12783 : : }
12784 : :
12785 : : static int
12786 : 0 : test_stats(void)
12787 : : {
12788 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12789 : : struct rte_cryptodev_stats stats;
12790 : :
12791 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12792 : : return TEST_SKIPPED;
12793 : :
12794 : : /* Verify the capabilities */
12795 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12796 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12797 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
12798 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12799 : : &cap_idx) == NULL)
12800 : : return TEST_SKIPPED;
12801 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12802 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12803 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12804 : : &cap_idx) == NULL)
12805 : : return TEST_SKIPPED;
12806 : :
12807 [ # # ]: 0 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
12808 : : == -ENOTSUP)
12809 : : return TEST_SKIPPED;
12810 : :
12811 : 0 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
12812 [ # # ]: 0 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
12813 : : &stats) == -ENODEV),
12814 : : "rte_cryptodev_stats_get invalid dev failed");
12815 [ # # ]: 0 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
12816 : : "rte_cryptodev_stats_get invalid Param failed");
12817 : :
12818 : : /* Test expected values */
12819 : 0 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
12820 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12821 : : &stats),
12822 : : "rte_cryptodev_stats_get failed");
12823 [ # # ]: 0 : TEST_ASSERT((stats.enqueued_count == 1),
12824 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
12825 [ # # ]: 0 : TEST_ASSERT((stats.dequeued_count == 1),
12826 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
12827 [ # # ]: 0 : TEST_ASSERT((stats.enqueue_err_count == 0),
12828 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
12829 [ # # ]: 0 : TEST_ASSERT((stats.dequeue_err_count == 0),
12830 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
12831 : :
12832 : : /* invalid device but should ignore and not reset device stats*/
12833 : 0 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
12834 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12835 : : &stats),
12836 : : "rte_cryptodev_stats_get failed");
12837 [ # # ]: 0 : TEST_ASSERT((stats.enqueued_count == 1),
12838 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
12839 : :
12840 : : /* check that a valid reset clears stats */
12841 : 0 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
12842 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12843 : : &stats),
12844 : : "rte_cryptodev_stats_get failed");
12845 [ # # ]: 0 : TEST_ASSERT((stats.enqueued_count == 0),
12846 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
12847 [ # # ]: 0 : TEST_ASSERT((stats.dequeued_count == 0),
12848 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
12849 : :
12850 : : return TEST_SUCCESS;
12851 : : }
12852 : :
12853 : : static int
12854 : 0 : test_device_reconfigure(void)
12855 : : {
12856 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12857 : 0 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
12858 : 0 : struct rte_cryptodev_qp_conf qp_conf = {
12859 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
12860 : 0 : .mp_session = ts_params->session_mpool
12861 : : };
12862 : : uint16_t qp_id, dev_id, num_devs = 0;
12863 : :
12864 [ # # ]: 0 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
12865 : : "Need at least %d devices for test", 1);
12866 : :
12867 : 0 : dev_id = ts_params->valid_devs[0];
12868 : :
12869 : : /* Stop the device in case it's started so it can be configured */
12870 : 0 : rte_cryptodev_stop(dev_id);
12871 : :
12872 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
12873 : : "Failed test for rte_cryptodev_configure: "
12874 : : "dev_num %u", dev_id);
12875 : :
12876 : : /* Reconfigure with same configure params */
12877 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
12878 : : "Failed test for rte_cryptodev_configure: "
12879 : : "dev_num %u", dev_id);
12880 : :
12881 : : /* Reconfigure with just one queue pair */
12882 : 0 : ts_params->conf.nb_queue_pairs = 1;
12883 : :
12884 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12885 : : &ts_params->conf),
12886 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
12887 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
12888 : :
12889 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
12890 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12891 : : ts_params->valid_devs[0], qp_id, &qp_conf,
12892 : : rte_cryptodev_socket_id(
12893 : : ts_params->valid_devs[0])),
12894 : : "Failed test for "
12895 : : "rte_cryptodev_queue_pair_setup: num_inflights "
12896 : : "%u on qp %u on cryptodev %u",
12897 : : qp_conf.nb_descriptors, qp_id,
12898 : : ts_params->valid_devs[0]);
12899 : : }
12900 : :
12901 : : /* Reconfigure with max number of queue pairs */
12902 : 0 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
12903 : :
12904 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12905 : : &ts_params->conf),
12906 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
12907 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
12908 : :
12909 : 0 : qp_conf.mp_session = ts_params->session_mpool;
12910 : :
12911 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
12912 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12913 : : ts_params->valid_devs[0], qp_id, &qp_conf,
12914 : : rte_cryptodev_socket_id(
12915 : : ts_params->valid_devs[0])),
12916 : : "Failed test for "
12917 : : "rte_cryptodev_queue_pair_setup: num_inflights "
12918 : : "%u on qp %u on cryptodev %u",
12919 : : qp_conf.nb_descriptors, qp_id,
12920 : : ts_params->valid_devs[0]);
12921 : : }
12922 : :
12923 : : /* Start the device */
12924 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
12925 : : "Failed to start cryptodev %u",
12926 : : ts_params->valid_devs[0]);
12927 : :
12928 : : /* Test expected values */
12929 : 0 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
12930 : : }
12931 : :
12932 : 0 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
12933 : : struct crypto_unittest_params *ut_params,
12934 : : enum rte_crypto_auth_operation op,
12935 : : const struct HMAC_MD5_vector *test_case)
12936 : : {
12937 : : uint8_t key[64];
12938 : :
12939 : 0 : memcpy(key, test_case->key.data, test_case->key.len);
12940 : :
12941 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12942 : 0 : ut_params->auth_xform.next = NULL;
12943 : 0 : ut_params->auth_xform.auth.op = op;
12944 : :
12945 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
12946 : :
12947 : 0 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
12948 : 0 : ut_params->auth_xform.auth.key.length = test_case->key.len;
12949 : 0 : ut_params->auth_xform.auth.key.data = key;
12950 : :
12951 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
12952 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
12953 : : ts_params->session_mpool);
12954 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
12955 : : return TEST_SKIPPED;
12956 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12957 : :
12958 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12959 : :
12960 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12961 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12962 : :
12963 : 0 : return 0;
12964 : : }
12965 : :
12966 : 0 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
12967 : : const struct HMAC_MD5_vector *test_case,
12968 : : uint8_t **plaintext)
12969 : : {
12970 : : uint16_t plaintext_pad_len;
12971 : :
12972 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12973 : :
12974 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
12975 : : 16);
12976 : :
12977 : 0 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12978 : : plaintext_pad_len);
12979 : 0 : memcpy(*plaintext, test_case->plaintext.data,
12980 : 0 : test_case->plaintext.len);
12981 : :
12982 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12983 : : ut_params->ibuf, MD5_DIGEST_LEN);
12984 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12985 : : "no room to append digest");
12986 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12987 : : ut_params->ibuf, plaintext_pad_len);
12988 : :
12989 [ # # ]: 0 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12990 : 0 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
12991 [ # # ]: 0 : test_case->auth_tag.len);
12992 : : }
12993 : :
12994 : 0 : sym_op->auth.data.offset = 0;
12995 : 0 : sym_op->auth.data.length = test_case->plaintext.len;
12996 : :
12997 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12998 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12999 : :
13000 : 0 : return 0;
13001 : : }
13002 : :
13003 : : static int
13004 : 0 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
13005 : : {
13006 : : uint16_t plaintext_pad_len;
13007 : : uint8_t *plaintext, *auth_tag;
13008 : : int ret;
13009 : :
13010 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13011 : : struct crypto_unittest_params *ut_params = &unittest_params;
13012 : : struct rte_cryptodev_info dev_info;
13013 : :
13014 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13015 : 0 : uint64_t feat_flags = dev_info.feature_flags;
13016 : :
13017 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13018 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13019 : : printf("Device doesn't support RAW data-path APIs.\n");
13020 : 0 : return TEST_SKIPPED;
13021 : : }
13022 : :
13023 : : /* Verify the capabilities */
13024 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13025 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13026 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13027 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13028 : : &cap_idx) == NULL)
13029 : : return TEST_SKIPPED;
13030 : :
13031 [ # # ]: 0 : if (MD5_HMAC_create_session(ts_params, ut_params,
13032 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
13033 : : return TEST_FAILED;
13034 : :
13035 : : /* Generate Crypto op data structure */
13036 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13037 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13038 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13039 : : "Failed to allocate symmetric crypto operation struct");
13040 : :
13041 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13042 : : 16);
13043 : :
13044 [ # # ]: 0 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13045 : : return TEST_FAILED;
13046 : :
13047 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13048 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13049 : : ut_params->op);
13050 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13051 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13052 [ # # ]: 0 : if (ret != TEST_SUCCESS)
13053 : : return ret;
13054 : : } else
13055 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
13056 : : process_crypto_request(ts_params->valid_devs[0],
13057 : : ut_params->op),
13058 : : "failed to process sym crypto op");
13059 : :
13060 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13061 : : "crypto op processing failed");
13062 : :
13063 [ # # ]: 0 : if (ut_params->op->sym->m_dst) {
13064 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13065 : : uint8_t *, plaintext_pad_len);
13066 : : } else {
13067 : 0 : auth_tag = plaintext + plaintext_pad_len;
13068 : : }
13069 : :
13070 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13071 : : auth_tag,
13072 : : test_case->auth_tag.data,
13073 : : test_case->auth_tag.len,
13074 : : "HMAC_MD5 generated tag not as expected");
13075 : :
13076 : : return TEST_SUCCESS;
13077 : : }
13078 : :
13079 : : static int
13080 : 0 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
13081 : : {
13082 : : uint8_t *plaintext;
13083 : : int ret;
13084 : :
13085 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13086 : : struct crypto_unittest_params *ut_params = &unittest_params;
13087 : : struct rte_cryptodev_info dev_info;
13088 : :
13089 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13090 : 0 : uint64_t feat_flags = dev_info.feature_flags;
13091 : :
13092 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13093 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13094 : : printf("Device doesn't support RAW data-path APIs.\n");
13095 : 0 : return TEST_SKIPPED;
13096 : : }
13097 : :
13098 : : /* Verify the capabilities */
13099 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13100 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13101 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13102 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13103 : : &cap_idx) == NULL)
13104 : : return TEST_SKIPPED;
13105 : :
13106 [ # # ]: 0 : if (MD5_HMAC_create_session(ts_params, ut_params,
13107 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
13108 : : return TEST_FAILED;
13109 : : }
13110 : :
13111 : : /* Generate Crypto op data structure */
13112 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13113 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13114 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13115 : : "Failed to allocate symmetric crypto operation struct");
13116 : :
13117 [ # # ]: 0 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13118 : : return TEST_FAILED;
13119 : :
13120 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13121 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13122 : : ut_params->op);
13123 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13124 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13125 [ # # ]: 0 : if (ret != TEST_SUCCESS)
13126 : : return ret;
13127 : : } else
13128 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
13129 : : process_crypto_request(ts_params->valid_devs[0],
13130 : : ut_params->op),
13131 : : "failed to process sym crypto op");
13132 : :
13133 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13134 : : "HMAC_MD5 crypto op processing failed");
13135 : :
13136 : : return TEST_SUCCESS;
13137 : : }
13138 : :
13139 : : static int
13140 : 0 : test_MD5_HMAC_generate_case_1(void)
13141 : : {
13142 : 0 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
13143 : : }
13144 : :
13145 : : static int
13146 : 0 : test_MD5_HMAC_verify_case_1(void)
13147 : : {
13148 : 0 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
13149 : : }
13150 : :
13151 : : static int
13152 : 0 : test_MD5_HMAC_generate_case_2(void)
13153 : : {
13154 : 0 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
13155 : : }
13156 : :
13157 : : static int
13158 : 0 : test_MD5_HMAC_verify_case_2(void)
13159 : : {
13160 : 0 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
13161 : : }
13162 : :
13163 : : static int
13164 : 0 : test_multi_session(void)
13165 : : {
13166 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13167 : : struct crypto_unittest_params *ut_params = &unittest_params;
13168 : : struct rte_cryptodev_info dev_info;
13169 : : int i, nb_sess, ret = TEST_SUCCESS;
13170 : : void **sessions;
13171 : :
13172 : : /* Verify the capabilities */
13173 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13174 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13175 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13176 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13177 : : &cap_idx) == NULL)
13178 : : return TEST_SKIPPED;
13179 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13180 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13181 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13182 : : &cap_idx) == NULL)
13183 : : return TEST_SKIPPED;
13184 : :
13185 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
13186 : : aes_cbc_key, hmac_sha512_key);
13187 : :
13188 : :
13189 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13190 : :
13191 : 0 : sessions = rte_malloc(NULL,
13192 : : sizeof(void *) *
13193 : : (MAX_NB_SESSIONS + 1), 0);
13194 : :
13195 : : /* Create multiple crypto sessions*/
13196 [ # # ]: 0 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
13197 : 0 : sessions[i] = rte_cryptodev_sym_session_create(
13198 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
13199 : : ts_params->session_mpool);
13200 [ # # # # ]: 0 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13201 : : nb_sess = i;
13202 : : ret = TEST_SKIPPED;
13203 : : break;
13204 : : }
13205 : :
13206 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sessions[i],
13207 : : "Session creation failed at session number %u",
13208 : : i);
13209 : :
13210 : : /* Attempt to send a request on each session */
13211 : 0 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13212 : : sessions[i],
13213 : : ut_params,
13214 : : ts_params,
13215 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
13216 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
13217 : : aes_cbc_iv);
13218 : :
13219 : : /* free crypto operation structure */
13220 : 0 : rte_crypto_op_free(ut_params->op);
13221 : :
13222 : : /*
13223 : : * free mbuf - both obuf and ibuf are usually the same,
13224 : : * so check if they point at the same address is necessary,
13225 : : * to avoid freeing the mbuf twice.
13226 : : */
13227 [ # # ]: 0 : if (ut_params->obuf) {
13228 : 0 : rte_pktmbuf_free(ut_params->obuf);
13229 [ # # ]: 0 : if (ut_params->ibuf == ut_params->obuf)
13230 : 0 : ut_params->ibuf = 0;
13231 : 0 : ut_params->obuf = 0;
13232 : : }
13233 [ # # ]: 0 : if (ut_params->ibuf) {
13234 : 0 : rte_pktmbuf_free(ut_params->ibuf);
13235 : 0 : ut_params->ibuf = 0;
13236 : : }
13237 : :
13238 [ # # ]: 0 : if (ret != TEST_SUCCESS) {
13239 : 0 : i++;
13240 : 0 : break;
13241 : : }
13242 : : }
13243 : :
13244 : : nb_sess = i;
13245 : :
13246 [ # # ]: 0 : for (i = 0; i < nb_sess; i++) {
13247 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13248 : 0 : sessions[i]);
13249 : : }
13250 : :
13251 : 0 : rte_free(sessions);
13252 : :
13253 [ # # ]: 0 : if (ret != TEST_SKIPPED)
13254 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
13255 : :
13256 : : return ret;
13257 : : }
13258 : :
13259 : : struct multi_session_params {
13260 : : struct crypto_unittest_params ut_params;
13261 : : uint8_t *cipher_key;
13262 : : uint8_t *hmac_key;
13263 : : const uint8_t *cipher;
13264 : : const uint8_t *digest;
13265 : : uint8_t *iv;
13266 : : };
13267 : :
13268 : : #define MB_SESSION_NUMBER 3
13269 : :
13270 : : static int
13271 : 0 : test_multi_session_random_usage(void)
13272 : : {
13273 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13274 : : struct rte_cryptodev_info dev_info;
13275 : : int index = 0, ret = TEST_SUCCESS;
13276 : : uint32_t nb_sess, i, j;
13277 : : void **sessions;
13278 : 0 : struct multi_session_params ut_paramz[] = {
13279 : :
13280 : : {
13281 : : .cipher_key = ms_aes_cbc_key0,
13282 : : .hmac_key = ms_hmac_key0,
13283 : : .cipher = ms_aes_cbc_cipher0,
13284 : : .digest = ms_hmac_digest0,
13285 : : .iv = ms_aes_cbc_iv0
13286 : : },
13287 : : {
13288 : : .cipher_key = ms_aes_cbc_key1,
13289 : : .hmac_key = ms_hmac_key1,
13290 : : .cipher = ms_aes_cbc_cipher1,
13291 : : .digest = ms_hmac_digest1,
13292 : : .iv = ms_aes_cbc_iv1
13293 : : },
13294 : : {
13295 : : .cipher_key = ms_aes_cbc_key2,
13296 : : .hmac_key = ms_hmac_key2,
13297 : : .cipher = ms_aes_cbc_cipher2,
13298 : : .digest = ms_hmac_digest2,
13299 : : .iv = ms_aes_cbc_iv2
13300 : : },
13301 : :
13302 : : };
13303 : :
13304 : : /* Verify the capabilities */
13305 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13306 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13307 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13308 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13309 : : &cap_idx) == NULL)
13310 : : return TEST_SKIPPED;
13311 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13312 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13313 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13314 : : &cap_idx) == NULL)
13315 : : return TEST_SKIPPED;
13316 : :
13317 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13318 : :
13319 : 0 : sessions = rte_malloc(NULL, (sizeof(void *)
13320 : : * MAX_NB_SESSIONS) + 1, 0);
13321 : :
13322 [ # # ]: 0 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
13323 : :
13324 [ # # ]: 0 : rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
13325 : : sizeof(struct crypto_unittest_params));
13326 : :
13327 : 0 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
13328 : : &ut_paramz[i].ut_params,
13329 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
13330 : :
13331 : : /* Create multiple crypto sessions*/
13332 : 0 : sessions[i] = rte_cryptodev_sym_session_create(
13333 : 0 : ts_params->valid_devs[0],
13334 : : &ut_paramz[i].ut_params.auth_xform,
13335 : : ts_params->session_mpool);
13336 [ # # # # ]: 0 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13337 : : nb_sess = i;
13338 : : ret = TEST_SKIPPED;
13339 : 0 : goto session_clear;
13340 : : }
13341 : :
13342 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sessions[i],
13343 : : "Session creation failed at session number %u",
13344 : : i);
13345 : : }
13346 : :
13347 : : nb_sess = i;
13348 : :
13349 : 0 : srand(time(NULL));
13350 [ # # ]: 0 : for (i = 0; i < 40000; i++) {
13351 : :
13352 : 0 : j = rand() % MB_SESSION_NUMBER;
13353 : :
13354 : 0 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13355 : 0 : sessions[j],
13356 : : &ut_paramz[j].ut_params,
13357 : : ts_params, ut_paramz[j].cipher,
13358 : : ut_paramz[j].digest,
13359 : 0 : ut_paramz[j].iv);
13360 : :
13361 : 0 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
13362 : :
13363 : : /*
13364 : : * free mbuf - both obuf and ibuf are usually the same,
13365 : : * so check if they point at the same address is necessary,
13366 : : * to avoid freeing the mbuf twice.
13367 : : */
13368 [ # # ]: 0 : if (ut_paramz[j].ut_params.obuf) {
13369 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
13370 : 0 : if (ut_paramz[j].ut_params.ibuf
13371 [ # # ]: 0 : == ut_paramz[j].ut_params.obuf)
13372 : 0 : ut_paramz[j].ut_params.ibuf = 0;
13373 : 0 : ut_paramz[j].ut_params.obuf = 0;
13374 : : }
13375 [ # # ]: 0 : if (ut_paramz[j].ut_params.ibuf) {
13376 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
13377 : 0 : ut_paramz[j].ut_params.ibuf = 0;
13378 : : }
13379 : :
13380 [ # # ]: 0 : if (ret != TEST_SKIPPED) {
13381 : 0 : index = i;
13382 : 0 : break;
13383 : : }
13384 : : }
13385 : :
13386 : 0 : session_clear:
13387 [ # # ]: 0 : for (i = 0; i < nb_sess; i++) {
13388 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13389 : 0 : sessions[i]);
13390 : : }
13391 : :
13392 : 0 : rte_free(sessions);
13393 : :
13394 [ # # ]: 0 : if (ret != TEST_SKIPPED)
13395 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
13396 : :
13397 : : return TEST_SUCCESS;
13398 : : }
13399 : :
13400 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
13401 : : 0xab, 0xab, 0xab, 0xab,
13402 : : 0xab, 0xab, 0xab, 0xab,
13403 : : 0xab, 0xab, 0xab, 0xab};
13404 : :
13405 : : static int
13406 : 0 : test_null_invalid_operation(void)
13407 : : {
13408 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13409 : : struct crypto_unittest_params *ut_params = &unittest_params;
13410 : :
13411 : : /* This test is for NULL PMD only */
13412 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
13413 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13414 : : return TEST_SKIPPED;
13415 : :
13416 : : /* Setup Cipher Parameters */
13417 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13418 : 0 : ut_params->cipher_xform.next = NULL;
13419 : :
13420 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
13421 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13422 : :
13423 : : /* Create Crypto session*/
13424 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13425 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
13426 : : ts_params->session_mpool);
13427 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
13428 : : "Session creation succeeded unexpectedly");
13429 : :
13430 : : /* Setup HMAC Parameters */
13431 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13432 : 0 : ut_params->auth_xform.next = NULL;
13433 : :
13434 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
13435 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13436 : :
13437 : : /* Create Crypto session*/
13438 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13439 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
13440 : : ts_params->session_mpool);
13441 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
13442 : : "Session creation succeeded unexpectedly");
13443 : :
13444 : : return TEST_SUCCESS;
13445 : : }
13446 : :
13447 : :
13448 : : #define NULL_BURST_LENGTH (32)
13449 : :
13450 : : static int
13451 : 0 : test_null_burst_operation(void)
13452 : : {
13453 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13454 : : struct crypto_unittest_params *ut_params = &unittest_params;
13455 : :
13456 : : unsigned i, burst_len = NULL_BURST_LENGTH;
13457 : :
13458 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
13459 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
13460 : :
13461 : : /* This test is for NULL PMD only */
13462 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
13463 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13464 : : return TEST_SKIPPED;
13465 : :
13466 : : /* Setup Cipher Parameters */
13467 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13468 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
13469 : :
13470 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
13471 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13472 : :
13473 : : /* Setup HMAC Parameters */
13474 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13475 : 0 : ut_params->auth_xform.next = NULL;
13476 : :
13477 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
13478 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13479 : :
13480 : : /* Create Crypto session*/
13481 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13482 : 0 : ts_params->valid_devs[0],
13483 : : &ut_params->auth_xform,
13484 : : ts_params->session_mpool);
13485 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13486 : : return TEST_SKIPPED;
13487 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13488 : :
13489 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
13490 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
13491 : : burst_len, "failed to generate burst of crypto ops");
13492 : :
13493 : : /* Generate an operation for each mbuf in burst */
13494 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
13495 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13496 : :
13497 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
13498 : :
13499 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
13500 : : sizeof(unsigned));
13501 : 0 : *data = i;
13502 : :
13503 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
13504 : :
13505 : 0 : burst[i]->sym->m_src = m;
13506 : : }
13507 : :
13508 : : /* Process crypto operation */
13509 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
13510 : : 0, burst, burst_len),
13511 : : burst_len,
13512 : : "Error enqueuing burst");
13513 : :
13514 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
13515 : : 0, burst_dequeued, burst_len),
13516 : : burst_len,
13517 : : "Error dequeuing burst");
13518 : :
13519 : :
13520 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
13521 [ # # ]: 0 : TEST_ASSERT_EQUAL(
13522 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
13523 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
13524 : : uint32_t *),
13525 : : "data not as expected");
13526 : :
13527 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
13528 : 0 : rte_crypto_op_free(burst[i]);
13529 : : }
13530 : :
13531 : : return TEST_SUCCESS;
13532 : : }
13533 : :
13534 : : static uint16_t
13535 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13536 : : uint16_t nb_ops, void *user_param)
13537 : : {
13538 : : RTE_SET_USED(dev_id);
13539 : : RTE_SET_USED(qp_id);
13540 : : RTE_SET_USED(ops);
13541 : : RTE_SET_USED(user_param);
13542 : :
13543 : : printf("crypto enqueue callback called\n");
13544 : 0 : return nb_ops;
13545 : : }
13546 : :
13547 : : static uint16_t
13548 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13549 : : uint16_t nb_ops, void *user_param)
13550 : : {
13551 : : RTE_SET_USED(dev_id);
13552 : : RTE_SET_USED(qp_id);
13553 : : RTE_SET_USED(ops);
13554 : : RTE_SET_USED(user_param);
13555 : :
13556 : : printf("crypto dequeue callback called\n");
13557 : 0 : return nb_ops;
13558 : : }
13559 : :
13560 : : /*
13561 : : * Thread using enqueue/dequeue callback with RCU.
13562 : : */
13563 : : static int
13564 : 0 : test_enqdeq_callback_thread(void *arg)
13565 : : {
13566 : : RTE_SET_USED(arg);
13567 : : /* DP thread calls rte_cryptodev_enqueue_burst()/
13568 : : * rte_cryptodev_dequeue_burst() and invokes callback.
13569 : : */
13570 : 0 : test_null_burst_operation();
13571 : 0 : return 0;
13572 : : }
13573 : :
13574 : : static int
13575 : 0 : test_enq_callback_setup(void)
13576 : : {
13577 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13578 : : struct rte_cryptodev_info dev_info;
13579 : 0 : struct rte_cryptodev_qp_conf qp_conf = {
13580 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
13581 : : };
13582 : :
13583 : : struct rte_cryptodev_cb *cb;
13584 : : uint16_t qp_id = 0;
13585 : :
13586 : : /* Stop the device in case it's started so it can be configured */
13587 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
13588 : :
13589 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13590 : :
13591 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13592 : : &ts_params->conf),
13593 : : "Failed to configure cryptodev %u",
13594 : : ts_params->valid_devs[0]);
13595 : :
13596 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13597 : 0 : qp_conf.mp_session = ts_params->session_mpool;
13598 : :
13599 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13600 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13601 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13602 : : "Failed test for "
13603 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13604 : : "%u on qp %u on cryptodev %u",
13605 : : qp_conf.nb_descriptors, qp_id,
13606 : : ts_params->valid_devs[0]);
13607 : :
13608 : : /* Test with invalid crypto device */
13609 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
13610 : : qp_id, test_enq_callback, NULL);
13611 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13612 : : "cryptodev %u did not fail",
13613 : : qp_id, RTE_CRYPTO_MAX_DEVS);
13614 : :
13615 : : /* Test with invalid queue pair */
13616 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13617 : 0 : dev_info.max_nb_queue_pairs + 1,
13618 : : test_enq_callback, NULL);
13619 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13620 : : "cryptodev %u did not fail",
13621 : : dev_info.max_nb_queue_pairs + 1,
13622 : : ts_params->valid_devs[0]);
13623 : :
13624 : : /* Test with NULL callback */
13625 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13626 : : qp_id, NULL, NULL);
13627 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13628 : : "cryptodev %u did not fail",
13629 : : qp_id, ts_params->valid_devs[0]);
13630 : :
13631 : : /* Test with valid configuration */
13632 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13633 : : qp_id, test_enq_callback, NULL);
13634 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
13635 : : "qp %u on cryptodev %u",
13636 : : qp_id, ts_params->valid_devs[0]);
13637 : :
13638 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
13639 : :
13640 : : /* Launch a thread */
13641 : 0 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
13642 : : rte_get_next_lcore(-1, 1, 0));
13643 : :
13644 : : /* Wait until reader exited. */
13645 : 0 : rte_eal_mp_wait_lcore();
13646 : :
13647 : : /* Test with invalid crypto device */
13648 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13649 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
13650 : : "Expected call to fail as crypto device is invalid");
13651 : :
13652 : : /* Test with invalid queue pair */
13653 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13654 : : ts_params->valid_devs[0],
13655 : : dev_info.max_nb_queue_pairs + 1, cb),
13656 : : "Expected call to fail as queue pair is invalid");
13657 : :
13658 : : /* Test with NULL callback */
13659 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13660 : : ts_params->valid_devs[0], qp_id, NULL),
13661 : : "Expected call to fail as callback is NULL");
13662 : :
13663 : : /* Test with valid configuration */
13664 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
13665 : : ts_params->valid_devs[0], qp_id, cb),
13666 : : "Failed test to remove callback on "
13667 : : "qp %u on cryptodev %u",
13668 : : qp_id, ts_params->valid_devs[0]);
13669 : :
13670 : : return TEST_SUCCESS;
13671 : : }
13672 : :
13673 : : static int
13674 : 0 : test_deq_callback_setup(void)
13675 : : {
13676 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13677 : : struct rte_cryptodev_info dev_info;
13678 : 0 : struct rte_cryptodev_qp_conf qp_conf = {
13679 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
13680 : : };
13681 : :
13682 : : struct rte_cryptodev_cb *cb;
13683 : : uint16_t qp_id = 0;
13684 : :
13685 : : /* Stop the device in case it's started so it can be configured */
13686 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
13687 : :
13688 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13689 : :
13690 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13691 : : &ts_params->conf),
13692 : : "Failed to configure cryptodev %u",
13693 : : ts_params->valid_devs[0]);
13694 : :
13695 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13696 : 0 : qp_conf.mp_session = ts_params->session_mpool;
13697 : :
13698 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13699 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13700 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13701 : : "Failed test for "
13702 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13703 : : "%u on qp %u on cryptodev %u",
13704 : : qp_conf.nb_descriptors, qp_id,
13705 : : ts_params->valid_devs[0]);
13706 : :
13707 : : /* Test with invalid crypto device */
13708 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
13709 : : qp_id, test_deq_callback, NULL);
13710 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13711 : : "cryptodev %u did not fail",
13712 : : qp_id, RTE_CRYPTO_MAX_DEVS);
13713 : :
13714 : : /* Test with invalid queue pair */
13715 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13716 : 0 : dev_info.max_nb_queue_pairs + 1,
13717 : : test_deq_callback, NULL);
13718 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13719 : : "cryptodev %u did not fail",
13720 : : dev_info.max_nb_queue_pairs + 1,
13721 : : ts_params->valid_devs[0]);
13722 : :
13723 : : /* Test with NULL callback */
13724 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13725 : : qp_id, NULL, NULL);
13726 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13727 : : "cryptodev %u did not fail",
13728 : : qp_id, ts_params->valid_devs[0]);
13729 : :
13730 : : /* Test with valid configuration */
13731 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13732 : : qp_id, test_deq_callback, NULL);
13733 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
13734 : : "qp %u on cryptodev %u",
13735 : : qp_id, ts_params->valid_devs[0]);
13736 : :
13737 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
13738 : :
13739 : : /* Launch a thread */
13740 : 0 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
13741 : : rte_get_next_lcore(-1, 1, 0));
13742 : :
13743 : : /* Wait until reader exited. */
13744 : 0 : rte_eal_mp_wait_lcore();
13745 : :
13746 : : /* Test with invalid crypto device */
13747 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13748 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
13749 : : "Expected call to fail as crypto device is invalid");
13750 : :
13751 : : /* Test with invalid queue pair */
13752 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13753 : : ts_params->valid_devs[0],
13754 : : dev_info.max_nb_queue_pairs + 1, cb),
13755 : : "Expected call to fail as queue pair is invalid");
13756 : :
13757 : : /* Test with NULL callback */
13758 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13759 : : ts_params->valid_devs[0], qp_id, NULL),
13760 : : "Expected call to fail as callback is NULL");
13761 : :
13762 : : /* Test with valid configuration */
13763 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
13764 : : ts_params->valid_devs[0], qp_id, cb),
13765 : : "Failed test to remove callback on "
13766 : : "qp %u on cryptodev %u",
13767 : : qp_id, ts_params->valid_devs[0]);
13768 : :
13769 : : return TEST_SUCCESS;
13770 : : }
13771 : :
13772 : : static void
13773 : : generate_gmac_large_plaintext(uint8_t *data)
13774 : : {
13775 : : uint16_t i;
13776 : :
13777 [ # # # # ]: 0 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
13778 : 0 : memcpy(&data[i], &data[0], 32);
13779 : : }
13780 : :
13781 : : static int
13782 : 0 : create_gmac_operation(enum rte_crypto_auth_operation op,
13783 : : const struct gmac_test_data *tdata)
13784 : : {
13785 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13786 : : struct crypto_unittest_params *ut_params = &unittest_params;
13787 : : struct rte_crypto_sym_op *sym_op;
13788 : :
13789 : 0 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13790 : :
13791 : : /* Generate Crypto op data structure */
13792 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13793 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13794 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13795 : : "Failed to allocate symmetric crypto operation struct");
13796 : :
13797 : : sym_op = ut_params->op->sym;
13798 : :
13799 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13800 : 0 : ut_params->ibuf, tdata->gmac_tag.len);
13801 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13802 : : "no room to append digest");
13803 : :
13804 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13805 : : ut_params->ibuf, plaintext_pad_len);
13806 : :
13807 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13808 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
13809 [ # # ]: 0 : tdata->gmac_tag.len);
13810 : 0 : debug_hexdump(stdout, "digest:",
13811 : 0 : sym_op->auth.digest.data,
13812 : 0 : tdata->gmac_tag.len);
13813 : : }
13814 : :
13815 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13816 : : uint8_t *, IV_OFFSET);
13817 : :
13818 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
13819 : :
13820 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
13821 : :
13822 : 0 : sym_op->cipher.data.length = 0;
13823 : 0 : sym_op->cipher.data.offset = 0;
13824 : :
13825 : 0 : sym_op->auth.data.offset = 0;
13826 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
13827 : :
13828 : 0 : return 0;
13829 : : }
13830 : :
13831 : : static int
13832 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
13833 : : const struct gmac_test_data *tdata,
13834 : : void *digest_mem, uint64_t digest_phys)
13835 : : {
13836 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13837 : : struct crypto_unittest_params *ut_params = &unittest_params;
13838 : : struct rte_crypto_sym_op *sym_op;
13839 : :
13840 : : /* Generate Crypto op data structure */
13841 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13842 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13843 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13844 : : "Failed to allocate symmetric crypto operation struct");
13845 : :
13846 : : sym_op = ut_params->op->sym;
13847 : :
13848 : 0 : sym_op->auth.digest.data = digest_mem;
13849 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13850 : : "no room to append digest");
13851 : :
13852 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
13853 : :
13854 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13855 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
13856 [ # # ]: 0 : tdata->gmac_tag.len);
13857 : 0 : debug_hexdump(stdout, "digest:",
13858 : 0 : sym_op->auth.digest.data,
13859 : 0 : tdata->gmac_tag.len);
13860 : : }
13861 : :
13862 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13863 : : uint8_t *, IV_OFFSET);
13864 : :
13865 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
13866 : :
13867 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
13868 : :
13869 : 0 : sym_op->cipher.data.length = 0;
13870 : 0 : sym_op->cipher.data.offset = 0;
13871 : :
13872 : 0 : sym_op->auth.data.offset = 0;
13873 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
13874 : :
13875 : 0 : return 0;
13876 : : }
13877 : :
13878 : 0 : static int create_gmac_session(uint8_t dev_id,
13879 : : const struct gmac_test_data *tdata,
13880 : : enum rte_crypto_auth_operation auth_op)
13881 : 0 : {
13882 : 0 : uint8_t auth_key[tdata->key.len];
13883 : :
13884 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13885 : : struct crypto_unittest_params *ut_params = &unittest_params;
13886 : :
13887 : 0 : memcpy(auth_key, tdata->key.data, tdata->key.len);
13888 : :
13889 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13890 : 0 : ut_params->auth_xform.next = NULL;
13891 : :
13892 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
13893 : 0 : ut_params->auth_xform.auth.op = auth_op;
13894 : 0 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
13895 : 0 : ut_params->auth_xform.auth.key.length = tdata->key.len;
13896 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
13897 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13898 : 0 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
13899 : :
13900 : :
13901 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
13902 : : &ut_params->auth_xform, ts_params->session_mpool);
13903 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13904 : : return TEST_SKIPPED;
13905 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13906 : :
13907 : : return 0;
13908 : : }
13909 : :
13910 : : static int
13911 : 0 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
13912 : : {
13913 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13914 : : struct crypto_unittest_params *ut_params = &unittest_params;
13915 : : struct rte_cryptodev_info dev_info;
13916 : :
13917 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13918 : 0 : uint64_t feat_flags = dev_info.feature_flags;
13919 : :
13920 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13921 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13922 : : printf("Device doesn't support RAW data-path APIs.\n");
13923 : 0 : return TEST_SKIPPED;
13924 : : }
13925 : :
13926 : : int retval;
13927 : :
13928 : : uint8_t *auth_tag, *plaintext;
13929 : : uint16_t plaintext_pad_len;
13930 : :
13931 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
13932 : : "No GMAC length in the source data");
13933 : :
13934 : : /* Verify the capabilities */
13935 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13936 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13937 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
13938 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13939 : : &cap_idx) == NULL)
13940 : : return TEST_SKIPPED;
13941 : :
13942 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
13943 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
13944 : :
13945 [ # # ]: 0 : if (retval == TEST_SKIPPED)
13946 : : return TEST_SKIPPED;
13947 [ # # ]: 0 : if (retval < 0)
13948 : : return retval;
13949 : :
13950 [ # # ]: 0 : if (tdata->plaintext.len > MBUF_SIZE)
13951 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13952 : : else
13953 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13954 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13955 : : "Failed to allocate input buffer in mempool");
13956 : :
13957 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13958 : : rte_pktmbuf_tailroom(ut_params->ibuf));
13959 : :
13960 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13961 : : /*
13962 : : * Runtime generate the large plain text instead of use hard code
13963 : : * plain text vector. It is done to avoid create huge source file
13964 : : * with the test vector.
13965 : : */
13966 [ # # ]: 0 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
13967 : 0 : generate_gmac_large_plaintext(tdata->plaintext.data);
13968 : :
13969 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13970 : : plaintext_pad_len);
13971 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13972 : :
13973 : 0 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
13974 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
13975 : 0 : tdata->plaintext.len);
13976 : :
13977 : 0 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
13978 : : tdata);
13979 : :
13980 [ # # ]: 0 : if (retval < 0)
13981 : : return retval;
13982 : :
13983 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13984 : :
13985 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
13986 : :
13987 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13988 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13989 : : ut_params->op);
13990 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13991 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
13992 : : 0);
13993 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13994 : : return retval;
13995 : : } else
13996 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
13997 : : process_crypto_request(ts_params->valid_devs[0],
13998 : : ut_params->op), "failed to process sym crypto op");
13999 : :
14000 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14001 : : "crypto op processing failed");
14002 : :
14003 [ # # ]: 0 : if (ut_params->op->sym->m_dst) {
14004 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14005 : : uint8_t *, plaintext_pad_len);
14006 : : } else {
14007 : 0 : auth_tag = plaintext + plaintext_pad_len;
14008 : : }
14009 : :
14010 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14011 : :
14012 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14013 : : auth_tag,
14014 : : tdata->gmac_tag.data,
14015 : : tdata->gmac_tag.len,
14016 : : "GMAC Generated auth tag not as expected");
14017 : :
14018 : : return 0;
14019 : : }
14020 : :
14021 : : static int
14022 : 0 : test_AES_GMAC_authentication_test_case_1(void)
14023 : : {
14024 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_1);
14025 : : }
14026 : :
14027 : : static int
14028 : 0 : test_AES_GMAC_authentication_test_case_2(void)
14029 : : {
14030 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_2);
14031 : : }
14032 : :
14033 : : static int
14034 : 0 : test_AES_GMAC_authentication_test_case_3(void)
14035 : : {
14036 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_3);
14037 : : }
14038 : :
14039 : : static int
14040 : 0 : test_AES_GMAC_authentication_test_case_4(void)
14041 : : {
14042 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_4);
14043 : : }
14044 : :
14045 : : static int
14046 : 0 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
14047 : : {
14048 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14049 : : struct crypto_unittest_params *ut_params = &unittest_params;
14050 : : int retval;
14051 : : uint32_t plaintext_pad_len;
14052 : : uint8_t *plaintext;
14053 : : struct rte_cryptodev_info dev_info;
14054 : :
14055 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14056 : 0 : uint64_t feat_flags = dev_info.feature_flags;
14057 : :
14058 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14059 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14060 : : printf("Device doesn't support RAW data-path APIs.\n");
14061 : 0 : return TEST_SKIPPED;
14062 : : }
14063 : :
14064 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14065 : : "No GMAC length in the source data");
14066 : :
14067 : : /* Verify the capabilities */
14068 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14069 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14070 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14071 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14072 : : &cap_idx) == NULL)
14073 : : return TEST_SKIPPED;
14074 : :
14075 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
14076 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
14077 : :
14078 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14079 : : return TEST_SKIPPED;
14080 [ # # ]: 0 : if (retval < 0)
14081 : : return retval;
14082 : :
14083 [ # # ]: 0 : if (tdata->plaintext.len > MBUF_SIZE)
14084 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14085 : : else
14086 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14087 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14088 : : "Failed to allocate input buffer in mempool");
14089 : :
14090 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14091 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14092 : :
14093 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14094 : :
14095 : : /*
14096 : : * Runtime generate the large plain text instead of use hard code
14097 : : * plain text vector. It is done to avoid create huge source file
14098 : : * with the test vector.
14099 : : */
14100 [ # # ]: 0 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14101 : 0 : generate_gmac_large_plaintext(tdata->plaintext.data);
14102 : :
14103 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14104 : : plaintext_pad_len);
14105 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14106 : :
14107 : 0 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14108 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
14109 : 0 : tdata->plaintext.len);
14110 : :
14111 : 0 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
14112 : : tdata);
14113 : :
14114 [ # # ]: 0 : if (retval < 0)
14115 : : return retval;
14116 : :
14117 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14118 : :
14119 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
14120 : :
14121 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14122 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14123 : : ut_params->op);
14124 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14125 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14126 : : 0);
14127 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14128 : : return retval;
14129 : : } else
14130 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
14131 : : process_crypto_request(ts_params->valid_devs[0],
14132 : : ut_params->op), "failed to process sym crypto op");
14133 : :
14134 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14135 : : "crypto op processing failed");
14136 : :
14137 : : return 0;
14138 : :
14139 : : }
14140 : :
14141 : : static int
14142 : 0 : test_AES_GMAC_authentication_verify_test_case_1(void)
14143 : : {
14144 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
14145 : : }
14146 : :
14147 : : static int
14148 : 0 : test_AES_GMAC_authentication_verify_test_case_2(void)
14149 : : {
14150 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
14151 : : }
14152 : :
14153 : : static int
14154 : 0 : test_AES_GMAC_authentication_verify_test_case_3(void)
14155 : : {
14156 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
14157 : : }
14158 : :
14159 : : static int
14160 : 0 : test_AES_GMAC_authentication_verify_test_case_4(void)
14161 : : {
14162 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
14163 : : }
14164 : :
14165 : : static int
14166 : 0 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
14167 : : uint32_t fragsz)
14168 : : {
14169 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14170 : : struct crypto_unittest_params *ut_params = &unittest_params;
14171 : : struct rte_cryptodev_info dev_info;
14172 : : uint64_t feature_flags;
14173 : : unsigned int trn_data = 0;
14174 : : void *digest_mem = NULL;
14175 : : uint32_t segs = 1;
14176 : : unsigned int to_trn = 0;
14177 : : struct rte_mbuf *buf = NULL;
14178 : : uint8_t *auth_tag, *plaintext;
14179 : : int retval;
14180 : :
14181 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14182 : : "No GMAC length in the source data");
14183 : :
14184 : : /* Verify the capabilities */
14185 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14186 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14187 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14188 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14189 : : &cap_idx) == NULL)
14190 : : return TEST_SKIPPED;
14191 : :
14192 : : /* Check for any input SGL support */
14193 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14194 : 0 : feature_flags = dev_info.feature_flags;
14195 : :
14196 : 0 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
14197 [ # # ]: 0 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
14198 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
14199 : : return TEST_SKIPPED;
14200 : :
14201 : 0 : if (fragsz > tdata->plaintext.len)
14202 : : fragsz = tdata->plaintext.len;
14203 : :
14204 : 0 : uint16_t plaintext_len = fragsz;
14205 : :
14206 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
14207 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14208 : :
14209 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14210 : : return TEST_SKIPPED;
14211 [ # # ]: 0 : if (retval < 0)
14212 : : return retval;
14213 : :
14214 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14215 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14216 : : "Failed to allocate input buffer in mempool");
14217 : :
14218 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14219 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14220 : :
14221 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14222 : : plaintext_len);
14223 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14224 : :
14225 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14226 : :
14227 : : trn_data += plaintext_len;
14228 : :
14229 : 0 : buf = ut_params->ibuf;
14230 : :
14231 : : /*
14232 : : * Loop until no more fragments
14233 : : */
14234 : :
14235 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
14236 : 0 : ++segs;
14237 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14238 : : (tdata->plaintext.len - trn_data) : fragsz;
14239 : :
14240 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14241 : : buf = buf->next;
14242 : :
14243 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14244 : : rte_pktmbuf_tailroom(buf));
14245 : :
14246 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14247 : : to_trn);
14248 : :
14249 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
14250 : : to_trn);
14251 : 0 : trn_data += to_trn;
14252 [ # # ]: 0 : if (trn_data == tdata->plaintext.len)
14253 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14254 : 0 : tdata->gmac_tag.len);
14255 : : }
14256 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
14257 : :
14258 : : /*
14259 : : * Place digest at the end of the last buffer
14260 : : */
14261 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14262 : :
14263 [ # # ]: 0 : if (!digest_mem) {
14264 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14265 : 0 : + tdata->gmac_tag.len);
14266 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14267 : : tdata->plaintext.len);
14268 : : }
14269 : :
14270 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
14271 : : tdata, digest_mem, digest_phys);
14272 : :
14273 [ # # ]: 0 : if (retval < 0)
14274 : : return retval;
14275 : :
14276 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14277 : :
14278 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
14279 : :
14280 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14281 : : return TEST_SKIPPED;
14282 : :
14283 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
14284 : : process_crypto_request(ts_params->valid_devs[0],
14285 : : ut_params->op), "failed to process sym crypto op");
14286 : :
14287 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14288 : : "crypto op processing failed");
14289 : :
14290 : : auth_tag = digest_mem;
14291 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14292 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14293 : : auth_tag,
14294 : : tdata->gmac_tag.data,
14295 : : tdata->gmac_tag.len,
14296 : : "GMAC Generated auth tag not as expected");
14297 : :
14298 : : return 0;
14299 : : }
14300 : :
14301 : : /* Segment size not multiple of block size (16B) */
14302 : : static int
14303 : 0 : test_AES_GMAC_authentication_SGL_40B(void)
14304 : : {
14305 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
14306 : : }
14307 : :
14308 : : static int
14309 : 0 : test_AES_GMAC_authentication_SGL_80B(void)
14310 : : {
14311 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
14312 : : }
14313 : :
14314 : : static int
14315 : 0 : test_AES_GMAC_authentication_SGL_2048B(void)
14316 : : {
14317 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
14318 : : }
14319 : :
14320 : : /* Segment size not multiple of block size (16B) */
14321 : : static int
14322 : 0 : test_AES_GMAC_authentication_SGL_2047B(void)
14323 : : {
14324 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
14325 : : }
14326 : :
14327 : : struct test_crypto_vector {
14328 : : enum rte_crypto_cipher_algorithm crypto_algo;
14329 : : unsigned int cipher_offset;
14330 : : unsigned int cipher_len;
14331 : :
14332 : : struct {
14333 : : uint8_t data[64];
14334 : : unsigned int len;
14335 : : } cipher_key;
14336 : :
14337 : : struct {
14338 : : uint8_t data[64];
14339 : : unsigned int len;
14340 : : } iv;
14341 : :
14342 : : struct {
14343 : : const uint8_t *data;
14344 : : unsigned int len;
14345 : : } plaintext;
14346 : :
14347 : : struct {
14348 : : const uint8_t *data;
14349 : : unsigned int len;
14350 : : } ciphertext;
14351 : :
14352 : : enum rte_crypto_auth_algorithm auth_algo;
14353 : : unsigned int auth_offset;
14354 : :
14355 : : struct {
14356 : : uint8_t data[128];
14357 : : unsigned int len;
14358 : : } auth_key;
14359 : :
14360 : : struct {
14361 : : const uint8_t *data;
14362 : : unsigned int len;
14363 : : } aad;
14364 : :
14365 : : struct {
14366 : : uint8_t data[128];
14367 : : unsigned int len;
14368 : : } digest;
14369 : : };
14370 : :
14371 : : static const struct test_crypto_vector
14372 : : hmac_sha1_test_crypto_vector = {
14373 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14374 : : .plaintext = {
14375 : : .data = plaintext_hash,
14376 : : .len = 512
14377 : : },
14378 : : .auth_key = {
14379 : : .data = {
14380 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14381 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14382 : : 0xDE, 0xF4, 0xDE, 0xAD
14383 : : },
14384 : : .len = 20
14385 : : },
14386 : : .digest = {
14387 : : .data = {
14388 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
14389 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
14390 : : 0x3F, 0x91, 0x64, 0x59
14391 : : },
14392 : : .len = 20
14393 : : }
14394 : : };
14395 : :
14396 : : static const struct test_crypto_vector
14397 : : aes128_gmac_test_vector = {
14398 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
14399 : : .plaintext = {
14400 : : .data = plaintext_hash,
14401 : : .len = 512
14402 : : },
14403 : : .iv = {
14404 : : .data = {
14405 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14406 : : 0x08, 0x09, 0x0A, 0x0B
14407 : : },
14408 : : .len = 12
14409 : : },
14410 : : .auth_key = {
14411 : : .data = {
14412 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14413 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
14414 : : },
14415 : : .len = 16
14416 : : },
14417 : : .digest = {
14418 : : .data = {
14419 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
14420 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
14421 : : },
14422 : : .len = 16
14423 : : }
14424 : : };
14425 : :
14426 : : static const struct test_crypto_vector
14427 : : aes128cbc_hmac_sha1_test_vector = {
14428 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14429 : : .cipher_offset = 0,
14430 : : .cipher_len = 512,
14431 : : .cipher_key = {
14432 : : .data = {
14433 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14434 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14435 : : },
14436 : : .len = 16
14437 : : },
14438 : : .iv = {
14439 : : .data = {
14440 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14441 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14442 : : },
14443 : : .len = 16
14444 : : },
14445 : : .plaintext = {
14446 : : .data = plaintext_hash,
14447 : : .len = 512
14448 : : },
14449 : : .ciphertext = {
14450 : : .data = ciphertext512_aes128cbc,
14451 : : .len = 512
14452 : : },
14453 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14454 : : .auth_offset = 0,
14455 : : .auth_key = {
14456 : : .data = {
14457 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14458 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14459 : : 0xDE, 0xF4, 0xDE, 0xAD
14460 : : },
14461 : : .len = 20
14462 : : },
14463 : : .digest = {
14464 : : .data = {
14465 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
14466 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14467 : : 0x18, 0x8C, 0x1D, 0x32
14468 : : },
14469 : : .len = 20
14470 : : }
14471 : : };
14472 : :
14473 : : static const struct test_crypto_vector
14474 : : aes128cbc_hmac_sha1_aad_test_vector = {
14475 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14476 : : .cipher_offset = 8,
14477 : : .cipher_len = 496,
14478 : : .cipher_key = {
14479 : : .data = {
14480 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14481 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14482 : : },
14483 : : .len = 16
14484 : : },
14485 : : .iv = {
14486 : : .data = {
14487 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14488 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14489 : : },
14490 : : .len = 16
14491 : : },
14492 : : .plaintext = {
14493 : : .data = plaintext_hash,
14494 : : .len = 512
14495 : : },
14496 : : .ciphertext = {
14497 : : .data = ciphertext512_aes128cbc_aad,
14498 : : .len = 512
14499 : : },
14500 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14501 : : .auth_offset = 0,
14502 : : .auth_key = {
14503 : : .data = {
14504 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14505 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14506 : : 0xDE, 0xF4, 0xDE, 0xAD
14507 : : },
14508 : : .len = 20
14509 : : },
14510 : : .digest = {
14511 : : .data = {
14512 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
14513 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
14514 : : 0x62, 0x0F, 0xFB, 0x10
14515 : : },
14516 : : .len = 20
14517 : : }
14518 : : };
14519 : :
14520 : : static void
14521 : : data_corruption(uint8_t *data)
14522 : : {
14523 : 0 : data[0] += 1;
14524 : 0 : }
14525 : :
14526 : : static void
14527 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
14528 : : {
14529 : 0 : data[tag_offset] += 1;
14530 : 0 : }
14531 : :
14532 : : static int
14533 : 0 : create_auth_session(struct crypto_unittest_params *ut_params,
14534 : : uint8_t dev_id,
14535 : : const struct test_crypto_vector *reference,
14536 : : enum rte_crypto_auth_operation auth_op)
14537 : 0 : {
14538 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14539 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
14540 : :
14541 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14542 : :
14543 : : /* Setup Authentication Parameters */
14544 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14545 : 0 : ut_params->auth_xform.auth.op = auth_op;
14546 : 0 : ut_params->auth_xform.next = NULL;
14547 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
14548 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14549 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
14550 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
14551 : :
14552 : : /* Create Crypto session*/
14553 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14554 : : &ut_params->auth_xform,
14555 : : ts_params->session_mpool);
14556 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14557 : 0 : return TEST_SKIPPED;
14558 : :
14559 : : return 0;
14560 : : }
14561 : :
14562 : : static int
14563 : 0 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
14564 : : uint8_t dev_id,
14565 : : const struct test_crypto_vector *reference,
14566 : : enum rte_crypto_auth_operation auth_op,
14567 : : enum rte_crypto_cipher_operation cipher_op)
14568 : 0 : {
14569 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14570 : 0 : uint8_t cipher_key[reference->cipher_key.len + 1];
14571 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
14572 : :
14573 [ # # ]: 0 : memcpy(cipher_key, reference->cipher_key.data,
14574 : : reference->cipher_key.len);
14575 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14576 : :
14577 : : /* Setup Authentication Parameters */
14578 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14579 : 0 : ut_params->auth_xform.auth.op = auth_op;
14580 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
14581 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14582 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
14583 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
14584 : :
14585 [ # # ]: 0 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
14586 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14587 : 0 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
14588 : : } else {
14589 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
14590 : :
14591 : : /* Setup Cipher Parameters */
14592 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14593 : 0 : ut_params->cipher_xform.next = NULL;
14594 : 0 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14595 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
14596 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
14597 : 0 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14598 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14599 : 0 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14600 : : }
14601 : :
14602 : : /* Create Crypto session*/
14603 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14604 : : &ut_params->auth_xform,
14605 : : ts_params->session_mpool);
14606 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14607 : 0 : return TEST_SKIPPED;
14608 : :
14609 : : return 0;
14610 : : }
14611 : :
14612 : : static int
14613 : 0 : create_auth_operation(struct crypto_testsuite_params *ts_params,
14614 : : struct crypto_unittest_params *ut_params,
14615 : : const struct test_crypto_vector *reference,
14616 : : unsigned int auth_generate)
14617 : : {
14618 : : /* Generate Crypto op data structure */
14619 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14620 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14621 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14622 : : "Failed to allocate pktmbuf offload");
14623 : :
14624 : : /* Set crypto operation data parameters */
14625 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14626 : :
14627 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14628 : :
14629 : : /* set crypto operation source mbuf */
14630 : 0 : sym_op->m_src = ut_params->ibuf;
14631 : :
14632 : : /* digest */
14633 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14634 : 0 : ut_params->ibuf, reference->digest.len);
14635 : :
14636 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14637 : : "no room to append auth tag");
14638 : :
14639 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14640 : : ut_params->ibuf, reference->plaintext.len);
14641 : :
14642 [ # # ]: 0 : if (auth_generate)
14643 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
14644 : : else
14645 : 0 : memcpy(sym_op->auth.digest.data,
14646 : 0 : reference->digest.data,
14647 : 0 : reference->digest.len);
14648 : :
14649 : 0 : debug_hexdump(stdout, "digest:",
14650 : 0 : sym_op->auth.digest.data,
14651 : 0 : reference->digest.len);
14652 : :
14653 : 0 : sym_op->auth.data.length = reference->plaintext.len;
14654 : 0 : sym_op->auth.data.offset = 0;
14655 : :
14656 : 0 : return 0;
14657 : : }
14658 : :
14659 : : static int
14660 : 0 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
14661 : : struct crypto_unittest_params *ut_params,
14662 : : const struct test_crypto_vector *reference,
14663 : : unsigned int auth_generate)
14664 : : {
14665 : : /* Generate Crypto op data structure */
14666 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14667 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14668 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14669 : : "Failed to allocate pktmbuf offload");
14670 : :
14671 : : /* Set crypto operation data parameters */
14672 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14673 : :
14674 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14675 : :
14676 : : /* set crypto operation source mbuf */
14677 : 0 : sym_op->m_src = ut_params->ibuf;
14678 : :
14679 : : /* digest */
14680 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14681 : 0 : ut_params->ibuf, reference->digest.len);
14682 : :
14683 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14684 : : "no room to append auth tag");
14685 : :
14686 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14687 : : ut_params->ibuf, reference->ciphertext.len);
14688 : :
14689 [ # # ]: 0 : if (auth_generate)
14690 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
14691 : : else
14692 : 0 : memcpy(sym_op->auth.digest.data,
14693 : 0 : reference->digest.data,
14694 : 0 : reference->digest.len);
14695 : :
14696 : 0 : debug_hexdump(stdout, "digest:",
14697 : 0 : sym_op->auth.digest.data,
14698 : 0 : reference->digest.len);
14699 : :
14700 : 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
14701 [ # # ]: 0 : reference->iv.data, reference->iv.len);
14702 : :
14703 : 0 : sym_op->cipher.data.length = 0;
14704 : 0 : sym_op->cipher.data.offset = 0;
14705 : :
14706 : 0 : sym_op->auth.data.length = reference->plaintext.len;
14707 : 0 : sym_op->auth.data.offset = 0;
14708 : :
14709 : 0 : return 0;
14710 : : }
14711 : :
14712 : : static int
14713 : 0 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
14714 : : struct crypto_unittest_params *ut_params,
14715 : : const struct test_crypto_vector *reference,
14716 : : unsigned int auth_generate)
14717 : : {
14718 : : /* Generate Crypto op data structure */
14719 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14720 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14721 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14722 : : "Failed to allocate pktmbuf offload");
14723 : :
14724 : : /* Set crypto operation data parameters */
14725 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14726 : :
14727 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14728 : :
14729 : : /* set crypto operation source mbuf */
14730 : 0 : sym_op->m_src = ut_params->ibuf;
14731 : :
14732 : : /* digest */
14733 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14734 : 0 : ut_params->ibuf, reference->digest.len);
14735 : :
14736 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14737 : : "no room to append auth tag");
14738 : :
14739 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14740 : : ut_params->ibuf, reference->ciphertext.len);
14741 : :
14742 [ # # ]: 0 : if (auth_generate)
14743 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
14744 : : else
14745 : 0 : memcpy(sym_op->auth.digest.data,
14746 : 0 : reference->digest.data,
14747 : 0 : reference->digest.len);
14748 : :
14749 : 0 : debug_hexdump(stdout, "digest:",
14750 : 0 : sym_op->auth.digest.data,
14751 : 0 : reference->digest.len);
14752 : :
14753 : 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
14754 [ # # ]: 0 : reference->iv.data, reference->iv.len);
14755 : :
14756 : 0 : sym_op->cipher.data.length = reference->cipher_len;
14757 : 0 : sym_op->cipher.data.offset = reference->cipher_offset;
14758 : :
14759 : 0 : sym_op->auth.data.length = reference->plaintext.len;
14760 : 0 : sym_op->auth.data.offset = reference->auth_offset;
14761 : :
14762 : 0 : return 0;
14763 : : }
14764 : :
14765 : : static int
14766 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
14767 : : struct crypto_unittest_params *ut_params,
14768 : : const struct test_crypto_vector *reference)
14769 : : {
14770 : 0 : return create_auth_operation(ts_params, ut_params, reference, 0);
14771 : : }
14772 : :
14773 : : static int
14774 : : create_auth_verify_GMAC_operation(
14775 : : struct crypto_testsuite_params *ts_params,
14776 : : struct crypto_unittest_params *ut_params,
14777 : : const struct test_crypto_vector *reference)
14778 : : {
14779 : 0 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
14780 : : }
14781 : :
14782 : : static int
14783 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
14784 : : struct crypto_unittest_params *ut_params,
14785 : : const struct test_crypto_vector *reference)
14786 : : {
14787 : 0 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
14788 : : }
14789 : :
14790 : : static int
14791 : 0 : test_authentication_verify_fail_when_data_corruption(
14792 : : struct crypto_testsuite_params *ts_params,
14793 : : struct crypto_unittest_params *ut_params,
14794 : : const struct test_crypto_vector *reference,
14795 : : unsigned int data_corrupted)
14796 : : {
14797 : : int retval;
14798 : :
14799 : : uint8_t *plaintext;
14800 : : struct rte_cryptodev_info dev_info;
14801 : :
14802 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14803 : 0 : uint64_t feat_flags = dev_info.feature_flags;
14804 : :
14805 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14806 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14807 : : printf("Device doesn't support RAW data-path APIs.\n");
14808 : 0 : return TEST_SKIPPED;
14809 : : }
14810 : :
14811 : : /* Verify the capabilities */
14812 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14813 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14814 : 0 : cap_idx.algo.auth = reference->auth_algo;
14815 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14816 : : &cap_idx) == NULL)
14817 : : return TEST_SKIPPED;
14818 : :
14819 : :
14820 : : /* Create session */
14821 : 0 : retval = create_auth_session(ut_params,
14822 : 0 : ts_params->valid_devs[0],
14823 : : reference,
14824 : : RTE_CRYPTO_AUTH_OP_VERIFY);
14825 : :
14826 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14827 : : return TEST_SKIPPED;
14828 [ # # ]: 0 : if (retval < 0)
14829 : : return retval;
14830 : :
14831 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14832 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14833 : : "Failed to allocate input buffer in mempool");
14834 : :
14835 : : /* clear mbuf payload */
14836 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14837 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14838 : :
14839 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14840 : 0 : reference->plaintext.len);
14841 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14842 : 0 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14843 : :
14844 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
14845 : 0 : reference->plaintext.len);
14846 : :
14847 : : /* Create operation */
14848 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
14849 : :
14850 [ # # ]: 0 : if (retval < 0)
14851 : : return retval;
14852 : :
14853 [ # # ]: 0 : if (data_corrupted)
14854 : : data_corruption(plaintext);
14855 : : else
14856 : 0 : tag_corruption(plaintext, reference->plaintext.len);
14857 : :
14858 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
14859 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14860 : : ut_params->op);
14861 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
14862 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14863 : : "authentication not failed");
14864 [ # # ]: 0 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14865 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14866 : : 0);
14867 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14868 : : return retval;
14869 : : } else {
14870 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14871 : : ut_params->op);
14872 : : }
14873 [ # # ]: 0 : if (ut_params->op == NULL)
14874 : : return 0;
14875 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
14876 : 0 : return 0;
14877 : :
14878 : : return -1;
14879 : : }
14880 : :
14881 : : static int
14882 : 0 : test_authentication_verify_GMAC_fail_when_corruption(
14883 : : struct crypto_testsuite_params *ts_params,
14884 : : struct crypto_unittest_params *ut_params,
14885 : : const struct test_crypto_vector *reference,
14886 : : unsigned int data_corrupted)
14887 : : {
14888 : : int retval;
14889 : : uint8_t *plaintext;
14890 : : struct rte_cryptodev_info dev_info;
14891 : :
14892 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14893 : 0 : uint64_t feat_flags = dev_info.feature_flags;
14894 : :
14895 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14896 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14897 : : printf("Device doesn't support RAW data-path APIs.\n");
14898 : 0 : return TEST_SKIPPED;
14899 : : }
14900 : :
14901 : : /* Verify the capabilities */
14902 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14903 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14904 : 0 : cap_idx.algo.auth = reference->auth_algo;
14905 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14906 : : &cap_idx) == NULL)
14907 : : return TEST_SKIPPED;
14908 : :
14909 : : /* Create session */
14910 : 0 : retval = create_auth_cipher_session(ut_params,
14911 : 0 : ts_params->valid_devs[0],
14912 : : reference,
14913 : : RTE_CRYPTO_AUTH_OP_VERIFY,
14914 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
14915 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14916 : : return TEST_SKIPPED;
14917 [ # # ]: 0 : if (retval < 0)
14918 : : return retval;
14919 : :
14920 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14921 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14922 : : "Failed to allocate input buffer in mempool");
14923 : :
14924 : : /* clear mbuf payload */
14925 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14926 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14927 : :
14928 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14929 : 0 : reference->plaintext.len);
14930 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14931 : 0 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14932 : :
14933 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
14934 : 0 : reference->plaintext.len);
14935 : :
14936 : : /* Create operation */
14937 : : retval = create_auth_verify_GMAC_operation(ts_params,
14938 : : ut_params,
14939 : : reference);
14940 : :
14941 [ # # ]: 0 : if (retval < 0)
14942 : : return retval;
14943 : :
14944 [ # # ]: 0 : if (data_corrupted)
14945 : : data_corruption(plaintext);
14946 : : else
14947 : 0 : tag_corruption(plaintext, reference->aad.len);
14948 : :
14949 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
14950 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14951 : : ut_params->op);
14952 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
14953 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14954 : : "authentication not failed");
14955 [ # # ]: 0 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14956 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14957 : : 0);
14958 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14959 : 0 : return retval;
14960 : : } else {
14961 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14962 : : ut_params->op);
14963 [ # # ]: 0 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
14964 : : }
14965 : :
14966 : : return 0;
14967 : : }
14968 : :
14969 : : static int
14970 : 0 : test_authenticated_decryption_fail_when_corruption(
14971 : : struct crypto_testsuite_params *ts_params,
14972 : : struct crypto_unittest_params *ut_params,
14973 : : const struct test_crypto_vector *reference,
14974 : : unsigned int data_corrupted)
14975 : : {
14976 : : int retval;
14977 : :
14978 : : uint8_t *ciphertext;
14979 : : struct rte_cryptodev_info dev_info;
14980 : :
14981 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14982 : 0 : uint64_t feat_flags = dev_info.feature_flags;
14983 : :
14984 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14985 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14986 : : printf("Device doesn't support RAW data-path APIs.\n");
14987 : 0 : return TEST_SKIPPED;
14988 : : }
14989 : :
14990 : : /* Verify the capabilities */
14991 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14992 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14993 : 0 : cap_idx.algo.auth = reference->auth_algo;
14994 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14995 : : &cap_idx) == NULL)
14996 : : return TEST_SKIPPED;
14997 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14998 : 0 : cap_idx.algo.cipher = reference->crypto_algo;
14999 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15000 : : &cap_idx) == NULL)
15001 : : return TEST_SKIPPED;
15002 : :
15003 : : /* Create session */
15004 : 0 : retval = create_auth_cipher_session(ut_params,
15005 : 0 : ts_params->valid_devs[0],
15006 : : reference,
15007 : : RTE_CRYPTO_AUTH_OP_VERIFY,
15008 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
15009 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15010 : : return TEST_SKIPPED;
15011 [ # # ]: 0 : if (retval < 0)
15012 : : return retval;
15013 : :
15014 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15015 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15016 : : "Failed to allocate input buffer in mempool");
15017 : :
15018 : : /* clear mbuf payload */
15019 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15020 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15021 : :
15022 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15023 : 0 : reference->ciphertext.len);
15024 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15025 : 0 : memcpy(ciphertext, reference->ciphertext.data,
15026 : 0 : reference->ciphertext.len);
15027 : :
15028 : : /* Create operation */
15029 : : retval = create_cipher_auth_verify_operation(ts_params,
15030 : : ut_params,
15031 : : reference);
15032 : :
15033 [ # # ]: 0 : if (retval < 0)
15034 : : return retval;
15035 : :
15036 [ # # ]: 0 : if (data_corrupted)
15037 : : data_corruption(ciphertext);
15038 : : else
15039 : 0 : tag_corruption(ciphertext, reference->ciphertext.len);
15040 : :
15041 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15042 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15043 : : ut_params->op);
15044 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15045 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15046 : : "authentication not failed");
15047 [ # # ]: 0 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15048 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15049 : : 0);
15050 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15051 : 0 : return retval;
15052 : : } else {
15053 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15054 : : ut_params->op);
15055 [ # # ]: 0 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15056 : : }
15057 : :
15058 : : return 0;
15059 : : }
15060 : :
15061 : : static int
15062 : 0 : test_authenticated_encrypt_with_esn(
15063 : : struct crypto_testsuite_params *ts_params,
15064 : : struct crypto_unittest_params *ut_params,
15065 : : const struct test_crypto_vector *reference)
15066 : 0 : {
15067 : : int retval;
15068 : :
15069 : : uint8_t *authciphertext, *plaintext, *auth_tag;
15070 : : uint16_t plaintext_pad_len;
15071 : 0 : uint8_t cipher_key[reference->cipher_key.len + 1];
15072 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
15073 : : struct rte_cryptodev_info dev_info;
15074 : :
15075 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15076 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15077 : :
15078 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15079 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15080 : : printf("Device doesn't support RAW data-path APIs.\n");
15081 : 0 : return TEST_SKIPPED;
15082 : : }
15083 : :
15084 : : /* Verify the capabilities */
15085 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15086 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15087 : 0 : cap_idx.algo.auth = reference->auth_algo;
15088 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15089 : : &cap_idx) == NULL)
15090 : : return TEST_SKIPPED;
15091 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15092 : 0 : cap_idx.algo.cipher = reference->crypto_algo;
15093 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15094 : : &cap_idx) == NULL)
15095 : : return TEST_SKIPPED;
15096 : :
15097 : : /* Create session */
15098 : 0 : memcpy(cipher_key, reference->cipher_key.data,
15099 : 0 : reference->cipher_key.len);
15100 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15101 : :
15102 : : /* Setup Cipher Parameters */
15103 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15104 : 0 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15105 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15106 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
15107 : 0 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15108 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15109 : 0 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15110 : :
15111 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15112 : :
15113 : : /* Setup Authentication Parameters */
15114 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15115 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15116 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15117 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15118 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
15119 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15120 : 0 : ut_params->auth_xform.next = NULL;
15121 : :
15122 : : /* Create Crypto session*/
15123 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15124 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15125 : : ts_params->session_mpool);
15126 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15127 : : return TEST_SKIPPED;
15128 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15129 : :
15130 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15131 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15132 : : "Failed to allocate input buffer in mempool");
15133 : :
15134 : : /* clear mbuf payload */
15135 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15136 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15137 : :
15138 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15139 : 0 : reference->plaintext.len);
15140 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15141 : 0 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15142 : :
15143 : : /* Create operation */
15144 : 0 : retval = create_cipher_auth_operation(ts_params,
15145 : : ut_params,
15146 : : reference, 0);
15147 : :
15148 [ # # ]: 0 : if (retval < 0)
15149 : : return retval;
15150 : :
15151 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15152 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15153 : : ut_params->op);
15154 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15155 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15156 : : 0);
15157 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15158 : : return retval;
15159 : : } else
15160 : 0 : ut_params->op = process_crypto_request(
15161 : 0 : ts_params->valid_devs[0], ut_params->op);
15162 : :
15163 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
15164 : :
15165 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15166 : : "crypto op processing failed");
15167 : :
15168 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
15169 : :
15170 : 0 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
15171 : : ut_params->op->sym->auth.data.offset);
15172 : 0 : auth_tag = authciphertext + plaintext_pad_len;
15173 : 0 : debug_hexdump(stdout, "ciphertext:", authciphertext,
15174 : 0 : reference->ciphertext.len);
15175 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
15176 : :
15177 : : /* Validate obuf */
15178 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15179 : : authciphertext,
15180 : : reference->ciphertext.data,
15181 : : reference->ciphertext.len,
15182 : : "Ciphertext data not as expected");
15183 : :
15184 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15185 : : auth_tag,
15186 : : reference->digest.data,
15187 : : reference->digest.len,
15188 : : "Generated digest not as expected");
15189 : :
15190 : : return TEST_SUCCESS;
15191 : :
15192 : : }
15193 : :
15194 : : static int
15195 : 0 : test_authenticated_decrypt_with_esn(
15196 : : struct crypto_testsuite_params *ts_params,
15197 : : struct crypto_unittest_params *ut_params,
15198 : : const struct test_crypto_vector *reference)
15199 : 0 : {
15200 : : int retval;
15201 : :
15202 : : uint8_t *ciphertext;
15203 : 0 : uint8_t cipher_key[reference->cipher_key.len + 1];
15204 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
15205 : : struct rte_cryptodev_info dev_info;
15206 : :
15207 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15208 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15209 : :
15210 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15211 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15212 : : printf("Device doesn't support RAW data-path APIs.\n");
15213 : 0 : return TEST_SKIPPED;
15214 : : }
15215 : :
15216 : : /* Verify the capabilities */
15217 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15218 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15219 : 0 : cap_idx.algo.auth = reference->auth_algo;
15220 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15221 : : &cap_idx) == NULL)
15222 : : return TEST_SKIPPED;
15223 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15224 : 0 : cap_idx.algo.cipher = reference->crypto_algo;
15225 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15226 : : &cap_idx) == NULL)
15227 : : return TEST_SKIPPED;
15228 : :
15229 : : /* Create session */
15230 : 0 : memcpy(cipher_key, reference->cipher_key.data,
15231 : 0 : reference->cipher_key.len);
15232 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15233 : :
15234 : : /* Setup Authentication Parameters */
15235 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15236 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
15237 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15238 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15239 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
15240 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15241 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
15242 : :
15243 : : /* Setup Cipher Parameters */
15244 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15245 : 0 : ut_params->cipher_xform.next = NULL;
15246 : 0 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15247 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
15248 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
15249 : 0 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15250 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15251 : 0 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15252 : :
15253 : : /* Create Crypto session*/
15254 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15255 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
15256 : : ts_params->session_mpool);
15257 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15258 : : return TEST_SKIPPED;
15259 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15260 : :
15261 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15262 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15263 : : "Failed to allocate input buffer in mempool");
15264 : :
15265 : : /* clear mbuf payload */
15266 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15267 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15268 : :
15269 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15270 : 0 : reference->ciphertext.len);
15271 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15272 : 0 : memcpy(ciphertext, reference->ciphertext.data,
15273 : 0 : reference->ciphertext.len);
15274 : :
15275 : : /* Create operation */
15276 : : retval = create_cipher_auth_verify_operation(ts_params,
15277 : : ut_params,
15278 : : reference);
15279 : :
15280 [ # # ]: 0 : if (retval < 0)
15281 : : return retval;
15282 : :
15283 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15284 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15285 : : ut_params->op);
15286 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15287 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15288 : : 0);
15289 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15290 : : return retval;
15291 : : } else
15292 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15293 : : ut_params->op);
15294 : :
15295 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
15296 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
15297 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15298 : : "crypto op processing passed");
15299 : :
15300 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
15301 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
15302 : :
15303 : : return 0;
15304 : : }
15305 : :
15306 : : static int
15307 : 0 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
15308 : : const struct aead_test_data *tdata,
15309 : : void *digest_mem, uint64_t digest_phys)
15310 : : {
15311 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15312 : : struct crypto_unittest_params *ut_params = &unittest_params;
15313 : :
15314 : 0 : const unsigned int auth_tag_len = tdata->auth_tag.len;
15315 : 0 : const unsigned int iv_len = tdata->iv.len;
15316 : 0 : unsigned int aad_len = tdata->aad.len;
15317 : : unsigned int aad_len_pad = 0;
15318 : :
15319 : : /* Generate Crypto op data structure */
15320 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15321 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15322 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15323 : : "Failed to allocate symmetric crypto operation struct");
15324 : :
15325 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15326 : :
15327 : 0 : sym_op->aead.digest.data = digest_mem;
15328 : :
15329 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
15330 : : "no room to append digest");
15331 : :
15332 : 0 : sym_op->aead.digest.phys_addr = digest_phys;
15333 : :
15334 [ # # ]: 0 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
15335 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
15336 : : auth_tag_len);
15337 : 0 : debug_hexdump(stdout, "digest:",
15338 : 0 : sym_op->aead.digest.data,
15339 : : auth_tag_len);
15340 : : }
15341 : :
15342 : : /* Append aad data */
15343 [ # # ]: 0 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
15344 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15345 : : uint8_t *, IV_OFFSET);
15346 : :
15347 : : /* Copy IV 1 byte after the IV pointer, according to the API */
15348 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
15349 : :
15350 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
15351 : :
15352 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15353 : : ut_params->ibuf, aad_len);
15354 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15355 : : "no room to prepend aad");
15356 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15357 : : ut_params->ibuf);
15358 : :
15359 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
15360 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
15361 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15362 : :
15363 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15364 : 0 : debug_hexdump(stdout, "aad:",
15365 : 0 : sym_op->aead.aad.data, aad_len);
15366 : : } else {
15367 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15368 : : uint8_t *, IV_OFFSET);
15369 : :
15370 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
15371 : :
15372 : 0 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
15373 : :
15374 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15375 : : ut_params->ibuf, aad_len_pad);
15376 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15377 : : "no room to prepend aad");
15378 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15379 : : ut_params->ibuf);
15380 : :
15381 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
15382 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15383 : :
15384 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15385 : 0 : debug_hexdump(stdout, "aad:",
15386 : 0 : sym_op->aead.aad.data, aad_len);
15387 : : }
15388 : :
15389 : 0 : sym_op->aead.data.length = tdata->plaintext.len;
15390 : 0 : sym_op->aead.data.offset = aad_len_pad;
15391 : :
15392 : 0 : return 0;
15393 : : }
15394 : :
15395 : : #define SGL_MAX_NO 16
15396 : :
15397 : : static int
15398 : 0 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
15399 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
15400 : : {
15401 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15402 : : struct crypto_unittest_params *ut_params = &unittest_params;
15403 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
15404 : : int retval;
15405 : : int to_trn = 0;
15406 : : int to_trn_tbl[SGL_MAX_NO];
15407 : : int segs = 1;
15408 : : unsigned int trn_data = 0;
15409 : : uint8_t *plaintext, *ciphertext, *auth_tag;
15410 : : struct rte_cryptodev_info dev_info;
15411 : :
15412 : : /* Verify the capabilities */
15413 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15414 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
15415 : 0 : cap_idx.algo.aead = tdata->algo;
15416 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15417 : : &cap_idx) == NULL)
15418 : : return TEST_SKIPPED;
15419 : :
15420 : : /*
15421 : : * SGL not supported on AESNI_MB PMD CPU crypto,
15422 : : * OOP not supported on AESNI_GCM CPU crypto
15423 : : */
15424 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
15425 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
15426 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
15427 : : return TEST_SKIPPED;
15428 : :
15429 : : /* Detailed check for the particular SGL support flag */
15430 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15431 [ # # ]: 0 : if (!oop) {
15432 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
15433 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
15434 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
15435 : : return TEST_SKIPPED;
15436 : :
15437 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15438 : :
15439 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15440 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15441 : : printf("Device doesn't support RAW data-path APIs.\n");
15442 : 0 : return TEST_SKIPPED;
15443 : : }
15444 : : } else {
15445 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
15446 [ # # ]: 0 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
15447 : : tdata->plaintext.len;
15448 : : /* Raw data path API does not support OOP */
15449 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
15450 : : return TEST_SKIPPED;
15451 [ # # ]: 0 : if (sgl_in && !sgl_out) {
15452 [ # # ]: 0 : if (!(dev_info.feature_flags &
15453 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
15454 : : return TEST_SKIPPED;
15455 [ # # ]: 0 : } else if (!sgl_in && sgl_out) {
15456 [ # # ]: 0 : if (!(dev_info.feature_flags &
15457 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
15458 : : return TEST_SKIPPED;
15459 [ # # ]: 0 : } else if (sgl_in && sgl_out) {
15460 [ # # ]: 0 : if (!(dev_info.feature_flags &
15461 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
15462 : : return TEST_SKIPPED;
15463 : : }
15464 : : }
15465 : :
15466 : 0 : if (fragsz > tdata->plaintext.len)
15467 : : fragsz = tdata->plaintext.len;
15468 : :
15469 : 0 : uint16_t plaintext_len = fragsz;
15470 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
15471 : :
15472 [ # # ]: 0 : if (fragsz_oop > tdata->plaintext.len)
15473 : 0 : frag_size_oop = tdata->plaintext.len;
15474 : :
15475 : : int ecx = 0;
15476 : : void *digest_mem = NULL;
15477 : :
15478 : 0 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
15479 : :
15480 [ # # ]: 0 : if (tdata->plaintext.len % fragsz != 0) {
15481 [ # # ]: 0 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
15482 : : return 1;
15483 : : } else {
15484 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
15485 : : return 1;
15486 : : }
15487 : :
15488 : : /*
15489 : : * For out-op-place we need to alloc another mbuf
15490 : : */
15491 [ # # ]: 0 : if (oop) {
15492 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15493 : : rte_pktmbuf_append(ut_params->obuf,
15494 : 0 : frag_size_oop + prepend_len);
15495 : 0 : buf_oop = ut_params->obuf;
15496 : : }
15497 : :
15498 : : /* Create AEAD session */
15499 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
15500 : 0 : tdata->algo,
15501 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
15502 : 0 : tdata->key.data, tdata->key.len,
15503 : 0 : tdata->aad.len, tdata->auth_tag.len,
15504 : 0 : tdata->iv.len);
15505 [ # # ]: 0 : if (retval < 0)
15506 : : return retval;
15507 : :
15508 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15509 : :
15510 : : /* clear mbuf payload */
15511 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15512 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15513 : :
15514 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15515 : : plaintext_len);
15516 : :
15517 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15518 : :
15519 : : trn_data += plaintext_len;
15520 : :
15521 : 0 : buf = ut_params->ibuf;
15522 : :
15523 : : /*
15524 : : * Loop until no more fragments
15525 : : */
15526 : :
15527 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15528 : 0 : ++segs;
15529 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15530 : 0 : (tdata->plaintext.len - trn_data) : fragsz;
15531 : :
15532 : 0 : to_trn_tbl[ecx++] = to_trn;
15533 : :
15534 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15535 : : buf = buf->next;
15536 : :
15537 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15538 : : rte_pktmbuf_tailroom(buf));
15539 : :
15540 : : /* OOP */
15541 [ # # ]: 0 : if (oop && !fragsz_oop) {
15542 : 0 : buf_last_oop = buf_oop->next =
15543 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
15544 : : buf_oop = buf_oop->next;
15545 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15546 : : 0, rte_pktmbuf_tailroom(buf_oop));
15547 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
15548 : : }
15549 : :
15550 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15551 : : to_trn);
15552 : :
15553 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15554 : : to_trn);
15555 : 0 : trn_data += to_trn;
15556 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15557 [ # # ]: 0 : if (oop) {
15558 [ # # ]: 0 : if (!fragsz_oop)
15559 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
15560 : 0 : tdata->auth_tag.len);
15561 : : } else
15562 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15563 : 0 : tdata->auth_tag.len);
15564 : : }
15565 : : }
15566 : :
15567 : : uint64_t digest_phys = 0;
15568 : :
15569 : 0 : ut_params->ibuf->nb_segs = segs;
15570 : :
15571 : : segs = 1;
15572 [ # # ]: 0 : if (fragsz_oop && oop) {
15573 : : to_trn = 0;
15574 : : ecx = 0;
15575 : :
15576 [ # # ]: 0 : if (frag_size_oop == tdata->plaintext.len) {
15577 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
15578 : 0 : tdata->auth_tag.len);
15579 : :
15580 : 0 : digest_phys = rte_pktmbuf_iova_offset(
15581 : : ut_params->obuf,
15582 : : tdata->plaintext.len + prepend_len);
15583 : : }
15584 : :
15585 : : trn_data = frag_size_oop;
15586 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15587 : 0 : ++segs;
15588 : 0 : to_trn =
15589 : 0 : (tdata->plaintext.len - trn_data <
15590 : : frag_size_oop) ?
15591 : 0 : (tdata->plaintext.len - trn_data) :
15592 : : frag_size_oop;
15593 : :
15594 : 0 : to_trn_tbl[ecx++] = to_trn;
15595 : :
15596 : 0 : buf_last_oop = buf_oop->next =
15597 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
15598 : : buf_oop = buf_oop->next;
15599 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15600 : : 0, rte_pktmbuf_tailroom(buf_oop));
15601 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
15602 : :
15603 : 0 : trn_data += to_trn;
15604 : :
15605 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15606 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
15607 : 0 : tdata->auth_tag.len);
15608 : : }
15609 : : }
15610 : :
15611 : 0 : ut_params->obuf->nb_segs = segs;
15612 : : }
15613 : :
15614 : : /*
15615 : : * Place digest at the end of the last buffer
15616 : : */
15617 [ # # ]: 0 : if (!digest_phys)
15618 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15619 [ # # ]: 0 : if (oop && buf_last_oop)
15620 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
15621 : :
15622 [ # # ]: 0 : if (!digest_mem && !oop) {
15623 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15624 : 0 : + tdata->auth_tag.len);
15625 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15626 : : tdata->plaintext.len);
15627 : : }
15628 : :
15629 : : /* Create AEAD operation */
15630 : 0 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
15631 : : tdata, digest_mem, digest_phys);
15632 : :
15633 [ # # ]: 0 : if (retval < 0)
15634 : : return retval;
15635 : :
15636 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15637 : :
15638 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15639 [ # # ]: 0 : if (oop)
15640 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
15641 : :
15642 : : /* Process crypto operation */
15643 [ # # ]: 0 : if (oop == IN_PLACE &&
15644 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15645 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
15646 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15647 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
15648 : : 0);
15649 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15650 : : return retval;
15651 : : } else
15652 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15653 : : process_crypto_request(ts_params->valid_devs[0],
15654 : : ut_params->op), "failed to process sym crypto op");
15655 : :
15656 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15657 : : "crypto op processing failed");
15658 : :
15659 : :
15660 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
15661 : : uint8_t *, prepend_len);
15662 [ # # ]: 0 : if (oop) {
15663 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15664 : : uint8_t *, prepend_len);
15665 : : }
15666 : :
15667 [ # # ]: 0 : if (fragsz_oop)
15668 : : fragsz = fragsz_oop;
15669 : :
15670 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15671 : : ciphertext,
15672 : : tdata->ciphertext.data,
15673 : : fragsz,
15674 : : "Ciphertext data not as expected");
15675 : :
15676 : 0 : buf = ut_params->op->sym->m_src->next;
15677 [ # # ]: 0 : if (oop)
15678 : 0 : buf = ut_params->op->sym->m_dst->next;
15679 : :
15680 : : unsigned int off = fragsz;
15681 : :
15682 : : ecx = 0;
15683 [ # # ]: 0 : while (buf) {
15684 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
15685 : : uint8_t *);
15686 : :
15687 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15688 : : ciphertext,
15689 : : tdata->ciphertext.data + off,
15690 : : to_trn_tbl[ecx],
15691 : : "Ciphertext data not as expected");
15692 : :
15693 : 0 : off += to_trn_tbl[ecx++];
15694 : 0 : buf = buf->next;
15695 : : }
15696 : :
15697 : : auth_tag = digest_mem;
15698 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15699 : : auth_tag,
15700 : : tdata->auth_tag.data,
15701 : : tdata->auth_tag.len,
15702 : : "Generated auth tag not as expected");
15703 : :
15704 : : return 0;
15705 : : }
15706 : :
15707 : : static int
15708 : 0 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
15709 : : {
15710 : 0 : return test_authenticated_encryption_SGL(
15711 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
15712 : : }
15713 : :
15714 : : static int
15715 : 0 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
15716 : : {
15717 : 0 : return test_authenticated_encryption_SGL(
15718 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
15719 : : }
15720 : :
15721 : : static int
15722 : 0 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
15723 : : {
15724 : 0 : return test_authenticated_encryption_SGL(
15725 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
15726 : : gcm_test_case_8.plaintext.len);
15727 : : }
15728 : :
15729 : : static int
15730 : 0 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
15731 : : {
15732 : : /* This test is not for OPENSSL PMD */
15733 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
15734 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
15735 : : return TEST_SKIPPED;
15736 : :
15737 : 0 : return test_authenticated_encryption_SGL(
15738 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
15739 : : }
15740 : :
15741 : : static int
15742 : : test_authentication_verify_fail_when_data_corrupted(
15743 : : struct crypto_testsuite_params *ts_params,
15744 : : struct crypto_unittest_params *ut_params,
15745 : : const struct test_crypto_vector *reference)
15746 : : {
15747 : 0 : return test_authentication_verify_fail_when_data_corruption(
15748 : : ts_params, ut_params, reference, 1);
15749 : : }
15750 : :
15751 : : static int
15752 : : test_authentication_verify_fail_when_tag_corrupted(
15753 : : struct crypto_testsuite_params *ts_params,
15754 : : struct crypto_unittest_params *ut_params,
15755 : : const struct test_crypto_vector *reference)
15756 : : {
15757 : 0 : return test_authentication_verify_fail_when_data_corruption(
15758 : : ts_params, ut_params, reference, 0);
15759 : : }
15760 : :
15761 : : static int
15762 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
15763 : : struct crypto_testsuite_params *ts_params,
15764 : : struct crypto_unittest_params *ut_params,
15765 : : const struct test_crypto_vector *reference)
15766 : : {
15767 : 0 : return test_authentication_verify_GMAC_fail_when_corruption(
15768 : : ts_params, ut_params, reference, 1);
15769 : : }
15770 : :
15771 : : static int
15772 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
15773 : : struct crypto_testsuite_params *ts_params,
15774 : : struct crypto_unittest_params *ut_params,
15775 : : const struct test_crypto_vector *reference)
15776 : : {
15777 : 0 : return test_authentication_verify_GMAC_fail_when_corruption(
15778 : : ts_params, ut_params, reference, 0);
15779 : : }
15780 : :
15781 : : static int
15782 : : test_authenticated_decryption_fail_when_data_corrupted(
15783 : : struct crypto_testsuite_params *ts_params,
15784 : : struct crypto_unittest_params *ut_params,
15785 : : const struct test_crypto_vector *reference)
15786 : : {
15787 : 0 : return test_authenticated_decryption_fail_when_corruption(
15788 : : ts_params, ut_params, reference, 1);
15789 : : }
15790 : :
15791 : : static int
15792 : : test_authenticated_decryption_fail_when_tag_corrupted(
15793 : : struct crypto_testsuite_params *ts_params,
15794 : : struct crypto_unittest_params *ut_params,
15795 : : const struct test_crypto_vector *reference)
15796 : : {
15797 : 0 : return test_authenticated_decryption_fail_when_corruption(
15798 : : ts_params, ut_params, reference, 0);
15799 : : }
15800 : :
15801 : : static int
15802 : 0 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
15803 : : {
15804 : 0 : return test_authentication_verify_fail_when_data_corrupted(
15805 : : &testsuite_params, &unittest_params,
15806 : : &hmac_sha1_test_crypto_vector);
15807 : : }
15808 : :
15809 : : static int
15810 : 0 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
15811 : : {
15812 : 0 : return test_authentication_verify_fail_when_tag_corrupted(
15813 : : &testsuite_params, &unittest_params,
15814 : : &hmac_sha1_test_crypto_vector);
15815 : : }
15816 : :
15817 : : static int
15818 : 0 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
15819 : : {
15820 : 0 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
15821 : : &testsuite_params, &unittest_params,
15822 : : &aes128_gmac_test_vector);
15823 : : }
15824 : :
15825 : : static int
15826 : 0 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
15827 : : {
15828 : 0 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
15829 : : &testsuite_params, &unittest_params,
15830 : : &aes128_gmac_test_vector);
15831 : : }
15832 : :
15833 : : static int
15834 : 0 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
15835 : : {
15836 : 0 : return test_authenticated_decryption_fail_when_data_corrupted(
15837 : : &testsuite_params,
15838 : : &unittest_params,
15839 : : &aes128cbc_hmac_sha1_test_vector);
15840 : : }
15841 : :
15842 : : static int
15843 : 0 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
15844 : : {
15845 : 0 : return test_authenticated_decryption_fail_when_tag_corrupted(
15846 : : &testsuite_params,
15847 : : &unittest_params,
15848 : : &aes128cbc_hmac_sha1_test_vector);
15849 : : }
15850 : :
15851 : : static int
15852 : 0 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
15853 : : {
15854 : 0 : return test_authenticated_encrypt_with_esn(
15855 : : &testsuite_params,
15856 : : &unittest_params,
15857 : : &aes128cbc_hmac_sha1_aad_test_vector);
15858 : : }
15859 : :
15860 : : static int
15861 : 0 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
15862 : : {
15863 : 0 : return test_authenticated_decrypt_with_esn(
15864 : : &testsuite_params,
15865 : : &unittest_params,
15866 : : &aes128cbc_hmac_sha1_aad_test_vector);
15867 : : }
15868 : :
15869 : : static int
15870 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
15871 : : {
15872 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
15873 : : }
15874 : :
15875 : : static int
15876 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
15877 : : {
15878 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
15879 : : }
15880 : :
15881 : : static int
15882 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
15883 : : {
15884 : 0 : return test_authenticated_encryption_SGL(
15885 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
15886 : : chacha20_poly1305_case_2.plaintext.len);
15887 : : }
15888 : :
15889 : : #ifdef RTE_CRYPTO_SCHEDULER
15890 : :
15891 : : /* global AESNI worker IDs for the scheduler test */
15892 : : uint8_t aesni_ids[2];
15893 : :
15894 : : static int
15895 : 0 : scheduler_testsuite_setup(void)
15896 : : {
15897 : : uint32_t i = 0;
15898 : : int32_t nb_devs, ret;
15899 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
15900 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
15901 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
15902 : : uint16_t worker_core_count = 0;
15903 : : uint16_t socket_id = 0;
15904 : :
15905 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
15906 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
15907 : :
15908 : : /* Identify the Worker Cores
15909 : : * Use 2 worker cores for the device args
15910 : : */
15911 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
15912 [ # # ]: 0 : if (worker_core_count > 1)
15913 : : break;
15914 : : snprintf(vdev_args, sizeof(vdev_args),
15915 : : "%s%d", temp_str, i);
15916 : : strcpy(temp_str, vdev_args);
15917 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
15918 : 0 : worker_core_count++;
15919 : 0 : socket_id = rte_lcore_to_socket_id(i);
15920 : : }
15921 [ # # ]: 0 : if (worker_core_count != 2) {
15922 : 0 : RTE_LOG(ERR, USER1,
15923 : : "Cryptodev scheduler test require at least "
15924 : : "two worker cores to run. "
15925 : : "Please use the correct coremask.\n");
15926 : 0 : return TEST_FAILED;
15927 : : }
15928 : : strcpy(temp_str, vdev_args);
15929 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
15930 : : temp_str, socket_id);
15931 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
15932 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
15933 : 0 : rte_cryptodev_driver_id_get(
15934 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
15935 [ # # ]: 0 : if (nb_devs < 1) {
15936 : 0 : ret = rte_vdev_init(
15937 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
15938 : : vdev_args);
15939 [ # # ]: 0 : TEST_ASSERT(ret == 0,
15940 : : "Failed to create instance %u of pmd : %s",
15941 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15942 : : }
15943 : : }
15944 : 0 : return testsuite_setup();
15945 : : }
15946 : :
15947 : : static int
15948 : 0 : test_scheduler_attach_worker_op(void)
15949 : : {
15950 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15951 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
15952 : : uint32_t i, nb_devs_attached = 0;
15953 : : int ret;
15954 : : char vdev_name[32];
15955 : 0 : unsigned int count = rte_cryptodev_count();
15956 : :
15957 : : /* create 2 AESNI_MB vdevs on top of existing devices */
15958 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
15959 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
15960 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
15961 : : i);
15962 : 0 : ret = rte_vdev_init(vdev_name, NULL);
15963 : :
15964 [ # # ]: 0 : TEST_ASSERT(ret == 0,
15965 : : "Failed to create instance %u of"
15966 : : " pmd : %s",
15967 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15968 : :
15969 : : if (ret < 0) {
15970 : : RTE_LOG(ERR, USER1,
15971 : : "Failed to create 2 AESNI MB PMDs.\n");
15972 : : return TEST_SKIPPED;
15973 : : }
15974 : : }
15975 : :
15976 : : /* attach 2 AESNI_MB cdevs */
15977 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
15978 : : struct rte_cryptodev_info info;
15979 : : unsigned int session_size;
15980 : :
15981 : 0 : rte_cryptodev_info_get(i, &info);
15982 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
15983 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
15984 : 0 : continue;
15985 : :
15986 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
15987 : : /*
15988 : : * Create the session mempool again, since now there are new devices
15989 : : * to use the mempool.
15990 : : */
15991 [ # # ]: 0 : if (ts_params->session_mpool) {
15992 : 0 : rte_mempool_free(ts_params->session_mpool);
15993 : 0 : ts_params->session_mpool = NULL;
15994 : : }
15995 : :
15996 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
15997 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
15998 : 0 : RTE_LOG(ERR, USER1,
15999 : : "Device does not support "
16000 : : "at least %u sessions\n",
16001 : : MAX_NB_SESSIONS);
16002 : 0 : return TEST_FAILED;
16003 : : }
16004 : : /*
16005 : : * Create mempool with maximum number of sessions,
16006 : : * to include the session headers
16007 : : */
16008 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
16009 : 0 : ts_params->session_mpool =
16010 : 0 : rte_cryptodev_sym_session_pool_create(
16011 : : "test_sess_mp",
16012 : : MAX_NB_SESSIONS, session_size,
16013 : : 0, 0, SOCKET_ID_ANY);
16014 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
16015 : : "session mempool allocation failed");
16016 : : }
16017 : :
16018 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
16019 : :
16020 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
16021 : : (uint8_t)i);
16022 : :
16023 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16024 : : "Failed to attach device %u of pmd : %s", i,
16025 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16026 : :
16027 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
16028 : :
16029 : 0 : nb_devs_attached++;
16030 : : }
16031 : :
16032 : : return 0;
16033 : : }
16034 : :
16035 : : static int
16036 : 0 : test_scheduler_detach_worker_op(void)
16037 : : {
16038 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16039 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16040 : : uint32_t i;
16041 : : int ret;
16042 : :
16043 [ # # ]: 0 : for (i = 0; i < 2; i++) {
16044 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
16045 : 0 : aesni_ids[i]);
16046 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16047 : : "Failed to detach device %u", aesni_ids[i]);
16048 : : }
16049 : :
16050 : : return 0;
16051 : : }
16052 : :
16053 : : static int
16054 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
16055 : : {
16056 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16057 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16058 : : /* set mode */
16059 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
16060 : : scheduler_mode);
16061 : : }
16062 : :
16063 : : static int
16064 : 0 : test_scheduler_mode_roundrobin_op(void)
16065 : : {
16066 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
16067 : : 0, "Failed to set roundrobin mode");
16068 : : return 0;
16069 : :
16070 : : }
16071 : :
16072 : : static int
16073 : 0 : test_scheduler_mode_multicore_op(void)
16074 : : {
16075 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
16076 : : 0, "Failed to set multicore mode");
16077 : :
16078 : : return 0;
16079 : : }
16080 : :
16081 : : static int
16082 : 0 : test_scheduler_mode_failover_op(void)
16083 : : {
16084 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
16085 : : 0, "Failed to set failover mode");
16086 : :
16087 : : return 0;
16088 : : }
16089 : :
16090 : : static int
16091 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
16092 : : {
16093 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
16094 : : 0, "Failed to set pktsize mode");
16095 : :
16096 : : return 0;
16097 : : }
16098 : :
16099 : : static int
16100 : 0 : scheduler_multicore_testsuite_setup(void)
16101 : : {
16102 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16103 : : return TEST_SKIPPED;
16104 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
16105 : 0 : return TEST_SKIPPED;
16106 : : return 0;
16107 : : }
16108 : :
16109 : : static int
16110 : 0 : scheduler_roundrobin_testsuite_setup(void)
16111 : : {
16112 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16113 : : return TEST_SKIPPED;
16114 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
16115 : 0 : return TEST_SKIPPED;
16116 : : return 0;
16117 : : }
16118 : :
16119 : : static int
16120 : 0 : scheduler_failover_testsuite_setup(void)
16121 : : {
16122 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16123 : : return TEST_SKIPPED;
16124 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
16125 : 0 : return TEST_SKIPPED;
16126 : : return 0;
16127 : : }
16128 : :
16129 : : static int
16130 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
16131 : : {
16132 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16133 : : return TEST_SKIPPED;
16134 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
16135 : 0 : return TEST_SKIPPED;
16136 : : return 0;
16137 : : }
16138 : :
16139 : : static void
16140 : 0 : scheduler_mode_testsuite_teardown(void)
16141 : : {
16142 : 0 : test_scheduler_detach_worker_op();
16143 : 0 : }
16144 : :
16145 : : #endif /* RTE_CRYPTO_SCHEDULER */
16146 : :
16147 : : static struct unit_test_suite end_testsuite = {
16148 : : .suite_name = NULL,
16149 : : .setup = NULL,
16150 : : .teardown = NULL,
16151 : : .unit_test_suites = NULL
16152 : : };
16153 : :
16154 : : #ifdef RTE_LIB_SECURITY
16155 : : static struct unit_test_suite ipsec_proto_testsuite = {
16156 : : .suite_name = "IPsec Proto Unit Test Suite",
16157 : : .setup = ipsec_proto_testsuite_setup,
16158 : : .unit_test_cases = {
16159 : : TEST_CASE_NAMED_WITH_DATA(
16160 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16161 : : ut_setup_security, ut_teardown,
16162 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
16163 : : TEST_CASE_NAMED_WITH_DATA(
16164 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
16165 : : ut_setup_security, ut_teardown,
16166 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
16167 : : TEST_CASE_NAMED_WITH_DATA(
16168 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16169 : : ut_setup_security, ut_teardown,
16170 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
16171 : : TEST_CASE_NAMED_WITH_DATA(
16172 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16173 : : ut_setup_security, ut_teardown,
16174 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
16175 : : TEST_CASE_NAMED_WITH_DATA(
16176 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16177 : : ut_setup_security, ut_teardown,
16178 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
16179 : : TEST_CASE_NAMED_WITH_DATA(
16180 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16181 : : ut_setup_security, ut_teardown,
16182 : : test_ipsec_proto_known_vec,
16183 : : &pkt_aes_128_cbc_md5),
16184 : : TEST_CASE_NAMED_WITH_DATA(
16185 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16186 : : ut_setup_security, ut_teardown,
16187 : : test_ipsec_proto_known_vec,
16188 : : &pkt_aes_128_cbc_hmac_sha256),
16189 : : TEST_CASE_NAMED_WITH_DATA(
16190 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16191 : : ut_setup_security, ut_teardown,
16192 : : test_ipsec_proto_known_vec,
16193 : : &pkt_aes_128_cbc_hmac_sha384),
16194 : : TEST_CASE_NAMED_WITH_DATA(
16195 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16196 : : ut_setup_security, ut_teardown,
16197 : : test_ipsec_proto_known_vec,
16198 : : &pkt_aes_128_cbc_hmac_sha512),
16199 : : TEST_CASE_NAMED_WITH_DATA(
16200 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16201 : : ut_setup_security, ut_teardown,
16202 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
16203 : : TEST_CASE_NAMED_WITH_DATA(
16204 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16205 : : ut_setup_security, ut_teardown,
16206 : : test_ipsec_proto_known_vec,
16207 : : &pkt_aes_128_cbc_hmac_sha256_v6),
16208 : : TEST_CASE_NAMED_WITH_DATA(
16209 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16210 : : ut_setup_security, ut_teardown,
16211 : : test_ipsec_proto_known_vec,
16212 : : &pkt_null_aes_xcbc),
16213 : : TEST_CASE_NAMED_WITH_DATA(
16214 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16215 : : ut_setup_security, ut_teardown,
16216 : : test_ipsec_proto_known_vec,
16217 : : &pkt_des_cbc_hmac_sha256),
16218 : : TEST_CASE_NAMED_WITH_DATA(
16219 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16220 : : ut_setup_security, ut_teardown,
16221 : : test_ipsec_proto_known_vec,
16222 : : &pkt_des_cbc_hmac_sha384),
16223 : : TEST_CASE_NAMED_WITH_DATA(
16224 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16225 : : ut_setup_security, ut_teardown,
16226 : : test_ipsec_proto_known_vec,
16227 : : &pkt_des_cbc_hmac_sha512),
16228 : : TEST_CASE_NAMED_WITH_DATA(
16229 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16230 : : ut_setup_security, ut_teardown,
16231 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
16232 : : TEST_CASE_NAMED_WITH_DATA(
16233 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16234 : : ut_setup_security, ut_teardown,
16235 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
16236 : : TEST_CASE_NAMED_WITH_DATA(
16237 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16238 : : ut_setup_security, ut_teardown,
16239 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
16240 : : TEST_CASE_NAMED_WITH_DATA(
16241 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16242 : : ut_setup_security, ut_teardown,
16243 : : test_ipsec_proto_known_vec,
16244 : : &pkt_des_cbc_hmac_sha256_v6),
16245 : : TEST_CASE_NAMED_WITH_DATA(
16246 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16247 : : ut_setup_security, ut_teardown,
16248 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
16249 : : TEST_CASE_NAMED_WITH_DATA(
16250 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16251 : : ut_setup_security, ut_teardown,
16252 : : test_ipsec_proto_known_vec,
16253 : : &pkt_ah_tunnel_sha256),
16254 : : TEST_CASE_NAMED_WITH_DATA(
16255 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16256 : : ut_setup_security, ut_teardown,
16257 : : test_ipsec_proto_known_vec,
16258 : : &pkt_ah_transport_sha256),
16259 : : TEST_CASE_NAMED_WITH_DATA(
16260 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16261 : : ut_setup_security, ut_teardown,
16262 : : test_ipsec_proto_known_vec,
16263 : : &pkt_ah_ipv4_aes_gmac_128),
16264 : : TEST_CASE_NAMED_WITH_DATA(
16265 : : "Outbound fragmented packet",
16266 : : ut_setup_security, ut_teardown,
16267 : : test_ipsec_proto_known_vec_fragmented,
16268 : : &pkt_aes_128_gcm_frag),
16269 : : TEST_CASE_NAMED_WITH_DATA(
16270 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16271 : : ut_setup_security, ut_teardown,
16272 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
16273 : : TEST_CASE_NAMED_WITH_DATA(
16274 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16275 : : ut_setup_security, ut_teardown,
16276 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
16277 : : TEST_CASE_NAMED_WITH_DATA(
16278 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16279 : : ut_setup_security, ut_teardown,
16280 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
16281 : : TEST_CASE_NAMED_WITH_DATA(
16282 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16283 : : ut_setup_security, ut_teardown,
16284 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
16285 : : TEST_CASE_NAMED_WITH_DATA(
16286 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
16287 : : ut_setup_security, ut_teardown,
16288 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
16289 : : TEST_CASE_NAMED_WITH_DATA(
16290 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16291 : : ut_setup_security, ut_teardown,
16292 : : test_ipsec_proto_known_vec_inb,
16293 : : &pkt_aes_128_cbc_md5),
16294 : : TEST_CASE_NAMED_WITH_DATA(
16295 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16296 : : ut_setup_security, ut_teardown,
16297 : : test_ipsec_proto_known_vec_inb,
16298 : : &pkt_aes_128_cbc_hmac_sha256),
16299 : : TEST_CASE_NAMED_WITH_DATA(
16300 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16301 : : ut_setup_security, ut_teardown,
16302 : : test_ipsec_proto_known_vec_inb,
16303 : : &pkt_aes_128_cbc_hmac_sha384),
16304 : : TEST_CASE_NAMED_WITH_DATA(
16305 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16306 : : ut_setup_security, ut_teardown,
16307 : : test_ipsec_proto_known_vec_inb,
16308 : : &pkt_aes_128_cbc_hmac_sha512),
16309 : : TEST_CASE_NAMED_WITH_DATA(
16310 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16311 : : ut_setup_security, ut_teardown,
16312 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
16313 : : TEST_CASE_NAMED_WITH_DATA(
16314 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16315 : : ut_setup_security, ut_teardown,
16316 : : test_ipsec_proto_known_vec_inb,
16317 : : &pkt_aes_128_cbc_hmac_sha256_v6),
16318 : : TEST_CASE_NAMED_WITH_DATA(
16319 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16320 : : ut_setup_security, ut_teardown,
16321 : : test_ipsec_proto_known_vec_inb,
16322 : : &pkt_null_aes_xcbc),
16323 : : TEST_CASE_NAMED_WITH_DATA(
16324 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16325 : : ut_setup_security, ut_teardown,
16326 : : test_ipsec_proto_known_vec_inb,
16327 : : &pkt_des_cbc_hmac_sha256),
16328 : : TEST_CASE_NAMED_WITH_DATA(
16329 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16330 : : ut_setup_security, ut_teardown,
16331 : : test_ipsec_proto_known_vec_inb,
16332 : : &pkt_des_cbc_hmac_sha384),
16333 : : TEST_CASE_NAMED_WITH_DATA(
16334 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16335 : : ut_setup_security, ut_teardown,
16336 : : test_ipsec_proto_known_vec_inb,
16337 : : &pkt_des_cbc_hmac_sha512),
16338 : : TEST_CASE_NAMED_WITH_DATA(
16339 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16340 : : ut_setup_security, ut_teardown,
16341 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
16342 : : TEST_CASE_NAMED_WITH_DATA(
16343 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16344 : : ut_setup_security, ut_teardown,
16345 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
16346 : : TEST_CASE_NAMED_WITH_DATA(
16347 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16348 : : ut_setup_security, ut_teardown,
16349 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
16350 : : TEST_CASE_NAMED_WITH_DATA(
16351 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16352 : : ut_setup_security, ut_teardown,
16353 : : test_ipsec_proto_known_vec_inb,
16354 : : &pkt_des_cbc_hmac_sha256_v6),
16355 : : TEST_CASE_NAMED_WITH_DATA(
16356 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16357 : : ut_setup_security, ut_teardown,
16358 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
16359 : : TEST_CASE_NAMED_WITH_DATA(
16360 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16361 : : ut_setup_security, ut_teardown,
16362 : : test_ipsec_proto_known_vec_inb,
16363 : : &pkt_ah_tunnel_sha256),
16364 : : TEST_CASE_NAMED_WITH_DATA(
16365 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16366 : : ut_setup_security, ut_teardown,
16367 : : test_ipsec_proto_known_vec_inb,
16368 : : &pkt_ah_transport_sha256),
16369 : : TEST_CASE_NAMED_WITH_DATA(
16370 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16371 : : ut_setup_security, ut_teardown,
16372 : : test_ipsec_proto_known_vec_inb,
16373 : : &pkt_ah_ipv4_aes_gmac_128),
16374 : : TEST_CASE_NAMED_ST(
16375 : : "Combined test alg list",
16376 : : ut_setup_security, ut_teardown,
16377 : : test_ipsec_proto_display_list),
16378 : : TEST_CASE_NAMED_ST(
16379 : : "Combined test alg list (AH)",
16380 : : ut_setup_security, ut_teardown,
16381 : : test_ipsec_proto_ah_tunnel_ipv4),
16382 : : TEST_CASE_NAMED_ST(
16383 : : "IV generation",
16384 : : ut_setup_security, ut_teardown,
16385 : : test_ipsec_proto_iv_gen),
16386 : : TEST_CASE_NAMED_ST(
16387 : : "UDP encapsulation",
16388 : : ut_setup_security, ut_teardown,
16389 : : test_ipsec_proto_udp_encap),
16390 : : TEST_CASE_NAMED_ST(
16391 : : "UDP encapsulation with custom ports",
16392 : : ut_setup_security, ut_teardown,
16393 : : test_ipsec_proto_udp_encap_custom_ports),
16394 : : TEST_CASE_NAMED_ST(
16395 : : "UDP encapsulation ports verification test",
16396 : : ut_setup_security, ut_teardown,
16397 : : test_ipsec_proto_udp_ports_verify),
16398 : : TEST_CASE_NAMED_ST(
16399 : : "SA expiry packets soft",
16400 : : ut_setup_security, ut_teardown,
16401 : : test_ipsec_proto_sa_exp_pkts_soft),
16402 : : TEST_CASE_NAMED_ST(
16403 : : "SA expiry packets hard",
16404 : : ut_setup_security, ut_teardown,
16405 : : test_ipsec_proto_sa_exp_pkts_hard),
16406 : : TEST_CASE_NAMED_ST(
16407 : : "Negative test: ICV corruption",
16408 : : ut_setup_security, ut_teardown,
16409 : : test_ipsec_proto_err_icv_corrupt),
16410 : : TEST_CASE_NAMED_ST(
16411 : : "Tunnel dst addr verification",
16412 : : ut_setup_security, ut_teardown,
16413 : : test_ipsec_proto_tunnel_dst_addr_verify),
16414 : : TEST_CASE_NAMED_ST(
16415 : : "Tunnel src and dst addr verification",
16416 : : ut_setup_security, ut_teardown,
16417 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
16418 : : TEST_CASE_NAMED_ST(
16419 : : "Inner IP checksum",
16420 : : ut_setup_security, ut_teardown,
16421 : : test_ipsec_proto_inner_ip_csum),
16422 : : TEST_CASE_NAMED_ST(
16423 : : "Inner L4 checksum",
16424 : : ut_setup_security, ut_teardown,
16425 : : test_ipsec_proto_inner_l4_csum),
16426 : : TEST_CASE_NAMED_ST(
16427 : : "Tunnel IPv4 in IPv4",
16428 : : ut_setup_security, ut_teardown,
16429 : : test_ipsec_proto_tunnel_v4_in_v4),
16430 : : TEST_CASE_NAMED_ST(
16431 : : "Tunnel IPv6 in IPv6",
16432 : : ut_setup_security, ut_teardown,
16433 : : test_ipsec_proto_tunnel_v6_in_v6),
16434 : : TEST_CASE_NAMED_ST(
16435 : : "Tunnel IPv4 in IPv6",
16436 : : ut_setup_security, ut_teardown,
16437 : : test_ipsec_proto_tunnel_v4_in_v6),
16438 : : TEST_CASE_NAMED_ST(
16439 : : "Tunnel IPv6 in IPv4",
16440 : : ut_setup_security, ut_teardown,
16441 : : test_ipsec_proto_tunnel_v6_in_v4),
16442 : : TEST_CASE_NAMED_ST(
16443 : : "Transport IPv4",
16444 : : ut_setup_security, ut_teardown,
16445 : : test_ipsec_proto_transport_v4),
16446 : : TEST_CASE_NAMED_ST(
16447 : : "AH transport IPv4",
16448 : : ut_setup_security, ut_teardown,
16449 : : test_ipsec_proto_ah_transport_ipv4),
16450 : : TEST_CASE_NAMED_ST(
16451 : : "Transport l4 checksum",
16452 : : ut_setup_security, ut_teardown,
16453 : : test_ipsec_proto_transport_l4_csum),
16454 : : TEST_CASE_NAMED_ST(
16455 : : "Statistics: success",
16456 : : ut_setup_security, ut_teardown,
16457 : : test_ipsec_proto_stats),
16458 : : TEST_CASE_NAMED_ST(
16459 : : "Fragmented packet",
16460 : : ut_setup_security, ut_teardown,
16461 : : test_ipsec_proto_pkt_fragment),
16462 : : TEST_CASE_NAMED_ST(
16463 : : "Tunnel header copy DF (inner 0)",
16464 : : ut_setup_security, ut_teardown,
16465 : : test_ipsec_proto_copy_df_inner_0),
16466 : : TEST_CASE_NAMED_ST(
16467 : : "Tunnel header copy DF (inner 1)",
16468 : : ut_setup_security, ut_teardown,
16469 : : test_ipsec_proto_copy_df_inner_1),
16470 : : TEST_CASE_NAMED_ST(
16471 : : "Tunnel header set DF 0 (inner 1)",
16472 : : ut_setup_security, ut_teardown,
16473 : : test_ipsec_proto_set_df_0_inner_1),
16474 : : TEST_CASE_NAMED_ST(
16475 : : "Tunnel header set DF 1 (inner 0)",
16476 : : ut_setup_security, ut_teardown,
16477 : : test_ipsec_proto_set_df_1_inner_0),
16478 : : TEST_CASE_NAMED_ST(
16479 : : "Tunnel header IPv4 copy DSCP (inner 0)",
16480 : : ut_setup_security, ut_teardown,
16481 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
16482 : : TEST_CASE_NAMED_ST(
16483 : : "Tunnel header IPv4 copy DSCP (inner 1)",
16484 : : ut_setup_security, ut_teardown,
16485 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
16486 : : TEST_CASE_NAMED_ST(
16487 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
16488 : : ut_setup_security, ut_teardown,
16489 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
16490 : : TEST_CASE_NAMED_ST(
16491 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
16492 : : ut_setup_security, ut_teardown,
16493 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
16494 : : TEST_CASE_NAMED_ST(
16495 : : "Tunnel header IPv6 copy DSCP (inner 0)",
16496 : : ut_setup_security, ut_teardown,
16497 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
16498 : : TEST_CASE_NAMED_ST(
16499 : : "Tunnel header IPv6 copy DSCP (inner 1)",
16500 : : ut_setup_security, ut_teardown,
16501 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
16502 : : TEST_CASE_NAMED_ST(
16503 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
16504 : : ut_setup_security, ut_teardown,
16505 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
16506 : : TEST_CASE_NAMED_ST(
16507 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
16508 : : ut_setup_security, ut_teardown,
16509 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
16510 : : TEST_CASE_NAMED_WITH_DATA(
16511 : : "Antireplay with window size 1024",
16512 : : ut_setup_security, ut_teardown,
16513 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
16514 : : TEST_CASE_NAMED_WITH_DATA(
16515 : : "Antireplay with window size 2048",
16516 : : ut_setup_security, ut_teardown,
16517 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
16518 : : TEST_CASE_NAMED_WITH_DATA(
16519 : : "Antireplay with window size 4096",
16520 : : ut_setup_security, ut_teardown,
16521 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
16522 : : TEST_CASE_NAMED_WITH_DATA(
16523 : : "ESN and Antireplay with window size 1024",
16524 : : ut_setup_security, ut_teardown,
16525 : : test_ipsec_proto_pkt_esn_antireplay1024,
16526 : : &pkt_aes_128_gcm),
16527 : : TEST_CASE_NAMED_WITH_DATA(
16528 : : "ESN and Antireplay with window size 2048",
16529 : : ut_setup_security, ut_teardown,
16530 : : test_ipsec_proto_pkt_esn_antireplay2048,
16531 : : &pkt_aes_128_gcm),
16532 : : TEST_CASE_NAMED_WITH_DATA(
16533 : : "ESN and Antireplay with window size 4096",
16534 : : ut_setup_security, ut_teardown,
16535 : : test_ipsec_proto_pkt_esn_antireplay4096,
16536 : : &pkt_aes_128_gcm),
16537 : : TEST_CASE_NAMED_ST(
16538 : : "Tunnel header IPv4 decrement inner TTL",
16539 : : ut_setup_security, ut_teardown,
16540 : : test_ipsec_proto_ipv4_ttl_decrement),
16541 : : TEST_CASE_NAMED_ST(
16542 : : "Tunnel header IPv6 decrement inner hop limit",
16543 : : ut_setup_security, ut_teardown,
16544 : : test_ipsec_proto_ipv6_hop_limit_decrement),
16545 : : TEST_CASE_NAMED_ST(
16546 : : "Multi-segmented mode",
16547 : : ut_setup_security, ut_teardown,
16548 : : test_ipsec_proto_sgl),
16549 : : TEST_CASE_NAMED_ST(
16550 : : "Multi-segmented external mbuf mode",
16551 : : ut_setup_security, ut_teardown,
16552 : : test_ipsec_proto_sgl_ext_mbuf),
16553 : : TEST_CASE_NAMED_WITH_DATA(
16554 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
16555 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
16556 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
16557 : : TEST_CASES_END() /**< NULL terminate unit test array */
16558 : : }
16559 : : };
16560 : :
16561 : : static struct unit_test_suite pdcp_proto_testsuite = {
16562 : : .suite_name = "PDCP Proto Unit Test Suite",
16563 : : .setup = pdcp_proto_testsuite_setup,
16564 : : .unit_test_cases = {
16565 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
16566 : : test_PDCP_PROTO_all),
16567 : : TEST_CASES_END() /**< NULL terminate unit test array */
16568 : : }
16569 : : };
16570 : :
16571 : : #define ADD_UPLINK_TESTCASE(data) \
16572 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
16573 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
16574 : :
16575 : : #define ADD_DOWNLINK_TESTCASE(data) \
16576 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
16577 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
16578 : :
16579 : : static struct unit_test_suite docsis_proto_testsuite = {
16580 : : .suite_name = "DOCSIS Proto Unit Test Suite",
16581 : : .setup = docsis_proto_testsuite_setup,
16582 : : .unit_test_cases = {
16583 : : /* Uplink */
16584 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
16585 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
16586 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
16587 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
16588 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
16589 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
16590 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
16591 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
16592 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
16593 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
16594 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
16595 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
16596 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
16597 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
16598 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
16599 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
16600 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
16601 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
16602 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
16603 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
16604 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
16605 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
16606 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
16607 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
16608 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
16609 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
16610 : : /* Downlink */
16611 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
16612 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
16613 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
16614 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
16615 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
16616 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
16617 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
16618 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
16619 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
16620 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
16621 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
16622 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
16623 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
16624 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
16625 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
16626 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
16627 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
16628 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
16629 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
16630 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
16631 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
16632 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
16633 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
16634 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
16635 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
16636 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
16637 : : TEST_CASES_END() /**< NULL terminate unit test array */
16638 : : }
16639 : : };
16640 : : #endif
16641 : :
16642 : : static struct unit_test_suite cryptodev_gen_testsuite = {
16643 : : .suite_name = "Crypto General Unit Test Suite",
16644 : : .setup = crypto_gen_testsuite_setup,
16645 : : .unit_test_cases = {
16646 : : TEST_CASE_ST(ut_setup, ut_teardown,
16647 : : test_device_reconfigure),
16648 : : TEST_CASE_ST(ut_setup, ut_teardown,
16649 : : test_device_configure_invalid_dev_id),
16650 : : TEST_CASE_ST(ut_setup, ut_teardown,
16651 : : test_queue_pair_descriptor_setup),
16652 : : TEST_CASE_ST(ut_setup, ut_teardown,
16653 : : test_device_configure_invalid_queue_pair_ids),
16654 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
16655 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
16656 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
16657 : : TEST_CASES_END() /**< NULL terminate unit test array */
16658 : : }
16659 : : };
16660 : :
16661 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
16662 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
16663 : : .setup = negative_hmac_sha1_testsuite_setup,
16664 : : .unit_test_cases = {
16665 : : /** Negative tests */
16666 : : TEST_CASE_ST(ut_setup, ut_teardown,
16667 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
16668 : : TEST_CASE_ST(ut_setup, ut_teardown,
16669 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
16670 : : TEST_CASE_ST(ut_setup, ut_teardown,
16671 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
16672 : : TEST_CASE_ST(ut_setup, ut_teardown,
16673 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
16674 : :
16675 : : TEST_CASES_END() /**< NULL terminate unit test array */
16676 : : }
16677 : : };
16678 : :
16679 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
16680 : : .suite_name = "Multi Session Unit Test Suite",
16681 : : .setup = multi_session_testsuite_setup,
16682 : : .unit_test_cases = {
16683 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
16684 : : TEST_CASE_ST(ut_setup, ut_teardown,
16685 : : test_multi_session_random_usage),
16686 : :
16687 : : TEST_CASES_END() /**< NULL terminate unit test array */
16688 : : }
16689 : : };
16690 : :
16691 : : static struct unit_test_suite cryptodev_null_testsuite = {
16692 : : .suite_name = "NULL Test Suite",
16693 : : .setup = null_testsuite_setup,
16694 : : .unit_test_cases = {
16695 : : TEST_CASE_ST(ut_setup, ut_teardown,
16696 : : test_null_invalid_operation),
16697 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
16698 : : TEST_CASES_END()
16699 : : }
16700 : : };
16701 : :
16702 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
16703 : : .suite_name = "AES CCM Authenticated Test Suite",
16704 : : .setup = aes_ccm_auth_testsuite_setup,
16705 : : .unit_test_cases = {
16706 : : /** AES CCM Authenticated Encryption 128 bits key*/
16707 : : TEST_CASE_ST(ut_setup, ut_teardown,
16708 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
16709 : : TEST_CASE_ST(ut_setup, ut_teardown,
16710 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
16711 : : TEST_CASE_ST(ut_setup, ut_teardown,
16712 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
16713 : :
16714 : : /** AES CCM Authenticated Decryption 128 bits key*/
16715 : : TEST_CASE_ST(ut_setup, ut_teardown,
16716 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
16717 : : TEST_CASE_ST(ut_setup, ut_teardown,
16718 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
16719 : : TEST_CASE_ST(ut_setup, ut_teardown,
16720 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
16721 : :
16722 : : /** AES CCM Authenticated Encryption 192 bits key */
16723 : : TEST_CASE_ST(ut_setup, ut_teardown,
16724 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
16725 : : TEST_CASE_ST(ut_setup, ut_teardown,
16726 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
16727 : : TEST_CASE_ST(ut_setup, ut_teardown,
16728 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
16729 : :
16730 : : /** AES CCM Authenticated Decryption 192 bits key*/
16731 : : TEST_CASE_ST(ut_setup, ut_teardown,
16732 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
16733 : : TEST_CASE_ST(ut_setup, ut_teardown,
16734 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
16735 : : TEST_CASE_ST(ut_setup, ut_teardown,
16736 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
16737 : :
16738 : : /** AES CCM Authenticated Encryption 256 bits key */
16739 : : TEST_CASE_ST(ut_setup, ut_teardown,
16740 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
16741 : : TEST_CASE_ST(ut_setup, ut_teardown,
16742 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
16743 : : TEST_CASE_ST(ut_setup, ut_teardown,
16744 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
16745 : :
16746 : : /** AES CCM Authenticated Decryption 256 bits key*/
16747 : : TEST_CASE_ST(ut_setup, ut_teardown,
16748 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
16749 : : TEST_CASE_ST(ut_setup, ut_teardown,
16750 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
16751 : : TEST_CASE_ST(ut_setup, ut_teardown,
16752 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
16753 : : TEST_CASES_END()
16754 : : }
16755 : : };
16756 : :
16757 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
16758 : : .suite_name = "AES GCM Authenticated Test Suite",
16759 : : .setup = aes_gcm_auth_testsuite_setup,
16760 : : .unit_test_cases = {
16761 : : /** AES GCM Authenticated Encryption */
16762 : : TEST_CASE_ST(ut_setup, ut_teardown,
16763 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
16764 : : TEST_CASE_ST(ut_setup, ut_teardown,
16765 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
16766 : : TEST_CASE_ST(ut_setup, ut_teardown,
16767 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
16768 : : TEST_CASE_ST(ut_setup, ut_teardown,
16769 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
16770 : : TEST_CASE_ST(ut_setup, ut_teardown,
16771 : : test_AES_GCM_authenticated_encryption_test_case_1),
16772 : : TEST_CASE_ST(ut_setup, ut_teardown,
16773 : : test_AES_GCM_authenticated_encryption_test_case_2),
16774 : : TEST_CASE_ST(ut_setup, ut_teardown,
16775 : : test_AES_GCM_authenticated_encryption_test_case_3),
16776 : : TEST_CASE_ST(ut_setup, ut_teardown,
16777 : : test_AES_GCM_authenticated_encryption_test_case_4),
16778 : : TEST_CASE_ST(ut_setup, ut_teardown,
16779 : : test_AES_GCM_authenticated_encryption_test_case_5),
16780 : : TEST_CASE_ST(ut_setup, ut_teardown,
16781 : : test_AES_GCM_authenticated_encryption_test_case_6),
16782 : : TEST_CASE_ST(ut_setup, ut_teardown,
16783 : : test_AES_GCM_authenticated_encryption_test_case_7),
16784 : : TEST_CASE_ST(ut_setup, ut_teardown,
16785 : : test_AES_GCM_authenticated_encryption_test_case_8),
16786 : : TEST_CASE_ST(ut_setup, ut_teardown,
16787 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
16788 : :
16789 : : /** AES GCM Authenticated Decryption */
16790 : : TEST_CASE_ST(ut_setup, ut_teardown,
16791 : : test_AES_GCM_authenticated_decryption_test_case_1),
16792 : : TEST_CASE_ST(ut_setup, ut_teardown,
16793 : : test_AES_GCM_authenticated_decryption_test_case_2),
16794 : : TEST_CASE_ST(ut_setup, ut_teardown,
16795 : : test_AES_GCM_authenticated_decryption_test_case_3),
16796 : : TEST_CASE_ST(ut_setup, ut_teardown,
16797 : : test_AES_GCM_authenticated_decryption_test_case_4),
16798 : : TEST_CASE_ST(ut_setup, ut_teardown,
16799 : : test_AES_GCM_authenticated_decryption_test_case_5),
16800 : : TEST_CASE_ST(ut_setup, ut_teardown,
16801 : : test_AES_GCM_authenticated_decryption_test_case_6),
16802 : : TEST_CASE_ST(ut_setup, ut_teardown,
16803 : : test_AES_GCM_authenticated_decryption_test_case_7),
16804 : : TEST_CASE_ST(ut_setup, ut_teardown,
16805 : : test_AES_GCM_authenticated_decryption_test_case_8),
16806 : : TEST_CASE_ST(ut_setup, ut_teardown,
16807 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
16808 : :
16809 : : /** AES GCM Authenticated Encryption 192 bits key */
16810 : : TEST_CASE_ST(ut_setup, ut_teardown,
16811 : : test_AES_GCM_auth_encryption_test_case_192_1),
16812 : : TEST_CASE_ST(ut_setup, ut_teardown,
16813 : : test_AES_GCM_auth_encryption_test_case_192_2),
16814 : : TEST_CASE_ST(ut_setup, ut_teardown,
16815 : : test_AES_GCM_auth_encryption_test_case_192_3),
16816 : : TEST_CASE_ST(ut_setup, ut_teardown,
16817 : : test_AES_GCM_auth_encryption_test_case_192_4),
16818 : : TEST_CASE_ST(ut_setup, ut_teardown,
16819 : : test_AES_GCM_auth_encryption_test_case_192_5),
16820 : : TEST_CASE_ST(ut_setup, ut_teardown,
16821 : : test_AES_GCM_auth_encryption_test_case_192_6),
16822 : : TEST_CASE_ST(ut_setup, ut_teardown,
16823 : : test_AES_GCM_auth_encryption_test_case_192_7),
16824 : :
16825 : : /** AES GCM Authenticated Decryption 192 bits key */
16826 : : TEST_CASE_ST(ut_setup, ut_teardown,
16827 : : test_AES_GCM_auth_decryption_test_case_192_1),
16828 : : TEST_CASE_ST(ut_setup, ut_teardown,
16829 : : test_AES_GCM_auth_decryption_test_case_192_2),
16830 : : TEST_CASE_ST(ut_setup, ut_teardown,
16831 : : test_AES_GCM_auth_decryption_test_case_192_3),
16832 : : TEST_CASE_ST(ut_setup, ut_teardown,
16833 : : test_AES_GCM_auth_decryption_test_case_192_4),
16834 : : TEST_CASE_ST(ut_setup, ut_teardown,
16835 : : test_AES_GCM_auth_decryption_test_case_192_5),
16836 : : TEST_CASE_ST(ut_setup, ut_teardown,
16837 : : test_AES_GCM_auth_decryption_test_case_192_6),
16838 : : TEST_CASE_ST(ut_setup, ut_teardown,
16839 : : test_AES_GCM_auth_decryption_test_case_192_7),
16840 : :
16841 : : /** AES GCM Authenticated Encryption 256 bits key */
16842 : : TEST_CASE_ST(ut_setup, ut_teardown,
16843 : : test_AES_GCM_auth_encryption_test_case_256_1),
16844 : : TEST_CASE_ST(ut_setup, ut_teardown,
16845 : : test_AES_GCM_auth_encryption_test_case_256_2),
16846 : : TEST_CASE_ST(ut_setup, ut_teardown,
16847 : : test_AES_GCM_auth_encryption_test_case_256_3),
16848 : : TEST_CASE_ST(ut_setup, ut_teardown,
16849 : : test_AES_GCM_auth_encryption_test_case_256_4),
16850 : : TEST_CASE_ST(ut_setup, ut_teardown,
16851 : : test_AES_GCM_auth_encryption_test_case_256_5),
16852 : : TEST_CASE_ST(ut_setup, ut_teardown,
16853 : : test_AES_GCM_auth_encryption_test_case_256_6),
16854 : : TEST_CASE_ST(ut_setup, ut_teardown,
16855 : : test_AES_GCM_auth_encryption_test_case_256_7),
16856 : :
16857 : : /** AES GCM Authenticated Decryption 256 bits key */
16858 : : TEST_CASE_ST(ut_setup, ut_teardown,
16859 : : test_AES_GCM_auth_decryption_test_case_256_1),
16860 : : TEST_CASE_ST(ut_setup, ut_teardown,
16861 : : test_AES_GCM_auth_decryption_test_case_256_2),
16862 : : TEST_CASE_ST(ut_setup, ut_teardown,
16863 : : test_AES_GCM_auth_decryption_test_case_256_3),
16864 : : TEST_CASE_ST(ut_setup, ut_teardown,
16865 : : test_AES_GCM_auth_decryption_test_case_256_4),
16866 : : TEST_CASE_ST(ut_setup, ut_teardown,
16867 : : test_AES_GCM_auth_decryption_test_case_256_5),
16868 : : TEST_CASE_ST(ut_setup, ut_teardown,
16869 : : test_AES_GCM_auth_decryption_test_case_256_6),
16870 : : TEST_CASE_ST(ut_setup, ut_teardown,
16871 : : test_AES_GCM_auth_decryption_test_case_256_7),
16872 : :
16873 : : /** AES GCM Authenticated Encryption big aad size */
16874 : : TEST_CASE_ST(ut_setup, ut_teardown,
16875 : : test_AES_GCM_auth_encryption_test_case_aad_1),
16876 : : TEST_CASE_ST(ut_setup, ut_teardown,
16877 : : test_AES_GCM_auth_encryption_test_case_aad_2),
16878 : :
16879 : : /** AES GCM Authenticated Decryption big aad size */
16880 : : TEST_CASE_ST(ut_setup, ut_teardown,
16881 : : test_AES_GCM_auth_decryption_test_case_aad_1),
16882 : : TEST_CASE_ST(ut_setup, ut_teardown,
16883 : : test_AES_GCM_auth_decryption_test_case_aad_2),
16884 : :
16885 : : /** Out of place tests */
16886 : : TEST_CASE_ST(ut_setup, ut_teardown,
16887 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
16888 : : TEST_CASE_ST(ut_setup, ut_teardown,
16889 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
16890 : :
16891 : : /** Session-less tests */
16892 : : TEST_CASE_ST(ut_setup, ut_teardown,
16893 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
16894 : : TEST_CASE_ST(ut_setup, ut_teardown,
16895 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
16896 : :
16897 : : TEST_CASES_END()
16898 : : }
16899 : : };
16900 : :
16901 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
16902 : : .suite_name = "AES GMAC Authentication Test Suite",
16903 : : .setup = aes_gmac_auth_testsuite_setup,
16904 : : .unit_test_cases = {
16905 : : TEST_CASE_ST(ut_setup, ut_teardown,
16906 : : test_AES_GMAC_authentication_test_case_1),
16907 : : TEST_CASE_ST(ut_setup, ut_teardown,
16908 : : test_AES_GMAC_authentication_verify_test_case_1),
16909 : : TEST_CASE_ST(ut_setup, ut_teardown,
16910 : : test_AES_GMAC_authentication_test_case_2),
16911 : : TEST_CASE_ST(ut_setup, ut_teardown,
16912 : : test_AES_GMAC_authentication_verify_test_case_2),
16913 : : TEST_CASE_ST(ut_setup, ut_teardown,
16914 : : test_AES_GMAC_authentication_test_case_3),
16915 : : TEST_CASE_ST(ut_setup, ut_teardown,
16916 : : test_AES_GMAC_authentication_verify_test_case_3),
16917 : : TEST_CASE_ST(ut_setup, ut_teardown,
16918 : : test_AES_GMAC_authentication_test_case_4),
16919 : : TEST_CASE_ST(ut_setup, ut_teardown,
16920 : : test_AES_GMAC_authentication_verify_test_case_4),
16921 : : TEST_CASE_ST(ut_setup, ut_teardown,
16922 : : test_AES_GMAC_authentication_SGL_40B),
16923 : : TEST_CASE_ST(ut_setup, ut_teardown,
16924 : : test_AES_GMAC_authentication_SGL_80B),
16925 : : TEST_CASE_ST(ut_setup, ut_teardown,
16926 : : test_AES_GMAC_authentication_SGL_2048B),
16927 : : TEST_CASE_ST(ut_setup, ut_teardown,
16928 : : test_AES_GMAC_authentication_SGL_2047B),
16929 : :
16930 : : TEST_CASES_END()
16931 : : }
16932 : : };
16933 : :
16934 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
16935 : : .suite_name = "Chacha20-Poly1305 Test Suite",
16936 : : .setup = chacha20_poly1305_testsuite_setup,
16937 : : .unit_test_cases = {
16938 : : TEST_CASE_ST(ut_setup, ut_teardown,
16939 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
16940 : : TEST_CASE_ST(ut_setup, ut_teardown,
16941 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
16942 : : TEST_CASE_ST(ut_setup, ut_teardown,
16943 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
16944 : : TEST_CASES_END()
16945 : : }
16946 : : };
16947 : :
16948 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
16949 : : .suite_name = "SNOW 3G Test Suite",
16950 : : .setup = snow3g_testsuite_setup,
16951 : : .unit_test_cases = {
16952 : : /** SNOW 3G encrypt only (UEA2) */
16953 : : TEST_CASE_ST(ut_setup, ut_teardown,
16954 : : test_snow3g_encryption_test_case_1),
16955 : : TEST_CASE_ST(ut_setup, ut_teardown,
16956 : : test_snow3g_encryption_test_case_2),
16957 : : TEST_CASE_ST(ut_setup, ut_teardown,
16958 : : test_snow3g_encryption_test_case_3),
16959 : : TEST_CASE_ST(ut_setup, ut_teardown,
16960 : : test_snow3g_encryption_test_case_4),
16961 : : TEST_CASE_ST(ut_setup, ut_teardown,
16962 : : test_snow3g_encryption_test_case_5),
16963 : :
16964 : : TEST_CASE_ST(ut_setup, ut_teardown,
16965 : : test_snow3g_encryption_test_case_1_oop),
16966 : : TEST_CASE_ST(ut_setup, ut_teardown,
16967 : : test_snow3g_encryption_test_case_1_oop_sgl),
16968 : : TEST_CASE_ST(ut_setup, ut_teardown,
16969 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
16970 : : TEST_CASE_ST(ut_setup, ut_teardown,
16971 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
16972 : : TEST_CASE_ST(ut_setup, ut_teardown,
16973 : : test_snow3g_encryption_test_case_1_offset_oop),
16974 : : TEST_CASE_ST(ut_setup, ut_teardown,
16975 : : test_snow3g_decryption_test_case_1_oop),
16976 : :
16977 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
16978 : : TEST_CASE_ST(ut_setup, ut_teardown,
16979 : : test_snow3g_auth_cipher_test_case_1),
16980 : : TEST_CASE_ST(ut_setup, ut_teardown,
16981 : : test_snow3g_auth_cipher_test_case_2),
16982 : : TEST_CASE_ST(ut_setup, ut_teardown,
16983 : : test_snow3g_auth_cipher_test_case_2_oop),
16984 : : TEST_CASE_ST(ut_setup, ut_teardown,
16985 : : test_snow3g_auth_cipher_part_digest_enc),
16986 : : TEST_CASE_ST(ut_setup, ut_teardown,
16987 : : test_snow3g_auth_cipher_part_digest_enc_oop),
16988 : : TEST_CASE_ST(ut_setup, ut_teardown,
16989 : : test_snow3g_auth_cipher_test_case_3_sgl),
16990 : : TEST_CASE_ST(ut_setup, ut_teardown,
16991 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
16992 : : TEST_CASE_ST(ut_setup, ut_teardown,
16993 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
16994 : : TEST_CASE_ST(ut_setup, ut_teardown,
16995 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
16996 : : TEST_CASE_ST(ut_setup, ut_teardown,
16997 : : test_snow3g_auth_cipher_total_digest_enc_1),
16998 : : TEST_CASE_ST(ut_setup, ut_teardown,
16999 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
17000 : : TEST_CASE_ST(ut_setup, ut_teardown,
17001 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
17002 : : TEST_CASE_ST(ut_setup, ut_teardown,
17003 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
17004 : :
17005 : : /** SNOW 3G decrypt (UEA2), then verify auth */
17006 : : TEST_CASE_ST(ut_setup, ut_teardown,
17007 : : test_snow3g_auth_cipher_verify_test_case_1),
17008 : : TEST_CASE_ST(ut_setup, ut_teardown,
17009 : : test_snow3g_auth_cipher_verify_test_case_2),
17010 : : TEST_CASE_ST(ut_setup, ut_teardown,
17011 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
17012 : : TEST_CASE_ST(ut_setup, ut_teardown,
17013 : : test_snow3g_auth_cipher_verify_part_digest_enc),
17014 : : TEST_CASE_ST(ut_setup, ut_teardown,
17015 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
17016 : : TEST_CASE_ST(ut_setup, ut_teardown,
17017 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
17018 : : TEST_CASE_ST(ut_setup, ut_teardown,
17019 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
17020 : : TEST_CASE_ST(ut_setup, ut_teardown,
17021 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
17022 : : TEST_CASE_ST(ut_setup, ut_teardown,
17023 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
17024 : : TEST_CASE_ST(ut_setup, ut_teardown,
17025 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
17026 : : TEST_CASE_ST(ut_setup, ut_teardown,
17027 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
17028 : : TEST_CASE_ST(ut_setup, ut_teardown,
17029 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
17030 : : TEST_CASE_ST(ut_setup, ut_teardown,
17031 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
17032 : :
17033 : : /** SNOW 3G decrypt only (UEA2) */
17034 : : TEST_CASE_ST(ut_setup, ut_teardown,
17035 : : test_snow3g_decryption_test_case_1),
17036 : : TEST_CASE_ST(ut_setup, ut_teardown,
17037 : : test_snow3g_decryption_test_case_2),
17038 : : TEST_CASE_ST(ut_setup, ut_teardown,
17039 : : test_snow3g_decryption_test_case_3),
17040 : : TEST_CASE_ST(ut_setup, ut_teardown,
17041 : : test_snow3g_decryption_test_case_4),
17042 : : TEST_CASE_ST(ut_setup, ut_teardown,
17043 : : test_snow3g_decryption_test_case_5),
17044 : : TEST_CASE_ST(ut_setup, ut_teardown,
17045 : : test_snow3g_decryption_with_digest_test_case_1),
17046 : : TEST_CASE_ST(ut_setup, ut_teardown,
17047 : : test_snow3g_hash_generate_test_case_1),
17048 : : TEST_CASE_ST(ut_setup, ut_teardown,
17049 : : test_snow3g_hash_generate_test_case_2),
17050 : : TEST_CASE_ST(ut_setup, ut_teardown,
17051 : : test_snow3g_hash_generate_test_case_3),
17052 : :
17053 : : /* Tests with buffers which length is not byte-aligned */
17054 : : TEST_CASE_ST(ut_setup, ut_teardown,
17055 : : test_snow3g_hash_generate_test_case_4),
17056 : : TEST_CASE_ST(ut_setup, ut_teardown,
17057 : : test_snow3g_hash_generate_test_case_5),
17058 : : TEST_CASE_ST(ut_setup, ut_teardown,
17059 : : test_snow3g_hash_generate_test_case_6),
17060 : : TEST_CASE_ST(ut_setup, ut_teardown,
17061 : : test_snow3g_hash_verify_test_case_1),
17062 : : TEST_CASE_ST(ut_setup, ut_teardown,
17063 : : test_snow3g_hash_verify_test_case_2),
17064 : : TEST_CASE_ST(ut_setup, ut_teardown,
17065 : : test_snow3g_hash_verify_test_case_3),
17066 : :
17067 : : /* Tests with buffers which length is not byte-aligned */
17068 : : TEST_CASE_ST(ut_setup, ut_teardown,
17069 : : test_snow3g_hash_verify_test_case_4),
17070 : : TEST_CASE_ST(ut_setup, ut_teardown,
17071 : : test_snow3g_hash_verify_test_case_5),
17072 : : TEST_CASE_ST(ut_setup, ut_teardown,
17073 : : test_snow3g_hash_verify_test_case_6),
17074 : : TEST_CASE_ST(ut_setup, ut_teardown,
17075 : : test_snow3g_cipher_auth_test_case_1),
17076 : : TEST_CASE_ST(ut_setup, ut_teardown,
17077 : : test_snow3g_auth_cipher_with_digest_test_case_1),
17078 : : TEST_CASES_END()
17079 : : }
17080 : : };
17081 : :
17082 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
17083 : : .suite_name = "ZUC Test Suite",
17084 : : .setup = zuc_testsuite_setup,
17085 : : .unit_test_cases = {
17086 : : /** ZUC encrypt only (EEA3) */
17087 : : TEST_CASE_ST(ut_setup, ut_teardown,
17088 : : test_zuc_encryption_test_case_1),
17089 : : TEST_CASE_ST(ut_setup, ut_teardown,
17090 : : test_zuc_encryption_test_case_2),
17091 : : TEST_CASE_ST(ut_setup, ut_teardown,
17092 : : test_zuc_encryption_test_case_3),
17093 : : TEST_CASE_ST(ut_setup, ut_teardown,
17094 : : test_zuc_encryption_test_case_4),
17095 : : TEST_CASE_ST(ut_setup, ut_teardown,
17096 : : test_zuc_encryption_test_case_5),
17097 : : TEST_CASE_ST(ut_setup, ut_teardown,
17098 : : test_zuc_encryption_test_case_6_sgl),
17099 : :
17100 : : /** ZUC decrypt only (EEA3) */
17101 : : TEST_CASE_ST(ut_setup, ut_teardown,
17102 : : test_zuc_decryption_test_case_1),
17103 : : TEST_CASE_ST(ut_setup, ut_teardown,
17104 : : test_zuc_decryption_test_case_2),
17105 : : TEST_CASE_ST(ut_setup, ut_teardown,
17106 : : test_zuc_decryption_test_case_3),
17107 : : TEST_CASE_ST(ut_setup, ut_teardown,
17108 : : test_zuc_decryption_test_case_4),
17109 : : TEST_CASE_ST(ut_setup, ut_teardown,
17110 : : test_zuc_decryption_test_case_5),
17111 : : TEST_CASE_ST(ut_setup, ut_teardown,
17112 : : test_zuc_decryption_test_case_6_sgl),
17113 : :
17114 : : /** ZUC authenticate (EIA3) */
17115 : : TEST_CASE_ST(ut_setup, ut_teardown,
17116 : : test_zuc_hash_generate_test_case_1),
17117 : : TEST_CASE_ST(ut_setup, ut_teardown,
17118 : : test_zuc_hash_generate_test_case_2),
17119 : : TEST_CASE_ST(ut_setup, ut_teardown,
17120 : : test_zuc_hash_generate_test_case_3),
17121 : : TEST_CASE_ST(ut_setup, ut_teardown,
17122 : : test_zuc_hash_generate_test_case_4),
17123 : : TEST_CASE_ST(ut_setup, ut_teardown,
17124 : : test_zuc_hash_generate_test_case_5),
17125 : : TEST_CASE_ST(ut_setup, ut_teardown,
17126 : : test_zuc_hash_generate_test_case_6),
17127 : : TEST_CASE_ST(ut_setup, ut_teardown,
17128 : : test_zuc_hash_generate_test_case_7),
17129 : : TEST_CASE_ST(ut_setup, ut_teardown,
17130 : : test_zuc_hash_generate_test_case_8),
17131 : :
17132 : : /** ZUC verify (EIA3) */
17133 : : TEST_CASE_ST(ut_setup, ut_teardown,
17134 : : test_zuc_hash_verify_test_case_1),
17135 : : TEST_CASE_ST(ut_setup, ut_teardown,
17136 : : test_zuc_hash_verify_test_case_2),
17137 : : TEST_CASE_ST(ut_setup, ut_teardown,
17138 : : test_zuc_hash_verify_test_case_3),
17139 : : TEST_CASE_ST(ut_setup, ut_teardown,
17140 : : test_zuc_hash_verify_test_case_4),
17141 : : TEST_CASE_ST(ut_setup, ut_teardown,
17142 : : test_zuc_hash_verify_test_case_5),
17143 : : TEST_CASE_ST(ut_setup, ut_teardown,
17144 : : test_zuc_hash_verify_test_case_6),
17145 : : TEST_CASE_ST(ut_setup, ut_teardown,
17146 : : test_zuc_hash_verify_test_case_7),
17147 : : TEST_CASE_ST(ut_setup, ut_teardown,
17148 : : test_zuc_hash_verify_test_case_8),
17149 : :
17150 : : /** ZUC alg-chain (EEA3/EIA3) */
17151 : : TEST_CASE_ST(ut_setup, ut_teardown,
17152 : : test_zuc_cipher_auth_test_case_1),
17153 : : TEST_CASE_ST(ut_setup, ut_teardown,
17154 : : test_zuc_cipher_auth_test_case_2),
17155 : :
17156 : : /** ZUC generate auth, then encrypt (EEA3) */
17157 : : TEST_CASE_ST(ut_setup, ut_teardown,
17158 : : test_zuc_auth_cipher_test_case_1),
17159 : : TEST_CASE_ST(ut_setup, ut_teardown,
17160 : : test_zuc_auth_cipher_test_case_1_oop),
17161 : : TEST_CASE_ST(ut_setup, ut_teardown,
17162 : : test_zuc_auth_cipher_test_case_1_sgl),
17163 : : TEST_CASE_ST(ut_setup, ut_teardown,
17164 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
17165 : : TEST_CASE_ST(ut_setup, ut_teardown,
17166 : : test_zuc_auth_cipher_test_case_2),
17167 : : TEST_CASE_ST(ut_setup, ut_teardown,
17168 : : test_zuc_auth_cipher_test_case_2_oop),
17169 : :
17170 : : /** ZUC decrypt (EEA3), then verify auth */
17171 : : TEST_CASE_ST(ut_setup, ut_teardown,
17172 : : test_zuc_auth_cipher_verify_test_case_1),
17173 : : TEST_CASE_ST(ut_setup, ut_teardown,
17174 : : test_zuc_auth_cipher_verify_test_case_1_oop),
17175 : : TEST_CASE_ST(ut_setup, ut_teardown,
17176 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
17177 : : TEST_CASE_ST(ut_setup, ut_teardown,
17178 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
17179 : : TEST_CASE_ST(ut_setup, ut_teardown,
17180 : : test_zuc_auth_cipher_verify_test_case_2),
17181 : : TEST_CASE_ST(ut_setup, ut_teardown,
17182 : : test_zuc_auth_cipher_verify_test_case_2_oop),
17183 : :
17184 : : /** ZUC-256 encrypt only **/
17185 : : TEST_CASE_ST(ut_setup, ut_teardown,
17186 : : test_zuc256_encryption_test_case_1),
17187 : : TEST_CASE_ST(ut_setup, ut_teardown,
17188 : : test_zuc256_encryption_test_case_2),
17189 : :
17190 : : /** ZUC-256 decrypt only **/
17191 : : TEST_CASE_ST(ut_setup, ut_teardown,
17192 : : test_zuc256_decryption_test_case_1),
17193 : : TEST_CASE_ST(ut_setup, ut_teardown,
17194 : : test_zuc256_decryption_test_case_2),
17195 : :
17196 : : /** ZUC-256 authentication only **/
17197 : : TEST_CASE_ST(ut_setup, ut_teardown,
17198 : : test_zuc256_hash_generate_4b_tag_test_case_1),
17199 : : TEST_CASE_ST(ut_setup, ut_teardown,
17200 : : test_zuc256_hash_generate_4b_tag_test_case_2),
17201 : : TEST_CASE_ST(ut_setup, ut_teardown,
17202 : : test_zuc256_hash_generate_4b_tag_test_case_3),
17203 : : TEST_CASE_ST(ut_setup, ut_teardown,
17204 : : test_zuc256_hash_generate_8b_tag_test_case_1),
17205 : : TEST_CASE_ST(ut_setup, ut_teardown,
17206 : : test_zuc256_hash_generate_16b_tag_test_case_1),
17207 : :
17208 : : /** ZUC-256 authentication verify only **/
17209 : : TEST_CASE_ST(ut_setup, ut_teardown,
17210 : : test_zuc256_hash_verify_4b_tag_test_case_1),
17211 : : TEST_CASE_ST(ut_setup, ut_teardown,
17212 : : test_zuc256_hash_verify_4b_tag_test_case_2),
17213 : : TEST_CASE_ST(ut_setup, ut_teardown,
17214 : : test_zuc256_hash_verify_4b_tag_test_case_3),
17215 : : TEST_CASE_ST(ut_setup, ut_teardown,
17216 : : test_zuc256_hash_verify_8b_tag_test_case_1),
17217 : : TEST_CASE_ST(ut_setup, ut_teardown,
17218 : : test_zuc256_hash_verify_16b_tag_test_case_1),
17219 : :
17220 : : /** ZUC-256 encrypt and authenticate **/
17221 : : TEST_CASE_ST(ut_setup, ut_teardown,
17222 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
17223 : : TEST_CASE_ST(ut_setup, ut_teardown,
17224 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
17225 : : TEST_CASE_ST(ut_setup, ut_teardown,
17226 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
17227 : : TEST_CASE_ST(ut_setup, ut_teardown,
17228 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
17229 : :
17230 : : /** ZUC-256 generate auth, then encrypt */
17231 : : TEST_CASE_ST(ut_setup, ut_teardown,
17232 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
17233 : : TEST_CASE_ST(ut_setup, ut_teardown,
17234 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
17235 : : TEST_CASE_ST(ut_setup, ut_teardown,
17236 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
17237 : : TEST_CASE_ST(ut_setup, ut_teardown,
17238 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
17239 : :
17240 : : /** ZUC-256 decrypt, then verify auth */
17241 : : TEST_CASE_ST(ut_setup, ut_teardown,
17242 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
17243 : : TEST_CASE_ST(ut_setup, ut_teardown,
17244 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
17245 : : TEST_CASE_ST(ut_setup, ut_teardown,
17246 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
17247 : : TEST_CASE_ST(ut_setup, ut_teardown,
17248 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
17249 : :
17250 : : TEST_CASES_END()
17251 : : }
17252 : : };
17253 : :
17254 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
17255 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
17256 : : .setup = hmac_md5_auth_testsuite_setup,
17257 : : .unit_test_cases = {
17258 : : TEST_CASE_ST(ut_setup, ut_teardown,
17259 : : test_MD5_HMAC_generate_case_1),
17260 : : TEST_CASE_ST(ut_setup, ut_teardown,
17261 : : test_MD5_HMAC_verify_case_1),
17262 : : TEST_CASE_ST(ut_setup, ut_teardown,
17263 : : test_MD5_HMAC_generate_case_2),
17264 : : TEST_CASE_ST(ut_setup, ut_teardown,
17265 : : test_MD5_HMAC_verify_case_2),
17266 : : TEST_CASES_END()
17267 : : }
17268 : : };
17269 : :
17270 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
17271 : : .suite_name = "Kasumi Test Suite",
17272 : : .setup = kasumi_testsuite_setup,
17273 : : .unit_test_cases = {
17274 : : /** KASUMI hash only (UIA1) */
17275 : : TEST_CASE_ST(ut_setup, ut_teardown,
17276 : : test_kasumi_hash_generate_test_case_1),
17277 : : TEST_CASE_ST(ut_setup, ut_teardown,
17278 : : test_kasumi_hash_generate_test_case_2),
17279 : : TEST_CASE_ST(ut_setup, ut_teardown,
17280 : : test_kasumi_hash_generate_test_case_3),
17281 : : TEST_CASE_ST(ut_setup, ut_teardown,
17282 : : test_kasumi_hash_generate_test_case_4),
17283 : : TEST_CASE_ST(ut_setup, ut_teardown,
17284 : : test_kasumi_hash_generate_test_case_5),
17285 : : TEST_CASE_ST(ut_setup, ut_teardown,
17286 : : test_kasumi_hash_generate_test_case_6),
17287 : :
17288 : : TEST_CASE_ST(ut_setup, ut_teardown,
17289 : : test_kasumi_hash_verify_test_case_1),
17290 : : TEST_CASE_ST(ut_setup, ut_teardown,
17291 : : test_kasumi_hash_verify_test_case_2),
17292 : : TEST_CASE_ST(ut_setup, ut_teardown,
17293 : : test_kasumi_hash_verify_test_case_3),
17294 : : TEST_CASE_ST(ut_setup, ut_teardown,
17295 : : test_kasumi_hash_verify_test_case_4),
17296 : : TEST_CASE_ST(ut_setup, ut_teardown,
17297 : : test_kasumi_hash_verify_test_case_5),
17298 : :
17299 : : /** KASUMI encrypt only (UEA1) */
17300 : : TEST_CASE_ST(ut_setup, ut_teardown,
17301 : : test_kasumi_encryption_test_case_1),
17302 : : TEST_CASE_ST(ut_setup, ut_teardown,
17303 : : test_kasumi_encryption_test_case_1_sgl),
17304 : : TEST_CASE_ST(ut_setup, ut_teardown,
17305 : : test_kasumi_encryption_test_case_1_oop),
17306 : : TEST_CASE_ST(ut_setup, ut_teardown,
17307 : : test_kasumi_encryption_test_case_1_oop_sgl),
17308 : : TEST_CASE_ST(ut_setup, ut_teardown,
17309 : : test_kasumi_encryption_test_case_2),
17310 : : TEST_CASE_ST(ut_setup, ut_teardown,
17311 : : test_kasumi_encryption_test_case_3),
17312 : : TEST_CASE_ST(ut_setup, ut_teardown,
17313 : : test_kasumi_encryption_test_case_4),
17314 : : TEST_CASE_ST(ut_setup, ut_teardown,
17315 : : test_kasumi_encryption_test_case_5),
17316 : :
17317 : : /** KASUMI decrypt only (UEA1) */
17318 : : TEST_CASE_ST(ut_setup, ut_teardown,
17319 : : test_kasumi_decryption_test_case_1),
17320 : : TEST_CASE_ST(ut_setup, ut_teardown,
17321 : : test_kasumi_decryption_test_case_2),
17322 : : TEST_CASE_ST(ut_setup, ut_teardown,
17323 : : test_kasumi_decryption_test_case_3),
17324 : : TEST_CASE_ST(ut_setup, ut_teardown,
17325 : : test_kasumi_decryption_test_case_4),
17326 : : TEST_CASE_ST(ut_setup, ut_teardown,
17327 : : test_kasumi_decryption_test_case_5),
17328 : : TEST_CASE_ST(ut_setup, ut_teardown,
17329 : : test_kasumi_decryption_test_case_1_oop),
17330 : : TEST_CASE_ST(ut_setup, ut_teardown,
17331 : : test_kasumi_cipher_auth_test_case_1),
17332 : :
17333 : : /** KASUMI generate auth, then encrypt (F8) */
17334 : : TEST_CASE_ST(ut_setup, ut_teardown,
17335 : : test_kasumi_auth_cipher_test_case_1),
17336 : : TEST_CASE_ST(ut_setup, ut_teardown,
17337 : : test_kasumi_auth_cipher_test_case_2),
17338 : : TEST_CASE_ST(ut_setup, ut_teardown,
17339 : : test_kasumi_auth_cipher_test_case_2_oop),
17340 : : TEST_CASE_ST(ut_setup, ut_teardown,
17341 : : test_kasumi_auth_cipher_test_case_2_sgl),
17342 : : TEST_CASE_ST(ut_setup, ut_teardown,
17343 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
17344 : :
17345 : : /** KASUMI decrypt (F8), then verify auth */
17346 : : TEST_CASE_ST(ut_setup, ut_teardown,
17347 : : test_kasumi_auth_cipher_verify_test_case_1),
17348 : : TEST_CASE_ST(ut_setup, ut_teardown,
17349 : : test_kasumi_auth_cipher_verify_test_case_2),
17350 : : TEST_CASE_ST(ut_setup, ut_teardown,
17351 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
17352 : : TEST_CASE_ST(ut_setup, ut_teardown,
17353 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
17354 : : TEST_CASE_ST(ut_setup, ut_teardown,
17355 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
17356 : :
17357 : : TEST_CASES_END()
17358 : : }
17359 : : };
17360 : :
17361 : : static struct unit_test_suite cryptodev_esn_testsuite = {
17362 : : .suite_name = "ESN Test Suite",
17363 : : .setup = esn_testsuite_setup,
17364 : : .unit_test_cases = {
17365 : : TEST_CASE_ST(ut_setup, ut_teardown,
17366 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
17367 : : TEST_CASE_ST(ut_setup, ut_teardown,
17368 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
17369 : : TEST_CASES_END()
17370 : : }
17371 : : };
17372 : :
17373 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
17374 : : .suite_name = "Negative AES GCM Test Suite",
17375 : : .setup = negative_aes_gcm_testsuite_setup,
17376 : : .unit_test_cases = {
17377 : : TEST_CASE_ST(ut_setup, ut_teardown,
17378 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
17379 : : TEST_CASE_ST(ut_setup, ut_teardown,
17380 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
17381 : : TEST_CASE_ST(ut_setup, ut_teardown,
17382 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
17383 : : TEST_CASE_ST(ut_setup, ut_teardown,
17384 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
17385 : : TEST_CASE_ST(ut_setup, ut_teardown,
17386 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
17387 : : TEST_CASE_ST(ut_setup, ut_teardown,
17388 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
17389 : : TEST_CASE_ST(ut_setup, ut_teardown,
17390 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
17391 : : TEST_CASE_ST(ut_setup, ut_teardown,
17392 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
17393 : : TEST_CASE_ST(ut_setup, ut_teardown,
17394 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
17395 : : TEST_CASE_ST(ut_setup, ut_teardown,
17396 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
17397 : : TEST_CASE_ST(ut_setup, ut_teardown,
17398 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
17399 : : TEST_CASE_ST(ut_setup, ut_teardown,
17400 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
17401 : :
17402 : : TEST_CASES_END()
17403 : : }
17404 : : };
17405 : :
17406 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
17407 : : .suite_name = "Negative AES GMAC Test Suite",
17408 : : .setup = negative_aes_gmac_testsuite_setup,
17409 : : .unit_test_cases = {
17410 : : TEST_CASE_ST(ut_setup, ut_teardown,
17411 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
17412 : : TEST_CASE_ST(ut_setup, ut_teardown,
17413 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
17414 : :
17415 : : TEST_CASES_END()
17416 : : }
17417 : : };
17418 : :
17419 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
17420 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
17421 : : .setup = mixed_cipher_hash_testsuite_setup,
17422 : : .unit_test_cases = {
17423 : : /** AUTH AES CMAC + CIPHER AES CTR */
17424 : : TEST_CASE_ST(ut_setup, ut_teardown,
17425 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
17426 : : TEST_CASE_ST(ut_setup, ut_teardown,
17427 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17428 : : TEST_CASE_ST(ut_setup, ut_teardown,
17429 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17430 : : TEST_CASE_ST(ut_setup, ut_teardown,
17431 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17432 : : TEST_CASE_ST(ut_setup, ut_teardown,
17433 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
17434 : : TEST_CASE_ST(ut_setup, ut_teardown,
17435 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17436 : : TEST_CASE_ST(ut_setup, ut_teardown,
17437 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17438 : : TEST_CASE_ST(ut_setup, ut_teardown,
17439 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17440 : : TEST_CASE_ST(ut_setup, ut_teardown,
17441 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
17442 : : TEST_CASE_ST(ut_setup, ut_teardown,
17443 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17444 : : TEST_CASE_ST(ut_setup, ut_teardown,
17445 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
17446 : : TEST_CASE_ST(ut_setup, ut_teardown,
17447 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17448 : :
17449 : : /** AUTH ZUC + CIPHER SNOW3G */
17450 : : TEST_CASE_ST(ut_setup, ut_teardown,
17451 : : test_auth_zuc_cipher_snow_test_case_1),
17452 : : TEST_CASE_ST(ut_setup, ut_teardown,
17453 : : test_verify_auth_zuc_cipher_snow_test_case_1),
17454 : : TEST_CASE_ST(ut_setup, ut_teardown,
17455 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
17456 : : TEST_CASE_ST(ut_setup, ut_teardown,
17457 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
17458 : : /** AUTH AES CMAC + CIPHER SNOW3G */
17459 : : TEST_CASE_ST(ut_setup, ut_teardown,
17460 : : test_auth_aes_cmac_cipher_snow_test_case_1),
17461 : : TEST_CASE_ST(ut_setup, ut_teardown,
17462 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
17463 : : TEST_CASE_ST(ut_setup, ut_teardown,
17464 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
17465 : : TEST_CASE_ST(ut_setup, ut_teardown,
17466 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
17467 : : /** AUTH ZUC + CIPHER AES CTR */
17468 : : TEST_CASE_ST(ut_setup, ut_teardown,
17469 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
17470 : : TEST_CASE_ST(ut_setup, ut_teardown,
17471 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
17472 : : TEST_CASE_ST(ut_setup, ut_teardown,
17473 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
17474 : : TEST_CASE_ST(ut_setup, ut_teardown,
17475 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
17476 : : /** AUTH SNOW3G + CIPHER AES CTR */
17477 : : TEST_CASE_ST(ut_setup, ut_teardown,
17478 : : test_auth_snow_cipher_aes_ctr_test_case_1),
17479 : : TEST_CASE_ST(ut_setup, ut_teardown,
17480 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
17481 : : TEST_CASE_ST(ut_setup, ut_teardown,
17482 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
17483 : : TEST_CASE_ST(ut_setup, ut_teardown,
17484 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
17485 : : TEST_CASE_ST(ut_setup, ut_teardown,
17486 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
17487 : : TEST_CASE_ST(ut_setup, ut_teardown,
17488 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
17489 : : /** AUTH SNOW3G + CIPHER ZUC */
17490 : : TEST_CASE_ST(ut_setup, ut_teardown,
17491 : : test_auth_snow_cipher_zuc_test_case_1),
17492 : : TEST_CASE_ST(ut_setup, ut_teardown,
17493 : : test_verify_auth_snow_cipher_zuc_test_case_1),
17494 : : TEST_CASE_ST(ut_setup, ut_teardown,
17495 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
17496 : : TEST_CASE_ST(ut_setup, ut_teardown,
17497 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
17498 : : /** AUTH AES CMAC + CIPHER ZUC */
17499 : : TEST_CASE_ST(ut_setup, ut_teardown,
17500 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
17501 : : TEST_CASE_ST(ut_setup, ut_teardown,
17502 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
17503 : : TEST_CASE_ST(ut_setup, ut_teardown,
17504 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
17505 : : TEST_CASE_ST(ut_setup, ut_teardown,
17506 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
17507 : :
17508 : : /** AUTH NULL + CIPHER SNOW3G */
17509 : : TEST_CASE_ST(ut_setup, ut_teardown,
17510 : : test_auth_null_cipher_snow_test_case_1),
17511 : : TEST_CASE_ST(ut_setup, ut_teardown,
17512 : : test_verify_auth_null_cipher_snow_test_case_1),
17513 : : /** AUTH NULL + CIPHER ZUC */
17514 : : TEST_CASE_ST(ut_setup, ut_teardown,
17515 : : test_auth_null_cipher_zuc_test_case_1),
17516 : : TEST_CASE_ST(ut_setup, ut_teardown,
17517 : : test_verify_auth_null_cipher_zuc_test_case_1),
17518 : : /** AUTH SNOW3G + CIPHER NULL */
17519 : : TEST_CASE_ST(ut_setup, ut_teardown,
17520 : : test_auth_snow_cipher_null_test_case_1),
17521 : : TEST_CASE_ST(ut_setup, ut_teardown,
17522 : : test_verify_auth_snow_cipher_null_test_case_1),
17523 : : /** AUTH ZUC + CIPHER NULL */
17524 : : TEST_CASE_ST(ut_setup, ut_teardown,
17525 : : test_auth_zuc_cipher_null_test_case_1),
17526 : : TEST_CASE_ST(ut_setup, ut_teardown,
17527 : : test_verify_auth_zuc_cipher_null_test_case_1),
17528 : : /** AUTH NULL + CIPHER AES CTR */
17529 : : TEST_CASE_ST(ut_setup, ut_teardown,
17530 : : test_auth_null_cipher_aes_ctr_test_case_1),
17531 : : TEST_CASE_ST(ut_setup, ut_teardown,
17532 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
17533 : : /** AUTH AES CMAC + CIPHER NULL */
17534 : : TEST_CASE_ST(ut_setup, ut_teardown,
17535 : : test_auth_aes_cmac_cipher_null_test_case_1),
17536 : : TEST_CASE_ST(ut_setup, ut_teardown,
17537 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
17538 : : TEST_CASES_END()
17539 : : }
17540 : : };
17541 : :
17542 : : static int
17543 : 0 : run_cryptodev_testsuite(const char *pmd_name)
17544 : : {
17545 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
17546 : 0 : const enum blockcipher_test_type blk_suites[] = {
17547 : : BLKCIPHER_AES_CHAIN_TYPE,
17548 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
17549 : : BLKCIPHER_AES_DOCSIS_TYPE,
17550 : : BLKCIPHER_3DES_CHAIN_TYPE,
17551 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
17552 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
17553 : : BLKCIPHER_DES_DOCSIS_TYPE,
17554 : : BLKCIPHER_SM4_CHAIN_TYPE,
17555 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
17556 : : BLKCIPHER_AUTHONLY_TYPE};
17557 : 0 : struct unit_test_suite *static_suites[] = {
17558 : : &cryptodev_multi_session_testsuite,
17559 : : &cryptodev_null_testsuite,
17560 : : &cryptodev_aes_ccm_auth_testsuite,
17561 : : &cryptodev_aes_gcm_auth_testsuite,
17562 : : &cryptodev_aes_gmac_auth_testsuite,
17563 : : &cryptodev_snow3g_testsuite,
17564 : : &cryptodev_chacha20_poly1305_testsuite,
17565 : : &cryptodev_zuc_testsuite,
17566 : : &cryptodev_hmac_md5_auth_testsuite,
17567 : : &cryptodev_kasumi_testsuite,
17568 : : &cryptodev_esn_testsuite,
17569 : : &cryptodev_negative_aes_gcm_testsuite,
17570 : : &cryptodev_negative_aes_gmac_testsuite,
17571 : : &cryptodev_mixed_cipher_hash_testsuite,
17572 : : &cryptodev_negative_hmac_sha1_testsuite,
17573 : : &cryptodev_gen_testsuite,
17574 : : #ifdef RTE_LIB_SECURITY
17575 : : &ipsec_proto_testsuite,
17576 : : &pdcp_proto_testsuite,
17577 : : &docsis_proto_testsuite,
17578 : : #endif
17579 : : &end_testsuite
17580 : : };
17581 : : static struct unit_test_suite ts = {
17582 : : .suite_name = "Cryptodev Unit Test Suite",
17583 : : .setup = testsuite_setup,
17584 : : .teardown = testsuite_teardown,
17585 : : .unit_test_cases = {TEST_CASES_END()}
17586 : : };
17587 : :
17588 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
17589 : :
17590 [ # # ]: 0 : if (gbl_driver_id == -1) {
17591 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
17592 : 0 : return TEST_SKIPPED;
17593 : : }
17594 : :
17595 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
17596 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
17597 : :
17598 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
17599 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
17600 : 0 : ret = unit_test_suite_runner(&ts);
17601 : :
17602 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
17603 : 0 : free(ts.unit_test_suites);
17604 : 0 : return ret;
17605 : : }
17606 : :
17607 : : static int
17608 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
17609 : : {
17610 : : struct rte_cryptodev_info dev_info;
17611 : : uint8_t i, nb_devs;
17612 : : int driver_id;
17613 : :
17614 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
17615 [ # # ]: 0 : if (driver_id == -1) {
17616 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
17617 : 0 : return TEST_SKIPPED;
17618 : : }
17619 : :
17620 : 0 : nb_devs = rte_cryptodev_count();
17621 [ # # ]: 0 : if (nb_devs < 1) {
17622 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
17623 : 0 : return TEST_SKIPPED;
17624 : : }
17625 : :
17626 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
17627 : 0 : rte_cryptodev_info_get(i, &dev_info);
17628 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
17629 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
17630 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
17631 : : flag_name);
17632 : 0 : return TEST_SKIPPED;
17633 : : }
17634 : : return 0; /* found */
17635 : : }
17636 : : }
17637 : :
17638 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
17639 : 0 : return TEST_SKIPPED;
17640 : : }
17641 : :
17642 : : static int
17643 : 0 : test_cryptodev_qat(void)
17644 : : {
17645 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
17646 : : }
17647 : :
17648 : : static int
17649 : 0 : test_cryptodev_uadk(void)
17650 : : {
17651 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
17652 : : }
17653 : :
17654 : : static int
17655 : 0 : test_cryptodev_virtio(void)
17656 : : {
17657 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
17658 : : }
17659 : :
17660 : : static int
17661 : 0 : test_cryptodev_aesni_mb(void)
17662 : : {
17663 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17664 : : }
17665 : :
17666 : : static int
17667 : 0 : test_cryptodev_cpu_aesni_mb(void)
17668 : : {
17669 : : int32_t rc;
17670 : 0 : enum rte_security_session_action_type at = gbl_action_type;
17671 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
17672 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17673 : 0 : gbl_action_type = at;
17674 : 0 : return rc;
17675 : : }
17676 : :
17677 : : static int
17678 : 0 : test_cryptodev_chacha_poly_mb(void)
17679 : : {
17680 : : int32_t rc;
17681 : 0 : enum rte_security_session_action_type at = gbl_action_type;
17682 : 0 : rc = run_cryptodev_testsuite(
17683 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
17684 : 0 : gbl_action_type = at;
17685 : 0 : return rc;
17686 : : }
17687 : :
17688 : : static int
17689 : 0 : test_cryptodev_openssl(void)
17690 : : {
17691 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
17692 : : }
17693 : :
17694 : : static int
17695 : 0 : test_cryptodev_aesni_gcm(void)
17696 : : {
17697 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
17698 : : }
17699 : :
17700 : : static int
17701 : 0 : test_cryptodev_cpu_aesni_gcm(void)
17702 : : {
17703 : : int32_t rc;
17704 : 0 : enum rte_security_session_action_type at = gbl_action_type;
17705 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
17706 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
17707 : 0 : gbl_action_type = at;
17708 : 0 : return rc;
17709 : : }
17710 : :
17711 : : static int
17712 : 0 : test_cryptodev_mlx5(void)
17713 : : {
17714 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
17715 : : }
17716 : :
17717 : : static int
17718 : 0 : test_cryptodev_null(void)
17719 : : {
17720 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
17721 : : }
17722 : :
17723 : : static int
17724 : 0 : test_cryptodev_sw_snow3g(void)
17725 : : {
17726 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
17727 : : }
17728 : :
17729 : : static int
17730 : 0 : test_cryptodev_sw_kasumi(void)
17731 : : {
17732 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
17733 : : }
17734 : :
17735 : : static int
17736 : 0 : test_cryptodev_sw_zuc(void)
17737 : : {
17738 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
17739 : : }
17740 : :
17741 : : static int
17742 : 0 : test_cryptodev_armv8(void)
17743 : : {
17744 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
17745 : : }
17746 : :
17747 : : static int
17748 : 0 : test_cryptodev_mrvl(void)
17749 : : {
17750 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
17751 : : }
17752 : :
17753 : : #ifdef RTE_CRYPTO_SCHEDULER
17754 : :
17755 : : static int
17756 : 0 : test_cryptodev_scheduler(void)
17757 : : {
17758 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
17759 : 0 : const enum blockcipher_test_type blk_suites[] = {
17760 : : BLKCIPHER_AES_CHAIN_TYPE,
17761 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
17762 : : BLKCIPHER_AUTHONLY_TYPE
17763 : : };
17764 : : static struct unit_test_suite scheduler_multicore = {
17765 : : .suite_name = "Scheduler Multicore Unit Test Suite",
17766 : : .setup = scheduler_multicore_testsuite_setup,
17767 : : .teardown = scheduler_mode_testsuite_teardown,
17768 : : .unit_test_cases = {TEST_CASES_END()}
17769 : : };
17770 : : static struct unit_test_suite scheduler_round_robin = {
17771 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
17772 : : .setup = scheduler_roundrobin_testsuite_setup,
17773 : : .teardown = scheduler_mode_testsuite_teardown,
17774 : : .unit_test_cases = {TEST_CASES_END()}
17775 : : };
17776 : : static struct unit_test_suite scheduler_failover = {
17777 : : .suite_name = "Scheduler Failover Unit Test Suite",
17778 : : .setup = scheduler_failover_testsuite_setup,
17779 : : .teardown = scheduler_mode_testsuite_teardown,
17780 : : .unit_test_cases = {TEST_CASES_END()}
17781 : : };
17782 : : static struct unit_test_suite scheduler_pkt_size_distr = {
17783 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
17784 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
17785 : : .teardown = scheduler_mode_testsuite_teardown,
17786 : : .unit_test_cases = {TEST_CASES_END()}
17787 : : };
17788 : 0 : struct unit_test_suite *sched_mode_suites[] = {
17789 : : &scheduler_multicore,
17790 : : &scheduler_round_robin,
17791 : : &scheduler_failover,
17792 : : &scheduler_pkt_size_distr
17793 : : };
17794 : : static struct unit_test_suite scheduler_config = {
17795 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
17796 : : .unit_test_cases = {
17797 : : TEST_CASE(test_scheduler_attach_worker_op),
17798 : : TEST_CASE(test_scheduler_mode_multicore_op),
17799 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
17800 : : TEST_CASE(test_scheduler_mode_failover_op),
17801 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
17802 : : TEST_CASE(test_scheduler_detach_worker_op),
17803 : :
17804 : : TEST_CASES_END() /**< NULL terminate array */
17805 : : }
17806 : : };
17807 : 0 : struct unit_test_suite *static_suites[] = {
17808 : : &scheduler_config,
17809 : : &end_testsuite
17810 : : };
17811 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
17812 : : #ifdef RTE_LIB_SECURITY
17813 : : &docsis_proto_testsuite,
17814 : : #endif
17815 : : &end_testsuite
17816 : : };
17817 : : static struct unit_test_suite ts = {
17818 : : .suite_name = "Scheduler Unit Test Suite",
17819 : : .setup = scheduler_testsuite_setup,
17820 : : .teardown = testsuite_teardown,
17821 : : .unit_test_cases = {TEST_CASES_END()}
17822 : : };
17823 : :
17824 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
17825 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17826 : :
17827 [ # # ]: 0 : if (gbl_driver_id == -1) {
17828 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
17829 : 0 : return TEST_SKIPPED;
17830 : : }
17831 : :
17832 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
17833 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
17834 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
17835 : 0 : return TEST_SKIPPED;
17836 : : }
17837 : :
17838 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
17839 : : uint8_t blk_i = 0;
17840 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
17841 : : (struct unit_test_suite *) *
17842 : : (RTE_DIM(blk_suites) +
17843 : : RTE_DIM(sched_mode_static_suites) + 1));
17844 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
17845 : : blk_suites, RTE_DIM(blk_suites));
17846 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
17847 : : sched_mode_static_suites,
17848 : : RTE_DIM(sched_mode_static_suites));
17849 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
17850 : : }
17851 : :
17852 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
17853 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
17854 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
17855 : : RTE_DIM(sched_mode_suites));
17856 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
17857 : 0 : ret = unit_test_suite_runner(&ts);
17858 : :
17859 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
17860 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
17861 : : (*sched_mode_suites[sched_i]),
17862 : : RTE_DIM(blk_suites));
17863 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
17864 : : }
17865 : 0 : free(ts.unit_test_suites);
17866 : 0 : return ret;
17867 : : }
17868 : :
17869 : 235 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
17870 : :
17871 : : #endif
17872 : :
17873 : : static int
17874 : 0 : test_cryptodev_dpaa2_sec(void)
17875 : : {
17876 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
17877 : : }
17878 : :
17879 : : static int
17880 : 0 : test_cryptodev_dpaa_sec(void)
17881 : : {
17882 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
17883 : : }
17884 : :
17885 : : static int
17886 : 0 : test_cryptodev_ccp(void)
17887 : : {
17888 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
17889 : : }
17890 : :
17891 : : static int
17892 : 0 : test_cryptodev_octeontx(void)
17893 : : {
17894 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
17895 : : }
17896 : :
17897 : : static int
17898 : 0 : test_cryptodev_caam_jr(void)
17899 : : {
17900 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
17901 : : }
17902 : :
17903 : : static int
17904 : 0 : test_cryptodev_nitrox(void)
17905 : : {
17906 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
17907 : : }
17908 : :
17909 : : static int
17910 : 0 : test_cryptodev_bcmfs(void)
17911 : : {
17912 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
17913 : : }
17914 : :
17915 : : static int
17916 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
17917 : : {
17918 : : int ret;
17919 : :
17920 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
17921 [ # # ]: 0 : if (ret)
17922 : : return ret;
17923 : :
17924 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
17925 : 0 : ret = run_cryptodev_testsuite(pmd_name);
17926 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
17927 : :
17928 : 0 : return ret;
17929 : : }
17930 : :
17931 : : static int
17932 : 0 : test_cryptodev_qat_raw_api(void)
17933 : : {
17934 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
17935 : : }
17936 : :
17937 : : static int
17938 : 0 : test_cryptodev_cn9k(void)
17939 : : {
17940 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
17941 : : }
17942 : :
17943 : : static int
17944 : 0 : test_cryptodev_cn10k(void)
17945 : : {
17946 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
17947 : : }
17948 : :
17949 : : static int
17950 : 0 : test_cryptodev_cn10k_raw_api(void)
17951 : : {
17952 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
17953 : : }
17954 : :
17955 : : static int
17956 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
17957 : : {
17958 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
17959 : : }
17960 : :
17961 : : static int
17962 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
17963 : : {
17964 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
17965 : : }
17966 : :
17967 : 235 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
17968 : : test_cryptodev_cn10k_raw_api);
17969 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
17970 : : test_cryptodev_dpaa2_sec_raw_api);
17971 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
17972 : : test_cryptodev_dpaa_sec_raw_api);
17973 : 235 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
17974 : : test_cryptodev_qat_raw_api);
17975 : 235 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
17976 : 235 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
17977 : 235 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
17978 : : test_cryptodev_cpu_aesni_mb);
17979 : 235 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
17980 : : test_cryptodev_chacha_poly_mb);
17981 : 235 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
17982 : 235 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
17983 : 235 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
17984 : : test_cryptodev_cpu_aesni_gcm);
17985 : 235 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
17986 : 235 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
17987 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
17988 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
17989 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
17990 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
17991 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
17992 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
17993 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
17994 : 235 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
17995 : 235 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
17996 : 235 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
17997 : 235 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
17998 : 235 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
17999 : 235 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
18000 : 235 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
18001 : 235 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
18002 : 235 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
|