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_offset(ut_params->obuf,
3272 : : uint8_t *,
3273 : : plaintext_pad_len);
3274 : :
3275 : : /* Validate obuf */
3276 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3277 : : ut_params->digest,
3278 : : tdata->digest.data,
3279 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3280 : : "SNOW 3G Generated auth tag not as expected");
3281 : :
3282 : : return 0;
3283 : : }
3284 : :
3285 : : static int
3286 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3287 : : {
3288 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3289 : : struct crypto_unittest_params *ut_params = &unittest_params;
3290 : :
3291 : : int retval;
3292 : : unsigned plaintext_pad_len;
3293 : : unsigned plaintext_len;
3294 : : uint8_t *plaintext;
3295 : : struct rte_cryptodev_info dev_info;
3296 : :
3297 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3298 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3299 : :
3300 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3301 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3302 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3303 : 0 : return TEST_SKIPPED;
3304 : : }
3305 : :
3306 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3307 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3308 : : printf("Device doesn't support RAW data-path APIs.\n");
3309 : 0 : return TEST_SKIPPED;
3310 : : }
3311 : :
3312 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3313 : : return TEST_SKIPPED;
3314 : :
3315 : : /* Verify the capabilities */
3316 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3317 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3318 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3319 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3320 : : &cap_idx) == NULL)
3321 : : return TEST_SKIPPED;
3322 : :
3323 : : /* Create SNOW 3G session */
3324 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3325 : 0 : tdata->key.data, tdata->key.len,
3326 : 0 : tdata->auth_iv.len, tdata->digest.len,
3327 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3328 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3329 [ # # ]: 0 : if (retval < 0)
3330 : : return retval;
3331 : : /* alloc mbuf and set payload */
3332 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3333 : :
3334 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3335 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3336 : :
3337 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3338 : : /* Append data which is padded to a multiple of */
3339 : : /* the algorithms block size */
3340 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3341 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3342 : : plaintext_pad_len);
3343 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3344 : :
3345 : : /* Create SNOW 3G operation */
3346 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3347 : 0 : tdata->digest.len,
3348 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3349 : : plaintext_pad_len,
3350 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3351 : 0 : tdata->validAuthLenInBits.len,
3352 : : 0);
3353 [ # # ]: 0 : if (retval < 0)
3354 : : return retval;
3355 : :
3356 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3357 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3358 : : 0);
3359 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3360 : : return retval;
3361 : : } else
3362 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3363 : : ut_params->op);
3364 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3365 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3366 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3367 : : uint8_t *,
3368 : : plaintext_pad_len);
3369 : :
3370 : : /* Validate obuf */
3371 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3372 : : return 0;
3373 : : else
3374 : 0 : return -1;
3375 : :
3376 : : return 0;
3377 : : }
3378 : :
3379 : : static int
3380 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3381 : : {
3382 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3383 : : struct crypto_unittest_params *ut_params = &unittest_params;
3384 : :
3385 : : int retval;
3386 : : unsigned plaintext_pad_len;
3387 : : unsigned plaintext_len;
3388 : : uint8_t *plaintext;
3389 : : struct rte_cryptodev_info dev_info;
3390 : :
3391 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3392 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3393 : :
3394 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3395 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3396 : : printf("Device doesn't support RAW data-path APIs.\n");
3397 : 0 : return TEST_SKIPPED;
3398 : : }
3399 : :
3400 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3401 : : return TEST_SKIPPED;
3402 : :
3403 : : /* Verify the capabilities */
3404 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3405 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3406 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3407 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3408 : : &cap_idx) == NULL)
3409 : : return TEST_SKIPPED;
3410 : :
3411 : : /* Create KASUMI session */
3412 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3413 : 0 : tdata->key.data, tdata->key.len,
3414 : 0 : 0, tdata->digest.len,
3415 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3416 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3417 [ # # ]: 0 : if (retval < 0)
3418 : : return retval;
3419 : :
3420 : : /* alloc mbuf and set payload */
3421 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3422 : :
3423 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3424 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3425 : :
3426 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3427 : : /* Append data which is padded to a multiple of */
3428 : : /* the algorithms block size */
3429 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3430 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3431 : : plaintext_pad_len);
3432 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3433 : :
3434 : : /* Create KASUMI operation */
3435 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3436 : : NULL, 0,
3437 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3438 : 0 : tdata->plaintext.len,
3439 : : 0);
3440 [ # # ]: 0 : if (retval < 0)
3441 : : return retval;
3442 : :
3443 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3444 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3445 : : ut_params->op);
3446 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3447 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3448 : : 0);
3449 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3450 : : return retval;
3451 : : } else
3452 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3453 : : ut_params->op);
3454 : :
3455 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3456 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3457 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3458 : : uint8_t *,
3459 : : plaintext_pad_len);
3460 : :
3461 : : /* Validate obuf */
3462 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3463 : : ut_params->digest,
3464 : : tdata->digest.data,
3465 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3466 : : "KASUMI Generated auth tag not as expected");
3467 : :
3468 : : return 0;
3469 : : }
3470 : :
3471 : : static int
3472 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3473 : : {
3474 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3475 : : struct crypto_unittest_params *ut_params = &unittest_params;
3476 : :
3477 : : int retval;
3478 : : unsigned plaintext_pad_len;
3479 : : unsigned plaintext_len;
3480 : : uint8_t *plaintext;
3481 : : struct rte_cryptodev_info dev_info;
3482 : :
3483 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3484 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3485 : :
3486 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3487 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3488 : : printf("Device doesn't support RAW data-path APIs.\n");
3489 : 0 : return TEST_SKIPPED;
3490 : : }
3491 : :
3492 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3493 : : return TEST_SKIPPED;
3494 : :
3495 : : /* Verify the capabilities */
3496 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3497 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3498 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3499 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3500 : : &cap_idx) == NULL)
3501 : : return TEST_SKIPPED;
3502 : :
3503 : : /* Create KASUMI session */
3504 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3505 : 0 : tdata->key.data, tdata->key.len,
3506 : 0 : 0, tdata->digest.len,
3507 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3508 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3509 [ # # ]: 0 : if (retval < 0)
3510 : : return retval;
3511 : : /* alloc mbuf and set payload */
3512 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3513 : :
3514 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3515 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3516 : :
3517 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3518 : : /* Append data which is padded to a multiple */
3519 : : /* of the algorithms block size */
3520 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3521 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3522 : : plaintext_pad_len);
3523 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3524 : :
3525 : : /* Create KASUMI operation */
3526 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3527 : 0 : tdata->digest.len,
3528 : : NULL, 0,
3529 : : plaintext_pad_len,
3530 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3531 : 0 : tdata->plaintext.len,
3532 : : 0);
3533 [ # # ]: 0 : if (retval < 0)
3534 : : return retval;
3535 : :
3536 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3537 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3538 : : 0);
3539 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3540 : : return retval;
3541 : : } else
3542 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3543 : : ut_params->op);
3544 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3545 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3546 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3547 : : uint8_t *,
3548 : : plaintext_pad_len);
3549 : :
3550 : : /* Validate obuf */
3551 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3552 : : return 0;
3553 : : else
3554 : 0 : return -1;
3555 : :
3556 : : return 0;
3557 : : }
3558 : :
3559 : : static int
3560 : 0 : test_snow3g_hash_generate_test_case_1(void)
3561 : : {
3562 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3563 : : }
3564 : :
3565 : : static int
3566 : 0 : test_snow3g_hash_generate_test_case_2(void)
3567 : : {
3568 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3569 : : }
3570 : :
3571 : : static int
3572 : 0 : test_snow3g_hash_generate_test_case_3(void)
3573 : : {
3574 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3575 : : }
3576 : :
3577 : : static int
3578 : 0 : test_snow3g_hash_generate_test_case_4(void)
3579 : : {
3580 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3581 : : }
3582 : :
3583 : : static int
3584 : 0 : test_snow3g_hash_generate_test_case_5(void)
3585 : : {
3586 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3587 : : }
3588 : :
3589 : : static int
3590 : 0 : test_snow3g_hash_generate_test_case_6(void)
3591 : : {
3592 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3593 : : }
3594 : :
3595 : : static int
3596 : 0 : test_snow3g_hash_verify_test_case_1(void)
3597 : : {
3598 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3599 : :
3600 : : }
3601 : :
3602 : : static int
3603 : 0 : test_snow3g_hash_verify_test_case_2(void)
3604 : : {
3605 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3606 : : }
3607 : :
3608 : : static int
3609 : 0 : test_snow3g_hash_verify_test_case_3(void)
3610 : : {
3611 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3612 : : }
3613 : :
3614 : : static int
3615 : 0 : test_snow3g_hash_verify_test_case_4(void)
3616 : : {
3617 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3618 : : }
3619 : :
3620 : : static int
3621 : 0 : test_snow3g_hash_verify_test_case_5(void)
3622 : : {
3623 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3624 : : }
3625 : :
3626 : : static int
3627 : 0 : test_snow3g_hash_verify_test_case_6(void)
3628 : : {
3629 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3630 : : }
3631 : :
3632 : : static int
3633 : 0 : test_kasumi_hash_generate_test_case_1(void)
3634 : : {
3635 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
3636 : : }
3637 : :
3638 : : static int
3639 : 0 : test_kasumi_hash_generate_test_case_2(void)
3640 : : {
3641 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
3642 : : }
3643 : :
3644 : : static int
3645 : 0 : test_kasumi_hash_generate_test_case_3(void)
3646 : : {
3647 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
3648 : : }
3649 : :
3650 : : static int
3651 : 0 : test_kasumi_hash_generate_test_case_4(void)
3652 : : {
3653 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
3654 : : }
3655 : :
3656 : : static int
3657 : 0 : test_kasumi_hash_generate_test_case_5(void)
3658 : : {
3659 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
3660 : : }
3661 : :
3662 : : static int
3663 : 0 : test_kasumi_hash_generate_test_case_6(void)
3664 : : {
3665 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
3666 : : }
3667 : :
3668 : : static int
3669 : 0 : test_kasumi_hash_verify_test_case_1(void)
3670 : : {
3671 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3672 : : }
3673 : :
3674 : : static int
3675 : 0 : test_kasumi_hash_verify_test_case_2(void)
3676 : : {
3677 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3678 : : }
3679 : :
3680 : : static int
3681 : 0 : test_kasumi_hash_verify_test_case_3(void)
3682 : : {
3683 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3684 : : }
3685 : :
3686 : : static int
3687 : 0 : test_kasumi_hash_verify_test_case_4(void)
3688 : : {
3689 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3690 : : }
3691 : :
3692 : : static int
3693 : 0 : test_kasumi_hash_verify_test_case_5(void)
3694 : : {
3695 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3696 : : }
3697 : :
3698 : : static int
3699 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
3700 : : {
3701 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3702 : : struct crypto_unittest_params *ut_params = &unittest_params;
3703 : :
3704 : : int retval;
3705 : : uint8_t *plaintext, *ciphertext;
3706 : : unsigned plaintext_pad_len;
3707 : : unsigned plaintext_len;
3708 : : struct rte_cryptodev_info dev_info;
3709 : :
3710 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3711 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3712 : :
3713 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3714 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3715 : : printf("Device doesn't support RAW data-path APIs.\n");
3716 : 0 : return TEST_SKIPPED;
3717 : : }
3718 : :
3719 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3720 : : return TEST_SKIPPED;
3721 : :
3722 : : /* Verify the capabilities */
3723 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3724 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3725 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3726 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3727 : : &cap_idx) == NULL)
3728 : : return TEST_SKIPPED;
3729 : :
3730 : : /* Create KASUMI session */
3731 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3732 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3733 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3734 : 0 : tdata->key.data, tdata->key.len,
3735 : 0 : tdata->cipher_iv.len);
3736 [ # # ]: 0 : if (retval < 0)
3737 : : return retval;
3738 : :
3739 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3740 : :
3741 : : /* Clear mbuf payload */
3742 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3743 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3744 : :
3745 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3746 : : /* Append data which is padded to a multiple */
3747 : : /* of the algorithms block size */
3748 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3749 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3750 : : plaintext_pad_len);
3751 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3752 : :
3753 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3754 : :
3755 : : /* Create KASUMI operation */
3756 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3757 : 0 : tdata->cipher_iv.len,
3758 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3759 : 0 : tdata->validCipherOffsetInBits.len);
3760 [ # # ]: 0 : if (retval < 0)
3761 : : return retval;
3762 : :
3763 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3764 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3765 : 0 : tdata->cipher_iv.len);
3766 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3767 : : return retval;
3768 : : } else
3769 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3770 : : ut_params->op);
3771 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3772 : :
3773 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3774 [ # # ]: 0 : if (ut_params->obuf)
3775 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3776 : : else
3777 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3778 : :
3779 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3780 : :
3781 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3782 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3783 : : /* Validate obuf */
3784 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3785 : : ciphertext,
3786 : : reference_ciphertext,
3787 : : tdata->validCipherLenInBits.len,
3788 : : "KASUMI Ciphertext data not as expected");
3789 : : return 0;
3790 : : }
3791 : :
3792 : : static int
3793 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3794 : : {
3795 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3796 : : struct crypto_unittest_params *ut_params = &unittest_params;
3797 : :
3798 : : int retval;
3799 : :
3800 : : unsigned int plaintext_pad_len;
3801 : : unsigned int plaintext_len;
3802 : :
3803 : : uint8_t buffer[10000];
3804 : : const uint8_t *ciphertext;
3805 : :
3806 : : struct rte_cryptodev_info dev_info;
3807 : :
3808 : : /* Verify the capabilities */
3809 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3810 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3811 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3812 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3813 : : &cap_idx) == NULL)
3814 : : return TEST_SKIPPED;
3815 : :
3816 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3817 : :
3818 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3819 : :
3820 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3821 : : printf("Device doesn't support in-place scatter-gather. "
3822 : : "Test Skipped.\n");
3823 : 0 : return TEST_SKIPPED;
3824 : : }
3825 : :
3826 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3827 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3828 : : printf("Device doesn't support RAW data-path APIs.\n");
3829 : 0 : return TEST_SKIPPED;
3830 : : }
3831 : :
3832 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3833 : : return TEST_SKIPPED;
3834 : :
3835 : : /* Create KASUMI session */
3836 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3837 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3838 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3839 : 0 : tdata->key.data, tdata->key.len,
3840 : 0 : tdata->cipher_iv.len);
3841 [ # # ]: 0 : if (retval < 0)
3842 : : return retval;
3843 : :
3844 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3845 : :
3846 : :
3847 : : /* Append data which is padded to a multiple */
3848 : : /* of the algorithms block size */
3849 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3850 : :
3851 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3852 : : plaintext_pad_len, 10, 0);
3853 : :
3854 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3855 : :
3856 : : /* Create KASUMI operation */
3857 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3858 : 0 : tdata->cipher_iv.len,
3859 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3860 : 0 : tdata->validCipherOffsetInBits.len);
3861 [ # # ]: 0 : if (retval < 0)
3862 : : return retval;
3863 : :
3864 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3865 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3866 : 0 : tdata->cipher_iv.len);
3867 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3868 : : return retval;
3869 : : } else
3870 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3871 : : ut_params->op);
3872 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3873 : :
3874 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3875 : :
3876 [ # # ]: 0 : if (ut_params->obuf)
3877 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3878 : : plaintext_len, buffer);
3879 : : else
3880 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3881 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
3882 : : plaintext_len, buffer);
3883 : :
3884 : : /* Validate obuf */
3885 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3886 : :
3887 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3888 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3889 : : /* Validate obuf */
3890 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3891 : : ciphertext,
3892 : : reference_ciphertext,
3893 : : tdata->validCipherLenInBits.len,
3894 : : "KASUMI Ciphertext data not as expected");
3895 : : return 0;
3896 : : }
3897 : :
3898 : : static int
3899 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3900 : : {
3901 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3902 : : struct crypto_unittest_params *ut_params = &unittest_params;
3903 : :
3904 : : int retval;
3905 : : uint8_t *plaintext, *ciphertext;
3906 : : unsigned plaintext_pad_len;
3907 : : unsigned plaintext_len;
3908 : :
3909 : : /* Verify the capabilities */
3910 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3911 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3912 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3913 : : /* Data-path service does not support OOP */
3914 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3915 : : &cap_idx) == NULL)
3916 : : return TEST_SKIPPED;
3917 : :
3918 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3919 : : return TEST_SKIPPED;
3920 : :
3921 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3922 : : return TEST_SKIPPED;
3923 : :
3924 : : /* Create KASUMI session */
3925 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3926 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3927 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3928 : 0 : tdata->key.data, tdata->key.len,
3929 : 0 : tdata->cipher_iv.len);
3930 [ # # ]: 0 : if (retval < 0)
3931 : : return retval;
3932 : :
3933 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3934 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3935 : :
3936 : : /* Clear mbuf payload */
3937 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3938 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
3939 : :
3940 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3941 : : /* Append data which is padded to a multiple */
3942 : : /* of the algorithms block size */
3943 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3944 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3945 : : plaintext_pad_len);
3946 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3947 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3948 : :
3949 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3950 : :
3951 : : /* Create KASUMI operation */
3952 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3953 : 0 : tdata->cipher_iv.len,
3954 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3955 : 0 : tdata->validCipherOffsetInBits.len);
3956 [ # # ]: 0 : if (retval < 0)
3957 : : return retval;
3958 : :
3959 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3960 : : ut_params->op);
3961 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3962 : :
3963 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3964 [ # # ]: 0 : if (ut_params->obuf)
3965 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3966 : : else
3967 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3968 : :
3969 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3970 : :
3971 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3972 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3973 : : /* Validate obuf */
3974 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3975 : : ciphertext,
3976 : : reference_ciphertext,
3977 : : tdata->validCipherLenInBits.len,
3978 : : "KASUMI Ciphertext data not as expected");
3979 : : return 0;
3980 : : }
3981 : :
3982 : : static int
3983 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3984 : : {
3985 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3986 : : struct crypto_unittest_params *ut_params = &unittest_params;
3987 : :
3988 : : int retval;
3989 : : unsigned int plaintext_pad_len;
3990 : : unsigned int plaintext_len;
3991 : :
3992 : : const uint8_t *ciphertext;
3993 : : uint8_t buffer[2048];
3994 : :
3995 : : struct rte_cryptodev_info dev_info;
3996 : :
3997 : : /* Verify the capabilities */
3998 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3999 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4000 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4001 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4002 : : &cap_idx) == NULL)
4003 : : return TEST_SKIPPED;
4004 : :
4005 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4006 : : return TEST_SKIPPED;
4007 : :
4008 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4009 : : return TEST_SKIPPED;
4010 : :
4011 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4012 : :
4013 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4014 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4015 : : printf("Device doesn't support out-of-place scatter-gather "
4016 : : "in both input and output mbufs. "
4017 : : "Test Skipped.\n");
4018 : 0 : return TEST_SKIPPED;
4019 : : }
4020 : :
4021 : : /* Create KASUMI session */
4022 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4023 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4024 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4025 : 0 : tdata->key.data, tdata->key.len,
4026 : 0 : tdata->cipher_iv.len);
4027 [ # # ]: 0 : if (retval < 0)
4028 : : return retval;
4029 : :
4030 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4031 : : /* Append data which is padded to a multiple */
4032 : : /* of the algorithms block size */
4033 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4034 : :
4035 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4036 : : plaintext_pad_len, 10, 0);
4037 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4038 : : plaintext_pad_len, 3, 0);
4039 : :
4040 : : /* Append data which is padded to a multiple */
4041 : : /* of the algorithms block size */
4042 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4043 : :
4044 : : /* Create KASUMI operation */
4045 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4046 : 0 : tdata->cipher_iv.len,
4047 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4048 : 0 : tdata->validCipherOffsetInBits.len);
4049 [ # # ]: 0 : if (retval < 0)
4050 : : return retval;
4051 : :
4052 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4053 : : ut_params->op);
4054 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4055 : :
4056 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4057 [ # # ]: 0 : if (ut_params->obuf)
4058 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4059 : : plaintext_pad_len, buffer);
4060 : : else
4061 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4062 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4063 : : plaintext_pad_len, buffer);
4064 : :
4065 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4066 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4067 : : /* Validate obuf */
4068 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4069 : : ciphertext,
4070 : : reference_ciphertext,
4071 : : tdata->validCipherLenInBits.len,
4072 : : "KASUMI Ciphertext data not as expected");
4073 : : return 0;
4074 : : }
4075 : :
4076 : :
4077 : : static int
4078 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4079 : : {
4080 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4081 : : struct crypto_unittest_params *ut_params = &unittest_params;
4082 : :
4083 : : int retval;
4084 : : uint8_t *ciphertext, *plaintext;
4085 : : unsigned ciphertext_pad_len;
4086 : : unsigned ciphertext_len;
4087 : :
4088 : : /* Verify the capabilities */
4089 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4090 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4091 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4092 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4093 : : &cap_idx) == NULL)
4094 : : return TEST_SKIPPED;
4095 : :
4096 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4097 : : return TEST_SKIPPED;
4098 : :
4099 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4100 : : return TEST_SKIPPED;
4101 : :
4102 : : /* Create KASUMI session */
4103 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4104 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4105 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4106 : 0 : tdata->key.data, tdata->key.len,
4107 : 0 : tdata->cipher_iv.len);
4108 [ # # ]: 0 : if (retval < 0)
4109 : : return retval;
4110 : :
4111 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4112 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4113 : :
4114 : : /* Clear mbuf payload */
4115 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4116 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4117 : :
4118 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4119 : : /* Append data which is padded to a multiple */
4120 : : /* of the algorithms block size */
4121 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4122 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4123 : : ciphertext_pad_len);
4124 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4125 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4126 : :
4127 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4128 : :
4129 : : /* Create KASUMI operation */
4130 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4131 : 0 : tdata->cipher_iv.len,
4132 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4133 : 0 : tdata->validCipherOffsetInBits.len);
4134 [ # # ]: 0 : if (retval < 0)
4135 : : return retval;
4136 : :
4137 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4138 : : ut_params->op);
4139 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4140 : :
4141 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4142 [ # # ]: 0 : if (ut_params->obuf)
4143 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4144 : : else
4145 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4146 : :
4147 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4148 : :
4149 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4150 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4151 : : /* Validate obuf */
4152 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4153 : : plaintext,
4154 : : reference_plaintext,
4155 : : tdata->validCipherLenInBits.len,
4156 : : "KASUMI Plaintext data not as expected");
4157 : : return 0;
4158 : : }
4159 : :
4160 : : static int
4161 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4162 : : {
4163 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4164 : : struct crypto_unittest_params *ut_params = &unittest_params;
4165 : :
4166 : : int retval;
4167 : : uint8_t *ciphertext, *plaintext;
4168 : : unsigned ciphertext_pad_len;
4169 : : unsigned ciphertext_len;
4170 : : struct rte_cryptodev_info dev_info;
4171 : :
4172 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4173 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4174 : :
4175 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4176 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4177 : : printf("Device doesn't support RAW data-path APIs.\n");
4178 : 0 : return TEST_SKIPPED;
4179 : : }
4180 : :
4181 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4182 : : return TEST_SKIPPED;
4183 : :
4184 : : /* Verify the capabilities */
4185 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4186 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4187 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4188 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4189 : : &cap_idx) == NULL)
4190 : : return TEST_SKIPPED;
4191 : :
4192 : : /* Create KASUMI session */
4193 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4194 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4195 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4196 : 0 : tdata->key.data, tdata->key.len,
4197 : 0 : tdata->cipher_iv.len);
4198 [ # # ]: 0 : if (retval < 0)
4199 : : return retval;
4200 : :
4201 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4202 : :
4203 : : /* Clear mbuf payload */
4204 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4205 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4206 : :
4207 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4208 : : /* Append data which is padded to a multiple */
4209 : : /* of the algorithms block size */
4210 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4211 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4212 : : ciphertext_pad_len);
4213 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4214 : :
4215 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4216 : :
4217 : : /* Create KASUMI operation */
4218 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4219 : 0 : tdata->cipher_iv.len,
4220 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4221 : 0 : tdata->validCipherOffsetInBits.len);
4222 [ # # ]: 0 : if (retval < 0)
4223 : : return retval;
4224 : :
4225 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4226 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4227 : : 0);
4228 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4229 : : return retval;
4230 : : } else
4231 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4232 : : ut_params->op);
4233 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4234 : :
4235 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4236 [ # # ]: 0 : if (ut_params->obuf)
4237 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4238 : : else
4239 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4240 : :
4241 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4242 : :
4243 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4244 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4245 : : /* Validate obuf */
4246 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4247 : : plaintext,
4248 : : reference_plaintext,
4249 : : tdata->validCipherLenInBits.len,
4250 : : "KASUMI Plaintext data not as expected");
4251 : : return 0;
4252 : : }
4253 : :
4254 : : static int
4255 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4256 : : {
4257 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4258 : : struct crypto_unittest_params *ut_params = &unittest_params;
4259 : :
4260 : : int retval;
4261 : : uint8_t *plaintext, *ciphertext;
4262 : : unsigned plaintext_pad_len;
4263 : : unsigned plaintext_len;
4264 : : struct rte_cryptodev_info dev_info;
4265 : :
4266 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4267 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4268 : :
4269 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4270 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4271 : : printf("Device doesn't support RAW data-path APIs.\n");
4272 : 0 : return TEST_SKIPPED;
4273 : : }
4274 : :
4275 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4276 : : return TEST_SKIPPED;
4277 : :
4278 : : /* Verify the capabilities */
4279 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4280 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4281 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4282 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4283 : : &cap_idx) == NULL)
4284 : : return TEST_SKIPPED;
4285 : :
4286 : : /* Create SNOW 3G session */
4287 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4288 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4289 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4290 : 0 : tdata->key.data, tdata->key.len,
4291 : 0 : tdata->cipher_iv.len);
4292 [ # # ]: 0 : if (retval < 0)
4293 : : return retval;
4294 : :
4295 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4296 : :
4297 : : /* Clear mbuf payload */
4298 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4299 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4300 : :
4301 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4302 : : /* Append data which is padded to a multiple of */
4303 : : /* the algorithms block size */
4304 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4305 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4306 : : plaintext_pad_len);
4307 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4308 : :
4309 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4310 : :
4311 : : /* Create SNOW 3G operation */
4312 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4313 : 0 : tdata->cipher_iv.len,
4314 : 0 : tdata->validCipherLenInBits.len,
4315 : : 0);
4316 [ # # ]: 0 : if (retval < 0)
4317 : : return retval;
4318 : :
4319 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4320 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4321 : 0 : tdata->cipher_iv.len);
4322 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4323 : : return retval;
4324 : : } else
4325 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4326 : : ut_params->op);
4327 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4328 : :
4329 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4330 [ # # ]: 0 : if (ut_params->obuf)
4331 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4332 : : else
4333 : : ciphertext = plaintext;
4334 : :
4335 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4336 : :
4337 : : /* Validate obuf */
4338 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4339 : : ciphertext,
4340 : : tdata->ciphertext.data,
4341 : : tdata->validDataLenInBits.len,
4342 : : "SNOW 3G Ciphertext data not as expected");
4343 : : return 0;
4344 : : }
4345 : :
4346 : :
4347 : : static int
4348 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4349 : : {
4350 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4351 : : struct crypto_unittest_params *ut_params = &unittest_params;
4352 : : uint8_t *plaintext, *ciphertext;
4353 : :
4354 : : int retval;
4355 : : unsigned plaintext_pad_len;
4356 : : unsigned plaintext_len;
4357 : : struct rte_cryptodev_info dev_info;
4358 : :
4359 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4360 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4361 : :
4362 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4363 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4364 : : printf("Device does not support RAW data-path APIs.\n");
4365 : 0 : return -ENOTSUP;
4366 : : }
4367 : :
4368 : : /* Verify the capabilities */
4369 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4370 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4371 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4372 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4373 : : &cap_idx) == NULL)
4374 : : return TEST_SKIPPED;
4375 : :
4376 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4377 : : return TEST_SKIPPED;
4378 : :
4379 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4380 : : return TEST_SKIPPED;
4381 : :
4382 : : /* Create SNOW 3G session */
4383 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4384 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4385 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4386 : 0 : tdata->key.data, tdata->key.len,
4387 : 0 : tdata->cipher_iv.len);
4388 [ # # ]: 0 : if (retval < 0)
4389 : : return retval;
4390 : :
4391 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4392 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4393 : :
4394 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4395 : : "Failed to allocate input buffer in mempool");
4396 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4397 : : "Failed to allocate output buffer in mempool");
4398 : :
4399 : : /* Clear mbuf payload */
4400 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4401 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4402 : :
4403 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4404 : : /* Append data which is padded to a multiple of */
4405 : : /* the algorithms block size */
4406 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4407 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4408 : : plaintext_pad_len);
4409 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4410 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4411 : :
4412 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4413 : :
4414 : : /* Create SNOW 3G operation */
4415 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4416 : 0 : tdata->cipher_iv.len,
4417 : 0 : tdata->validCipherLenInBits.len,
4418 : : 0);
4419 [ # # ]: 0 : if (retval < 0)
4420 : : return retval;
4421 : :
4422 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4423 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4424 : 0 : tdata->cipher_iv.len);
4425 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4426 : : return retval;
4427 : : } else
4428 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4429 : : ut_params->op);
4430 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4431 : :
4432 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4433 [ # # ]: 0 : if (ut_params->obuf)
4434 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4435 : : else
4436 : : ciphertext = plaintext;
4437 : :
4438 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4439 : :
4440 : : /* Validate obuf */
4441 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4442 : : ciphertext,
4443 : : tdata->ciphertext.data,
4444 : : tdata->validDataLenInBits.len,
4445 : : "SNOW 3G Ciphertext data not as expected");
4446 : : return 0;
4447 : : }
4448 : :
4449 : : static int
4450 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4451 : : uint8_t sgl_in, uint8_t sgl_out)
4452 : : {
4453 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4454 : : struct crypto_unittest_params *ut_params = &unittest_params;
4455 : :
4456 : : int retval;
4457 : : unsigned int plaintext_pad_len;
4458 : : unsigned int plaintext_len;
4459 : : uint8_t buffer[10000];
4460 : : const uint8_t *ciphertext;
4461 : :
4462 : : struct rte_cryptodev_info dev_info;
4463 : :
4464 : : /* Verify the capabilities */
4465 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4466 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4467 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4468 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4469 : : &cap_idx) == NULL)
4470 : : return TEST_SKIPPED;
4471 : :
4472 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4473 : : return TEST_SKIPPED;
4474 : :
4475 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4476 : : return TEST_SKIPPED;
4477 : :
4478 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4479 : :
4480 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4481 : :
4482 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4483 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4484 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4485 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4486 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4487 : : printf("Device doesn't support out-of-place scatter gather type. "
4488 : : "Test Skipped.\n");
4489 : 0 : return TEST_SKIPPED;
4490 : : }
4491 : :
4492 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4493 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4494 : : printf("Device does not support RAW data-path APIs.\n");
4495 : 0 : return -ENOTSUP;
4496 : : }
4497 : :
4498 : : /* Create SNOW 3G session */
4499 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4500 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4501 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4502 : 0 : tdata->key.data, tdata->key.len,
4503 : 0 : tdata->cipher_iv.len);
4504 [ # # ]: 0 : if (retval < 0)
4505 : : return retval;
4506 : :
4507 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4508 : : /* Append data which is padded to a multiple of */
4509 : : /* the algorithms block size */
4510 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4511 : :
4512 [ # # ]: 0 : if (sgl_in)
4513 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4514 : : plaintext_pad_len, 10, 0);
4515 : : else {
4516 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4517 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4518 : : }
4519 : :
4520 [ # # ]: 0 : if (sgl_out)
4521 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4522 : : plaintext_pad_len, 3, 0);
4523 : : else {
4524 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4525 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4526 : : }
4527 : :
4528 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4529 : : "Failed to allocate input buffer in mempool");
4530 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4531 : : "Failed to allocate output buffer in mempool");
4532 : :
4533 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4534 : :
4535 : : /* Create SNOW 3G operation */
4536 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4537 : 0 : tdata->cipher_iv.len,
4538 : 0 : tdata->validCipherLenInBits.len,
4539 : : 0);
4540 [ # # ]: 0 : if (retval < 0)
4541 : : return retval;
4542 : :
4543 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4544 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4545 : 0 : tdata->cipher_iv.len);
4546 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4547 : : return retval;
4548 : : } else
4549 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4550 : : ut_params->op);
4551 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4552 : :
4553 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4554 [ # # ]: 0 : if (ut_params->obuf)
4555 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4556 : : plaintext_len, buffer);
4557 : : else
4558 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4559 : : plaintext_len, buffer);
4560 : :
4561 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4562 : :
4563 : : /* Validate obuf */
4564 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4565 : : ciphertext,
4566 : : tdata->ciphertext.data,
4567 : : tdata->validDataLenInBits.len,
4568 : : "SNOW 3G Ciphertext data not as expected");
4569 : :
4570 : : return 0;
4571 : : }
4572 : :
4573 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4574 : : static void
4575 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4576 : : {
4577 : : uint8_t curr_byte, prev_byte;
4578 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4579 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4580 : : unsigned i;
4581 : :
4582 : 0 : prev_byte = buffer[0];
4583 : 0 : buffer[0] >>= offset;
4584 : :
4585 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4586 : 0 : curr_byte = buffer[i];
4587 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4588 : 0 : (curr_byte >> offset);
4589 : : prev_byte = curr_byte;
4590 : : }
4591 : 0 : }
4592 : :
4593 : : static int
4594 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4595 : : {
4596 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4597 : : struct crypto_unittest_params *ut_params = &unittest_params;
4598 : : uint8_t *plaintext, *ciphertext;
4599 : : int retval;
4600 : : uint32_t plaintext_len;
4601 : : uint32_t plaintext_pad_len;
4602 : : uint8_t extra_offset = 4;
4603 : : uint8_t *expected_ciphertext_shifted;
4604 : : struct rte_cryptodev_info dev_info;
4605 : :
4606 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4607 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4608 : :
4609 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4610 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4611 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4612 : 0 : return TEST_SKIPPED;
4613 : : }
4614 : :
4615 : : /* Verify the capabilities */
4616 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4617 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4618 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4619 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4620 : : &cap_idx) == NULL)
4621 : : return TEST_SKIPPED;
4622 : :
4623 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4624 : : return TEST_SKIPPED;
4625 : :
4626 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4627 : : return TEST_SKIPPED;
4628 : :
4629 : : /* Create SNOW 3G session */
4630 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4631 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4632 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4633 : 0 : tdata->key.data, tdata->key.len,
4634 : 0 : tdata->cipher_iv.len);
4635 [ # # ]: 0 : if (retval < 0)
4636 : : return retval;
4637 : :
4638 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4639 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4640 : :
4641 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4642 : : "Failed to allocate input buffer in mempool");
4643 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4644 : : "Failed to allocate output buffer in mempool");
4645 : :
4646 : : /* Clear mbuf payload */
4647 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4648 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4649 : :
4650 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4651 : : /*
4652 : : * Append data which is padded to a
4653 : : * multiple of the algorithms block size
4654 : : */
4655 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4656 : :
4657 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4658 : : plaintext_pad_len);
4659 : :
4660 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4661 : :
4662 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4663 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4664 : :
4665 : : #ifdef RTE_APP_TEST_DEBUG
4666 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4667 : : #endif
4668 : : /* Create SNOW 3G operation */
4669 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4670 : 0 : tdata->cipher_iv.len,
4671 : 0 : tdata->validCipherLenInBits.len,
4672 : : extra_offset);
4673 [ # # ]: 0 : if (retval < 0)
4674 : : return retval;
4675 : :
4676 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4677 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4678 : 0 : tdata->cipher_iv.len);
4679 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4680 : : return retval;
4681 : : } else
4682 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4683 : : ut_params->op);
4684 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4685 : :
4686 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4687 [ # # ]: 0 : if (ut_params->obuf)
4688 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4689 : : else
4690 : : ciphertext = plaintext;
4691 : :
4692 : : #ifdef RTE_APP_TEST_DEBUG
4693 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4694 : : #endif
4695 : :
4696 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4697 : :
4698 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4699 : : "failed to reserve memory for ciphertext shifted\n");
4700 : :
4701 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4702 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
4703 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4704 : : extra_offset);
4705 : : /* Validate obuf */
4706 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
4707 : : ciphertext,
4708 : : expected_ciphertext_shifted,
4709 : : tdata->validDataLenInBits.len,
4710 : : extra_offset,
4711 : : "SNOW 3G Ciphertext data not as expected");
4712 : : return 0;
4713 : : }
4714 : :
4715 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4716 : : {
4717 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4718 : : struct crypto_unittest_params *ut_params = &unittest_params;
4719 : :
4720 : : int retval;
4721 : :
4722 : : uint8_t *plaintext, *ciphertext;
4723 : : unsigned ciphertext_pad_len;
4724 : : unsigned ciphertext_len;
4725 : : struct rte_cryptodev_info dev_info;
4726 : :
4727 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4728 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4729 : :
4730 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4731 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4732 : : printf("Device doesn't support RAW data-path APIs.\n");
4733 : 0 : return TEST_SKIPPED;
4734 : : }
4735 : :
4736 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4737 : : return TEST_SKIPPED;
4738 : :
4739 : : /* Verify the capabilities */
4740 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4741 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4742 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4743 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4744 : : &cap_idx) == NULL)
4745 : : return TEST_SKIPPED;
4746 : :
4747 : : /* Create SNOW 3G session */
4748 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4749 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4750 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4751 : 0 : tdata->key.data, tdata->key.len,
4752 : 0 : tdata->cipher_iv.len);
4753 [ # # ]: 0 : if (retval < 0)
4754 : : return retval;
4755 : :
4756 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4757 : :
4758 : : /* Clear mbuf payload */
4759 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4760 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4761 : :
4762 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4763 : : /* Append data which is padded to a multiple of */
4764 : : /* the algorithms block size */
4765 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4766 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4767 : : ciphertext_pad_len);
4768 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4769 : :
4770 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4771 : :
4772 : : /* Create SNOW 3G operation */
4773 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4774 : 0 : tdata->cipher_iv.len,
4775 : 0 : tdata->validCipherLenInBits.len,
4776 : 0 : tdata->cipher.offset_bits);
4777 [ # # ]: 0 : if (retval < 0)
4778 : : return retval;
4779 : :
4780 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4781 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4782 : 0 : tdata->cipher_iv.len);
4783 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4784 : : return retval;
4785 : : } else
4786 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4787 : : ut_params->op);
4788 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4789 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4790 [ # # ]: 0 : if (ut_params->obuf)
4791 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4792 : : else
4793 : : plaintext = ciphertext;
4794 : :
4795 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4796 : :
4797 : : /* Validate obuf */
4798 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
4799 : : tdata->plaintext.data,
4800 : : tdata->validDataLenInBits.len,
4801 : : "SNOW 3G Plaintext data not as expected");
4802 : : return 0;
4803 : : }
4804 : :
4805 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4806 : : {
4807 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4808 : : struct crypto_unittest_params *ut_params = &unittest_params;
4809 : :
4810 : : int retval;
4811 : :
4812 : : uint8_t *plaintext, *ciphertext;
4813 : : unsigned ciphertext_pad_len;
4814 : : unsigned ciphertext_len;
4815 : : struct rte_cryptodev_info dev_info;
4816 : :
4817 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4818 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4819 : :
4820 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4821 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4822 : : printf("Device does not support RAW data-path APIs.\n");
4823 : 0 : return -ENOTSUP;
4824 : : }
4825 : : /* Verify the capabilities */
4826 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4827 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4828 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4829 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4830 : : &cap_idx) == NULL)
4831 : : return TEST_SKIPPED;
4832 : :
4833 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4834 : : return TEST_SKIPPED;
4835 : :
4836 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4837 : : return TEST_SKIPPED;
4838 : :
4839 : : /* Create SNOW 3G session */
4840 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4841 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4842 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4843 : 0 : tdata->key.data, tdata->key.len,
4844 : 0 : tdata->cipher_iv.len);
4845 [ # # ]: 0 : if (retval < 0)
4846 : : return retval;
4847 : :
4848 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4849 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4850 : :
4851 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4852 : : "Failed to allocate input buffer");
4853 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4854 : : "Failed to allocate output buffer");
4855 : :
4856 : : /* Clear mbuf payload */
4857 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4858 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4859 : :
4860 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4861 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
4862 : :
4863 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4864 : : /* Append data which is padded to a multiple of */
4865 : : /* the algorithms block size */
4866 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4867 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4868 : : ciphertext_pad_len);
4869 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4870 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4871 : :
4872 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4873 : :
4874 : : /* Create SNOW 3G operation */
4875 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4876 : 0 : tdata->cipher_iv.len,
4877 : 0 : tdata->validCipherLenInBits.len,
4878 : : 0);
4879 [ # # ]: 0 : if (retval < 0)
4880 : : return retval;
4881 : :
4882 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4883 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4884 : 0 : tdata->cipher_iv.len);
4885 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4886 : : return retval;
4887 : : } else
4888 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4889 : : ut_params->op);
4890 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4891 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4892 [ # # ]: 0 : if (ut_params->obuf)
4893 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4894 : : else
4895 : : plaintext = ciphertext;
4896 : :
4897 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4898 : :
4899 : : /* Validate obuf */
4900 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
4901 : : tdata->plaintext.data,
4902 : : tdata->validDataLenInBits.len,
4903 : : "SNOW 3G Plaintext data not as expected");
4904 : : return 0;
4905 : : }
4906 : :
4907 : : static int
4908 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4909 : : {
4910 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4911 : : struct crypto_unittest_params *ut_params = &unittest_params;
4912 : :
4913 : : int retval;
4914 : :
4915 : : uint8_t *plaintext, *ciphertext;
4916 : : unsigned int plaintext_pad_len;
4917 : : unsigned int plaintext_len;
4918 : :
4919 : : struct rte_cryptodev_info dev_info;
4920 : :
4921 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4922 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4923 : :
4924 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4925 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
4926 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
4927 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4928 : 0 : return TEST_SKIPPED;
4929 : : }
4930 : :
4931 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4932 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4933 : : printf("Device doesn't support RAW data-path APIs.\n");
4934 : 0 : return TEST_SKIPPED;
4935 : : }
4936 : :
4937 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4938 : : return TEST_SKIPPED;
4939 : :
4940 : : /* Check if device supports ZUC EEA3 */
4941 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
4942 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
4943 : : return TEST_SKIPPED;
4944 : :
4945 : : /* Check if device supports ZUC EIA3 */
4946 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
4947 : 0 : tdata->key.len, tdata->auth_iv.len,
4948 : 0 : tdata->digest.len) < 0)
4949 : : return TEST_SKIPPED;
4950 : :
4951 : : /* Create ZUC session */
4952 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
4953 : 0 : ts_params->valid_devs[0],
4954 : : tdata);
4955 [ # # ]: 0 : if (retval != 0)
4956 : : return retval;
4957 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4958 : :
4959 : : /* clear mbuf payload */
4960 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4961 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4962 : :
4963 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4964 : : /* Append data which is padded to a multiple of */
4965 : : /* the algorithms block size */
4966 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4967 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4968 : : plaintext_pad_len);
4969 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4970 : :
4971 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4972 : :
4973 : : /* Create ZUC operation */
4974 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
4975 [ # # ]: 0 : if (retval < 0)
4976 : : return retval;
4977 : :
4978 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4979 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
4980 : 0 : tdata->cipher_iv.len);
4981 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4982 : : return retval;
4983 : : } else
4984 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4985 : : ut_params->op);
4986 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4987 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
4988 [ # # ]: 0 : if (ut_params->obuf)
4989 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4990 : : else
4991 : : ciphertext = plaintext;
4992 : :
4993 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4994 : : /* Validate obuf */
4995 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4996 : : ciphertext,
4997 : : tdata->ciphertext.data,
4998 : : tdata->validDataLenInBits.len,
4999 : : "ZUC Ciphertext data not as expected");
5000 : :
5001 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5002 : : uint8_t *,
5003 : : plaintext_pad_len);
5004 : :
5005 : : /* Validate obuf */
5006 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5007 : : ut_params->digest,
5008 : : tdata->digest.data,
5009 : : tdata->digest.len,
5010 : : "ZUC Generated auth tag not as expected");
5011 : : return 0;
5012 : : }
5013 : :
5014 : : static int
5015 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5016 : : {
5017 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5018 : : struct crypto_unittest_params *ut_params = &unittest_params;
5019 : :
5020 : : int retval;
5021 : :
5022 : : uint8_t *plaintext, *ciphertext;
5023 : : unsigned plaintext_pad_len;
5024 : : unsigned plaintext_len;
5025 : : struct rte_cryptodev_info dev_info;
5026 : :
5027 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5028 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5029 : :
5030 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5031 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5032 : : printf("Device doesn't support RAW data-path APIs.\n");
5033 : 0 : return TEST_SKIPPED;
5034 : : }
5035 : :
5036 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5037 : : return TEST_SKIPPED;
5038 : :
5039 : : /* Verify the capabilities */
5040 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5041 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5042 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5043 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5044 : : &cap_idx) == NULL)
5045 : : return TEST_SKIPPED;
5046 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5047 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5048 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5049 : : &cap_idx) == NULL)
5050 : : return TEST_SKIPPED;
5051 : :
5052 : : /* Create SNOW 3G session */
5053 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5054 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5055 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5056 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5057 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5058 : : tdata->key.data, tdata->key.len,
5059 : 0 : tdata->key.data, tdata->key.len,
5060 : 0 : tdata->auth_iv.len, tdata->digest.len,
5061 : 0 : tdata->cipher_iv.len);
5062 [ # # ]: 0 : if (retval != 0)
5063 : : return retval;
5064 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5065 : :
5066 : : /* clear mbuf payload */
5067 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5068 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5069 : :
5070 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5071 : : /* Append data which is padded to a multiple of */
5072 : : /* the algorithms block size */
5073 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5074 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5075 : : plaintext_pad_len);
5076 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5077 : :
5078 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5079 : :
5080 : : /* Create SNOW 3G operation */
5081 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5082 : 0 : tdata->digest.len, tdata->auth_iv.data,
5083 : 0 : tdata->auth_iv.len,
5084 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5085 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5086 : 0 : tdata->validCipherLenInBits.len,
5087 : : 0,
5088 : 0 : tdata->validAuthLenInBits.len,
5089 : : 0
5090 : : );
5091 [ # # ]: 0 : if (retval < 0)
5092 : : return retval;
5093 : :
5094 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5095 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5096 : 0 : tdata->cipher_iv.len);
5097 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5098 : : return retval;
5099 : : } else
5100 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5101 : : ut_params->op);
5102 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5103 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5104 [ # # ]: 0 : if (ut_params->obuf)
5105 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5106 : : else
5107 : : ciphertext = plaintext;
5108 : :
5109 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5110 : : /* Validate obuf */
5111 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5112 : : ciphertext,
5113 : : tdata->ciphertext.data,
5114 : : tdata->validDataLenInBits.len,
5115 : : "SNOW 3G Ciphertext data not as expected");
5116 : :
5117 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5118 : : uint8_t *,
5119 : : plaintext_pad_len);
5120 : :
5121 : : /* Validate obuf */
5122 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5123 : : ut_params->digest,
5124 : : tdata->digest.data,
5125 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5126 : : "SNOW 3G Generated auth tag not as expected");
5127 : : return 0;
5128 : : }
5129 : :
5130 : : static int
5131 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5132 : : uint8_t op_mode, uint8_t verify)
5133 : : {
5134 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5135 : : struct crypto_unittest_params *ut_params = &unittest_params;
5136 : :
5137 : : int retval;
5138 : :
5139 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5140 : : unsigned int plaintext_pad_len;
5141 : : unsigned int plaintext_len;
5142 : : unsigned int ciphertext_pad_len;
5143 : : unsigned int ciphertext_len;
5144 : : unsigned int digest_offset;
5145 : :
5146 : : struct rte_cryptodev_info dev_info;
5147 : :
5148 : : /* Verify the capabilities */
5149 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5150 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5151 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5152 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5153 : : &cap_idx) == NULL)
5154 : : return TEST_SKIPPED;
5155 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5156 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5157 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5158 : : &cap_idx) == NULL)
5159 : : return TEST_SKIPPED;
5160 : :
5161 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5162 : : return TEST_SKIPPED;
5163 : :
5164 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5165 : :
5166 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5167 : :
5168 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5169 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5170 : : printf("Device doesn't support digest encrypted.\n");
5171 : 0 : return TEST_SKIPPED;
5172 : : }
5173 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5174 : : return TEST_SKIPPED;
5175 : : }
5176 : :
5177 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5178 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5179 : : printf("Device doesn't support RAW data-path APIs.\n");
5180 : 0 : return TEST_SKIPPED;
5181 : : }
5182 : :
5183 : : /* Create SNOW 3G session */
5184 : 0 : retval = create_wireless_algo_auth_cipher_session(
5185 : 0 : ts_params->valid_devs[0],
5186 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5187 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5188 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5189 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5190 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5191 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5192 : : tdata->key.data, tdata->key.len,
5193 : 0 : tdata->key.data, tdata->key.len,
5194 : 0 : tdata->auth_iv.len, tdata->digest.len,
5195 : 0 : tdata->cipher_iv.len);
5196 [ # # ]: 0 : if (retval != 0)
5197 : : return retval;
5198 : :
5199 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5200 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5201 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5202 : :
5203 : : /* clear mbuf payload */
5204 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5205 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5206 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5207 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5208 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5209 : :
5210 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5211 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5212 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5213 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5214 : :
5215 [ # # ]: 0 : if (verify) {
5216 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5217 : : ciphertext_pad_len);
5218 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5219 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5220 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5221 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5222 : : ciphertext_len);
5223 : : } else {
5224 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5225 : : plaintext_pad_len);
5226 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5227 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5228 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5229 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5230 : : }
5231 : :
5232 : : /* Create SNOW 3G operation */
5233 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5234 : 0 : tdata->digest.data, tdata->digest.len,
5235 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5236 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5237 : 0 : (tdata->digest.offset_bytes == 0 ?
5238 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5239 : : : tdata->digest.offset_bytes),
5240 : 0 : tdata->validCipherLenInBits.len,
5241 : 0 : tdata->cipher.offset_bits,
5242 : 0 : tdata->validAuthLenInBits.len,
5243 [ # # ]: 0 : tdata->auth.offset_bits,
5244 : : op_mode, 0, verify);
5245 : :
5246 [ # # ]: 0 : if (retval < 0)
5247 : : return retval;
5248 : :
5249 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5250 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5251 : 0 : tdata->cipher_iv.len);
5252 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5253 : : return retval;
5254 : : } else
5255 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5256 : : ut_params->op);
5257 : :
5258 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5259 : :
5260 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5261 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5262 : :
5263 [ # # ]: 0 : if (verify) {
5264 [ # # ]: 0 : if (ut_params->obuf)
5265 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5266 : : uint8_t *);
5267 : : else
5268 : 0 : plaintext = ciphertext +
5269 : 0 : (tdata->cipher.offset_bits >> 3);
5270 : :
5271 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5272 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5273 : 0 : debug_hexdump(stdout, "plaintext expected:",
5274 : 0 : tdata->plaintext.data,
5275 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5276 : : } else {
5277 [ # # ]: 0 : if (ut_params->obuf)
5278 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5279 : : uint8_t *);
5280 : : else
5281 : : ciphertext = plaintext;
5282 : :
5283 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5284 : : ciphertext_len);
5285 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5286 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5287 : :
5288 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5289 : : digest_offset = plaintext_pad_len;
5290 : : else
5291 : : digest_offset = tdata->digest.offset_bytes;
5292 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5293 : : uint8_t *, digest_offset);
5294 : :
5295 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5296 : 0 : tdata->digest.len);
5297 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5298 : 0 : tdata->digest.len);
5299 : : }
5300 : :
5301 : : /* Validate obuf */
5302 [ # # ]: 0 : if (verify) {
5303 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5304 : : plaintext,
5305 : : tdata->plaintext.data,
5306 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5307 : : (tdata->digest.len << 3)),
5308 : : tdata->cipher.offset_bits,
5309 : : "SNOW 3G Plaintext data not as expected");
5310 : : } else {
5311 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5312 : : ciphertext,
5313 : : tdata->ciphertext.data,
5314 : : (tdata->validDataLenInBits.len -
5315 : : tdata->cipher.offset_bits),
5316 : : tdata->cipher.offset_bits,
5317 : : "SNOW 3G Ciphertext data not as expected");
5318 : :
5319 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5320 : : ut_params->digest,
5321 : : tdata->digest.data,
5322 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5323 : : "SNOW 3G Generated auth tag not as expected");
5324 : : }
5325 : : return 0;
5326 : : }
5327 : :
5328 : : static int
5329 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5330 : : uint8_t op_mode, uint8_t verify)
5331 : : {
5332 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5333 : : struct crypto_unittest_params *ut_params = &unittest_params;
5334 : :
5335 : : int retval;
5336 : :
5337 : : const uint8_t *plaintext = NULL;
5338 : : const uint8_t *ciphertext = NULL;
5339 : : const uint8_t *digest = NULL;
5340 : : unsigned int plaintext_pad_len;
5341 : : unsigned int plaintext_len;
5342 : : unsigned int ciphertext_pad_len;
5343 : : unsigned int ciphertext_len;
5344 : : uint8_t buffer[10000];
5345 : : uint8_t digest_buffer[10000];
5346 : :
5347 : : struct rte_cryptodev_info dev_info;
5348 : :
5349 : : /* Verify the capabilities */
5350 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5351 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5352 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5353 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5354 : : &cap_idx) == NULL)
5355 : : return TEST_SKIPPED;
5356 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5357 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5358 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5359 : : &cap_idx) == NULL)
5360 : : return TEST_SKIPPED;
5361 : :
5362 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5363 : : return TEST_SKIPPED;
5364 : :
5365 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5366 : :
5367 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5368 : :
5369 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5370 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5371 : : printf("Device doesn't support in-place scatter-gather "
5372 : : "in both input and output mbufs.\n");
5373 : 0 : return TEST_SKIPPED;
5374 : : }
5375 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5376 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5377 : : printf("Device doesn't support RAW data-path APIs.\n");
5378 : 0 : return TEST_SKIPPED;
5379 : : }
5380 : : } else {
5381 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5382 : : return TEST_SKIPPED;
5383 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5384 : : printf("Device doesn't support out-of-place scatter-gather "
5385 : : "in both input and output mbufs.\n");
5386 : 0 : return TEST_SKIPPED;
5387 : : }
5388 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5389 : : printf("Device doesn't support digest encrypted.\n");
5390 : 0 : return TEST_SKIPPED;
5391 : : }
5392 : : }
5393 : :
5394 : : /* Create SNOW 3G session */
5395 : 0 : retval = create_wireless_algo_auth_cipher_session(
5396 : 0 : ts_params->valid_devs[0],
5397 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5398 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5399 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5400 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5401 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5402 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5403 : : tdata->key.data, tdata->key.len,
5404 : 0 : tdata->key.data, tdata->key.len,
5405 : 0 : tdata->auth_iv.len, tdata->digest.len,
5406 : 0 : tdata->cipher_iv.len);
5407 : :
5408 [ # # ]: 0 : if (retval != 0)
5409 : : return retval;
5410 : :
5411 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5412 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5413 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5414 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5415 : :
5416 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5417 : : plaintext_pad_len, 15, 0);
5418 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5419 : : "Failed to allocate input buffer in mempool");
5420 : :
5421 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5422 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5423 : : plaintext_pad_len, 15, 0);
5424 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5425 : : "Failed to allocate output buffer in mempool");
5426 : : }
5427 : :
5428 [ # # ]: 0 : if (verify) {
5429 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5430 : 0 : tdata->ciphertext.data);
5431 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5432 : : ciphertext_len, buffer);
5433 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5434 : : ciphertext_len);
5435 : : } else {
5436 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5437 : 0 : tdata->plaintext.data);
5438 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5439 : : plaintext_len, buffer);
5440 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5441 : : plaintext_len);
5442 : : }
5443 : : memset(buffer, 0, sizeof(buffer));
5444 : :
5445 : : /* Create SNOW 3G operation */
5446 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5447 : 0 : tdata->digest.data, tdata->digest.len,
5448 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5449 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5450 : 0 : (tdata->digest.offset_bytes == 0 ?
5451 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5452 : : : tdata->digest.offset_bytes),
5453 : 0 : tdata->validCipherLenInBits.len,
5454 : 0 : tdata->cipher.offset_bits,
5455 : 0 : tdata->validAuthLenInBits.len,
5456 [ # # ]: 0 : tdata->auth.offset_bits,
5457 : : op_mode, 1, verify);
5458 : :
5459 [ # # ]: 0 : if (retval < 0)
5460 : : return retval;
5461 : :
5462 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5463 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5464 : 0 : tdata->cipher_iv.len);
5465 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5466 : : return retval;
5467 : : } else
5468 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5469 : : ut_params->op);
5470 : :
5471 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5472 : :
5473 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5474 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5475 : :
5476 [ # # ]: 0 : if (verify) {
5477 [ # # ]: 0 : if (ut_params->obuf)
5478 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5479 : : plaintext_len, buffer);
5480 : : else
5481 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5482 : : plaintext_len, buffer);
5483 : :
5484 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5485 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5486 : 0 : debug_hexdump(stdout, "plaintext expected:",
5487 : 0 : tdata->plaintext.data,
5488 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5489 : : } else {
5490 [ # # ]: 0 : if (ut_params->obuf)
5491 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5492 : : ciphertext_len, buffer);
5493 : : else
5494 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5495 : : ciphertext_len, buffer);
5496 : :
5497 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5498 : : ciphertext_len);
5499 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5500 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5501 : :
5502 [ # # ]: 0 : if (ut_params->obuf)
5503 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5504 : 0 : (tdata->digest.offset_bytes == 0 ?
5505 : : plaintext_pad_len : tdata->digest.offset_bytes),
5506 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5507 : : else
5508 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5509 : 0 : (tdata->digest.offset_bytes == 0 ?
5510 : : plaintext_pad_len : tdata->digest.offset_bytes),
5511 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5512 : :
5513 : 0 : debug_hexdump(stdout, "digest:", digest,
5514 : 0 : tdata->digest.len);
5515 : 0 : debug_hexdump(stdout, "digest expected:",
5516 : 0 : tdata->digest.data, tdata->digest.len);
5517 : : }
5518 : :
5519 : : /* Validate obuf */
5520 [ # # ]: 0 : if (verify) {
5521 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5522 : : plaintext,
5523 : : tdata->plaintext.data,
5524 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5525 : : (tdata->digest.len << 3)),
5526 : : tdata->cipher.offset_bits,
5527 : : "SNOW 3G Plaintext data not as expected");
5528 : : } else {
5529 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5530 : : ciphertext,
5531 : : tdata->ciphertext.data,
5532 : : (tdata->validDataLenInBits.len -
5533 : : tdata->cipher.offset_bits),
5534 : : tdata->cipher.offset_bits,
5535 : : "SNOW 3G Ciphertext data not as expected");
5536 : :
5537 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5538 : : digest,
5539 : : tdata->digest.data,
5540 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5541 : : "SNOW 3G Generated auth tag not as expected");
5542 : : }
5543 : : return 0;
5544 : : }
5545 : :
5546 : : static int
5547 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5548 : : uint8_t op_mode, uint8_t verify)
5549 : : {
5550 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5551 : : struct crypto_unittest_params *ut_params = &unittest_params;
5552 : :
5553 : : int retval;
5554 : :
5555 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5556 : : unsigned int plaintext_pad_len;
5557 : : unsigned int plaintext_len;
5558 : : unsigned int ciphertext_pad_len;
5559 : : unsigned int ciphertext_len;
5560 : : unsigned int digest_offset;
5561 : :
5562 : : struct rte_cryptodev_info dev_info;
5563 : :
5564 : : /* Verify the capabilities */
5565 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5566 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5567 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5568 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5569 : : &cap_idx) == NULL)
5570 : : return TEST_SKIPPED;
5571 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5572 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5573 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5574 : : &cap_idx) == NULL)
5575 : : return TEST_SKIPPED;
5576 : :
5577 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5578 : :
5579 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5580 : :
5581 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5582 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5583 : : printf("Device doesn't support RAW data-path APIs.\n");
5584 : 0 : return TEST_SKIPPED;
5585 : : }
5586 : :
5587 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5588 : : return TEST_SKIPPED;
5589 : :
5590 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5591 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5592 : : return TEST_SKIPPED;
5593 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5594 : : printf("Device doesn't support digest encrypted.\n");
5595 : 0 : return TEST_SKIPPED;
5596 : : }
5597 : : }
5598 : :
5599 : : /* Create KASUMI session */
5600 : 0 : retval = create_wireless_algo_auth_cipher_session(
5601 : 0 : ts_params->valid_devs[0],
5602 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5603 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5604 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5605 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5606 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5607 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5608 : : tdata->key.data, tdata->key.len,
5609 : 0 : tdata->key.data, tdata->key.len,
5610 : 0 : 0, tdata->digest.len,
5611 : 0 : tdata->cipher_iv.len);
5612 : :
5613 [ # # ]: 0 : if (retval != 0)
5614 : : return retval;
5615 : :
5616 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5617 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5618 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5619 : :
5620 : : /* clear mbuf payload */
5621 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5622 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5623 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5624 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5625 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5626 : :
5627 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5628 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5629 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5630 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5631 : :
5632 [ # # ]: 0 : if (verify) {
5633 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5634 : : ciphertext_pad_len);
5635 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5636 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5637 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5638 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5639 : : ciphertext_len);
5640 : : } else {
5641 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5642 : : plaintext_pad_len);
5643 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5644 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5645 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5646 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5647 : : plaintext_len);
5648 : : }
5649 : :
5650 : : /* Create KASUMI operation */
5651 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5652 : 0 : tdata->digest.data, tdata->digest.len,
5653 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5654 : : NULL, 0,
5655 : 0 : (tdata->digest.offset_bytes == 0 ?
5656 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5657 : : : tdata->digest.offset_bytes),
5658 : 0 : tdata->validCipherLenInBits.len,
5659 : 0 : tdata->validCipherOffsetInBits.len,
5660 [ # # ]: 0 : tdata->validAuthLenInBits.len,
5661 : : 0,
5662 : : op_mode, 0, verify);
5663 : :
5664 [ # # ]: 0 : if (retval < 0)
5665 : : return retval;
5666 : :
5667 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5668 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5669 : 0 : tdata->cipher_iv.len);
5670 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5671 : : return retval;
5672 : : } else
5673 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5674 : : ut_params->op);
5675 : :
5676 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5677 : :
5678 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5679 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5680 : :
5681 : :
5682 [ # # ]: 0 : if (verify) {
5683 [ # # ]: 0 : if (ut_params->obuf)
5684 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5685 : : uint8_t *);
5686 : : else
5687 : : plaintext = ciphertext;
5688 : :
5689 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5690 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5691 : 0 : debug_hexdump(stdout, "plaintext expected:",
5692 : 0 : tdata->plaintext.data,
5693 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5694 : : } else {
5695 [ # # ]: 0 : if (ut_params->obuf)
5696 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5697 : : uint8_t *);
5698 : : else
5699 : : ciphertext = plaintext;
5700 : :
5701 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5702 : : ciphertext_len);
5703 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5704 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5705 : :
5706 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5707 : : digest_offset = plaintext_pad_len;
5708 : : else
5709 : : digest_offset = tdata->digest.offset_bytes;
5710 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5711 : : uint8_t *, digest_offset);
5712 : :
5713 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5714 : 0 : tdata->digest.len);
5715 : 0 : debug_hexdump(stdout, "digest expected:",
5716 : 0 : tdata->digest.data, tdata->digest.len);
5717 : : }
5718 : :
5719 : : /* Validate obuf */
5720 [ # # ]: 0 : if (verify) {
5721 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5722 : : plaintext,
5723 : : tdata->plaintext.data,
5724 : : tdata->plaintext.len >> 3,
5725 : : "KASUMI Plaintext data not as expected");
5726 : : } else {
5727 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5728 : : ciphertext,
5729 : : tdata->ciphertext.data,
5730 : : tdata->ciphertext.len >> 3,
5731 : : "KASUMI Ciphertext data not as expected");
5732 : :
5733 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5734 : : ut_params->digest,
5735 : : tdata->digest.data,
5736 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
5737 : : "KASUMI Generated auth tag not as expected");
5738 : : }
5739 : : return 0;
5740 : : }
5741 : :
5742 : : static int
5743 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5744 : : uint8_t op_mode, uint8_t verify)
5745 : : {
5746 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5747 : : struct crypto_unittest_params *ut_params = &unittest_params;
5748 : :
5749 : : int retval;
5750 : :
5751 : : const uint8_t *plaintext = NULL;
5752 : : const uint8_t *ciphertext = NULL;
5753 : : const uint8_t *digest = NULL;
5754 : : unsigned int plaintext_pad_len;
5755 : : unsigned int plaintext_len;
5756 : : unsigned int ciphertext_pad_len;
5757 : : unsigned int ciphertext_len;
5758 : : uint8_t buffer[10000];
5759 : : uint8_t digest_buffer[10000];
5760 : :
5761 : : struct rte_cryptodev_info dev_info;
5762 : :
5763 : : /* Verify the capabilities */
5764 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5765 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5766 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5767 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5768 : : &cap_idx) == NULL)
5769 : : return TEST_SKIPPED;
5770 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5771 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5772 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5773 : : &cap_idx) == NULL)
5774 : : return TEST_SKIPPED;
5775 : :
5776 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5777 : : return TEST_SKIPPED;
5778 : :
5779 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5780 : :
5781 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5782 : :
5783 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5784 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5785 : : printf("Device doesn't support in-place scatter-gather "
5786 : : "in both input and output mbufs.\n");
5787 : 0 : return TEST_SKIPPED;
5788 : : }
5789 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5790 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5791 : : printf("Device doesn't support RAW data-path APIs.\n");
5792 : 0 : return TEST_SKIPPED;
5793 : : }
5794 : : } else {
5795 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5796 : : return TEST_SKIPPED;
5797 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5798 : : printf("Device doesn't support out-of-place scatter-gather "
5799 : : "in both input and output mbufs.\n");
5800 : 0 : return TEST_SKIPPED;
5801 : : }
5802 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5803 : : printf("Device doesn't support digest encrypted.\n");
5804 : 0 : return TEST_SKIPPED;
5805 : : }
5806 : : }
5807 : :
5808 : : /* Create KASUMI session */
5809 : 0 : retval = create_wireless_algo_auth_cipher_session(
5810 : 0 : ts_params->valid_devs[0],
5811 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5812 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5813 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5814 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5815 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5816 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5817 : : tdata->key.data, tdata->key.len,
5818 : 0 : tdata->key.data, tdata->key.len,
5819 : 0 : 0, tdata->digest.len,
5820 : 0 : tdata->cipher_iv.len);
5821 : :
5822 [ # # ]: 0 : if (retval != 0)
5823 : : return retval;
5824 : :
5825 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5826 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5827 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5828 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5829 : :
5830 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5831 : : plaintext_pad_len, 15, 0);
5832 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5833 : : "Failed to allocate input buffer in mempool");
5834 : :
5835 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5836 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5837 : : plaintext_pad_len, 15, 0);
5838 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5839 : : "Failed to allocate output buffer in mempool");
5840 : : }
5841 : :
5842 [ # # ]: 0 : if (verify) {
5843 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5844 : 0 : tdata->ciphertext.data);
5845 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5846 : : ciphertext_len, buffer);
5847 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5848 : : ciphertext_len);
5849 : : } else {
5850 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5851 : 0 : tdata->plaintext.data);
5852 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5853 : : plaintext_len, buffer);
5854 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5855 : : plaintext_len);
5856 : : }
5857 : : memset(buffer, 0, sizeof(buffer));
5858 : :
5859 : : /* Create KASUMI operation */
5860 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5861 : 0 : tdata->digest.data, tdata->digest.len,
5862 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5863 : : NULL, 0,
5864 : 0 : (tdata->digest.offset_bytes == 0 ?
5865 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5866 : : : tdata->digest.offset_bytes),
5867 : 0 : tdata->validCipherLenInBits.len,
5868 : 0 : tdata->validCipherOffsetInBits.len,
5869 [ # # ]: 0 : tdata->validAuthLenInBits.len,
5870 : : 0,
5871 : : op_mode, 1, verify);
5872 : :
5873 [ # # ]: 0 : if (retval < 0)
5874 : : return retval;
5875 : :
5876 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5877 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5878 : 0 : tdata->cipher_iv.len);
5879 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5880 : : return retval;
5881 : : } else
5882 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5883 : : ut_params->op);
5884 : :
5885 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5886 : :
5887 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5888 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5889 : :
5890 [ # # ]: 0 : if (verify) {
5891 [ # # ]: 0 : if (ut_params->obuf)
5892 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5893 : : plaintext_len, buffer);
5894 : : else
5895 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5896 : : plaintext_len, buffer);
5897 : :
5898 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5899 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5900 : 0 : debug_hexdump(stdout, "plaintext expected:",
5901 : 0 : tdata->plaintext.data,
5902 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5903 : : } else {
5904 [ # # ]: 0 : if (ut_params->obuf)
5905 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5906 : : ciphertext_len, buffer);
5907 : : else
5908 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5909 : : ciphertext_len, buffer);
5910 : :
5911 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5912 : : ciphertext_len);
5913 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5914 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5915 : :
5916 [ # # ]: 0 : if (ut_params->obuf)
5917 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5918 : 0 : (tdata->digest.offset_bytes == 0 ?
5919 : : plaintext_pad_len : tdata->digest.offset_bytes),
5920 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5921 : : else
5922 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5923 : 0 : (tdata->digest.offset_bytes == 0 ?
5924 : : plaintext_pad_len : tdata->digest.offset_bytes),
5925 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5926 : :
5927 : 0 : debug_hexdump(stdout, "digest:", digest,
5928 : 0 : tdata->digest.len);
5929 : 0 : debug_hexdump(stdout, "digest expected:",
5930 : 0 : tdata->digest.data, tdata->digest.len);
5931 : : }
5932 : :
5933 : : /* Validate obuf */
5934 [ # # ]: 0 : if (verify) {
5935 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5936 : : plaintext,
5937 : : tdata->plaintext.data,
5938 : : tdata->plaintext.len >> 3,
5939 : : "KASUMI Plaintext data not as expected");
5940 : : } else {
5941 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5942 : : ciphertext,
5943 : : tdata->ciphertext.data,
5944 : : tdata->validDataLenInBits.len,
5945 : : "KASUMI Ciphertext data not as expected");
5946 : :
5947 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5948 : : digest,
5949 : : tdata->digest.data,
5950 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
5951 : : "KASUMI Generated auth tag not as expected");
5952 : : }
5953 : : return 0;
5954 : : }
5955 : :
5956 : : static int
5957 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5958 : : {
5959 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5960 : : struct crypto_unittest_params *ut_params = &unittest_params;
5961 : :
5962 : : int retval;
5963 : :
5964 : : uint8_t *plaintext, *ciphertext;
5965 : : unsigned plaintext_pad_len;
5966 : : unsigned plaintext_len;
5967 : : struct rte_cryptodev_info dev_info;
5968 : :
5969 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5970 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5971 : :
5972 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5973 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5974 : : printf("Device doesn't support RAW data-path APIs.\n");
5975 : 0 : return TEST_SKIPPED;
5976 : : }
5977 : :
5978 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5979 : : return TEST_SKIPPED;
5980 : :
5981 : : /* Verify the capabilities */
5982 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5983 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5984 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5985 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5986 : : &cap_idx) == NULL)
5987 : : return TEST_SKIPPED;
5988 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5989 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5990 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5991 : : &cap_idx) == NULL)
5992 : : return TEST_SKIPPED;
5993 : :
5994 : : /* Create KASUMI session */
5995 : 0 : retval = create_wireless_algo_cipher_auth_session(
5996 : 0 : ts_params->valid_devs[0],
5997 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5998 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5999 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6000 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6001 : : tdata->key.data, tdata->key.len,
6002 : 0 : tdata->key.data, tdata->key.len,
6003 : 0 : 0, tdata->digest.len,
6004 : 0 : tdata->cipher_iv.len);
6005 [ # # ]: 0 : if (retval != 0)
6006 : : return retval;
6007 : :
6008 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6009 : :
6010 : : /* clear mbuf payload */
6011 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6012 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6013 : :
6014 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6015 : : /* Append data which is padded to a multiple of */
6016 : : /* the algorithms block size */
6017 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6018 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6019 : : plaintext_pad_len);
6020 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6021 : :
6022 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6023 : :
6024 : : /* Create KASUMI operation */
6025 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6026 : 0 : tdata->digest.len, NULL, 0,
6027 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6028 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6029 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6030 : 0 : tdata->validCipherOffsetInBits.len,
6031 : 0 : tdata->validAuthLenInBits.len,
6032 : : 0
6033 : : );
6034 [ # # ]: 0 : if (retval < 0)
6035 : : return retval;
6036 : :
6037 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6038 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6039 : 0 : tdata->cipher_iv.len);
6040 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6041 : : return retval;
6042 : : } else
6043 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6044 : : ut_params->op);
6045 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6046 : :
6047 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6048 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6049 : : else
6050 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6051 : :
6052 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6053 : : tdata->validCipherOffsetInBits.len >> 3);
6054 : :
6055 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6056 : : uint8_t *,
6057 : : plaintext_pad_len);
6058 : :
6059 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6060 : : (tdata->validCipherOffsetInBits.len >> 3);
6061 : : /* Validate obuf */
6062 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6063 : : ciphertext,
6064 : : reference_ciphertext,
6065 : : tdata->validCipherLenInBits.len,
6066 : : "KASUMI Ciphertext data not as expected");
6067 : :
6068 : : /* Validate obuf */
6069 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6070 : : ut_params->digest,
6071 : : tdata->digest.data,
6072 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6073 : : "KASUMI Generated auth tag not as expected");
6074 : : return 0;
6075 : : }
6076 : :
6077 : : static int
6078 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6079 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6080 : : const uint16_t key_size, const uint16_t iv_size)
6081 : : {
6082 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6083 : : const struct rte_cryptodev_symmetric_capability *cap;
6084 : :
6085 : : /* Check if device supports the algorithm */
6086 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6087 : 0 : cap_idx.algo.cipher = cipher_algo;
6088 : :
6089 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6090 : : &cap_idx);
6091 : :
6092 [ # # ]: 0 : if (cap == NULL)
6093 : : return -1;
6094 : :
6095 : : /* Check if device supports key size and IV size */
6096 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6097 : : iv_size) < 0) {
6098 : 0 : return -1;
6099 : : }
6100 : :
6101 : : return 0;
6102 : : }
6103 : :
6104 : : static int
6105 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6106 : : const enum rte_crypto_auth_algorithm auth_algo,
6107 : : const uint16_t key_size, const uint16_t iv_size,
6108 : : const uint16_t tag_size)
6109 : : {
6110 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6111 : : const struct rte_cryptodev_symmetric_capability *cap;
6112 : :
6113 : : /* Check if device supports the algorithm */
6114 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6115 : 0 : cap_idx.algo.auth = auth_algo;
6116 : :
6117 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6118 : : &cap_idx);
6119 : :
6120 [ # # ]: 0 : if (cap == NULL)
6121 : : return -1;
6122 : :
6123 : : /* Check if device supports key size and IV size */
6124 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6125 : : tag_size, iv_size) < 0) {
6126 : 0 : return -1;
6127 : : }
6128 : :
6129 : : return 0;
6130 : : }
6131 : :
6132 : : static int
6133 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6134 : : enum rte_crypto_cipher_operation direction)
6135 : : {
6136 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6137 : : struct crypto_unittest_params *ut_params = &unittest_params;
6138 : :
6139 : : int retval;
6140 : : uint8_t *plaintext = NULL;
6141 : : uint8_t *ciphertext = NULL;
6142 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6143 : : unsigned int plaintext_len = 0;
6144 : : unsigned int ciphertext_len = 0;
6145 : : struct rte_cryptodev_info dev_info;
6146 : :
6147 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6148 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6149 : :
6150 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6151 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6152 : : printf("Device doesn't support RAW data-path APIs.\n");
6153 : 0 : return TEST_SKIPPED;
6154 : : }
6155 : :
6156 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6157 : : return TEST_SKIPPED;
6158 : :
6159 : : /* Check if device supports ZUC EEA3 */
6160 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6161 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6162 : : return TEST_SKIPPED;
6163 : :
6164 : : /* Create ZUC session */
6165 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6166 : : direction,
6167 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6168 : 0 : tdata->key.data, tdata->key.len,
6169 : 0 : tdata->cipher_iv.len);
6170 [ # # ]: 0 : if (retval != 0)
6171 : : return retval;
6172 : :
6173 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6174 : :
6175 : : /* Clear mbuf payload */
6176 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6177 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6178 : :
6179 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6180 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6181 : : /* Append data which is padded to a multiple */
6182 : : /* of the algorithms block size */
6183 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6184 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6185 : : plaintext_pad_len);
6186 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6187 : :
6188 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6189 : : } else {
6190 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6191 : : /* Append data which is padded to a multiple */
6192 : : /* of the algorithms block size */
6193 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6194 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6195 : : ciphertext_pad_len);
6196 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6197 : :
6198 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6199 : : }
6200 : :
6201 : : /* Create ZUC operation */
6202 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6203 : 0 : tdata->cipher_iv.len,
6204 : 0 : tdata->plaintext.len,
6205 : 0 : tdata->validCipherOffsetInBits.len);
6206 [ # # ]: 0 : if (retval < 0)
6207 : : return retval;
6208 : :
6209 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6210 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6211 : 0 : tdata->cipher_iv.len);
6212 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6213 : : return retval;
6214 : : } else
6215 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6216 : : ut_params->op);
6217 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6218 : :
6219 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6220 : :
6221 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6222 [ # # ]: 0 : if (ut_params->obuf)
6223 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6224 : : else
6225 : : ciphertext = plaintext;
6226 : :
6227 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6228 : :
6229 : : /* Validate obuf */
6230 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6231 : : ciphertext,
6232 : : tdata->ciphertext.data,
6233 : : tdata->validCipherLenInBits.len,
6234 : : "ZUC Ciphertext data not as expected");
6235 : : } else {
6236 [ # # ]: 0 : if (ut_params->obuf)
6237 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6238 : : else
6239 : : plaintext = ciphertext;
6240 : :
6241 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6242 : :
6243 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6244 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6245 : :
6246 : : /* Validate obuf */
6247 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6248 : : plaintext,
6249 : : reference_plaintext,
6250 : : tdata->validCipherLenInBits.len,
6251 : : "ZUC Plaintext data not as expected");
6252 : : }
6253 : :
6254 : : return 0;
6255 : : }
6256 : :
6257 : : static int
6258 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6259 : : enum rte_crypto_cipher_operation direction)
6260 : : {
6261 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6262 : : struct crypto_unittest_params *ut_params = &unittest_params;
6263 : :
6264 : : int retval;
6265 : :
6266 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6267 : : unsigned int plaintext_len = 0;
6268 : : unsigned int ciphertext_len = 0;
6269 : : const uint8_t *ciphertext, *plaintext;
6270 : : uint8_t buffer[2048];
6271 : : struct rte_cryptodev_info dev_info;
6272 : :
6273 : : /* Check if device supports ZUC EEA3 */
6274 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6275 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6276 : : return TEST_SKIPPED;
6277 : :
6278 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6279 : : return TEST_SKIPPED;
6280 : :
6281 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6282 : :
6283 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6284 : :
6285 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6286 : : printf("Device doesn't support in-place scatter-gather. "
6287 : : "Test Skipped.\n");
6288 : 0 : return TEST_SKIPPED;
6289 : : }
6290 : :
6291 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6292 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6293 : : printf("Device doesn't support RAW data-path APIs.\n");
6294 : 0 : return TEST_SKIPPED;
6295 : : }
6296 : :
6297 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6298 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6299 : :
6300 : : /* Append data which is padded to a multiple */
6301 : : /* of the algorithms block size */
6302 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6303 : :
6304 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6305 : : plaintext_pad_len, 10, 0);
6306 : :
6307 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6308 : 0 : tdata->plaintext.data);
6309 : : } else {
6310 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6311 : :
6312 : : /* Append data which is padded to a multiple */
6313 : : /* of the algorithms block size */
6314 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6315 : :
6316 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6317 : : ciphertext_pad_len, 10, 0);
6318 : :
6319 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6320 : 0 : tdata->ciphertext.data);
6321 : :
6322 : : }
6323 : :
6324 : : /* Create ZUC session */
6325 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6326 : : direction,
6327 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6328 : 0 : tdata->key.data, tdata->key.len,
6329 : 0 : tdata->cipher_iv.len);
6330 [ # # ]: 0 : if (retval < 0)
6331 : : return retval;
6332 : :
6333 : : /* Clear mbuf payload */
6334 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6335 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6336 : : else
6337 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6338 : :
6339 : : /* Create ZUC operation */
6340 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6341 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6342 : 0 : tdata->validCipherOffsetInBits.len);
6343 [ # # ]: 0 : if (retval < 0)
6344 : : return retval;
6345 : :
6346 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6347 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6348 : 0 : tdata->cipher_iv.len);
6349 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6350 : : return retval;
6351 : : } else
6352 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6353 : : ut_params->op);
6354 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6355 : :
6356 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6357 : :
6358 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6359 [ # # ]: 0 : if (ut_params->obuf)
6360 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6361 : : 0, plaintext_len, buffer);
6362 : : else
6363 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6364 : : 0, plaintext_len, buffer);
6365 : :
6366 : : /* Validate obuf */
6367 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6368 : :
6369 : : /* Validate obuf */
6370 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6371 : : ciphertext,
6372 : : tdata->ciphertext.data,
6373 : : tdata->validCipherLenInBits.len,
6374 : : "ZUC Ciphertext data not as expected");
6375 : : } else {
6376 [ # # ]: 0 : if (ut_params->obuf)
6377 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6378 : : 0, ciphertext_len, buffer);
6379 : : else
6380 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6381 : : 0, ciphertext_len, buffer);
6382 : :
6383 : : /* Validate obuf */
6384 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6385 : :
6386 : : /* Validate obuf */
6387 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6388 : : plaintext,
6389 : : tdata->plaintext.data,
6390 : : tdata->validCipherLenInBits.len,
6391 : : "ZUC Plaintext data not as expected");
6392 : : }
6393 : :
6394 : : return 0;
6395 : : }
6396 : :
6397 : : static int
6398 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6399 : : enum rte_crypto_auth_operation auth_op)
6400 : : {
6401 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6402 : : struct crypto_unittest_params *ut_params = &unittest_params;
6403 : :
6404 : : int retval;
6405 : : unsigned plaintext_pad_len;
6406 : : unsigned plaintext_len;
6407 : : uint8_t *plaintext;
6408 : :
6409 : : struct rte_cryptodev_info dev_info;
6410 : :
6411 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6412 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6413 : :
6414 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6415 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6416 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6417 : 0 : return TEST_SKIPPED;
6418 : : }
6419 : :
6420 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6421 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6422 : : printf("Device doesn't support RAW data-path APIs.\n");
6423 : 0 : return TEST_SKIPPED;
6424 : : }
6425 : :
6426 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6427 : : return TEST_SKIPPED;
6428 : :
6429 : : /* Check if device supports ZUC EIA3 */
6430 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6431 : 0 : tdata->key.len, tdata->auth_iv.len,
6432 : 0 : tdata->digest.len) < 0)
6433 : : return TEST_SKIPPED;
6434 : :
6435 : : /* Create ZUC session */
6436 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6437 : 0 : tdata->key.data, tdata->key.len,
6438 : 0 : tdata->auth_iv.len, tdata->digest.len,
6439 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6440 [ # # ]: 0 : if (retval != 0)
6441 : : return retval;
6442 : :
6443 : : /* alloc mbuf and set payload */
6444 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6445 : :
6446 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6447 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6448 : :
6449 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6450 : : /* Append data which is padded to a multiple of */
6451 : : /* the algorithms block size */
6452 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6453 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6454 : : plaintext_pad_len);
6455 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6456 : :
6457 : : /* Create ZUC operation */
6458 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6459 : 0 : tdata->digest.len,
6460 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6461 : : plaintext_pad_len,
6462 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6463 [ # # ]: 0 : if (retval < 0)
6464 : : return retval;
6465 : :
6466 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6467 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6468 : : 0);
6469 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6470 : : return retval;
6471 : : } else
6472 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6473 : : ut_params->op);
6474 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6475 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6476 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6477 : : uint8_t *,
6478 : : plaintext_pad_len);
6479 : :
6480 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6481 : : /* Validate obuf */
6482 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6483 : : ut_params->digest,
6484 : : tdata->digest.data,
6485 : : tdata->digest.len,
6486 : : "ZUC Generated auth tag not as expected");
6487 : : return 0;
6488 : : }
6489 : :
6490 : : /* Validate obuf */
6491 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6492 : : return 0;
6493 : : else
6494 : 0 : return -1;
6495 : :
6496 : : return 0;
6497 : : }
6498 : :
6499 : : static int
6500 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6501 : : uint8_t op_mode, uint8_t verify)
6502 : : {
6503 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6504 : : struct crypto_unittest_params *ut_params = &unittest_params;
6505 : :
6506 : : int retval;
6507 : :
6508 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6509 : : unsigned int plaintext_pad_len;
6510 : : unsigned int plaintext_len;
6511 : : unsigned int ciphertext_pad_len;
6512 : : unsigned int ciphertext_len;
6513 : : unsigned int digest_offset;
6514 : :
6515 : : struct rte_cryptodev_info dev_info;
6516 : :
6517 : : /* Check if device supports ZUC EEA3 */
6518 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6519 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6520 : : return TEST_SKIPPED;
6521 : :
6522 : : /* Check if device supports ZUC EIA3 */
6523 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6524 : 0 : tdata->key.len, tdata->auth_iv.len,
6525 : 0 : tdata->digest.len) < 0)
6526 : : return TEST_SKIPPED;
6527 : :
6528 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6529 : : return TEST_SKIPPED;
6530 : :
6531 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6532 : :
6533 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6534 : :
6535 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6536 : : printf("Device doesn't support digest encrypted.\n");
6537 : 0 : return TEST_SKIPPED;
6538 : : }
6539 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6540 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6541 : : printf("Device doesn't support in-place scatter-gather "
6542 : : "in both input and output mbufs.\n");
6543 : 0 : return TEST_SKIPPED;
6544 : : }
6545 : :
6546 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6547 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6548 : : printf("Device doesn't support RAW data-path APIs.\n");
6549 : 0 : return TEST_SKIPPED;
6550 : : }
6551 : : } else {
6552 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6553 : : return TEST_SKIPPED;
6554 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6555 : : printf("Device doesn't support out-of-place scatter-gather "
6556 : : "in both input and output mbufs.\n");
6557 : 0 : return TEST_SKIPPED;
6558 : : }
6559 : : }
6560 : :
6561 : : /* Create ZUC session */
6562 : 0 : retval = create_wireless_algo_auth_cipher_session(
6563 : 0 : ts_params->valid_devs[0],
6564 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6565 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6566 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6567 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6568 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6569 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6570 : : tdata->key.data, tdata->key.len,
6571 : 0 : tdata->key.data, tdata->key.len,
6572 : 0 : tdata->auth_iv.len, tdata->digest.len,
6573 : 0 : tdata->cipher_iv.len);
6574 : :
6575 [ # # ]: 0 : if (retval != 0)
6576 : : return retval;
6577 : :
6578 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6579 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6580 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6581 : :
6582 : : /* clear mbuf payload */
6583 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6584 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6585 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6586 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6587 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6588 : :
6589 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6590 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6591 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6592 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6593 : :
6594 [ # # ]: 0 : if (verify) {
6595 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6596 : : ciphertext_pad_len);
6597 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6598 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6599 : : ciphertext_len);
6600 : : } else {
6601 : : /* make sure enough space to cover partial digest verify case */
6602 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6603 : : ciphertext_pad_len);
6604 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6605 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6606 : : plaintext_len);
6607 : : }
6608 : :
6609 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6610 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6611 : :
6612 : : /* Create ZUC operation */
6613 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6614 : 0 : tdata->digest.data, tdata->digest.len,
6615 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6616 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6617 : 0 : (tdata->digest.offset_bytes == 0 ?
6618 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6619 : : : tdata->digest.offset_bytes),
6620 : 0 : tdata->validCipherLenInBits.len,
6621 : 0 : tdata->validCipherOffsetInBits.len,
6622 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6623 : : 0,
6624 : : op_mode, 0, verify);
6625 : :
6626 [ # # ]: 0 : if (retval < 0)
6627 : : return retval;
6628 : :
6629 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6630 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6631 : 0 : tdata->cipher_iv.len);
6632 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6633 : : return retval;
6634 : : } else
6635 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6636 : : ut_params->op);
6637 : :
6638 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6639 : :
6640 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6641 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6642 : :
6643 : :
6644 [ # # ]: 0 : if (verify) {
6645 [ # # ]: 0 : if (ut_params->obuf)
6646 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6647 : : uint8_t *);
6648 : : else
6649 : : plaintext = ciphertext;
6650 : :
6651 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6652 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6653 : 0 : debug_hexdump(stdout, "plaintext expected:",
6654 : 0 : tdata->plaintext.data,
6655 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6656 : : } else {
6657 [ # # ]: 0 : if (ut_params->obuf)
6658 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6659 : : uint8_t *);
6660 : : else
6661 : : ciphertext = plaintext;
6662 : :
6663 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6664 : : ciphertext_len);
6665 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6666 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6667 : :
6668 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6669 : : digest_offset = plaintext_pad_len;
6670 : : else
6671 : : digest_offset = tdata->digest.offset_bytes;
6672 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6673 : : uint8_t *, digest_offset);
6674 : :
6675 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6676 : 0 : tdata->digest.len);
6677 : 0 : debug_hexdump(stdout, "digest expected:",
6678 : 0 : tdata->digest.data, tdata->digest.len);
6679 : : }
6680 : :
6681 : : /* Validate obuf */
6682 [ # # ]: 0 : if (verify) {
6683 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6684 : : plaintext,
6685 : : tdata->plaintext.data,
6686 : : tdata->plaintext.len >> 3,
6687 : : "ZUC Plaintext data not as expected");
6688 : : } else {
6689 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6690 : : ciphertext,
6691 : : tdata->ciphertext.data,
6692 : : tdata->ciphertext.len >> 3,
6693 : : "ZUC Ciphertext data not as expected");
6694 : :
6695 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6696 : : ut_params->digest,
6697 : : tdata->digest.data,
6698 : : tdata->digest.len,
6699 : : "ZUC Generated auth tag not as expected");
6700 : : }
6701 : : return 0;
6702 : : }
6703 : :
6704 : : static int
6705 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6706 : : uint8_t op_mode, uint8_t verify)
6707 : : {
6708 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6709 : : struct crypto_unittest_params *ut_params = &unittest_params;
6710 : :
6711 : : int retval;
6712 : :
6713 : : const uint8_t *plaintext = NULL;
6714 : : const uint8_t *ciphertext = NULL;
6715 : : const uint8_t *digest = NULL;
6716 : : unsigned int plaintext_pad_len;
6717 : : unsigned int plaintext_len;
6718 : : unsigned int ciphertext_pad_len;
6719 : : unsigned int ciphertext_len;
6720 : : uint8_t buffer[10000];
6721 : : uint8_t digest_buffer[10000];
6722 : :
6723 : : struct rte_cryptodev_info dev_info;
6724 : :
6725 : : /* Check if device supports ZUC EEA3 */
6726 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6727 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6728 : : return TEST_SKIPPED;
6729 : :
6730 : : /* Check if device supports ZUC EIA3 */
6731 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6732 : 0 : tdata->key.len, tdata->auth_iv.len,
6733 : 0 : tdata->digest.len) < 0)
6734 : : return TEST_SKIPPED;
6735 : :
6736 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6737 : : return TEST_SKIPPED;
6738 : :
6739 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6740 : :
6741 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6742 : :
6743 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6744 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6745 : : printf("Device doesn't support in-place scatter-gather "
6746 : : "in both input and output mbufs.\n");
6747 : 0 : return TEST_SKIPPED;
6748 : : }
6749 : :
6750 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6751 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6752 : : printf("Device doesn't support RAW data-path APIs.\n");
6753 : 0 : return TEST_SKIPPED;
6754 : : }
6755 : : } else {
6756 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6757 : : return TEST_SKIPPED;
6758 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6759 : : printf("Device doesn't support out-of-place scatter-gather "
6760 : : "in both input and output mbufs.\n");
6761 : 0 : return TEST_SKIPPED;
6762 : : }
6763 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6764 : : printf("Device doesn't support digest encrypted.\n");
6765 : 0 : return TEST_SKIPPED;
6766 : : }
6767 : : }
6768 : :
6769 : : /* Create ZUC session */
6770 : 0 : retval = create_wireless_algo_auth_cipher_session(
6771 : 0 : ts_params->valid_devs[0],
6772 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6773 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6774 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6775 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6776 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6777 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6778 : : tdata->key.data, tdata->key.len,
6779 : 0 : tdata->key.data, tdata->key.len,
6780 : 0 : tdata->auth_iv.len, tdata->digest.len,
6781 : 0 : tdata->cipher_iv.len);
6782 : :
6783 [ # # ]: 0 : if (retval != 0)
6784 : : return retval;
6785 : :
6786 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6787 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6788 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6789 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6790 : :
6791 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6792 : : plaintext_pad_len, 15, 0);
6793 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6794 : : "Failed to allocate input buffer in mempool");
6795 : :
6796 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6797 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6798 : : plaintext_pad_len, 15, 0);
6799 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6800 : : "Failed to allocate output buffer in mempool");
6801 : : }
6802 : :
6803 [ # # ]: 0 : if (verify) {
6804 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6805 : 0 : tdata->ciphertext.data);
6806 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6807 : : ciphertext_len, buffer);
6808 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6809 : : ciphertext_len);
6810 : : } else {
6811 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6812 : 0 : tdata->plaintext.data);
6813 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6814 : : plaintext_len, buffer);
6815 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6816 : : plaintext_len);
6817 : : }
6818 : : memset(buffer, 0, sizeof(buffer));
6819 : :
6820 : : /* Create ZUC operation */
6821 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6822 : 0 : tdata->digest.data, tdata->digest.len,
6823 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6824 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6825 : 0 : (tdata->digest.offset_bytes == 0 ?
6826 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6827 : : : tdata->digest.offset_bytes),
6828 : 0 : tdata->validCipherLenInBits.len,
6829 : 0 : tdata->validCipherOffsetInBits.len,
6830 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6831 : : 0,
6832 : : op_mode, 1, verify);
6833 : :
6834 [ # # ]: 0 : if (retval < 0)
6835 : : return retval;
6836 : :
6837 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6838 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6839 : 0 : tdata->cipher_iv.len);
6840 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6841 : : return retval;
6842 : : } else
6843 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6844 : : ut_params->op);
6845 : :
6846 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6847 : :
6848 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6849 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6850 : :
6851 [ # # ]: 0 : if (verify) {
6852 [ # # ]: 0 : if (ut_params->obuf)
6853 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6854 : : plaintext_len, buffer);
6855 : : else
6856 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6857 : : plaintext_len, buffer);
6858 : :
6859 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6860 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6861 : 0 : debug_hexdump(stdout, "plaintext expected:",
6862 : 0 : tdata->plaintext.data,
6863 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6864 : : } else {
6865 [ # # ]: 0 : if (ut_params->obuf)
6866 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6867 : : ciphertext_len, buffer);
6868 : : else
6869 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6870 : : ciphertext_len, buffer);
6871 : :
6872 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6873 : : ciphertext_len);
6874 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6875 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6876 : :
6877 [ # # ]: 0 : if (ut_params->obuf)
6878 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6879 : 0 : (tdata->digest.offset_bytes == 0 ?
6880 : : plaintext_pad_len : tdata->digest.offset_bytes),
6881 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6882 : : else
6883 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6884 : 0 : (tdata->digest.offset_bytes == 0 ?
6885 : : plaintext_pad_len : tdata->digest.offset_bytes),
6886 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6887 : :
6888 : 0 : debug_hexdump(stdout, "digest:", digest,
6889 : 0 : tdata->digest.len);
6890 : 0 : debug_hexdump(stdout, "digest expected:",
6891 : 0 : tdata->digest.data, tdata->digest.len);
6892 : : }
6893 : :
6894 : : /* Validate obuf */
6895 [ # # ]: 0 : if (verify) {
6896 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6897 : : plaintext,
6898 : : tdata->plaintext.data,
6899 : : tdata->plaintext.len >> 3,
6900 : : "ZUC Plaintext data not as expected");
6901 : : } else {
6902 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6903 : : ciphertext,
6904 : : tdata->ciphertext.data,
6905 : : tdata->validDataLenInBits.len,
6906 : : "ZUC Ciphertext data not as expected");
6907 : :
6908 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6909 : : digest,
6910 : : tdata->digest.data,
6911 : : tdata->digest.len,
6912 : : "ZUC Generated auth tag not as expected");
6913 : : }
6914 : : return 0;
6915 : : }
6916 : :
6917 : : static int
6918 : 0 : test_kasumi_encryption_test_case_1(void)
6919 : : {
6920 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
6921 : : }
6922 : :
6923 : : static int
6924 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
6925 : : {
6926 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6927 : : }
6928 : :
6929 : : static int
6930 : 0 : test_kasumi_encryption_test_case_1_oop(void)
6931 : : {
6932 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
6933 : : }
6934 : :
6935 : : static int
6936 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
6937 : : {
6938 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6939 : : }
6940 : :
6941 : : static int
6942 : 0 : test_kasumi_encryption_test_case_2(void)
6943 : : {
6944 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
6945 : : }
6946 : :
6947 : : static int
6948 : 0 : test_kasumi_encryption_test_case_3(void)
6949 : : {
6950 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
6951 : : }
6952 : :
6953 : : static int
6954 : 0 : test_kasumi_encryption_test_case_4(void)
6955 : : {
6956 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
6957 : : }
6958 : :
6959 : : static int
6960 : 0 : test_kasumi_encryption_test_case_5(void)
6961 : : {
6962 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
6963 : : }
6964 : :
6965 : : static int
6966 : 0 : test_kasumi_decryption_test_case_1(void)
6967 : : {
6968 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
6969 : : }
6970 : :
6971 : : static int
6972 : 0 : test_kasumi_decryption_test_case_1_oop(void)
6973 : : {
6974 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
6975 : : }
6976 : :
6977 : : static int
6978 : 0 : test_kasumi_decryption_test_case_2(void)
6979 : : {
6980 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
6981 : : }
6982 : :
6983 : : static int
6984 : 0 : test_kasumi_decryption_test_case_3(void)
6985 : : {
6986 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6987 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6988 : : return TEST_SKIPPED;
6989 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
6990 : : }
6991 : :
6992 : : static int
6993 : 0 : test_kasumi_decryption_test_case_4(void)
6994 : : {
6995 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
6996 : : }
6997 : :
6998 : : static int
6999 : 0 : test_kasumi_decryption_test_case_5(void)
7000 : : {
7001 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7002 : : }
7003 : : static int
7004 : 0 : test_snow3g_encryption_test_case_1(void)
7005 : : {
7006 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7007 : : }
7008 : :
7009 : : static int
7010 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7011 : : {
7012 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7013 : : }
7014 : :
7015 : : static int
7016 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7017 : : {
7018 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7019 : : }
7020 : :
7021 : : static int
7022 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7023 : : {
7024 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7025 : : }
7026 : :
7027 : : static int
7028 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7029 : : {
7030 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7031 : : }
7032 : :
7033 : : static int
7034 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7035 : : {
7036 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7037 : : }
7038 : :
7039 : : static int
7040 : 0 : test_snow3g_encryption_test_case_2(void)
7041 : : {
7042 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7043 : : }
7044 : :
7045 : : static int
7046 : 0 : test_snow3g_encryption_test_case_3(void)
7047 : : {
7048 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7049 : : }
7050 : :
7051 : : static int
7052 : 0 : test_snow3g_encryption_test_case_4(void)
7053 : : {
7054 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7055 : : }
7056 : :
7057 : : static int
7058 : 0 : test_snow3g_encryption_test_case_5(void)
7059 : : {
7060 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7061 : : }
7062 : :
7063 : : static int
7064 : 0 : test_snow3g_decryption_test_case_1(void)
7065 : : {
7066 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7067 : : }
7068 : :
7069 : : static int
7070 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7071 : : {
7072 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7073 : : }
7074 : :
7075 : : static int
7076 : 0 : test_snow3g_decryption_test_case_2(void)
7077 : : {
7078 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7079 : : }
7080 : :
7081 : : static int
7082 : 0 : test_snow3g_decryption_test_case_3(void)
7083 : : {
7084 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7085 : : }
7086 : :
7087 : : static int
7088 : 0 : test_snow3g_decryption_test_case_4(void)
7089 : : {
7090 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7091 : : }
7092 : :
7093 : : static int
7094 : 0 : test_snow3g_decryption_test_case_5(void)
7095 : : {
7096 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7097 : : }
7098 : :
7099 : : /*
7100 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7101 : : * Pattern digest from snow3g_test_data must be allocated as
7102 : : * 4 last bytes in plaintext.
7103 : : */
7104 : : static void
7105 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7106 : : struct snow3g_hash_test_data *output)
7107 : : {
7108 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7109 : 0 : output->key.len = pattern->key.len;
7110 : :
7111 : 0 : memcpy(output->key.data,
7112 : 0 : pattern->key.data, pattern->key.len);
7113 : :
7114 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7115 : :
7116 : 0 : memcpy(output->auth_iv.data,
7117 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7118 : :
7119 : 0 : output->plaintext.len = pattern->plaintext.len;
7120 : :
7121 : 0 : memcpy(output->plaintext.data,
7122 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7123 : :
7124 : 0 : output->digest.len = pattern->digest.len;
7125 : :
7126 : 0 : memcpy(output->digest.data,
7127 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7128 : : pattern->digest.len);
7129 : :
7130 : 0 : output->validAuthLenInBits.len =
7131 : 0 : pattern->validAuthLenInBits.len;
7132 : : }
7133 : 0 : }
7134 : :
7135 : : /*
7136 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7137 : : */
7138 : : static int
7139 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7140 : : {
7141 : : int ret;
7142 : : struct snow3g_hash_test_data snow3g_hash_data;
7143 : : struct rte_cryptodev_info dev_info;
7144 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7145 : :
7146 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7147 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7148 : :
7149 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7150 : : printf("Device doesn't support encrypted digest operations.\n");
7151 : 0 : return TEST_SKIPPED;
7152 : : }
7153 : :
7154 : : /*
7155 : : * Function prepare data for hash verification test case.
7156 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7157 : : */
7158 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7159 : :
7160 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7161 [ # # ]: 0 : if (ret != 0)
7162 : : return ret;
7163 : :
7164 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7165 : : }
7166 : :
7167 : : static int
7168 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7169 : : {
7170 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7171 : : }
7172 : :
7173 : : static int
7174 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7175 : : {
7176 : 0 : return test_snow3g_auth_cipher(
7177 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7178 : : }
7179 : :
7180 : : static int
7181 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7182 : : {
7183 : 0 : return test_snow3g_auth_cipher(
7184 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7185 : : }
7186 : :
7187 : : static int
7188 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7189 : : {
7190 : 0 : return test_snow3g_auth_cipher(
7191 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7192 : : }
7193 : :
7194 : : static int
7195 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7196 : : {
7197 : 0 : return test_snow3g_auth_cipher(
7198 : : &snow3g_auth_cipher_partial_digest_encryption,
7199 : : IN_PLACE, 0);
7200 : : }
7201 : :
7202 : : static int
7203 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7204 : : {
7205 : 0 : return test_snow3g_auth_cipher(
7206 : : &snow3g_auth_cipher_partial_digest_encryption,
7207 : : OUT_OF_PLACE, 0);
7208 : : }
7209 : :
7210 : : static int
7211 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7212 : : {
7213 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7214 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7215 : : return TEST_SKIPPED;
7216 : 0 : return test_snow3g_auth_cipher_sgl(
7217 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7218 : : }
7219 : :
7220 : : static int
7221 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7222 : : {
7223 : 0 : return test_snow3g_auth_cipher_sgl(
7224 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7225 : : }
7226 : :
7227 : : static int
7228 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7229 : : {
7230 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7231 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7232 : : return TEST_SKIPPED;
7233 : 0 : return test_snow3g_auth_cipher_sgl(
7234 : : &snow3g_auth_cipher_partial_digest_encryption,
7235 : : IN_PLACE, 0);
7236 : : }
7237 : :
7238 : : static int
7239 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7240 : : {
7241 : 0 : return test_snow3g_auth_cipher_sgl(
7242 : : &snow3g_auth_cipher_partial_digest_encryption,
7243 : : OUT_OF_PLACE, 0);
7244 : : }
7245 : :
7246 : : static int
7247 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7248 : : {
7249 : 0 : return test_snow3g_auth_cipher(
7250 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7251 : : }
7252 : :
7253 : : static int
7254 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7255 : : {
7256 : 0 : return test_snow3g_auth_cipher(
7257 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7258 : : }
7259 : :
7260 : : static int
7261 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7262 : : {
7263 : 0 : return test_snow3g_auth_cipher_sgl(
7264 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7265 : : }
7266 : :
7267 : : static int
7268 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7269 : : {
7270 : 0 : return test_snow3g_auth_cipher_sgl(
7271 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7272 : : }
7273 : :
7274 : : static int
7275 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7276 : : {
7277 : 0 : return test_snow3g_auth_cipher(
7278 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7279 : : }
7280 : :
7281 : : static int
7282 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7283 : : {
7284 : 0 : return test_snow3g_auth_cipher(
7285 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7286 : : }
7287 : :
7288 : : static int
7289 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7290 : : {
7291 : 0 : return test_snow3g_auth_cipher(
7292 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7293 : : }
7294 : :
7295 : : static int
7296 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7297 : : {
7298 : 0 : return test_snow3g_auth_cipher(
7299 : : &snow3g_auth_cipher_partial_digest_encryption,
7300 : : IN_PLACE, 1);
7301 : : }
7302 : :
7303 : : static int
7304 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7305 : : {
7306 : 0 : return test_snow3g_auth_cipher(
7307 : : &snow3g_auth_cipher_partial_digest_encryption,
7308 : : OUT_OF_PLACE, 1);
7309 : : }
7310 : :
7311 : : static int
7312 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7313 : : {
7314 : 0 : return test_snow3g_auth_cipher_sgl(
7315 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7316 : : }
7317 : :
7318 : : static int
7319 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7320 : : {
7321 : 0 : return test_snow3g_auth_cipher_sgl(
7322 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7323 : : }
7324 : :
7325 : : static int
7326 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7327 : : {
7328 : 0 : return test_snow3g_auth_cipher_sgl(
7329 : : &snow3g_auth_cipher_partial_digest_encryption,
7330 : : IN_PLACE, 1);
7331 : : }
7332 : :
7333 : : static int
7334 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7335 : : {
7336 : 0 : return test_snow3g_auth_cipher_sgl(
7337 : : &snow3g_auth_cipher_partial_digest_encryption,
7338 : : OUT_OF_PLACE, 1);
7339 : : }
7340 : :
7341 : : static int
7342 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7343 : : {
7344 : 0 : return test_snow3g_auth_cipher(
7345 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7346 : : }
7347 : :
7348 : : static int
7349 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7350 : : {
7351 : 0 : return test_snow3g_auth_cipher(
7352 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7353 : : }
7354 : :
7355 : : static int
7356 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7357 : : {
7358 : 0 : return test_snow3g_auth_cipher_sgl(
7359 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7360 : : }
7361 : :
7362 : : static int
7363 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7364 : : {
7365 : 0 : return test_snow3g_auth_cipher_sgl(
7366 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7367 : : }
7368 : :
7369 : : static int
7370 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7371 : : {
7372 : 0 : return test_snow3g_auth_cipher(
7373 : : &snow3g_test_case_7, IN_PLACE, 0);
7374 : : }
7375 : :
7376 : : static int
7377 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7378 : : {
7379 : 0 : return test_kasumi_auth_cipher(
7380 : : &kasumi_test_case_3, IN_PLACE, 0);
7381 : : }
7382 : :
7383 : : static int
7384 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7385 : : {
7386 : 0 : return test_kasumi_auth_cipher(
7387 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7388 : : }
7389 : :
7390 : : static int
7391 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7392 : : {
7393 : 0 : return test_kasumi_auth_cipher(
7394 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7395 : : }
7396 : :
7397 : : static int
7398 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7399 : : {
7400 : 0 : return test_kasumi_auth_cipher_sgl(
7401 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7402 : : }
7403 : :
7404 : : static int
7405 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7406 : : {
7407 : 0 : return test_kasumi_auth_cipher_sgl(
7408 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7409 : : }
7410 : :
7411 : : static int
7412 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7413 : : {
7414 : 0 : return test_kasumi_auth_cipher(
7415 : : &kasumi_test_case_3, IN_PLACE, 1);
7416 : : }
7417 : :
7418 : : static int
7419 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7420 : : {
7421 : 0 : return test_kasumi_auth_cipher(
7422 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7423 : : }
7424 : :
7425 : : static int
7426 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7427 : : {
7428 : 0 : return test_kasumi_auth_cipher(
7429 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7430 : : }
7431 : :
7432 : : static int
7433 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7434 : : {
7435 : 0 : return test_kasumi_auth_cipher_sgl(
7436 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7437 : : }
7438 : :
7439 : : static int
7440 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7441 : : {
7442 : 0 : return test_kasumi_auth_cipher_sgl(
7443 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7444 : : }
7445 : :
7446 : : static int
7447 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7448 : : {
7449 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7450 : : }
7451 : :
7452 : : static int
7453 : 0 : test_zuc_encryption_test_case_1(void)
7454 : : {
7455 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7456 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7457 : : }
7458 : :
7459 : : static int
7460 : 0 : test_zuc_encryption_test_case_2(void)
7461 : : {
7462 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7463 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7464 : : }
7465 : :
7466 : : static int
7467 : 0 : test_zuc_encryption_test_case_3(void)
7468 : : {
7469 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7470 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7471 : : }
7472 : :
7473 : : static int
7474 : 0 : test_zuc_encryption_test_case_4(void)
7475 : : {
7476 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7477 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7478 : : }
7479 : :
7480 : : static int
7481 : 0 : test_zuc_encryption_test_case_5(void)
7482 : : {
7483 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7484 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7485 : : }
7486 : :
7487 : : static int
7488 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7489 : : {
7490 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7491 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7492 : : }
7493 : :
7494 : : static int
7495 : 0 : test_zuc_decryption_test_case_1(void)
7496 : : {
7497 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7498 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7499 : : }
7500 : :
7501 : : static int
7502 : 0 : test_zuc_decryption_test_case_2(void)
7503 : : {
7504 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7505 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7506 : : }
7507 : :
7508 : : static int
7509 : 0 : test_zuc_decryption_test_case_3(void)
7510 : : {
7511 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7512 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7513 : : }
7514 : :
7515 : : static int
7516 : 0 : test_zuc_decryption_test_case_4(void)
7517 : : {
7518 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7519 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7520 : : }
7521 : :
7522 : : static int
7523 : 0 : test_zuc_decryption_test_case_5(void)
7524 : : {
7525 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7526 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7527 : : }
7528 : :
7529 : : static int
7530 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7531 : : {
7532 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7533 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7534 : : }
7535 : :
7536 : : static int
7537 : 0 : test_zuc_hash_generate_test_case_1(void)
7538 : : {
7539 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7540 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7541 : : }
7542 : :
7543 : : static int
7544 : 0 : test_zuc_hash_generate_test_case_2(void)
7545 : : {
7546 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7547 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7548 : : }
7549 : :
7550 : : static int
7551 : 0 : test_zuc_hash_generate_test_case_3(void)
7552 : : {
7553 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7554 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7555 : : }
7556 : :
7557 : : static int
7558 : 0 : test_zuc_hash_generate_test_case_4(void)
7559 : : {
7560 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7561 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7562 : : }
7563 : :
7564 : : static int
7565 : 0 : test_zuc_hash_generate_test_case_5(void)
7566 : : {
7567 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7568 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7569 : : }
7570 : :
7571 : : static int
7572 : 0 : test_zuc_hash_generate_test_case_6(void)
7573 : : {
7574 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7575 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7576 : : }
7577 : :
7578 : : static int
7579 : 0 : test_zuc_hash_generate_test_case_7(void)
7580 : : {
7581 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7582 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7583 : : }
7584 : :
7585 : : static int
7586 : 0 : test_zuc_hash_generate_test_case_8(void)
7587 : : {
7588 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7589 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7590 : : }
7591 : :
7592 : : static int
7593 : 0 : test_zuc_hash_verify_test_case_1(void)
7594 : : {
7595 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7596 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7597 : : }
7598 : :
7599 : : static int
7600 : 0 : test_zuc_hash_verify_test_case_2(void)
7601 : : {
7602 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7603 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7604 : : }
7605 : :
7606 : : static int
7607 : 0 : test_zuc_hash_verify_test_case_3(void)
7608 : : {
7609 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7610 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7611 : : }
7612 : :
7613 : : static int
7614 : 0 : test_zuc_hash_verify_test_case_4(void)
7615 : : {
7616 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7617 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7618 : : }
7619 : :
7620 : : static int
7621 : 0 : test_zuc_hash_verify_test_case_5(void)
7622 : : {
7623 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7624 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7625 : : }
7626 : :
7627 : : static int
7628 : 0 : test_zuc_hash_verify_test_case_6(void)
7629 : : {
7630 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7631 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7632 : : }
7633 : :
7634 : : static int
7635 : 0 : test_zuc_hash_verify_test_case_7(void)
7636 : : {
7637 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7638 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7639 : : }
7640 : :
7641 : : static int
7642 : 0 : test_zuc_hash_verify_test_case_8(void)
7643 : : {
7644 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7645 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7646 : : }
7647 : :
7648 : : static int
7649 : 0 : test_zuc_cipher_auth_test_case_1(void)
7650 : : {
7651 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7652 : : }
7653 : :
7654 : : static int
7655 : 0 : test_zuc_cipher_auth_test_case_2(void)
7656 : : {
7657 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7658 : : }
7659 : :
7660 : : static int
7661 : 0 : test_zuc_auth_cipher_test_case_1(void)
7662 : : {
7663 : 0 : return test_zuc_auth_cipher(
7664 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7665 : : }
7666 : :
7667 : : static int
7668 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
7669 : : {
7670 : 0 : return test_zuc_auth_cipher(
7671 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7672 : : }
7673 : :
7674 : : static int
7675 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
7676 : : {
7677 : 0 : return test_zuc_auth_cipher_sgl(
7678 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7679 : : }
7680 : :
7681 : : static int
7682 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7683 : : {
7684 : 0 : return test_zuc_auth_cipher_sgl(
7685 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7686 : : }
7687 : :
7688 : : static int
7689 : 0 : test_zuc_auth_cipher_test_case_2(void)
7690 : : {
7691 : 0 : return test_zuc_auth_cipher(
7692 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7693 : : }
7694 : :
7695 : : static int
7696 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
7697 : : {
7698 : 0 : return test_zuc_auth_cipher(
7699 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7700 : : }
7701 : :
7702 : : static int
7703 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
7704 : : {
7705 : 0 : return test_zuc_auth_cipher(
7706 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7707 : : }
7708 : :
7709 : : static int
7710 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
7711 : : {
7712 : 0 : return test_zuc_auth_cipher(
7713 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7714 : : }
7715 : :
7716 : : static int
7717 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7718 : : {
7719 : 0 : return test_zuc_auth_cipher_sgl(
7720 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7721 : : }
7722 : :
7723 : : static int
7724 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7725 : : {
7726 : 0 : return test_zuc_auth_cipher_sgl(
7727 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7728 : : }
7729 : :
7730 : : static int
7731 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
7732 : : {
7733 : 0 : return test_zuc_auth_cipher(
7734 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7735 : : }
7736 : :
7737 : : static int
7738 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
7739 : : {
7740 : 0 : return test_zuc_auth_cipher(
7741 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7742 : : }
7743 : :
7744 : : static int
7745 : 0 : test_zuc256_encryption_test_case_1(void)
7746 : : {
7747 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7748 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7749 : : }
7750 : :
7751 : : static int
7752 : 0 : test_zuc256_encryption_test_case_2(void)
7753 : : {
7754 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7755 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7756 : : }
7757 : :
7758 : : static int
7759 : 0 : test_zuc256_decryption_test_case_1(void)
7760 : : {
7761 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7762 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7763 : : }
7764 : :
7765 : : static int
7766 : 0 : test_zuc256_decryption_test_case_2(void)
7767 : : {
7768 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7769 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7770 : : }
7771 : :
7772 : : static int
7773 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
7774 : : {
7775 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7776 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7777 : : }
7778 : :
7779 : : static int
7780 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
7781 : : {
7782 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7783 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7784 : : }
7785 : :
7786 : : static int
7787 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
7788 : : {
7789 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7790 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7791 : : }
7792 : :
7793 : : static int
7794 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
7795 : : {
7796 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7797 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7798 : : }
7799 : :
7800 : : static int
7801 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
7802 : : {
7803 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7804 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7805 : : }
7806 : :
7807 : : static int
7808 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
7809 : : {
7810 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7811 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7812 : : }
7813 : :
7814 : : static int
7815 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
7816 : : {
7817 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7818 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7819 : : }
7820 : :
7821 : : static int
7822 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
7823 : : {
7824 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7825 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7826 : : }
7827 : :
7828 : : static int
7829 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
7830 : : {
7831 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7832 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7833 : : }
7834 : :
7835 : : static int
7836 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
7837 : : {
7838 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7839 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7840 : : }
7841 : :
7842 : : static int
7843 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7844 : : {
7845 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7846 : : }
7847 : :
7848 : : static int
7849 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7850 : : {
7851 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7852 : : }
7853 : :
7854 : : static int
7855 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
7856 : : {
7857 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
7858 : : }
7859 : :
7860 : : static int
7861 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
7862 : : {
7863 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
7864 : : }
7865 : :
7866 : : static int
7867 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
7868 : : {
7869 : 0 : return test_zuc_auth_cipher(
7870 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
7871 : : }
7872 : :
7873 : : static int
7874 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
7875 : : {
7876 : 0 : return test_zuc_auth_cipher(
7877 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
7878 : : }
7879 : :
7880 : : static int
7881 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
7882 : : {
7883 : 0 : return test_zuc_auth_cipher(
7884 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
7885 : : }
7886 : :
7887 : : static int
7888 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
7889 : : {
7890 : 0 : return test_zuc_auth_cipher(
7891 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
7892 : : }
7893 : :
7894 : : static int
7895 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
7896 : : {
7897 : 0 : return test_zuc_auth_cipher(
7898 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
7899 : : }
7900 : :
7901 : : static int
7902 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
7903 : : {
7904 : 0 : return test_zuc_auth_cipher(
7905 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
7906 : : }
7907 : :
7908 : : static int
7909 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
7910 : : {
7911 : 0 : return test_zuc_auth_cipher(
7912 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
7913 : : }
7914 : :
7915 : : static int
7916 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
7917 : : {
7918 : 0 : return test_zuc_auth_cipher(
7919 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
7920 : : }
7921 : :
7922 : : static int
7923 : 0 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7924 : : {
7925 : 0 : uint8_t dev_id = testsuite_params.valid_devs[0];
7926 : :
7927 : : struct rte_cryptodev_sym_capability_idx cap_idx;
7928 : :
7929 : : /* Check if device supports particular cipher algorithm */
7930 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7931 : 0 : cap_idx.algo.cipher = tdata->cipher_algo;
7932 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7933 : : return TEST_SKIPPED;
7934 : :
7935 : : /* Check if device supports particular hash algorithm */
7936 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7937 : 0 : cap_idx.algo.auth = tdata->auth_algo;
7938 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7939 : 0 : return TEST_SKIPPED;
7940 : :
7941 : : return 0;
7942 : : }
7943 : :
7944 : : static int
7945 : 0 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7946 : : uint8_t op_mode, uint8_t verify)
7947 : : {
7948 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7949 : : struct crypto_unittest_params *ut_params = &unittest_params;
7950 : :
7951 : : int retval;
7952 : :
7953 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
7954 : : unsigned int plaintext_pad_len;
7955 : : unsigned int plaintext_len;
7956 : : unsigned int ciphertext_pad_len;
7957 : : unsigned int ciphertext_len;
7958 : : unsigned int digest_offset;
7959 : :
7960 : : struct rte_cryptodev_info dev_info;
7961 : : struct rte_crypto_op *op;
7962 : :
7963 : : /* Check if device supports particular algorithms separately */
7964 [ # # ]: 0 : if (test_mixed_check_if_unsupported(tdata))
7965 : : return TEST_SKIPPED;
7966 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7967 : : return TEST_SKIPPED;
7968 : :
7969 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7970 : : return TEST_SKIPPED;
7971 : :
7972 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7973 : :
7974 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7975 : :
7976 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7977 : : printf("Device doesn't support digest encrypted.\n");
7978 : 0 : return TEST_SKIPPED;
7979 : : }
7980 : :
7981 : : /* Create the session */
7982 [ # # ]: 0 : if (verify)
7983 : 0 : retval = create_wireless_algo_cipher_auth_session(
7984 : 0 : ts_params->valid_devs[0],
7985 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
7986 : : RTE_CRYPTO_AUTH_OP_VERIFY,
7987 : 0 : tdata->auth_algo,
7988 : 0 : tdata->cipher_algo,
7989 : 0 : tdata->auth_key.data, tdata->auth_key.len,
7990 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
7991 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
7992 : 0 : tdata->cipher_iv.len);
7993 : : else
7994 : 0 : retval = create_wireless_algo_auth_cipher_session(
7995 : 0 : ts_params->valid_devs[0],
7996 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7997 : : RTE_CRYPTO_AUTH_OP_GENERATE,
7998 : 0 : tdata->auth_algo,
7999 : 0 : tdata->cipher_algo,
8000 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8001 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8002 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8003 : 0 : tdata->cipher_iv.len);
8004 [ # # ]: 0 : if (retval != 0)
8005 : : return retval;
8006 : :
8007 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8008 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8009 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8010 : :
8011 : : /* clear mbuf payload */
8012 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8013 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8014 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8015 : :
8016 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8017 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8018 : : }
8019 : :
8020 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8021 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8022 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8023 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8024 : :
8025 [ # # ]: 0 : if (verify) {
8026 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8027 : : ciphertext_pad_len);
8028 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8029 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8030 : : ciphertext_len);
8031 : : } else {
8032 : : /* make sure enough space to cover partial digest verify case */
8033 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8034 : : ciphertext_pad_len);
8035 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8036 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8037 : : }
8038 : :
8039 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8040 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8041 : :
8042 : : /* Create the operation */
8043 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8044 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8045 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8046 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8047 : 0 : (tdata->digest_enc.offset == 0 ?
8048 : : plaintext_pad_len
8049 : : : tdata->digest_enc.offset),
8050 : 0 : tdata->validCipherLen.len_bits,
8051 : 0 : tdata->cipher.offset_bits,
8052 : 0 : tdata->validAuthLen.len_bits,
8053 [ # # ]: 0 : tdata->auth.offset_bits,
8054 : : op_mode, 0, verify);
8055 : :
8056 [ # # ]: 0 : if (retval < 0)
8057 : : return retval;
8058 : :
8059 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8060 : :
8061 : : /* Check if the op failed because the device doesn't */
8062 : : /* support this particular combination of algorithms */
8063 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8064 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8065 : : printf("Device doesn't support this mixed combination. "
8066 : : "Test Skipped.\n");
8067 : 0 : return TEST_SKIPPED;
8068 : : }
8069 : 0 : ut_params->op = op;
8070 : :
8071 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8072 : :
8073 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8074 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8075 : :
8076 [ # # ]: 0 : if (verify) {
8077 [ # # ]: 0 : if (ut_params->obuf)
8078 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8079 : : uint8_t *);
8080 : : else
8081 : 0 : plaintext = ciphertext +
8082 : 0 : (tdata->cipher.offset_bits >> 3);
8083 : :
8084 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8085 : 0 : tdata->plaintext.len_bits >> 3);
8086 : 0 : debug_hexdump(stdout, "plaintext expected:",
8087 : 0 : tdata->plaintext.data,
8088 : 0 : tdata->plaintext.len_bits >> 3);
8089 : : } else {
8090 [ # # ]: 0 : if (ut_params->obuf)
8091 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8092 : : uint8_t *);
8093 : : else
8094 : : ciphertext = plaintext;
8095 : :
8096 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8097 : : ciphertext_len);
8098 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8099 : 0 : tdata->ciphertext.data,
8100 : 0 : tdata->ciphertext.len_bits >> 3);
8101 : :
8102 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8103 : : digest_offset = plaintext_pad_len;
8104 : : else
8105 : : digest_offset = tdata->digest_enc.offset;
8106 : :
8107 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8108 : : uint8_t *, digest_offset);
8109 : :
8110 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8111 : 0 : tdata->digest_enc.len);
8112 : 0 : debug_hexdump(stdout, "digest expected:",
8113 : : tdata->digest_enc.data,
8114 : 0 : tdata->digest_enc.len);
8115 : : }
8116 : :
8117 [ # # ]: 0 : if (!verify) {
8118 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8119 : : ut_params->digest,
8120 : : tdata->digest_enc.data,
8121 : : tdata->digest_enc.len,
8122 : : "Generated auth tag not as expected");
8123 : : }
8124 : :
8125 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8126 [ # # ]: 0 : if (verify) {
8127 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8128 : : plaintext,
8129 : : tdata->plaintext.data,
8130 : : tdata->plaintext.len_bits >> 3,
8131 : : "Plaintext data not as expected");
8132 : : } else {
8133 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8134 : : ciphertext,
8135 : : tdata->ciphertext.data,
8136 : : tdata->validDataLen.len_bits,
8137 : : "Ciphertext data not as expected");
8138 : : }
8139 : : }
8140 : :
8141 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8142 : : "crypto op processing failed");
8143 : :
8144 : : return 0;
8145 : : }
8146 : :
8147 : : static int
8148 : 0 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8149 : : uint8_t op_mode, uint8_t verify)
8150 : : {
8151 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8152 : : struct crypto_unittest_params *ut_params = &unittest_params;
8153 : :
8154 : : int retval;
8155 : :
8156 : : const uint8_t *plaintext = NULL;
8157 : : const uint8_t *ciphertext = NULL;
8158 : : const uint8_t *digest = NULL;
8159 : : unsigned int plaintext_pad_len;
8160 : : unsigned int plaintext_len;
8161 : : unsigned int ciphertext_pad_len;
8162 : : unsigned int ciphertext_len;
8163 : : uint8_t buffer[10000];
8164 : : uint8_t digest_buffer[10000];
8165 : :
8166 : : struct rte_cryptodev_info dev_info;
8167 : : struct rte_crypto_op *op;
8168 : :
8169 : : /* Check if device supports particular algorithms */
8170 [ # # ]: 0 : if (test_mixed_check_if_unsupported(tdata))
8171 : : return TEST_SKIPPED;
8172 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8173 : : return TEST_SKIPPED;
8174 : :
8175 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8176 : :
8177 : 0 : uint64_t feat_flags = dev_info.feature_flags;
8178 : :
8179 [ # # ]: 0 : if (op_mode == IN_PLACE) {
8180 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8181 : : printf("Device doesn't support in-place scatter-gather "
8182 : : "in both input and output mbufs.\n");
8183 : 0 : return TEST_SKIPPED;
8184 : : }
8185 : : } else {
8186 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8187 : : printf("Device doesn't support out-of-place scatter-gather "
8188 : : "in both input and output mbufs.\n");
8189 : 0 : return TEST_SKIPPED;
8190 : : }
8191 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8192 : : printf("Device doesn't support digest encrypted.\n");
8193 : 0 : return TEST_SKIPPED;
8194 : : }
8195 : : }
8196 : :
8197 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8198 : : return TEST_SKIPPED;
8199 : :
8200 : : /* Create the session */
8201 [ # # ]: 0 : if (verify)
8202 : 0 : retval = create_wireless_algo_cipher_auth_session(
8203 : 0 : ts_params->valid_devs[0],
8204 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8205 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8206 : 0 : tdata->auth_algo,
8207 : 0 : tdata->cipher_algo,
8208 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8209 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8210 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8211 : 0 : tdata->cipher_iv.len);
8212 : : else
8213 : 0 : retval = create_wireless_algo_auth_cipher_session(
8214 : 0 : ts_params->valid_devs[0],
8215 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8216 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8217 : 0 : tdata->auth_algo,
8218 : 0 : tdata->cipher_algo,
8219 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8220 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8221 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8222 : 0 : tdata->cipher_iv.len);
8223 [ # # ]: 0 : if (retval != 0)
8224 : : return retval;
8225 : :
8226 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8227 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8228 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8229 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8230 : :
8231 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8232 : : ciphertext_pad_len, 15, 0);
8233 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8234 : : "Failed to allocate input buffer in mempool");
8235 : :
8236 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8237 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8238 : : plaintext_pad_len, 15, 0);
8239 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8240 : : "Failed to allocate output buffer in mempool");
8241 : : }
8242 : :
8243 [ # # ]: 0 : if (verify) {
8244 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8245 : 0 : tdata->ciphertext.data);
8246 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8247 : : ciphertext_len, buffer);
8248 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8249 : : ciphertext_len);
8250 : : } else {
8251 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8252 : 0 : tdata->plaintext.data);
8253 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8254 : : plaintext_len, buffer);
8255 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8256 : : plaintext_len);
8257 : : }
8258 : : memset(buffer, 0, sizeof(buffer));
8259 : :
8260 : : /* Create the operation */
8261 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8262 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8263 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8264 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8265 : 0 : (tdata->digest_enc.offset == 0 ?
8266 : : plaintext_pad_len
8267 : : : tdata->digest_enc.offset),
8268 : 0 : tdata->validCipherLen.len_bits,
8269 : 0 : tdata->cipher.offset_bits,
8270 : 0 : tdata->validAuthLen.len_bits,
8271 [ # # ]: 0 : tdata->auth.offset_bits,
8272 : : op_mode, 1, verify);
8273 : :
8274 [ # # ]: 0 : if (retval < 0)
8275 : : return retval;
8276 : :
8277 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8278 : :
8279 : : /* Check if the op failed because the device doesn't */
8280 : : /* support this particular combination of algorithms */
8281 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8282 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8283 : : printf("Device doesn't support this mixed combination. "
8284 : : "Test Skipped.\n");
8285 : 0 : return TEST_SKIPPED;
8286 : : }
8287 : 0 : ut_params->op = op;
8288 : :
8289 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8290 : :
8291 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8292 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8293 : :
8294 [ # # ]: 0 : if (verify) {
8295 [ # # ]: 0 : if (ut_params->obuf)
8296 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8297 : : plaintext_len, buffer);
8298 : : else
8299 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8300 : : plaintext_len, buffer);
8301 : :
8302 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8303 : 0 : (tdata->plaintext.len_bits >> 3) -
8304 : 0 : tdata->digest_enc.len);
8305 : 0 : debug_hexdump(stdout, "plaintext expected:",
8306 : 0 : tdata->plaintext.data,
8307 : 0 : (tdata->plaintext.len_bits >> 3) -
8308 : 0 : tdata->digest_enc.len);
8309 : : } else {
8310 [ # # ]: 0 : if (ut_params->obuf)
8311 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8312 : : ciphertext_len, buffer);
8313 : : else
8314 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8315 : : ciphertext_len, buffer);
8316 : :
8317 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8318 : : ciphertext_len);
8319 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8320 : 0 : tdata->ciphertext.data,
8321 : 0 : tdata->ciphertext.len_bits >> 3);
8322 : :
8323 [ # # ]: 0 : if (ut_params->obuf)
8324 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
8325 : 0 : (tdata->digest_enc.offset == 0 ?
8326 : : plaintext_pad_len :
8327 : : tdata->digest_enc.offset),
8328 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8329 : : else
8330 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8331 : 0 : (tdata->digest_enc.offset == 0 ?
8332 : : plaintext_pad_len :
8333 : : tdata->digest_enc.offset),
8334 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8335 : :
8336 : 0 : debug_hexdump(stdout, "digest:", digest,
8337 : 0 : tdata->digest_enc.len);
8338 : 0 : debug_hexdump(stdout, "digest expected:",
8339 : 0 : tdata->digest_enc.data, tdata->digest_enc.len);
8340 : : }
8341 : :
8342 [ # # ]: 0 : if (!verify) {
8343 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8344 : : digest,
8345 : : tdata->digest_enc.data,
8346 : : tdata->digest_enc.len,
8347 : : "Generated auth tag not as expected");
8348 : : }
8349 : :
8350 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8351 [ # # ]: 0 : if (verify) {
8352 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8353 : : plaintext,
8354 : : tdata->plaintext.data,
8355 : : tdata->plaintext.len_bits >> 3,
8356 : : "Plaintext data not as expected");
8357 : : } else {
8358 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8359 : : ciphertext,
8360 : : tdata->ciphertext.data,
8361 : : tdata->validDataLen.len_bits,
8362 : : "Ciphertext data not as expected");
8363 : : }
8364 : : }
8365 : :
8366 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8367 : : "crypto op processing failed");
8368 : :
8369 : : return 0;
8370 : : }
8371 : :
8372 : : /** AUTH AES CMAC + CIPHER AES CTR */
8373 : :
8374 : : static int
8375 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8376 : : {
8377 : 0 : return test_mixed_auth_cipher(
8378 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8379 : : }
8380 : :
8381 : : static int
8382 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8383 : : {
8384 : 0 : return test_mixed_auth_cipher(
8385 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8386 : : }
8387 : :
8388 : : static int
8389 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8390 : : {
8391 : 0 : return test_mixed_auth_cipher_sgl(
8392 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8393 : : }
8394 : :
8395 : : static int
8396 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8397 : : {
8398 : 0 : return test_mixed_auth_cipher_sgl(
8399 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8400 : : }
8401 : :
8402 : : static int
8403 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8404 : : {
8405 : 0 : return test_mixed_auth_cipher(
8406 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8407 : : }
8408 : :
8409 : : static int
8410 : 0 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8411 : : {
8412 : 0 : return test_mixed_auth_cipher(
8413 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8414 : : }
8415 : :
8416 : : static int
8417 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8418 : : {
8419 : 0 : return test_mixed_auth_cipher(
8420 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8421 : : }
8422 : :
8423 : : static int
8424 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8425 : : {
8426 : 0 : return test_mixed_auth_cipher(
8427 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8428 : : }
8429 : :
8430 : : static int
8431 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8432 : : {
8433 : 0 : return test_mixed_auth_cipher(
8434 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8435 : : }
8436 : :
8437 : : static int
8438 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8439 : : {
8440 : 0 : return test_mixed_auth_cipher_sgl(
8441 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8442 : : }
8443 : :
8444 : : static int
8445 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8446 : : {
8447 : 0 : return test_mixed_auth_cipher_sgl(
8448 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8449 : : }
8450 : :
8451 : : static int
8452 : 0 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8453 : : {
8454 : 0 : return test_mixed_auth_cipher(
8455 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8456 : : }
8457 : :
8458 : : /** MIXED AUTH + CIPHER */
8459 : :
8460 : : static int
8461 : 0 : test_auth_zuc_cipher_snow_test_case_1(void)
8462 : : {
8463 : 0 : return test_mixed_auth_cipher(
8464 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8465 : : }
8466 : :
8467 : : static int
8468 : 0 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8469 : : {
8470 : 0 : return test_mixed_auth_cipher(
8471 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8472 : : }
8473 : :
8474 : : static int
8475 : 0 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8476 : : {
8477 : 0 : return test_mixed_auth_cipher(
8478 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8479 : : }
8480 : :
8481 : : static int
8482 : 0 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8483 : : {
8484 : 0 : return test_mixed_auth_cipher(
8485 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8486 : : }
8487 : :
8488 : :
8489 : : static int
8490 : 0 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8491 : : {
8492 : 0 : return test_mixed_auth_cipher(
8493 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8494 : : }
8495 : :
8496 : : static int
8497 : 0 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8498 : : {
8499 : 0 : return test_mixed_auth_cipher(
8500 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8501 : : }
8502 : :
8503 : : static int
8504 : 0 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8505 : : {
8506 : 0 : return test_mixed_auth_cipher(
8507 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8508 : : }
8509 : :
8510 : : static int
8511 : 0 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8512 : : {
8513 : 0 : return test_mixed_auth_cipher(
8514 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8515 : : }
8516 : :
8517 : : static int
8518 : 0 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8519 : : {
8520 : 0 : return test_mixed_auth_cipher(
8521 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8522 : : }
8523 : :
8524 : : static int
8525 : 0 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8526 : : {
8527 : 0 : return test_mixed_auth_cipher(
8528 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8529 : : }
8530 : :
8531 : : static int
8532 : 0 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8533 : : {
8534 : 0 : return test_mixed_auth_cipher(
8535 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8536 : : }
8537 : :
8538 : : static int
8539 : 0 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8540 : : {
8541 : 0 : return test_mixed_auth_cipher(
8542 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8543 : : }
8544 : :
8545 : : static int
8546 : 0 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8547 : : {
8548 : 0 : return test_mixed_auth_cipher(
8549 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8550 : : }
8551 : :
8552 : : static int
8553 : 0 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8554 : : {
8555 : 0 : return test_mixed_auth_cipher(
8556 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8557 : : }
8558 : :
8559 : : static int
8560 : 0 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8561 : : {
8562 : 0 : return test_mixed_auth_cipher_sgl(
8563 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8564 : : }
8565 : :
8566 : : static int
8567 : 0 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8568 : : {
8569 : 0 : return test_mixed_auth_cipher(
8570 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8571 : : }
8572 : :
8573 : : static int
8574 : 0 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8575 : : {
8576 : 0 : return test_mixed_auth_cipher_sgl(
8577 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8578 : : }
8579 : :
8580 : : static int
8581 : 0 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8582 : : {
8583 : 0 : return test_mixed_auth_cipher(
8584 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8585 : : }
8586 : :
8587 : : static int
8588 : 0 : test_auth_snow_cipher_zuc_test_case_1(void)
8589 : : {
8590 : 0 : return test_mixed_auth_cipher(
8591 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8592 : : }
8593 : :
8594 : : static int
8595 : 0 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8596 : : {
8597 : 0 : return test_mixed_auth_cipher(
8598 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8599 : : }
8600 : :
8601 : : static int
8602 : 0 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8603 : : {
8604 : 0 : return test_mixed_auth_cipher(
8605 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8606 : : }
8607 : :
8608 : : static int
8609 : 0 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8610 : : {
8611 : 0 : return test_mixed_auth_cipher(
8612 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8613 : : }
8614 : :
8615 : : static int
8616 : 0 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8617 : : {
8618 : 0 : return test_mixed_auth_cipher(
8619 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8620 : : }
8621 : :
8622 : : static int
8623 : 0 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8624 : : {
8625 : 0 : return test_mixed_auth_cipher(
8626 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8627 : : }
8628 : : static int
8629 : 0 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8630 : : {
8631 : 0 : return test_mixed_auth_cipher(
8632 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8633 : : }
8634 : :
8635 : : static int
8636 : 0 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8637 : : {
8638 : 0 : return test_mixed_auth_cipher(
8639 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8640 : : }
8641 : :
8642 : : static int
8643 : 0 : test_auth_null_cipher_snow_test_case_1(void)
8644 : : {
8645 : 0 : return test_mixed_auth_cipher(
8646 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8647 : : }
8648 : :
8649 : : static int
8650 : 0 : test_verify_auth_null_cipher_snow_test_case_1(void)
8651 : : {
8652 : 0 : return test_mixed_auth_cipher(
8653 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8654 : : }
8655 : :
8656 : : static int
8657 : 0 : test_auth_null_cipher_zuc_test_case_1(void)
8658 : : {
8659 : 0 : return test_mixed_auth_cipher(
8660 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8661 : : }
8662 : :
8663 : : static int
8664 : 0 : test_verify_auth_null_cipher_zuc_test_case_1(void)
8665 : : {
8666 : 0 : return test_mixed_auth_cipher(
8667 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8668 : : }
8669 : :
8670 : : static int
8671 : 0 : test_auth_snow_cipher_null_test_case_1(void)
8672 : : {
8673 : 0 : return test_mixed_auth_cipher(
8674 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8675 : : }
8676 : :
8677 : : static int
8678 : 0 : test_verify_auth_snow_cipher_null_test_case_1(void)
8679 : : {
8680 : 0 : return test_mixed_auth_cipher(
8681 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8682 : : }
8683 : :
8684 : : static int
8685 : 0 : test_auth_zuc_cipher_null_test_case_1(void)
8686 : : {
8687 : 0 : return test_mixed_auth_cipher(
8688 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8689 : : }
8690 : :
8691 : : static int
8692 : 0 : test_verify_auth_zuc_cipher_null_test_case_1(void)
8693 : : {
8694 : 0 : return test_mixed_auth_cipher(
8695 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8696 : : }
8697 : :
8698 : : static int
8699 : 0 : test_auth_null_cipher_aes_ctr_test_case_1(void)
8700 : : {
8701 : 0 : return test_mixed_auth_cipher(
8702 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8703 : : }
8704 : :
8705 : : static int
8706 : 0 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8707 : : {
8708 : 0 : return test_mixed_auth_cipher(
8709 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8710 : : }
8711 : :
8712 : : static int
8713 : 0 : test_auth_aes_cmac_cipher_null_test_case_1(void)
8714 : : {
8715 : 0 : return test_mixed_auth_cipher(
8716 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8717 : : }
8718 : :
8719 : : static int
8720 : 0 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8721 : : {
8722 : 0 : return test_mixed_auth_cipher(
8723 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8724 : : }
8725 : :
8726 : : /* ***** AEAD algorithm Tests ***** */
8727 : :
8728 : : static int
8729 : 0 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8730 : : enum rte_crypto_aead_operation op,
8731 : : const uint8_t *key, const uint8_t key_len,
8732 : : const uint16_t aad_len, const uint8_t auth_len,
8733 : : uint8_t iv_len)
8734 : 0 : {
8735 : 0 : uint8_t aead_key[key_len];
8736 : :
8737 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8738 : : struct crypto_unittest_params *ut_params = &unittest_params;
8739 : :
8740 : : memcpy(aead_key, key, key_len);
8741 : :
8742 : : /* Setup AEAD Parameters */
8743 : 0 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8744 : 0 : ut_params->aead_xform.next = NULL;
8745 : 0 : ut_params->aead_xform.aead.algo = algo;
8746 : 0 : ut_params->aead_xform.aead.op = op;
8747 : 0 : ut_params->aead_xform.aead.key.data = aead_key;
8748 : 0 : ut_params->aead_xform.aead.key.length = key_len;
8749 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8750 : 0 : ut_params->aead_xform.aead.iv.length = iv_len;
8751 : 0 : ut_params->aead_xform.aead.digest_length = auth_len;
8752 : 0 : ut_params->aead_xform.aead.aad_length = aad_len;
8753 : :
8754 : 0 : debug_hexdump(stdout, "key:", key, key_len);
8755 : :
8756 : : /* Create Crypto session*/
8757 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8758 : : &ut_params->aead_xform, ts_params->session_mpool);
8759 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8760 : : return TEST_SKIPPED;
8761 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8762 : : return 0;
8763 : : }
8764 : :
8765 : : static int
8766 : 0 : create_aead_xform(struct rte_crypto_op *op,
8767 : : enum rte_crypto_aead_algorithm algo,
8768 : : enum rte_crypto_aead_operation aead_op,
8769 : : uint8_t *key, const uint8_t key_len,
8770 : : const uint8_t aad_len, const uint8_t auth_len,
8771 : : uint8_t iv_len)
8772 : : {
8773 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8774 : : "failed to allocate space for crypto transform");
8775 : :
8776 : : struct rte_crypto_sym_op *sym_op = op->sym;
8777 : :
8778 : : /* Setup AEAD Parameters */
8779 : 0 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8780 : 0 : sym_op->xform->next = NULL;
8781 : 0 : sym_op->xform->aead.algo = algo;
8782 : 0 : sym_op->xform->aead.op = aead_op;
8783 : 0 : sym_op->xform->aead.key.data = key;
8784 : 0 : sym_op->xform->aead.key.length = key_len;
8785 : 0 : sym_op->xform->aead.iv.offset = IV_OFFSET;
8786 : 0 : sym_op->xform->aead.iv.length = iv_len;
8787 : 0 : sym_op->xform->aead.digest_length = auth_len;
8788 : 0 : sym_op->xform->aead.aad_length = aad_len;
8789 : :
8790 : 0 : debug_hexdump(stdout, "key:", key, key_len);
8791 : :
8792 : : return 0;
8793 : : }
8794 : :
8795 : : static int
8796 : 0 : create_aead_operation(enum rte_crypto_aead_operation op,
8797 : : const struct aead_test_data *tdata)
8798 : : {
8799 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8800 : : struct crypto_unittest_params *ut_params = &unittest_params;
8801 : :
8802 : : uint8_t *plaintext, *ciphertext;
8803 : : unsigned int aad_pad_len, plaintext_pad_len;
8804 : :
8805 : : /* Generate Crypto op data structure */
8806 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8807 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8808 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
8809 : : "Failed to allocate symmetric crypto operation struct");
8810 : :
8811 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8812 : :
8813 : : /* Append aad data */
8814 [ # # ]: 0 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8815 : 0 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8816 : 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8817 : : aad_pad_len);
8818 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8819 : : "no room to append aad");
8820 : :
8821 : 0 : sym_op->aead.aad.phys_addr =
8822 : 0 : rte_pktmbuf_iova(ut_params->ibuf);
8823 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8824 : 0 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8825 : 0 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8826 : 0 : tdata->aad.len);
8827 : :
8828 : : /* Append IV at the end of the crypto operation*/
8829 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8830 : : uint8_t *, IV_OFFSET);
8831 : :
8832 : : /* Copy IV 1 byte after the IV pointer, according to the API */
8833 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8834 : 0 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
8835 : 0 : tdata->iv.len);
8836 : : } else {
8837 : 0 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8838 : 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8839 : : aad_pad_len);
8840 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8841 : : "no room to append aad");
8842 : :
8843 : 0 : sym_op->aead.aad.phys_addr =
8844 : 0 : rte_pktmbuf_iova(ut_params->ibuf);
8845 : 0 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8846 : 0 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8847 : 0 : tdata->aad.len);
8848 : :
8849 : : /* Append IV at the end of the crypto operation*/
8850 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8851 : : uint8_t *, IV_OFFSET);
8852 : :
8853 [ # # ]: 0 : if (tdata->iv.len == 0) {
8854 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8855 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
8856 : : AES_GCM_J0_LENGTH);
8857 : : } else {
8858 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8859 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
8860 : 0 : tdata->iv.len);
8861 : : }
8862 : : }
8863 : :
8864 : : /* Append plaintext/ciphertext */
8865 [ # # ]: 0 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8866 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8867 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8868 : : plaintext_pad_len);
8869 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8870 : :
8871 : 0 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8872 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8873 : 0 : tdata->plaintext.len);
8874 : :
8875 [ # # ]: 0 : if (ut_params->obuf) {
8876 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
8877 : : ut_params->obuf,
8878 : 0 : plaintext_pad_len + aad_pad_len);
8879 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext,
8880 : : "no room to append ciphertext");
8881 : :
8882 : 0 : memset(ciphertext + aad_pad_len, 0,
8883 : 0 : tdata->ciphertext.len);
8884 : : }
8885 : : } else {
8886 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8887 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8888 : : plaintext_pad_len);
8889 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext,
8890 : : "no room to append ciphertext");
8891 : :
8892 : 0 : memcpy(ciphertext, tdata->ciphertext.data,
8893 : 0 : tdata->ciphertext.len);
8894 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8895 : 0 : tdata->ciphertext.len);
8896 : :
8897 [ # # ]: 0 : if (ut_params->obuf) {
8898 : : plaintext = (uint8_t *)rte_pktmbuf_append(
8899 : : ut_params->obuf,
8900 : 0 : plaintext_pad_len + aad_pad_len);
8901 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext,
8902 : : "no room to append plaintext");
8903 : :
8904 : 0 : memset(plaintext + aad_pad_len, 0,
8905 : 0 : tdata->plaintext.len);
8906 : : }
8907 : : }
8908 : :
8909 : : /* Append digest data */
8910 [ # # ]: 0 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8911 : 0 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8912 : 0 : ut_params->obuf ? ut_params->obuf :
8913 : : ut_params->ibuf,
8914 [ # # ]: 0 : tdata->auth_tag.len);
8915 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8916 : : "no room to append digest");
8917 [ # # ]: 0 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8918 [ # # ]: 0 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8919 : : ut_params->obuf ? ut_params->obuf :
8920 : : ut_params->ibuf,
8921 : : plaintext_pad_len +
8922 : : aad_pad_len);
8923 : : } else {
8924 : 0 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8925 : 0 : ut_params->ibuf, tdata->auth_tag.len);
8926 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8927 : : "no room to append digest");
8928 [ # # ]: 0 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8929 : : ut_params->ibuf,
8930 : : plaintext_pad_len + aad_pad_len);
8931 : :
8932 : 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8933 [ # # ]: 0 : tdata->auth_tag.len);
8934 : 0 : debug_hexdump(stdout, "digest:",
8935 : 0 : sym_op->aead.digest.data,
8936 : 0 : tdata->auth_tag.len);
8937 : : }
8938 : :
8939 : 0 : sym_op->aead.data.length = tdata->plaintext.len;
8940 : 0 : sym_op->aead.data.offset = aad_pad_len;
8941 : :
8942 : 0 : return 0;
8943 : : }
8944 : :
8945 : : static int
8946 : 0 : test_authenticated_encryption(const struct aead_test_data *tdata)
8947 : : {
8948 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8949 : : struct crypto_unittest_params *ut_params = &unittest_params;
8950 : :
8951 : : int retval;
8952 : : uint8_t *ciphertext, *auth_tag;
8953 : : uint16_t plaintext_pad_len;
8954 : : uint32_t i;
8955 : : struct rte_cryptodev_info dev_info;
8956 : :
8957 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8958 : 0 : uint64_t feat_flags = dev_info.feature_flags;
8959 : :
8960 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8961 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8962 : : printf("Device doesn't support RAW data-path APIs.\n");
8963 : 0 : return TEST_SKIPPED;
8964 : : }
8965 : :
8966 : : /* Verify the capabilities */
8967 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8968 : : const struct rte_cryptodev_symmetric_capability *capability;
8969 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8970 : 0 : cap_idx.algo.aead = tdata->algo;
8971 : 0 : capability = rte_cryptodev_sym_capability_get(
8972 : 0 : ts_params->valid_devs[0], &cap_idx);
8973 [ # # ]: 0 : if (capability == NULL)
8974 : : return TEST_SKIPPED;
8975 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_aead(
8976 : 0 : capability, tdata->key.len, tdata->auth_tag.len,
8977 : 0 : tdata->aad.len, tdata->iv.len))
8978 : : return TEST_SKIPPED;
8979 : :
8980 : : /* Create AEAD session */
8981 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
8982 : 0 : tdata->algo,
8983 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
8984 : 0 : tdata->key.data, tdata->key.len,
8985 : 0 : tdata->aad.len, tdata->auth_tag.len,
8986 : 0 : tdata->iv.len);
8987 [ # # ]: 0 : if (retval != TEST_SUCCESS)
8988 : : return retval;
8989 : :
8990 [ # # ]: 0 : if (tdata->aad.len > MBUF_SIZE) {
8991 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8992 : : /* Populate full size of add data */
8993 [ # # ]: 0 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8994 : 0 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8995 : : } else
8996 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8997 : :
8998 : : /* clear mbuf payload */
8999 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9000 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
9001 : :
9002 : : /* Create AEAD operation */
9003 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9004 [ # # ]: 0 : if (retval < 0)
9005 : : return retval;
9006 : :
9007 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9008 : :
9009 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9010 : :
9011 : : /* Process crypto operation */
9012 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9013 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9014 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9015 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9016 : : 0);
9017 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9018 : : return retval;
9019 : : } else
9020 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
9021 : : process_crypto_request(ts_params->valid_devs[0],
9022 : : ut_params->op), "failed to process sym crypto op");
9023 : :
9024 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9025 : : "crypto op processing failed");
9026 : :
9027 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9028 : :
9029 [ # # ]: 0 : if (ut_params->op->sym->m_dst) {
9030 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9031 : : uint8_t *);
9032 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9033 : : uint8_t *, plaintext_pad_len);
9034 : : } else {
9035 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9036 : : uint8_t *,
9037 : : ut_params->op->sym->cipher.data.offset);
9038 : 0 : auth_tag = ciphertext + plaintext_pad_len;
9039 : : }
9040 : :
9041 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9042 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9043 : :
9044 : : /* Validate obuf */
9045 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9046 : : ciphertext,
9047 : : tdata->ciphertext.data,
9048 : : tdata->ciphertext.len,
9049 : : "Ciphertext data not as expected");
9050 : :
9051 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9052 : : auth_tag,
9053 : : tdata->auth_tag.data,
9054 : : tdata->auth_tag.len,
9055 : : "Generated auth tag not as expected");
9056 : :
9057 : : return 0;
9058 : :
9059 : : }
9060 : :
9061 : : #ifdef RTE_LIB_SECURITY
9062 : : static int
9063 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9064 : : enum rte_security_session_protocol proto)
9065 : : {
9066 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9067 : :
9068 : : const struct rte_security_capability *capabilities;
9069 : : const struct rte_security_capability *capability;
9070 : : uint16_t i = 0;
9071 : :
9072 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9073 : :
9074 : :
9075 : 0 : capabilities = rte_security_capabilities_get(ctx);
9076 : :
9077 [ # # ]: 0 : if (capabilities == NULL)
9078 : : return -ENOTSUP;
9079 : :
9080 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9081 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9082 [ # # ]: 0 : if (capability->action == action &&
9083 [ # # ]: 0 : capability->protocol == proto)
9084 : : return 0;
9085 : : }
9086 : :
9087 : : return -ENOTSUP;
9088 : : }
9089 : :
9090 : : /* Basic algorithm run function for async inplace mode.
9091 : : * Creates a session from input parameters and runs one operation
9092 : : * on input_vec. Checks the output of the crypto operation against
9093 : : * output_vec.
9094 : : */
9095 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9096 : : enum rte_crypto_auth_operation opa,
9097 : : const uint8_t *input_vec, unsigned int input_vec_len,
9098 : : const uint8_t *output_vec,
9099 : : unsigned int output_vec_len,
9100 : : enum rte_crypto_cipher_algorithm cipher_alg,
9101 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9102 : : enum rte_crypto_auth_algorithm auth_alg,
9103 : : const uint8_t *auth_key, uint32_t auth_key_len,
9104 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9105 : : uint8_t packet_direction, uint8_t sn_size,
9106 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9107 : : {
9108 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9109 : : struct crypto_unittest_params *ut_params = &unittest_params;
9110 : : uint8_t *plaintext;
9111 : : int ret = TEST_SUCCESS;
9112 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9113 : : struct rte_cryptodev_info dev_info;
9114 : : uint64_t feat_flags;
9115 : :
9116 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9117 : 0 : feat_flags = dev_info.feature_flags;
9118 : :
9119 : : /* Verify the capabilities */
9120 : : struct rte_security_capability_idx sec_cap_idx;
9121 : :
9122 : 0 : sec_cap_idx.action = ut_params->type;
9123 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9124 : 0 : sec_cap_idx.pdcp.domain = domain;
9125 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9126 : : return TEST_SKIPPED;
9127 : :
9128 : : /* Generate test mbuf data */
9129 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9130 : :
9131 : : /* clear mbuf payload */
9132 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9133 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9134 : :
9135 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9136 : : input_vec_len);
9137 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9138 : :
9139 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9140 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9141 : : printf("Device does not support RAW data-path APIs.\n");
9142 : 0 : return TEST_SKIPPED;
9143 : : }
9144 : : /* Out of place support */
9145 [ # # ]: 0 : if (oop) {
9146 : : /*
9147 : : * For out-op-place we need to alloc another mbuf
9148 : : */
9149 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9150 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9151 : : }
9152 : :
9153 : : /* Setup Cipher Parameters */
9154 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9155 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9156 : 0 : ut_params->cipher_xform.cipher.op = opc;
9157 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9158 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9159 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9160 : : packet_direction ? 4 : 0;
9161 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9162 : :
9163 : : /* Setup HMAC Parameters if ICV header is required */
9164 [ # # ]: 0 : if (auth_alg != 0) {
9165 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9166 : 0 : ut_params->auth_xform.next = NULL;
9167 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9168 : 0 : ut_params->auth_xform.auth.op = opa;
9169 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9170 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9171 : :
9172 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9173 : : } else {
9174 : 0 : ut_params->cipher_xform.next = NULL;
9175 : : }
9176 : :
9177 : 0 : struct rte_security_session_conf sess_conf = {
9178 : 0 : .action_type = ut_params->type,
9179 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9180 : : {.pdcp = {
9181 : : .bearer = bearer,
9182 : : .domain = domain,
9183 : : .pkt_dir = packet_direction,
9184 : : .sn_size = sn_size,
9185 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9186 : : /**
9187 : : * hfn can be set as pdcp_test_hfn[i]
9188 : : * if hfn_ovrd is not set. Here, PDCP
9189 : : * packet direction is just used to
9190 : : * run half of the cases with session
9191 : : * HFN and other half with per packet
9192 : : * HFN.
9193 : : */
9194 : : .hfn_threshold = hfn_threshold,
9195 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9196 : : .sdap_enabled = sdap,
9197 : : } },
9198 : : .crypto_xform = &ut_params->cipher_xform
9199 : : };
9200 : :
9201 : : /* Create security session */
9202 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9203 : : &sess_conf, ts_params->session_mpool);
9204 : :
9205 [ # # ]: 0 : if (!ut_params->sec_session) {
9206 : : printf("TestCase %s()-%d line %d failed %s: ",
9207 : : __func__, i, __LINE__, "Failed to allocate session");
9208 : : ret = TEST_FAILED;
9209 : 0 : goto on_err;
9210 : : }
9211 : :
9212 : : /* Generate crypto op data structure */
9213 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9214 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9215 [ # # ]: 0 : if (!ut_params->op) {
9216 : : printf("TestCase %s()-%d line %d failed %s: ",
9217 : : __func__, i, __LINE__,
9218 : : "Failed to allocate symmetric crypto operation struct");
9219 : : ret = TEST_FAILED;
9220 : 0 : goto on_err;
9221 : : }
9222 : :
9223 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9224 : : uint32_t *, IV_OFFSET);
9225 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9226 : :
9227 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9228 : :
9229 : : /* set crypto operation source mbuf */
9230 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9231 [ # # ]: 0 : if (oop)
9232 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9233 : :
9234 : : /* Process crypto operation */
9235 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9236 : : /* filling lengths */
9237 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9238 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9239 : :
9240 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9241 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9242 : : return ret;
9243 : : } else {
9244 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9245 : : }
9246 [ # # ]: 0 : if (ut_params->op == NULL) {
9247 : : printf("TestCase %s()-%d line %d failed %s: ",
9248 : : __func__, i, __LINE__,
9249 : : "failed to process sym crypto op");
9250 : : ret = TEST_FAILED;
9251 : 0 : goto on_err;
9252 : : }
9253 : :
9254 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9255 : : printf("TestCase %s()-%d line %d failed %s: ",
9256 : : __func__, i, __LINE__, "crypto op processing failed");
9257 : : ret = TEST_FAILED;
9258 : 0 : goto on_err;
9259 : : }
9260 : :
9261 : : /* Validate obuf */
9262 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9263 : : uint8_t *);
9264 [ # # ]: 0 : if (oop) {
9265 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9266 : : uint8_t *);
9267 : : }
9268 : :
9269 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9270 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9271 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9272 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9273 : : ret = TEST_FAILED;
9274 : 0 : goto on_err;
9275 : : }
9276 : :
9277 : 0 : on_err:
9278 : 0 : rte_crypto_op_free(ut_params->op);
9279 : 0 : ut_params->op = NULL;
9280 : :
9281 [ # # ]: 0 : if (ut_params->sec_session)
9282 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9283 : 0 : ut_params->sec_session = NULL;
9284 : :
9285 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9286 : 0 : ut_params->ibuf = NULL;
9287 [ # # ]: 0 : if (oop) {
9288 : 0 : rte_pktmbuf_free(ut_params->obuf);
9289 : 0 : ut_params->obuf = NULL;
9290 : : }
9291 : :
9292 : : return ret;
9293 : : }
9294 : :
9295 : : static int
9296 : 0 : test_pdcp_proto_SGL(int i, int oop,
9297 : : enum rte_crypto_cipher_operation opc,
9298 : : enum rte_crypto_auth_operation opa,
9299 : : uint8_t *input_vec,
9300 : : unsigned int input_vec_len,
9301 : : uint8_t *output_vec,
9302 : : unsigned int output_vec_len,
9303 : : uint32_t fragsz,
9304 : : uint32_t fragsz_oop)
9305 : : {
9306 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9307 : : struct crypto_unittest_params *ut_params = &unittest_params;
9308 : : uint8_t *plaintext;
9309 : : struct rte_mbuf *buf, *buf_oop = NULL;
9310 : : int ret = TEST_SUCCESS;
9311 : : int to_trn = 0;
9312 : : int to_trn_tbl[16];
9313 : : int segs = 1;
9314 : : unsigned int trn_data = 0;
9315 : : struct rte_cryptodev_info dev_info;
9316 : : uint64_t feat_flags;
9317 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9318 : : struct rte_mbuf *temp_mbuf;
9319 : :
9320 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9321 : 0 : feat_flags = dev_info.feature_flags;
9322 : :
9323 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9324 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9325 : : printf("Device does not support RAW data-path APIs.\n");
9326 : 0 : return -ENOTSUP;
9327 : : }
9328 : : /* Verify the capabilities */
9329 : : struct rte_security_capability_idx sec_cap_idx;
9330 : :
9331 : 0 : sec_cap_idx.action = ut_params->type;
9332 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9333 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9334 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9335 : : return TEST_SKIPPED;
9336 : :
9337 : : if (fragsz > input_vec_len)
9338 : : fragsz = input_vec_len;
9339 : :
9340 : 0 : uint16_t plaintext_len = fragsz;
9341 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9342 : :
9343 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9344 : 0 : frag_size_oop = output_vec_len;
9345 : :
9346 : : int ecx = 0;
9347 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9348 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9349 : : return 1;
9350 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9351 : : return 1;
9352 : :
9353 : : /* Out of place support */
9354 [ # # ]: 0 : if (oop) {
9355 : : /*
9356 : : * For out-op-place we need to alloc another mbuf
9357 : : */
9358 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9359 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9360 : 0 : buf_oop = ut_params->obuf;
9361 : : }
9362 : :
9363 : : /* Generate test mbuf data */
9364 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9365 : :
9366 : : /* clear mbuf payload */
9367 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9368 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9369 : :
9370 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9371 : : plaintext_len);
9372 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9373 : : trn_data += plaintext_len;
9374 : :
9375 : 0 : buf = ut_params->ibuf;
9376 : :
9377 : : /*
9378 : : * Loop until no more fragments
9379 : : */
9380 : :
9381 [ # # ]: 0 : while (trn_data < input_vec_len) {
9382 : 0 : ++segs;
9383 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9384 : 0 : (input_vec_len - trn_data) : fragsz;
9385 : :
9386 : 0 : to_trn_tbl[ecx++] = to_trn;
9387 : :
9388 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9389 : : buf = buf->next;
9390 : :
9391 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9392 : : rte_pktmbuf_tailroom(buf));
9393 : :
9394 : : /* OOP */
9395 [ # # ]: 0 : if (oop && !fragsz_oop) {
9396 : 0 : buf_oop->next =
9397 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9398 : : buf_oop = buf_oop->next;
9399 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9400 : : 0, rte_pktmbuf_tailroom(buf_oop));
9401 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9402 : : }
9403 : :
9404 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9405 : : to_trn);
9406 : :
9407 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9408 : 0 : trn_data += to_trn;
9409 : : }
9410 : :
9411 : 0 : ut_params->ibuf->nb_segs = segs;
9412 : :
9413 : : segs = 1;
9414 [ # # ]: 0 : if (fragsz_oop && oop) {
9415 : : to_trn = 0;
9416 : : ecx = 0;
9417 : :
9418 : 0 : trn_data = frag_size_oop;
9419 [ # # ]: 0 : while (trn_data < output_vec_len) {
9420 : 0 : ++segs;
9421 : 0 : to_trn =
9422 : 0 : (output_vec_len - trn_data <
9423 : : frag_size_oop) ?
9424 : 0 : (output_vec_len - trn_data) :
9425 : : frag_size_oop;
9426 : :
9427 : 0 : to_trn_tbl[ecx++] = to_trn;
9428 : :
9429 : 0 : buf_oop->next =
9430 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9431 : : buf_oop = buf_oop->next;
9432 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9433 : : 0, rte_pktmbuf_tailroom(buf_oop));
9434 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9435 : :
9436 : 0 : trn_data += to_trn;
9437 : : }
9438 : 0 : ut_params->obuf->nb_segs = segs;
9439 : : }
9440 : :
9441 : : /* Setup Cipher Parameters */
9442 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9443 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9444 : 0 : ut_params->cipher_xform.cipher.op = opc;
9445 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9446 : 0 : ut_params->cipher_xform.cipher.key.length =
9447 : 0 : pdcp_test_params[i].cipher_key_len;
9448 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9449 : :
9450 : : /* Setup HMAC Parameters if ICV header is required */
9451 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9452 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9453 : 0 : ut_params->auth_xform.next = NULL;
9454 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9455 : 0 : ut_params->auth_xform.auth.op = opa;
9456 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9457 : 0 : ut_params->auth_xform.auth.key.length =
9458 : 0 : pdcp_test_params[i].auth_key_len;
9459 : :
9460 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9461 : : } else {
9462 : 0 : ut_params->cipher_xform.next = NULL;
9463 : : }
9464 : :
9465 : 0 : struct rte_security_session_conf sess_conf = {
9466 : 0 : .action_type = ut_params->type,
9467 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9468 : : {.pdcp = {
9469 : 0 : .bearer = pdcp_test_bearer[i],
9470 : 0 : .domain = pdcp_test_params[i].domain,
9471 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9472 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9473 : 0 : .hfn = pdcp_test_hfn[i],
9474 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9475 : : .hfn_ovrd = 0,
9476 : : } },
9477 : : .crypto_xform = &ut_params->cipher_xform
9478 : : };
9479 : :
9480 : : /* Create security session */
9481 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9482 : : &sess_conf, ts_params->session_mpool);
9483 : :
9484 [ # # ]: 0 : if (!ut_params->sec_session) {
9485 : : printf("TestCase %s()-%d line %d failed %s: ",
9486 : : __func__, i, __LINE__, "Failed to allocate session");
9487 : : ret = TEST_FAILED;
9488 : 0 : goto on_err;
9489 : : }
9490 : :
9491 : : /* Generate crypto op data structure */
9492 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9493 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9494 [ # # ]: 0 : if (!ut_params->op) {
9495 : : printf("TestCase %s()-%d line %d failed %s: ",
9496 : : __func__, i, __LINE__,
9497 : : "Failed to allocate symmetric crypto operation struct");
9498 : : ret = TEST_FAILED;
9499 : 0 : goto on_err;
9500 : : }
9501 : :
9502 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9503 : :
9504 : : /* set crypto operation source mbuf */
9505 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9506 [ # # ]: 0 : if (oop)
9507 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9508 : :
9509 : : /* Process crypto operation */
9510 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9511 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9512 : : /* filling lengths */
9513 [ # # ]: 0 : while (temp_mbuf) {
9514 : 0 : ut_params->op->sym->cipher.data.length
9515 : 0 : += temp_mbuf->pkt_len;
9516 : 0 : ut_params->op->sym->auth.data.length
9517 : 0 : += temp_mbuf->pkt_len;
9518 : 0 : temp_mbuf = temp_mbuf->next;
9519 : : }
9520 : :
9521 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9522 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9523 : : return ret;
9524 : : } else {
9525 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9526 : : ut_params->op);
9527 : : }
9528 [ # # ]: 0 : if (ut_params->op == NULL) {
9529 : : printf("TestCase %s()-%d line %d failed %s: ",
9530 : : __func__, i, __LINE__,
9531 : : "failed to process sym crypto op");
9532 : : ret = TEST_FAILED;
9533 : 0 : goto on_err;
9534 : : }
9535 : :
9536 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9537 : : printf("TestCase %s()-%d line %d failed %s: ",
9538 : : __func__, i, __LINE__, "crypto op processing failed");
9539 : : ret = TEST_FAILED;
9540 : 0 : goto on_err;
9541 : : }
9542 : :
9543 : : /* Validate obuf */
9544 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9545 : : uint8_t *);
9546 [ # # ]: 0 : if (oop) {
9547 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9548 : : uint8_t *);
9549 : : }
9550 [ # # ]: 0 : if (fragsz_oop)
9551 : 0 : fragsz = frag_size_oop;
9552 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9553 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9554 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9555 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9556 : : ret = TEST_FAILED;
9557 : 0 : goto on_err;
9558 : : }
9559 : :
9560 : 0 : buf = ut_params->op->sym->m_src->next;
9561 [ # # ]: 0 : if (oop)
9562 : 0 : buf = ut_params->op->sym->m_dst->next;
9563 : :
9564 : : unsigned int off = fragsz;
9565 : :
9566 : : ecx = 0;
9567 [ # # ]: 0 : while (buf) {
9568 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9569 : : uint8_t *);
9570 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9571 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9572 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9573 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9574 : : to_trn_tbl[ecx]);
9575 : : ret = TEST_FAILED;
9576 : 0 : goto on_err;
9577 : : }
9578 : 0 : off += to_trn_tbl[ecx++];
9579 : 0 : buf = buf->next;
9580 : : }
9581 : 0 : on_err:
9582 : 0 : rte_crypto_op_free(ut_params->op);
9583 : 0 : ut_params->op = NULL;
9584 : :
9585 [ # # ]: 0 : if (ut_params->sec_session)
9586 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9587 : 0 : ut_params->sec_session = NULL;
9588 : :
9589 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9590 : 0 : ut_params->ibuf = NULL;
9591 [ # # ]: 0 : if (oop) {
9592 : 0 : rte_pktmbuf_free(ut_params->obuf);
9593 : 0 : ut_params->obuf = NULL;
9594 : : }
9595 : :
9596 : : return ret;
9597 : : }
9598 : :
9599 : : int
9600 : 0 : test_pdcp_proto_cplane_encap(int i)
9601 : : {
9602 : 0 : return test_pdcp_proto(
9603 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9604 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9605 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9606 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9607 : 0 : pdcp_test_params[i].cipher_key_len,
9608 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9609 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9610 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9611 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9612 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9613 : : }
9614 : :
9615 : : int
9616 : 0 : test_pdcp_proto_uplane_encap(int i)
9617 : : {
9618 : 0 : return test_pdcp_proto(
9619 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9620 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9621 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9622 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9623 : 0 : pdcp_test_params[i].cipher_key_len,
9624 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9625 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9626 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9627 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9628 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9629 : : }
9630 : :
9631 : : int
9632 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
9633 : : {
9634 : 0 : return test_pdcp_proto(
9635 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9636 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9637 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9638 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9639 : 0 : pdcp_test_params[i].cipher_key_len,
9640 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9641 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9642 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9643 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9644 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9645 : : }
9646 : :
9647 : : int
9648 : 0 : test_pdcp_proto_cplane_decap(int i)
9649 : : {
9650 : 0 : return test_pdcp_proto(
9651 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9652 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9653 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9654 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9655 : 0 : pdcp_test_params[i].cipher_key_len,
9656 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9657 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9658 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9659 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9660 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9661 : : }
9662 : :
9663 : : int
9664 : 0 : test_pdcp_proto_uplane_decap(int i)
9665 : : {
9666 : 0 : return test_pdcp_proto(
9667 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9668 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9669 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9670 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9671 : 0 : pdcp_test_params[i].cipher_key_len,
9672 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9673 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9674 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9675 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9676 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9677 : : }
9678 : :
9679 : : int
9680 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
9681 : : {
9682 : 0 : return test_pdcp_proto(
9683 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9684 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9685 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9686 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9687 : 0 : pdcp_test_params[i].cipher_key_len,
9688 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9689 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9690 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9691 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9692 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9693 : : }
9694 : :
9695 : : static int
9696 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
9697 : : {
9698 : : /* i can be used for running any PDCP case
9699 : : * In this case it is uplane 12-bit AES-SNOW DL encap
9700 : : */
9701 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9702 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
9703 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9704 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9705 : : pdcp_test_data_in[i],
9706 : : pdcp_test_data_in_len[i],
9707 : : pdcp_test_data_out[i],
9708 : 0 : pdcp_test_data_in_len[i]+4,
9709 : : 32, 0);
9710 : : }
9711 : : static int
9712 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
9713 : : {
9714 : : /* i can be used for running any PDCP case
9715 : : * In this case it is uplane 18-bit NULL-NULL DL encap
9716 : : */
9717 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9718 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9719 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9720 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9721 : : pdcp_test_data_in[i],
9722 : : pdcp_test_data_in_len[i],
9723 : : pdcp_test_data_out[i],
9724 : 0 : pdcp_test_data_in_len[i]+4,
9725 : : 32, 128);
9726 : : }
9727 : : static int
9728 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
9729 : : {
9730 : : /* i can be used for running any PDCP case
9731 : : * In this case it is uplane 18-bit AES DL encap
9732 : : */
9733 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9734 : : + DOWNLINK;
9735 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9736 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9737 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9738 : : pdcp_test_data_in[i],
9739 : : pdcp_test_data_in_len[i],
9740 : : pdcp_test_data_out[i],
9741 : : pdcp_test_data_in_len[i],
9742 : : 32, 40);
9743 : : }
9744 : : static int
9745 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
9746 : : {
9747 : : /* i can be used for running any PDCP case
9748 : : * In this case it is cplane 12-bit AES-ZUC DL encap
9749 : : */
9750 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9751 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9752 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9753 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9754 : : pdcp_test_data_in[i],
9755 : : pdcp_test_data_in_len[i],
9756 : : pdcp_test_data_out[i],
9757 : 0 : pdcp_test_data_in_len[i]+4,
9758 : : 128, 32);
9759 : : }
9760 : :
9761 : : static int
9762 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
9763 : : {
9764 : : int i = 0, size = 0;
9765 : : int err, all_err = TEST_SUCCESS;
9766 : : const struct pdcp_sdap_test *cur_test;
9767 : :
9768 : : size = RTE_DIM(list_pdcp_sdap_tests);
9769 : :
9770 [ # # ]: 0 : for (i = 0; i < size; i++) {
9771 : : cur_test = &list_pdcp_sdap_tests[i];
9772 : 0 : err = test_pdcp_proto(
9773 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9774 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9775 : 0 : cur_test->in_len, cur_test->data_out,
9776 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9777 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
9778 : 0 : cur_test->param.cipher_key_len,
9779 : 0 : cur_test->param.auth_alg,
9780 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9781 : 0 : cur_test->bearer, cur_test->param.domain,
9782 : 0 : cur_test->packet_direction, cur_test->sn_size,
9783 : 0 : cur_test->hfn,
9784 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
9785 [ # # ]: 0 : if (err) {
9786 : : printf("\t%d) %s: Encapsulation failed\n",
9787 : 0 : cur_test->test_idx,
9788 : 0 : cur_test->param.name);
9789 : : err = TEST_FAILED;
9790 : : } else {
9791 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9792 : 0 : cur_test->param.name);
9793 : : err = TEST_SUCCESS;
9794 : : }
9795 : 0 : all_err += err;
9796 : : }
9797 : :
9798 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9799 : :
9800 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9801 : : }
9802 : :
9803 : : static int
9804 : 0 : test_PDCP_PROTO_short_mac(void)
9805 : : {
9806 : : int i = 0, size = 0;
9807 : : int err, all_err = TEST_SUCCESS;
9808 : : const struct pdcp_short_mac_test *cur_test;
9809 : :
9810 : : size = RTE_DIM(list_pdcp_smac_tests);
9811 : :
9812 [ # # ]: 0 : for (i = 0; i < size; i++) {
9813 : : cur_test = &list_pdcp_smac_tests[i];
9814 : 0 : err = test_pdcp_proto(
9815 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9816 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9817 : 0 : cur_test->in_len, cur_test->data_out,
9818 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9819 : : RTE_CRYPTO_CIPHER_NULL, NULL,
9820 : 0 : 0, cur_test->param.auth_alg,
9821 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9822 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
9823 : : 0, 0, 0);
9824 [ # # ]: 0 : if (err) {
9825 : : printf("\t%d) %s: Short MAC test failed\n",
9826 : 0 : cur_test->test_idx,
9827 : 0 : cur_test->param.name);
9828 : : err = TEST_FAILED;
9829 : : } else {
9830 : : printf("\t%d) %s: Short MAC test PASS\n",
9831 : 0 : cur_test->test_idx,
9832 : 0 : cur_test->param.name);
9833 : 0 : rte_hexdump(stdout, "MAC I",
9834 : 0 : cur_test->data_out + cur_test->in_len + 2,
9835 : : 2);
9836 : : err = TEST_SUCCESS;
9837 : : }
9838 : 0 : all_err += err;
9839 : : }
9840 : :
9841 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9842 : :
9843 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9844 : :
9845 : : }
9846 : :
9847 : : static int
9848 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
9849 : : {
9850 : : int i = 0, size = 0;
9851 : : int err, all_err = TEST_SUCCESS;
9852 : : const struct pdcp_sdap_test *cur_test;
9853 : :
9854 : : size = RTE_DIM(list_pdcp_sdap_tests);
9855 : :
9856 [ # # ]: 0 : for (i = 0; i < size; i++) {
9857 : : cur_test = &list_pdcp_sdap_tests[i];
9858 : 0 : err = test_pdcp_proto(
9859 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9860 : : RTE_CRYPTO_AUTH_OP_VERIFY,
9861 : 0 : cur_test->data_out,
9862 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9863 : 0 : cur_test->data_in, cur_test->in_len,
9864 : 0 : cur_test->param.cipher_alg,
9865 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
9866 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
9867 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
9868 : 0 : cur_test->param.domain, cur_test->packet_direction,
9869 : 0 : cur_test->sn_size, cur_test->hfn,
9870 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
9871 [ # # ]: 0 : if (err) {
9872 : : printf("\t%d) %s: Decapsulation failed\n",
9873 : 0 : cur_test->test_idx,
9874 : 0 : cur_test->param.name);
9875 : : err = TEST_FAILED;
9876 : : } else {
9877 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9878 : 0 : cur_test->param.name);
9879 : : err = TEST_SUCCESS;
9880 : : }
9881 : 0 : all_err += err;
9882 : : }
9883 : :
9884 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9885 : :
9886 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9887 : : }
9888 : :
9889 : : static inline void
9890 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
9891 : : {
9892 : 0 : }
9893 : :
9894 : : static inline void
9895 : 0 : ext_mbuf_memzone_free(int nb_segs)
9896 : : {
9897 : : int i;
9898 : :
9899 [ # # ]: 0 : for (i = 0; i <= nb_segs; i++) {
9900 : : char mz_name[RTE_MEMZONE_NAMESIZE];
9901 : : const struct rte_memzone *memzone;
9902 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9903 : 0 : memzone = rte_memzone_lookup(mz_name);
9904 [ # # ]: 0 : if (memzone != NULL) {
9905 : 0 : rte_memzone_free(memzone);
9906 : : memzone = NULL;
9907 : : }
9908 : : }
9909 : 0 : }
9910 : :
9911 : : static inline struct rte_mbuf *
9912 : 0 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
9913 : : int nb_segs, const void *input_text)
9914 : : {
9915 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
9916 : : size_t data_off = 0;
9917 : : uint8_t *dst;
9918 : : int i, size;
9919 : : int t_len;
9920 : :
9921 [ # # ]: 0 : if (pkt_len < 1) {
9922 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
9923 : 0 : return NULL;
9924 : : }
9925 : :
9926 [ # # ]: 0 : if (nb_segs < 1) {
9927 : : printf("Number of segments must be 1 or more (is %d)\n",
9928 : : nb_segs);
9929 : 0 : return NULL;
9930 : : }
9931 : :
9932 [ # # ]: 0 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
9933 : : size = pkt_len;
9934 : :
9935 : : /* Create chained mbuf_src with external buffer */
9936 [ # # ]: 0 : for (i = 0; size > 0; i++) {
9937 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
9938 : 0 : uint16_t data_len = RTE_MIN(size, t_len);
9939 : : char mz_name[RTE_MEMZONE_NAMESIZE];
9940 : : const struct rte_memzone *memzone;
9941 : : void *ext_buf_addr = NULL;
9942 : : rte_iova_t buf_iova;
9943 : 0 : bool freed = false;
9944 : : uint16_t buf_len;
9945 : :
9946 : 0 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
9947 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
9948 : :
9949 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9950 : 0 : memzone = rte_memzone_lookup(mz_name);
9951 [ # # # # ]: 0 : if (memzone != NULL && memzone->len != buf_len) {
9952 : 0 : rte_memzone_free(memzone);
9953 : : memzone = NULL;
9954 : : }
9955 [ # # ]: 0 : if (memzone == NULL) {
9956 : 0 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
9957 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
9958 [ # # ]: 0 : if (memzone == NULL) {
9959 : : printf("Can't allocate memory zone %s\n", mz_name);
9960 : 0 : return NULL;
9961 : : }
9962 : : }
9963 : :
9964 : 0 : ext_buf_addr = memzone->addr;
9965 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
9966 : :
9967 : : /* Create buffer to hold rte_mbuf header */
9968 : 0 : m = rte_pktmbuf_alloc(mbuf_pool);
9969 [ # # ]: 0 : if (i == 0)
9970 : : mbuf = m;
9971 : :
9972 [ # # ]: 0 : if (m == NULL) {
9973 : : printf("Cannot create segment for source mbuf");
9974 : 0 : goto fail;
9975 : : }
9976 : :
9977 : : /* Save shared data (like callback function) in external buffer's end */
9978 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
9979 : : ext_mbuf_callback_fn_free, &freed);
9980 : : if (ret_shinfo == NULL) {
9981 : : printf("Shared mem initialization failed!\n");
9982 : 0 : goto fail;
9983 : : }
9984 : :
9985 : 0 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
9986 : :
9987 : : /* Attach external buffer to mbuf */
9988 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
9989 : : ret_shinfo);
9990 [ # # ]: 0 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
9991 : : printf("External buffer is not attached to mbuf\n");
9992 : 0 : goto fail;
9993 : : }
9994 : :
9995 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
9996 [ # # ]: 0 : if (dst == NULL) {
9997 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
9998 : 0 : goto fail;
9999 : : }
10000 : :
10001 [ # # ]: 0 : if (mbuf != m)
10002 : : rte_pktmbuf_chain(mbuf, m);
10003 : :
10004 : 0 : size -= data_len;
10005 : 0 : data_off += data_len;
10006 : : }
10007 : :
10008 : : return mbuf;
10009 : :
10010 : : fail:
10011 : 0 : rte_pktmbuf_free(mbuf);
10012 : 0 : ext_mbuf_memzone_free(nb_segs);
10013 : 0 : return NULL;
10014 : : }
10015 : :
10016 : : static int
10017 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10018 : : struct crypto_unittest_params *ut_params,
10019 : : struct rte_security_ipsec_xform *ipsec_xform,
10020 : : const struct ipsec_test_data *td,
10021 : : const struct ipsec_test_flags *flags,
10022 : : int pkt_num)
10023 : : {
10024 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10025 : : enum rte_security_ipsec_sa_direction dir;
10026 : : int ret;
10027 : :
10028 : 0 : dir = ipsec_xform->direction;
10029 : :
10030 : : /* Generate crypto op data structure */
10031 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10032 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10033 [ # # ]: 0 : if (!ut_params->op) {
10034 : : printf("Could not allocate crypto op");
10035 : 0 : return TEST_FAILED;
10036 : : }
10037 : :
10038 : : /* Attach session to operation */
10039 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10040 : :
10041 : : /* Set crypto operation mbufs */
10042 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10043 : 0 : ut_params->op->sym->m_dst = NULL;
10044 : :
10045 : : /* Copy IV in crypto operation when IV generation is disabled */
10046 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10047 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10048 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10049 : : uint8_t *,
10050 : : IV_OFFSET);
10051 : : int len;
10052 : :
10053 [ # # ]: 0 : if (td->aead)
10054 : 0 : len = td->xform.aead.aead.iv.length;
10055 [ # # ]: 0 : else if (td->aes_gmac)
10056 : 0 : len = td->xform.chain.auth.auth.iv.length;
10057 : : else
10058 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10059 : :
10060 : 0 : memcpy(iv, td->iv.data, len);
10061 : : }
10062 : :
10063 : : /* Process crypto operation */
10064 : 0 : process_crypto_request(dev_id, ut_params->op);
10065 : :
10066 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10067 : :
10068 : 0 : rte_crypto_op_free(ut_params->op);
10069 : 0 : ut_params->op = NULL;
10070 : :
10071 : 0 : return ret;
10072 : : }
10073 : :
10074 : : static int
10075 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10076 : : struct crypto_unittest_params *ut_params,
10077 : : void *ctx)
10078 : : {
10079 : : uint64_t timeout, userdata;
10080 : : struct rte_ether_hdr *hdr;
10081 : : struct rte_mbuf *m;
10082 : : void **sec_sess;
10083 : : int ret;
10084 : :
10085 : : RTE_SET_USED(ts_params);
10086 : :
10087 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10088 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10089 : :
10090 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10091 : 0 : ut_params->ibuf->port = 0;
10092 : :
10093 : 0 : sec_sess = &ut_params->sec_session;
10094 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10095 : :
10096 [ # # ]: 0 : if (ret != 1)
10097 : : return TEST_FAILED;
10098 : :
10099 : 0 : ut_params->ibuf = NULL;
10100 : :
10101 : : /* Add a timeout for 1 s */
10102 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10103 : :
10104 : : do {
10105 : : /* Get packet from port 0, queue 0 */
10106 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10107 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10108 : :
10109 [ # # ]: 0 : if (ret == 0) {
10110 : : printf("Could not receive packets from ethdev\n");
10111 : 0 : return TEST_FAILED;
10112 : : }
10113 : :
10114 [ # # ]: 0 : if (m == NULL) {
10115 : : printf("Received mbuf is NULL\n");
10116 : 0 : return TEST_FAILED;
10117 : : }
10118 : :
10119 : 0 : ut_params->ibuf = m;
10120 : :
10121 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10122 : : printf("Received packet is not Rx security processed\n");
10123 : 0 : return TEST_FAILED;
10124 : : }
10125 : :
10126 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10127 : : printf("Received packet has failed Rx security processing\n");
10128 : 0 : return TEST_FAILED;
10129 : : }
10130 : :
10131 : : /*
10132 : : * 'ut_params' is set as userdata. Verify that the field is returned
10133 : : * correctly.
10134 : : */
10135 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10136 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10137 : : printf("Userdata retrieved not matching expected\n");
10138 : 0 : return TEST_FAILED;
10139 : : }
10140 : :
10141 : : /* Trim L2 header */
10142 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10143 : :
10144 : : return TEST_SUCCESS;
10145 : : }
10146 : :
10147 : : static int
10148 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10149 : : struct ipsec_test_data res_d[],
10150 : : int nb_td,
10151 : : bool silent,
10152 : : const struct ipsec_test_flags *flags)
10153 : : {
10154 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10155 : : 0x0000, 0x001a};
10156 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10157 : : 0xe82c, 0x4887};
10158 : : const struct rte_ipv4_hdr *ipv4 =
10159 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10160 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10161 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10162 : : struct crypto_unittest_params *ut_params = &unittest_params;
10163 : : struct rte_security_capability_idx sec_cap_idx;
10164 : : const struct rte_security_capability *sec_cap;
10165 : : struct rte_security_ipsec_xform ipsec_xform;
10166 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10167 : : enum rte_security_ipsec_sa_direction dir;
10168 : : struct ipsec_test_data *res_d_tmp = NULL;
10169 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10170 : : int salt_len, i, ret = TEST_SUCCESS;
10171 : : void *ctx;
10172 : : uint32_t src, dst;
10173 : : uint32_t verify;
10174 : :
10175 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10176 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10177 : :
10178 : : /* Use first test data to create session */
10179 : :
10180 : : /* Copy IPsec xform */
10181 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10182 : :
10183 : 0 : dir = ipsec_xform.direction;
10184 : 0 : verify = flags->tunnel_hdr_verify;
10185 : :
10186 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10187 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10188 : :
10189 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10190 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10191 : 0 : src += 1;
10192 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10193 : 0 : dst += 1;
10194 : : }
10195 : :
10196 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10197 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10198 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10199 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10200 : : sizeof(src));
10201 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10202 : : sizeof(dst));
10203 : :
10204 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10205 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10206 : :
10207 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10208 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10209 : :
10210 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10211 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10212 : :
10213 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10214 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10215 : : TEST_IPSEC_DSCP_VAL;
10216 : :
10217 : : } else {
10218 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10219 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10220 : :
10221 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10222 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10223 : : TEST_IPSEC_DSCP_VAL;
10224 : :
10225 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10226 : : sizeof(v6_src));
10227 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10228 : : sizeof(v6_dst));
10229 : : }
10230 : : }
10231 : :
10232 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10233 : :
10234 : 0 : sec_cap_idx.action = ut_params->type;
10235 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10236 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10237 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10238 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10239 : :
10240 [ # # ]: 0 : if (flags->udp_encap)
10241 : 0 : ipsec_xform.options.udp_encap = 1;
10242 : :
10243 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10244 [ # # ]: 0 : if (sec_cap == NULL)
10245 : : return TEST_SKIPPED;
10246 : :
10247 : : /* Copy cipher session parameters */
10248 [ # # ]: 0 : if (td[0].aead) {
10249 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10250 : : sizeof(ut_params->aead_xform));
10251 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10252 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10253 : :
10254 : : /* Verify crypto capabilities */
10255 [ # # ]: 0 : if (test_ipsec_crypto_caps_aead_verify(
10256 : : sec_cap,
10257 : : &ut_params->aead_xform) != 0) {
10258 [ # # ]: 0 : if (!silent)
10259 : 0 : RTE_LOG(INFO, USER1,
10260 : : "Crypto capabilities not supported\n");
10261 : 0 : return TEST_SKIPPED;
10262 : : }
10263 [ # # ]: 0 : } else if (td[0].auth_only) {
10264 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10265 : : sizeof(ut_params->auth_xform));
10266 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10267 : :
10268 [ # # ]: 0 : if (test_ipsec_crypto_caps_auth_verify(
10269 : : sec_cap,
10270 : : &ut_params->auth_xform) != 0) {
10271 [ # # ]: 0 : if (!silent)
10272 : 0 : RTE_LOG(INFO, USER1,
10273 : : "Auth crypto capabilities not supported\n");
10274 : 0 : return TEST_SKIPPED;
10275 : : }
10276 : : } else {
10277 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10278 : : sizeof(ut_params->cipher_xform));
10279 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10280 : : sizeof(ut_params->auth_xform));
10281 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10282 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10283 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10284 : :
10285 : : /* Verify crypto capabilities */
10286 : :
10287 [ # # ]: 0 : if (test_ipsec_crypto_caps_cipher_verify(
10288 : : sec_cap,
10289 : : &ut_params->cipher_xform) != 0) {
10290 [ # # ]: 0 : if (!silent)
10291 : 0 : RTE_LOG(INFO, USER1,
10292 : : "Cipher crypto capabilities not supported\n");
10293 : 0 : return TEST_SKIPPED;
10294 : : }
10295 : :
10296 [ # # ]: 0 : if (test_ipsec_crypto_caps_auth_verify(
10297 : : sec_cap,
10298 : : &ut_params->auth_xform) != 0) {
10299 [ # # ]: 0 : if (!silent)
10300 : 0 : RTE_LOG(INFO, USER1,
10301 : : "Auth crypto capabilities not supported\n");
10302 : 0 : return TEST_SKIPPED;
10303 : : }
10304 : : }
10305 : :
10306 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10307 : : return TEST_SKIPPED;
10308 : :
10309 : 0 : struct rte_security_session_conf sess_conf = {
10310 : 0 : .action_type = ut_params->type,
10311 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10312 : : };
10313 : :
10314 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac) {
10315 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10316 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10317 : : }
10318 : :
10319 [ # # ]: 0 : if (td[0].aead) {
10320 : 0 : sess_conf.ipsec = ipsec_xform;
10321 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10322 [ # # ]: 0 : } else if (td[0].auth_only) {
10323 : 0 : sess_conf.ipsec = ipsec_xform;
10324 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10325 : : } else {
10326 : 0 : sess_conf.ipsec = ipsec_xform;
10327 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10328 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10329 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10330 : : } else {
10331 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10332 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10333 : : }
10334 : : }
10335 : :
10336 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10337 : 0 : sess_conf.userdata = ut_params;
10338 : :
10339 : : /* Create security session */
10340 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10341 : : ts_params->session_mpool);
10342 : :
10343 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10344 : : return TEST_SKIPPED;
10345 : :
10346 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10347 [ # # # # ]: 0 : if (flags->antireplay &&
10348 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10349 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10350 : 0 : ret = rte_security_session_update(ctx,
10351 : : ut_params->sec_session, &sess_conf);
10352 [ # # ]: 0 : if (ret) {
10353 : : printf("Could not update sequence number in "
10354 : : "session\n");
10355 : 0 : return TEST_SKIPPED;
10356 : : }
10357 : : }
10358 : :
10359 : : /* Copy test data before modification */
10360 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10361 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10362 : : ret = TEST_FAILED;
10363 : 0 : goto mbuf_free;
10364 : : }
10365 : :
10366 : : /* Setup source mbuf payload */
10367 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10368 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10369 : 0 : td[i].input_text.len, nb_segs, input_text);
10370 : : } else {
10371 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10372 : 0 : td[i].input_text.len, nb_segs, 0);
10373 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10374 : : }
10375 : :
10376 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10377 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10378 : : ctx);
10379 : : else
10380 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10381 : : ut_params,
10382 : : &ipsec_xform,
10383 : : &td[i], flags,
10384 : : i + 1);
10385 : :
10386 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10387 : 0 : goto mbuf_free;
10388 : :
10389 [ # # ]: 0 : if (res_d != NULL)
10390 : 0 : res_d_tmp = &res_d[i];
10391 : :
10392 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10393 : : res_d_tmp, silent, flags);
10394 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10395 : 0 : goto mbuf_free;
10396 : :
10397 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10398 : : flags, dir);
10399 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10400 : 0 : goto mbuf_free;
10401 : :
10402 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10403 : 0 : ut_params->ibuf = NULL;
10404 : : }
10405 : :
10406 : 0 : mbuf_free:
10407 [ # # ]: 0 : if (flags->use_ext_mbuf)
10408 : 0 : ext_mbuf_memzone_free(nb_segs);
10409 : :
10410 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10411 : 0 : ut_params->ibuf = NULL;
10412 : :
10413 [ # # ]: 0 : if (ut_params->sec_session)
10414 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10415 : 0 : ut_params->sec_session = NULL;
10416 : :
10417 : 0 : return ret;
10418 : : }
10419 : :
10420 : : static int
10421 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10422 : : {
10423 : : struct ipsec_test_data td_outb;
10424 : : struct ipsec_test_flags flags;
10425 : :
10426 : : memset(&flags, 0, sizeof(flags));
10427 : :
10428 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10429 : :
10430 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10431 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10432 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10433 : : /* Disable IV gen to be able to test with known vectors */
10434 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10435 : : }
10436 : :
10437 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10438 : : }
10439 : :
10440 : : static int
10441 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10442 : : {
10443 : : struct ipsec_test_data td_outb;
10444 : : struct ipsec_test_flags flags;
10445 : :
10446 : : memset(&flags, 0, sizeof(flags));
10447 [ # # ]: 0 : flags.use_ext_mbuf = true;
10448 : :
10449 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10450 : :
10451 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10452 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10453 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10454 : : /* Disable IV gen to be able to test with known vectors */
10455 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10456 : : }
10457 : :
10458 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10459 : : }
10460 : :
10461 : : static int
10462 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10463 : : {
10464 : : const struct ipsec_test_data *td = test_data;
10465 : : struct ipsec_test_flags flags;
10466 : : struct ipsec_test_data td_inb;
10467 : :
10468 : : memset(&flags, 0, sizeof(flags));
10469 : :
10470 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10471 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10472 : : else
10473 : : memcpy(&td_inb, td, sizeof(td_inb));
10474 : :
10475 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10476 : : }
10477 : :
10478 : : static int
10479 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10480 : : {
10481 : : struct ipsec_test_data td_outb;
10482 : : struct ipsec_test_flags flags;
10483 : :
10484 : : memset(&flags, 0, sizeof(flags));
10485 : 0 : flags.fragment = true;
10486 : :
10487 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10488 : :
10489 : : /* Disable IV gen to be able to test with known vectors */
10490 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10491 : :
10492 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10493 : : }
10494 : :
10495 : : static int
10496 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10497 : : {
10498 : : const struct ipsec_test_data *td = test_data;
10499 : : struct ipsec_test_flags flags;
10500 : : struct ipsec_test_data td_inb;
10501 : :
10502 : : memset(&flags, 0, sizeof(flags));
10503 : 0 : flags.rx_inject = true;
10504 : :
10505 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10506 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10507 : : else
10508 : : memcpy(&td_inb, td, sizeof(td_inb));
10509 : :
10510 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10511 : : }
10512 : :
10513 : : static int
10514 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10515 : : {
10516 : : struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10517 : : struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10518 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10519 : : int ret;
10520 : :
10521 [ # # ]: 0 : if (flags->iv_gen ||
10522 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10523 : : flags->sa_expiry_pkts_hard)
10524 : : nb_pkts = IPSEC_TEST_PACKETS_MAX;
10525 : :
10526 [ # # ]: 0 : for (i = 0; i < RTE_DIM(alg_list); i++) {
10527 : 0 : test_ipsec_td_prepare(alg_list[i].param1,
10528 : : alg_list[i].param2,
10529 : : flags,
10530 : : td_outb,
10531 : : nb_pkts);
10532 : :
10533 [ # # ]: 0 : if (!td_outb->aead) {
10534 : : enum rte_crypto_cipher_algorithm cipher_alg;
10535 : : enum rte_crypto_auth_algorithm auth_alg;
10536 : :
10537 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10538 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10539 : :
10540 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10541 : 0 : continue;
10542 : :
10543 : : /* ICV is not applicable for NULL auth */
10544 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10545 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10546 : 0 : continue;
10547 : :
10548 : : /* IV is not applicable for NULL cipher */
10549 [ # # # # ]: 0 : if (flags->iv_gen &&
10550 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10551 : 0 : continue;
10552 : : }
10553 : :
10554 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10555 : : flags);
10556 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10557 : 0 : continue;
10558 : :
10559 [ # # ]: 0 : if (ret == TEST_FAILED)
10560 : : return TEST_FAILED;
10561 : :
10562 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10563 : :
10564 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10565 : : flags);
10566 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10567 : 0 : continue;
10568 : :
10569 [ # # ]: 0 : if (ret == TEST_FAILED)
10570 : : return TEST_FAILED;
10571 : :
10572 [ # # ]: 0 : if (flags->display_alg)
10573 : 0 : test_ipsec_display_alg(alg_list[i].param1,
10574 : : alg_list[i].param2);
10575 : :
10576 : 0 : pass_cnt++;
10577 : : }
10578 : :
10579 [ # # ]: 0 : if (pass_cnt > 0)
10580 : : return TEST_SUCCESS;
10581 : : else
10582 : 0 : return TEST_SKIPPED;
10583 : : }
10584 : :
10585 : : static int
10586 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10587 : : {
10588 : : struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10589 : : struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10590 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10591 : : int ret;
10592 : :
10593 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ah_alg_list); i++) {
10594 : 0 : test_ipsec_td_prepare(ah_alg_list[i].param1,
10595 : : ah_alg_list[i].param2,
10596 : : flags,
10597 : : td_outb,
10598 : : nb_pkts);
10599 : :
10600 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10601 : : flags);
10602 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10603 : 0 : continue;
10604 : :
10605 [ # # ]: 0 : if (ret == TEST_FAILED)
10606 : : return TEST_FAILED;
10607 : :
10608 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10609 : :
10610 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10611 : : flags);
10612 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10613 : 0 : continue;
10614 : :
10615 [ # # ]: 0 : if (ret == TEST_FAILED)
10616 : : return TEST_FAILED;
10617 : :
10618 [ # # ]: 0 : if (flags->display_alg)
10619 : 0 : test_ipsec_display_alg(ah_alg_list[i].param1,
10620 : : ah_alg_list[i].param2);
10621 : :
10622 : 0 : pass_cnt++;
10623 : : }
10624 : :
10625 [ # # ]: 0 : if (pass_cnt > 0)
10626 : : return TEST_SUCCESS;
10627 : : else
10628 : 0 : return TEST_SKIPPED;
10629 : : }
10630 : :
10631 : : static int
10632 : 0 : test_ipsec_proto_display_list(void)
10633 : : {
10634 : : struct ipsec_test_flags flags;
10635 : :
10636 : : memset(&flags, 0, sizeof(flags));
10637 : :
10638 : 0 : flags.display_alg = true;
10639 : :
10640 : 0 : return test_ipsec_proto_all(&flags);
10641 : : }
10642 : :
10643 : : static int
10644 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10645 : : {
10646 : : struct ipsec_test_flags flags;
10647 : :
10648 : : memset(&flags, 0, sizeof(flags));
10649 : :
10650 : 0 : flags.ah = true;
10651 : 0 : flags.display_alg = true;
10652 : :
10653 : 0 : return test_ipsec_ah_proto_all(&flags);
10654 : : }
10655 : :
10656 : : static int
10657 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10658 : : {
10659 : : struct ipsec_test_flags flags;
10660 : :
10661 : : memset(&flags, 0, sizeof(flags));
10662 : :
10663 : 0 : flags.ah = true;
10664 : 0 : flags.transport = true;
10665 : :
10666 : 0 : return test_ipsec_ah_proto_all(&flags);
10667 : : }
10668 : :
10669 : : static int
10670 : 0 : test_ipsec_proto_iv_gen(void)
10671 : : {
10672 : : struct ipsec_test_flags flags;
10673 : :
10674 : : memset(&flags, 0, sizeof(flags));
10675 : :
10676 : 0 : flags.iv_gen = true;
10677 : :
10678 : 0 : return test_ipsec_proto_all(&flags);
10679 : : }
10680 : :
10681 : : static int
10682 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10683 : : {
10684 : : struct ipsec_test_flags flags;
10685 : :
10686 : : memset(&flags, 0, sizeof(flags));
10687 : :
10688 : 0 : flags.sa_expiry_pkts_soft = true;
10689 : :
10690 : 0 : return test_ipsec_proto_all(&flags);
10691 : : }
10692 : :
10693 : : static int
10694 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10695 : : {
10696 : : struct ipsec_test_flags flags;
10697 : :
10698 : : memset(&flags, 0, sizeof(flags));
10699 : :
10700 : 0 : flags.sa_expiry_pkts_hard = true;
10701 : :
10702 : 0 : return test_ipsec_proto_all(&flags);
10703 : : }
10704 : :
10705 : : static int
10706 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10707 : : {
10708 : : struct ipsec_test_flags flags;
10709 : :
10710 : : memset(&flags, 0, sizeof(flags));
10711 : :
10712 : 0 : flags.icv_corrupt = true;
10713 : :
10714 : 0 : return test_ipsec_proto_all(&flags);
10715 : : }
10716 : :
10717 : : static int
10718 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10719 : : {
10720 : : struct ipsec_test_flags flags;
10721 : :
10722 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10723 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10724 : : return TEST_SKIPPED;
10725 : :
10726 : : memset(&flags, 0, sizeof(flags));
10727 : :
10728 : 0 : flags.udp_encap = true;
10729 : 0 : flags.udp_encap_custom_ports = true;
10730 : :
10731 : 0 : return test_ipsec_proto_all(&flags);
10732 : : }
10733 : :
10734 : : static int
10735 : 0 : test_ipsec_proto_udp_encap(void)
10736 : : {
10737 : : struct ipsec_test_flags flags;
10738 : :
10739 : : memset(&flags, 0, sizeof(flags));
10740 : :
10741 : 0 : flags.udp_encap = true;
10742 : :
10743 : 0 : return test_ipsec_proto_all(&flags);
10744 : : }
10745 : :
10746 : : static int
10747 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10748 : : {
10749 : : struct ipsec_test_flags flags;
10750 : :
10751 : : memset(&flags, 0, sizeof(flags));
10752 : :
10753 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10754 : :
10755 : 0 : return test_ipsec_proto_all(&flags);
10756 : : }
10757 : :
10758 : : static int
10759 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
10760 : : {
10761 : : struct ipsec_test_flags flags;
10762 : :
10763 : : memset(&flags, 0, sizeof(flags));
10764 : :
10765 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10766 : :
10767 : 0 : return test_ipsec_proto_all(&flags);
10768 : : }
10769 : :
10770 : : static int
10771 : 0 : test_ipsec_proto_udp_ports_verify(void)
10772 : : {
10773 : : struct ipsec_test_flags flags;
10774 : :
10775 : : memset(&flags, 0, sizeof(flags));
10776 : :
10777 : 0 : flags.udp_encap = true;
10778 : 0 : flags.udp_ports_verify = true;
10779 : :
10780 : 0 : return test_ipsec_proto_all(&flags);
10781 : : }
10782 : :
10783 : : static int
10784 : 0 : test_ipsec_proto_inner_ip_csum(void)
10785 : : {
10786 : : struct ipsec_test_flags flags;
10787 : :
10788 : : memset(&flags, 0, sizeof(flags));
10789 : :
10790 : 0 : flags.ip_csum = true;
10791 : :
10792 : 0 : return test_ipsec_proto_all(&flags);
10793 : : }
10794 : :
10795 : : static int
10796 : 0 : test_ipsec_proto_inner_l4_csum(void)
10797 : : {
10798 : : struct ipsec_test_flags flags;
10799 : :
10800 : : memset(&flags, 0, sizeof(flags));
10801 : :
10802 : 0 : flags.l4_csum = true;
10803 : :
10804 : 0 : return test_ipsec_proto_all(&flags);
10805 : : }
10806 : :
10807 : : static int
10808 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
10809 : : {
10810 : : struct ipsec_test_flags flags;
10811 : :
10812 : : memset(&flags, 0, sizeof(flags));
10813 : :
10814 : : flags.ipv6 = false;
10815 : : flags.tunnel_ipv6 = false;
10816 : :
10817 : 0 : return test_ipsec_proto_all(&flags);
10818 : : }
10819 : :
10820 : : static int
10821 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
10822 : : {
10823 : : struct ipsec_test_flags flags;
10824 : :
10825 : : memset(&flags, 0, sizeof(flags));
10826 : :
10827 : 0 : flags.ipv6 = true;
10828 : 0 : flags.tunnel_ipv6 = true;
10829 : :
10830 : 0 : return test_ipsec_proto_all(&flags);
10831 : : }
10832 : :
10833 : : static int
10834 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
10835 : : {
10836 : : struct ipsec_test_flags flags;
10837 : :
10838 : : memset(&flags, 0, sizeof(flags));
10839 : :
10840 : : flags.ipv6 = false;
10841 : 0 : flags.tunnel_ipv6 = true;
10842 : :
10843 : 0 : return test_ipsec_proto_all(&flags);
10844 : : }
10845 : :
10846 : : static int
10847 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
10848 : : {
10849 : : struct ipsec_test_flags flags;
10850 : :
10851 : : memset(&flags, 0, sizeof(flags));
10852 : :
10853 : 0 : flags.ipv6 = true;
10854 : : flags.tunnel_ipv6 = false;
10855 : :
10856 : 0 : return test_ipsec_proto_all(&flags);
10857 : : }
10858 : :
10859 : : static int
10860 : 0 : test_ipsec_proto_transport_v4(void)
10861 : : {
10862 : : struct ipsec_test_flags flags;
10863 : :
10864 : : memset(&flags, 0, sizeof(flags));
10865 : :
10866 : : flags.ipv6 = false;
10867 : 0 : flags.transport = true;
10868 : :
10869 : 0 : return test_ipsec_proto_all(&flags);
10870 : : }
10871 : :
10872 : : static int
10873 : 0 : test_ipsec_proto_transport_l4_csum(void)
10874 : : {
10875 : 0 : struct ipsec_test_flags flags = {
10876 : : .l4_csum = true,
10877 : : .transport = true,
10878 : : };
10879 : :
10880 : 0 : return test_ipsec_proto_all(&flags);
10881 : : }
10882 : :
10883 : : static int
10884 : 0 : test_ipsec_proto_stats(void)
10885 : : {
10886 : : struct ipsec_test_flags flags;
10887 : :
10888 : : memset(&flags, 0, sizeof(flags));
10889 : :
10890 : 0 : flags.stats_success = true;
10891 : :
10892 : 0 : return test_ipsec_proto_all(&flags);
10893 : : }
10894 : :
10895 : : static int
10896 : 0 : test_ipsec_proto_pkt_fragment(void)
10897 : : {
10898 : : struct ipsec_test_flags flags;
10899 : :
10900 : : memset(&flags, 0, sizeof(flags));
10901 : :
10902 : 0 : flags.fragment = true;
10903 : :
10904 : 0 : return test_ipsec_proto_all(&flags);
10905 : :
10906 : : }
10907 : :
10908 : : static int
10909 : 0 : test_ipsec_proto_copy_df_inner_0(void)
10910 : : {
10911 : : struct ipsec_test_flags flags;
10912 : :
10913 : : memset(&flags, 0, sizeof(flags));
10914 : :
10915 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10916 : :
10917 : 0 : return test_ipsec_proto_all(&flags);
10918 : : }
10919 : :
10920 : : static int
10921 : 0 : test_ipsec_proto_copy_df_inner_1(void)
10922 : : {
10923 : : struct ipsec_test_flags flags;
10924 : :
10925 : : memset(&flags, 0, sizeof(flags));
10926 : :
10927 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10928 : :
10929 : 0 : return test_ipsec_proto_all(&flags);
10930 : : }
10931 : :
10932 : : static int
10933 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
10934 : : {
10935 : : struct ipsec_test_flags flags;
10936 : :
10937 : : memset(&flags, 0, sizeof(flags));
10938 : :
10939 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10940 : :
10941 : 0 : return test_ipsec_proto_all(&flags);
10942 : : }
10943 : :
10944 : : static int
10945 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
10946 : : {
10947 : : struct ipsec_test_flags flags;
10948 : :
10949 : : memset(&flags, 0, sizeof(flags));
10950 : :
10951 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10952 : :
10953 : 0 : return test_ipsec_proto_all(&flags);
10954 : : }
10955 : :
10956 : : static int
10957 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10958 : : {
10959 : : struct ipsec_test_flags flags;
10960 : :
10961 : : memset(&flags, 0, sizeof(flags));
10962 : :
10963 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10964 : :
10965 : 0 : return test_ipsec_proto_all(&flags);
10966 : : }
10967 : :
10968 : : static int
10969 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
10970 : : {
10971 : : struct ipsec_test_flags flags;
10972 : :
10973 : : memset(&flags, 0, sizeof(flags));
10974 : :
10975 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10976 : :
10977 : 0 : return test_ipsec_proto_all(&flags);
10978 : : }
10979 : :
10980 : : static int
10981 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
10982 : : {
10983 : : struct ipsec_test_flags flags;
10984 : :
10985 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10986 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10987 : : return TEST_SKIPPED;
10988 : :
10989 : : memset(&flags, 0, sizeof(flags));
10990 : :
10991 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10992 : :
10993 : 0 : return test_ipsec_proto_all(&flags);
10994 : : }
10995 : :
10996 : : static int
10997 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
10998 : : {
10999 : : struct ipsec_test_flags flags;
11000 : :
11001 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11002 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11003 : : return TEST_SKIPPED;
11004 : :
11005 : : memset(&flags, 0, sizeof(flags));
11006 : :
11007 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11008 : :
11009 : 0 : return test_ipsec_proto_all(&flags);
11010 : : }
11011 : :
11012 : : static int
11013 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11014 : : {
11015 : : struct ipsec_test_flags flags;
11016 : :
11017 : : memset(&flags, 0, sizeof(flags));
11018 : :
11019 : 0 : flags.ipv6 = true;
11020 : 0 : flags.tunnel_ipv6 = true;
11021 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11022 : :
11023 : 0 : return test_ipsec_proto_all(&flags);
11024 : : }
11025 : :
11026 : : static int
11027 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11028 : : {
11029 : : struct ipsec_test_flags flags;
11030 : :
11031 : : memset(&flags, 0, sizeof(flags));
11032 : :
11033 : 0 : flags.ipv6 = true;
11034 : 0 : flags.tunnel_ipv6 = true;
11035 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11036 : :
11037 : 0 : return test_ipsec_proto_all(&flags);
11038 : : }
11039 : :
11040 : : static int
11041 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11042 : : {
11043 : : struct ipsec_test_flags flags;
11044 : :
11045 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11046 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11047 : : return TEST_SKIPPED;
11048 : :
11049 : : memset(&flags, 0, sizeof(flags));
11050 : :
11051 : 0 : flags.ipv6 = true;
11052 : 0 : flags.tunnel_ipv6 = true;
11053 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11054 : :
11055 : 0 : return test_ipsec_proto_all(&flags);
11056 : : }
11057 : :
11058 : : static int
11059 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11060 : : {
11061 : : struct ipsec_test_flags flags;
11062 : :
11063 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11064 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11065 : : return TEST_SKIPPED;
11066 : :
11067 : : memset(&flags, 0, sizeof(flags));
11068 : :
11069 : 0 : flags.ipv6 = true;
11070 : 0 : flags.tunnel_ipv6 = true;
11071 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11072 : :
11073 : 0 : return test_ipsec_proto_all(&flags);
11074 : : }
11075 : :
11076 : : static int
11077 : 0 : test_ipsec_proto_sgl(void)
11078 : : {
11079 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11080 : : struct rte_cryptodev_info dev_info;
11081 : :
11082 : 0 : struct ipsec_test_flags flags = {
11083 : : .nb_segs_in_mbuf = 5
11084 : : };
11085 : :
11086 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11087 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11088 : : printf("Device doesn't support in-place scatter-gather. "
11089 : : "Test Skipped.\n");
11090 : 0 : return TEST_SKIPPED;
11091 : : }
11092 : :
11093 : 0 : return test_ipsec_proto_all(&flags);
11094 : : }
11095 : :
11096 : : static int
11097 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11098 : : {
11099 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11100 : : struct rte_cryptodev_info dev_info;
11101 : :
11102 : 0 : struct ipsec_test_flags flags = {
11103 : : .nb_segs_in_mbuf = 5,
11104 : : .use_ext_mbuf = 1
11105 : : };
11106 : :
11107 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11108 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11109 : : printf("Device doesn't support in-place scatter-gather. "
11110 : : "Test Skipped.\n");
11111 : 0 : return TEST_SKIPPED;
11112 : : }
11113 : :
11114 : 0 : return test_ipsec_proto_all(&flags);
11115 : : }
11116 : :
11117 : : static int
11118 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11119 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11120 : : uint64_t winsz)
11121 : : {
11122 : : struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
11123 : : struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
11124 : : struct ipsec_test_flags flags;
11125 : : uint32_t i = 0, ret = 0;
11126 : :
11127 [ # # ]: 0 : if (nb_pkts == 0)
11128 : : return TEST_FAILED;
11129 : :
11130 : : memset(&flags, 0, sizeof(flags));
11131 : 0 : flags.antireplay = true;
11132 : :
11133 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11134 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11135 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11136 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11137 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11138 : : }
11139 : :
11140 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11141 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11142 : :
11143 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11144 : : &flags);
11145 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11146 : : return ret;
11147 : :
11148 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11149 : :
11150 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11151 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11152 : : /* Set antireplay flag for packets to be dropped */
11153 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11154 : : }
11155 : :
11156 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11157 : : &flags);
11158 : :
11159 : 0 : return ret;
11160 : : }
11161 : :
11162 : : static int
11163 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11164 : : {
11165 : :
11166 : : uint32_t nb_pkts = 5;
11167 : : bool replayed_pkt[5];
11168 : : uint64_t esn[5];
11169 : :
11170 : : /* 1. Advance the TOP of the window to WS * 2 */
11171 : 0 : esn[0] = winsz * 2;
11172 : : /* 2. Test sequence number within the new window(WS + 1) */
11173 : 0 : esn[1] = winsz + 1;
11174 : : /* 3. Test sequence number less than the window BOTTOM */
11175 : 0 : esn[2] = winsz;
11176 : : /* 4. Test sequence number in the middle of the window */
11177 : 0 : esn[3] = winsz + (winsz / 2);
11178 : : /* 5. Test replay of the packet in the middle of the window */
11179 : 0 : esn[4] = winsz + (winsz / 2);
11180 : :
11181 : 0 : replayed_pkt[0] = false;
11182 : 0 : replayed_pkt[1] = false;
11183 : 0 : replayed_pkt[2] = true;
11184 : 0 : replayed_pkt[3] = false;
11185 : 0 : replayed_pkt[4] = true;
11186 : :
11187 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11188 : : false, winsz);
11189 : : }
11190 : :
11191 : : static int
11192 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11193 : : {
11194 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11195 : : }
11196 : :
11197 : : static int
11198 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11199 : : {
11200 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11201 : : }
11202 : :
11203 : : static int
11204 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11205 : : {
11206 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11207 : : }
11208 : :
11209 : : static int
11210 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11211 : : {
11212 : :
11213 : : uint32_t nb_pkts = 7;
11214 : : bool replayed_pkt[7];
11215 : : uint64_t esn[7];
11216 : :
11217 : : /* Set the initial sequence number */
11218 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11219 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11220 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11221 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11222 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11223 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11224 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11225 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11226 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11227 : : /* 5. Test with duplicate sequence number within
11228 : : * new window (1<<32 - 1)
11229 : : */
11230 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11231 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11232 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11233 : :
11234 : 0 : replayed_pkt[0] = false;
11235 : 0 : replayed_pkt[1] = false;
11236 : 0 : replayed_pkt[2] = false;
11237 : 0 : replayed_pkt[3] = false;
11238 : 0 : replayed_pkt[4] = false;
11239 : 0 : replayed_pkt[5] = true;
11240 : 0 : replayed_pkt[6] = true;
11241 : :
11242 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11243 : : true, winsz);
11244 : : }
11245 : :
11246 : : static int
11247 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11248 : : {
11249 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11250 : : }
11251 : :
11252 : : static int
11253 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11254 : : {
11255 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11256 : : }
11257 : :
11258 : : static int
11259 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11260 : : {
11261 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11262 : : }
11263 : :
11264 : : static int
11265 : 0 : test_PDCP_PROTO_all(void)
11266 : : {
11267 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11268 : : struct crypto_unittest_params *ut_params = &unittest_params;
11269 : : struct rte_cryptodev_info dev_info;
11270 : : int status;
11271 : :
11272 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11273 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11274 : :
11275 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11276 : : return TEST_SKIPPED;
11277 : :
11278 : : /* Set action type */
11279 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11280 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11281 : : gbl_action_type;
11282 : :
11283 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11284 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11285 : : return TEST_SKIPPED;
11286 : :
11287 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11288 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11289 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11290 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11291 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11292 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11293 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11294 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11295 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11296 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11297 : 0 : status += test_PDCP_PROTO_short_mac();
11298 : :
11299 [ # # ]: 0 : if (status)
11300 : : return TEST_FAILED;
11301 : : else
11302 : 0 : return TEST_SUCCESS;
11303 : : }
11304 : :
11305 : : static int
11306 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11307 : : {
11308 : 0 : struct ipsec_test_flags flags = {
11309 : : .dec_ttl_or_hop_limit = true
11310 : : };
11311 : :
11312 : 0 : return test_ipsec_proto_all(&flags);
11313 : : }
11314 : :
11315 : : static int
11316 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11317 : : {
11318 : 0 : struct ipsec_test_flags flags = {
11319 : : .ipv6 = true,
11320 : : .dec_ttl_or_hop_limit = true
11321 : : };
11322 : :
11323 : 0 : return test_ipsec_proto_all(&flags);
11324 : : }
11325 : :
11326 : : static int
11327 : 0 : test_docsis_proto_uplink(const void *data)
11328 : : {
11329 : : const struct docsis_test_data *d_td = data;
11330 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11331 : : struct crypto_unittest_params *ut_params = &unittest_params;
11332 : : uint8_t *plaintext = NULL;
11333 : : uint8_t *ciphertext = NULL;
11334 : : uint8_t *iv_ptr;
11335 : : int32_t cipher_len, crc_len;
11336 : : uint32_t crc_data_len;
11337 : : int ret = TEST_SUCCESS;
11338 : :
11339 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11340 : :
11341 : : /* Verify the capabilities */
11342 : : struct rte_security_capability_idx sec_cap_idx;
11343 : : const struct rte_security_capability *sec_cap;
11344 : : const struct rte_cryptodev_capabilities *crypto_cap;
11345 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11346 : : int j = 0;
11347 : :
11348 : : /* Set action type */
11349 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11350 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11351 : : gbl_action_type;
11352 : :
11353 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11354 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11355 : : return TEST_SKIPPED;
11356 : :
11357 : 0 : sec_cap_idx.action = ut_params->type;
11358 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11359 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11360 : :
11361 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11362 [ # # ]: 0 : if (sec_cap == NULL)
11363 : : return TEST_SKIPPED;
11364 : :
11365 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11366 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11367 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11368 : : crypto_cap->sym.xform_type ==
11369 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11370 : : crypto_cap->sym.cipher.algo ==
11371 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11372 : 0 : sym_cap = &crypto_cap->sym;
11373 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11374 : 0 : d_td->key.len,
11375 : 0 : d_td->iv.len) == 0)
11376 : : break;
11377 : : }
11378 : : }
11379 : :
11380 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11381 : : return TEST_SKIPPED;
11382 : :
11383 : : /* Setup source mbuf payload */
11384 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11385 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11386 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11387 : :
11388 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11389 : 0 : d_td->ciphertext.len);
11390 : :
11391 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11392 : :
11393 : : /* Setup cipher session parameters */
11394 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11395 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11396 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11397 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11398 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11399 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11400 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11401 : 0 : ut_params->cipher_xform.next = NULL;
11402 : :
11403 : : /* Setup DOCSIS session parameters */
11404 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11405 : :
11406 : 0 : struct rte_security_session_conf sess_conf = {
11407 : 0 : .action_type = ut_params->type,
11408 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11409 : : .docsis = ut_params->docsis_xform,
11410 : : .crypto_xform = &ut_params->cipher_xform,
11411 : : };
11412 : :
11413 : : /* Create security session */
11414 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11415 : : ts_params->session_mpool);
11416 : :
11417 [ # # ]: 0 : if (!ut_params->sec_session) {
11418 : : printf("Test function %s line %u: failed to allocate session\n",
11419 : : __func__, __LINE__);
11420 : : ret = TEST_FAILED;
11421 : 0 : goto on_err;
11422 : : }
11423 : :
11424 : : /* Generate crypto op data structure */
11425 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11426 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11427 [ # # ]: 0 : if (!ut_params->op) {
11428 : : printf("Test function %s line %u: failed to allocate symmetric "
11429 : : "crypto operation\n", __func__, __LINE__);
11430 : : ret = TEST_FAILED;
11431 : 0 : goto on_err;
11432 : : }
11433 : :
11434 : : /* Setup CRC operation parameters */
11435 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11436 : 0 : (d_td->ciphertext.len -
11437 : 0 : d_td->ciphertext.crc_offset -
11438 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11439 : : 0;
11440 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11441 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11442 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11443 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11444 : :
11445 : : /* Setup cipher operation parameters */
11446 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11447 : 0 : (d_td->ciphertext.len -
11448 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11449 : : 0;
11450 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11451 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11452 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11453 : :
11454 : : /* Setup cipher IV */
11455 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11456 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11457 : :
11458 : : /* Attach session to operation */
11459 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11460 : :
11461 : : /* Set crypto operation mbufs */
11462 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11463 : 0 : ut_params->op->sym->m_dst = NULL;
11464 : :
11465 : : /* Process crypto operation */
11466 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11467 : : NULL) {
11468 : : printf("Test function %s line %u: failed to process security "
11469 : : "crypto op\n", __func__, __LINE__);
11470 : : ret = TEST_FAILED;
11471 : 0 : goto on_err;
11472 : : }
11473 : :
11474 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11475 : : printf("Test function %s line %u: failed to process crypto op\n",
11476 : : __func__, __LINE__);
11477 : : ret = TEST_FAILED;
11478 : 0 : goto on_err;
11479 : : }
11480 : :
11481 : : /* Validate plaintext */
11482 : : plaintext = ciphertext;
11483 : :
11484 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11485 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11486 : : printf("Test function %s line %u: plaintext not as expected\n",
11487 : : __func__, __LINE__);
11488 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11489 : 0 : d_td->plaintext.len);
11490 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11491 : : ret = TEST_FAILED;
11492 : 0 : goto on_err;
11493 : : }
11494 : :
11495 : 0 : on_err:
11496 : 0 : rte_crypto_op_free(ut_params->op);
11497 : 0 : ut_params->op = NULL;
11498 : :
11499 [ # # ]: 0 : if (ut_params->sec_session)
11500 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11501 : 0 : ut_params->sec_session = NULL;
11502 : :
11503 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11504 : 0 : ut_params->ibuf = NULL;
11505 : :
11506 : 0 : return ret;
11507 : : }
11508 : :
11509 : : static int
11510 : 0 : test_docsis_proto_downlink(const void *data)
11511 : : {
11512 : : const struct docsis_test_data *d_td = data;
11513 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11514 : : struct crypto_unittest_params *ut_params = &unittest_params;
11515 : : uint8_t *plaintext = NULL;
11516 : : uint8_t *ciphertext = NULL;
11517 : : uint8_t *iv_ptr;
11518 : : int32_t cipher_len, crc_len;
11519 : : int ret = TEST_SUCCESS;
11520 : :
11521 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11522 : :
11523 : : /* Verify the capabilities */
11524 : : struct rte_security_capability_idx sec_cap_idx;
11525 : : const struct rte_security_capability *sec_cap;
11526 : : const struct rte_cryptodev_capabilities *crypto_cap;
11527 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11528 : : int j = 0;
11529 : :
11530 : : /* Set action type */
11531 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11532 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11533 : : gbl_action_type;
11534 : :
11535 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11536 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11537 : : return TEST_SKIPPED;
11538 : :
11539 : 0 : sec_cap_idx.action = ut_params->type;
11540 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11541 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11542 : :
11543 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11544 [ # # ]: 0 : if (sec_cap == NULL)
11545 : : return TEST_SKIPPED;
11546 : :
11547 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11548 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11549 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11550 : : crypto_cap->sym.xform_type ==
11551 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11552 : : crypto_cap->sym.cipher.algo ==
11553 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11554 : 0 : sym_cap = &crypto_cap->sym;
11555 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11556 : 0 : d_td->key.len,
11557 : 0 : d_td->iv.len) == 0)
11558 : : break;
11559 : : }
11560 : : }
11561 : :
11562 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11563 : : return TEST_SKIPPED;
11564 : :
11565 : : /* Setup source mbuf payload */
11566 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11567 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11568 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11569 : :
11570 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11571 : 0 : d_td->plaintext.len);
11572 : :
11573 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11574 : :
11575 : : /* Setup cipher session parameters */
11576 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11577 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11578 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11579 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11580 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11581 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11582 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11583 : 0 : ut_params->cipher_xform.next = NULL;
11584 : :
11585 : : /* Setup DOCSIS session parameters */
11586 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11587 : :
11588 : 0 : struct rte_security_session_conf sess_conf = {
11589 : 0 : .action_type = ut_params->type,
11590 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11591 : : .docsis = ut_params->docsis_xform,
11592 : : .crypto_xform = &ut_params->cipher_xform,
11593 : : };
11594 : :
11595 : : /* Create security session */
11596 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11597 : : ts_params->session_mpool);
11598 : :
11599 [ # # ]: 0 : if (!ut_params->sec_session) {
11600 : : printf("Test function %s line %u: failed to allocate session\n",
11601 : : __func__, __LINE__);
11602 : : ret = TEST_FAILED;
11603 : 0 : goto on_err;
11604 : : }
11605 : :
11606 : : /* Generate crypto op data structure */
11607 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11608 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11609 [ # # ]: 0 : if (!ut_params->op) {
11610 : : printf("Test function %s line %u: failed to allocate symmetric "
11611 : : "crypto operation\n", __func__, __LINE__);
11612 : : ret = TEST_FAILED;
11613 : 0 : goto on_err;
11614 : : }
11615 : :
11616 : : /* Setup CRC operation parameters */
11617 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11618 : 0 : (d_td->plaintext.len -
11619 : 0 : d_td->plaintext.crc_offset -
11620 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11621 : : 0;
11622 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11623 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11624 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11625 : :
11626 : : /* Setup cipher operation parameters */
11627 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11628 : 0 : (d_td->plaintext.len -
11629 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11630 : : 0;
11631 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11632 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11633 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11634 : :
11635 : : /* Setup cipher IV */
11636 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11637 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11638 : :
11639 : : /* Attach session to operation */
11640 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11641 : :
11642 : : /* Set crypto operation mbufs */
11643 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11644 : 0 : ut_params->op->sym->m_dst = NULL;
11645 : :
11646 : : /* Process crypto operation */
11647 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11648 : : NULL) {
11649 : : printf("Test function %s line %u: failed to process crypto op\n",
11650 : : __func__, __LINE__);
11651 : : ret = TEST_FAILED;
11652 : 0 : goto on_err;
11653 : : }
11654 : :
11655 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11656 : : printf("Test function %s line %u: crypto op processing failed\n",
11657 : : __func__, __LINE__);
11658 : : ret = TEST_FAILED;
11659 : 0 : goto on_err;
11660 : : }
11661 : :
11662 : : /* Validate ciphertext */
11663 : : ciphertext = plaintext;
11664 : :
11665 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11666 : : printf("Test function %s line %u: plaintext not as expected\n",
11667 : : __func__, __LINE__);
11668 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11669 : 0 : d_td->ciphertext.len);
11670 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11671 : : ret = TEST_FAILED;
11672 : 0 : goto on_err;
11673 : : }
11674 : :
11675 : 0 : on_err:
11676 : 0 : rte_crypto_op_free(ut_params->op);
11677 : 0 : ut_params->op = NULL;
11678 : :
11679 [ # # ]: 0 : if (ut_params->sec_session)
11680 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11681 : 0 : ut_params->sec_session = NULL;
11682 : :
11683 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11684 : 0 : ut_params->ibuf = NULL;
11685 : :
11686 : 0 : return ret;
11687 : : }
11688 : : #endif
11689 : :
11690 : : static int
11691 : 0 : test_AES_GCM_authenticated_encryption_test_case_1(void)
11692 : : {
11693 : 0 : return test_authenticated_encryption(&gcm_test_case_1);
11694 : : }
11695 : :
11696 : : static int
11697 : 0 : test_AES_GCM_authenticated_encryption_test_case_2(void)
11698 : : {
11699 : 0 : return test_authenticated_encryption(&gcm_test_case_2);
11700 : : }
11701 : :
11702 : : static int
11703 : 0 : test_AES_GCM_authenticated_encryption_test_case_3(void)
11704 : : {
11705 : 0 : return test_authenticated_encryption(&gcm_test_case_3);
11706 : : }
11707 : :
11708 : : static int
11709 : 0 : test_AES_GCM_authenticated_encryption_test_case_4(void)
11710 : : {
11711 : 0 : return test_authenticated_encryption(&gcm_test_case_4);
11712 : : }
11713 : :
11714 : : static int
11715 : 0 : test_AES_GCM_authenticated_encryption_test_case_5(void)
11716 : : {
11717 : 0 : return test_authenticated_encryption(&gcm_test_case_5);
11718 : : }
11719 : :
11720 : : static int
11721 : 0 : test_AES_GCM_authenticated_encryption_test_case_6(void)
11722 : : {
11723 : 0 : return test_authenticated_encryption(&gcm_test_case_6);
11724 : : }
11725 : :
11726 : : static int
11727 : 0 : test_AES_GCM_authenticated_encryption_test_case_7(void)
11728 : : {
11729 : 0 : return test_authenticated_encryption(&gcm_test_case_7);
11730 : : }
11731 : :
11732 : : static int
11733 : 0 : test_AES_GCM_authenticated_encryption_test_case_8(void)
11734 : : {
11735 : 0 : return test_authenticated_encryption(&gcm_test_case_8);
11736 : : }
11737 : :
11738 : : static int
11739 : 0 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
11740 : : {
11741 : 0 : return test_authenticated_encryption(&gcm_J0_test_case_1);
11742 : : }
11743 : :
11744 : : static int
11745 : 0 : test_AES_GCM_auth_encryption_test_case_192_1(void)
11746 : : {
11747 : 0 : return test_authenticated_encryption(&gcm_test_case_192_1);
11748 : : }
11749 : :
11750 : : static int
11751 : 0 : test_AES_GCM_auth_encryption_test_case_192_2(void)
11752 : : {
11753 : 0 : return test_authenticated_encryption(&gcm_test_case_192_2);
11754 : : }
11755 : :
11756 : : static int
11757 : 0 : test_AES_GCM_auth_encryption_test_case_192_3(void)
11758 : : {
11759 : 0 : return test_authenticated_encryption(&gcm_test_case_192_3);
11760 : : }
11761 : :
11762 : : static int
11763 : 0 : test_AES_GCM_auth_encryption_test_case_192_4(void)
11764 : : {
11765 : 0 : return test_authenticated_encryption(&gcm_test_case_192_4);
11766 : : }
11767 : :
11768 : : static int
11769 : 0 : test_AES_GCM_auth_encryption_test_case_192_5(void)
11770 : : {
11771 : 0 : return test_authenticated_encryption(&gcm_test_case_192_5);
11772 : : }
11773 : :
11774 : : static int
11775 : 0 : test_AES_GCM_auth_encryption_test_case_192_6(void)
11776 : : {
11777 : 0 : return test_authenticated_encryption(&gcm_test_case_192_6);
11778 : : }
11779 : :
11780 : : static int
11781 : 0 : test_AES_GCM_auth_encryption_test_case_192_7(void)
11782 : : {
11783 : 0 : return test_authenticated_encryption(&gcm_test_case_192_7);
11784 : : }
11785 : :
11786 : : static int
11787 : 0 : test_AES_GCM_auth_encryption_test_case_256_1(void)
11788 : : {
11789 : 0 : return test_authenticated_encryption(&gcm_test_case_256_1);
11790 : : }
11791 : :
11792 : : static int
11793 : 0 : test_AES_GCM_auth_encryption_test_case_256_2(void)
11794 : : {
11795 : 0 : return test_authenticated_encryption(&gcm_test_case_256_2);
11796 : : }
11797 : :
11798 : : static int
11799 : 0 : test_AES_GCM_auth_encryption_test_case_256_3(void)
11800 : : {
11801 : 0 : return test_authenticated_encryption(&gcm_test_case_256_3);
11802 : : }
11803 : :
11804 : : static int
11805 : 0 : test_AES_GCM_auth_encryption_test_case_256_4(void)
11806 : : {
11807 : 0 : return test_authenticated_encryption(&gcm_test_case_256_4);
11808 : : }
11809 : :
11810 : : static int
11811 : 0 : test_AES_GCM_auth_encryption_test_case_256_5(void)
11812 : : {
11813 : 0 : return test_authenticated_encryption(&gcm_test_case_256_5);
11814 : : }
11815 : :
11816 : : static int
11817 : 0 : test_AES_GCM_auth_encryption_test_case_256_6(void)
11818 : : {
11819 : 0 : return test_authenticated_encryption(&gcm_test_case_256_6);
11820 : : }
11821 : :
11822 : : static int
11823 : 0 : test_AES_GCM_auth_encryption_test_case_256_7(void)
11824 : : {
11825 : 0 : return test_authenticated_encryption(&gcm_test_case_256_7);
11826 : : }
11827 : :
11828 : : static int
11829 : 0 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
11830 : : {
11831 : 0 : return test_authenticated_encryption(&gcm_test_case_aad_1);
11832 : : }
11833 : :
11834 : : static int
11835 : 0 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
11836 : : {
11837 : 0 : return test_authenticated_encryption(&gcm_test_case_aad_2);
11838 : : }
11839 : :
11840 : : static int
11841 : 0 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
11842 : : {
11843 : : struct aead_test_data tdata;
11844 : : int res;
11845 : :
11846 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11847 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11848 : 0 : tdata.iv.data[0] += 1;
11849 : 0 : res = test_authenticated_encryption(&tdata);
11850 [ # # ]: 0 : if (res == TEST_SKIPPED)
11851 : : return res;
11852 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11853 : : return TEST_SUCCESS;
11854 : : }
11855 : :
11856 : : static int
11857 : 0 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
11858 : : {
11859 : : struct aead_test_data tdata;
11860 : : int res;
11861 : :
11862 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11863 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11864 : 0 : tdata.plaintext.data[0] += 1;
11865 : 0 : res = test_authenticated_encryption(&tdata);
11866 [ # # ]: 0 : if (res == TEST_SKIPPED)
11867 : : return res;
11868 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11869 : : return TEST_SUCCESS;
11870 : : }
11871 : :
11872 : : static int
11873 : 0 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
11874 : : {
11875 : : struct aead_test_data tdata;
11876 : : int res;
11877 : :
11878 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11879 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11880 : 0 : tdata.ciphertext.data[0] += 1;
11881 : 0 : res = test_authenticated_encryption(&tdata);
11882 [ # # ]: 0 : if (res == TEST_SKIPPED)
11883 : : return res;
11884 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11885 : : return TEST_SUCCESS;
11886 : : }
11887 : :
11888 : : static int
11889 : 0 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
11890 : : {
11891 : : struct aead_test_data tdata;
11892 : : int res;
11893 : :
11894 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11895 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11896 : 0 : tdata.aad.len += 1;
11897 : 0 : res = test_authenticated_encryption(&tdata);
11898 [ # # ]: 0 : if (res == TEST_SKIPPED)
11899 : : return res;
11900 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11901 : : return TEST_SUCCESS;
11902 : : }
11903 : :
11904 : : static int
11905 : 0 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
11906 : 0 : {
11907 : : struct aead_test_data tdata;
11908 : : uint8_t aad[gcm_test_case_7.aad.len];
11909 : : int res;
11910 : :
11911 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11912 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11913 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
11914 : 0 : aad[0] += 1;
11915 : 0 : tdata.aad.data = aad;
11916 : 0 : res = test_authenticated_encryption(&tdata);
11917 [ # # ]: 0 : if (res == TEST_SKIPPED)
11918 : : return res;
11919 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11920 : : return TEST_SUCCESS;
11921 : : }
11922 : :
11923 : : static int
11924 : 0 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
11925 : : {
11926 : : struct aead_test_data tdata;
11927 : : int res;
11928 : :
11929 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11930 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11931 : 0 : tdata.auth_tag.data[0] += 1;
11932 : 0 : res = test_authenticated_encryption(&tdata);
11933 [ # # ]: 0 : if (res == TEST_SKIPPED)
11934 : : return res;
11935 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11936 : : return TEST_SUCCESS;
11937 : : }
11938 : :
11939 : : static int
11940 : 0 : test_authenticated_decryption(const struct aead_test_data *tdata)
11941 : : {
11942 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11943 : : struct crypto_unittest_params *ut_params = &unittest_params;
11944 : :
11945 : : int retval;
11946 : : uint8_t *plaintext;
11947 : : uint32_t i;
11948 : : struct rte_cryptodev_info dev_info;
11949 : :
11950 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11951 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11952 : :
11953 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11954 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11955 : : printf("Device doesn't support RAW data-path APIs.\n");
11956 : 0 : return TEST_SKIPPED;
11957 : : }
11958 : :
11959 : : /* Verify the capabilities */
11960 : : struct rte_cryptodev_sym_capability_idx cap_idx;
11961 : : const struct rte_cryptodev_symmetric_capability *capability;
11962 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11963 : 0 : cap_idx.algo.aead = tdata->algo;
11964 : 0 : capability = rte_cryptodev_sym_capability_get(
11965 : 0 : ts_params->valid_devs[0], &cap_idx);
11966 [ # # ]: 0 : if (capability == NULL)
11967 : : return TEST_SKIPPED;
11968 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_aead(
11969 : 0 : capability, tdata->key.len, tdata->auth_tag.len,
11970 : 0 : tdata->aad.len, tdata->iv.len))
11971 : : return TEST_SKIPPED;
11972 : :
11973 : : /* Create AEAD session */
11974 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
11975 : 0 : tdata->algo,
11976 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
11977 : 0 : tdata->key.data, tdata->key.len,
11978 : 0 : tdata->aad.len, tdata->auth_tag.len,
11979 : 0 : tdata->iv.len);
11980 [ # # ]: 0 : if (retval != TEST_SUCCESS)
11981 : : return retval;
11982 : :
11983 : : /* alloc mbuf and set payload */
11984 [ # # ]: 0 : if (tdata->aad.len > MBUF_SIZE) {
11985 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11986 : : /* Populate full size of add data */
11987 [ # # ]: 0 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
11988 : 0 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
11989 : : } else
11990 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11991 : :
11992 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11993 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
11994 : :
11995 : : /* Create AEAD operation */
11996 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11997 [ # # ]: 0 : if (retval < 0)
11998 : : return retval;
11999 : :
12000 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12001 : :
12002 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12003 : :
12004 : : /* Process crypto operation */
12005 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12006 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12007 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12008 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12009 : : 0);
12010 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12011 : : return retval;
12012 : : } else
12013 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
12014 : : process_crypto_request(ts_params->valid_devs[0],
12015 : : ut_params->op), "failed to process sym crypto op");
12016 : :
12017 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12018 : : "crypto op processing failed");
12019 : :
12020 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
12021 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
12022 : : uint8_t *);
12023 : : else
12024 : 0 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12025 : : uint8_t *,
12026 : : ut_params->op->sym->cipher.data.offset);
12027 : :
12028 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12029 : :
12030 : : /* Validate obuf */
12031 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12032 : : plaintext,
12033 : : tdata->plaintext.data,
12034 : : tdata->plaintext.len,
12035 : : "Plaintext data not as expected");
12036 : :
12037 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
12038 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12039 : : "Authentication failed");
12040 : :
12041 : : return 0;
12042 : : }
12043 : :
12044 : : static int
12045 : 0 : test_AES_GCM_authenticated_decryption_test_case_1(void)
12046 : : {
12047 : 0 : return test_authenticated_decryption(&gcm_test_case_1);
12048 : : }
12049 : :
12050 : : static int
12051 : 0 : test_AES_GCM_authenticated_decryption_test_case_2(void)
12052 : : {
12053 : 0 : return test_authenticated_decryption(&gcm_test_case_2);
12054 : : }
12055 : :
12056 : : static int
12057 : 0 : test_AES_GCM_authenticated_decryption_test_case_3(void)
12058 : : {
12059 : 0 : return test_authenticated_decryption(&gcm_test_case_3);
12060 : : }
12061 : :
12062 : : static int
12063 : 0 : test_AES_GCM_authenticated_decryption_test_case_4(void)
12064 : : {
12065 : 0 : return test_authenticated_decryption(&gcm_test_case_4);
12066 : : }
12067 : :
12068 : : static int
12069 : 0 : test_AES_GCM_authenticated_decryption_test_case_5(void)
12070 : : {
12071 : 0 : return test_authenticated_decryption(&gcm_test_case_5);
12072 : : }
12073 : :
12074 : : static int
12075 : 0 : test_AES_GCM_authenticated_decryption_test_case_6(void)
12076 : : {
12077 : 0 : return test_authenticated_decryption(&gcm_test_case_6);
12078 : : }
12079 : :
12080 : : static int
12081 : 0 : test_AES_GCM_authenticated_decryption_test_case_7(void)
12082 : : {
12083 : 0 : return test_authenticated_decryption(&gcm_test_case_7);
12084 : : }
12085 : :
12086 : : static int
12087 : 0 : test_AES_GCM_authenticated_decryption_test_case_8(void)
12088 : : {
12089 : 0 : return test_authenticated_decryption(&gcm_test_case_8);
12090 : : }
12091 : :
12092 : : static int
12093 : 0 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
12094 : : {
12095 : 0 : return test_authenticated_decryption(&gcm_J0_test_case_1);
12096 : : }
12097 : :
12098 : : static int
12099 : 0 : test_AES_GCM_auth_decryption_test_case_192_1(void)
12100 : : {
12101 : 0 : return test_authenticated_decryption(&gcm_test_case_192_1);
12102 : : }
12103 : :
12104 : : static int
12105 : 0 : test_AES_GCM_auth_decryption_test_case_192_2(void)
12106 : : {
12107 : 0 : return test_authenticated_decryption(&gcm_test_case_192_2);
12108 : : }
12109 : :
12110 : : static int
12111 : 0 : test_AES_GCM_auth_decryption_test_case_192_3(void)
12112 : : {
12113 : 0 : return test_authenticated_decryption(&gcm_test_case_192_3);
12114 : : }
12115 : :
12116 : : static int
12117 : 0 : test_AES_GCM_auth_decryption_test_case_192_4(void)
12118 : : {
12119 : 0 : return test_authenticated_decryption(&gcm_test_case_192_4);
12120 : : }
12121 : :
12122 : : static int
12123 : 0 : test_AES_GCM_auth_decryption_test_case_192_5(void)
12124 : : {
12125 : 0 : return test_authenticated_decryption(&gcm_test_case_192_5);
12126 : : }
12127 : :
12128 : : static int
12129 : 0 : test_AES_GCM_auth_decryption_test_case_192_6(void)
12130 : : {
12131 : 0 : return test_authenticated_decryption(&gcm_test_case_192_6);
12132 : : }
12133 : :
12134 : : static int
12135 : 0 : test_AES_GCM_auth_decryption_test_case_192_7(void)
12136 : : {
12137 : 0 : return test_authenticated_decryption(&gcm_test_case_192_7);
12138 : : }
12139 : :
12140 : : static int
12141 : 0 : test_AES_GCM_auth_decryption_test_case_256_1(void)
12142 : : {
12143 : 0 : return test_authenticated_decryption(&gcm_test_case_256_1);
12144 : : }
12145 : :
12146 : : static int
12147 : 0 : test_AES_GCM_auth_decryption_test_case_256_2(void)
12148 : : {
12149 : 0 : return test_authenticated_decryption(&gcm_test_case_256_2);
12150 : : }
12151 : :
12152 : : static int
12153 : 0 : test_AES_GCM_auth_decryption_test_case_256_3(void)
12154 : : {
12155 : 0 : return test_authenticated_decryption(&gcm_test_case_256_3);
12156 : : }
12157 : :
12158 : : static int
12159 : 0 : test_AES_GCM_auth_decryption_test_case_256_4(void)
12160 : : {
12161 : 0 : return test_authenticated_decryption(&gcm_test_case_256_4);
12162 : : }
12163 : :
12164 : : static int
12165 : 0 : test_AES_GCM_auth_decryption_test_case_256_5(void)
12166 : : {
12167 : 0 : return test_authenticated_decryption(&gcm_test_case_256_5);
12168 : : }
12169 : :
12170 : : static int
12171 : 0 : test_AES_GCM_auth_decryption_test_case_256_6(void)
12172 : : {
12173 : 0 : return test_authenticated_decryption(&gcm_test_case_256_6);
12174 : : }
12175 : :
12176 : : static int
12177 : 0 : test_AES_GCM_auth_decryption_test_case_256_7(void)
12178 : : {
12179 : 0 : return test_authenticated_decryption(&gcm_test_case_256_7);
12180 : : }
12181 : :
12182 : : static int
12183 : 0 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
12184 : : {
12185 : 0 : return test_authenticated_decryption(&gcm_test_case_aad_1);
12186 : : }
12187 : :
12188 : : static int
12189 : 0 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
12190 : : {
12191 : 0 : return test_authenticated_decryption(&gcm_test_case_aad_2);
12192 : : }
12193 : :
12194 : : static int
12195 : 0 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
12196 : : {
12197 : : struct aead_test_data tdata;
12198 : : int res;
12199 : :
12200 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12201 : 0 : tdata.iv.data[0] += 1;
12202 : 0 : res = test_authenticated_decryption(&tdata);
12203 [ # # ]: 0 : if (res == TEST_SKIPPED)
12204 : : return res;
12205 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12206 : : return TEST_SUCCESS;
12207 : : }
12208 : :
12209 : : static int
12210 : 0 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
12211 : : {
12212 : : struct aead_test_data tdata;
12213 : : int res;
12214 : :
12215 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12216 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12217 : 0 : tdata.plaintext.data[0] += 1;
12218 : 0 : res = test_authenticated_decryption(&tdata);
12219 [ # # ]: 0 : if (res == TEST_SKIPPED)
12220 : : return res;
12221 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12222 : : return TEST_SUCCESS;
12223 : : }
12224 : :
12225 : : static int
12226 : 0 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
12227 : : {
12228 : : struct aead_test_data tdata;
12229 : : int res;
12230 : :
12231 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12232 : 0 : tdata.ciphertext.data[0] += 1;
12233 : 0 : res = test_authenticated_decryption(&tdata);
12234 [ # # ]: 0 : if (res == TEST_SKIPPED)
12235 : : return res;
12236 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12237 : : return TEST_SUCCESS;
12238 : : }
12239 : :
12240 : : static int
12241 : 0 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
12242 : : {
12243 : : struct aead_test_data tdata;
12244 : : int res;
12245 : :
12246 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12247 : 0 : tdata.aad.len += 1;
12248 : 0 : res = test_authenticated_decryption(&tdata);
12249 [ # # ]: 0 : if (res == TEST_SKIPPED)
12250 : : return res;
12251 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12252 : : return TEST_SUCCESS;
12253 : : }
12254 : :
12255 : : static int
12256 : 0 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
12257 : 0 : {
12258 : : struct aead_test_data tdata;
12259 : : uint8_t aad[gcm_test_case_7.aad.len];
12260 : : int res;
12261 : :
12262 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12263 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12264 : 0 : aad[0] += 1;
12265 : 0 : tdata.aad.data = aad;
12266 : 0 : res = test_authenticated_decryption(&tdata);
12267 [ # # ]: 0 : if (res == TEST_SKIPPED)
12268 : : return res;
12269 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12270 : : return TEST_SUCCESS;
12271 : : }
12272 : :
12273 : : static int
12274 : 0 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
12275 : : {
12276 : : struct aead_test_data tdata;
12277 : : int res;
12278 : :
12279 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12280 : 0 : tdata.auth_tag.data[0] += 1;
12281 : 0 : res = test_authenticated_decryption(&tdata);
12282 [ # # ]: 0 : if (res == TEST_SKIPPED)
12283 : : return res;
12284 [ # # ]: 0 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
12285 : : return TEST_SUCCESS;
12286 : : }
12287 : :
12288 : : static int
12289 : 0 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
12290 : : {
12291 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12292 : : struct crypto_unittest_params *ut_params = &unittest_params;
12293 : :
12294 : : int retval;
12295 : : uint8_t *ciphertext, *auth_tag;
12296 : : uint16_t plaintext_pad_len;
12297 : : struct rte_cryptodev_info dev_info;
12298 : :
12299 : : /* Verify the capabilities */
12300 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12301 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12302 : 0 : cap_idx.algo.aead = tdata->algo;
12303 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12304 : : &cap_idx) == NULL)
12305 : : return TEST_SKIPPED;
12306 : :
12307 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12308 : 0 : uint64_t feat_flags = dev_info.feature_flags;
12309 : :
12310 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12311 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
12312 : : return TEST_SKIPPED;
12313 : :
12314 : : /* not supported with CPU crypto */
12315 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12316 : : return TEST_SKIPPED;
12317 : :
12318 : : /* Create AEAD session */
12319 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
12320 : 0 : tdata->algo,
12321 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
12322 : 0 : tdata->key.data, tdata->key.len,
12323 : 0 : tdata->aad.len, tdata->auth_tag.len,
12324 : 0 : tdata->iv.len);
12325 [ # # ]: 0 : if (retval < 0)
12326 : : return retval;
12327 : :
12328 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12329 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12330 : :
12331 : : /* clear mbuf payload */
12332 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12333 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
12334 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12335 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
12336 : :
12337 : : /* Create AEAD operation */
12338 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12339 [ # # ]: 0 : if (retval < 0)
12340 : : return retval;
12341 : :
12342 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12343 : :
12344 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12345 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12346 : :
12347 : : /* Process crypto operation */
12348 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12349 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12350 : : 0);
12351 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12352 : : return retval;
12353 : : } else
12354 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12355 : : ut_params->op), "failed to process sym crypto op");
12356 : :
12357 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12358 : : "crypto op processing failed");
12359 : :
12360 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12361 : :
12362 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12363 : : ut_params->op->sym->cipher.data.offset);
12364 : 0 : auth_tag = ciphertext + plaintext_pad_len;
12365 : :
12366 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12367 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12368 : :
12369 : : /* Validate obuf */
12370 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12371 : : ciphertext,
12372 : : tdata->ciphertext.data,
12373 : : tdata->ciphertext.len,
12374 : : "Ciphertext data not as expected");
12375 : :
12376 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12377 : : auth_tag,
12378 : : tdata->auth_tag.data,
12379 : : tdata->auth_tag.len,
12380 : : "Generated auth tag not as expected");
12381 : :
12382 : : return 0;
12383 : :
12384 : : }
12385 : :
12386 : : static int
12387 : 0 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
12388 : : {
12389 : 0 : return test_authenticated_encryption_oop(&gcm_test_case_5);
12390 : : }
12391 : :
12392 : : static int
12393 : 0 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
12394 : : {
12395 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12396 : : struct crypto_unittest_params *ut_params = &unittest_params;
12397 : :
12398 : : int retval;
12399 : : uint8_t *plaintext;
12400 : : struct rte_cryptodev_info dev_info;
12401 : :
12402 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12403 : : uint64_t feat_flags = dev_info.feature_flags;
12404 : :
12405 : : /* Verify the capabilities */
12406 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12407 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12408 : 0 : cap_idx.algo.aead = tdata->algo;
12409 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12410 : : &cap_idx) == NULL)
12411 : : return TEST_SKIPPED;
12412 : :
12413 : : /* not supported with CPU crypto and raw data-path APIs*/
12414 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
12415 [ # # ]: 0 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
12416 : : return TEST_SKIPPED;
12417 : :
12418 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12419 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12420 : : printf("Device does not support RAW data-path APIs.\n");
12421 : : return TEST_SKIPPED;
12422 : : }
12423 : :
12424 : : /* Create AEAD session */
12425 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
12426 : 0 : tdata->algo,
12427 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12428 : 0 : tdata->key.data, tdata->key.len,
12429 : 0 : tdata->aad.len, tdata->auth_tag.len,
12430 : 0 : tdata->iv.len);
12431 [ # # ]: 0 : if (retval < 0)
12432 : : return retval;
12433 : :
12434 : : /* alloc mbuf and set payload */
12435 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12436 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12437 : :
12438 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12439 : 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
12440 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12441 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
12442 : :
12443 : : /* Create AEAD operation */
12444 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12445 [ # # ]: 0 : if (retval < 0)
12446 : : return retval;
12447 : :
12448 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12449 : :
12450 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12451 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
12452 : :
12453 : : /* Process crypto operation */
12454 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12455 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12456 : : 0);
12457 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12458 : : return retval;
12459 : : } else
12460 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12461 : : ut_params->op), "failed to process sym crypto op");
12462 : :
12463 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12464 : : "crypto op processing failed");
12465 : :
12466 : 0 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12467 : : ut_params->op->sym->cipher.data.offset);
12468 : :
12469 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12470 : :
12471 : : /* Validate obuf */
12472 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12473 : : plaintext,
12474 : : tdata->plaintext.data,
12475 : : tdata->plaintext.len,
12476 : : "Plaintext data not as expected");
12477 : :
12478 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
12479 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12480 : : "Authentication failed");
12481 : : return 0;
12482 : : }
12483 : :
12484 : : static int
12485 : 0 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
12486 : : {
12487 : 0 : return test_authenticated_decryption_oop(&gcm_test_case_5);
12488 : : }
12489 : :
12490 : : static int
12491 : 0 : test_authenticated_encryption_sessionless(
12492 : : const struct aead_test_data *tdata)
12493 : 0 : {
12494 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12495 : : struct crypto_unittest_params *ut_params = &unittest_params;
12496 : :
12497 : : int retval;
12498 : : uint8_t *ciphertext, *auth_tag;
12499 : : uint16_t plaintext_pad_len;
12500 : 0 : uint8_t key[tdata->key.len + 1];
12501 : : struct rte_cryptodev_info dev_info;
12502 : :
12503 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12504 : 0 : uint64_t feat_flags = dev_info.feature_flags;
12505 : :
12506 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12507 : : printf("Device doesn't support Sessionless ops.\n");
12508 : 0 : return TEST_SKIPPED;
12509 : : }
12510 : :
12511 : : /* not supported with CPU crypto */
12512 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12513 : : return TEST_SKIPPED;
12514 : :
12515 : : /* Verify the capabilities */
12516 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12517 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12518 : 0 : cap_idx.algo.aead = tdata->algo;
12519 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12520 : : &cap_idx) == NULL)
12521 : : return TEST_SKIPPED;
12522 : :
12523 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12524 : :
12525 : : /* clear mbuf payload */
12526 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12527 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12528 : :
12529 : : /* Create AEAD operation */
12530 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12531 [ # # ]: 0 : if (retval < 0)
12532 : : return retval;
12533 : :
12534 : : /* Create GCM xform */
12535 : 0 : memcpy(key, tdata->key.data, tdata->key.len);
12536 : 0 : retval = create_aead_xform(ut_params->op,
12537 : 0 : tdata->algo,
12538 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
12539 : : key, tdata->key.len,
12540 : 0 : tdata->aad.len, tdata->auth_tag.len,
12541 : 0 : tdata->iv.len);
12542 [ # # ]: 0 : if (retval < 0)
12543 : : return retval;
12544 : :
12545 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12546 : :
12547 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12548 : : RTE_CRYPTO_OP_SESSIONLESS,
12549 : : "crypto op session type not sessionless");
12550 : :
12551 : : /* Process crypto operation */
12552 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12553 : : ut_params->op), "failed to process sym crypto op");
12554 : :
12555 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12556 : :
12557 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12558 : : "crypto op status not success");
12559 : :
12560 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12561 : :
12562 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12563 : : ut_params->op->sym->cipher.data.offset);
12564 : 0 : auth_tag = ciphertext + plaintext_pad_len;
12565 : :
12566 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12567 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12568 : :
12569 : : /* Validate obuf */
12570 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12571 : : ciphertext,
12572 : : tdata->ciphertext.data,
12573 : : tdata->ciphertext.len,
12574 : : "Ciphertext data not as expected");
12575 : :
12576 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12577 : : auth_tag,
12578 : : tdata->auth_tag.data,
12579 : : tdata->auth_tag.len,
12580 : : "Generated auth tag not as expected");
12581 : :
12582 : : return 0;
12583 : :
12584 : : }
12585 : :
12586 : : static int
12587 : 0 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
12588 : : {
12589 : 0 : return test_authenticated_encryption_sessionless(
12590 : : &gcm_test_case_5);
12591 : : }
12592 : :
12593 : : static int
12594 : 0 : test_authenticated_decryption_sessionless(
12595 : : const struct aead_test_data *tdata)
12596 : 0 : {
12597 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12598 : : struct crypto_unittest_params *ut_params = &unittest_params;
12599 : :
12600 : : int retval;
12601 : : uint8_t *plaintext;
12602 : 0 : uint8_t key[tdata->key.len + 1];
12603 : : struct rte_cryptodev_info dev_info;
12604 : :
12605 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12606 : 0 : uint64_t feat_flags = dev_info.feature_flags;
12607 : :
12608 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12609 : : printf("Device doesn't support Sessionless ops.\n");
12610 : 0 : return TEST_SKIPPED;
12611 : : }
12612 : :
12613 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12614 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12615 : : printf("Device doesn't support RAW data-path APIs.\n");
12616 : 0 : return TEST_SKIPPED;
12617 : : }
12618 : :
12619 : : /* not supported with CPU crypto */
12620 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12621 : : return TEST_SKIPPED;
12622 : :
12623 : : /* Verify the capabilities */
12624 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12625 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12626 : 0 : cap_idx.algo.aead = tdata->algo;
12627 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12628 : : &cap_idx) == NULL)
12629 : : return TEST_SKIPPED;
12630 : :
12631 : : /* alloc mbuf and set payload */
12632 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12633 : :
12634 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12635 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12636 : :
12637 : : /* Create AEAD operation */
12638 : 0 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12639 [ # # ]: 0 : if (retval < 0)
12640 : : return retval;
12641 : :
12642 : : /* Create AEAD xform */
12643 : 0 : memcpy(key, tdata->key.data, tdata->key.len);
12644 : 0 : retval = create_aead_xform(ut_params->op,
12645 : 0 : tdata->algo,
12646 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12647 : : key, tdata->key.len,
12648 : 0 : tdata->aad.len, tdata->auth_tag.len,
12649 : 0 : tdata->iv.len);
12650 [ # # ]: 0 : if (retval < 0)
12651 : : return retval;
12652 : :
12653 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
12654 : :
12655 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12656 : : RTE_CRYPTO_OP_SESSIONLESS,
12657 : : "crypto op session type not sessionless");
12658 : :
12659 : : /* Process crypto operation */
12660 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12661 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12662 : : 0);
12663 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12664 : : return retval;
12665 : : } else
12666 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(process_crypto_request(
12667 : : ts_params->valid_devs[0], ut_params->op),
12668 : : "failed to process sym crypto op");
12669 : :
12670 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12671 : :
12672 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12673 : : "crypto op status not success");
12674 : :
12675 : 0 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12676 : : ut_params->op->sym->cipher.data.offset);
12677 : :
12678 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12679 : :
12680 : : /* Validate obuf */
12681 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12682 : : plaintext,
12683 : : tdata->plaintext.data,
12684 : : tdata->plaintext.len,
12685 : : "Plaintext data not as expected");
12686 : :
12687 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
12688 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12689 : : "Authentication failed");
12690 : : return 0;
12691 : : }
12692 : :
12693 : : static int
12694 : 0 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
12695 : : {
12696 : 0 : return test_authenticated_decryption_sessionless(
12697 : : &gcm_test_case_5);
12698 : : }
12699 : :
12700 : : static int
12701 : 0 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
12702 : : {
12703 : 0 : return test_authenticated_encryption(&ccm_test_case_128_1);
12704 : : }
12705 : :
12706 : : static int
12707 : 0 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
12708 : : {
12709 : 0 : return test_authenticated_encryption(&ccm_test_case_128_2);
12710 : : }
12711 : :
12712 : : static int
12713 : 0 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
12714 : : {
12715 : 0 : return test_authenticated_encryption(&ccm_test_case_128_3);
12716 : : }
12717 : :
12718 : : static int
12719 : 0 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
12720 : : {
12721 : 0 : return test_authenticated_decryption(&ccm_test_case_128_1);
12722 : : }
12723 : :
12724 : : static int
12725 : 0 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
12726 : : {
12727 : 0 : return test_authenticated_decryption(&ccm_test_case_128_2);
12728 : : }
12729 : :
12730 : : static int
12731 : 0 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
12732 : : {
12733 : 0 : return test_authenticated_decryption(&ccm_test_case_128_3);
12734 : : }
12735 : :
12736 : : static int
12737 : 0 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
12738 : : {
12739 : 0 : return test_authenticated_encryption(&ccm_test_case_192_1);
12740 : : }
12741 : :
12742 : : static int
12743 : 0 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
12744 : : {
12745 : 0 : return test_authenticated_encryption(&ccm_test_case_192_2);
12746 : : }
12747 : :
12748 : : static int
12749 : 0 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
12750 : : {
12751 : 0 : return test_authenticated_encryption(&ccm_test_case_192_3);
12752 : : }
12753 : :
12754 : : static int
12755 : 0 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
12756 : : {
12757 : 0 : return test_authenticated_decryption(&ccm_test_case_192_1);
12758 : : }
12759 : :
12760 : : static int
12761 : 0 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
12762 : : {
12763 : 0 : return test_authenticated_decryption(&ccm_test_case_192_2);
12764 : : }
12765 : :
12766 : : static int
12767 : 0 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
12768 : : {
12769 : 0 : return test_authenticated_decryption(&ccm_test_case_192_3);
12770 : : }
12771 : :
12772 : : static int
12773 : 0 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
12774 : : {
12775 : 0 : return test_authenticated_encryption(&ccm_test_case_256_1);
12776 : : }
12777 : :
12778 : : static int
12779 : 0 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
12780 : : {
12781 : 0 : return test_authenticated_encryption(&ccm_test_case_256_2);
12782 : : }
12783 : :
12784 : : static int
12785 : 0 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
12786 : : {
12787 : 0 : return test_authenticated_encryption(&ccm_test_case_256_3);
12788 : : }
12789 : :
12790 : : static int
12791 : 0 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
12792 : : {
12793 : 0 : return test_authenticated_decryption(&ccm_test_case_256_1);
12794 : : }
12795 : :
12796 : : static int
12797 : 0 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
12798 : : {
12799 : 0 : return test_authenticated_decryption(&ccm_test_case_256_2);
12800 : : }
12801 : :
12802 : : static int
12803 : 0 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
12804 : : {
12805 : 0 : return test_authenticated_decryption(&ccm_test_case_256_3);
12806 : : }
12807 : :
12808 : : static int
12809 : 0 : test_stats(void)
12810 : : {
12811 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12812 : : struct rte_cryptodev_stats stats;
12813 : :
12814 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12815 : : return TEST_SKIPPED;
12816 : :
12817 : : /* Verify the capabilities */
12818 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12819 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12820 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
12821 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12822 : : &cap_idx) == NULL)
12823 : : return TEST_SKIPPED;
12824 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12825 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12826 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12827 : : &cap_idx) == NULL)
12828 : : return TEST_SKIPPED;
12829 : :
12830 [ # # ]: 0 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
12831 : : == -ENOTSUP)
12832 : : return TEST_SKIPPED;
12833 : :
12834 : 0 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
12835 [ # # ]: 0 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
12836 : : &stats) == -ENODEV),
12837 : : "rte_cryptodev_stats_get invalid dev failed");
12838 [ # # ]: 0 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
12839 : : "rte_cryptodev_stats_get invalid Param failed");
12840 : :
12841 : : /* Test expected values */
12842 : 0 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
12843 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12844 : : &stats),
12845 : : "rte_cryptodev_stats_get failed");
12846 [ # # ]: 0 : TEST_ASSERT((stats.enqueued_count == 1),
12847 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
12848 [ # # ]: 0 : TEST_ASSERT((stats.dequeued_count == 1),
12849 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
12850 [ # # ]: 0 : TEST_ASSERT((stats.enqueue_err_count == 0),
12851 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
12852 [ # # ]: 0 : TEST_ASSERT((stats.dequeue_err_count == 0),
12853 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
12854 : :
12855 : : /* invalid device but should ignore and not reset device stats*/
12856 : 0 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
12857 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12858 : : &stats),
12859 : : "rte_cryptodev_stats_get failed");
12860 [ # # ]: 0 : TEST_ASSERT((stats.enqueued_count == 1),
12861 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
12862 : :
12863 : : /* check that a valid reset clears stats */
12864 : 0 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
12865 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12866 : : &stats),
12867 : : "rte_cryptodev_stats_get failed");
12868 [ # # ]: 0 : TEST_ASSERT((stats.enqueued_count == 0),
12869 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
12870 [ # # ]: 0 : TEST_ASSERT((stats.dequeued_count == 0),
12871 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
12872 : :
12873 : : return TEST_SUCCESS;
12874 : : }
12875 : :
12876 : : static int
12877 : 0 : test_device_reconfigure(void)
12878 : : {
12879 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12880 : 0 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
12881 : 0 : struct rte_cryptodev_qp_conf qp_conf = {
12882 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
12883 : 0 : .mp_session = ts_params->session_mpool
12884 : : };
12885 : : uint16_t qp_id, dev_id, num_devs = 0;
12886 : :
12887 [ # # ]: 0 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
12888 : : "Need at least %d devices for test", 1);
12889 : :
12890 : 0 : dev_id = ts_params->valid_devs[0];
12891 : :
12892 : : /* Stop the device in case it's started so it can be configured */
12893 : 0 : rte_cryptodev_stop(dev_id);
12894 : :
12895 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
12896 : : "Failed test for rte_cryptodev_configure: "
12897 : : "dev_num %u", dev_id);
12898 : :
12899 : : /* Reconfigure with same configure params */
12900 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
12901 : : "Failed test for rte_cryptodev_configure: "
12902 : : "dev_num %u", dev_id);
12903 : :
12904 : : /* Reconfigure with just one queue pair */
12905 : 0 : ts_params->conf.nb_queue_pairs = 1;
12906 : :
12907 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12908 : : &ts_params->conf),
12909 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
12910 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
12911 : :
12912 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
12913 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12914 : : ts_params->valid_devs[0], qp_id, &qp_conf,
12915 : : rte_cryptodev_socket_id(
12916 : : ts_params->valid_devs[0])),
12917 : : "Failed test for "
12918 : : "rte_cryptodev_queue_pair_setup: num_inflights "
12919 : : "%u on qp %u on cryptodev %u",
12920 : : qp_conf.nb_descriptors, qp_id,
12921 : : ts_params->valid_devs[0]);
12922 : : }
12923 : :
12924 : : /* Reconfigure with max number of queue pairs */
12925 : 0 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
12926 : :
12927 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12928 : : &ts_params->conf),
12929 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
12930 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
12931 : :
12932 : 0 : qp_conf.mp_session = ts_params->session_mpool;
12933 : :
12934 [ # # ]: 0 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
12935 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12936 : : ts_params->valid_devs[0], qp_id, &qp_conf,
12937 : : rte_cryptodev_socket_id(
12938 : : ts_params->valid_devs[0])),
12939 : : "Failed test for "
12940 : : "rte_cryptodev_queue_pair_setup: num_inflights "
12941 : : "%u on qp %u on cryptodev %u",
12942 : : qp_conf.nb_descriptors, qp_id,
12943 : : ts_params->valid_devs[0]);
12944 : : }
12945 : :
12946 : : /* Start the device */
12947 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
12948 : : "Failed to start cryptodev %u",
12949 : : ts_params->valid_devs[0]);
12950 : :
12951 : : /* Test expected values */
12952 : 0 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
12953 : : }
12954 : :
12955 : 0 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
12956 : : struct crypto_unittest_params *ut_params,
12957 : : enum rte_crypto_auth_operation op,
12958 : : const struct HMAC_MD5_vector *test_case)
12959 : : {
12960 : : uint8_t key[64];
12961 : :
12962 : 0 : memcpy(key, test_case->key.data, test_case->key.len);
12963 : :
12964 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12965 : 0 : ut_params->auth_xform.next = NULL;
12966 : 0 : ut_params->auth_xform.auth.op = op;
12967 : :
12968 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
12969 : :
12970 : 0 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
12971 : 0 : ut_params->auth_xform.auth.key.length = test_case->key.len;
12972 : 0 : ut_params->auth_xform.auth.key.data = key;
12973 : :
12974 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
12975 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
12976 : : ts_params->session_mpool);
12977 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
12978 : : return TEST_SKIPPED;
12979 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12980 : :
12981 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12982 : :
12983 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12984 : : rte_pktmbuf_tailroom(ut_params->ibuf));
12985 : :
12986 : 0 : return 0;
12987 : : }
12988 : :
12989 : 0 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
12990 : : const struct HMAC_MD5_vector *test_case,
12991 : : uint8_t **plaintext)
12992 : : {
12993 : : uint16_t plaintext_pad_len;
12994 : :
12995 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12996 : :
12997 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
12998 : : 16);
12999 : :
13000 : 0 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13001 : : plaintext_pad_len);
13002 : 0 : memcpy(*plaintext, test_case->plaintext.data,
13003 : 0 : test_case->plaintext.len);
13004 : :
13005 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13006 : : ut_params->ibuf, MD5_DIGEST_LEN);
13007 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13008 : : "no room to append digest");
13009 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13010 : : ut_params->ibuf, plaintext_pad_len);
13011 : :
13012 [ # # ]: 0 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13013 : 0 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
13014 [ # # ]: 0 : test_case->auth_tag.len);
13015 : : }
13016 : :
13017 : 0 : sym_op->auth.data.offset = 0;
13018 : 0 : sym_op->auth.data.length = test_case->plaintext.len;
13019 : :
13020 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13021 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
13022 : :
13023 : 0 : return 0;
13024 : : }
13025 : :
13026 : : static int
13027 : 0 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
13028 : : {
13029 : : uint16_t plaintext_pad_len;
13030 : : uint8_t *plaintext, *auth_tag;
13031 : : int ret;
13032 : :
13033 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13034 : : struct crypto_unittest_params *ut_params = &unittest_params;
13035 : : struct rte_cryptodev_info dev_info;
13036 : :
13037 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13038 : 0 : uint64_t feat_flags = dev_info.feature_flags;
13039 : :
13040 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13041 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13042 : : printf("Device doesn't support RAW data-path APIs.\n");
13043 : 0 : return TEST_SKIPPED;
13044 : : }
13045 : :
13046 : : /* Verify the capabilities */
13047 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13048 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13049 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13050 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13051 : : &cap_idx) == NULL)
13052 : : return TEST_SKIPPED;
13053 : :
13054 [ # # ]: 0 : if (MD5_HMAC_create_session(ts_params, ut_params,
13055 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
13056 : : return TEST_FAILED;
13057 : :
13058 : : /* Generate Crypto op data structure */
13059 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13060 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13061 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13062 : : "Failed to allocate symmetric crypto operation struct");
13063 : :
13064 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13065 : : 16);
13066 : :
13067 [ # # ]: 0 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13068 : : return TEST_FAILED;
13069 : :
13070 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13071 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13072 : : ut_params->op);
13073 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13074 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13075 [ # # ]: 0 : if (ret != TEST_SUCCESS)
13076 : : return ret;
13077 : : } else
13078 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
13079 : : process_crypto_request(ts_params->valid_devs[0],
13080 : : ut_params->op),
13081 : : "failed to process sym crypto op");
13082 : :
13083 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13084 : : "crypto op processing failed");
13085 : :
13086 [ # # ]: 0 : if (ut_params->op->sym->m_dst) {
13087 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13088 : : uint8_t *, plaintext_pad_len);
13089 : : } else {
13090 : 0 : auth_tag = plaintext + plaintext_pad_len;
13091 : : }
13092 : :
13093 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13094 : : auth_tag,
13095 : : test_case->auth_tag.data,
13096 : : test_case->auth_tag.len,
13097 : : "HMAC_MD5 generated tag not as expected");
13098 : :
13099 : : return TEST_SUCCESS;
13100 : : }
13101 : :
13102 : : static int
13103 : 0 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
13104 : : {
13105 : : uint8_t *plaintext;
13106 : : int ret;
13107 : :
13108 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13109 : : struct crypto_unittest_params *ut_params = &unittest_params;
13110 : : struct rte_cryptodev_info dev_info;
13111 : :
13112 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13113 : 0 : uint64_t feat_flags = dev_info.feature_flags;
13114 : :
13115 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13116 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13117 : : printf("Device doesn't support RAW data-path APIs.\n");
13118 : 0 : return TEST_SKIPPED;
13119 : : }
13120 : :
13121 : : /* Verify the capabilities */
13122 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13123 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13124 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13125 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13126 : : &cap_idx) == NULL)
13127 : : return TEST_SKIPPED;
13128 : :
13129 [ # # ]: 0 : if (MD5_HMAC_create_session(ts_params, ut_params,
13130 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
13131 : : return TEST_FAILED;
13132 : : }
13133 : :
13134 : : /* Generate Crypto op data structure */
13135 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13136 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13137 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13138 : : "Failed to allocate symmetric crypto operation struct");
13139 : :
13140 [ # # ]: 0 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13141 : : return TEST_FAILED;
13142 : :
13143 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13144 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13145 : : ut_params->op);
13146 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13147 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13148 [ # # ]: 0 : if (ret != TEST_SUCCESS)
13149 : : return ret;
13150 : : } else
13151 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
13152 : : process_crypto_request(ts_params->valid_devs[0],
13153 : : ut_params->op),
13154 : : "failed to process sym crypto op");
13155 : :
13156 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13157 : : "HMAC_MD5 crypto op processing failed");
13158 : :
13159 : : return TEST_SUCCESS;
13160 : : }
13161 : :
13162 : : static int
13163 : 0 : test_MD5_HMAC_generate_case_1(void)
13164 : : {
13165 : 0 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
13166 : : }
13167 : :
13168 : : static int
13169 : 0 : test_MD5_HMAC_verify_case_1(void)
13170 : : {
13171 : 0 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
13172 : : }
13173 : :
13174 : : static int
13175 : 0 : test_MD5_HMAC_generate_case_2(void)
13176 : : {
13177 : 0 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
13178 : : }
13179 : :
13180 : : static int
13181 : 0 : test_MD5_HMAC_verify_case_2(void)
13182 : : {
13183 : 0 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
13184 : : }
13185 : :
13186 : : static int
13187 : 0 : test_multi_session(void)
13188 : : {
13189 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13190 : : struct crypto_unittest_params *ut_params = &unittest_params;
13191 : : struct rte_cryptodev_info dev_info;
13192 : : int i, nb_sess, ret = TEST_SUCCESS;
13193 : : void **sessions;
13194 : :
13195 : : /* Verify the capabilities */
13196 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13197 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13198 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13199 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13200 : : &cap_idx) == NULL)
13201 : : return TEST_SKIPPED;
13202 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13203 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13204 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13205 : : &cap_idx) == NULL)
13206 : : return TEST_SKIPPED;
13207 : :
13208 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
13209 : : aes_cbc_key, hmac_sha512_key);
13210 : :
13211 : :
13212 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13213 : :
13214 : 0 : sessions = rte_malloc(NULL,
13215 : : sizeof(void *) *
13216 : : (MAX_NB_SESSIONS + 1), 0);
13217 : :
13218 : : /* Create multiple crypto sessions*/
13219 [ # # ]: 0 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
13220 : 0 : sessions[i] = rte_cryptodev_sym_session_create(
13221 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
13222 : : ts_params->session_mpool);
13223 [ # # # # ]: 0 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13224 : : nb_sess = i;
13225 : : ret = TEST_SKIPPED;
13226 : : break;
13227 : : }
13228 : :
13229 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sessions[i],
13230 : : "Session creation failed at session number %u",
13231 : : i);
13232 : :
13233 : : /* Attempt to send a request on each session */
13234 : 0 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13235 : : sessions[i],
13236 : : ut_params,
13237 : : ts_params,
13238 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
13239 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
13240 : : aes_cbc_iv);
13241 : :
13242 : : /* free crypto operation structure */
13243 : 0 : rte_crypto_op_free(ut_params->op);
13244 : :
13245 : : /*
13246 : : * free mbuf - both obuf and ibuf are usually the same,
13247 : : * so check if they point at the same address is necessary,
13248 : : * to avoid freeing the mbuf twice.
13249 : : */
13250 [ # # ]: 0 : if (ut_params->obuf) {
13251 : 0 : rte_pktmbuf_free(ut_params->obuf);
13252 [ # # ]: 0 : if (ut_params->ibuf == ut_params->obuf)
13253 : 0 : ut_params->ibuf = 0;
13254 : 0 : ut_params->obuf = 0;
13255 : : }
13256 [ # # ]: 0 : if (ut_params->ibuf) {
13257 : 0 : rte_pktmbuf_free(ut_params->ibuf);
13258 : 0 : ut_params->ibuf = 0;
13259 : : }
13260 : :
13261 [ # # ]: 0 : if (ret != TEST_SUCCESS) {
13262 : 0 : i++;
13263 : 0 : break;
13264 : : }
13265 : : }
13266 : :
13267 : : nb_sess = i;
13268 : :
13269 [ # # ]: 0 : for (i = 0; i < nb_sess; i++) {
13270 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13271 : 0 : sessions[i]);
13272 : : }
13273 : :
13274 : 0 : rte_free(sessions);
13275 : :
13276 [ # # ]: 0 : if (ret != TEST_SKIPPED)
13277 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
13278 : :
13279 : : return ret;
13280 : : }
13281 : :
13282 : : struct multi_session_params {
13283 : : struct crypto_unittest_params ut_params;
13284 : : uint8_t *cipher_key;
13285 : : uint8_t *hmac_key;
13286 : : const uint8_t *cipher;
13287 : : const uint8_t *digest;
13288 : : uint8_t *iv;
13289 : : };
13290 : :
13291 : : #define MB_SESSION_NUMBER 3
13292 : :
13293 : : static int
13294 : 0 : test_multi_session_random_usage(void)
13295 : : {
13296 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13297 : : struct rte_cryptodev_info dev_info;
13298 : : int index = 0, ret = TEST_SUCCESS;
13299 : : uint32_t nb_sess, i, j;
13300 : : void **sessions;
13301 : 0 : struct multi_session_params ut_paramz[] = {
13302 : :
13303 : : {
13304 : : .cipher_key = ms_aes_cbc_key0,
13305 : : .hmac_key = ms_hmac_key0,
13306 : : .cipher = ms_aes_cbc_cipher0,
13307 : : .digest = ms_hmac_digest0,
13308 : : .iv = ms_aes_cbc_iv0
13309 : : },
13310 : : {
13311 : : .cipher_key = ms_aes_cbc_key1,
13312 : : .hmac_key = ms_hmac_key1,
13313 : : .cipher = ms_aes_cbc_cipher1,
13314 : : .digest = ms_hmac_digest1,
13315 : : .iv = ms_aes_cbc_iv1
13316 : : },
13317 : : {
13318 : : .cipher_key = ms_aes_cbc_key2,
13319 : : .hmac_key = ms_hmac_key2,
13320 : : .cipher = ms_aes_cbc_cipher2,
13321 : : .digest = ms_hmac_digest2,
13322 : : .iv = ms_aes_cbc_iv2
13323 : : },
13324 : :
13325 : : };
13326 : :
13327 : : /* Verify the capabilities */
13328 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13329 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13330 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13331 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13332 : : &cap_idx) == NULL)
13333 : : return TEST_SKIPPED;
13334 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13335 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13336 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13337 : : &cap_idx) == NULL)
13338 : : return TEST_SKIPPED;
13339 : :
13340 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13341 : :
13342 : 0 : sessions = rte_malloc(NULL, (sizeof(void *)
13343 : : * MAX_NB_SESSIONS) + 1, 0);
13344 : :
13345 [ # # ]: 0 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
13346 : :
13347 [ # # ]: 0 : rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
13348 : : sizeof(struct crypto_unittest_params));
13349 : :
13350 : 0 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
13351 : : &ut_paramz[i].ut_params,
13352 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
13353 : :
13354 : : /* Create multiple crypto sessions*/
13355 : 0 : sessions[i] = rte_cryptodev_sym_session_create(
13356 : 0 : ts_params->valid_devs[0],
13357 : : &ut_paramz[i].ut_params.auth_xform,
13358 : : ts_params->session_mpool);
13359 [ # # # # ]: 0 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13360 : : nb_sess = i;
13361 : : ret = TEST_SKIPPED;
13362 : 0 : goto session_clear;
13363 : : }
13364 : :
13365 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sessions[i],
13366 : : "Session creation failed at session number %u",
13367 : : i);
13368 : : }
13369 : :
13370 : : nb_sess = i;
13371 : :
13372 : 0 : srand(time(NULL));
13373 [ # # ]: 0 : for (i = 0; i < 40000; i++) {
13374 : :
13375 : 0 : j = rand() % MB_SESSION_NUMBER;
13376 : :
13377 : 0 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13378 : 0 : sessions[j],
13379 : : &ut_paramz[j].ut_params,
13380 : : ts_params, ut_paramz[j].cipher,
13381 : : ut_paramz[j].digest,
13382 : 0 : ut_paramz[j].iv);
13383 : :
13384 : 0 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
13385 : :
13386 : : /*
13387 : : * free mbuf - both obuf and ibuf are usually the same,
13388 : : * so check if they point at the same address is necessary,
13389 : : * to avoid freeing the mbuf twice.
13390 : : */
13391 [ # # ]: 0 : if (ut_paramz[j].ut_params.obuf) {
13392 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
13393 : 0 : if (ut_paramz[j].ut_params.ibuf
13394 [ # # ]: 0 : == ut_paramz[j].ut_params.obuf)
13395 : 0 : ut_paramz[j].ut_params.ibuf = 0;
13396 : 0 : ut_paramz[j].ut_params.obuf = 0;
13397 : : }
13398 [ # # ]: 0 : if (ut_paramz[j].ut_params.ibuf) {
13399 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
13400 : 0 : ut_paramz[j].ut_params.ibuf = 0;
13401 : : }
13402 : :
13403 [ # # ]: 0 : if (ret != TEST_SKIPPED) {
13404 : 0 : index = i;
13405 : 0 : break;
13406 : : }
13407 : : }
13408 : :
13409 : 0 : session_clear:
13410 [ # # ]: 0 : for (i = 0; i < nb_sess; i++) {
13411 : 0 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13412 : 0 : sessions[i]);
13413 : : }
13414 : :
13415 : 0 : rte_free(sessions);
13416 : :
13417 [ # # ]: 0 : if (ret != TEST_SKIPPED)
13418 [ # # ]: 0 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
13419 : :
13420 : : return TEST_SUCCESS;
13421 : : }
13422 : :
13423 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
13424 : : 0xab, 0xab, 0xab, 0xab,
13425 : : 0xab, 0xab, 0xab, 0xab,
13426 : : 0xab, 0xab, 0xab, 0xab};
13427 : :
13428 : : static int
13429 : 0 : test_null_invalid_operation(void)
13430 : : {
13431 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13432 : : struct crypto_unittest_params *ut_params = &unittest_params;
13433 : :
13434 : : /* This test is for NULL PMD only */
13435 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
13436 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13437 : : return TEST_SKIPPED;
13438 : :
13439 : : /* Setup Cipher Parameters */
13440 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13441 : 0 : ut_params->cipher_xform.next = NULL;
13442 : :
13443 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
13444 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13445 : :
13446 : : /* Create Crypto session*/
13447 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13448 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
13449 : : ts_params->session_mpool);
13450 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
13451 : : "Session creation succeeded unexpectedly");
13452 : :
13453 : : /* Setup HMAC Parameters */
13454 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13455 : 0 : ut_params->auth_xform.next = NULL;
13456 : :
13457 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
13458 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13459 : :
13460 : : /* Create Crypto session*/
13461 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13462 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
13463 : : ts_params->session_mpool);
13464 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
13465 : : "Session creation succeeded unexpectedly");
13466 : :
13467 : : return TEST_SUCCESS;
13468 : : }
13469 : :
13470 : :
13471 : : #define NULL_BURST_LENGTH (32)
13472 : :
13473 : : static int
13474 : 0 : test_null_burst_operation(void)
13475 : : {
13476 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13477 : : struct crypto_unittest_params *ut_params = &unittest_params;
13478 : :
13479 : : unsigned i, burst_len = NULL_BURST_LENGTH;
13480 : :
13481 : 0 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
13482 : 0 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
13483 : :
13484 : : /* This test is for NULL PMD only */
13485 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
13486 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13487 : : return TEST_SKIPPED;
13488 : :
13489 : : /* Setup Cipher Parameters */
13490 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13491 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
13492 : :
13493 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
13494 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13495 : :
13496 : : /* Setup HMAC Parameters */
13497 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13498 : 0 : ut_params->auth_xform.next = NULL;
13499 : :
13500 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
13501 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13502 : :
13503 : : /* Create Crypto session*/
13504 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
13505 : 0 : ts_params->valid_devs[0],
13506 : : &ut_params->auth_xform,
13507 : : ts_params->session_mpool);
13508 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13509 : : return TEST_SKIPPED;
13510 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13511 : :
13512 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
13513 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
13514 : : burst_len, "failed to generate burst of crypto ops");
13515 : :
13516 : : /* Generate an operation for each mbuf in burst */
13517 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
13518 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13519 : :
13520 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
13521 : :
13522 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
13523 : : sizeof(unsigned));
13524 : 0 : *data = i;
13525 : :
13526 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
13527 : :
13528 : 0 : burst[i]->sym->m_src = m;
13529 : : }
13530 : :
13531 : : /* Process crypto operation */
13532 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
13533 : : 0, burst, burst_len),
13534 : : burst_len,
13535 : : "Error enqueuing burst");
13536 : :
13537 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
13538 : : 0, burst_dequeued, burst_len),
13539 : : burst_len,
13540 : : "Error dequeuing burst");
13541 : :
13542 : :
13543 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
13544 [ # # ]: 0 : TEST_ASSERT_EQUAL(
13545 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
13546 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
13547 : : uint32_t *),
13548 : : "data not as expected");
13549 : :
13550 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
13551 : 0 : rte_crypto_op_free(burst[i]);
13552 : : }
13553 : :
13554 : : return TEST_SUCCESS;
13555 : : }
13556 : :
13557 : : static uint16_t
13558 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13559 : : uint16_t nb_ops, void *user_param)
13560 : : {
13561 : : RTE_SET_USED(dev_id);
13562 : : RTE_SET_USED(qp_id);
13563 : : RTE_SET_USED(ops);
13564 : : RTE_SET_USED(user_param);
13565 : :
13566 : : printf("crypto enqueue callback called\n");
13567 : 0 : return nb_ops;
13568 : : }
13569 : :
13570 : : static uint16_t
13571 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13572 : : uint16_t nb_ops, void *user_param)
13573 : : {
13574 : : RTE_SET_USED(dev_id);
13575 : : RTE_SET_USED(qp_id);
13576 : : RTE_SET_USED(ops);
13577 : : RTE_SET_USED(user_param);
13578 : :
13579 : : printf("crypto dequeue callback called\n");
13580 : 0 : return nb_ops;
13581 : : }
13582 : :
13583 : : /*
13584 : : * Thread using enqueue/dequeue callback with RCU.
13585 : : */
13586 : : static int
13587 : 0 : test_enqdeq_callback_thread(void *arg)
13588 : : {
13589 : : RTE_SET_USED(arg);
13590 : : /* DP thread calls rte_cryptodev_enqueue_burst()/
13591 : : * rte_cryptodev_dequeue_burst() and invokes callback.
13592 : : */
13593 : 0 : test_null_burst_operation();
13594 : 0 : return 0;
13595 : : }
13596 : :
13597 : : static int
13598 : 0 : test_enq_callback_setup(void)
13599 : : {
13600 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13601 : : struct rte_cryptodev_info dev_info;
13602 : 0 : struct rte_cryptodev_qp_conf qp_conf = {
13603 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
13604 : : };
13605 : :
13606 : : struct rte_cryptodev_cb *cb;
13607 : : uint16_t qp_id = 0;
13608 : :
13609 : : /* Stop the device in case it's started so it can be configured */
13610 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
13611 : :
13612 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13613 : :
13614 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13615 : : &ts_params->conf),
13616 : : "Failed to configure cryptodev %u",
13617 : : ts_params->valid_devs[0]);
13618 : :
13619 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13620 : 0 : qp_conf.mp_session = ts_params->session_mpool;
13621 : :
13622 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13623 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13624 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13625 : : "Failed test for "
13626 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13627 : : "%u on qp %u on cryptodev %u",
13628 : : qp_conf.nb_descriptors, qp_id,
13629 : : ts_params->valid_devs[0]);
13630 : :
13631 : : /* Test with invalid crypto device */
13632 : 0 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
13633 : : qp_id, test_enq_callback, NULL);
13634 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13635 : : "cryptodev %u did not fail",
13636 : : qp_id, RTE_CRYPTO_MAX_DEVS);
13637 : :
13638 : : /* Test with invalid queue pair */
13639 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13640 : 0 : dev_info.max_nb_queue_pairs + 1,
13641 : : test_enq_callback, NULL);
13642 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13643 : : "cryptodev %u did not fail",
13644 : : dev_info.max_nb_queue_pairs + 1,
13645 : : ts_params->valid_devs[0]);
13646 : :
13647 : : /* Test with NULL callback */
13648 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13649 : : qp_id, NULL, NULL);
13650 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13651 : : "cryptodev %u did not fail",
13652 : : qp_id, ts_params->valid_devs[0]);
13653 : :
13654 : : /* Test with valid configuration */
13655 : 0 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13656 : : qp_id, test_enq_callback, NULL);
13657 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
13658 : : "qp %u on cryptodev %u",
13659 : : qp_id, ts_params->valid_devs[0]);
13660 : :
13661 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
13662 : :
13663 : : /* Launch a thread */
13664 : 0 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
13665 : : rte_get_next_lcore(-1, 1, 0));
13666 : :
13667 : : /* Wait until reader exited. */
13668 : 0 : rte_eal_mp_wait_lcore();
13669 : :
13670 : : /* Test with invalid crypto device */
13671 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13672 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
13673 : : "Expected call to fail as crypto device is invalid");
13674 : :
13675 : : /* Test with invalid queue pair */
13676 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13677 : : ts_params->valid_devs[0],
13678 : : dev_info.max_nb_queue_pairs + 1, cb),
13679 : : "Expected call to fail as queue pair is invalid");
13680 : :
13681 : : /* Test with NULL callback */
13682 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13683 : : ts_params->valid_devs[0], qp_id, NULL),
13684 : : "Expected call to fail as callback is NULL");
13685 : :
13686 : : /* Test with valid configuration */
13687 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
13688 : : ts_params->valid_devs[0], qp_id, cb),
13689 : : "Failed test to remove callback on "
13690 : : "qp %u on cryptodev %u",
13691 : : qp_id, ts_params->valid_devs[0]);
13692 : :
13693 : : return TEST_SUCCESS;
13694 : : }
13695 : :
13696 : : static int
13697 : 0 : test_deq_callback_setup(void)
13698 : : {
13699 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13700 : : struct rte_cryptodev_info dev_info;
13701 : 0 : struct rte_cryptodev_qp_conf qp_conf = {
13702 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
13703 : : };
13704 : :
13705 : : struct rte_cryptodev_cb *cb;
13706 : : uint16_t qp_id = 0;
13707 : :
13708 : : /* Stop the device in case it's started so it can be configured */
13709 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
13710 : :
13711 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13712 : :
13713 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13714 : : &ts_params->conf),
13715 : : "Failed to configure cryptodev %u",
13716 : : ts_params->valid_devs[0]);
13717 : :
13718 : 0 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13719 : 0 : qp_conf.mp_session = ts_params->session_mpool;
13720 : :
13721 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13722 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13723 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13724 : : "Failed test for "
13725 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13726 : : "%u on qp %u on cryptodev %u",
13727 : : qp_conf.nb_descriptors, qp_id,
13728 : : ts_params->valid_devs[0]);
13729 : :
13730 : : /* Test with invalid crypto device */
13731 : 0 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
13732 : : qp_id, test_deq_callback, NULL);
13733 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13734 : : "cryptodev %u did not fail",
13735 : : qp_id, RTE_CRYPTO_MAX_DEVS);
13736 : :
13737 : : /* Test with invalid queue pair */
13738 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13739 : 0 : dev_info.max_nb_queue_pairs + 1,
13740 : : test_deq_callback, NULL);
13741 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13742 : : "cryptodev %u did not fail",
13743 : : dev_info.max_nb_queue_pairs + 1,
13744 : : ts_params->valid_devs[0]);
13745 : :
13746 : : /* Test with NULL callback */
13747 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13748 : : qp_id, NULL, NULL);
13749 [ # # ]: 0 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13750 : : "cryptodev %u did not fail",
13751 : : qp_id, ts_params->valid_devs[0]);
13752 : :
13753 : : /* Test with valid configuration */
13754 : 0 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13755 : : qp_id, test_deq_callback, NULL);
13756 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
13757 : : "qp %u on cryptodev %u",
13758 : : qp_id, ts_params->valid_devs[0]);
13759 : :
13760 : 0 : rte_cryptodev_start(ts_params->valid_devs[0]);
13761 : :
13762 : : /* Launch a thread */
13763 : 0 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
13764 : : rte_get_next_lcore(-1, 1, 0));
13765 : :
13766 : : /* Wait until reader exited. */
13767 : 0 : rte_eal_mp_wait_lcore();
13768 : :
13769 : : /* Test with invalid crypto device */
13770 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13771 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
13772 : : "Expected call to fail as crypto device is invalid");
13773 : :
13774 : : /* Test with invalid queue pair */
13775 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13776 : : ts_params->valid_devs[0],
13777 : : dev_info.max_nb_queue_pairs + 1, cb),
13778 : : "Expected call to fail as queue pair is invalid");
13779 : :
13780 : : /* Test with NULL callback */
13781 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13782 : : ts_params->valid_devs[0], qp_id, NULL),
13783 : : "Expected call to fail as callback is NULL");
13784 : :
13785 : : /* Test with valid configuration */
13786 [ # # ]: 0 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
13787 : : ts_params->valid_devs[0], qp_id, cb),
13788 : : "Failed test to remove callback on "
13789 : : "qp %u on cryptodev %u",
13790 : : qp_id, ts_params->valid_devs[0]);
13791 : :
13792 : : return TEST_SUCCESS;
13793 : : }
13794 : :
13795 : : static void
13796 : : generate_gmac_large_plaintext(uint8_t *data)
13797 : : {
13798 : : uint16_t i;
13799 : :
13800 [ # # # # ]: 0 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
13801 : 0 : memcpy(&data[i], &data[0], 32);
13802 : : }
13803 : :
13804 : : static int
13805 : 0 : create_gmac_operation(enum rte_crypto_auth_operation op,
13806 : : const struct gmac_test_data *tdata)
13807 : : {
13808 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13809 : : struct crypto_unittest_params *ut_params = &unittest_params;
13810 : : struct rte_crypto_sym_op *sym_op;
13811 : :
13812 : 0 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13813 : :
13814 : : /* Generate Crypto op data structure */
13815 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13816 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13817 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13818 : : "Failed to allocate symmetric crypto operation struct");
13819 : :
13820 : : sym_op = ut_params->op->sym;
13821 : :
13822 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13823 : 0 : ut_params->ibuf, tdata->gmac_tag.len);
13824 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13825 : : "no room to append digest");
13826 : :
13827 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13828 : : ut_params->ibuf, plaintext_pad_len);
13829 : :
13830 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13831 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
13832 [ # # ]: 0 : tdata->gmac_tag.len);
13833 : 0 : debug_hexdump(stdout, "digest:",
13834 : 0 : sym_op->auth.digest.data,
13835 : 0 : tdata->gmac_tag.len);
13836 : : }
13837 : :
13838 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13839 : : uint8_t *, IV_OFFSET);
13840 : :
13841 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
13842 : :
13843 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
13844 : :
13845 : 0 : sym_op->cipher.data.length = 0;
13846 : 0 : sym_op->cipher.data.offset = 0;
13847 : :
13848 : 0 : sym_op->auth.data.offset = 0;
13849 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
13850 : :
13851 : 0 : return 0;
13852 : : }
13853 : :
13854 : : static int
13855 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
13856 : : const struct gmac_test_data *tdata,
13857 : : void *digest_mem, uint64_t digest_phys)
13858 : : {
13859 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13860 : : struct crypto_unittest_params *ut_params = &unittest_params;
13861 : : struct rte_crypto_sym_op *sym_op;
13862 : :
13863 : : /* Generate Crypto op data structure */
13864 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13865 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13866 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
13867 : : "Failed to allocate symmetric crypto operation struct");
13868 : :
13869 : : sym_op = ut_params->op->sym;
13870 : :
13871 : 0 : sym_op->auth.digest.data = digest_mem;
13872 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13873 : : "no room to append digest");
13874 : :
13875 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
13876 : :
13877 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13878 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
13879 [ # # ]: 0 : tdata->gmac_tag.len);
13880 : 0 : debug_hexdump(stdout, "digest:",
13881 : 0 : sym_op->auth.digest.data,
13882 : 0 : tdata->gmac_tag.len);
13883 : : }
13884 : :
13885 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13886 : : uint8_t *, IV_OFFSET);
13887 : :
13888 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
13889 : :
13890 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
13891 : :
13892 : 0 : sym_op->cipher.data.length = 0;
13893 : 0 : sym_op->cipher.data.offset = 0;
13894 : :
13895 : 0 : sym_op->auth.data.offset = 0;
13896 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
13897 : :
13898 : 0 : return 0;
13899 : : }
13900 : :
13901 : 0 : static int create_gmac_session(uint8_t dev_id,
13902 : : const struct gmac_test_data *tdata,
13903 : : enum rte_crypto_auth_operation auth_op)
13904 : 0 : {
13905 : 0 : uint8_t auth_key[tdata->key.len];
13906 : :
13907 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13908 : : struct crypto_unittest_params *ut_params = &unittest_params;
13909 : :
13910 : 0 : memcpy(auth_key, tdata->key.data, tdata->key.len);
13911 : :
13912 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13913 : 0 : ut_params->auth_xform.next = NULL;
13914 : :
13915 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
13916 : 0 : ut_params->auth_xform.auth.op = auth_op;
13917 : 0 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
13918 : 0 : ut_params->auth_xform.auth.key.length = tdata->key.len;
13919 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
13920 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13921 : 0 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
13922 : :
13923 : :
13924 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
13925 : : &ut_params->auth_xform, ts_params->session_mpool);
13926 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13927 : : return TEST_SKIPPED;
13928 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13929 : :
13930 : : return 0;
13931 : : }
13932 : :
13933 : : static int
13934 : 0 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
13935 : : {
13936 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13937 : : struct crypto_unittest_params *ut_params = &unittest_params;
13938 : : struct rte_cryptodev_info dev_info;
13939 : :
13940 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13941 : 0 : uint64_t feat_flags = dev_info.feature_flags;
13942 : :
13943 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13944 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13945 : : printf("Device doesn't support RAW data-path APIs.\n");
13946 : 0 : return TEST_SKIPPED;
13947 : : }
13948 : :
13949 : : int retval;
13950 : :
13951 : : uint8_t *auth_tag, *plaintext;
13952 : : uint16_t plaintext_pad_len;
13953 : :
13954 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
13955 : : "No GMAC length in the source data");
13956 : :
13957 : : /* Verify the capabilities */
13958 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13959 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13960 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
13961 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13962 : : &cap_idx) == NULL)
13963 : : return TEST_SKIPPED;
13964 : :
13965 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
13966 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
13967 : :
13968 [ # # ]: 0 : if (retval == TEST_SKIPPED)
13969 : : return TEST_SKIPPED;
13970 [ # # ]: 0 : if (retval < 0)
13971 : : return retval;
13972 : :
13973 [ # # ]: 0 : if (tdata->plaintext.len > MBUF_SIZE)
13974 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13975 : : else
13976 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13977 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13978 : : "Failed to allocate input buffer in mempool");
13979 : :
13980 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13981 : : rte_pktmbuf_tailroom(ut_params->ibuf));
13982 : :
13983 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13984 : : /*
13985 : : * Runtime generate the large plain text instead of use hard code
13986 : : * plain text vector. It is done to avoid create huge source file
13987 : : * with the test vector.
13988 : : */
13989 [ # # ]: 0 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
13990 : 0 : generate_gmac_large_plaintext(tdata->plaintext.data);
13991 : :
13992 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13993 : : plaintext_pad_len);
13994 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13995 : :
13996 : 0 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
13997 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
13998 : 0 : tdata->plaintext.len);
13999 : :
14000 : 0 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
14001 : : tdata);
14002 : :
14003 [ # # ]: 0 : if (retval < 0)
14004 : : return retval;
14005 : :
14006 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14007 : :
14008 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
14009 : :
14010 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14011 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14012 : : ut_params->op);
14013 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14014 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14015 : : 0);
14016 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14017 : : return retval;
14018 : : } else
14019 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
14020 : : process_crypto_request(ts_params->valid_devs[0],
14021 : : ut_params->op), "failed to process sym crypto op");
14022 : :
14023 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14024 : : "crypto op processing failed");
14025 : :
14026 [ # # ]: 0 : if (ut_params->op->sym->m_dst) {
14027 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14028 : : uint8_t *, plaintext_pad_len);
14029 : : } else {
14030 : 0 : auth_tag = plaintext + plaintext_pad_len;
14031 : : }
14032 : :
14033 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14034 : :
14035 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14036 : : auth_tag,
14037 : : tdata->gmac_tag.data,
14038 : : tdata->gmac_tag.len,
14039 : : "GMAC Generated auth tag not as expected");
14040 : :
14041 : : return 0;
14042 : : }
14043 : :
14044 : : static int
14045 : 0 : test_AES_GMAC_authentication_test_case_1(void)
14046 : : {
14047 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_1);
14048 : : }
14049 : :
14050 : : static int
14051 : 0 : test_AES_GMAC_authentication_test_case_2(void)
14052 : : {
14053 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_2);
14054 : : }
14055 : :
14056 : : static int
14057 : 0 : test_AES_GMAC_authentication_test_case_3(void)
14058 : : {
14059 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_3);
14060 : : }
14061 : :
14062 : : static int
14063 : 0 : test_AES_GMAC_authentication_test_case_4(void)
14064 : : {
14065 : 0 : return test_AES_GMAC_authentication(&gmac_test_case_4);
14066 : : }
14067 : :
14068 : : static int
14069 : 0 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
14070 : : {
14071 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14072 : : struct crypto_unittest_params *ut_params = &unittest_params;
14073 : : int retval;
14074 : : uint32_t plaintext_pad_len;
14075 : : uint8_t *plaintext;
14076 : : struct rte_cryptodev_info dev_info;
14077 : :
14078 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14079 : 0 : uint64_t feat_flags = dev_info.feature_flags;
14080 : :
14081 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14082 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14083 : : printf("Device doesn't support RAW data-path APIs.\n");
14084 : 0 : return TEST_SKIPPED;
14085 : : }
14086 : :
14087 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14088 : : "No GMAC length in the source data");
14089 : :
14090 : : /* Verify the capabilities */
14091 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14092 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14093 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14094 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14095 : : &cap_idx) == NULL)
14096 : : return TEST_SKIPPED;
14097 : :
14098 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
14099 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
14100 : :
14101 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14102 : : return TEST_SKIPPED;
14103 [ # # ]: 0 : if (retval < 0)
14104 : : return retval;
14105 : :
14106 [ # # ]: 0 : if (tdata->plaintext.len > MBUF_SIZE)
14107 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14108 : : else
14109 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14110 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14111 : : "Failed to allocate input buffer in mempool");
14112 : :
14113 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14114 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14115 : :
14116 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14117 : :
14118 : : /*
14119 : : * Runtime generate the large plain text instead of use hard code
14120 : : * plain text vector. It is done to avoid create huge source file
14121 : : * with the test vector.
14122 : : */
14123 [ # # ]: 0 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14124 : 0 : generate_gmac_large_plaintext(tdata->plaintext.data);
14125 : :
14126 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14127 : : plaintext_pad_len);
14128 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14129 : :
14130 : 0 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14131 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
14132 : 0 : tdata->plaintext.len);
14133 : :
14134 : 0 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
14135 : : tdata);
14136 : :
14137 [ # # ]: 0 : if (retval < 0)
14138 : : return retval;
14139 : :
14140 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14141 : :
14142 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
14143 : :
14144 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14145 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14146 : : ut_params->op);
14147 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14148 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14149 : : 0);
14150 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14151 : : return retval;
14152 : : } else
14153 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
14154 : : process_crypto_request(ts_params->valid_devs[0],
14155 : : ut_params->op), "failed to process sym crypto op");
14156 : :
14157 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14158 : : "crypto op processing failed");
14159 : :
14160 : : return 0;
14161 : :
14162 : : }
14163 : :
14164 : : static int
14165 : 0 : test_AES_GMAC_authentication_verify_test_case_1(void)
14166 : : {
14167 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
14168 : : }
14169 : :
14170 : : static int
14171 : 0 : test_AES_GMAC_authentication_verify_test_case_2(void)
14172 : : {
14173 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
14174 : : }
14175 : :
14176 : : static int
14177 : 0 : test_AES_GMAC_authentication_verify_test_case_3(void)
14178 : : {
14179 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
14180 : : }
14181 : :
14182 : : static int
14183 : 0 : test_AES_GMAC_authentication_verify_test_case_4(void)
14184 : : {
14185 : 0 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
14186 : : }
14187 : :
14188 : : static int
14189 : 0 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
14190 : : uint32_t fragsz)
14191 : : {
14192 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14193 : : struct crypto_unittest_params *ut_params = &unittest_params;
14194 : : struct rte_cryptodev_info dev_info;
14195 : : uint64_t feature_flags;
14196 : : unsigned int trn_data = 0;
14197 : : void *digest_mem = NULL;
14198 : : uint32_t segs = 1;
14199 : : unsigned int to_trn = 0;
14200 : : struct rte_mbuf *buf = NULL;
14201 : : uint8_t *auth_tag, *plaintext;
14202 : : int retval;
14203 : :
14204 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14205 : : "No GMAC length in the source data");
14206 : :
14207 : : /* Verify the capabilities */
14208 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14209 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14210 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14211 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14212 : : &cap_idx) == NULL)
14213 : : return TEST_SKIPPED;
14214 : :
14215 : : /* Check for any input SGL support */
14216 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14217 : 0 : feature_flags = dev_info.feature_flags;
14218 : :
14219 : 0 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
14220 [ # # ]: 0 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
14221 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
14222 : : return TEST_SKIPPED;
14223 : :
14224 : 0 : if (fragsz > tdata->plaintext.len)
14225 : : fragsz = tdata->plaintext.len;
14226 : :
14227 : 0 : uint16_t plaintext_len = fragsz;
14228 : :
14229 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
14230 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14231 : :
14232 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14233 : : return TEST_SKIPPED;
14234 [ # # ]: 0 : if (retval < 0)
14235 : : return retval;
14236 : :
14237 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14238 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14239 : : "Failed to allocate input buffer in mempool");
14240 : :
14241 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14242 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14243 : :
14244 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14245 : : plaintext_len);
14246 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14247 : :
14248 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14249 : :
14250 : : trn_data += plaintext_len;
14251 : :
14252 : 0 : buf = ut_params->ibuf;
14253 : :
14254 : : /*
14255 : : * Loop until no more fragments
14256 : : */
14257 : :
14258 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
14259 : 0 : ++segs;
14260 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14261 : : (tdata->plaintext.len - trn_data) : fragsz;
14262 : :
14263 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14264 : : buf = buf->next;
14265 : :
14266 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14267 : : rte_pktmbuf_tailroom(buf));
14268 : :
14269 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14270 : : to_trn);
14271 : :
14272 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
14273 : : to_trn);
14274 : 0 : trn_data += to_trn;
14275 [ # # ]: 0 : if (trn_data == tdata->plaintext.len)
14276 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14277 : 0 : tdata->gmac_tag.len);
14278 : : }
14279 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
14280 : :
14281 : : /*
14282 : : * Place digest at the end of the last buffer
14283 : : */
14284 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14285 : :
14286 [ # # ]: 0 : if (!digest_mem) {
14287 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14288 : 0 : + tdata->gmac_tag.len);
14289 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14290 : : tdata->plaintext.len);
14291 : : }
14292 : :
14293 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
14294 : : tdata, digest_mem, digest_phys);
14295 : :
14296 [ # # ]: 0 : if (retval < 0)
14297 : : return retval;
14298 : :
14299 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14300 : :
14301 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
14302 : :
14303 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14304 : : return TEST_SKIPPED;
14305 : :
14306 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
14307 : : process_crypto_request(ts_params->valid_devs[0],
14308 : : ut_params->op), "failed to process sym crypto op");
14309 : :
14310 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14311 : : "crypto op processing failed");
14312 : :
14313 : : auth_tag = digest_mem;
14314 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14315 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14316 : : auth_tag,
14317 : : tdata->gmac_tag.data,
14318 : : tdata->gmac_tag.len,
14319 : : "GMAC Generated auth tag not as expected");
14320 : :
14321 : : return 0;
14322 : : }
14323 : :
14324 : : /* Segment size not multiple of block size (16B) */
14325 : : static int
14326 : 0 : test_AES_GMAC_authentication_SGL_40B(void)
14327 : : {
14328 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
14329 : : }
14330 : :
14331 : : static int
14332 : 0 : test_AES_GMAC_authentication_SGL_80B(void)
14333 : : {
14334 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
14335 : : }
14336 : :
14337 : : static int
14338 : 0 : test_AES_GMAC_authentication_SGL_2048B(void)
14339 : : {
14340 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
14341 : : }
14342 : :
14343 : : /* Segment size not multiple of block size (16B) */
14344 : : static int
14345 : 0 : test_AES_GMAC_authentication_SGL_2047B(void)
14346 : : {
14347 : 0 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
14348 : : }
14349 : :
14350 : : struct test_crypto_vector {
14351 : : enum rte_crypto_cipher_algorithm crypto_algo;
14352 : : unsigned int cipher_offset;
14353 : : unsigned int cipher_len;
14354 : :
14355 : : struct {
14356 : : uint8_t data[64];
14357 : : unsigned int len;
14358 : : } cipher_key;
14359 : :
14360 : : struct {
14361 : : uint8_t data[64];
14362 : : unsigned int len;
14363 : : } iv;
14364 : :
14365 : : struct {
14366 : : const uint8_t *data;
14367 : : unsigned int len;
14368 : : } plaintext;
14369 : :
14370 : : struct {
14371 : : const uint8_t *data;
14372 : : unsigned int len;
14373 : : } ciphertext;
14374 : :
14375 : : enum rte_crypto_auth_algorithm auth_algo;
14376 : : unsigned int auth_offset;
14377 : :
14378 : : struct {
14379 : : uint8_t data[128];
14380 : : unsigned int len;
14381 : : } auth_key;
14382 : :
14383 : : struct {
14384 : : const uint8_t *data;
14385 : : unsigned int len;
14386 : : } aad;
14387 : :
14388 : : struct {
14389 : : uint8_t data[128];
14390 : : unsigned int len;
14391 : : } digest;
14392 : : };
14393 : :
14394 : : static const struct test_crypto_vector
14395 : : hmac_sha1_test_crypto_vector = {
14396 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14397 : : .plaintext = {
14398 : : .data = plaintext_hash,
14399 : : .len = 512
14400 : : },
14401 : : .auth_key = {
14402 : : .data = {
14403 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14404 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14405 : : 0xDE, 0xF4, 0xDE, 0xAD
14406 : : },
14407 : : .len = 20
14408 : : },
14409 : : .digest = {
14410 : : .data = {
14411 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
14412 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
14413 : : 0x3F, 0x91, 0x64, 0x59
14414 : : },
14415 : : .len = 20
14416 : : }
14417 : : };
14418 : :
14419 : : static const struct test_crypto_vector
14420 : : aes128_gmac_test_vector = {
14421 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
14422 : : .plaintext = {
14423 : : .data = plaintext_hash,
14424 : : .len = 512
14425 : : },
14426 : : .iv = {
14427 : : .data = {
14428 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14429 : : 0x08, 0x09, 0x0A, 0x0B
14430 : : },
14431 : : .len = 12
14432 : : },
14433 : : .auth_key = {
14434 : : .data = {
14435 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14436 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
14437 : : },
14438 : : .len = 16
14439 : : },
14440 : : .digest = {
14441 : : .data = {
14442 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
14443 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
14444 : : },
14445 : : .len = 16
14446 : : }
14447 : : };
14448 : :
14449 : : static const struct test_crypto_vector
14450 : : aes128cbc_hmac_sha1_test_vector = {
14451 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14452 : : .cipher_offset = 0,
14453 : : .cipher_len = 512,
14454 : : .cipher_key = {
14455 : : .data = {
14456 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14457 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14458 : : },
14459 : : .len = 16
14460 : : },
14461 : : .iv = {
14462 : : .data = {
14463 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14464 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14465 : : },
14466 : : .len = 16
14467 : : },
14468 : : .plaintext = {
14469 : : .data = plaintext_hash,
14470 : : .len = 512
14471 : : },
14472 : : .ciphertext = {
14473 : : .data = ciphertext512_aes128cbc,
14474 : : .len = 512
14475 : : },
14476 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14477 : : .auth_offset = 0,
14478 : : .auth_key = {
14479 : : .data = {
14480 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14481 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14482 : : 0xDE, 0xF4, 0xDE, 0xAD
14483 : : },
14484 : : .len = 20
14485 : : },
14486 : : .digest = {
14487 : : .data = {
14488 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
14489 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14490 : : 0x18, 0x8C, 0x1D, 0x32
14491 : : },
14492 : : .len = 20
14493 : : }
14494 : : };
14495 : :
14496 : : static const struct test_crypto_vector
14497 : : aes128cbc_hmac_sha1_aad_test_vector = {
14498 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14499 : : .cipher_offset = 8,
14500 : : .cipher_len = 496,
14501 : : .cipher_key = {
14502 : : .data = {
14503 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14504 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14505 : : },
14506 : : .len = 16
14507 : : },
14508 : : .iv = {
14509 : : .data = {
14510 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14511 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14512 : : },
14513 : : .len = 16
14514 : : },
14515 : : .plaintext = {
14516 : : .data = plaintext_hash,
14517 : : .len = 512
14518 : : },
14519 : : .ciphertext = {
14520 : : .data = ciphertext512_aes128cbc_aad,
14521 : : .len = 512
14522 : : },
14523 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14524 : : .auth_offset = 0,
14525 : : .auth_key = {
14526 : : .data = {
14527 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14528 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14529 : : 0xDE, 0xF4, 0xDE, 0xAD
14530 : : },
14531 : : .len = 20
14532 : : },
14533 : : .digest = {
14534 : : .data = {
14535 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
14536 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
14537 : : 0x62, 0x0F, 0xFB, 0x10
14538 : : },
14539 : : .len = 20
14540 : : }
14541 : : };
14542 : :
14543 : : static void
14544 : : data_corruption(uint8_t *data)
14545 : : {
14546 : 0 : data[0] += 1;
14547 : 0 : }
14548 : :
14549 : : static void
14550 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
14551 : : {
14552 : 0 : data[tag_offset] += 1;
14553 : 0 : }
14554 : :
14555 : : static int
14556 : 0 : create_auth_session(struct crypto_unittest_params *ut_params,
14557 : : uint8_t dev_id,
14558 : : const struct test_crypto_vector *reference,
14559 : : enum rte_crypto_auth_operation auth_op)
14560 : 0 : {
14561 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14562 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
14563 : :
14564 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14565 : :
14566 : : /* Setup Authentication Parameters */
14567 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14568 : 0 : ut_params->auth_xform.auth.op = auth_op;
14569 : 0 : ut_params->auth_xform.next = NULL;
14570 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
14571 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14572 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
14573 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
14574 : :
14575 : : /* Create Crypto session*/
14576 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14577 : : &ut_params->auth_xform,
14578 : : ts_params->session_mpool);
14579 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14580 : 0 : return TEST_SKIPPED;
14581 : :
14582 : : return 0;
14583 : : }
14584 : :
14585 : : static int
14586 : 0 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
14587 : : uint8_t dev_id,
14588 : : const struct test_crypto_vector *reference,
14589 : : enum rte_crypto_auth_operation auth_op,
14590 : : enum rte_crypto_cipher_operation cipher_op)
14591 : 0 : {
14592 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14593 : 0 : uint8_t cipher_key[reference->cipher_key.len + 1];
14594 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
14595 : :
14596 [ # # ]: 0 : memcpy(cipher_key, reference->cipher_key.data,
14597 : : reference->cipher_key.len);
14598 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14599 : :
14600 : : /* Setup Authentication Parameters */
14601 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14602 : 0 : ut_params->auth_xform.auth.op = auth_op;
14603 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
14604 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14605 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
14606 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
14607 : :
14608 [ # # ]: 0 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
14609 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14610 : 0 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
14611 : : } else {
14612 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
14613 : :
14614 : : /* Setup Cipher Parameters */
14615 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14616 : 0 : ut_params->cipher_xform.next = NULL;
14617 : 0 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14618 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
14619 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
14620 : 0 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14621 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14622 : 0 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14623 : : }
14624 : :
14625 : : /* Create Crypto session*/
14626 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14627 : : &ut_params->auth_xform,
14628 : : ts_params->session_mpool);
14629 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14630 : 0 : return TEST_SKIPPED;
14631 : :
14632 : : return 0;
14633 : : }
14634 : :
14635 : : static int
14636 : 0 : create_auth_operation(struct crypto_testsuite_params *ts_params,
14637 : : struct crypto_unittest_params *ut_params,
14638 : : const struct test_crypto_vector *reference,
14639 : : unsigned int auth_generate)
14640 : : {
14641 : : /* Generate Crypto op data structure */
14642 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14643 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14644 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14645 : : "Failed to allocate pktmbuf offload");
14646 : :
14647 : : /* Set crypto operation data parameters */
14648 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14649 : :
14650 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14651 : :
14652 : : /* set crypto operation source mbuf */
14653 : 0 : sym_op->m_src = ut_params->ibuf;
14654 : :
14655 : : /* digest */
14656 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14657 : 0 : ut_params->ibuf, reference->digest.len);
14658 : :
14659 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14660 : : "no room to append auth tag");
14661 : :
14662 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14663 : : ut_params->ibuf, reference->plaintext.len);
14664 : :
14665 [ # # ]: 0 : if (auth_generate)
14666 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
14667 : : else
14668 : 0 : memcpy(sym_op->auth.digest.data,
14669 : 0 : reference->digest.data,
14670 : 0 : reference->digest.len);
14671 : :
14672 : 0 : debug_hexdump(stdout, "digest:",
14673 : 0 : sym_op->auth.digest.data,
14674 : 0 : reference->digest.len);
14675 : :
14676 : 0 : sym_op->auth.data.length = reference->plaintext.len;
14677 : 0 : sym_op->auth.data.offset = 0;
14678 : :
14679 : 0 : return 0;
14680 : : }
14681 : :
14682 : : static int
14683 : 0 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
14684 : : struct crypto_unittest_params *ut_params,
14685 : : const struct test_crypto_vector *reference,
14686 : : unsigned int auth_generate)
14687 : : {
14688 : : /* Generate Crypto op data structure */
14689 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14690 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14691 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14692 : : "Failed to allocate pktmbuf offload");
14693 : :
14694 : : /* Set crypto operation data parameters */
14695 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14696 : :
14697 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14698 : :
14699 : : /* set crypto operation source mbuf */
14700 : 0 : sym_op->m_src = ut_params->ibuf;
14701 : :
14702 : : /* digest */
14703 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14704 : 0 : ut_params->ibuf, reference->digest.len);
14705 : :
14706 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14707 : : "no room to append auth tag");
14708 : :
14709 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14710 : : ut_params->ibuf, reference->ciphertext.len);
14711 : :
14712 [ # # ]: 0 : if (auth_generate)
14713 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
14714 : : else
14715 : 0 : memcpy(sym_op->auth.digest.data,
14716 : 0 : reference->digest.data,
14717 : 0 : reference->digest.len);
14718 : :
14719 : 0 : debug_hexdump(stdout, "digest:",
14720 : 0 : sym_op->auth.digest.data,
14721 : 0 : reference->digest.len);
14722 : :
14723 : 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
14724 [ # # ]: 0 : reference->iv.data, reference->iv.len);
14725 : :
14726 : 0 : sym_op->cipher.data.length = 0;
14727 : 0 : sym_op->cipher.data.offset = 0;
14728 : :
14729 : 0 : sym_op->auth.data.length = reference->plaintext.len;
14730 : 0 : sym_op->auth.data.offset = 0;
14731 : :
14732 : 0 : return 0;
14733 : : }
14734 : :
14735 : : static int
14736 : 0 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
14737 : : struct crypto_unittest_params *ut_params,
14738 : : const struct test_crypto_vector *reference,
14739 : : unsigned int auth_generate)
14740 : : {
14741 : : /* Generate Crypto op data structure */
14742 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14743 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14744 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14745 : : "Failed to allocate pktmbuf offload");
14746 : :
14747 : : /* Set crypto operation data parameters */
14748 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14749 : :
14750 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14751 : :
14752 : : /* set crypto operation source mbuf */
14753 : 0 : sym_op->m_src = ut_params->ibuf;
14754 : :
14755 : : /* digest */
14756 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14757 : 0 : ut_params->ibuf, reference->digest.len);
14758 : :
14759 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14760 : : "no room to append auth tag");
14761 : :
14762 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14763 : : ut_params->ibuf, reference->ciphertext.len);
14764 : :
14765 [ # # ]: 0 : if (auth_generate)
14766 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
14767 : : else
14768 : 0 : memcpy(sym_op->auth.digest.data,
14769 : 0 : reference->digest.data,
14770 : 0 : reference->digest.len);
14771 : :
14772 : 0 : debug_hexdump(stdout, "digest:",
14773 : 0 : sym_op->auth.digest.data,
14774 : 0 : reference->digest.len);
14775 : :
14776 : 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
14777 [ # # ]: 0 : reference->iv.data, reference->iv.len);
14778 : :
14779 : 0 : sym_op->cipher.data.length = reference->cipher_len;
14780 : 0 : sym_op->cipher.data.offset = reference->cipher_offset;
14781 : :
14782 : 0 : sym_op->auth.data.length = reference->plaintext.len;
14783 : 0 : sym_op->auth.data.offset = reference->auth_offset;
14784 : :
14785 : 0 : return 0;
14786 : : }
14787 : :
14788 : : static int
14789 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
14790 : : struct crypto_unittest_params *ut_params,
14791 : : const struct test_crypto_vector *reference)
14792 : : {
14793 : 0 : return create_auth_operation(ts_params, ut_params, reference, 0);
14794 : : }
14795 : :
14796 : : static int
14797 : : create_auth_verify_GMAC_operation(
14798 : : struct crypto_testsuite_params *ts_params,
14799 : : struct crypto_unittest_params *ut_params,
14800 : : const struct test_crypto_vector *reference)
14801 : : {
14802 : 0 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
14803 : : }
14804 : :
14805 : : static int
14806 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
14807 : : struct crypto_unittest_params *ut_params,
14808 : : const struct test_crypto_vector *reference)
14809 : : {
14810 : 0 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
14811 : : }
14812 : :
14813 : : static int
14814 : 0 : test_authentication_verify_fail_when_data_corruption(
14815 : : struct crypto_testsuite_params *ts_params,
14816 : : struct crypto_unittest_params *ut_params,
14817 : : const struct test_crypto_vector *reference,
14818 : : unsigned int data_corrupted)
14819 : : {
14820 : : int retval;
14821 : :
14822 : : uint8_t *plaintext;
14823 : : struct rte_cryptodev_info dev_info;
14824 : :
14825 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14826 : 0 : uint64_t feat_flags = dev_info.feature_flags;
14827 : :
14828 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14829 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14830 : : printf("Device doesn't support RAW data-path APIs.\n");
14831 : 0 : return TEST_SKIPPED;
14832 : : }
14833 : :
14834 : : /* Verify the capabilities */
14835 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14836 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14837 : 0 : cap_idx.algo.auth = reference->auth_algo;
14838 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14839 : : &cap_idx) == NULL)
14840 : : return TEST_SKIPPED;
14841 : :
14842 : :
14843 : : /* Create session */
14844 : 0 : retval = create_auth_session(ut_params,
14845 : 0 : ts_params->valid_devs[0],
14846 : : reference,
14847 : : RTE_CRYPTO_AUTH_OP_VERIFY);
14848 : :
14849 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14850 : : return TEST_SKIPPED;
14851 [ # # ]: 0 : if (retval < 0)
14852 : : return retval;
14853 : :
14854 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14855 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14856 : : "Failed to allocate input buffer in mempool");
14857 : :
14858 : : /* clear mbuf payload */
14859 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14860 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14861 : :
14862 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14863 : 0 : reference->plaintext.len);
14864 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14865 : 0 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14866 : :
14867 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
14868 : 0 : reference->plaintext.len);
14869 : :
14870 : : /* Create operation */
14871 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
14872 : :
14873 [ # # ]: 0 : if (retval < 0)
14874 : : return retval;
14875 : :
14876 [ # # ]: 0 : if (data_corrupted)
14877 : : data_corruption(plaintext);
14878 : : else
14879 : 0 : tag_corruption(plaintext, reference->plaintext.len);
14880 : :
14881 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
14882 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14883 : : ut_params->op);
14884 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
14885 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14886 : : "authentication not failed");
14887 [ # # ]: 0 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14888 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14889 : : 0);
14890 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14891 : : return retval;
14892 : : } else {
14893 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14894 : : ut_params->op);
14895 : : }
14896 [ # # ]: 0 : if (ut_params->op == NULL)
14897 : : return 0;
14898 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
14899 : 0 : return 0;
14900 : :
14901 : : return -1;
14902 : : }
14903 : :
14904 : : static int
14905 : 0 : test_authentication_verify_GMAC_fail_when_corruption(
14906 : : struct crypto_testsuite_params *ts_params,
14907 : : struct crypto_unittest_params *ut_params,
14908 : : const struct test_crypto_vector *reference,
14909 : : unsigned int data_corrupted)
14910 : : {
14911 : : int retval;
14912 : : uint8_t *plaintext;
14913 : : struct rte_cryptodev_info dev_info;
14914 : :
14915 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14916 : 0 : uint64_t feat_flags = dev_info.feature_flags;
14917 : :
14918 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14919 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14920 : : printf("Device doesn't support RAW data-path APIs.\n");
14921 : 0 : return TEST_SKIPPED;
14922 : : }
14923 : :
14924 : : /* Verify the capabilities */
14925 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14926 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14927 : 0 : cap_idx.algo.auth = reference->auth_algo;
14928 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14929 : : &cap_idx) == NULL)
14930 : : return TEST_SKIPPED;
14931 : :
14932 : : /* Create session */
14933 : 0 : retval = create_auth_cipher_session(ut_params,
14934 : 0 : ts_params->valid_devs[0],
14935 : : reference,
14936 : : RTE_CRYPTO_AUTH_OP_VERIFY,
14937 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
14938 [ # # ]: 0 : if (retval == TEST_SKIPPED)
14939 : : return TEST_SKIPPED;
14940 [ # # ]: 0 : if (retval < 0)
14941 : : return retval;
14942 : :
14943 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14944 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14945 : : "Failed to allocate input buffer in mempool");
14946 : :
14947 : : /* clear mbuf payload */
14948 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14949 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14950 : :
14951 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14952 : 0 : reference->plaintext.len);
14953 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14954 : 0 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14955 : :
14956 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
14957 : 0 : reference->plaintext.len);
14958 : :
14959 : : /* Create operation */
14960 : : retval = create_auth_verify_GMAC_operation(ts_params,
14961 : : ut_params,
14962 : : reference);
14963 : :
14964 [ # # ]: 0 : if (retval < 0)
14965 : : return retval;
14966 : :
14967 [ # # ]: 0 : if (data_corrupted)
14968 : : data_corruption(plaintext);
14969 : : else
14970 : 0 : tag_corruption(plaintext, reference->aad.len);
14971 : :
14972 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
14973 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14974 : : ut_params->op);
14975 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
14976 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
14977 : : "authentication not failed");
14978 [ # # ]: 0 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14979 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14980 : : 0);
14981 [ # # ]: 0 : if (retval != TEST_SUCCESS)
14982 : 0 : return retval;
14983 : : } else {
14984 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14985 : : ut_params->op);
14986 [ # # ]: 0 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
14987 : : }
14988 : :
14989 : : return 0;
14990 : : }
14991 : :
14992 : : static int
14993 : 0 : test_authenticated_decryption_fail_when_corruption(
14994 : : struct crypto_testsuite_params *ts_params,
14995 : : struct crypto_unittest_params *ut_params,
14996 : : const struct test_crypto_vector *reference,
14997 : : unsigned int data_corrupted)
14998 : : {
14999 : : int retval;
15000 : :
15001 : : uint8_t *ciphertext;
15002 : : struct rte_cryptodev_info dev_info;
15003 : :
15004 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15005 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15006 : :
15007 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15008 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15009 : : printf("Device doesn't support RAW data-path APIs.\n");
15010 : 0 : return TEST_SKIPPED;
15011 : : }
15012 : :
15013 : : /* Verify the capabilities */
15014 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15015 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15016 : 0 : cap_idx.algo.auth = reference->auth_algo;
15017 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15018 : : &cap_idx) == NULL)
15019 : : return TEST_SKIPPED;
15020 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15021 : 0 : cap_idx.algo.cipher = reference->crypto_algo;
15022 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15023 : : &cap_idx) == NULL)
15024 : : return TEST_SKIPPED;
15025 : :
15026 : : /* Create session */
15027 : 0 : retval = create_auth_cipher_session(ut_params,
15028 : 0 : ts_params->valid_devs[0],
15029 : : reference,
15030 : : RTE_CRYPTO_AUTH_OP_VERIFY,
15031 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
15032 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15033 : : return TEST_SKIPPED;
15034 [ # # ]: 0 : if (retval < 0)
15035 : : return retval;
15036 : :
15037 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15038 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15039 : : "Failed to allocate input buffer in mempool");
15040 : :
15041 : : /* clear mbuf payload */
15042 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15043 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15044 : :
15045 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15046 : 0 : reference->ciphertext.len);
15047 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15048 : 0 : memcpy(ciphertext, reference->ciphertext.data,
15049 : 0 : reference->ciphertext.len);
15050 : :
15051 : : /* Create operation */
15052 : : retval = create_cipher_auth_verify_operation(ts_params,
15053 : : ut_params,
15054 : : reference);
15055 : :
15056 [ # # ]: 0 : if (retval < 0)
15057 : : return retval;
15058 : :
15059 [ # # ]: 0 : if (data_corrupted)
15060 : : data_corruption(ciphertext);
15061 : : else
15062 : 0 : tag_corruption(ciphertext, reference->ciphertext.len);
15063 : :
15064 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15065 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15066 : : ut_params->op);
15067 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15068 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15069 : : "authentication not failed");
15070 [ # # ]: 0 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15071 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15072 : : 0);
15073 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15074 : 0 : return retval;
15075 : : } else {
15076 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15077 : : ut_params->op);
15078 [ # # ]: 0 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15079 : : }
15080 : :
15081 : : return 0;
15082 : : }
15083 : :
15084 : : static int
15085 : 0 : test_authenticated_encrypt_with_esn(
15086 : : struct crypto_testsuite_params *ts_params,
15087 : : struct crypto_unittest_params *ut_params,
15088 : : const struct test_crypto_vector *reference)
15089 : 0 : {
15090 : : int retval;
15091 : :
15092 : : uint8_t *authciphertext, *plaintext, *auth_tag;
15093 : : uint16_t plaintext_pad_len;
15094 : 0 : uint8_t cipher_key[reference->cipher_key.len + 1];
15095 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
15096 : : struct rte_cryptodev_info dev_info;
15097 : :
15098 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15099 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15100 : :
15101 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15102 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15103 : : printf("Device doesn't support RAW data-path APIs.\n");
15104 : 0 : return TEST_SKIPPED;
15105 : : }
15106 : :
15107 : : /* Verify the capabilities */
15108 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15109 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15110 : 0 : cap_idx.algo.auth = reference->auth_algo;
15111 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15112 : : &cap_idx) == NULL)
15113 : : return TEST_SKIPPED;
15114 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15115 : 0 : cap_idx.algo.cipher = reference->crypto_algo;
15116 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15117 : : &cap_idx) == NULL)
15118 : : return TEST_SKIPPED;
15119 : :
15120 : : /* Create session */
15121 : 0 : memcpy(cipher_key, reference->cipher_key.data,
15122 : 0 : reference->cipher_key.len);
15123 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15124 : :
15125 : : /* Setup Cipher Parameters */
15126 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15127 : 0 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15128 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15129 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
15130 : 0 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15131 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15132 : 0 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15133 : :
15134 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
15135 : :
15136 : : /* Setup Authentication Parameters */
15137 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15138 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15139 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15140 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15141 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
15142 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15143 : 0 : ut_params->auth_xform.next = NULL;
15144 : :
15145 : : /* Create Crypto session*/
15146 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15147 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
15148 : : ts_params->session_mpool);
15149 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15150 : : return TEST_SKIPPED;
15151 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15152 : :
15153 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15154 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15155 : : "Failed to allocate input buffer in mempool");
15156 : :
15157 : : /* clear mbuf payload */
15158 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15159 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15160 : :
15161 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15162 : 0 : reference->plaintext.len);
15163 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15164 : 0 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15165 : :
15166 : : /* Create operation */
15167 : 0 : retval = create_cipher_auth_operation(ts_params,
15168 : : ut_params,
15169 : : reference, 0);
15170 : :
15171 [ # # ]: 0 : if (retval < 0)
15172 : : return retval;
15173 : :
15174 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15175 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15176 : : ut_params->op);
15177 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15178 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15179 : : 0);
15180 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15181 : : return retval;
15182 : : } else
15183 : 0 : ut_params->op = process_crypto_request(
15184 : 0 : ts_params->valid_devs[0], ut_params->op);
15185 : :
15186 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
15187 : :
15188 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15189 : : "crypto op processing failed");
15190 : :
15191 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
15192 : :
15193 : 0 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
15194 : : ut_params->op->sym->auth.data.offset);
15195 : 0 : auth_tag = authciphertext + plaintext_pad_len;
15196 : 0 : debug_hexdump(stdout, "ciphertext:", authciphertext,
15197 : 0 : reference->ciphertext.len);
15198 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
15199 : :
15200 : : /* Validate obuf */
15201 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15202 : : authciphertext,
15203 : : reference->ciphertext.data,
15204 : : reference->ciphertext.len,
15205 : : "Ciphertext data not as expected");
15206 : :
15207 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15208 : : auth_tag,
15209 : : reference->digest.data,
15210 : : reference->digest.len,
15211 : : "Generated digest not as expected");
15212 : :
15213 : : return TEST_SUCCESS;
15214 : :
15215 : : }
15216 : :
15217 : : static int
15218 : 0 : test_authenticated_decrypt_with_esn(
15219 : : struct crypto_testsuite_params *ts_params,
15220 : : struct crypto_unittest_params *ut_params,
15221 : : const struct test_crypto_vector *reference)
15222 : 0 : {
15223 : : int retval;
15224 : :
15225 : : uint8_t *ciphertext;
15226 : 0 : uint8_t cipher_key[reference->cipher_key.len + 1];
15227 : 0 : uint8_t auth_key[reference->auth_key.len + 1];
15228 : : struct rte_cryptodev_info dev_info;
15229 : :
15230 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15231 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15232 : :
15233 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15234 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15235 : : printf("Device doesn't support RAW data-path APIs.\n");
15236 : 0 : return TEST_SKIPPED;
15237 : : }
15238 : :
15239 : : /* Verify the capabilities */
15240 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15241 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15242 : 0 : cap_idx.algo.auth = reference->auth_algo;
15243 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15244 : : &cap_idx) == NULL)
15245 : : return TEST_SKIPPED;
15246 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15247 : 0 : cap_idx.algo.cipher = reference->crypto_algo;
15248 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15249 : : &cap_idx) == NULL)
15250 : : return TEST_SKIPPED;
15251 : :
15252 : : /* Create session */
15253 : 0 : memcpy(cipher_key, reference->cipher_key.data,
15254 : 0 : reference->cipher_key.len);
15255 : 0 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15256 : :
15257 : : /* Setup Authentication Parameters */
15258 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15259 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
15260 : 0 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15261 : 0 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15262 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
15263 : 0 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15264 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
15265 : :
15266 : : /* Setup Cipher Parameters */
15267 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15268 : 0 : ut_params->cipher_xform.next = NULL;
15269 : 0 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15270 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
15271 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
15272 : 0 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15273 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15274 : 0 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15275 : :
15276 : : /* Create Crypto session*/
15277 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
15278 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
15279 : : ts_params->session_mpool);
15280 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15281 : : return TEST_SKIPPED;
15282 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15283 : :
15284 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15285 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15286 : : "Failed to allocate input buffer in mempool");
15287 : :
15288 : : /* clear mbuf payload */
15289 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15290 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15291 : :
15292 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15293 : 0 : reference->ciphertext.len);
15294 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15295 : 0 : memcpy(ciphertext, reference->ciphertext.data,
15296 : 0 : reference->ciphertext.len);
15297 : :
15298 : : /* Create operation */
15299 : : retval = create_cipher_auth_verify_operation(ts_params,
15300 : : ut_params,
15301 : : reference);
15302 : :
15303 [ # # ]: 0 : if (retval < 0)
15304 : : return retval;
15305 : :
15306 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15307 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15308 : : ut_params->op);
15309 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15310 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15311 : : 0);
15312 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15313 : : return retval;
15314 : : } else
15315 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15316 : : ut_params->op);
15317 : :
15318 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
15319 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status,
15320 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15321 : : "crypto op processing passed");
15322 : :
15323 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
15324 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
15325 : :
15326 : : return 0;
15327 : : }
15328 : :
15329 : : static int
15330 : 0 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
15331 : : const struct aead_test_data *tdata,
15332 : : void *digest_mem, uint64_t digest_phys)
15333 : : {
15334 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15335 : : struct crypto_unittest_params *ut_params = &unittest_params;
15336 : :
15337 : 0 : const unsigned int auth_tag_len = tdata->auth_tag.len;
15338 : 0 : const unsigned int iv_len = tdata->iv.len;
15339 : 0 : unsigned int aad_len = tdata->aad.len;
15340 : : unsigned int aad_len_pad = 0;
15341 : :
15342 : : /* Generate Crypto op data structure */
15343 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15344 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15345 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
15346 : : "Failed to allocate symmetric crypto operation struct");
15347 : :
15348 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15349 : :
15350 : 0 : sym_op->aead.digest.data = digest_mem;
15351 : :
15352 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
15353 : : "no room to append digest");
15354 : :
15355 : 0 : sym_op->aead.digest.phys_addr = digest_phys;
15356 : :
15357 [ # # ]: 0 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
15358 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
15359 : : auth_tag_len);
15360 : 0 : debug_hexdump(stdout, "digest:",
15361 : 0 : sym_op->aead.digest.data,
15362 : : auth_tag_len);
15363 : : }
15364 : :
15365 : : /* Append aad data */
15366 [ # # ]: 0 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
15367 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15368 : : uint8_t *, IV_OFFSET);
15369 : :
15370 : : /* Copy IV 1 byte after the IV pointer, according to the API */
15371 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
15372 : :
15373 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
15374 : :
15375 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15376 : : ut_params->ibuf, aad_len);
15377 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15378 : : "no room to prepend aad");
15379 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15380 : : ut_params->ibuf);
15381 : :
15382 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
15383 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
15384 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15385 : :
15386 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15387 : 0 : debug_hexdump(stdout, "aad:",
15388 : 0 : sym_op->aead.aad.data, aad_len);
15389 : : } else {
15390 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15391 : : uint8_t *, IV_OFFSET);
15392 : :
15393 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
15394 : :
15395 : 0 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
15396 : :
15397 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15398 : : ut_params->ibuf, aad_len_pad);
15399 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15400 : : "no room to prepend aad");
15401 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15402 : : ut_params->ibuf);
15403 : :
15404 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
15405 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15406 : :
15407 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15408 : 0 : debug_hexdump(stdout, "aad:",
15409 : 0 : sym_op->aead.aad.data, aad_len);
15410 : : }
15411 : :
15412 : 0 : sym_op->aead.data.length = tdata->plaintext.len;
15413 : 0 : sym_op->aead.data.offset = aad_len_pad;
15414 : :
15415 : 0 : return 0;
15416 : : }
15417 : :
15418 : : #define SGL_MAX_NO 16
15419 : :
15420 : : static int
15421 : 0 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
15422 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
15423 : : {
15424 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15425 : : struct crypto_unittest_params *ut_params = &unittest_params;
15426 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
15427 : : int retval;
15428 : : int to_trn = 0;
15429 : : int to_trn_tbl[SGL_MAX_NO];
15430 : : int segs = 1;
15431 : : unsigned int trn_data = 0;
15432 : : uint8_t *plaintext, *ciphertext, *auth_tag;
15433 : : struct rte_cryptodev_info dev_info;
15434 : :
15435 : : /* Verify the capabilities */
15436 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15437 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
15438 : 0 : cap_idx.algo.aead = tdata->algo;
15439 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15440 : : &cap_idx) == NULL)
15441 : : return TEST_SKIPPED;
15442 : :
15443 : : /*
15444 : : * SGL not supported on AESNI_MB PMD CPU crypto,
15445 : : * OOP not supported on AESNI_GCM CPU crypto
15446 : : */
15447 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
15448 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
15449 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
15450 : : return TEST_SKIPPED;
15451 : :
15452 : : /* Detailed check for the particular SGL support flag */
15453 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15454 [ # # ]: 0 : if (!oop) {
15455 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
15456 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
15457 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
15458 : : return TEST_SKIPPED;
15459 : :
15460 : 0 : uint64_t feat_flags = dev_info.feature_flags;
15461 : :
15462 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15463 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15464 : : printf("Device doesn't support RAW data-path APIs.\n");
15465 : 0 : return TEST_SKIPPED;
15466 : : }
15467 : : } else {
15468 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
15469 [ # # ]: 0 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
15470 : : tdata->plaintext.len;
15471 : : /* Raw data path API does not support OOP */
15472 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
15473 : : return TEST_SKIPPED;
15474 [ # # ]: 0 : if (sgl_in && !sgl_out) {
15475 [ # # ]: 0 : if (!(dev_info.feature_flags &
15476 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
15477 : : return TEST_SKIPPED;
15478 [ # # ]: 0 : } else if (!sgl_in && sgl_out) {
15479 [ # # ]: 0 : if (!(dev_info.feature_flags &
15480 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
15481 : : return TEST_SKIPPED;
15482 [ # # ]: 0 : } else if (sgl_in && sgl_out) {
15483 [ # # ]: 0 : if (!(dev_info.feature_flags &
15484 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
15485 : : return TEST_SKIPPED;
15486 : : }
15487 : : }
15488 : :
15489 : 0 : if (fragsz > tdata->plaintext.len)
15490 : : fragsz = tdata->plaintext.len;
15491 : :
15492 : 0 : uint16_t plaintext_len = fragsz;
15493 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
15494 : :
15495 [ # # ]: 0 : if (fragsz_oop > tdata->plaintext.len)
15496 : 0 : frag_size_oop = tdata->plaintext.len;
15497 : :
15498 : : int ecx = 0;
15499 : : void *digest_mem = NULL;
15500 : :
15501 : 0 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
15502 : :
15503 [ # # ]: 0 : if (tdata->plaintext.len % fragsz != 0) {
15504 [ # # ]: 0 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
15505 : : return 1;
15506 : : } else {
15507 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
15508 : : return 1;
15509 : : }
15510 : :
15511 : : /*
15512 : : * For out-op-place we need to alloc another mbuf
15513 : : */
15514 [ # # ]: 0 : if (oop) {
15515 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15516 : : rte_pktmbuf_append(ut_params->obuf,
15517 : 0 : frag_size_oop + prepend_len);
15518 : 0 : buf_oop = ut_params->obuf;
15519 : : }
15520 : :
15521 : : /* Create AEAD session */
15522 : 0 : retval = create_aead_session(ts_params->valid_devs[0],
15523 : 0 : tdata->algo,
15524 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
15525 : 0 : tdata->key.data, tdata->key.len,
15526 : 0 : tdata->aad.len, tdata->auth_tag.len,
15527 : 0 : tdata->iv.len);
15528 [ # # ]: 0 : if (retval < 0)
15529 : : return retval;
15530 : :
15531 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15532 : :
15533 : : /* clear mbuf payload */
15534 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15535 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15536 : :
15537 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15538 : : plaintext_len);
15539 : :
15540 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15541 : :
15542 : : trn_data += plaintext_len;
15543 : :
15544 : 0 : buf = ut_params->ibuf;
15545 : :
15546 : : /*
15547 : : * Loop until no more fragments
15548 : : */
15549 : :
15550 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15551 : 0 : ++segs;
15552 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15553 : 0 : (tdata->plaintext.len - trn_data) : fragsz;
15554 : :
15555 : 0 : to_trn_tbl[ecx++] = to_trn;
15556 : :
15557 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15558 : : buf = buf->next;
15559 : :
15560 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15561 : : rte_pktmbuf_tailroom(buf));
15562 : :
15563 : : /* OOP */
15564 [ # # ]: 0 : if (oop && !fragsz_oop) {
15565 : 0 : buf_last_oop = buf_oop->next =
15566 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
15567 : : buf_oop = buf_oop->next;
15568 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15569 : : 0, rte_pktmbuf_tailroom(buf_oop));
15570 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
15571 : : }
15572 : :
15573 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15574 : : to_trn);
15575 : :
15576 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15577 : : to_trn);
15578 : 0 : trn_data += to_trn;
15579 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15580 [ # # ]: 0 : if (oop) {
15581 [ # # ]: 0 : if (!fragsz_oop)
15582 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
15583 : 0 : tdata->auth_tag.len);
15584 : : } else
15585 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15586 : 0 : tdata->auth_tag.len);
15587 : : }
15588 : : }
15589 : :
15590 : : uint64_t digest_phys = 0;
15591 : :
15592 : 0 : ut_params->ibuf->nb_segs = segs;
15593 : :
15594 : : segs = 1;
15595 [ # # ]: 0 : if (fragsz_oop && oop) {
15596 : : to_trn = 0;
15597 : : ecx = 0;
15598 : :
15599 [ # # ]: 0 : if (frag_size_oop == tdata->plaintext.len) {
15600 : 0 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
15601 : 0 : tdata->auth_tag.len);
15602 : :
15603 : 0 : digest_phys = rte_pktmbuf_iova_offset(
15604 : : ut_params->obuf,
15605 : : tdata->plaintext.len + prepend_len);
15606 : : }
15607 : :
15608 : : trn_data = frag_size_oop;
15609 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15610 : 0 : ++segs;
15611 : 0 : to_trn =
15612 : 0 : (tdata->plaintext.len - trn_data <
15613 : : frag_size_oop) ?
15614 : 0 : (tdata->plaintext.len - trn_data) :
15615 : : frag_size_oop;
15616 : :
15617 : 0 : to_trn_tbl[ecx++] = to_trn;
15618 : :
15619 : 0 : buf_last_oop = buf_oop->next =
15620 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
15621 : : buf_oop = buf_oop->next;
15622 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15623 : : 0, rte_pktmbuf_tailroom(buf_oop));
15624 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
15625 : :
15626 : 0 : trn_data += to_trn;
15627 : :
15628 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
15629 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
15630 : 0 : tdata->auth_tag.len);
15631 : : }
15632 : : }
15633 : :
15634 : 0 : ut_params->obuf->nb_segs = segs;
15635 : : }
15636 : :
15637 : : /*
15638 : : * Place digest at the end of the last buffer
15639 : : */
15640 [ # # ]: 0 : if (!digest_phys)
15641 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15642 [ # # ]: 0 : if (oop && buf_last_oop)
15643 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
15644 : :
15645 [ # # ]: 0 : if (!digest_mem && !oop) {
15646 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15647 : 0 : + tdata->auth_tag.len);
15648 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15649 : : tdata->plaintext.len);
15650 : : }
15651 : :
15652 : : /* Create AEAD operation */
15653 : 0 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
15654 : : tdata, digest_mem, digest_phys);
15655 : :
15656 [ # # ]: 0 : if (retval < 0)
15657 : : return retval;
15658 : :
15659 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15660 : :
15661 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15662 [ # # ]: 0 : if (oop)
15663 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
15664 : :
15665 : : /* Process crypto operation */
15666 [ # # ]: 0 : if (oop == IN_PLACE &&
15667 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15668 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
15669 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15670 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
15671 : : 0);
15672 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15673 : : return retval;
15674 : : } else
15675 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15676 : : process_crypto_request(ts_params->valid_devs[0],
15677 : : ut_params->op), "failed to process sym crypto op");
15678 : :
15679 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15680 : : "crypto op processing failed");
15681 : :
15682 : :
15683 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
15684 : : uint8_t *, prepend_len);
15685 [ # # ]: 0 : if (oop) {
15686 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15687 : : uint8_t *, prepend_len);
15688 : : }
15689 : :
15690 [ # # ]: 0 : if (fragsz_oop)
15691 : : fragsz = fragsz_oop;
15692 : :
15693 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15694 : : ciphertext,
15695 : : tdata->ciphertext.data,
15696 : : fragsz,
15697 : : "Ciphertext data not as expected");
15698 : :
15699 : 0 : buf = ut_params->op->sym->m_src->next;
15700 [ # # ]: 0 : if (oop)
15701 : 0 : buf = ut_params->op->sym->m_dst->next;
15702 : :
15703 : : unsigned int off = fragsz;
15704 : :
15705 : : ecx = 0;
15706 [ # # ]: 0 : while (buf) {
15707 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
15708 : : uint8_t *);
15709 : :
15710 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15711 : : ciphertext,
15712 : : tdata->ciphertext.data + off,
15713 : : to_trn_tbl[ecx],
15714 : : "Ciphertext data not as expected");
15715 : :
15716 : 0 : off += to_trn_tbl[ecx++];
15717 : 0 : buf = buf->next;
15718 : : }
15719 : :
15720 : : auth_tag = digest_mem;
15721 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15722 : : auth_tag,
15723 : : tdata->auth_tag.data,
15724 : : tdata->auth_tag.len,
15725 : : "Generated auth tag not as expected");
15726 : :
15727 : : return 0;
15728 : : }
15729 : :
15730 : : static int
15731 : 0 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
15732 : : {
15733 : 0 : return test_authenticated_encryption_SGL(
15734 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
15735 : : }
15736 : :
15737 : : static int
15738 : 0 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
15739 : : {
15740 : 0 : return test_authenticated_encryption_SGL(
15741 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
15742 : : }
15743 : :
15744 : : static int
15745 : 0 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
15746 : : {
15747 : 0 : return test_authenticated_encryption_SGL(
15748 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
15749 : : gcm_test_case_8.plaintext.len);
15750 : : }
15751 : :
15752 : : static int
15753 : 0 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
15754 : : {
15755 : : /* This test is not for OPENSSL PMD */
15756 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
15757 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
15758 : : return TEST_SKIPPED;
15759 : :
15760 : 0 : return test_authenticated_encryption_SGL(
15761 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
15762 : : }
15763 : :
15764 : : static int
15765 : : test_authentication_verify_fail_when_data_corrupted(
15766 : : struct crypto_testsuite_params *ts_params,
15767 : : struct crypto_unittest_params *ut_params,
15768 : : const struct test_crypto_vector *reference)
15769 : : {
15770 : 0 : return test_authentication_verify_fail_when_data_corruption(
15771 : : ts_params, ut_params, reference, 1);
15772 : : }
15773 : :
15774 : : static int
15775 : : test_authentication_verify_fail_when_tag_corrupted(
15776 : : struct crypto_testsuite_params *ts_params,
15777 : : struct crypto_unittest_params *ut_params,
15778 : : const struct test_crypto_vector *reference)
15779 : : {
15780 : 0 : return test_authentication_verify_fail_when_data_corruption(
15781 : : ts_params, ut_params, reference, 0);
15782 : : }
15783 : :
15784 : : static int
15785 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
15786 : : struct crypto_testsuite_params *ts_params,
15787 : : struct crypto_unittest_params *ut_params,
15788 : : const struct test_crypto_vector *reference)
15789 : : {
15790 : 0 : return test_authentication_verify_GMAC_fail_when_corruption(
15791 : : ts_params, ut_params, reference, 1);
15792 : : }
15793 : :
15794 : : static int
15795 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
15796 : : struct crypto_testsuite_params *ts_params,
15797 : : struct crypto_unittest_params *ut_params,
15798 : : const struct test_crypto_vector *reference)
15799 : : {
15800 : 0 : return test_authentication_verify_GMAC_fail_when_corruption(
15801 : : ts_params, ut_params, reference, 0);
15802 : : }
15803 : :
15804 : : static int
15805 : : test_authenticated_decryption_fail_when_data_corrupted(
15806 : : struct crypto_testsuite_params *ts_params,
15807 : : struct crypto_unittest_params *ut_params,
15808 : : const struct test_crypto_vector *reference)
15809 : : {
15810 : 0 : return test_authenticated_decryption_fail_when_corruption(
15811 : : ts_params, ut_params, reference, 1);
15812 : : }
15813 : :
15814 : : static int
15815 : : test_authenticated_decryption_fail_when_tag_corrupted(
15816 : : struct crypto_testsuite_params *ts_params,
15817 : : struct crypto_unittest_params *ut_params,
15818 : : const struct test_crypto_vector *reference)
15819 : : {
15820 : 0 : return test_authenticated_decryption_fail_when_corruption(
15821 : : ts_params, ut_params, reference, 0);
15822 : : }
15823 : :
15824 : : static int
15825 : 0 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
15826 : : {
15827 : 0 : return test_authentication_verify_fail_when_data_corrupted(
15828 : : &testsuite_params, &unittest_params,
15829 : : &hmac_sha1_test_crypto_vector);
15830 : : }
15831 : :
15832 : : static int
15833 : 0 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
15834 : : {
15835 : 0 : return test_authentication_verify_fail_when_tag_corrupted(
15836 : : &testsuite_params, &unittest_params,
15837 : : &hmac_sha1_test_crypto_vector);
15838 : : }
15839 : :
15840 : : static int
15841 : 0 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
15842 : : {
15843 : 0 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
15844 : : &testsuite_params, &unittest_params,
15845 : : &aes128_gmac_test_vector);
15846 : : }
15847 : :
15848 : : static int
15849 : 0 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
15850 : : {
15851 : 0 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
15852 : : &testsuite_params, &unittest_params,
15853 : : &aes128_gmac_test_vector);
15854 : : }
15855 : :
15856 : : static int
15857 : 0 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
15858 : : {
15859 : 0 : return test_authenticated_decryption_fail_when_data_corrupted(
15860 : : &testsuite_params,
15861 : : &unittest_params,
15862 : : &aes128cbc_hmac_sha1_test_vector);
15863 : : }
15864 : :
15865 : : static int
15866 : 0 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
15867 : : {
15868 : 0 : return test_authenticated_decryption_fail_when_tag_corrupted(
15869 : : &testsuite_params,
15870 : : &unittest_params,
15871 : : &aes128cbc_hmac_sha1_test_vector);
15872 : : }
15873 : :
15874 : : static int
15875 : 0 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
15876 : : {
15877 : 0 : return test_authenticated_encrypt_with_esn(
15878 : : &testsuite_params,
15879 : : &unittest_params,
15880 : : &aes128cbc_hmac_sha1_aad_test_vector);
15881 : : }
15882 : :
15883 : : static int
15884 : 0 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
15885 : : {
15886 : 0 : return test_authenticated_decrypt_with_esn(
15887 : : &testsuite_params,
15888 : : &unittest_params,
15889 : : &aes128cbc_hmac_sha1_aad_test_vector);
15890 : : }
15891 : :
15892 : : static int
15893 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
15894 : : {
15895 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
15896 : : }
15897 : :
15898 : : static int
15899 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
15900 : : {
15901 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
15902 : : }
15903 : :
15904 : : static int
15905 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
15906 : : {
15907 : 0 : return test_authenticated_encryption_SGL(
15908 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
15909 : : chacha20_poly1305_case_2.plaintext.len);
15910 : : }
15911 : :
15912 : : #ifdef RTE_CRYPTO_SCHEDULER
15913 : :
15914 : : /* global AESNI worker IDs for the scheduler test */
15915 : : uint8_t aesni_ids[2];
15916 : :
15917 : : static int
15918 : 0 : scheduler_testsuite_setup(void)
15919 : : {
15920 : : uint32_t i = 0;
15921 : : int32_t nb_devs, ret;
15922 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
15923 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
15924 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
15925 : : uint16_t worker_core_count = 0;
15926 : : uint16_t socket_id = 0;
15927 : :
15928 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
15929 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
15930 : :
15931 : : /* Identify the Worker Cores
15932 : : * Use 2 worker cores for the device args
15933 : : */
15934 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
15935 [ # # ]: 0 : if (worker_core_count > 1)
15936 : : break;
15937 : : snprintf(vdev_args, sizeof(vdev_args),
15938 : : "%s%d", temp_str, i);
15939 : : strcpy(temp_str, vdev_args);
15940 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
15941 : 0 : worker_core_count++;
15942 : 0 : socket_id = rte_lcore_to_socket_id(i);
15943 : : }
15944 [ # # ]: 0 : if (worker_core_count != 2) {
15945 : 0 : RTE_LOG(ERR, USER1,
15946 : : "Cryptodev scheduler test require at least "
15947 : : "two worker cores to run. "
15948 : : "Please use the correct coremask.\n");
15949 : 0 : return TEST_FAILED;
15950 : : }
15951 : : strcpy(temp_str, vdev_args);
15952 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
15953 : : temp_str, socket_id);
15954 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
15955 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
15956 : 0 : rte_cryptodev_driver_id_get(
15957 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
15958 [ # # ]: 0 : if (nb_devs < 1) {
15959 : 0 : ret = rte_vdev_init(
15960 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
15961 : : vdev_args);
15962 [ # # ]: 0 : TEST_ASSERT(ret == 0,
15963 : : "Failed to create instance %u of pmd : %s",
15964 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15965 : : }
15966 : : }
15967 : 0 : return testsuite_setup();
15968 : : }
15969 : :
15970 : : static int
15971 : 0 : test_scheduler_attach_worker_op(void)
15972 : : {
15973 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15974 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
15975 : : uint32_t i, nb_devs_attached = 0;
15976 : : int ret;
15977 : : char vdev_name[32];
15978 : 0 : unsigned int count = rte_cryptodev_count();
15979 : :
15980 : : /* create 2 AESNI_MB vdevs on top of existing devices */
15981 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
15982 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
15983 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
15984 : : i);
15985 : 0 : ret = rte_vdev_init(vdev_name, NULL);
15986 : :
15987 [ # # ]: 0 : TEST_ASSERT(ret == 0,
15988 : : "Failed to create instance %u of"
15989 : : " pmd : %s",
15990 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15991 : :
15992 : : if (ret < 0) {
15993 : : RTE_LOG(ERR, USER1,
15994 : : "Failed to create 2 AESNI MB PMDs.\n");
15995 : : return TEST_SKIPPED;
15996 : : }
15997 : : }
15998 : :
15999 : : /* attach 2 AESNI_MB cdevs */
16000 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
16001 : : struct rte_cryptodev_info info;
16002 : : unsigned int session_size;
16003 : :
16004 : 0 : rte_cryptodev_info_get(i, &info);
16005 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
16006 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
16007 : 0 : continue;
16008 : :
16009 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
16010 : : /*
16011 : : * Create the session mempool again, since now there are new devices
16012 : : * to use the mempool.
16013 : : */
16014 [ # # ]: 0 : if (ts_params->session_mpool) {
16015 : 0 : rte_mempool_free(ts_params->session_mpool);
16016 : 0 : ts_params->session_mpool = NULL;
16017 : : }
16018 : :
16019 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
16020 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
16021 : 0 : RTE_LOG(ERR, USER1,
16022 : : "Device does not support "
16023 : : "at least %u sessions\n",
16024 : : MAX_NB_SESSIONS);
16025 : 0 : return TEST_FAILED;
16026 : : }
16027 : : /*
16028 : : * Create mempool with maximum number of sessions,
16029 : : * to include the session headers
16030 : : */
16031 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
16032 : 0 : ts_params->session_mpool =
16033 : 0 : rte_cryptodev_sym_session_pool_create(
16034 : : "test_sess_mp",
16035 : : MAX_NB_SESSIONS, session_size,
16036 : : 0, 0, SOCKET_ID_ANY);
16037 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
16038 : : "session mempool allocation failed");
16039 : : }
16040 : :
16041 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
16042 : :
16043 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
16044 : : (uint8_t)i);
16045 : :
16046 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16047 : : "Failed to attach device %u of pmd : %s", i,
16048 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16049 : :
16050 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
16051 : :
16052 : 0 : nb_devs_attached++;
16053 : : }
16054 : :
16055 : : return 0;
16056 : : }
16057 : :
16058 : : static int
16059 : 0 : test_scheduler_detach_worker_op(void)
16060 : : {
16061 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16062 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16063 : : uint32_t i;
16064 : : int ret;
16065 : :
16066 [ # # ]: 0 : for (i = 0; i < 2; i++) {
16067 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
16068 : 0 : aesni_ids[i]);
16069 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16070 : : "Failed to detach device %u", aesni_ids[i]);
16071 : : }
16072 : :
16073 : : return 0;
16074 : : }
16075 : :
16076 : : static int
16077 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
16078 : : {
16079 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16080 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16081 : : /* set mode */
16082 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
16083 : : scheduler_mode);
16084 : : }
16085 : :
16086 : : static int
16087 : 0 : test_scheduler_mode_roundrobin_op(void)
16088 : : {
16089 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
16090 : : 0, "Failed to set roundrobin mode");
16091 : : return 0;
16092 : :
16093 : : }
16094 : :
16095 : : static int
16096 : 0 : test_scheduler_mode_multicore_op(void)
16097 : : {
16098 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
16099 : : 0, "Failed to set multicore mode");
16100 : :
16101 : : return 0;
16102 : : }
16103 : :
16104 : : static int
16105 : 0 : test_scheduler_mode_failover_op(void)
16106 : : {
16107 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
16108 : : 0, "Failed to set failover mode");
16109 : :
16110 : : return 0;
16111 : : }
16112 : :
16113 : : static int
16114 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
16115 : : {
16116 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
16117 : : 0, "Failed to set pktsize mode");
16118 : :
16119 : : return 0;
16120 : : }
16121 : :
16122 : : static int
16123 : 0 : scheduler_multicore_testsuite_setup(void)
16124 : : {
16125 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16126 : : return TEST_SKIPPED;
16127 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
16128 : 0 : return TEST_SKIPPED;
16129 : : return 0;
16130 : : }
16131 : :
16132 : : static int
16133 : 0 : scheduler_roundrobin_testsuite_setup(void)
16134 : : {
16135 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16136 : : return TEST_SKIPPED;
16137 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
16138 : 0 : return TEST_SKIPPED;
16139 : : return 0;
16140 : : }
16141 : :
16142 : : static int
16143 : 0 : scheduler_failover_testsuite_setup(void)
16144 : : {
16145 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16146 : : return TEST_SKIPPED;
16147 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
16148 : 0 : return TEST_SKIPPED;
16149 : : return 0;
16150 : : }
16151 : :
16152 : : static int
16153 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
16154 : : {
16155 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
16156 : : return TEST_SKIPPED;
16157 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
16158 : 0 : return TEST_SKIPPED;
16159 : : return 0;
16160 : : }
16161 : :
16162 : : static void
16163 : 0 : scheduler_mode_testsuite_teardown(void)
16164 : : {
16165 : 0 : test_scheduler_detach_worker_op();
16166 : 0 : }
16167 : :
16168 : : #endif /* RTE_CRYPTO_SCHEDULER */
16169 : :
16170 : : static struct unit_test_suite end_testsuite = {
16171 : : .suite_name = NULL,
16172 : : .setup = NULL,
16173 : : .teardown = NULL,
16174 : : .unit_test_suites = NULL
16175 : : };
16176 : :
16177 : : #ifdef RTE_LIB_SECURITY
16178 : : static struct unit_test_suite ipsec_proto_testsuite = {
16179 : : .suite_name = "IPsec Proto Unit Test Suite",
16180 : : .setup = ipsec_proto_testsuite_setup,
16181 : : .unit_test_cases = {
16182 : : TEST_CASE_NAMED_WITH_DATA(
16183 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16184 : : ut_setup_security, ut_teardown,
16185 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
16186 : : TEST_CASE_NAMED_WITH_DATA(
16187 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
16188 : : ut_setup_security, ut_teardown,
16189 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
16190 : : TEST_CASE_NAMED_WITH_DATA(
16191 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16192 : : ut_setup_security, ut_teardown,
16193 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
16194 : : TEST_CASE_NAMED_WITH_DATA(
16195 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16196 : : ut_setup_security, ut_teardown,
16197 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
16198 : : TEST_CASE_NAMED_WITH_DATA(
16199 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16200 : : ut_setup_security, ut_teardown,
16201 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
16202 : : TEST_CASE_NAMED_WITH_DATA(
16203 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16204 : : ut_setup_security, ut_teardown,
16205 : : test_ipsec_proto_known_vec,
16206 : : &pkt_aes_128_cbc_md5),
16207 : : TEST_CASE_NAMED_WITH_DATA(
16208 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16209 : : ut_setup_security, ut_teardown,
16210 : : test_ipsec_proto_known_vec,
16211 : : &pkt_aes_128_cbc_hmac_sha256),
16212 : : TEST_CASE_NAMED_WITH_DATA(
16213 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16214 : : ut_setup_security, ut_teardown,
16215 : : test_ipsec_proto_known_vec,
16216 : : &pkt_aes_128_cbc_hmac_sha384),
16217 : : TEST_CASE_NAMED_WITH_DATA(
16218 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16219 : : ut_setup_security, ut_teardown,
16220 : : test_ipsec_proto_known_vec,
16221 : : &pkt_aes_128_cbc_hmac_sha512),
16222 : : TEST_CASE_NAMED_WITH_DATA(
16223 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16224 : : ut_setup_security, ut_teardown,
16225 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
16226 : : TEST_CASE_NAMED_WITH_DATA(
16227 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16228 : : ut_setup_security, ut_teardown,
16229 : : test_ipsec_proto_known_vec,
16230 : : &pkt_aes_128_cbc_hmac_sha256_v6),
16231 : : TEST_CASE_NAMED_WITH_DATA(
16232 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16233 : : ut_setup_security, ut_teardown,
16234 : : test_ipsec_proto_known_vec,
16235 : : &pkt_null_aes_xcbc),
16236 : : TEST_CASE_NAMED_WITH_DATA(
16237 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16238 : : ut_setup_security, ut_teardown,
16239 : : test_ipsec_proto_known_vec,
16240 : : &pkt_des_cbc_hmac_sha256),
16241 : : TEST_CASE_NAMED_WITH_DATA(
16242 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16243 : : ut_setup_security, ut_teardown,
16244 : : test_ipsec_proto_known_vec,
16245 : : &pkt_des_cbc_hmac_sha384),
16246 : : TEST_CASE_NAMED_WITH_DATA(
16247 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16248 : : ut_setup_security, ut_teardown,
16249 : : test_ipsec_proto_known_vec,
16250 : : &pkt_des_cbc_hmac_sha512),
16251 : : TEST_CASE_NAMED_WITH_DATA(
16252 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16253 : : ut_setup_security, ut_teardown,
16254 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
16255 : : TEST_CASE_NAMED_WITH_DATA(
16256 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16257 : : ut_setup_security, ut_teardown,
16258 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
16259 : : TEST_CASE_NAMED_WITH_DATA(
16260 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16261 : : ut_setup_security, ut_teardown,
16262 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
16263 : : TEST_CASE_NAMED_WITH_DATA(
16264 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16265 : : ut_setup_security, ut_teardown,
16266 : : test_ipsec_proto_known_vec,
16267 : : &pkt_des_cbc_hmac_sha256_v6),
16268 : : TEST_CASE_NAMED_WITH_DATA(
16269 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16270 : : ut_setup_security, ut_teardown,
16271 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
16272 : : TEST_CASE_NAMED_WITH_DATA(
16273 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16274 : : ut_setup_security, ut_teardown,
16275 : : test_ipsec_proto_known_vec,
16276 : : &pkt_ah_tunnel_sha256),
16277 : : TEST_CASE_NAMED_WITH_DATA(
16278 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16279 : : ut_setup_security, ut_teardown,
16280 : : test_ipsec_proto_known_vec,
16281 : : &pkt_ah_transport_sha256),
16282 : : TEST_CASE_NAMED_WITH_DATA(
16283 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16284 : : ut_setup_security, ut_teardown,
16285 : : test_ipsec_proto_known_vec,
16286 : : &pkt_ah_ipv4_aes_gmac_128),
16287 : : TEST_CASE_NAMED_WITH_DATA(
16288 : : "Outbound fragmented packet",
16289 : : ut_setup_security, ut_teardown,
16290 : : test_ipsec_proto_known_vec_fragmented,
16291 : : &pkt_aes_128_gcm_frag),
16292 : : TEST_CASE_NAMED_WITH_DATA(
16293 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16294 : : ut_setup_security, ut_teardown,
16295 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
16296 : : TEST_CASE_NAMED_WITH_DATA(
16297 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16298 : : ut_setup_security, ut_teardown,
16299 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
16300 : : TEST_CASE_NAMED_WITH_DATA(
16301 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16302 : : ut_setup_security, ut_teardown,
16303 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
16304 : : TEST_CASE_NAMED_WITH_DATA(
16305 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16306 : : ut_setup_security, ut_teardown,
16307 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
16308 : : TEST_CASE_NAMED_WITH_DATA(
16309 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
16310 : : ut_setup_security, ut_teardown,
16311 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
16312 : : TEST_CASE_NAMED_WITH_DATA(
16313 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16314 : : ut_setup_security, ut_teardown,
16315 : : test_ipsec_proto_known_vec_inb,
16316 : : &pkt_aes_128_cbc_md5),
16317 : : TEST_CASE_NAMED_WITH_DATA(
16318 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16319 : : ut_setup_security, ut_teardown,
16320 : : test_ipsec_proto_known_vec_inb,
16321 : : &pkt_aes_128_cbc_hmac_sha256),
16322 : : TEST_CASE_NAMED_WITH_DATA(
16323 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16324 : : ut_setup_security, ut_teardown,
16325 : : test_ipsec_proto_known_vec_inb,
16326 : : &pkt_aes_128_cbc_hmac_sha384),
16327 : : TEST_CASE_NAMED_WITH_DATA(
16328 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16329 : : ut_setup_security, ut_teardown,
16330 : : test_ipsec_proto_known_vec_inb,
16331 : : &pkt_aes_128_cbc_hmac_sha512),
16332 : : TEST_CASE_NAMED_WITH_DATA(
16333 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16334 : : ut_setup_security, ut_teardown,
16335 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
16336 : : TEST_CASE_NAMED_WITH_DATA(
16337 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16338 : : ut_setup_security, ut_teardown,
16339 : : test_ipsec_proto_known_vec_inb,
16340 : : &pkt_aes_128_cbc_hmac_sha256_v6),
16341 : : TEST_CASE_NAMED_WITH_DATA(
16342 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16343 : : ut_setup_security, ut_teardown,
16344 : : test_ipsec_proto_known_vec_inb,
16345 : : &pkt_null_aes_xcbc),
16346 : : TEST_CASE_NAMED_WITH_DATA(
16347 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16348 : : ut_setup_security, ut_teardown,
16349 : : test_ipsec_proto_known_vec_inb,
16350 : : &pkt_des_cbc_hmac_sha256),
16351 : : TEST_CASE_NAMED_WITH_DATA(
16352 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16353 : : ut_setup_security, ut_teardown,
16354 : : test_ipsec_proto_known_vec_inb,
16355 : : &pkt_des_cbc_hmac_sha384),
16356 : : TEST_CASE_NAMED_WITH_DATA(
16357 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16358 : : ut_setup_security, ut_teardown,
16359 : : test_ipsec_proto_known_vec_inb,
16360 : : &pkt_des_cbc_hmac_sha512),
16361 : : TEST_CASE_NAMED_WITH_DATA(
16362 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16363 : : ut_setup_security, ut_teardown,
16364 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
16365 : : TEST_CASE_NAMED_WITH_DATA(
16366 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16367 : : ut_setup_security, ut_teardown,
16368 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
16369 : : TEST_CASE_NAMED_WITH_DATA(
16370 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16371 : : ut_setup_security, ut_teardown,
16372 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
16373 : : TEST_CASE_NAMED_WITH_DATA(
16374 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16375 : : ut_setup_security, ut_teardown,
16376 : : test_ipsec_proto_known_vec_inb,
16377 : : &pkt_des_cbc_hmac_sha256_v6),
16378 : : TEST_CASE_NAMED_WITH_DATA(
16379 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16380 : : ut_setup_security, ut_teardown,
16381 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
16382 : : TEST_CASE_NAMED_WITH_DATA(
16383 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16384 : : ut_setup_security, ut_teardown,
16385 : : test_ipsec_proto_known_vec_inb,
16386 : : &pkt_ah_tunnel_sha256),
16387 : : TEST_CASE_NAMED_WITH_DATA(
16388 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16389 : : ut_setup_security, ut_teardown,
16390 : : test_ipsec_proto_known_vec_inb,
16391 : : &pkt_ah_transport_sha256),
16392 : : TEST_CASE_NAMED_WITH_DATA(
16393 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16394 : : ut_setup_security, ut_teardown,
16395 : : test_ipsec_proto_known_vec_inb,
16396 : : &pkt_ah_ipv4_aes_gmac_128),
16397 : : TEST_CASE_NAMED_ST(
16398 : : "Combined test alg list",
16399 : : ut_setup_security, ut_teardown,
16400 : : test_ipsec_proto_display_list),
16401 : : TEST_CASE_NAMED_ST(
16402 : : "Combined test alg list (AH)",
16403 : : ut_setup_security, ut_teardown,
16404 : : test_ipsec_proto_ah_tunnel_ipv4),
16405 : : TEST_CASE_NAMED_ST(
16406 : : "IV generation",
16407 : : ut_setup_security, ut_teardown,
16408 : : test_ipsec_proto_iv_gen),
16409 : : TEST_CASE_NAMED_ST(
16410 : : "UDP encapsulation",
16411 : : ut_setup_security, ut_teardown,
16412 : : test_ipsec_proto_udp_encap),
16413 : : TEST_CASE_NAMED_ST(
16414 : : "UDP encapsulation with custom ports",
16415 : : ut_setup_security, ut_teardown,
16416 : : test_ipsec_proto_udp_encap_custom_ports),
16417 : : TEST_CASE_NAMED_ST(
16418 : : "UDP encapsulation ports verification test",
16419 : : ut_setup_security, ut_teardown,
16420 : : test_ipsec_proto_udp_ports_verify),
16421 : : TEST_CASE_NAMED_ST(
16422 : : "SA expiry packets soft",
16423 : : ut_setup_security, ut_teardown,
16424 : : test_ipsec_proto_sa_exp_pkts_soft),
16425 : : TEST_CASE_NAMED_ST(
16426 : : "SA expiry packets hard",
16427 : : ut_setup_security, ut_teardown,
16428 : : test_ipsec_proto_sa_exp_pkts_hard),
16429 : : TEST_CASE_NAMED_ST(
16430 : : "Negative test: ICV corruption",
16431 : : ut_setup_security, ut_teardown,
16432 : : test_ipsec_proto_err_icv_corrupt),
16433 : : TEST_CASE_NAMED_ST(
16434 : : "Tunnel dst addr verification",
16435 : : ut_setup_security, ut_teardown,
16436 : : test_ipsec_proto_tunnel_dst_addr_verify),
16437 : : TEST_CASE_NAMED_ST(
16438 : : "Tunnel src and dst addr verification",
16439 : : ut_setup_security, ut_teardown,
16440 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
16441 : : TEST_CASE_NAMED_ST(
16442 : : "Inner IP checksum",
16443 : : ut_setup_security, ut_teardown,
16444 : : test_ipsec_proto_inner_ip_csum),
16445 : : TEST_CASE_NAMED_ST(
16446 : : "Inner L4 checksum",
16447 : : ut_setup_security, ut_teardown,
16448 : : test_ipsec_proto_inner_l4_csum),
16449 : : TEST_CASE_NAMED_ST(
16450 : : "Tunnel IPv4 in IPv4",
16451 : : ut_setup_security, ut_teardown,
16452 : : test_ipsec_proto_tunnel_v4_in_v4),
16453 : : TEST_CASE_NAMED_ST(
16454 : : "Tunnel IPv6 in IPv6",
16455 : : ut_setup_security, ut_teardown,
16456 : : test_ipsec_proto_tunnel_v6_in_v6),
16457 : : TEST_CASE_NAMED_ST(
16458 : : "Tunnel IPv4 in IPv6",
16459 : : ut_setup_security, ut_teardown,
16460 : : test_ipsec_proto_tunnel_v4_in_v6),
16461 : : TEST_CASE_NAMED_ST(
16462 : : "Tunnel IPv6 in IPv4",
16463 : : ut_setup_security, ut_teardown,
16464 : : test_ipsec_proto_tunnel_v6_in_v4),
16465 : : TEST_CASE_NAMED_ST(
16466 : : "Transport IPv4",
16467 : : ut_setup_security, ut_teardown,
16468 : : test_ipsec_proto_transport_v4),
16469 : : TEST_CASE_NAMED_ST(
16470 : : "AH transport IPv4",
16471 : : ut_setup_security, ut_teardown,
16472 : : test_ipsec_proto_ah_transport_ipv4),
16473 : : TEST_CASE_NAMED_ST(
16474 : : "Transport l4 checksum",
16475 : : ut_setup_security, ut_teardown,
16476 : : test_ipsec_proto_transport_l4_csum),
16477 : : TEST_CASE_NAMED_ST(
16478 : : "Statistics: success",
16479 : : ut_setup_security, ut_teardown,
16480 : : test_ipsec_proto_stats),
16481 : : TEST_CASE_NAMED_ST(
16482 : : "Fragmented packet",
16483 : : ut_setup_security, ut_teardown,
16484 : : test_ipsec_proto_pkt_fragment),
16485 : : TEST_CASE_NAMED_ST(
16486 : : "Tunnel header copy DF (inner 0)",
16487 : : ut_setup_security, ut_teardown,
16488 : : test_ipsec_proto_copy_df_inner_0),
16489 : : TEST_CASE_NAMED_ST(
16490 : : "Tunnel header copy DF (inner 1)",
16491 : : ut_setup_security, ut_teardown,
16492 : : test_ipsec_proto_copy_df_inner_1),
16493 : : TEST_CASE_NAMED_ST(
16494 : : "Tunnel header set DF 0 (inner 1)",
16495 : : ut_setup_security, ut_teardown,
16496 : : test_ipsec_proto_set_df_0_inner_1),
16497 : : TEST_CASE_NAMED_ST(
16498 : : "Tunnel header set DF 1 (inner 0)",
16499 : : ut_setup_security, ut_teardown,
16500 : : test_ipsec_proto_set_df_1_inner_0),
16501 : : TEST_CASE_NAMED_ST(
16502 : : "Tunnel header IPv4 copy DSCP (inner 0)",
16503 : : ut_setup_security, ut_teardown,
16504 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
16505 : : TEST_CASE_NAMED_ST(
16506 : : "Tunnel header IPv4 copy DSCP (inner 1)",
16507 : : ut_setup_security, ut_teardown,
16508 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
16509 : : TEST_CASE_NAMED_ST(
16510 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
16511 : : ut_setup_security, ut_teardown,
16512 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
16513 : : TEST_CASE_NAMED_ST(
16514 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
16515 : : ut_setup_security, ut_teardown,
16516 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
16517 : : TEST_CASE_NAMED_ST(
16518 : : "Tunnel header IPv6 copy DSCP (inner 0)",
16519 : : ut_setup_security, ut_teardown,
16520 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
16521 : : TEST_CASE_NAMED_ST(
16522 : : "Tunnel header IPv6 copy DSCP (inner 1)",
16523 : : ut_setup_security, ut_teardown,
16524 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
16525 : : TEST_CASE_NAMED_ST(
16526 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
16527 : : ut_setup_security, ut_teardown,
16528 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
16529 : : TEST_CASE_NAMED_ST(
16530 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
16531 : : ut_setup_security, ut_teardown,
16532 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
16533 : : TEST_CASE_NAMED_WITH_DATA(
16534 : : "Antireplay with window size 1024",
16535 : : ut_setup_security, ut_teardown,
16536 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
16537 : : TEST_CASE_NAMED_WITH_DATA(
16538 : : "Antireplay with window size 2048",
16539 : : ut_setup_security, ut_teardown,
16540 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
16541 : : TEST_CASE_NAMED_WITH_DATA(
16542 : : "Antireplay with window size 4096",
16543 : : ut_setup_security, ut_teardown,
16544 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
16545 : : TEST_CASE_NAMED_WITH_DATA(
16546 : : "ESN and Antireplay with window size 1024",
16547 : : ut_setup_security, ut_teardown,
16548 : : test_ipsec_proto_pkt_esn_antireplay1024,
16549 : : &pkt_aes_128_gcm),
16550 : : TEST_CASE_NAMED_WITH_DATA(
16551 : : "ESN and Antireplay with window size 2048",
16552 : : ut_setup_security, ut_teardown,
16553 : : test_ipsec_proto_pkt_esn_antireplay2048,
16554 : : &pkt_aes_128_gcm),
16555 : : TEST_CASE_NAMED_WITH_DATA(
16556 : : "ESN and Antireplay with window size 4096",
16557 : : ut_setup_security, ut_teardown,
16558 : : test_ipsec_proto_pkt_esn_antireplay4096,
16559 : : &pkt_aes_128_gcm),
16560 : : TEST_CASE_NAMED_ST(
16561 : : "Tunnel header IPv4 decrement inner TTL",
16562 : : ut_setup_security, ut_teardown,
16563 : : test_ipsec_proto_ipv4_ttl_decrement),
16564 : : TEST_CASE_NAMED_ST(
16565 : : "Tunnel header IPv6 decrement inner hop limit",
16566 : : ut_setup_security, ut_teardown,
16567 : : test_ipsec_proto_ipv6_hop_limit_decrement),
16568 : : TEST_CASE_NAMED_ST(
16569 : : "Multi-segmented mode",
16570 : : ut_setup_security, ut_teardown,
16571 : : test_ipsec_proto_sgl),
16572 : : TEST_CASE_NAMED_ST(
16573 : : "Multi-segmented external mbuf mode",
16574 : : ut_setup_security, ut_teardown,
16575 : : test_ipsec_proto_sgl_ext_mbuf),
16576 : : TEST_CASE_NAMED_WITH_DATA(
16577 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
16578 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
16579 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
16580 : : TEST_CASES_END() /**< NULL terminate unit test array */
16581 : : }
16582 : : };
16583 : :
16584 : : static struct unit_test_suite pdcp_proto_testsuite = {
16585 : : .suite_name = "PDCP Proto Unit Test Suite",
16586 : : .setup = pdcp_proto_testsuite_setup,
16587 : : .unit_test_cases = {
16588 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
16589 : : test_PDCP_PROTO_all),
16590 : : TEST_CASES_END() /**< NULL terminate unit test array */
16591 : : }
16592 : : };
16593 : :
16594 : : #define ADD_UPLINK_TESTCASE(data) \
16595 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
16596 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
16597 : :
16598 : : #define ADD_DOWNLINK_TESTCASE(data) \
16599 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
16600 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
16601 : :
16602 : : static struct unit_test_suite docsis_proto_testsuite = {
16603 : : .suite_name = "DOCSIS Proto Unit Test Suite",
16604 : : .setup = docsis_proto_testsuite_setup,
16605 : : .unit_test_cases = {
16606 : : /* Uplink */
16607 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
16608 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
16609 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
16610 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
16611 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
16612 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
16613 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
16614 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
16615 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
16616 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
16617 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
16618 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
16619 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
16620 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
16621 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
16622 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
16623 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
16624 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
16625 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
16626 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
16627 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
16628 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
16629 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
16630 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
16631 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
16632 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
16633 : : /* Downlink */
16634 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
16635 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
16636 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
16637 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
16638 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
16639 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
16640 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
16641 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
16642 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
16643 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
16644 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
16645 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
16646 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
16647 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
16648 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
16649 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
16650 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
16651 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
16652 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
16653 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
16654 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
16655 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
16656 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
16657 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
16658 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
16659 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
16660 : : TEST_CASES_END() /**< NULL terminate unit test array */
16661 : : }
16662 : : };
16663 : : #endif
16664 : :
16665 : : static struct unit_test_suite cryptodev_gen_testsuite = {
16666 : : .suite_name = "Crypto General Unit Test Suite",
16667 : : .setup = crypto_gen_testsuite_setup,
16668 : : .unit_test_cases = {
16669 : : TEST_CASE_ST(ut_setup, ut_teardown,
16670 : : test_device_reconfigure),
16671 : : TEST_CASE_ST(ut_setup, ut_teardown,
16672 : : test_device_configure_invalid_dev_id),
16673 : : TEST_CASE_ST(ut_setup, ut_teardown,
16674 : : test_queue_pair_descriptor_setup),
16675 : : TEST_CASE_ST(ut_setup, ut_teardown,
16676 : : test_device_configure_invalid_queue_pair_ids),
16677 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
16678 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
16679 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
16680 : : TEST_CASES_END() /**< NULL terminate unit test array */
16681 : : }
16682 : : };
16683 : :
16684 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
16685 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
16686 : : .setup = negative_hmac_sha1_testsuite_setup,
16687 : : .unit_test_cases = {
16688 : : /** Negative tests */
16689 : : TEST_CASE_ST(ut_setup, ut_teardown,
16690 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
16691 : : TEST_CASE_ST(ut_setup, ut_teardown,
16692 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
16693 : : TEST_CASE_ST(ut_setup, ut_teardown,
16694 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
16695 : : TEST_CASE_ST(ut_setup, ut_teardown,
16696 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
16697 : :
16698 : : TEST_CASES_END() /**< NULL terminate unit test array */
16699 : : }
16700 : : };
16701 : :
16702 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
16703 : : .suite_name = "Multi Session Unit Test Suite",
16704 : : .setup = multi_session_testsuite_setup,
16705 : : .unit_test_cases = {
16706 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
16707 : : TEST_CASE_ST(ut_setup, ut_teardown,
16708 : : test_multi_session_random_usage),
16709 : :
16710 : : TEST_CASES_END() /**< NULL terminate unit test array */
16711 : : }
16712 : : };
16713 : :
16714 : : static struct unit_test_suite cryptodev_null_testsuite = {
16715 : : .suite_name = "NULL Test Suite",
16716 : : .setup = null_testsuite_setup,
16717 : : .unit_test_cases = {
16718 : : TEST_CASE_ST(ut_setup, ut_teardown,
16719 : : test_null_invalid_operation),
16720 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
16721 : : TEST_CASES_END()
16722 : : }
16723 : : };
16724 : :
16725 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
16726 : : .suite_name = "AES CCM Authenticated Test Suite",
16727 : : .setup = aes_ccm_auth_testsuite_setup,
16728 : : .unit_test_cases = {
16729 : : /** AES CCM Authenticated Encryption 128 bits key*/
16730 : : TEST_CASE_ST(ut_setup, ut_teardown,
16731 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
16732 : : TEST_CASE_ST(ut_setup, ut_teardown,
16733 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
16734 : : TEST_CASE_ST(ut_setup, ut_teardown,
16735 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
16736 : :
16737 : : /** AES CCM Authenticated Decryption 128 bits key*/
16738 : : TEST_CASE_ST(ut_setup, ut_teardown,
16739 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
16740 : : TEST_CASE_ST(ut_setup, ut_teardown,
16741 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
16742 : : TEST_CASE_ST(ut_setup, ut_teardown,
16743 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
16744 : :
16745 : : /** AES CCM Authenticated Encryption 192 bits key */
16746 : : TEST_CASE_ST(ut_setup, ut_teardown,
16747 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
16748 : : TEST_CASE_ST(ut_setup, ut_teardown,
16749 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
16750 : : TEST_CASE_ST(ut_setup, ut_teardown,
16751 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
16752 : :
16753 : : /** AES CCM Authenticated Decryption 192 bits key*/
16754 : : TEST_CASE_ST(ut_setup, ut_teardown,
16755 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
16756 : : TEST_CASE_ST(ut_setup, ut_teardown,
16757 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
16758 : : TEST_CASE_ST(ut_setup, ut_teardown,
16759 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
16760 : :
16761 : : /** AES CCM Authenticated Encryption 256 bits key */
16762 : : TEST_CASE_ST(ut_setup, ut_teardown,
16763 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
16764 : : TEST_CASE_ST(ut_setup, ut_teardown,
16765 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
16766 : : TEST_CASE_ST(ut_setup, ut_teardown,
16767 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
16768 : :
16769 : : /** AES CCM Authenticated Decryption 256 bits key*/
16770 : : TEST_CASE_ST(ut_setup, ut_teardown,
16771 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
16772 : : TEST_CASE_ST(ut_setup, ut_teardown,
16773 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
16774 : : TEST_CASE_ST(ut_setup, ut_teardown,
16775 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
16776 : : TEST_CASES_END()
16777 : : }
16778 : : };
16779 : :
16780 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
16781 : : .suite_name = "AES GCM Authenticated Test Suite",
16782 : : .setup = aes_gcm_auth_testsuite_setup,
16783 : : .unit_test_cases = {
16784 : : /** AES GCM Authenticated Encryption */
16785 : : TEST_CASE_ST(ut_setup, ut_teardown,
16786 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
16787 : : TEST_CASE_ST(ut_setup, ut_teardown,
16788 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
16789 : : TEST_CASE_ST(ut_setup, ut_teardown,
16790 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
16791 : : TEST_CASE_ST(ut_setup, ut_teardown,
16792 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
16793 : : TEST_CASE_ST(ut_setup, ut_teardown,
16794 : : test_AES_GCM_authenticated_encryption_test_case_1),
16795 : : TEST_CASE_ST(ut_setup, ut_teardown,
16796 : : test_AES_GCM_authenticated_encryption_test_case_2),
16797 : : TEST_CASE_ST(ut_setup, ut_teardown,
16798 : : test_AES_GCM_authenticated_encryption_test_case_3),
16799 : : TEST_CASE_ST(ut_setup, ut_teardown,
16800 : : test_AES_GCM_authenticated_encryption_test_case_4),
16801 : : TEST_CASE_ST(ut_setup, ut_teardown,
16802 : : test_AES_GCM_authenticated_encryption_test_case_5),
16803 : : TEST_CASE_ST(ut_setup, ut_teardown,
16804 : : test_AES_GCM_authenticated_encryption_test_case_6),
16805 : : TEST_CASE_ST(ut_setup, ut_teardown,
16806 : : test_AES_GCM_authenticated_encryption_test_case_7),
16807 : : TEST_CASE_ST(ut_setup, ut_teardown,
16808 : : test_AES_GCM_authenticated_encryption_test_case_8),
16809 : : TEST_CASE_ST(ut_setup, ut_teardown,
16810 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
16811 : :
16812 : : /** AES GCM Authenticated Decryption */
16813 : : TEST_CASE_ST(ut_setup, ut_teardown,
16814 : : test_AES_GCM_authenticated_decryption_test_case_1),
16815 : : TEST_CASE_ST(ut_setup, ut_teardown,
16816 : : test_AES_GCM_authenticated_decryption_test_case_2),
16817 : : TEST_CASE_ST(ut_setup, ut_teardown,
16818 : : test_AES_GCM_authenticated_decryption_test_case_3),
16819 : : TEST_CASE_ST(ut_setup, ut_teardown,
16820 : : test_AES_GCM_authenticated_decryption_test_case_4),
16821 : : TEST_CASE_ST(ut_setup, ut_teardown,
16822 : : test_AES_GCM_authenticated_decryption_test_case_5),
16823 : : TEST_CASE_ST(ut_setup, ut_teardown,
16824 : : test_AES_GCM_authenticated_decryption_test_case_6),
16825 : : TEST_CASE_ST(ut_setup, ut_teardown,
16826 : : test_AES_GCM_authenticated_decryption_test_case_7),
16827 : : TEST_CASE_ST(ut_setup, ut_teardown,
16828 : : test_AES_GCM_authenticated_decryption_test_case_8),
16829 : : TEST_CASE_ST(ut_setup, ut_teardown,
16830 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
16831 : :
16832 : : /** AES GCM Authenticated Encryption 192 bits key */
16833 : : TEST_CASE_ST(ut_setup, ut_teardown,
16834 : : test_AES_GCM_auth_encryption_test_case_192_1),
16835 : : TEST_CASE_ST(ut_setup, ut_teardown,
16836 : : test_AES_GCM_auth_encryption_test_case_192_2),
16837 : : TEST_CASE_ST(ut_setup, ut_teardown,
16838 : : test_AES_GCM_auth_encryption_test_case_192_3),
16839 : : TEST_CASE_ST(ut_setup, ut_teardown,
16840 : : test_AES_GCM_auth_encryption_test_case_192_4),
16841 : : TEST_CASE_ST(ut_setup, ut_teardown,
16842 : : test_AES_GCM_auth_encryption_test_case_192_5),
16843 : : TEST_CASE_ST(ut_setup, ut_teardown,
16844 : : test_AES_GCM_auth_encryption_test_case_192_6),
16845 : : TEST_CASE_ST(ut_setup, ut_teardown,
16846 : : test_AES_GCM_auth_encryption_test_case_192_7),
16847 : :
16848 : : /** AES GCM Authenticated Decryption 192 bits key */
16849 : : TEST_CASE_ST(ut_setup, ut_teardown,
16850 : : test_AES_GCM_auth_decryption_test_case_192_1),
16851 : : TEST_CASE_ST(ut_setup, ut_teardown,
16852 : : test_AES_GCM_auth_decryption_test_case_192_2),
16853 : : TEST_CASE_ST(ut_setup, ut_teardown,
16854 : : test_AES_GCM_auth_decryption_test_case_192_3),
16855 : : TEST_CASE_ST(ut_setup, ut_teardown,
16856 : : test_AES_GCM_auth_decryption_test_case_192_4),
16857 : : TEST_CASE_ST(ut_setup, ut_teardown,
16858 : : test_AES_GCM_auth_decryption_test_case_192_5),
16859 : : TEST_CASE_ST(ut_setup, ut_teardown,
16860 : : test_AES_GCM_auth_decryption_test_case_192_6),
16861 : : TEST_CASE_ST(ut_setup, ut_teardown,
16862 : : test_AES_GCM_auth_decryption_test_case_192_7),
16863 : :
16864 : : /** AES GCM Authenticated Encryption 256 bits key */
16865 : : TEST_CASE_ST(ut_setup, ut_teardown,
16866 : : test_AES_GCM_auth_encryption_test_case_256_1),
16867 : : TEST_CASE_ST(ut_setup, ut_teardown,
16868 : : test_AES_GCM_auth_encryption_test_case_256_2),
16869 : : TEST_CASE_ST(ut_setup, ut_teardown,
16870 : : test_AES_GCM_auth_encryption_test_case_256_3),
16871 : : TEST_CASE_ST(ut_setup, ut_teardown,
16872 : : test_AES_GCM_auth_encryption_test_case_256_4),
16873 : : TEST_CASE_ST(ut_setup, ut_teardown,
16874 : : test_AES_GCM_auth_encryption_test_case_256_5),
16875 : : TEST_CASE_ST(ut_setup, ut_teardown,
16876 : : test_AES_GCM_auth_encryption_test_case_256_6),
16877 : : TEST_CASE_ST(ut_setup, ut_teardown,
16878 : : test_AES_GCM_auth_encryption_test_case_256_7),
16879 : :
16880 : : /** AES GCM Authenticated Decryption 256 bits key */
16881 : : TEST_CASE_ST(ut_setup, ut_teardown,
16882 : : test_AES_GCM_auth_decryption_test_case_256_1),
16883 : : TEST_CASE_ST(ut_setup, ut_teardown,
16884 : : test_AES_GCM_auth_decryption_test_case_256_2),
16885 : : TEST_CASE_ST(ut_setup, ut_teardown,
16886 : : test_AES_GCM_auth_decryption_test_case_256_3),
16887 : : TEST_CASE_ST(ut_setup, ut_teardown,
16888 : : test_AES_GCM_auth_decryption_test_case_256_4),
16889 : : TEST_CASE_ST(ut_setup, ut_teardown,
16890 : : test_AES_GCM_auth_decryption_test_case_256_5),
16891 : : TEST_CASE_ST(ut_setup, ut_teardown,
16892 : : test_AES_GCM_auth_decryption_test_case_256_6),
16893 : : TEST_CASE_ST(ut_setup, ut_teardown,
16894 : : test_AES_GCM_auth_decryption_test_case_256_7),
16895 : :
16896 : : /** AES GCM Authenticated Encryption big aad size */
16897 : : TEST_CASE_ST(ut_setup, ut_teardown,
16898 : : test_AES_GCM_auth_encryption_test_case_aad_1),
16899 : : TEST_CASE_ST(ut_setup, ut_teardown,
16900 : : test_AES_GCM_auth_encryption_test_case_aad_2),
16901 : :
16902 : : /** AES GCM Authenticated Decryption big aad size */
16903 : : TEST_CASE_ST(ut_setup, ut_teardown,
16904 : : test_AES_GCM_auth_decryption_test_case_aad_1),
16905 : : TEST_CASE_ST(ut_setup, ut_teardown,
16906 : : test_AES_GCM_auth_decryption_test_case_aad_2),
16907 : :
16908 : : /** Out of place tests */
16909 : : TEST_CASE_ST(ut_setup, ut_teardown,
16910 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
16911 : : TEST_CASE_ST(ut_setup, ut_teardown,
16912 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
16913 : :
16914 : : /** Session-less tests */
16915 : : TEST_CASE_ST(ut_setup, ut_teardown,
16916 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
16917 : : TEST_CASE_ST(ut_setup, ut_teardown,
16918 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
16919 : :
16920 : : TEST_CASES_END()
16921 : : }
16922 : : };
16923 : :
16924 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
16925 : : .suite_name = "AES GMAC Authentication Test Suite",
16926 : : .setup = aes_gmac_auth_testsuite_setup,
16927 : : .unit_test_cases = {
16928 : : TEST_CASE_ST(ut_setup, ut_teardown,
16929 : : test_AES_GMAC_authentication_test_case_1),
16930 : : TEST_CASE_ST(ut_setup, ut_teardown,
16931 : : test_AES_GMAC_authentication_verify_test_case_1),
16932 : : TEST_CASE_ST(ut_setup, ut_teardown,
16933 : : test_AES_GMAC_authentication_test_case_2),
16934 : : TEST_CASE_ST(ut_setup, ut_teardown,
16935 : : test_AES_GMAC_authentication_verify_test_case_2),
16936 : : TEST_CASE_ST(ut_setup, ut_teardown,
16937 : : test_AES_GMAC_authentication_test_case_3),
16938 : : TEST_CASE_ST(ut_setup, ut_teardown,
16939 : : test_AES_GMAC_authentication_verify_test_case_3),
16940 : : TEST_CASE_ST(ut_setup, ut_teardown,
16941 : : test_AES_GMAC_authentication_test_case_4),
16942 : : TEST_CASE_ST(ut_setup, ut_teardown,
16943 : : test_AES_GMAC_authentication_verify_test_case_4),
16944 : : TEST_CASE_ST(ut_setup, ut_teardown,
16945 : : test_AES_GMAC_authentication_SGL_40B),
16946 : : TEST_CASE_ST(ut_setup, ut_teardown,
16947 : : test_AES_GMAC_authentication_SGL_80B),
16948 : : TEST_CASE_ST(ut_setup, ut_teardown,
16949 : : test_AES_GMAC_authentication_SGL_2048B),
16950 : : TEST_CASE_ST(ut_setup, ut_teardown,
16951 : : test_AES_GMAC_authentication_SGL_2047B),
16952 : :
16953 : : TEST_CASES_END()
16954 : : }
16955 : : };
16956 : :
16957 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
16958 : : .suite_name = "Chacha20-Poly1305 Test Suite",
16959 : : .setup = chacha20_poly1305_testsuite_setup,
16960 : : .unit_test_cases = {
16961 : : TEST_CASE_ST(ut_setup, ut_teardown,
16962 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
16963 : : TEST_CASE_ST(ut_setup, ut_teardown,
16964 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
16965 : : TEST_CASE_ST(ut_setup, ut_teardown,
16966 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
16967 : : TEST_CASES_END()
16968 : : }
16969 : : };
16970 : :
16971 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
16972 : : .suite_name = "SNOW 3G Test Suite",
16973 : : .setup = snow3g_testsuite_setup,
16974 : : .unit_test_cases = {
16975 : : /** SNOW 3G encrypt only (UEA2) */
16976 : : TEST_CASE_ST(ut_setup, ut_teardown,
16977 : : test_snow3g_encryption_test_case_1),
16978 : : TEST_CASE_ST(ut_setup, ut_teardown,
16979 : : test_snow3g_encryption_test_case_2),
16980 : : TEST_CASE_ST(ut_setup, ut_teardown,
16981 : : test_snow3g_encryption_test_case_3),
16982 : : TEST_CASE_ST(ut_setup, ut_teardown,
16983 : : test_snow3g_encryption_test_case_4),
16984 : : TEST_CASE_ST(ut_setup, ut_teardown,
16985 : : test_snow3g_encryption_test_case_5),
16986 : :
16987 : : TEST_CASE_ST(ut_setup, ut_teardown,
16988 : : test_snow3g_encryption_test_case_1_oop),
16989 : : TEST_CASE_ST(ut_setup, ut_teardown,
16990 : : test_snow3g_encryption_test_case_1_oop_sgl),
16991 : : TEST_CASE_ST(ut_setup, ut_teardown,
16992 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
16993 : : TEST_CASE_ST(ut_setup, ut_teardown,
16994 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
16995 : : TEST_CASE_ST(ut_setup, ut_teardown,
16996 : : test_snow3g_encryption_test_case_1_offset_oop),
16997 : : TEST_CASE_ST(ut_setup, ut_teardown,
16998 : : test_snow3g_decryption_test_case_1_oop),
16999 : :
17000 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
17001 : : TEST_CASE_ST(ut_setup, ut_teardown,
17002 : : test_snow3g_auth_cipher_test_case_1),
17003 : : TEST_CASE_ST(ut_setup, ut_teardown,
17004 : : test_snow3g_auth_cipher_test_case_2),
17005 : : TEST_CASE_ST(ut_setup, ut_teardown,
17006 : : test_snow3g_auth_cipher_test_case_2_oop),
17007 : : TEST_CASE_ST(ut_setup, ut_teardown,
17008 : : test_snow3g_auth_cipher_part_digest_enc),
17009 : : TEST_CASE_ST(ut_setup, ut_teardown,
17010 : : test_snow3g_auth_cipher_part_digest_enc_oop),
17011 : : TEST_CASE_ST(ut_setup, ut_teardown,
17012 : : test_snow3g_auth_cipher_test_case_3_sgl),
17013 : : TEST_CASE_ST(ut_setup, ut_teardown,
17014 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
17015 : : TEST_CASE_ST(ut_setup, ut_teardown,
17016 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
17017 : : TEST_CASE_ST(ut_setup, ut_teardown,
17018 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
17019 : : TEST_CASE_ST(ut_setup, ut_teardown,
17020 : : test_snow3g_auth_cipher_total_digest_enc_1),
17021 : : TEST_CASE_ST(ut_setup, ut_teardown,
17022 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
17023 : : TEST_CASE_ST(ut_setup, ut_teardown,
17024 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
17025 : : TEST_CASE_ST(ut_setup, ut_teardown,
17026 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
17027 : :
17028 : : /** SNOW 3G decrypt (UEA2), then verify auth */
17029 : : TEST_CASE_ST(ut_setup, ut_teardown,
17030 : : test_snow3g_auth_cipher_verify_test_case_1),
17031 : : TEST_CASE_ST(ut_setup, ut_teardown,
17032 : : test_snow3g_auth_cipher_verify_test_case_2),
17033 : : TEST_CASE_ST(ut_setup, ut_teardown,
17034 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
17035 : : TEST_CASE_ST(ut_setup, ut_teardown,
17036 : : test_snow3g_auth_cipher_verify_part_digest_enc),
17037 : : TEST_CASE_ST(ut_setup, ut_teardown,
17038 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
17039 : : TEST_CASE_ST(ut_setup, ut_teardown,
17040 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
17041 : : TEST_CASE_ST(ut_setup, ut_teardown,
17042 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
17043 : : TEST_CASE_ST(ut_setup, ut_teardown,
17044 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
17045 : : TEST_CASE_ST(ut_setup, ut_teardown,
17046 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
17047 : : TEST_CASE_ST(ut_setup, ut_teardown,
17048 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
17049 : : TEST_CASE_ST(ut_setup, ut_teardown,
17050 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
17051 : : TEST_CASE_ST(ut_setup, ut_teardown,
17052 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
17053 : : TEST_CASE_ST(ut_setup, ut_teardown,
17054 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
17055 : :
17056 : : /** SNOW 3G decrypt only (UEA2) */
17057 : : TEST_CASE_ST(ut_setup, ut_teardown,
17058 : : test_snow3g_decryption_test_case_1),
17059 : : TEST_CASE_ST(ut_setup, ut_teardown,
17060 : : test_snow3g_decryption_test_case_2),
17061 : : TEST_CASE_ST(ut_setup, ut_teardown,
17062 : : test_snow3g_decryption_test_case_3),
17063 : : TEST_CASE_ST(ut_setup, ut_teardown,
17064 : : test_snow3g_decryption_test_case_4),
17065 : : TEST_CASE_ST(ut_setup, ut_teardown,
17066 : : test_snow3g_decryption_test_case_5),
17067 : : TEST_CASE_ST(ut_setup, ut_teardown,
17068 : : test_snow3g_decryption_with_digest_test_case_1),
17069 : : TEST_CASE_ST(ut_setup, ut_teardown,
17070 : : test_snow3g_hash_generate_test_case_1),
17071 : : TEST_CASE_ST(ut_setup, ut_teardown,
17072 : : test_snow3g_hash_generate_test_case_2),
17073 : : TEST_CASE_ST(ut_setup, ut_teardown,
17074 : : test_snow3g_hash_generate_test_case_3),
17075 : :
17076 : : /* Tests with buffers which length is not byte-aligned */
17077 : : TEST_CASE_ST(ut_setup, ut_teardown,
17078 : : test_snow3g_hash_generate_test_case_4),
17079 : : TEST_CASE_ST(ut_setup, ut_teardown,
17080 : : test_snow3g_hash_generate_test_case_5),
17081 : : TEST_CASE_ST(ut_setup, ut_teardown,
17082 : : test_snow3g_hash_generate_test_case_6),
17083 : : TEST_CASE_ST(ut_setup, ut_teardown,
17084 : : test_snow3g_hash_verify_test_case_1),
17085 : : TEST_CASE_ST(ut_setup, ut_teardown,
17086 : : test_snow3g_hash_verify_test_case_2),
17087 : : TEST_CASE_ST(ut_setup, ut_teardown,
17088 : : test_snow3g_hash_verify_test_case_3),
17089 : :
17090 : : /* Tests with buffers which length is not byte-aligned */
17091 : : TEST_CASE_ST(ut_setup, ut_teardown,
17092 : : test_snow3g_hash_verify_test_case_4),
17093 : : TEST_CASE_ST(ut_setup, ut_teardown,
17094 : : test_snow3g_hash_verify_test_case_5),
17095 : : TEST_CASE_ST(ut_setup, ut_teardown,
17096 : : test_snow3g_hash_verify_test_case_6),
17097 : : TEST_CASE_ST(ut_setup, ut_teardown,
17098 : : test_snow3g_cipher_auth_test_case_1),
17099 : : TEST_CASE_ST(ut_setup, ut_teardown,
17100 : : test_snow3g_auth_cipher_with_digest_test_case_1),
17101 : : TEST_CASES_END()
17102 : : }
17103 : : };
17104 : :
17105 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
17106 : : .suite_name = "ZUC Test Suite",
17107 : : .setup = zuc_testsuite_setup,
17108 : : .unit_test_cases = {
17109 : : /** ZUC encrypt only (EEA3) */
17110 : : TEST_CASE_ST(ut_setup, ut_teardown,
17111 : : test_zuc_encryption_test_case_1),
17112 : : TEST_CASE_ST(ut_setup, ut_teardown,
17113 : : test_zuc_encryption_test_case_2),
17114 : : TEST_CASE_ST(ut_setup, ut_teardown,
17115 : : test_zuc_encryption_test_case_3),
17116 : : TEST_CASE_ST(ut_setup, ut_teardown,
17117 : : test_zuc_encryption_test_case_4),
17118 : : TEST_CASE_ST(ut_setup, ut_teardown,
17119 : : test_zuc_encryption_test_case_5),
17120 : : TEST_CASE_ST(ut_setup, ut_teardown,
17121 : : test_zuc_encryption_test_case_6_sgl),
17122 : :
17123 : : /** ZUC decrypt only (EEA3) */
17124 : : TEST_CASE_ST(ut_setup, ut_teardown,
17125 : : test_zuc_decryption_test_case_1),
17126 : : TEST_CASE_ST(ut_setup, ut_teardown,
17127 : : test_zuc_decryption_test_case_2),
17128 : : TEST_CASE_ST(ut_setup, ut_teardown,
17129 : : test_zuc_decryption_test_case_3),
17130 : : TEST_CASE_ST(ut_setup, ut_teardown,
17131 : : test_zuc_decryption_test_case_4),
17132 : : TEST_CASE_ST(ut_setup, ut_teardown,
17133 : : test_zuc_decryption_test_case_5),
17134 : : TEST_CASE_ST(ut_setup, ut_teardown,
17135 : : test_zuc_decryption_test_case_6_sgl),
17136 : :
17137 : : /** ZUC authenticate (EIA3) */
17138 : : TEST_CASE_ST(ut_setup, ut_teardown,
17139 : : test_zuc_hash_generate_test_case_1),
17140 : : TEST_CASE_ST(ut_setup, ut_teardown,
17141 : : test_zuc_hash_generate_test_case_2),
17142 : : TEST_CASE_ST(ut_setup, ut_teardown,
17143 : : test_zuc_hash_generate_test_case_3),
17144 : : TEST_CASE_ST(ut_setup, ut_teardown,
17145 : : test_zuc_hash_generate_test_case_4),
17146 : : TEST_CASE_ST(ut_setup, ut_teardown,
17147 : : test_zuc_hash_generate_test_case_5),
17148 : : TEST_CASE_ST(ut_setup, ut_teardown,
17149 : : test_zuc_hash_generate_test_case_6),
17150 : : TEST_CASE_ST(ut_setup, ut_teardown,
17151 : : test_zuc_hash_generate_test_case_7),
17152 : : TEST_CASE_ST(ut_setup, ut_teardown,
17153 : : test_zuc_hash_generate_test_case_8),
17154 : :
17155 : : /** ZUC verify (EIA3) */
17156 : : TEST_CASE_ST(ut_setup, ut_teardown,
17157 : : test_zuc_hash_verify_test_case_1),
17158 : : TEST_CASE_ST(ut_setup, ut_teardown,
17159 : : test_zuc_hash_verify_test_case_2),
17160 : : TEST_CASE_ST(ut_setup, ut_teardown,
17161 : : test_zuc_hash_verify_test_case_3),
17162 : : TEST_CASE_ST(ut_setup, ut_teardown,
17163 : : test_zuc_hash_verify_test_case_4),
17164 : : TEST_CASE_ST(ut_setup, ut_teardown,
17165 : : test_zuc_hash_verify_test_case_5),
17166 : : TEST_CASE_ST(ut_setup, ut_teardown,
17167 : : test_zuc_hash_verify_test_case_6),
17168 : : TEST_CASE_ST(ut_setup, ut_teardown,
17169 : : test_zuc_hash_verify_test_case_7),
17170 : : TEST_CASE_ST(ut_setup, ut_teardown,
17171 : : test_zuc_hash_verify_test_case_8),
17172 : :
17173 : : /** ZUC alg-chain (EEA3/EIA3) */
17174 : : TEST_CASE_ST(ut_setup, ut_teardown,
17175 : : test_zuc_cipher_auth_test_case_1),
17176 : : TEST_CASE_ST(ut_setup, ut_teardown,
17177 : : test_zuc_cipher_auth_test_case_2),
17178 : :
17179 : : /** ZUC generate auth, then encrypt (EEA3) */
17180 : : TEST_CASE_ST(ut_setup, ut_teardown,
17181 : : test_zuc_auth_cipher_test_case_1),
17182 : : TEST_CASE_ST(ut_setup, ut_teardown,
17183 : : test_zuc_auth_cipher_test_case_1_oop),
17184 : : TEST_CASE_ST(ut_setup, ut_teardown,
17185 : : test_zuc_auth_cipher_test_case_1_sgl),
17186 : : TEST_CASE_ST(ut_setup, ut_teardown,
17187 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
17188 : : TEST_CASE_ST(ut_setup, ut_teardown,
17189 : : test_zuc_auth_cipher_test_case_2),
17190 : : TEST_CASE_ST(ut_setup, ut_teardown,
17191 : : test_zuc_auth_cipher_test_case_2_oop),
17192 : :
17193 : : /** ZUC decrypt (EEA3), then verify auth */
17194 : : TEST_CASE_ST(ut_setup, ut_teardown,
17195 : : test_zuc_auth_cipher_verify_test_case_1),
17196 : : TEST_CASE_ST(ut_setup, ut_teardown,
17197 : : test_zuc_auth_cipher_verify_test_case_1_oop),
17198 : : TEST_CASE_ST(ut_setup, ut_teardown,
17199 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
17200 : : TEST_CASE_ST(ut_setup, ut_teardown,
17201 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
17202 : : TEST_CASE_ST(ut_setup, ut_teardown,
17203 : : test_zuc_auth_cipher_verify_test_case_2),
17204 : : TEST_CASE_ST(ut_setup, ut_teardown,
17205 : : test_zuc_auth_cipher_verify_test_case_2_oop),
17206 : :
17207 : : /** ZUC-256 encrypt only **/
17208 : : TEST_CASE_ST(ut_setup, ut_teardown,
17209 : : test_zuc256_encryption_test_case_1),
17210 : : TEST_CASE_ST(ut_setup, ut_teardown,
17211 : : test_zuc256_encryption_test_case_2),
17212 : :
17213 : : /** ZUC-256 decrypt only **/
17214 : : TEST_CASE_ST(ut_setup, ut_teardown,
17215 : : test_zuc256_decryption_test_case_1),
17216 : : TEST_CASE_ST(ut_setup, ut_teardown,
17217 : : test_zuc256_decryption_test_case_2),
17218 : :
17219 : : /** ZUC-256 authentication only **/
17220 : : TEST_CASE_ST(ut_setup, ut_teardown,
17221 : : test_zuc256_hash_generate_4b_tag_test_case_1),
17222 : : TEST_CASE_ST(ut_setup, ut_teardown,
17223 : : test_zuc256_hash_generate_4b_tag_test_case_2),
17224 : : TEST_CASE_ST(ut_setup, ut_teardown,
17225 : : test_zuc256_hash_generate_4b_tag_test_case_3),
17226 : : TEST_CASE_ST(ut_setup, ut_teardown,
17227 : : test_zuc256_hash_generate_8b_tag_test_case_1),
17228 : : TEST_CASE_ST(ut_setup, ut_teardown,
17229 : : test_zuc256_hash_generate_16b_tag_test_case_1),
17230 : :
17231 : : /** ZUC-256 authentication verify only **/
17232 : : TEST_CASE_ST(ut_setup, ut_teardown,
17233 : : test_zuc256_hash_verify_4b_tag_test_case_1),
17234 : : TEST_CASE_ST(ut_setup, ut_teardown,
17235 : : test_zuc256_hash_verify_4b_tag_test_case_2),
17236 : : TEST_CASE_ST(ut_setup, ut_teardown,
17237 : : test_zuc256_hash_verify_4b_tag_test_case_3),
17238 : : TEST_CASE_ST(ut_setup, ut_teardown,
17239 : : test_zuc256_hash_verify_8b_tag_test_case_1),
17240 : : TEST_CASE_ST(ut_setup, ut_teardown,
17241 : : test_zuc256_hash_verify_16b_tag_test_case_1),
17242 : :
17243 : : /** ZUC-256 encrypt and authenticate **/
17244 : : TEST_CASE_ST(ut_setup, ut_teardown,
17245 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
17246 : : TEST_CASE_ST(ut_setup, ut_teardown,
17247 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
17248 : : TEST_CASE_ST(ut_setup, ut_teardown,
17249 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
17250 : : TEST_CASE_ST(ut_setup, ut_teardown,
17251 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
17252 : :
17253 : : /** ZUC-256 generate auth, then encrypt */
17254 : : TEST_CASE_ST(ut_setup, ut_teardown,
17255 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
17256 : : TEST_CASE_ST(ut_setup, ut_teardown,
17257 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
17258 : : TEST_CASE_ST(ut_setup, ut_teardown,
17259 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
17260 : : TEST_CASE_ST(ut_setup, ut_teardown,
17261 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
17262 : :
17263 : : /** ZUC-256 decrypt, then verify auth */
17264 : : TEST_CASE_ST(ut_setup, ut_teardown,
17265 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
17266 : : TEST_CASE_ST(ut_setup, ut_teardown,
17267 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
17268 : : TEST_CASE_ST(ut_setup, ut_teardown,
17269 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
17270 : : TEST_CASE_ST(ut_setup, ut_teardown,
17271 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
17272 : :
17273 : : TEST_CASES_END()
17274 : : }
17275 : : };
17276 : :
17277 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
17278 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
17279 : : .setup = hmac_md5_auth_testsuite_setup,
17280 : : .unit_test_cases = {
17281 : : TEST_CASE_ST(ut_setup, ut_teardown,
17282 : : test_MD5_HMAC_generate_case_1),
17283 : : TEST_CASE_ST(ut_setup, ut_teardown,
17284 : : test_MD5_HMAC_verify_case_1),
17285 : : TEST_CASE_ST(ut_setup, ut_teardown,
17286 : : test_MD5_HMAC_generate_case_2),
17287 : : TEST_CASE_ST(ut_setup, ut_teardown,
17288 : : test_MD5_HMAC_verify_case_2),
17289 : : TEST_CASES_END()
17290 : : }
17291 : : };
17292 : :
17293 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
17294 : : .suite_name = "Kasumi Test Suite",
17295 : : .setup = kasumi_testsuite_setup,
17296 : : .unit_test_cases = {
17297 : : /** KASUMI hash only (UIA1) */
17298 : : TEST_CASE_ST(ut_setup, ut_teardown,
17299 : : test_kasumi_hash_generate_test_case_1),
17300 : : TEST_CASE_ST(ut_setup, ut_teardown,
17301 : : test_kasumi_hash_generate_test_case_2),
17302 : : TEST_CASE_ST(ut_setup, ut_teardown,
17303 : : test_kasumi_hash_generate_test_case_3),
17304 : : TEST_CASE_ST(ut_setup, ut_teardown,
17305 : : test_kasumi_hash_generate_test_case_4),
17306 : : TEST_CASE_ST(ut_setup, ut_teardown,
17307 : : test_kasumi_hash_generate_test_case_5),
17308 : : TEST_CASE_ST(ut_setup, ut_teardown,
17309 : : test_kasumi_hash_generate_test_case_6),
17310 : :
17311 : : TEST_CASE_ST(ut_setup, ut_teardown,
17312 : : test_kasumi_hash_verify_test_case_1),
17313 : : TEST_CASE_ST(ut_setup, ut_teardown,
17314 : : test_kasumi_hash_verify_test_case_2),
17315 : : TEST_CASE_ST(ut_setup, ut_teardown,
17316 : : test_kasumi_hash_verify_test_case_3),
17317 : : TEST_CASE_ST(ut_setup, ut_teardown,
17318 : : test_kasumi_hash_verify_test_case_4),
17319 : : TEST_CASE_ST(ut_setup, ut_teardown,
17320 : : test_kasumi_hash_verify_test_case_5),
17321 : :
17322 : : /** KASUMI encrypt only (UEA1) */
17323 : : TEST_CASE_ST(ut_setup, ut_teardown,
17324 : : test_kasumi_encryption_test_case_1),
17325 : : TEST_CASE_ST(ut_setup, ut_teardown,
17326 : : test_kasumi_encryption_test_case_1_sgl),
17327 : : TEST_CASE_ST(ut_setup, ut_teardown,
17328 : : test_kasumi_encryption_test_case_1_oop),
17329 : : TEST_CASE_ST(ut_setup, ut_teardown,
17330 : : test_kasumi_encryption_test_case_1_oop_sgl),
17331 : : TEST_CASE_ST(ut_setup, ut_teardown,
17332 : : test_kasumi_encryption_test_case_2),
17333 : : TEST_CASE_ST(ut_setup, ut_teardown,
17334 : : test_kasumi_encryption_test_case_3),
17335 : : TEST_CASE_ST(ut_setup, ut_teardown,
17336 : : test_kasumi_encryption_test_case_4),
17337 : : TEST_CASE_ST(ut_setup, ut_teardown,
17338 : : test_kasumi_encryption_test_case_5),
17339 : :
17340 : : /** KASUMI decrypt only (UEA1) */
17341 : : TEST_CASE_ST(ut_setup, ut_teardown,
17342 : : test_kasumi_decryption_test_case_1),
17343 : : TEST_CASE_ST(ut_setup, ut_teardown,
17344 : : test_kasumi_decryption_test_case_2),
17345 : : TEST_CASE_ST(ut_setup, ut_teardown,
17346 : : test_kasumi_decryption_test_case_3),
17347 : : TEST_CASE_ST(ut_setup, ut_teardown,
17348 : : test_kasumi_decryption_test_case_4),
17349 : : TEST_CASE_ST(ut_setup, ut_teardown,
17350 : : test_kasumi_decryption_test_case_5),
17351 : : TEST_CASE_ST(ut_setup, ut_teardown,
17352 : : test_kasumi_decryption_test_case_1_oop),
17353 : : TEST_CASE_ST(ut_setup, ut_teardown,
17354 : : test_kasumi_cipher_auth_test_case_1),
17355 : :
17356 : : /** KASUMI generate auth, then encrypt (F8) */
17357 : : TEST_CASE_ST(ut_setup, ut_teardown,
17358 : : test_kasumi_auth_cipher_test_case_1),
17359 : : TEST_CASE_ST(ut_setup, ut_teardown,
17360 : : test_kasumi_auth_cipher_test_case_2),
17361 : : TEST_CASE_ST(ut_setup, ut_teardown,
17362 : : test_kasumi_auth_cipher_test_case_2_oop),
17363 : : TEST_CASE_ST(ut_setup, ut_teardown,
17364 : : test_kasumi_auth_cipher_test_case_2_sgl),
17365 : : TEST_CASE_ST(ut_setup, ut_teardown,
17366 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
17367 : :
17368 : : /** KASUMI decrypt (F8), then verify auth */
17369 : : TEST_CASE_ST(ut_setup, ut_teardown,
17370 : : test_kasumi_auth_cipher_verify_test_case_1),
17371 : : TEST_CASE_ST(ut_setup, ut_teardown,
17372 : : test_kasumi_auth_cipher_verify_test_case_2),
17373 : : TEST_CASE_ST(ut_setup, ut_teardown,
17374 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
17375 : : TEST_CASE_ST(ut_setup, ut_teardown,
17376 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
17377 : : TEST_CASE_ST(ut_setup, ut_teardown,
17378 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
17379 : :
17380 : : TEST_CASES_END()
17381 : : }
17382 : : };
17383 : :
17384 : : static struct unit_test_suite cryptodev_esn_testsuite = {
17385 : : .suite_name = "ESN Test Suite",
17386 : : .setup = esn_testsuite_setup,
17387 : : .unit_test_cases = {
17388 : : TEST_CASE_ST(ut_setup, ut_teardown,
17389 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
17390 : : TEST_CASE_ST(ut_setup, ut_teardown,
17391 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
17392 : : TEST_CASES_END()
17393 : : }
17394 : : };
17395 : :
17396 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
17397 : : .suite_name = "Negative AES GCM Test Suite",
17398 : : .setup = negative_aes_gcm_testsuite_setup,
17399 : : .unit_test_cases = {
17400 : : TEST_CASE_ST(ut_setup, ut_teardown,
17401 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
17402 : : TEST_CASE_ST(ut_setup, ut_teardown,
17403 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
17404 : : TEST_CASE_ST(ut_setup, ut_teardown,
17405 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
17406 : : TEST_CASE_ST(ut_setup, ut_teardown,
17407 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
17408 : : TEST_CASE_ST(ut_setup, ut_teardown,
17409 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
17410 : : TEST_CASE_ST(ut_setup, ut_teardown,
17411 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
17412 : : TEST_CASE_ST(ut_setup, ut_teardown,
17413 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
17414 : : TEST_CASE_ST(ut_setup, ut_teardown,
17415 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
17416 : : TEST_CASE_ST(ut_setup, ut_teardown,
17417 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
17418 : : TEST_CASE_ST(ut_setup, ut_teardown,
17419 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
17420 : : TEST_CASE_ST(ut_setup, ut_teardown,
17421 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
17422 : : TEST_CASE_ST(ut_setup, ut_teardown,
17423 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
17424 : :
17425 : : TEST_CASES_END()
17426 : : }
17427 : : };
17428 : :
17429 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
17430 : : .suite_name = "Negative AES GMAC Test Suite",
17431 : : .setup = negative_aes_gmac_testsuite_setup,
17432 : : .unit_test_cases = {
17433 : : TEST_CASE_ST(ut_setup, ut_teardown,
17434 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
17435 : : TEST_CASE_ST(ut_setup, ut_teardown,
17436 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
17437 : :
17438 : : TEST_CASES_END()
17439 : : }
17440 : : };
17441 : :
17442 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
17443 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
17444 : : .setup = mixed_cipher_hash_testsuite_setup,
17445 : : .unit_test_cases = {
17446 : : /** AUTH AES CMAC + CIPHER AES CTR */
17447 : : TEST_CASE_ST(ut_setup, ut_teardown,
17448 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
17449 : : TEST_CASE_ST(ut_setup, ut_teardown,
17450 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17451 : : TEST_CASE_ST(ut_setup, ut_teardown,
17452 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17453 : : TEST_CASE_ST(ut_setup, ut_teardown,
17454 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17455 : : TEST_CASE_ST(ut_setup, ut_teardown,
17456 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
17457 : : TEST_CASE_ST(ut_setup, ut_teardown,
17458 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17459 : : TEST_CASE_ST(ut_setup, ut_teardown,
17460 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17461 : : TEST_CASE_ST(ut_setup, ut_teardown,
17462 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17463 : : TEST_CASE_ST(ut_setup, ut_teardown,
17464 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
17465 : : TEST_CASE_ST(ut_setup, ut_teardown,
17466 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17467 : : TEST_CASE_ST(ut_setup, ut_teardown,
17468 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
17469 : : TEST_CASE_ST(ut_setup, ut_teardown,
17470 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17471 : :
17472 : : /** AUTH ZUC + CIPHER SNOW3G */
17473 : : TEST_CASE_ST(ut_setup, ut_teardown,
17474 : : test_auth_zuc_cipher_snow_test_case_1),
17475 : : TEST_CASE_ST(ut_setup, ut_teardown,
17476 : : test_verify_auth_zuc_cipher_snow_test_case_1),
17477 : : TEST_CASE_ST(ut_setup, ut_teardown,
17478 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
17479 : : TEST_CASE_ST(ut_setup, ut_teardown,
17480 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
17481 : : /** AUTH AES CMAC + CIPHER SNOW3G */
17482 : : TEST_CASE_ST(ut_setup, ut_teardown,
17483 : : test_auth_aes_cmac_cipher_snow_test_case_1),
17484 : : TEST_CASE_ST(ut_setup, ut_teardown,
17485 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
17486 : : TEST_CASE_ST(ut_setup, ut_teardown,
17487 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
17488 : : TEST_CASE_ST(ut_setup, ut_teardown,
17489 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
17490 : : /** AUTH ZUC + CIPHER AES CTR */
17491 : : TEST_CASE_ST(ut_setup, ut_teardown,
17492 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
17493 : : TEST_CASE_ST(ut_setup, ut_teardown,
17494 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
17495 : : TEST_CASE_ST(ut_setup, ut_teardown,
17496 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
17497 : : TEST_CASE_ST(ut_setup, ut_teardown,
17498 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
17499 : : /** AUTH SNOW3G + CIPHER AES CTR */
17500 : : TEST_CASE_ST(ut_setup, ut_teardown,
17501 : : test_auth_snow_cipher_aes_ctr_test_case_1),
17502 : : TEST_CASE_ST(ut_setup, ut_teardown,
17503 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
17504 : : TEST_CASE_ST(ut_setup, ut_teardown,
17505 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
17506 : : TEST_CASE_ST(ut_setup, ut_teardown,
17507 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
17508 : : TEST_CASE_ST(ut_setup, ut_teardown,
17509 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
17510 : : TEST_CASE_ST(ut_setup, ut_teardown,
17511 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
17512 : : /** AUTH SNOW3G + CIPHER ZUC */
17513 : : TEST_CASE_ST(ut_setup, ut_teardown,
17514 : : test_auth_snow_cipher_zuc_test_case_1),
17515 : : TEST_CASE_ST(ut_setup, ut_teardown,
17516 : : test_verify_auth_snow_cipher_zuc_test_case_1),
17517 : : TEST_CASE_ST(ut_setup, ut_teardown,
17518 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
17519 : : TEST_CASE_ST(ut_setup, ut_teardown,
17520 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
17521 : : /** AUTH AES CMAC + CIPHER ZUC */
17522 : : TEST_CASE_ST(ut_setup, ut_teardown,
17523 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
17524 : : TEST_CASE_ST(ut_setup, ut_teardown,
17525 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
17526 : : TEST_CASE_ST(ut_setup, ut_teardown,
17527 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
17528 : : TEST_CASE_ST(ut_setup, ut_teardown,
17529 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
17530 : :
17531 : : /** AUTH NULL + CIPHER SNOW3G */
17532 : : TEST_CASE_ST(ut_setup, ut_teardown,
17533 : : test_auth_null_cipher_snow_test_case_1),
17534 : : TEST_CASE_ST(ut_setup, ut_teardown,
17535 : : test_verify_auth_null_cipher_snow_test_case_1),
17536 : : /** AUTH NULL + CIPHER ZUC */
17537 : : TEST_CASE_ST(ut_setup, ut_teardown,
17538 : : test_auth_null_cipher_zuc_test_case_1),
17539 : : TEST_CASE_ST(ut_setup, ut_teardown,
17540 : : test_verify_auth_null_cipher_zuc_test_case_1),
17541 : : /** AUTH SNOW3G + CIPHER NULL */
17542 : : TEST_CASE_ST(ut_setup, ut_teardown,
17543 : : test_auth_snow_cipher_null_test_case_1),
17544 : : TEST_CASE_ST(ut_setup, ut_teardown,
17545 : : test_verify_auth_snow_cipher_null_test_case_1),
17546 : : /** AUTH ZUC + CIPHER NULL */
17547 : : TEST_CASE_ST(ut_setup, ut_teardown,
17548 : : test_auth_zuc_cipher_null_test_case_1),
17549 : : TEST_CASE_ST(ut_setup, ut_teardown,
17550 : : test_verify_auth_zuc_cipher_null_test_case_1),
17551 : : /** AUTH NULL + CIPHER AES CTR */
17552 : : TEST_CASE_ST(ut_setup, ut_teardown,
17553 : : test_auth_null_cipher_aes_ctr_test_case_1),
17554 : : TEST_CASE_ST(ut_setup, ut_teardown,
17555 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
17556 : : /** AUTH AES CMAC + CIPHER NULL */
17557 : : TEST_CASE_ST(ut_setup, ut_teardown,
17558 : : test_auth_aes_cmac_cipher_null_test_case_1),
17559 : : TEST_CASE_ST(ut_setup, ut_teardown,
17560 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
17561 : : TEST_CASES_END()
17562 : : }
17563 : : };
17564 : :
17565 : : static int
17566 : 0 : run_cryptodev_testsuite(const char *pmd_name)
17567 : : {
17568 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
17569 : 0 : const enum blockcipher_test_type blk_suites[] = {
17570 : : BLKCIPHER_AES_CHAIN_TYPE,
17571 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
17572 : : BLKCIPHER_AES_DOCSIS_TYPE,
17573 : : BLKCIPHER_3DES_CHAIN_TYPE,
17574 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
17575 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
17576 : : BLKCIPHER_DES_DOCSIS_TYPE,
17577 : : BLKCIPHER_SM4_CHAIN_TYPE,
17578 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
17579 : : BLKCIPHER_AUTHONLY_TYPE};
17580 : 0 : struct unit_test_suite *static_suites[] = {
17581 : : &cryptodev_multi_session_testsuite,
17582 : : &cryptodev_null_testsuite,
17583 : : &cryptodev_aes_ccm_auth_testsuite,
17584 : : &cryptodev_aes_gcm_auth_testsuite,
17585 : : &cryptodev_aes_gmac_auth_testsuite,
17586 : : &cryptodev_snow3g_testsuite,
17587 : : &cryptodev_chacha20_poly1305_testsuite,
17588 : : &cryptodev_zuc_testsuite,
17589 : : &cryptodev_hmac_md5_auth_testsuite,
17590 : : &cryptodev_kasumi_testsuite,
17591 : : &cryptodev_esn_testsuite,
17592 : : &cryptodev_negative_aes_gcm_testsuite,
17593 : : &cryptodev_negative_aes_gmac_testsuite,
17594 : : &cryptodev_mixed_cipher_hash_testsuite,
17595 : : &cryptodev_negative_hmac_sha1_testsuite,
17596 : : &cryptodev_gen_testsuite,
17597 : : #ifdef RTE_LIB_SECURITY
17598 : : &ipsec_proto_testsuite,
17599 : : &pdcp_proto_testsuite,
17600 : : &docsis_proto_testsuite,
17601 : : #endif
17602 : : &end_testsuite
17603 : : };
17604 : : static struct unit_test_suite ts = {
17605 : : .suite_name = "Cryptodev Unit Test Suite",
17606 : : .setup = testsuite_setup,
17607 : : .teardown = testsuite_teardown,
17608 : : .unit_test_cases = {TEST_CASES_END()}
17609 : : };
17610 : :
17611 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
17612 : :
17613 [ # # ]: 0 : if (gbl_driver_id == -1) {
17614 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
17615 : 0 : return TEST_SKIPPED;
17616 : : }
17617 : :
17618 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
17619 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
17620 : :
17621 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
17622 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
17623 : 0 : ret = unit_test_suite_runner(&ts);
17624 : :
17625 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
17626 : 0 : free(ts.unit_test_suites);
17627 : 0 : return ret;
17628 : : }
17629 : :
17630 : : static int
17631 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
17632 : : {
17633 : : struct rte_cryptodev_info dev_info;
17634 : : uint8_t i, nb_devs;
17635 : : int driver_id;
17636 : :
17637 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
17638 [ # # ]: 0 : if (driver_id == -1) {
17639 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
17640 : 0 : return TEST_SKIPPED;
17641 : : }
17642 : :
17643 : 0 : nb_devs = rte_cryptodev_count();
17644 [ # # ]: 0 : if (nb_devs < 1) {
17645 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
17646 : 0 : return TEST_SKIPPED;
17647 : : }
17648 : :
17649 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
17650 : 0 : rte_cryptodev_info_get(i, &dev_info);
17651 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
17652 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
17653 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
17654 : : flag_name);
17655 : 0 : return TEST_SKIPPED;
17656 : : }
17657 : : return 0; /* found */
17658 : : }
17659 : : }
17660 : :
17661 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
17662 : 0 : return TEST_SKIPPED;
17663 : : }
17664 : :
17665 : : static int
17666 : 0 : test_cryptodev_qat(void)
17667 : : {
17668 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
17669 : : }
17670 : :
17671 : : static int
17672 : 0 : test_cryptodev_uadk(void)
17673 : : {
17674 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
17675 : : }
17676 : :
17677 : : static int
17678 : 0 : test_cryptodev_virtio(void)
17679 : : {
17680 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
17681 : : }
17682 : :
17683 : : static int
17684 : 0 : test_cryptodev_aesni_mb(void)
17685 : : {
17686 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17687 : : }
17688 : :
17689 : : static int
17690 : 0 : test_cryptodev_cpu_aesni_mb(void)
17691 : : {
17692 : : int32_t rc;
17693 : 0 : enum rte_security_session_action_type at = gbl_action_type;
17694 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
17695 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17696 : 0 : gbl_action_type = at;
17697 : 0 : return rc;
17698 : : }
17699 : :
17700 : : static int
17701 : 0 : test_cryptodev_chacha_poly_mb(void)
17702 : : {
17703 : : int32_t rc;
17704 : 0 : enum rte_security_session_action_type at = gbl_action_type;
17705 : 0 : rc = run_cryptodev_testsuite(
17706 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
17707 : 0 : gbl_action_type = at;
17708 : 0 : return rc;
17709 : : }
17710 : :
17711 : : static int
17712 : 0 : test_cryptodev_openssl(void)
17713 : : {
17714 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
17715 : : }
17716 : :
17717 : : static int
17718 : 0 : test_cryptodev_aesni_gcm(void)
17719 : : {
17720 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
17721 : : }
17722 : :
17723 : : static int
17724 : 0 : test_cryptodev_cpu_aesni_gcm(void)
17725 : : {
17726 : : int32_t rc;
17727 : 0 : enum rte_security_session_action_type at = gbl_action_type;
17728 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
17729 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
17730 : 0 : gbl_action_type = at;
17731 : 0 : return rc;
17732 : : }
17733 : :
17734 : : static int
17735 : 0 : test_cryptodev_mlx5(void)
17736 : : {
17737 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
17738 : : }
17739 : :
17740 : : static int
17741 : 0 : test_cryptodev_null(void)
17742 : : {
17743 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
17744 : : }
17745 : :
17746 : : static int
17747 : 0 : test_cryptodev_sw_snow3g(void)
17748 : : {
17749 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
17750 : : }
17751 : :
17752 : : static int
17753 : 0 : test_cryptodev_sw_kasumi(void)
17754 : : {
17755 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
17756 : : }
17757 : :
17758 : : static int
17759 : 0 : test_cryptodev_sw_zuc(void)
17760 : : {
17761 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
17762 : : }
17763 : :
17764 : : static int
17765 : 0 : test_cryptodev_armv8(void)
17766 : : {
17767 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
17768 : : }
17769 : :
17770 : : static int
17771 : 0 : test_cryptodev_mrvl(void)
17772 : : {
17773 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
17774 : : }
17775 : :
17776 : : #ifdef RTE_CRYPTO_SCHEDULER
17777 : :
17778 : : static int
17779 : 0 : test_cryptodev_scheduler(void)
17780 : : {
17781 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
17782 : 0 : const enum blockcipher_test_type blk_suites[] = {
17783 : : BLKCIPHER_AES_CHAIN_TYPE,
17784 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
17785 : : BLKCIPHER_AUTHONLY_TYPE
17786 : : };
17787 : : static struct unit_test_suite scheduler_multicore = {
17788 : : .suite_name = "Scheduler Multicore Unit Test Suite",
17789 : : .setup = scheduler_multicore_testsuite_setup,
17790 : : .teardown = scheduler_mode_testsuite_teardown,
17791 : : .unit_test_cases = {TEST_CASES_END()}
17792 : : };
17793 : : static struct unit_test_suite scheduler_round_robin = {
17794 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
17795 : : .setup = scheduler_roundrobin_testsuite_setup,
17796 : : .teardown = scheduler_mode_testsuite_teardown,
17797 : : .unit_test_cases = {TEST_CASES_END()}
17798 : : };
17799 : : static struct unit_test_suite scheduler_failover = {
17800 : : .suite_name = "Scheduler Failover Unit Test Suite",
17801 : : .setup = scheduler_failover_testsuite_setup,
17802 : : .teardown = scheduler_mode_testsuite_teardown,
17803 : : .unit_test_cases = {TEST_CASES_END()}
17804 : : };
17805 : : static struct unit_test_suite scheduler_pkt_size_distr = {
17806 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
17807 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
17808 : : .teardown = scheduler_mode_testsuite_teardown,
17809 : : .unit_test_cases = {TEST_CASES_END()}
17810 : : };
17811 : 0 : struct unit_test_suite *sched_mode_suites[] = {
17812 : : &scheduler_multicore,
17813 : : &scheduler_round_robin,
17814 : : &scheduler_failover,
17815 : : &scheduler_pkt_size_distr
17816 : : };
17817 : : static struct unit_test_suite scheduler_config = {
17818 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
17819 : : .unit_test_cases = {
17820 : : TEST_CASE(test_scheduler_attach_worker_op),
17821 : : TEST_CASE(test_scheduler_mode_multicore_op),
17822 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
17823 : : TEST_CASE(test_scheduler_mode_failover_op),
17824 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
17825 : : TEST_CASE(test_scheduler_detach_worker_op),
17826 : :
17827 : : TEST_CASES_END() /**< NULL terminate array */
17828 : : }
17829 : : };
17830 : 0 : struct unit_test_suite *static_suites[] = {
17831 : : &scheduler_config,
17832 : : &end_testsuite
17833 : : };
17834 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
17835 : : #ifdef RTE_LIB_SECURITY
17836 : : &docsis_proto_testsuite,
17837 : : #endif
17838 : : &end_testsuite
17839 : : };
17840 : : static struct unit_test_suite ts = {
17841 : : .suite_name = "Scheduler Unit Test Suite",
17842 : : .setup = scheduler_testsuite_setup,
17843 : : .teardown = testsuite_teardown,
17844 : : .unit_test_cases = {TEST_CASES_END()}
17845 : : };
17846 : :
17847 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
17848 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17849 : :
17850 [ # # ]: 0 : if (gbl_driver_id == -1) {
17851 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
17852 : 0 : return TEST_SKIPPED;
17853 : : }
17854 : :
17855 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
17856 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
17857 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
17858 : 0 : return TEST_SKIPPED;
17859 : : }
17860 : :
17861 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
17862 : : uint8_t blk_i = 0;
17863 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
17864 : : (struct unit_test_suite *) *
17865 : : (RTE_DIM(blk_suites) +
17866 : : RTE_DIM(sched_mode_static_suites) + 1));
17867 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
17868 : : blk_suites, RTE_DIM(blk_suites));
17869 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
17870 : : sched_mode_static_suites,
17871 : : RTE_DIM(sched_mode_static_suites));
17872 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
17873 : : }
17874 : :
17875 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
17876 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
17877 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
17878 : : RTE_DIM(sched_mode_suites));
17879 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
17880 : 0 : ret = unit_test_suite_runner(&ts);
17881 : :
17882 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
17883 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
17884 : : (*sched_mode_suites[sched_i]),
17885 : : RTE_DIM(blk_suites));
17886 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
17887 : : }
17888 : 0 : free(ts.unit_test_suites);
17889 : 0 : return ret;
17890 : : }
17891 : :
17892 : 235 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
17893 : :
17894 : : #endif
17895 : :
17896 : : static int
17897 : 0 : test_cryptodev_dpaa2_sec(void)
17898 : : {
17899 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
17900 : : }
17901 : :
17902 : : static int
17903 : 0 : test_cryptodev_dpaa_sec(void)
17904 : : {
17905 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
17906 : : }
17907 : :
17908 : : static int
17909 : 0 : test_cryptodev_ccp(void)
17910 : : {
17911 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
17912 : : }
17913 : :
17914 : : static int
17915 : 0 : test_cryptodev_octeontx(void)
17916 : : {
17917 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
17918 : : }
17919 : :
17920 : : static int
17921 : 0 : test_cryptodev_caam_jr(void)
17922 : : {
17923 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
17924 : : }
17925 : :
17926 : : static int
17927 : 0 : test_cryptodev_nitrox(void)
17928 : : {
17929 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
17930 : : }
17931 : :
17932 : : static int
17933 : 0 : test_cryptodev_bcmfs(void)
17934 : : {
17935 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
17936 : : }
17937 : :
17938 : : static int
17939 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
17940 : : {
17941 : : int ret;
17942 : :
17943 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
17944 [ # # ]: 0 : if (ret)
17945 : : return ret;
17946 : :
17947 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
17948 : 0 : ret = run_cryptodev_testsuite(pmd_name);
17949 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
17950 : :
17951 : 0 : return ret;
17952 : : }
17953 : :
17954 : : static int
17955 : 0 : test_cryptodev_qat_raw_api(void)
17956 : : {
17957 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
17958 : : }
17959 : :
17960 : : static int
17961 : 0 : test_cryptodev_cn9k(void)
17962 : : {
17963 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
17964 : : }
17965 : :
17966 : : static int
17967 : 0 : test_cryptodev_cn10k(void)
17968 : : {
17969 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
17970 : : }
17971 : :
17972 : : static int
17973 : 0 : test_cryptodev_cn10k_raw_api(void)
17974 : : {
17975 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
17976 : : }
17977 : :
17978 : : static int
17979 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
17980 : : {
17981 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
17982 : : }
17983 : :
17984 : : static int
17985 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
17986 : : {
17987 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
17988 : : }
17989 : :
17990 : 235 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
17991 : : test_cryptodev_cn10k_raw_api);
17992 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
17993 : : test_cryptodev_dpaa2_sec_raw_api);
17994 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
17995 : : test_cryptodev_dpaa_sec_raw_api);
17996 : 235 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
17997 : : test_cryptodev_qat_raw_api);
17998 : 235 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
17999 : 235 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
18000 : 235 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
18001 : : test_cryptodev_cpu_aesni_mb);
18002 : 235 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
18003 : : test_cryptodev_chacha_poly_mb);
18004 : 235 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
18005 : 235 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
18006 : 235 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
18007 : : test_cryptodev_cpu_aesni_gcm);
18008 : 235 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
18009 : 235 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
18010 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
18011 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
18012 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
18013 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
18014 : 235 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
18015 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
18016 : 235 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
18017 : 235 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
18018 : 235 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
18019 : 235 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
18020 : 235 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
18021 : 235 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
18022 : 235 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
18023 : 235 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
18024 : 235 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
18025 : 235 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
|